mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-04-24 15:07:05 -05:00
Add a command to start the Electron app
This commit is contained in:
parent
3c66bbd95d
commit
b677b22809
|
|
@ -4,4 +4,4 @@ import createDebug from 'debug';
|
|||
|
||||
createDebug.log = console.warn.bind(console);
|
||||
|
||||
import('../dist/cli.js').then(cli => cli.default.argv);
|
||||
import('../dist/cli.js').then(cli => cli.main.call(null));
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import createDebug from 'debug';
|
|||
import Yargs from 'yargs';
|
||||
import dotenv from 'dotenv';
|
||||
import dotenvExpand from 'dotenv-expand';
|
||||
import { paths, YargsArguments } from './util.js';
|
||||
import { dev, paths, YargsArguments } from './util.js';
|
||||
import * as commands from './cli/index.js';
|
||||
|
||||
const debug = createDebug('cli');
|
||||
|
|
@ -26,6 +26,8 @@ const yargs = Yargs(process.argv.slice(2)).option('data-path', {
|
|||
export type Arguments = YargsArguments<typeof yargs>;
|
||||
|
||||
for (const command of Object.values(commands)) {
|
||||
if (command.command === 'app' && !dev) continue;
|
||||
|
||||
// @ts-expect-error
|
||||
yargs.command(command);
|
||||
}
|
||||
|
|
@ -38,3 +40,7 @@ yargs
|
|||
.showHelpOnFail(false, 'Specify --help for available options');
|
||||
|
||||
export default yargs;
|
||||
|
||||
export async function main() {
|
||||
yargs.argv;
|
||||
}
|
||||
|
|
|
|||
31
src/cli/app.ts
Normal file
31
src/cli/app.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import { createRequire } from 'module';
|
||||
import { execFileSync } from 'child_process';
|
||||
import createDebug from 'debug';
|
||||
import type { Arguments as ParentArguments } from '../cli.js';
|
||||
import { ArgumentsCamelCase, Argv, YargsArguments } from '../util.js';
|
||||
|
||||
const debug = createDebug('cli:app');
|
||||
|
||||
export const command = 'app';
|
||||
export const desc = 'Start the Electron app';
|
||||
|
||||
export function builder(yargs: Argv<ParentArguments>) {
|
||||
return yargs;
|
||||
}
|
||||
|
||||
type Arguments = YargsArguments<ReturnType<typeof builder>>;
|
||||
|
||||
export async function handler(argv: ArgumentsCamelCase<Arguments>) {
|
||||
const require = createRequire(import.meta.url);
|
||||
const electron = require('electron');
|
||||
|
||||
if (typeof electron !== 'string') {
|
||||
throw new Error('Already running in Electron??');
|
||||
}
|
||||
|
||||
execFileSync(electron, [
|
||||
'dist/app/main/app-entry.cjs',
|
||||
], {
|
||||
stdio: 'inherit',
|
||||
});
|
||||
}
|
||||
|
|
@ -3,3 +3,4 @@ export * as nso from './nso.js';
|
|||
export * as splatnet2 from './splatnet2.js';
|
||||
export * as pctl from './pctl.js';
|
||||
export * as androidZncaApiServerFrida from './android-znca-api-server-frida.js';
|
||||
export * as app from './app.js';
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user