Build caxa binary

This commit is contained in:
Samuel Elliott 2022-03-13 20:01:29 +00:00
parent c0c138ef49
commit d750ed5a1f
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
5 changed files with 1904 additions and 6 deletions

2
bin/caxa Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env sh
"$(dirname "$0")/../node_modules/.bin/node" "$(dirname "$0")/nintendo-znc.js" $@

1890
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -15,12 +15,16 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"cli": "node bin/nintendo-znc.js",
"build-macos-linux": "caxa --input . --exclude src dist/bin data node_modules --prepare-command \"npm ci --production\" --output dist/bin/nintendo-znc -- \"{{caxa}}/node_modules/.bin/node\" \"{{caxa}}/bin/nintendo-znc.js\"",
"build-macosapp": "caxa --input . --exclude src dist/bin data node_modules --prepare-command \"npm ci --production\" --output dist/bin/nintendo-znc.app -- \"{{caxa}}/node_modules/.bin/node\" \"{{caxa}}/bin/nintendo-znc.js\" \"presence\"",
"build-windows": "caxa --input . --exclude src dist/bin data node_modules --prepare-command \"npm ci --production\" --output dist/bin/nintendo-znc.exe -- \"{{caxa}}/node_modules/.bin/node\" \"{{caxa}}/bin/nintendo-znc.js\"",
"start": "node bin/nintendo-znc.js presence"
},
"dependencies": {
"cli-table": "^0.3.11",
"debug": "^4.3.3",
"discord-rpc": "^4.0.1",
"env-paths": "^3.0.0",
"express": "^4.17.3",
"node-fetch": "^3.2.2",
"node-notifier": "^10.0.1",
@ -40,6 +44,7 @@
"@types/read": "^0.0.29",
"@types/uuid": "^8.3.4",
"@types/yargs": "^17.0.9",
"caxa": "^2.1.0",
"typescript": "^4.7.0-dev.20220308"
}
}

View File

@ -1,7 +1,6 @@
import * as path from 'path';
import createDebug from 'debug';
import Yargs from 'yargs';
import { YargsArguments } from './util.js';
import { paths, YargsArguments } from './util.js';
import * as commands from './cli/index.js';
const debug = createDebug('cli');
@ -9,7 +8,7 @@ const debug = createDebug('cli');
const yargs = Yargs(process.argv.slice(2)).option('data-path', {
describe: 'Data storage path',
type: 'string',
default: path.join(import.meta.url.substr(7), '..', '..', 'data'),
default: paths.data,
}).option('znc-proxy-url', {
describe: 'URL of Nintendo Switch Online app API proxy server to use',
type: 'string',

View File

@ -1,9 +1,9 @@
import * as yargs from 'yargs';
import * as yargstypes from '../node_modules/@types/yargs/index.js';
import type * as yargstypes from '../node_modules/@types/yargs/index.js';
import createDebug from 'debug';
import DiscordRPC from 'discord-rpc';
import persist from 'node-persist';
import * as path from 'path';
import getPaths from 'env-paths';
import { FlapgApiResponse } from './api/f.js';
import { NintendoAccountToken, NintendoAccountUser } from './api/na.js';
import { AccountLogin, CurrentUser, Game } from './api/znc-types.js';
@ -13,6 +13,8 @@ import ZncProxyApi from './api/znc-proxy.js';
const debug = createDebug('cli');
export const paths = getPaths('nintendo-znc');
export type YargsArguments<T extends yargs.Argv> = T extends yargs.Argv<infer R> ? R : any;
export type Argv<T = {}> = yargs.Argv<T>;
export type ArgumentsCamelCase<T = {}> = yargstypes.ArgumentsCamelCase<T>;
@ -30,7 +32,7 @@ export interface SavedToken {
proxy_url?: string;
}
export async function initStorage(dir = path.join(import.meta.url.substr(7), '..', '..', 'data')) {
export async function initStorage(dir: string) {
const storage = persist.create({
dir,
stringify: data => JSON.stringify(data, null, 4) + '\n',