-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(cli): migrate from yargs to commander (#1216)
- Loading branch information
1 parent
e1edc05
commit 7ca5a28
Showing
4 changed files
with
27 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,32 @@ | ||
#!/usr/bin/env node | ||
|
||
import process from 'node:process'; | ||
|
||
import yargs from 'yargs/yargs'; | ||
import * as yargs_helpers from 'yargs/helpers'; | ||
import { program } from 'commander'; | ||
|
||
import nwbuild from './index.js'; | ||
|
||
const cli = yargs(yargs_helpers.hideBin(process.argv)) | ||
.version(false) | ||
.command('[srcDir] [options]') | ||
.option('mode', { | ||
type: 'string', | ||
description: '`get`, `run` or `build` application', | ||
choices: ['get', 'run', 'build'] | ||
}) | ||
.option('version', { | ||
type: 'string', | ||
description: 'NW.js version', | ||
}) | ||
.option('flavor', { | ||
type: 'string', | ||
description: 'NW.js build flavor', | ||
choices: ['normal', 'sdk'] | ||
}) | ||
.option('platform', { | ||
type: 'string', | ||
description: 'NW.js supported platform', | ||
choices: ['linux', 'osx', 'win'] | ||
}) | ||
.option('arch', { | ||
type: 'string', | ||
description: 'NW.js supported architecture', | ||
choices: ['ia32', 'x64', 'arm64'] | ||
}) | ||
.option('downloadUrl', { | ||
type: 'string', | ||
description: 'NW.js download server', | ||
}) | ||
.option('manifestUrl', { | ||
type: 'string', | ||
description: 'NW.js version info', | ||
}) | ||
.option('cacheDir', { | ||
type: 'string', | ||
description: 'Cache NW.js binaries', | ||
}) | ||
.option('outDir', { | ||
type: 'string', | ||
description: 'NW.js build artifacts', | ||
}) | ||
.option('app', { | ||
type: 'object', | ||
description: 'Platform specific app metadata. Refer to docs for more info', | ||
}) | ||
.option('cache', { | ||
type: 'boolean', | ||
description: 'Flag to enable/disable caching', | ||
}) | ||
.option('ffmpeg', { | ||
type: 'boolean', | ||
description: 'Flag to enable/disable downloading community ffmpeg', | ||
}) | ||
.option('glob', { | ||
type: 'boolean', | ||
description: 'Flag to enable/disable globbing', | ||
}) | ||
.option('logLevel', { | ||
type: 'string', | ||
description: 'Specify log level', | ||
choices: ['error', 'warn', 'info', 'debug'] | ||
}) | ||
.option('zip', { | ||
type: 'string', | ||
description: 'Flag to enable/disable compression', | ||
choices: ['zip', 'tar', 'tgz'] | ||
}) | ||
.option('managedManifest', { | ||
type: 'string', | ||
description: 'Managed manifest mode', | ||
}) | ||
.option('nodeAddon', { | ||
type: 'string', | ||
description: 'Download NW.js Node headers', | ||
choices: [false, 'gyp'] | ||
}) | ||
.strictOptions() | ||
.parse(); | ||
program | ||
.option('--mode', 'get, run or build mode') | ||
.option('--version', 'NW.js version') | ||
.option('--flavor', 'NW.js build flavor') | ||
.option('--platform', 'NW.js supported platform') | ||
.option('--arch', 'NW.js supported architecture') | ||
.option('--downloadUrl', 'NW.js download server') | ||
.option('--manifestUrl', 'NW.js version info') | ||
.option('--cacheDir', 'Cache NW.js binaries') | ||
.option('--outDir', 'NW.js build artifacts') | ||
.option('--app', 'Platform specific app metadata. Refer to docs for more info') | ||
.option('--cache', 'Flag to enable/disable caching') | ||
.option('--ffmpeg', 'Flag to enable/disable downloading community ffmpeg') | ||
.option('--glob', 'Flag to enable/disable globbing') | ||
.option('--logLevel', 'Specify log level') | ||
.option('--zip', 'Flag to enable/disable compression') | ||
.option('--managedManifest', 'Managed manifest mode') | ||
.option('--nodeAddon', 'Download NW.js Node headers'); | ||
|
||
program.parse(); | ||
|
||
nwbuild({ | ||
...cli, | ||
srcDir: cli._.join(' '), | ||
...program.opts(), | ||
srcDir: program.args.join(' '), | ||
cli: true, | ||
}); |