@neon-rs/cli 0.0.166 → 0.0.168

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 +256 -29
  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
- /***/ 1217:
10248
+ /***/ 3235:
10249
10249
  /***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
10250
10250
 
10251
10251
 
@@ -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,10 +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
 
12033
12037
 
12038
+
12034
12039
  function isRustTarget(x) {
12035
12040
  return (typeof x === 'string') && (x in rust_namespaceObject);
12036
12041
  }
@@ -12047,6 +12052,31 @@ function assertIsNodeTarget(x) {
12047
12052
  throw new RangeError(`invalid Node target: ${x}`);
12048
12053
  }
12049
12054
  }
12055
+ function isTargetPreset(x) {
12056
+ return (typeof x === 'string') && (x in family_namespaceObject);
12057
+ }
12058
+ function assertIsTargetPreset(x) {
12059
+ if (!isTargetPreset(x)) {
12060
+ throw new RangeError(`invalid target family preset: ${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 isTargetPreset(family)
12075
+ ? expandTargetFamily(lookupTargetFamily(family))
12076
+ : Array.isArray(family)
12077
+ ? merge(family.map(expandTargetFamily))
12078
+ : family;
12079
+ }
12050
12080
  function getTargetDescriptor(target) {
12051
12081
  const node = rust_namespaceObject[target];
12052
12082
  if (!isNodeTarget(node)) {
@@ -12145,6 +12175,19 @@ function assertIsTargetMap(json, path) {
12145
12175
  }
12146
12176
  }
12147
12177
  }
12178
+ function assertIsTargetFamily(json, path) {
12179
+ if (typeof json === 'string') {
12180
+ assertIsTargetPreset(json);
12181
+ return;
12182
+ }
12183
+ if (Array.isArray(json)) {
12184
+ for (const elt of json) {
12185
+ assertIsTargetPreset(elt);
12186
+ }
12187
+ return;
12188
+ }
12189
+ assertIsTargetMap(json, path);
12190
+ }
12148
12191
  function assertIsBinaryV1(json) {
12149
12192
  assertHasProps(['binary'], json, "neon");
12150
12193
  const binary = json.binary;
@@ -12188,7 +12231,7 @@ function assertIsSourceCfg(json) {
12188
12231
  if (typeof json.org !== 'string') {
12189
12232
  throw new TypeError(`expected "neon.org" to be a string, found ${json.org}`);
12190
12233
  }
12191
- assertIsTargetMap(json.targets, "neon.targets");
12234
+ assertIsTargetFamily(json.targets, "neon.targets");
12192
12235
  }
12193
12236
  function assertIsPreamble(json) {
12194
12237
  if (!json || typeof json !== 'object') {
@@ -12325,11 +12368,13 @@ function normalizeSourceCfg(json) {
12325
12368
  }
12326
12369
  class SourceManifest extends AbstractManifest {
12327
12370
  _sourceJSON;
12371
+ _expandedTargets;
12328
12372
  constructor(json) {
12329
12373
  super(json);
12330
12374
  this._upgraded = normalizeSourceCfg(this._json);
12331
12375
  assertHasSourceCfg(this._json);
12332
12376
  this._sourceJSON = this._json;
12377
+ this._expandedTargets = expandTargetFamily(this._sourceJSON.neon.targets);
12333
12378
  }
12334
12379
  static async load(dir) {
12335
12380
  return new SourceManifest(await readManifest(dir));
@@ -12339,18 +12384,21 @@ class SourceManifest extends AbstractManifest {
12339
12384
  }
12340
12385
  packageNames() {
12341
12386
  const cfg = this.cfg();
12342
- return Object.keys(cfg.targets).map(key => `${cfg.org}/${key}`);
12387
+ return Object.keys(this._expandedTargets).map(key => `${cfg.org}/${key}`);
12343
12388
  }
12344
12389
  packageFor(target) {
12345
12390
  const cfg = this.cfg();
12346
- for (const key in cfg.targets) {
12347
- const value = cfg.targets[key];
12391
+ for (const key in this._expandedTargets) {
12392
+ const value = this._expandedTargets[key];
12348
12393
  if (value === target) {
12349
12394
  return `${cfg.org}/${key}`;
12350
12395
  }
12351
12396
  }
12352
12397
  return undefined;
12353
12398
  }
12399
+ rustTargetFor(node) {
12400
+ return this._expandedTargets[node];
12401
+ }
12354
12402
  manifestFor(target) {
12355
12403
  const targetInfo = getTargetDescriptor(target);
12356
12404
  const name = this.packageFor(target);
@@ -12384,24 +12432,62 @@ class SourceManifest extends AbstractManifest {
12384
12432
  }
12385
12433
  return new BinaryManifest(json);
12386
12434
  }
12387
- async addTargetPair(node, rust) {
12388
- const targets = this.cfg().targets;
12389
- if (targets[node] === rust) {
12390
- return false;
12435
+ async addTargetPair(pair) {
12436
+ const { node, rust } = pair;
12437
+ if (this._expandedTargets[node] === rust) {
12438
+ return null;
12391
12439
  }
12392
- targets[node] = rust;
12440
+ this._expandedTargets[node] = rust;
12393
12441
  await this.save();
12394
- return true;
12442
+ return pair;
12395
12443
  }
12396
12444
  async addNodeTarget(target) {
12397
12445
  const rt = node2Rust(target);
12398
12446
  if (rt.length > 1) {
12399
12447
  throw new Error(`multiple Rust targets found for Node target ${target}; please specify one of ${rt.join(', ')}`);
12400
12448
  }
12401
- return await this.addTargetPair(target, rt[0]);
12449
+ return await this.addTargetPair({ node: target, rust: rt[0] });
12402
12450
  }
12403
12451
  async addRustTarget(target) {
12404
- return await this.addTargetPair(rust2Node(target), target);
12452
+ return await this.addTargetPair({ node: rust2Node(target), rust: target });
12453
+ }
12454
+ filterNewTargets(family) {
12455
+ let newTargets = [];
12456
+ for (const [key, value] of Object.entries(family)) {
12457
+ const node = key;
12458
+ const rust = value;
12459
+ if (this._expandedTargets[node] === rust) {
12460
+ continue;
12461
+ }
12462
+ newTargets.push({ node, rust });
12463
+ }
12464
+ return newTargets;
12465
+ }
12466
+ async addTargets(family, opts = {}) {
12467
+ let newTargets = this.filterNewTargets(family);
12468
+ if (!newTargets.length) {
12469
+ return [];
12470
+ }
12471
+ for (const { node, rust } of newTargets) {
12472
+ if (opts.targetsSrc) {
12473
+ opts.targetsSrc[node] = rust;
12474
+ }
12475
+ this._expandedTargets[node] = rust;
12476
+ }
12477
+ await this.save();
12478
+ return newTargets;
12479
+ }
12480
+ async addTargetPreset(preset) {
12481
+ const targetsSrc = this.cfg().targets;
12482
+ if (typeof targetsSrc === 'string') {
12483
+ this.cfg().targets = [targetsSrc, preset];
12484
+ return this.addTargets(expandTargetFamily(preset));
12485
+ }
12486
+ if (Array.isArray(targetsSrc)) {
12487
+ targetsSrc.push(preset);
12488
+ return this.addTargets(expandTargetFamily(preset));
12489
+ }
12490
+ return this.addTargets(expandTargetFamily(preset), { targetsSrc });
12405
12491
  }
12406
12492
  async updateTargets(log, bundle) {
12407
12493
  const packages = this.packageNames();
@@ -12503,6 +12589,7 @@ class Tarball {
12503
12589
  { name: 'cross-rs', summary: '<https://github.com/cross-rs/cross>' }
12504
12590
  ];
12505
12591
  }
12592
+ static extraSection() { }
12506
12593
  _target;
12507
12594
  _addon;
12508
12595
  _inDir;
@@ -12598,23 +12685,34 @@ class Tarball {
12598
12685
 
12599
12686
 
12600
12687
 
12688
+
12689
+
12690
+ function optionArray(option) {
12691
+ return option == null ? [] : [option];
12692
+ }
12601
12693
  const add_target_OPTIONS = [
12602
12694
  { name: 'bundle', alias: 'b', type: String, defaultValue: null },
12603
12695
  { name: 'platform', alias: 'p', type: String, defaultValue: null },
12604
12696
  { name: 'arch', alias: 'a', type: String, defaultValue: null },
12605
12697
  { name: 'abi', type: String, defaultValue: null },
12698
+ { name: 'out-dir', alias: 'o', type: String, defaultValue: 'npm' },
12606
12699
  { name: 'verbose', alias: 'v', type: Boolean, defaultValue: false }
12607
12700
  ];
12608
12701
  class AddTarget {
12609
12702
  static summary() { return 'Add a new build target to package.json.'; }
12610
- static syntax() { return 'neon add-target [<target> | -p <plat> -a <arch> [--abi <abi>]] [-b <file>]'; }
12703
+ static syntax() { return 'neon add-target [<t> | -p <p> -a <arch> [--abi <abi>]] [-o <d>] [-b <f>]'; }
12611
12704
  static options() {
12612
12705
  return [
12613
- { name: '<target>', summary: 'Full target name, in either Node or Rust convention. (Default: current target)' },
12614
- { name: '-p, --platform <plat>', summary: 'Target platform name. (Default: current platform)' },
12706
+ { name: '<t>', summary: 'Full target name, in either Node or Rust convention.' },
12707
+ {
12708
+ name: '',
12709
+ 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)'
12710
+ },
12711
+ { name: '-p, --platform <p>', summary: 'Target platform name. (Default: current platform)' },
12615
12712
  { name: '-a, --arch <arch>', summary: 'Target architecture name. (Default: current arch)' },
12616
12713
  { name: '--abi <abi>', summary: 'Target ABI name. (Default: current ABI)' },
12617
- { name: '-b, --bundle <file>', summary: 'File to generate bundling metadata.' },
12714
+ { name: '-o, --out-dir <d>', summary: 'Output directory for target template tree. (Default: npm)' },
12715
+ { name: '-b, --bundle <f>', summary: 'File to generate bundling metadata.' },
12618
12716
  {
12619
12717
  name: '',
12620
12718
  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.'
@@ -12622,13 +12720,26 @@ class AddTarget {
12622
12720
  { name: '-v, --verbose', summary: 'Enable verbose logging. (Default: false)' }
12623
12721
  ];
12624
12722
  }
12625
- static seeAlso() {
12626
- return [];
12723
+ static seeAlso() { }
12724
+ static extraSection() {
12725
+ return {
12726
+ title: 'Target Family Presets',
12727
+ details: [
12728
+ { name: 'linux', summary: 'Common desktop Linux targets.' },
12729
+ { name: 'macos', summary: 'Common desktop macOS targets.' },
12730
+ { name: 'windows', summary: 'Common desktop Windows targets.' },
12731
+ { name: 'mobile', summary: 'Common mobile and tablet targets.' },
12732
+ { name: 'desktop', summary: 'All common desktop targets.' },
12733
+ { name: 'common', summary: 'All common targets.' },
12734
+ { name: 'extended', summary: 'All supported targets.' }
12735
+ ]
12736
+ };
12627
12737
  }
12628
12738
  _platform;
12629
12739
  _arch;
12630
12740
  _abi;
12631
12741
  _target;
12742
+ _outDir;
12632
12743
  _bundle;
12633
12744
  _verbose;
12634
12745
  constructor(argv) {
@@ -12636,6 +12747,7 @@ class AddTarget {
12636
12747
  this._platform = options.platform || null;
12637
12748
  this._arch = options.arch || null;
12638
12749
  this._abi = options.abi || null;
12750
+ this._outDir = options['out-dir'] || external_node_path_namespaceObject.join(process.cwd(), 'dist');
12639
12751
  this._bundle = options.bundle || null;
12640
12752
  this._verbose = !!options.verbose;
12641
12753
  if (options.platform && !options.arch) {
@@ -12654,7 +12766,10 @@ class AddTarget {
12654
12766
  this._target = options._unknown[0];
12655
12767
  }
12656
12768
  else {
12657
- this._target = null;
12769
+ this._target = `${options.platform}-${options.arch}`;
12770
+ if (!!options.abi) {
12771
+ this._target = `${this._target}-${options.abi}`;
12772
+ }
12658
12773
  }
12659
12774
  }
12660
12775
  log(msg) {
@@ -12665,26 +12780,46 @@ class AddTarget {
12665
12780
  async addTarget(sourceManifest) {
12666
12781
  if (!this._target) {
12667
12782
  this.log('adding default system target');
12668
- return sourceManifest.addRustTarget(await getCurrentTarget(msg => this.log(msg)));
12783
+ return optionArray(await sourceManifest.addRustTarget(await getCurrentTarget(msg => this.log(msg))));
12669
12784
  }
12670
12785
  else if (isRustTarget(this._target)) {
12671
12786
  this.log(`adding Rust target ${this._target}`);
12672
- return sourceManifest.addRustTarget(this._target);
12787
+ return optionArray(await sourceManifest.addRustTarget(this._target));
12673
12788
  }
12674
12789
  else if (isNodeTarget(this._target)) {
12675
12790
  this.log(`adding Node target ${this._target}`);
12676
- return sourceManifest.addNodeTarget(this._target);
12791
+ return optionArray(await sourceManifest.addNodeTarget(this._target));
12792
+ }
12793
+ else if (isTargetPreset(this._target)) {
12794
+ return sourceManifest.addTargetPreset(this._target);
12677
12795
  }
12678
12796
  else {
12679
12797
  throw new Error(`unrecognized target ${this._target}`);
12680
12798
  }
12681
12799
  }
12800
+ async createTemplateTree(sourceManifest, pair) {
12801
+ const { node, rust } = pair;
12802
+ const binaryManifest = sourceManifest.manifestFor(rust);
12803
+ this.log(`prebuild manifest: ${binaryManifest.stringify()}`);
12804
+ const treeDir = external_node_path_namespaceObject.join(this._outDir, node);
12805
+ this.log(`creating ${treeDir}`);
12806
+ await promises_namespaceObject.mkdir(treeDir, { recursive: true });
12807
+ this.log(`created ${treeDir}`);
12808
+ this.log(`creating ${treeDir}/package.json`);
12809
+ await binaryManifest.save(treeDir);
12810
+ this.log(`creating ${treeDir}/README.md`);
12811
+ await promises_namespaceObject.writeFile(external_node_path_namespaceObject.join(treeDir, "README.md"), `# \`${binaryManifest.name}\`\n\n${binaryManifest.description}\n`);
12812
+ }
12682
12813
  async run() {
12683
12814
  this.log(`reading package.json`);
12684
12815
  const sourceManifest = await SourceManifest.load();
12685
12816
  this.log(`manifest: ${sourceManifest.stringify()}`);
12686
- if (await this.addTarget(sourceManifest)) {
12817
+ const modified = await this.addTarget(sourceManifest);
12818
+ if (modified.length) {
12687
12819
  sourceManifest.updateTargets(msg => this.log(msg), this._bundle);
12820
+ for (const pair of modified) {
12821
+ await this.createTemplateTree(sourceManifest, pair);
12822
+ }
12688
12823
  }
12689
12824
  }
12690
12825
  }
@@ -12714,6 +12849,7 @@ class UpdateTargets {
12714
12849
  { name: 'ncc', summary: '<https://github.com/vercel/ncc>' }
12715
12850
  ];
12716
12851
  }
12852
+ static extraSection() { }
12717
12853
  _bundle;
12718
12854
  _verbose;
12719
12855
  constructor(argv) {
@@ -12740,6 +12876,85 @@ class UpdateTargets {
12740
12876
  }
12741
12877
  }
12742
12878
 
12879
+ ;// CONCATENATED MODULE: ./src/commands/rust-target.ts
12880
+
12881
+
12882
+
12883
+ const rust_target_OPTIONS = [
12884
+ { name: 'platform', alias: 'p', type: String, defaultValue: null },
12885
+ { name: 'arch', alias: 'a', type: String, defaultValue: null },
12886
+ { name: 'abi', type: String, defaultValue: null },
12887
+ { name: 'verbose', alias: 'v', type: Boolean, defaultValue: false }
12888
+ ];
12889
+ class RustTarget {
12890
+ static summary() { return 'Look up the Rust target triple for a given build target.'; }
12891
+ static syntax() { return 'neon rust-target <target> | (-p <plat> -a <arch> [--abi <abi>])'; }
12892
+ static options() {
12893
+ return [
12894
+ { name: '<target>', summary: 'Full target name in Node convention.' },
12895
+ { name: '-p, --platform <plat>', summary: 'Target platform name.' },
12896
+ { name: '-a, --arch <arch>', summary: 'Target architecture name.' },
12897
+ { name: '--abi <abi>', summary: 'Target ABI name. (Default: null)' },
12898
+ { name: '-v, --verbose', summary: 'Enable verbose logging. (Default: false)' }
12899
+ ];
12900
+ }
12901
+ static seeAlso() { }
12902
+ static extraSection() { }
12903
+ _platform;
12904
+ _arch;
12905
+ _abi;
12906
+ _target;
12907
+ _verbose;
12908
+ constructor(argv) {
12909
+ const options = dist_default()(rust_target_OPTIONS, { argv, partial: true });
12910
+ this._platform = options.platform || null;
12911
+ this._arch = options.arch || null;
12912
+ this._abi = options.abi || null;
12913
+ this._verbose = !!options.verbose;
12914
+ if (options.platform && !options.arch) {
12915
+ throw new Error("Option --platform requires option --arch to be specified as well.");
12916
+ }
12917
+ if (!options.platform && options.arch) {
12918
+ throw new Error("Option --arch requires option --platform to be specified as well.");
12919
+ }
12920
+ if (options.abi && (!options.platform || !options.arch)) {
12921
+ throw new Error("Option --abi requires both options --platform and --arch to be specified as well.");
12922
+ }
12923
+ let target;
12924
+ if (!options.platform && !options.arch && !options.abi) {
12925
+ if (!options._unknown || options._unknown.length === 0) {
12926
+ throw new Error("No arguments found, expected <target> or -p and -a options.");
12927
+ }
12928
+ target = options._unknown[0];
12929
+ }
12930
+ else {
12931
+ target = `${options.platform}-${options.arch}`;
12932
+ if (!!options.abi) {
12933
+ target = `${target}-${options.abi}`;
12934
+ }
12935
+ }
12936
+ if (!isNodeTarget(target)) {
12937
+ throw new Error(`${target} is not a valid Node target.`);
12938
+ }
12939
+ this._target = target;
12940
+ }
12941
+ log(msg) {
12942
+ if (this._verbose) {
12943
+ console.error("[neon rust-target] " + msg);
12944
+ }
12945
+ }
12946
+ async run() {
12947
+ this.log(`reading package.json`);
12948
+ const sourceManifest = await SourceManifest.load();
12949
+ this.log(`manifest: ${sourceManifest.stringify()}`);
12950
+ const rust = sourceManifest.rustTargetFor(this._target);
12951
+ if (!rust) {
12952
+ throw new Error(`no Rust target found for ${this._target}`);
12953
+ }
12954
+ console.log(rust);
12955
+ }
12956
+ }
12957
+
12743
12958
  // EXTERNAL MODULE: ./src/print.ts + 26 modules
12744
12959
  var print = __nccwpck_require__(9050);
12745
12960
  ;// CONCATENATED MODULE: ./src/commands/help.ts
@@ -12754,6 +12969,7 @@ class Help {
12754
12969
  ];
12755
12970
  }
12756
12971
  static seeAlso() { }
12972
+ static extraSection() { }
12757
12973
  _name;
12758
12974
  constructor(argv) {
12759
12975
  this._name = argv.length > 0 ? asCommandName(argv[0]) : undefined;
@@ -12778,6 +12994,7 @@ class Help {
12778
12994
 
12779
12995
 
12780
12996
 
12997
+
12781
12998
  var CommandName;
12782
12999
  (function (CommandName) {
12783
13000
  CommandName["Help"] = "help";
@@ -12788,6 +13005,7 @@ var CommandName;
12788
13005
  CommandName["AddTarget"] = "add-target";
12789
13006
  CommandName["InstallBuilds"] = "install-builds";
12790
13007
  CommandName["UpdateTargets"] = "update-targets";
13008
+ CommandName["RustTarget"] = "rust-target";
12791
13009
  })(CommandName || (CommandName = {}));
12792
13010
  ;
12793
13011
  function isCommandName(s) {
@@ -12808,7 +13026,8 @@ const COMMANDS = {
12808
13026
  [CommandName.Tarball]: Tarball,
12809
13027
  [CommandName.AddTarget]: AddTarget,
12810
13028
  [CommandName.InstallBuilds]: UpdateTargets,
12811
- [CommandName.UpdateTargets]: UpdateTargets
13029
+ [CommandName.UpdateTargets]: UpdateTargets,
13030
+ [CommandName.RustTarget]: RustTarget
12812
13031
  };
12813
13032
  function commandFor(name) {
12814
13033
  return COMMANDS[name];
@@ -12820,7 +13039,8 @@ function summaries() {
12820
13039
  { name: CommandName.Bump, summary: Bump.summary() },
12821
13040
  { name: CommandName.Tarball, summary: Tarball.summary() },
12822
13041
  { name: CommandName.AddTarget, summary: AddTarget.summary() },
12823
- { name: CommandName.UpdateTargets, summary: UpdateTargets.summary() }
13042
+ { name: CommandName.UpdateTargets, summary: UpdateTargets.summary() },
13043
+ { name: CommandName.RustTarget, summary: RustTarget.summary() }
12824
13044
  ];
12825
13045
  }
12826
13046
 
@@ -12834,7 +13054,7 @@ __nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __we
12834
13054
  /* harmony import */ var command_line_commands__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(5046);
12835
13055
  /* harmony import */ var command_line_commands__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(command_line_commands__WEBPACK_IMPORTED_MODULE_0__);
12836
13056
  /* harmony import */ var _print_js__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(9050);
12837
- /* harmony import */ var _command_js__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(1217);
13057
+ /* harmony import */ var _command_js__WEBPACK_IMPORTED_MODULE_2__ = __nccwpck_require__(3235);
12838
13058
  /* harmony import */ var node_module__WEBPACK_IMPORTED_MODULE_3__ = __nccwpck_require__(2033);
12839
13059
  /* harmony import */ var node_module__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__nccwpck_require__.n(node_module__WEBPACK_IMPORTED_MODULE_3__);
12840
13060
 
@@ -15857,8 +16077,8 @@ const chalkStderr = createChalk({level: stderrColor ? stderrColor.level : 0});
15857
16077
 
15858
16078
  /* harmony default export */ const chalk_source = (chalk);
15859
16079
 
15860
- // EXTERNAL MODULE: ./src/command.ts + 37 modules
15861
- var command = __nccwpck_require__(1217);
16080
+ // EXTERNAL MODULE: ./src/command.ts + 39 modules
16081
+ var command = __nccwpck_require__(3235);
15862
16082
  ;// CONCATENATED MODULE: ./src/print.ts
15863
16083
 
15864
16084
 
@@ -15875,6 +16095,9 @@ function yellow(text) {
15875
16095
  function green(text) {
15876
16096
  return chalk_source.bold.greenBright(text);
15877
16097
  }
16098
+ function purple(text) {
16099
+ return chalk_source.bold.magentaBright(text);
16100
+ }
15878
16101
  function commandUsage(name, command) {
15879
16102
  const sections = [
15880
16103
  {
@@ -15894,6 +16117,10 @@ function commandUsage(name, command) {
15894
16117
  if (seeAlso) {
15895
16118
  sections.push({ header: green('See Also:'), content: seeAlso });
15896
16119
  }
16120
+ const extraSection = command.extraSection();
16121
+ if (extraSection) {
16122
+ sections.push({ header: purple(extraSection.title + ':'), content: extraSection.details });
16123
+ }
15897
16124
  return command_line_usage(sections).trimStart();
15898
16125
  }
15899
16126
  function mainUsage() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neon-rs/cli",
3
- "version": "0.0.166",
3
+ "version": "0.0.168",
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.166",
31
- "@cargo-messages/darwin-arm64": "0.0.166",
32
- "@cargo-messages/darwin-x64": "0.0.166",
33
- "@cargo-messages/linux-arm-gnueabihf": "0.0.166",
34
- "@cargo-messages/linux-x64-gnu": "0.0.166",
35
- "@cargo-messages/win32-arm64-msvc": "0.0.166",
36
- "@cargo-messages/win32-x64-msvc": "0.0.166"
30
+ "@cargo-messages/android-arm-eabi": "0.0.168",
31
+ "@cargo-messages/darwin-arm64": "0.0.168",
32
+ "@cargo-messages/darwin-x64": "0.0.168",
33
+ "@cargo-messages/linux-arm-gnueabihf": "0.0.168",
34
+ "@cargo-messages/linux-x64-gnu": "0.0.168",
35
+ "@cargo-messages/win32-arm64-msvc": "0.0.168",
36
+ "@cargo-messages/win32-x64-msvc": "0.0.168"
37
37
  }
38
38
  }