diff --git a/README.md b/README.md index 5fef79bb..7324dfc8 100644 --- a/README.md +++ b/README.md @@ -375,7 +375,6 @@ nwbuild({ ### Features - feat(get): support canary releases -- feat(bld): rename MacOS Helper apps - feat(pkg): add `AppImage` installer - feat(pkg): add `NSIS` installer - feat(pkg): add `DMG` installer @@ -389,7 +388,6 @@ nwbuild({ - chore: annotate file paths as `fs.PathLike` instead of `string`. - chore(bld): factor out core build step - chore(bld): factor out linux config -- chore(bld): factor out macos config - chore(bld): factor out windows config - chore(bld): factor out native addon - chore(bld): factor out compressing diff --git a/package-lock.json b/package-lock.json index 9e9ea012..1c5503dc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,13 +12,13 @@ "dependencies": { "archiver": "^7.0.1", "axios": "^1.7.5", + "commander": "^12.1.0", "glob": "^11.0.0", "node-gyp": "^10.2.0", "plist": "^3.1.0", "resedit": "^2.0.2", "semver": "^7.6.3", "tar": "^7.4.3", - "yargs": "^17.7.2", "yauzl-promise": "^4.0.0" }, "bin": { @@ -2235,37 +2235,6 @@ "node": ">=6" } }, - "node_modules/cliui": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", - "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", - "license": "ISC", - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.1", - "wrap-ansi": "^7.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/cliui/node_modules/wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "license": "MIT", - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -2300,7 +2269,6 @@ "version": "12.1.0", "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz", "integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==", - "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -2664,15 +2632,6 @@ "@esbuild/win32-x64": "0.21.5" } }, - "node_modules/escalade": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", - "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/escape-string-regexp": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", @@ -3122,15 +3081,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "license": "ISC", - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, "node_modules/get-func-name": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.2.tgz", @@ -4717,15 +4667,6 @@ "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", "license": "MIT" }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/resedit": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/resedit/-/resedit-2.0.2.tgz", @@ -5855,48 +5796,12 @@ "node": ">=8.0" } }, - "node_modules/y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "license": "ISC", - "engines": { - "node": ">=10" - } - }, "node_modules/yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "license": "ISC" }, - "node_modules/yargs": { - "version": "17.7.2", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", - "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", - "license": "MIT", - "dependencies": { - "cliui": "^8.0.1", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.1.1" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/yargs/node_modules/yargs-parser": { - "version": "21.1.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", - "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", - "license": "ISC", - "engines": { - "node": ">=12" - } - }, "node_modules/yauzl-promise": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yauzl-promise/-/yauzl-promise-4.0.0.tgz", diff --git a/package.json b/package.json index 6b9320cc..9596b561 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,8 @@ "test": "vitest run --coverage", "test:cov": "vitest --coverage.enabled true", "demo:bld": "node ./tests/fixtures/demo.js", - "demo:exe": "./tests/fixtures/out/nwapp.app/Contents/MacOS/nwapp" + "demo:exe": "./tests/fixtures/out/nwapp.app/Contents/MacOS/nwapp", + "demo:cli": "nwbuild --mode run ./src ./app/**" }, "devDependencies": { "@eslint/js": "^9.9.1", @@ -63,13 +64,13 @@ "dependencies": { "archiver": "^7.0.1", "axios": "^1.7.5", + "commander": "^12.1.0", "glob": "^11.0.0", "node-gyp": "^10.2.0", "plist": "^3.1.0", "resedit": "^2.0.2", "semver": "^7.6.3", "tar": "^7.4.3", - "yargs": "^17.7.2", "yauzl-promise": "^4.0.0" }, "volta": { diff --git a/src/cli.js b/src/cli.js index b0dd33da..f9b7cb8a 100755 --- a/src/cli.js +++ b/src/cli.js @@ -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, });