@neon-rs/cli 0.0.165 → 0.0.167

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +389 -63
  2. package/package.json +8 -8
package/index.js CHANGED
@@ -10245,7 +10245,7 @@ function wrappy (fn, cb) {
10245
10245
 
10246
10246
  /***/ }),
10247
10247
 
10248
- /***/ 3236:
10248
+ /***/ 3235:
10249
10249
  /***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
10250
10250
 
10251
10251
 
@@ -10292,7 +10292,7 @@ function createInputStream(file) {
10292
10292
  return file ? (0,external_node_fs_namespaceObject.createReadStream)(file) : process.stdin;
10293
10293
  }
10294
10294
  class Dist {
10295
- static summary() { return 'Generate a .node file from a build.'; }
10295
+ static summary() { return 'Generate a binary .node file from a cargo output log.'; }
10296
10296
  static syntax() { return 'neon dist [-n <name>] [-f <dylib>|[-l <log>] [-m <path>]] [-o <dist>]'; }
10297
10297
  static options() {
10298
10298
  return [
@@ -10314,6 +10314,7 @@ class Dist {
10314
10314
  { name: 'cross-rs', summary: '<https://github.com/cross-rs/cross>' }
10315
10315
  ];
10316
10316
  }
10317
+ static extraSection() { }
10317
10318
  _log;
10318
10319
  _file;
10319
10320
  _mount;
@@ -11956,6 +11957,7 @@ class Bump {
11956
11957
  { name: 'npm version', summary: '<https://docs.npmjs.com/cli/commands/npm-version>' }
11957
11958
  ];
11958
11959
  }
11960
+ static extraSection() { }
11959
11961
  _verbose;
11960
11962
  _dir;
11961
11963
  _workspaces;
@@ -12027,9 +12029,13 @@ var temp = __nccwpck_require__(591);
12027
12029
  const rust_namespaceObject = JSON.parse('{"aarch64-apple-darwin":"darwin-arm64","x86_64-apple-darwin":"darwin-x64","aarch64-apple-ios":"ios-arm64","x86_64-apple-ios":"ios-x64","aarch64-linux-android":"android-arm64","armv7-linux-androideabi":"android-arm-eabi","i686-linux-android":"android-ia32","x86_64-linux-android":"android-x64","aarch64-pc-windows-msvc":"win32-arm64-msvc","i686-pc-windows-gnu":"win32-ia32-gnu","i686-pc-windows-msvc":"win32-ia32-msvc","x86_64-pc-windows-gnu":"win32-x64-gnu","x86_64-pc-windows-msvc":"win32-x64-msvc","aarch64-unknown-linux-gnu":"linux-arm64-gnu","aarch64-unknown-linux-musl":"linux-arm64-musl","arm-unknown-linux-gnueabihf":"linux-arm-gnueabihf","arm-unknown-linux-musleabihf":"linux-arm-musleabihf","armv7-unknown-linux-gnueabihf":"linux-arm-gnueabihf","armv7-unknown-linux-musleabihf":"linux-arm-musleabihf","i686-unknown-linux-gnu":"linux-ia32-gnu","i686-unknown-linux-musl":"linux-ia32-musl","mips-unknown-linux-gnu":"linux-mips-gnu","mips-unknown-linux-musl":"linux-mips-musl","mips64-unknown-linux-gnuabi64":"linux-mips64-gnuabi64","mips64-unknown-linux-muslabi64":"linux-mips64-muslabi64","mips64el-unknown-linux-gnuabi64":"linux-mips64el-gnuabi64","mips64el-unknown-linux-muslabi64":"linux-mips64el-muslabi64","mipsel-unknown-linux-gnu":"linux-mipsel-gnu","mipsel-unknown-linux-musl":"linux-mipsel-musl","powerpc-unknown-linux-gnu":"linux-powerpc-gnu","powerpc64-unknown-linux-gnu":"linux-powerpc64-gnu","powerpc64le-unknown-linux-gnu":"linux-powerpc64le-gnu","riscv64gc-unknown-linux-gnu":"linux-riscv64gc-gnu","s390x-unknown-linux-gnu":"linux-s390x-gnu","sparc64-unknown-linux-gnu":"linux-sparc64-gnu","x86_64-unknown-linux-gnu":"linux-x64-gnu","x86_64-unknown-linux-gnux32":"linux-x64-gnux32","x86_64-unknown-linux-musl":"linux-x64-musl","i686-unknown-freebsd":"freebsd-ia32","x86_64-unknown-freebsd":"freebsd-x64"}');
12028
12030
  ;// CONCATENATED MODULE: ./data/node.json
12029
12031
  const node_namespaceObject = JSON.parse('{"darwin-arm64":{"platform":"darwin","arch":"arm64","abi":null,"llvm":["aarch64-apple-darwin"]},"darwin-x64":{"platform":"darwin","arch":"x64","abi":null,"llvm":["x86_64-apple-darwin"]},"ios-arm64":{"platform":"ios","arch":"arm64","abi":null,"llvm":["aarch64-apple-ios"]},"ios-x64":{"platform":"ios","arch":"x64","abi":null,"llvm":["x86_64-apple-ios"]},"android-arm64":{"platform":"android","arch":"arm64","abi":null,"llvm":["aarch64-linux-android"]},"android-arm-eabi":{"platform":"android","arch":"arm","abi":"eabi","llvm":["armv7-linux-androideabi"]},"android-ia32":{"platform":"android","arch":"ia32","abi":null,"llvm":["i686-linux-android"]},"android-x64":{"platform":"android","arch":"x64","abi":null,"llvm":["x86_64-linux-android"]},"win32-arm64-msvc":{"platform":"win32","arch":"arm64","abi":"msvc","llvm":["aarch64-pc-windows-msvc"]},"win32-ia32-gnu":{"platform":"win32","arch":"ia32","abi":"gnu","llvm":["i686-pc-windows-gnu"]},"win32-ia32-msvc":{"platform":"win32","arch":"ia32","abi":"msvc","llvm":["i686-pc-windows-msvc"]},"win32-x64-gnu":{"platform":"win32","arch":"x64","abi":"gnu","llvm":["x86_64-pc-windows-gnu"]},"win32-x64-msvc":{"platform":"win32","arch":"x64","abi":"msvc","llvm":["x86_64-pc-windows-msvc"]},"linux-arm64-gnu":{"platform":"linux","arch":"arm64","abi":"gnu","llvm":["aarch64-unknown-linux-gnu"]},"linux-arm64-musl":{"platform":"linux","arch":"arm64","abi":"musl","llvm":["aarch64-unknown-linux-musl"]},"linux-arm-gnueabihf":{"platform":"linux","arch":"arm","abi":"gnueabihf","llvm":["arm-unknown-linux-gnueabihf","armv7-unknown-linux-gnueabihf"]},"linux-arm-musleabihf":{"platform":"linux","arch":"arm","abi":"musleabihf","llvm":["arm-unknown-linux-musleabihf","armv7-unknown-linux-musleabihf"]},"linux-ia32-gnu":{"platform":"linux","arch":"ia32","abi":"gnu","llvm":["i686-unknown-linux-gnu"]},"linux-ia32-musl":{"platform":"linux","arch":"ia32","abi":"musl","llvm":["i686-unknown-linux-musl"]},"linux-mips-gnu":{"platform":"linux","arch":"mips","abi":"gnu","llvm":["mips-unknown-linux-gnu"]},"linux-mips-musl":{"platform":"linux","arch":"mips","abi":"musl","llvm":["mips-unknown-linux-musl"]},"linux-mips64-gnuabi64":{"platform":"linux","arch":"mips64","abi":"gnuabi64","llvm":["mips64-unknown-linux-gnuabi64"]},"linux-mips64-muslabi64":{"platform":"linux","arch":"mips64","abi":"muslabi64","llvm":["mips64-unknown-linux-muslabi64"]},"linux-mips64el-gnuabi64":{"platform":"linux","arch":"mips64el","abi":"gnuabi64","llvm":["mips64el-unknown-linux-gnuabi64"]},"linux-mips64el-muslabi64":{"platform":"linux","arch":"mips64el","abi":"muslabi64","llvm":["mips64el-unknown-linux-muslabi64"]},"linux-mipsel-gnu":{"platform":"linux","arch":"mipsel","abi":"gnu","llvm":["mipsel-unknown-linux-gnu"]},"linux-mipsel-musl":{"platform":"linux","arch":"mipsel","abi":"musl","llvm":["mipsel-unknown-linux-musl"]},"linux-powerpc-gnu":{"platform":"linux","arch":"powerpc","abi":"gnu","llvm":["powerpc-unknown-linux-gnu"]},"linux-powerpc64-gnu":{"platform":"linux","arch":"powerpc64","abi":"gnu","llvm":["powerpc64-unknown-linux-gnu"]},"linux-powerpc64le-gnu":{"platform":"linux","arch":"powerpc64le","abi":"gnu","llvm":["powerpc64le-unknown-linux-gnu"]},"linux-riscv64gc-gnu":{"platform":"linux","arch":"riscv64gc","abi":"gnu","llvm":["riscv64gc-unknown-linux-gnu"]},"linux-s390x-gnu":{"platform":"linux","arch":"s390x","abi":"gnu","llvm":["s390x-unknown-linux-gnu"]},"linux-sparc64-gnu":{"platform":"linux","arch":"sparc64","abi":"gnu","llvm":["sparc64-unknown-linux-gnu"]},"linux-x64-gnu":{"platform":"linux","arch":"x64","abi":"gnu","llvm":["x86_64-unknown-linux-gnu"]},"linux-x64-gnux32":{"platform":"linux","arch":"x64","abi":"gnux32","llvm":["x86_64-unknown-linux-gnux32"]},"linux-x64-musl":{"platform":"linux","arch":"x64","abi":"musl","llvm":["x86_64-unknown-linux-musl"]},"freebsd-ia32":{"platform":"freebsd","arch":"ia32","abi":null,"llvm":["i686-unknown-freebsd"]},"freebsd-x64":{"platform":"freebsd","arch":"x64","abi":null,"llvm":["x86_64-unknown-freebsd"]}}');
12032
+ ;// CONCATENATED MODULE: ./data/family.json
12033
+ const family_namespaceObject = JSON.parse('{"windows":{"win32-x64-msvc":"x86_64-pc-windows-msvc"},"macos":{"darwin-x64":"x86_64-apple-darwin","darwin-arm64":"aarch64-apple-darwin"},"linux":{"linux-x64-gnu":"x86_64-unknown-linux-gnu","linux-arm-gnueabihf":"armv7-unknown-linux-gnueabihf"},"desktop":{"win32-x64-msvc":"x86_64-pc-windows-msvc","darwin-x64":"x86_64-apple-darwin","darwin-arm64":"aarch64-apple-darwin","linux-x64-gnu":"x86_64-unknown-linux-gnu"},"mobile":{"win32-arm64-msvc":"aarch64-pc-windows-msvc","linux-arm-gnueabihf":"armv7-unknown-linux-gnueabihf","android-arm-eabi":"armv7-linux-androideabi"},"common":["desktop"],"extended":["desktop","mobile"]}');
12030
12034
  ;// CONCATENATED MODULE: ./src/target.ts
12031
12035
 
12032
12036
 
12037
+
12038
+
12033
12039
  function isRustTarget(x) {
12034
12040
  return (typeof x === 'string') && (x in rust_namespaceObject);
12035
12041
  }
@@ -12046,6 +12052,31 @@ function assertIsNodeTarget(x) {
12046
12052
  throw new RangeError(`invalid Node target: ${x}`);
12047
12053
  }
12048
12054
  }
12055
+ function isTargetFamilyKey(x) {
12056
+ return (typeof x === 'string') && (x in family_namespaceObject);
12057
+ }
12058
+ function assertIsTargetFamilyKey(x) {
12059
+ if (!isTargetFamilyKey(x)) {
12060
+ throw new RangeError(`invalid target family name: ${x}`);
12061
+ }
12062
+ }
12063
+ function lookupTargetFamily(key) {
12064
+ return family_namespaceObject[key];
12065
+ }
12066
+ function merge(maps) {
12067
+ const merged = Object.create(null);
12068
+ for (const map of maps) {
12069
+ Object.assign(merged, map);
12070
+ }
12071
+ return merged;
12072
+ }
12073
+ function expandTargetFamily(family) {
12074
+ return isTargetFamilyKey(family)
12075
+ ? expandTargetFamily(lookupTargetFamily(family))
12076
+ : Array.isArray(family)
12077
+ ? merge(family.map(expandTargetFamily))
12078
+ : family;
12079
+ }
12049
12080
  function getTargetDescriptor(target) {
12050
12081
  const node = rust_namespaceObject[target];
12051
12082
  if (!isNodeTarget(node)) {
@@ -12064,11 +12095,39 @@ function getTargetDescriptor(target) {
12064
12095
  llvm: nodeDescriptor.llvm
12065
12096
  };
12066
12097
  }
12098
+ function node2Rust(target) {
12099
+ return node_namespaceObject[target].llvm.map(rt => {
12100
+ assertIsRustTarget(rt);
12101
+ return rt;
12102
+ });
12103
+ }
12104
+ function rust2Node(target) {
12105
+ const nt = rust_namespaceObject[target];
12106
+ assertIsNodeTarget(nt);
12107
+ return nt;
12108
+ }
12109
+ async function getCurrentTarget(log) {
12110
+ log(`rustc -vV`);
12111
+ const result = await execa("rustc", ["-vV"], { shell: true });
12112
+ if (result.exitCode !== 0) {
12113
+ throw new Error(`Could not determine current Rust target: ${result.stderr}`);
12114
+ }
12115
+ const hostLine = result.stdout.split(/\n/).find(line => line.startsWith('host:'));
12116
+ log(`found host line: ${hostLine}`);
12117
+ if (!hostLine) {
12118
+ throw new Error("Could not determine current Rust target (unexpected rustc output)");
12119
+ }
12120
+ const target = hostLine.replace(/^host:\s+/, '');
12121
+ log(`currentTarget result: "${target}"`);
12122
+ assertIsRustTarget(target);
12123
+ return target;
12124
+ }
12067
12125
 
12068
12126
  ;// CONCATENATED MODULE: ./src/manifest.ts
12069
12127
 
12070
12128
 
12071
12129
 
12130
+
12072
12131
  function assertIsObject(json, path) {
12073
12132
  if (!json || typeof json !== 'object') {
12074
12133
  throw new TypeError(`expected "${path}" property to be an object, found ${json}`);
@@ -12355,6 +12414,71 @@ class SourceManifest extends AbstractManifest {
12355
12414
  }
12356
12415
  return new BinaryManifest(json);
12357
12416
  }
12417
+ async addTargetPair(pair) {
12418
+ const { node, rust } = pair;
12419
+ const targets = this.cfg().targets;
12420
+ if (targets[node] === rust) {
12421
+ return null;
12422
+ }
12423
+ targets[node] = rust;
12424
+ await this.save();
12425
+ return pair;
12426
+ }
12427
+ async addNodeTarget(target) {
12428
+ const rt = node2Rust(target);
12429
+ if (rt.length > 1) {
12430
+ throw new Error(`multiple Rust targets found for Node target ${target}; please specify one of ${rt.join(', ')}`);
12431
+ }
12432
+ return await this.addTargetPair({ node: target, rust: rt[0] });
12433
+ }
12434
+ async addRustTarget(target) {
12435
+ return await this.addTargetPair({ node: rust2Node(target), rust: target });
12436
+ }
12437
+ async addTargets(family) {
12438
+ const targets = this.cfg().targets;
12439
+ let modified = [];
12440
+ for (const [key, value] of Object.entries(family)) {
12441
+ const node = key;
12442
+ const rust = value;
12443
+ if (targets[node] === rust) {
12444
+ continue;
12445
+ }
12446
+ targets[node] = rust;
12447
+ modified.push({ node, rust });
12448
+ }
12449
+ if (modified.length) {
12450
+ await this.save();
12451
+ }
12452
+ return modified;
12453
+ }
12454
+ async updateTargets(log, bundle) {
12455
+ const packages = this.packageNames();
12456
+ const specs = packages.map(name => `${name}@${this.version}`);
12457
+ log(`npm install --save-exact -O ${specs.join(' ')}`);
12458
+ const result = await execa('npm', ['install', '--save-exact', '-O', ...specs], { shell: true });
12459
+ if (result.exitCode !== 0) {
12460
+ log(`npm failed with exit code ${result.exitCode}`);
12461
+ console.error(result.stderr);
12462
+ process.exit(result.exitCode);
12463
+ }
12464
+ log(`package.json after: ${await promises_namespaceObject.readFile(external_node_path_namespaceObject.join(process.cwd(), "package.json"))}`);
12465
+ if (!bundle) {
12466
+ return;
12467
+ }
12468
+ const PREAMBLE = `// AUTOMATICALLY GENERATED FILE. DO NOT EDIT.
12469
+ //
12470
+ // This code is never executed but is detected by the static analysis of
12471
+ // bundlers such as \`@vercel/ncc\`. The require() expression that selects
12472
+ // the right binary module for the current platform is too dynamic to be
12473
+ // analyzable by bundler analyses, so this module provides an exhaustive
12474
+ // static list for those analyses.
12475
+
12476
+ if (0) {
12477
+ `;
12478
+ const requires = packages.map(name => ` require('${name}');`).join('\n');
12479
+ log(`generating bundler compatibility module at ${bundle}`);
12480
+ await promises_namespaceObject.writeFile(bundle, PREAMBLE + requires + '\n}\n');
12481
+ }
12358
12482
  }
12359
12483
  function upgradeSourceV1(object) {
12360
12484
  function splitSwap([key, value]) {
@@ -12392,7 +12516,7 @@ function upgradeBinaryV1(json) {
12392
12516
  };
12393
12517
  }
12394
12518
 
12395
- ;// CONCATENATED MODULE: ./src/commands/pack-build.ts
12519
+ ;// CONCATENATED MODULE: ./src/commands/tarball.ts
12396
12520
 
12397
12521
 
12398
12522
 
@@ -12401,16 +12525,16 @@ function upgradeBinaryV1(json) {
12401
12525
 
12402
12526
 
12403
12527
  const mktemp = temp.track().mkdir;
12404
- const pack_build_OPTIONS = [
12528
+ const tarball_OPTIONS = [
12405
12529
  { name: 'file', alias: 'f', type: String, defaultValue: 'index.node' },
12406
12530
  { name: 'target', alias: 't', type: String, defaultValue: null },
12407
12531
  { name: 'in-dir', alias: 'i', type: String, defaultValue: null },
12408
12532
  { name: 'out-dir', alias: 'o', type: String, defaultValue: null },
12409
12533
  { name: 'verbose', alias: 'v', type: Boolean, defaultValue: false },
12410
12534
  ];
12411
- class PackBuild {
12412
- static summary() { return 'Create an npm tarball from a prebuild.'; }
12413
- static syntax() { return 'neon pack-build [-f <addon>] [-t <target>] [-i <dir>] [-o <dir>] [-v]'; }
12535
+ class Tarball {
12536
+ static summary() { return 'Create an npm tarball from a binary .node file.'; }
12537
+ static syntax() { return 'neon tarball [-f <addon>] [-t <target>] [-i <dir>] [-o <dir>] [-v]'; }
12414
12538
  static options() {
12415
12539
  return [
12416
12540
  { name: '-f, --file <addon>', summary: 'Prebuilt .node file to pack. (Default: index.node)' },
@@ -12427,13 +12551,14 @@ class PackBuild {
12427
12551
  { name: 'cross-rs', summary: '<https://github.com/cross-rs/cross>' }
12428
12552
  ];
12429
12553
  }
12554
+ static extraSection() { }
12430
12555
  _target;
12431
12556
  _addon;
12432
12557
  _inDir;
12433
12558
  _outDir;
12434
12559
  _verbose;
12435
12560
  constructor(argv) {
12436
- const options = dist_default()(pack_build_OPTIONS, { argv });
12561
+ const options = dist_default()(tarball_OPTIONS, { argv });
12437
12562
  this._target = options.target || null;
12438
12563
  this._addon = options.file;
12439
12564
  this._inDir = options['in-dir'] || null;
@@ -12442,26 +12567,11 @@ class PackBuild {
12442
12567
  }
12443
12568
  log(msg) {
12444
12569
  if (this._verbose) {
12445
- console.error("[neon pack-build] " + msg);
12570
+ console.error("[neon tarball] " + msg);
12446
12571
  }
12447
12572
  }
12448
- async currentTarget() {
12449
- this.log(`rustc -vV`);
12450
- const result = await execa("rustc", ["-vV"], { shell: true });
12451
- if (result.exitCode !== 0) {
12452
- throw new Error(`Could not determine current Rust target: ${result.stderr}`);
12453
- }
12454
- const hostLine = result.stdout.split(/\n/).find(line => line.startsWith('host:'));
12455
- this.log(`found host line: ${hostLine}`);
12456
- if (!hostLine) {
12457
- throw new Error("Could not determine current Rust target (unexpected rustc output)");
12458
- }
12459
- const target = hostLine.replace(/^host:\s+/, '');
12460
- this.log(`currentTarget result: "${target}"`);
12461
- return target;
12462
- }
12463
12573
  async createTempDir(sourceManifest) {
12464
- const target = this._target || await this.currentTarget();
12574
+ const target = this._target || await getCurrentTarget(msg => this.log(msg));
12465
12575
  if (!isRustTarget(target)) {
12466
12576
  throw new Error(`Rust target ${target} not supported.`);
12467
12577
  }
@@ -12533,19 +12643,159 @@ class PackBuild {
12533
12643
  ;
12534
12644
  }
12535
12645
 
12536
- ;// CONCATENATED MODULE: ./src/commands/install-builds.ts
12646
+ ;// CONCATENATED MODULE: ./src/commands/add-target.ts
12537
12647
 
12538
12648
 
12539
12649
 
12540
12650
 
12541
12651
 
12542
- const install_builds_OPTIONS = [
12652
+ function optionArray(option) {
12653
+ return option == null ? [] : [option];
12654
+ }
12655
+ const add_target_OPTIONS = [
12543
12656
  { name: 'bundle', alias: 'b', type: String, defaultValue: null },
12657
+ { name: 'platform', alias: 'p', type: String, defaultValue: null },
12658
+ { name: 'arch', alias: 'a', type: String, defaultValue: null },
12659
+ { name: 'abi', type: String, defaultValue: null },
12660
+ { name: 'out-dir', alias: 'o', type: String, defaultValue: 'npm' },
12544
12661
  { name: 'verbose', alias: 'v', type: Boolean, defaultValue: false }
12545
12662
  ];
12546
- class InstallBuilds {
12547
- static summary() { return 'Install dependencies on prebuilds in package.json.'; }
12548
- static syntax() { return 'neon install-builds [-b <file>]'; }
12663
+ class AddTarget {
12664
+ static summary() { return 'Add a new build target to package.json.'; }
12665
+ static syntax() { return 'neon add-target [<t> | -p <p> -a <arch> [--abi <abi>]] [-o <d>] [-b <f>]'; }
12666
+ static options() {
12667
+ return [
12668
+ { name: '<t>', summary: 'Full target name, in either Node or Rust convention.' },
12669
+ {
12670
+ name: '',
12671
+ summary: 'This may be a target name in either Node or Rust convention, or one of the Neon target family presets described below. (Default: current target)'
12672
+ },
12673
+ { name: '-p, --platform <p>', summary: 'Target platform name. (Default: current platform)' },
12674
+ { name: '-a, --arch <arch>', summary: 'Target architecture name. (Default: current arch)' },
12675
+ { name: '--abi <abi>', summary: 'Target ABI name. (Default: current ABI)' },
12676
+ { name: '-o, --out-dir <d>', summary: 'Output directory for target template tree. (Default: npm)' },
12677
+ { name: '-b, --bundle <f>', summary: 'File to generate bundling metadata.' },
12678
+ {
12679
+ name: '',
12680
+ summary: 'This generated file ensures support for bundlers (e.g. @vercel/ncc), which rely on static analysis to detect and enable any addons used by the library.'
12681
+ },
12682
+ { name: '-v, --verbose', summary: 'Enable verbose logging. (Default: false)' }
12683
+ ];
12684
+ }
12685
+ static seeAlso() { }
12686
+ static extraSection() {
12687
+ return {
12688
+ title: 'Target Family Presets',
12689
+ details: [
12690
+ { name: 'linux', summary: 'Common desktop Linux targets.' },
12691
+ { name: 'macos', summary: 'Common desktop macOS targets.' },
12692
+ { name: 'windows', summary: 'Common desktop Windows targets.' },
12693
+ { name: 'mobile', summary: 'Common mobile and tablet targets.' },
12694
+ { name: 'desktop', summary: 'All common desktop targets.' },
12695
+ { name: 'common', summary: 'All common targets.' },
12696
+ { name: 'extended', summary: 'All supported targets.' }
12697
+ ]
12698
+ };
12699
+ }
12700
+ _platform;
12701
+ _arch;
12702
+ _abi;
12703
+ _target;
12704
+ _outDir;
12705
+ _bundle;
12706
+ _verbose;
12707
+ constructor(argv) {
12708
+ const options = dist_default()(add_target_OPTIONS, { argv, partial: true });
12709
+ this._platform = options.platform || null;
12710
+ this._arch = options.arch || null;
12711
+ this._abi = options.abi || null;
12712
+ this._outDir = options['out-dir'] || external_node_path_namespaceObject.join(process.cwd(), 'dist');
12713
+ this._bundle = options.bundle || null;
12714
+ this._verbose = !!options.verbose;
12715
+ if (options.platform && !options.arch) {
12716
+ throw new Error("Option --platform requires option --arch to be specified as well.");
12717
+ }
12718
+ if (!options.platform && options.arch) {
12719
+ throw new Error("Option --arch requires option --platform to be specified as well.");
12720
+ }
12721
+ if (options.abi && (!options.platform || !options.arch)) {
12722
+ throw new Error("Option --abi requires both options --platform and --arch to be specified as well.");
12723
+ }
12724
+ if (!options.platform && !options.arch && !options.abi) {
12725
+ if (!options._unknown || options._unknown.length === 0) {
12726
+ throw new Error("No arguments found, expected <target> or -p and -a options.");
12727
+ }
12728
+ this._target = options._unknown[0];
12729
+ }
12730
+ else {
12731
+ this._target = `${options.platform}-${options.arch}`;
12732
+ if (!!options.abi) {
12733
+ this._target = `${this._target}-${options.abi}`;
12734
+ }
12735
+ }
12736
+ }
12737
+ log(msg) {
12738
+ if (this._verbose) {
12739
+ console.error("[neon add-target] " + msg);
12740
+ }
12741
+ }
12742
+ async addTarget(sourceManifest) {
12743
+ if (!this._target) {
12744
+ this.log('adding default system target');
12745
+ return optionArray(await sourceManifest.addRustTarget(await getCurrentTarget(msg => this.log(msg))));
12746
+ }
12747
+ else if (isRustTarget(this._target)) {
12748
+ this.log(`adding Rust target ${this._target}`);
12749
+ return optionArray(await sourceManifest.addRustTarget(this._target));
12750
+ }
12751
+ else if (isNodeTarget(this._target)) {
12752
+ this.log(`adding Node target ${this._target}`);
12753
+ return optionArray(await sourceManifest.addNodeTarget(this._target));
12754
+ }
12755
+ else if (isTargetFamilyKey(this._target)) {
12756
+ return sourceManifest.addTargets(expandTargetFamily(this._target));
12757
+ }
12758
+ else {
12759
+ throw new Error(`unrecognized target ${this._target}`);
12760
+ }
12761
+ }
12762
+ async createTemplateTree(sourceManifest, pair) {
12763
+ const { node, rust } = pair;
12764
+ const binaryManifest = sourceManifest.manifestFor(rust);
12765
+ this.log(`prebuild manifest: ${binaryManifest.stringify()}`);
12766
+ const treeDir = external_node_path_namespaceObject.join(this._outDir, node);
12767
+ this.log(`creating ${treeDir}`);
12768
+ await promises_namespaceObject.mkdir(treeDir, { recursive: true });
12769
+ this.log(`created ${treeDir}`);
12770
+ this.log(`creating ${treeDir}/package.json`);
12771
+ await binaryManifest.save(treeDir);
12772
+ this.log(`creating ${treeDir}/README.md`);
12773
+ await promises_namespaceObject.writeFile(external_node_path_namespaceObject.join(treeDir, "README.md"), `# \`${binaryManifest.name}\`\n\n${binaryManifest.description}\n`);
12774
+ }
12775
+ async run() {
12776
+ this.log(`reading package.json`);
12777
+ const sourceManifest = await SourceManifest.load();
12778
+ this.log(`manifest: ${sourceManifest.stringify()}`);
12779
+ const modified = await this.addTarget(sourceManifest);
12780
+ if (modified.length) {
12781
+ sourceManifest.updateTargets(msg => this.log(msg), this._bundle);
12782
+ for (const pair of modified) {
12783
+ await this.createTemplateTree(sourceManifest, pair);
12784
+ }
12785
+ }
12786
+ }
12787
+ }
12788
+
12789
+ ;// CONCATENATED MODULE: ./src/commands/update-targets.ts
12790
+
12791
+
12792
+ const update_targets_OPTIONS = [
12793
+ { name: 'bundle', alias: 'b', type: String, defaultValue: null },
12794
+ { name: 'verbose', alias: 'v', type: Boolean, defaultValue: false }
12795
+ ];
12796
+ class UpdateTargets {
12797
+ static summary() { return 'Update dependencies for all build targets in package.json.'; }
12798
+ static syntax() { return 'neon update-targets [-b <file>]'; }
12549
12799
  static options() {
12550
12800
  return [
12551
12801
  { name: '-b, --bundle <file>', summary: 'File to generate bundling metadata.' },
@@ -12561,16 +12811,17 @@ class InstallBuilds {
12561
12811
  { name: 'ncc', summary: '<https://github.com/vercel/ncc>' }
12562
12812
  ];
12563
12813
  }
12814
+ static extraSection() { }
12564
12815
  _bundle;
12565
12816
  _verbose;
12566
12817
  constructor(argv) {
12567
- const options = dist_default()(install_builds_OPTIONS, { argv });
12818
+ const options = dist_default()(update_targets_OPTIONS, { argv });
12568
12819
  this._bundle = options.bundle || null;
12569
12820
  this._verbose = !!options.verbose;
12570
12821
  }
12571
12822
  log(msg) {
12572
12823
  if (this._verbose) {
12573
- console.error("[neon install-builds] " + msg);
12824
+ console.error("[neon update-targets] " + msg);
12574
12825
  }
12575
12826
  }
12576
12827
  async run() {
@@ -12579,36 +12830,91 @@ class InstallBuilds {
12579
12830
  const version = sourceManifest.version;
12580
12831
  this.log(`package.json before: ${sourceManifest.stringify()}`);
12581
12832
  this.log(`determined version: ${version}`);
12582
- const packages = sourceManifest.packageNames();
12583
- const specs = packages.map(name => `${name}@${version}`);
12584
12833
  if (sourceManifest.upgraded) {
12585
12834
  this.log(`upgrading manifest format`);
12586
12835
  await sourceManifest.save();
12587
12836
  }
12588
- this.log(`npm install --save-exact -O ${specs.join(' ')}`);
12589
- const result = await execa('npm', ['install', '--save-exact', '-O', ...specs], { shell: true });
12590
- if (result.exitCode !== 0) {
12591
- this.log(`npm failed with exit code ${result.exitCode}`);
12592
- console.error(result.stderr);
12593
- process.exit(result.exitCode);
12837
+ sourceManifest.updateTargets(msg => this.log(msg), this._bundle);
12838
+ }
12839
+ }
12840
+
12841
+ ;// CONCATENATED MODULE: ./src/commands/rust-target.ts
12842
+
12843
+
12844
+
12845
+ const rust_target_OPTIONS = [
12846
+ { name: 'platform', alias: 'p', type: String, defaultValue: null },
12847
+ { name: 'arch', alias: 'a', type: String, defaultValue: null },
12848
+ { name: 'abi', type: String, defaultValue: null },
12849
+ { name: 'verbose', alias: 'v', type: Boolean, defaultValue: false }
12850
+ ];
12851
+ class RustTarget {
12852
+ static summary() { return 'Look up the Rust target triple for a given build target.'; }
12853
+ static syntax() { return 'neon rust-target <target> | (-p <plat> -a <arch> [--abi <abi>])'; }
12854
+ static options() {
12855
+ return [
12856
+ { name: '<target>', summary: 'Full target name in Node convention.' },
12857
+ { name: '-p, --platform <plat>', summary: 'Target platform name.' },
12858
+ { name: '-a, --arch <arch>', summary: 'Target architecture name.' },
12859
+ { name: '--abi <abi>', summary: 'Target ABI name. (Default: null)' },
12860
+ { name: '-v, --verbose', summary: 'Enable verbose logging. (Default: false)' }
12861
+ ];
12862
+ }
12863
+ static seeAlso() { }
12864
+ static extraSection() { }
12865
+ _platform;
12866
+ _arch;
12867
+ _abi;
12868
+ _target;
12869
+ _verbose;
12870
+ constructor(argv) {
12871
+ const options = dist_default()(rust_target_OPTIONS, { argv, partial: true });
12872
+ this._platform = options.platform || null;
12873
+ this._arch = options.arch || null;
12874
+ this._abi = options.abi || null;
12875
+ this._verbose = !!options.verbose;
12876
+ if (options.platform && !options.arch) {
12877
+ throw new Error("Option --platform requires option --arch to be specified as well.");
12594
12878
  }
12595
- this.log(`package.json after: ${await promises_namespaceObject.readFile(external_node_path_namespaceObject.join(process.cwd(), "package.json"))}`);
12596
- if (!this._bundle) {
12597
- return;
12879
+ if (!options.platform && options.arch) {
12880
+ throw new Error("Option --arch requires option --platform to be specified as well.");
12881
+ }
12882
+ if (options.abi && (!options.platform || !options.arch)) {
12883
+ throw new Error("Option --abi requires both options --platform and --arch to be specified as well.");
12884
+ }
12885
+ let target;
12886
+ if (!options.platform && !options.arch && !options.abi) {
12887
+ if (!options._unknown || options._unknown.length === 0) {
12888
+ throw new Error("No arguments found, expected <target> or -p and -a options.");
12889
+ }
12890
+ target = options._unknown[0];
12891
+ }
12892
+ else {
12893
+ target = `${options.platform}-${options.arch}`;
12894
+ if (!!options.abi) {
12895
+ target = `${target}-${options.abi}`;
12896
+ }
12897
+ }
12898
+ if (!isNodeTarget(target)) {
12899
+ throw new Error(`${target} is not a valid Node target.`);
12900
+ }
12901
+ this._target = target;
12902
+ }
12903
+ log(msg) {
12904
+ if (this._verbose) {
12905
+ console.error("[neon rust-target] " + msg);
12598
12906
  }
12599
- const PREAMBLE = `// AUTOMATICALLY GENERATED FILE. DO NOT EDIT.
12600
- //
12601
- // This code is never executed but is detected by the static analysis of
12602
- // bundlers such as \`@vercel/ncc\`. The require() expression that selects
12603
- // the right binary module for the current platform is too dynamic to be
12604
- // analyzable by bundler analyses, so this module provides an exhaustive
12605
- // static list for those analyses.
12606
-
12607
- if (0) {
12608
- `;
12609
- const requires = packages.map(name => ` require('${name}');`).join('\n');
12610
- this.log(`generating bundler compatibility module at ${this._bundle}`);
12611
- await promises_namespaceObject.writeFile(this._bundle, PREAMBLE + requires + '\n}\n');
12907
+ }
12908
+ async run() {
12909
+ this.log(`reading package.json`);
12910
+ const sourceManifest = await SourceManifest.load();
12911
+ this.log(`manifest: ${sourceManifest.stringify()}`);
12912
+ const targets = sourceManifest.cfg().targets;
12913
+ const rust = targets[this._target];
12914
+ if (!rust) {
12915
+ throw new Error(`no Rust target found for ${this._target}`);
12916
+ }
12917
+ console.log(rust);
12612
12918
  }
12613
12919
  }
12614
12920
 
@@ -12626,6 +12932,7 @@ class Help {
12626
12932
  ];
12627
12933
  }
12628
12934
  static seeAlso() { }
12935
+ static extraSection() { }
12629
12936
  _name;
12630
12937
  constructor(argv) {
12631
12938
  this._name = argv.length > 0 ? asCommandName(argv[0]) : undefined;
@@ -12649,13 +12956,19 @@ class Help {
12649
12956
 
12650
12957
 
12651
12958
 
12959
+
12960
+
12652
12961
  var CommandName;
12653
12962
  (function (CommandName) {
12654
12963
  CommandName["Help"] = "help";
12655
12964
  CommandName["Dist"] = "dist";
12656
12965
  CommandName["Bump"] = "bump";
12657
12966
  CommandName["PackBuild"] = "pack-build";
12967
+ CommandName["Tarball"] = "tarball";
12968
+ CommandName["AddTarget"] = "add-target";
12658
12969
  CommandName["InstallBuilds"] = "install-builds";
12970
+ CommandName["UpdateTargets"] = "update-targets";
12971
+ CommandName["RustTarget"] = "rust-target";
12659
12972
  })(CommandName || (CommandName = {}));
12660
12973
  ;
12661
12974
  function isCommandName(s) {
@@ -12672,8 +12985,12 @@ const COMMANDS = {
12672
12985
  [CommandName.Help]: Help,
12673
12986
  [CommandName.Dist]: Dist,
12674
12987
  [CommandName.Bump]: Bump,
12675
- [CommandName.PackBuild]: PackBuild,
12676
- [CommandName.InstallBuilds]: InstallBuilds
12988
+ [CommandName.PackBuild]: Tarball,
12989
+ [CommandName.Tarball]: Tarball,
12990
+ [CommandName.AddTarget]: AddTarget,
12991
+ [CommandName.InstallBuilds]: UpdateTargets,
12992
+ [CommandName.UpdateTargets]: UpdateTargets,
12993
+ [CommandName.RustTarget]: RustTarget
12677
12994
  };
12678
12995
  function commandFor(name) {
12679
12996
  return COMMANDS[name];
@@ -12683,8 +13000,10 @@ function summaries() {
12683
13000
  { name: CommandName.Help, summary: Help.summary() },
12684
13001
  { name: CommandName.Dist, summary: Dist.summary() },
12685
13002
  { name: CommandName.Bump, summary: Bump.summary() },
12686
- { name: CommandName.PackBuild, summary: PackBuild.summary() },
12687
- { name: CommandName.InstallBuilds, summary: InstallBuilds.summary() }
13003
+ { name: CommandName.Tarball, summary: Tarball.summary() },
13004
+ { name: CommandName.AddTarget, summary: AddTarget.summary() },
13005
+ { name: CommandName.UpdateTargets, summary: UpdateTargets.summary() },
13006
+ { name: CommandName.RustTarget, summary: RustTarget.summary() }
12688
13007
  ];
12689
13008
  }
12690
13009
 
@@ -12698,7 +13017,7 @@ __nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __we
12698
13017
  /* harmony import */ var command_line_commands__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(5046);
12699
13018
  /* harmony import */ var command_line_commands__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(command_line_commands__WEBPACK_IMPORTED_MODULE_0__);
12700
13019
  /* harmony import */ var _print_js__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(9050);
12701
- /* harmony import */ var _command_js__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(3236);
13020
+ /* harmony import */ var _command_js__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(3235);
12702
13021
  /* harmony import */ var node_module__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(2033);
12703
13022
  /* harmony import */ var node_module__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__nccwpck_require__.n(node_module__WEBPACK_IMPORTED_MODULE_3__);
12704
13023
 
@@ -15721,8 +16040,8 @@ const chalkStderr = createChalk({level: stderrColor ? stderrColor.level : 0});
15721
16040
 
15722
16041
  /* harmony default export */ const chalk_source = (chalk);
15723
16042
 
15724
- // EXTERNAL MODULE: ./src/command.ts + 36 modules
15725
- var command = __nccwpck_require__(3236);
16043
+ // EXTERNAL MODULE: ./src/command.ts + 39 modules
16044
+ var command = __nccwpck_require__(3235);
15726
16045
  ;// CONCATENATED MODULE: ./src/print.ts
15727
16046
 
15728
16047
 
@@ -15739,6 +16058,9 @@ function yellow(text) {
15739
16058
  function green(text) {
15740
16059
  return chalk_source.bold.greenBright(text);
15741
16060
  }
16061
+ function purple(text) {
16062
+ return chalk_source.bold.magentaBright(text);
16063
+ }
15742
16064
  function commandUsage(name, command) {
15743
16065
  const sections = [
15744
16066
  {
@@ -15758,6 +16080,10 @@ function commandUsage(name, command) {
15758
16080
  if (seeAlso) {
15759
16081
  sections.push({ header: green('See Also:'), content: seeAlso });
15760
16082
  }
16083
+ const extraSection = command.extraSection();
16084
+ if (extraSection) {
16085
+ sections.push({ header: purple(extraSection.title + ':'), content: extraSection.details });
16086
+ }
15761
16087
  return command_line_usage(sections).trimStart();
15762
16088
  }
15763
16089
  function mainUsage() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neon-rs/cli",
3
- "version": "0.0.165",
3
+ "version": "0.0.167",
4
4
  "description": "Command-line build tool for Neon modules.",
5
5
  "type": "module",
6
6
  "exports": "./index.js",
@@ -27,12 +27,12 @@
27
27
  },
28
28
  "homepage": "https://github.com/dherman/neon-rs#readme",
29
29
  "optionalDependencies": {
30
- "@cargo-messages/android-arm-eabi": "0.0.165",
31
- "@cargo-messages/darwin-arm64": "0.0.165",
32
- "@cargo-messages/darwin-x64": "0.0.165",
33
- "@cargo-messages/linux-arm-gnueabihf": "0.0.165",
34
- "@cargo-messages/linux-x64-gnu": "0.0.165",
35
- "@cargo-messages/win32-arm64-msvc": "0.0.165",
36
- "@cargo-messages/win32-x64-msvc": "0.0.165"
30
+ "@cargo-messages/android-arm-eabi": "0.0.167",
31
+ "@cargo-messages/darwin-arm64": "0.0.167",
32
+ "@cargo-messages/darwin-x64": "0.0.167",
33
+ "@cargo-messages/linux-arm-gnueabihf": "0.0.167",
34
+ "@cargo-messages/linux-x64-gnu": "0.0.167",
35
+ "@cargo-messages/win32-arm64-msvc": "0.0.167",
36
+ "@cargo-messages/win32-x64-msvc": "0.0.167"
37
37
  }
38
38
  }