@neon-rs/cli 0.0.134 → 0.0.136

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 +46 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -11982,7 +11982,8 @@ const pack_build_OPTIONS = [
11982
11982
  { name: 'file', alias: 'f', type: String, defaultValue: 'index.node' },
11983
11983
  { name: 'target', alias: 't', type: String, defaultValue: null },
11984
11984
  { name: 'in-dir', alias: 'i', type: String, defaultValue: null },
11985
- { name: 'out-dir', alias: 'o', type: String, defaultValue: null }
11985
+ { name: 'out-dir', alias: 'o', type: String, defaultValue: null },
11986
+ { name: 'verbose', alias: 'v', type: Boolean, defaultValue: false },
11986
11987
  ];
11987
11988
 
11988
11989
  function isRustTarget(x) {
@@ -12007,7 +12008,8 @@ class PackBuild {
12007
12008
  { name: '-f, --file <addon>', summary: 'Prebuilt .node file to pack. (Default: index.node)' },
12008
12009
  { name: '-t, --target <target>', summary: 'Rust target triple the addon was built for. (Default: in-dir manifest target or else rustc default host)' },
12009
12010
  { name: '-i, --in-dir <path>', summary: 'Input directory with package manifest, created automatically by default. (Default: temp dir)' },
12010
- { name: '-o, --out-dir <path>', summary: 'Output directory, recursively created if needed. (Default: ./dist)' }
12011
+ { name: '-o, --out-dir <path>', summary: 'Output directory, recursively created if needed. (Default: ./dist)' },
12012
+ { name: '-v, --verbose', summary: 'Enable verbose logging. (Default: false)' }
12011
12013
  ];
12012
12014
  }
12013
12015
  static seeAlso() {
@@ -12023,17 +12025,27 @@ class PackBuild {
12023
12025
  this._addon = options.file;
12024
12026
  this._inDir = options['in-dir'] || null;
12025
12027
  this._outDir = options['out-dir'] || external_node_path_namespaceObject.join(process.cwd(), 'dist');
12028
+ this._verbose = !!options.verbose;
12029
+ }
12030
+ log(msg) {
12031
+ if (this._verbose) {
12032
+ console.error("[neon pack-build] " + msg);
12033
+ }
12026
12034
  }
12027
12035
  async currentTarget() {
12036
+ this.log(`rustc -vV`);
12028
12037
  const result = await execa("rustc", ["-vV"], { shell: true });
12029
12038
  if (result.exitCode !== 0) {
12030
12039
  throw new Error(`Could not determine current Rust target: ${result.stderr}`);
12031
12040
  }
12032
12041
  const hostLine = result.stdout.split(/\n/).find(line => line.startsWith('host:'));
12042
+ this.log(`found host line: ${hostLine}`);
12033
12043
  if (!hostLine) {
12034
12044
  throw new Error("Could not determine current Rust target (unexpected rustc output)");
12035
12045
  }
12036
- return hostLine.replace(/^host:\s+/, '');
12046
+ const target = hostLine.replace(/^host:\s+/, '');
12047
+ this.log(`currentTarget result: "${target}"`);
12048
+ return target;
12037
12049
  }
12038
12050
  async createTempDir(manifest) {
12039
12051
  const version = manifest.version;
@@ -12074,9 +12086,15 @@ class PackBuild {
12074
12086
  prebuildManifest[key] = manifest[key];
12075
12087
  }
12076
12088
  }
12089
+ this.log(`prebuild manifest: ${JSON.stringify(prebuildManifest)}`);
12090
+ this.log("creating temp dir");
12077
12091
  const tmpdir = await mktemp('neon-');
12092
+ this.log(`created temp dir ${tmpdir}`);
12093
+ this.log(`creating ${tmpdir}/package.json`);
12078
12094
  await promises_namespaceObject.writeFile(external_node_path_namespaceObject.join(tmpdir, "package.json"), JSON.stringify(prebuildManifest, null, 2));
12095
+ this.log(`copying ${this._addon} to ${tmpdir}/index.node`);
12079
12096
  await promises_namespaceObject.copyFile(this._addon, external_node_path_namespaceObject.join(tmpdir, "index.node"));
12097
+ this.log(`creating ${tmpdir}/README.md`);
12080
12098
  await promises_namespaceObject.writeFile(external_node_path_namespaceObject.join(tmpdir, "README.md"), `# \`${name}\`\n\n${description}\n`);
12081
12099
  return tmpdir;
12082
12100
  }
@@ -12105,26 +12123,36 @@ class PackBuild {
12105
12123
  };
12106
12124
  // FIXME: make it possible to disable this
12107
12125
  binaryManifest.version = version;
12126
+ this.log(`binary manifest: ${JSON.stringify(binaryManifest)}`);
12127
+ this.log(`creating ${this._inDir}/package.json`);
12108
12128
  await promises_namespaceObject.writeFile(external_node_path_namespaceObject.join(this._inDir, 'package.json'), JSON.stringify(binaryManifest, null, 2), { encoding: 'utf8' });
12109
12129
  // FIXME: make this path configurable
12130
+ this.log(`copying ${this._addon} to ${this._inDir}/index.node`);
12110
12131
  await promises_namespaceObject.copyFile(this._addon, external_node_path_namespaceObject.join(this._inDir, "index.node"));
12111
12132
  return this._inDir;
12112
12133
  }
12113
12134
  async run() {
12135
+ this.log(`creating directory ${this._outDir}`);
12114
12136
  await promises_namespaceObject.mkdir(this._outDir, { recursive: true });
12137
+ this.log(`reading package.json`);
12115
12138
  const manifest = JSON.parse(await promises_namespaceObject.readFile('package.json', { encoding: 'utf8' }));
12139
+ this.log(`manifest: ${JSON.stringify(manifest)}`);
12116
12140
  const inDir = await this.prepareInDir(manifest);
12141
+ this.log(`npm pack --json`);
12117
12142
  const result = await execa("npm", ["pack", "--json"], {
12118
12143
  shell: true,
12119
12144
  cwd: inDir,
12120
12145
  stdio: ['pipe', 'pipe', 'inherit']
12121
12146
  });
12122
12147
  if (result.exitCode !== 0) {
12148
+ this.log(`npm pack failed with exit code ${result.exitCode}`);
12123
12149
  process.exit(result.exitCode);
12124
12150
  }
12125
12151
  // FIXME: comment linking to the npm issue this fixes
12126
12152
  const tarball = JSON.parse(result.stdout)[0].filename.replace('@', '').replace('/', '-');
12153
+ this.log(`tarball filename: ${tarball}`);
12127
12154
  const dest = external_node_path_namespaceObject.join(this._outDir, tarball);
12155
+ this.log(`copying ${external_node_path_namespaceObject.join(inDir, tarball)} to ${dest}`);
12128
12156
  // Copy instead of move since e.g. GitHub Actions Windows runners host temp directories
12129
12157
  // on a different device (which causes fs.renameSync to fail).
12130
12158
  await promises_namespaceObject.copyFile(external_node_path_namespaceObject.join(inDir, tarball), dest);
@@ -12139,7 +12167,8 @@ class PackBuild {
12139
12167
 
12140
12168
 
12141
12169
  const install_builds_OPTIONS = [
12142
- { name: 'bundle', alias: 'b', type: String, defaultValue: null }
12170
+ { name: 'bundle', alias: 'b', type: String, defaultValue: null },
12171
+ { name: 'verbose', alias: 'v', type: Boolean, defaultValue: false }
12143
12172
  ];
12144
12173
  class InstallBuilds {
12145
12174
  static summary() { return 'Install dependencies on prebuilds in package.json.'; }
@@ -12150,7 +12179,8 @@ class InstallBuilds {
12150
12179
  {
12151
12180
  name: '',
12152
12181
  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.'
12153
- }
12182
+ },
12183
+ { name: '-v, --verbose', summary: 'Enable verbose logging. (Default: false)' }
12154
12184
  ];
12155
12185
  }
12156
12186
  static seeAlso() {
@@ -12161,14 +12191,24 @@ class InstallBuilds {
12161
12191
  constructor(argv) {
12162
12192
  const options = dist_default()(install_builds_OPTIONS, { argv });
12163
12193
  this._bundle = options.bundle || null;
12194
+ this._verbose = !!options.verbose;
12195
+ }
12196
+ log(msg) {
12197
+ if (this._verbose) {
12198
+ console.error("[neon install-builds] " + msg);
12199
+ }
12164
12200
  }
12165
12201
  async run() {
12202
+ this.log(`reading package.json (CWD=${process.cwd()})`);
12166
12203
  const manifest = JSON.parse(await promises_namespaceObject.readFile(external_node_path_namespaceObject.join(process.cwd(), 'package.json'), { encoding: 'utf8' }));
12167
12204
  const version = manifest.version;
12205
+ this.log(`determined version: ${version}`);
12168
12206
  const targets = Object.values(manifest.neon.targets);
12169
12207
  const specs = targets.map(name => `${name}@${version}`);
12208
+ this.log(`npm install --save-exact -O ${specs.join(' ')}`);
12170
12209
  const result = await execa('npm', ['install', '--save-exact', '-O', ...specs], { shell: true });
12171
12210
  if (result.exitCode !== 0) {
12211
+ this.log(`npm failed with exit code ${result.exitCode}`);
12172
12212
  console.error(result.stderr);
12173
12213
  process.exit(result.exitCode);
12174
12214
  }
@@ -12186,6 +12226,7 @@ class InstallBuilds {
12186
12226
  if (0) {
12187
12227
  `;
12188
12228
  const requires = targets.map(name => ` require('${name}');`).join('\n');
12229
+ this.log(`generating bundler compatibility module at ${this._bundle}`);
12189
12230
  await promises_namespaceObject.writeFile(this._bundle, PREAMBLE + requires + '\n}\n');
12190
12231
  }
12191
12232
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neon-rs/cli",
3
- "version": "0.0.134",
3
+ "version": "0.0.136",
4
4
  "description": "Command-line build tool for Neon modules.",
5
5
  "type": "module",
6
6
  "exports": "./index.js",