@neon-rs/cli 0.0.184 → 0.0.185
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.
- package/index.js +70 -53
- package/package.json +8 -8
package/index.js
CHANGED
|
@@ -44489,7 +44489,7 @@ const OPTIONS = [
|
|
|
44489
44489
|
{ name: 'log', alias: 'l', type: String, defaultValue: null },
|
|
44490
44490
|
{ name: 'mount', alias: 'm', type: String, defaultValue: null },
|
|
44491
44491
|
{ name: 'manifest-path', type: String, defaultValue: null },
|
|
44492
|
-
{ name: 'out', alias: 'o', type: String, defaultValue:
|
|
44492
|
+
{ name: 'out', alias: 'o', type: String, defaultValue: null },
|
|
44493
44493
|
{ name: 'verbose', alias: 'v', type: Boolean, defaultValue: false }
|
|
44494
44494
|
];
|
|
44495
44495
|
function createInputStream(file) {
|
|
@@ -44517,7 +44517,7 @@ class Dist {
|
|
|
44517
44517
|
summary: 'Mounted path of target directory in virtual filesystem. This is used to map paths from the log data back to their real paths, needed when tools such as cross-rs report messages from within a mounted Docker filesystem.'
|
|
44518
44518
|
},
|
|
44519
44519
|
{ name: '--manifest-path <path>', summary: 'Real path to Cargo.toml. (Default: cargo behavior)' },
|
|
44520
|
-
{ name: '-o, --out <dist>', summary: 'Copy output to file <dist>. (Default: index.node)' },
|
|
44520
|
+
{ name: '-o, --out <dist>', summary: 'Copy output to file <dist>. (Default: $NEON_DIST_OUTPUT or index.node)' },
|
|
44521
44521
|
{ name: '-v, --verbose', summary: 'Enable verbose logging. (Default: false)' }
|
|
44522
44522
|
];
|
|
44523
44523
|
}
|
|
@@ -44552,7 +44552,9 @@ class Dist {
|
|
|
44552
44552
|
this._manifestPath = options['manifest-path'];
|
|
44553
44553
|
this._crateName = options.name ||
|
|
44554
44554
|
basename(ensureDefined(process.env['npm_package_name'], '$npm_package_name'));
|
|
44555
|
-
this._out = options.out
|
|
44555
|
+
this._out = options.out ||
|
|
44556
|
+
process.env['NEON_DIST_OUTPUT'] ||
|
|
44557
|
+
'index.node';
|
|
44556
44558
|
this._verbose = !!options.verbose;
|
|
44557
44559
|
this.log(`crate name = "${this._crateName}"`);
|
|
44558
44560
|
}
|
|
@@ -46459,7 +46461,7 @@ function assertIsBinaryV1(json) {
|
|
|
46459
46461
|
throw new TypeError(`expected "neon.binary.abi" to be a string or null, found ${binary.abi}`);
|
|
46460
46462
|
}
|
|
46461
46463
|
}
|
|
46462
|
-
function
|
|
46464
|
+
function assertIsLibraryV1(json) {
|
|
46463
46465
|
assertIsObject(json, "neon");
|
|
46464
46466
|
for (const key in json) {
|
|
46465
46467
|
const value = json[key];
|
|
@@ -46471,10 +46473,10 @@ function assertIsSourceV1(json) {
|
|
|
46471
46473
|
}
|
|
46472
46474
|
}
|
|
46473
46475
|
}
|
|
46474
|
-
function
|
|
46476
|
+
function assertIsLibraryCfg(json) {
|
|
46475
46477
|
assertHasProps(['type', 'org', 'platforms'], json, "neon");
|
|
46476
|
-
if (json.type !== '
|
|
46477
|
-
throw new TypeError(`expected "neon.type" property to be "
|
|
46478
|
+
if (json.type !== 'library') {
|
|
46479
|
+
throw new TypeError(`expected "neon.type" property to be "library", found ${json.type}`);
|
|
46478
46480
|
}
|
|
46479
46481
|
if (typeof json.org !== 'string') {
|
|
46480
46482
|
throw new TypeError(`expected "neon.org" to be a string, found ${json.org}`);
|
|
@@ -46529,9 +46531,9 @@ function assertHasBinaryCfg(json) {
|
|
|
46529
46531
|
assertHasCfg(json);
|
|
46530
46532
|
assertIsBinaryCfg(json.neon);
|
|
46531
46533
|
}
|
|
46532
|
-
function
|
|
46534
|
+
function assertHasLibraryCfg(json) {
|
|
46533
46535
|
assertHasCfg(json);
|
|
46534
|
-
|
|
46536
|
+
assertIsLibraryCfg(json.neon);
|
|
46535
46537
|
}
|
|
46536
46538
|
async function readManifest(dir) {
|
|
46537
46539
|
dir = dir ?? process.cwd();
|
|
@@ -46595,8 +46597,17 @@ function normalizeBinaryCfg(json) {
|
|
|
46595
46597
|
json.neon = upgradeBinaryV1(json.neon);
|
|
46596
46598
|
return true;
|
|
46597
46599
|
}
|
|
46598
|
-
function
|
|
46600
|
+
function normalizeLibraryCfg(json) {
|
|
46599
46601
|
assertHasCfg(json);
|
|
46602
|
+
// V5 format: {
|
|
46603
|
+
// type: 'library',
|
|
46604
|
+
// org: string,
|
|
46605
|
+
// platforms: PlatformFamily,
|
|
46606
|
+
// load?: string | undefined
|
|
46607
|
+
// }
|
|
46608
|
+
if ('type' in json.neon && json.neon.type === 'library') {
|
|
46609
|
+
return false;
|
|
46610
|
+
}
|
|
46600
46611
|
// V4 format: {
|
|
46601
46612
|
// neon: {
|
|
46602
46613
|
// type: 'source',
|
|
@@ -46606,7 +46617,8 @@ function normalizeSourceCfg(json) {
|
|
|
46606
46617
|
// }
|
|
46607
46618
|
// }
|
|
46608
46619
|
if ('type' in json.neon && 'platforms' in json.neon) {
|
|
46609
|
-
|
|
46620
|
+
json.neon.type = 'library';
|
|
46621
|
+
return true;
|
|
46610
46622
|
}
|
|
46611
46623
|
// V3 format: {
|
|
46612
46624
|
// neon: {
|
|
@@ -46620,7 +46632,7 @@ function normalizeSourceCfg(json) {
|
|
|
46620
46632
|
const targets = json.neon['targets'];
|
|
46621
46633
|
assertIsPlatformFamily(targets, "neon.targets");
|
|
46622
46634
|
json.neon = {
|
|
46623
|
-
type: '
|
|
46635
|
+
type: 'library',
|
|
46624
46636
|
org,
|
|
46625
46637
|
platforms: targets
|
|
46626
46638
|
};
|
|
@@ -46636,7 +46648,7 @@ function normalizeSourceCfg(json) {
|
|
|
46636
46648
|
const platforms = json.neon['targets'];
|
|
46637
46649
|
assertIsPlatformMap(platforms, "neon.targets");
|
|
46638
46650
|
json.neon = {
|
|
46639
|
-
type: '
|
|
46651
|
+
type: 'library',
|
|
46640
46652
|
org: json.neon.org,
|
|
46641
46653
|
platforms
|
|
46642
46654
|
};
|
|
@@ -46648,8 +46660,8 @@ function normalizeSourceCfg(json) {
|
|
|
46648
46660
|
// }
|
|
46649
46661
|
// }
|
|
46650
46662
|
const targets = json.neon['targets'];
|
|
46651
|
-
|
|
46652
|
-
json.neon =
|
|
46663
|
+
assertIsLibraryV1(targets);
|
|
46664
|
+
json.neon = upgradeLibraryV1(targets);
|
|
46653
46665
|
return true;
|
|
46654
46666
|
}
|
|
46655
46667
|
// The source manifest is the source of truth for all Neon
|
|
@@ -46657,18 +46669,18 @@ function normalizeSourceCfg(json) {
|
|
|
46657
46669
|
// for any other files to query the Neon project's metadata.
|
|
46658
46670
|
// (Some data is replicated in the binary manifests, however,
|
|
46659
46671
|
// since they are independently published in npm.)
|
|
46660
|
-
class
|
|
46672
|
+
class LibraryManifest extends AbstractManifest {
|
|
46661
46673
|
_sourceJSON;
|
|
46662
46674
|
_expandedPlatforms;
|
|
46663
46675
|
constructor(json) {
|
|
46664
46676
|
super(json);
|
|
46665
|
-
this._upgraded =
|
|
46666
|
-
|
|
46677
|
+
this._upgraded = normalizeLibraryCfg(this._json);
|
|
46678
|
+
assertHasLibraryCfg(this._json);
|
|
46667
46679
|
this._sourceJSON = this._json;
|
|
46668
46680
|
this._expandedPlatforms = expandPlatformFamily(this._sourceJSON.neon.platforms);
|
|
46669
46681
|
}
|
|
46670
46682
|
static async load(dir) {
|
|
46671
|
-
return new
|
|
46683
|
+
return new LibraryManifest(await readManifest(dir));
|
|
46672
46684
|
}
|
|
46673
46685
|
cfg() {
|
|
46674
46686
|
return this._sourceJSON.neon;
|
|
@@ -46808,6 +46820,11 @@ class SourceManifest extends AbstractManifest {
|
|
|
46808
46820
|
platformsSrc.push(preset);
|
|
46809
46821
|
return this.addPlatforms(expandPlatformFamily(preset));
|
|
46810
46822
|
}
|
|
46823
|
+
// Edge case: an empty object can be treated like an empty array
|
|
46824
|
+
if (Object.keys(platformsSrc).length === 0) {
|
|
46825
|
+
this.cfg().platforms = [];
|
|
46826
|
+
return await this.addPlatformPreset(preset);
|
|
46827
|
+
}
|
|
46811
46828
|
return this.addPlatforms(expandPlatformFamily(preset), { platformsSrc });
|
|
46812
46829
|
}
|
|
46813
46830
|
async updateTargets(log, bundle) {
|
|
@@ -46840,7 +46857,7 @@ if (0) {
|
|
|
46840
46857
|
await promises_namespaceObject.writeFile(bundle, PREAMBLE + requires + '\n}\n');
|
|
46841
46858
|
}
|
|
46842
46859
|
}
|
|
46843
|
-
function
|
|
46860
|
+
function upgradeLibraryV1(object) {
|
|
46844
46861
|
function splitSwap([key, value]) {
|
|
46845
46862
|
if (!/^@.*\//.test(value)) {
|
|
46846
46863
|
throw new TypeError(`expected namespaced npm package name, found ${value}`);
|
|
@@ -46859,7 +46876,7 @@ function upgradeSourceV1(object) {
|
|
|
46859
46876
|
throw new Error(`multiple npm orgs found: ${orgs}`);
|
|
46860
46877
|
}
|
|
46861
46878
|
return {
|
|
46862
|
-
type: '
|
|
46879
|
+
type: 'library',
|
|
46863
46880
|
org: [...orgs][0],
|
|
46864
46881
|
platforms: Object.fromEntries(entries)
|
|
46865
46882
|
};
|
|
@@ -46941,12 +46958,12 @@ class Tarball {
|
|
|
46941
46958
|
console.error("[neon tarball] " + msg);
|
|
46942
46959
|
}
|
|
46943
46960
|
}
|
|
46944
|
-
async createTempDir(
|
|
46961
|
+
async createTempDir(libManifest) {
|
|
46945
46962
|
const target = this._target || await getCurrentTarget(msg => this.log(msg));
|
|
46946
46963
|
if (!isRustTarget(target)) {
|
|
46947
46964
|
throw new Error(`Rust target ${target} not supported.`);
|
|
46948
46965
|
}
|
|
46949
|
-
const binaryManifest =
|
|
46966
|
+
const binaryManifest = libManifest.manifestFor(target);
|
|
46950
46967
|
this.log(`prebuild manifest: ${binaryManifest.stringify()}`);
|
|
46951
46968
|
this.log("creating temp dir");
|
|
46952
46969
|
const tmpdir = await mktemp('neon-');
|
|
@@ -46959,11 +46976,11 @@ class Tarball {
|
|
|
46959
46976
|
await promises_namespaceObject.writeFile(external_node_path_namespaceObject.join(tmpdir, "README.md"), `# \`${binaryManifest.name}\`\n\n${binaryManifest.description}\n`);
|
|
46960
46977
|
return tmpdir;
|
|
46961
46978
|
}
|
|
46962
|
-
async prepareInDir(
|
|
46979
|
+
async prepareInDir(libManifest) {
|
|
46963
46980
|
if (!this._inDir) {
|
|
46964
|
-
return await this.createTempDir(
|
|
46981
|
+
return await this.createTempDir(libManifest);
|
|
46965
46982
|
}
|
|
46966
|
-
const version =
|
|
46983
|
+
const version = libManifest.version;
|
|
46967
46984
|
const binaryManifest = await BinaryManifest.load(this._inDir);
|
|
46968
46985
|
const cfg = binaryManifest.cfg();
|
|
46969
46986
|
// Since the source manifest is the source of truth, any time there's a
|
|
@@ -46990,9 +47007,9 @@ class Tarball {
|
|
|
46990
47007
|
this.log(`creating directory ${this._outDir}`);
|
|
46991
47008
|
await promises_namespaceObject.mkdir(this._outDir, { recursive: true });
|
|
46992
47009
|
this.log(`reading package.json`);
|
|
46993
|
-
const
|
|
46994
|
-
this.log(`manifest: ${
|
|
46995
|
-
const inDir = await this.prepareInDir(
|
|
47010
|
+
const libManifest = await LibraryManifest.load();
|
|
47011
|
+
this.log(`manifest: ${libManifest.stringify()}`);
|
|
47012
|
+
const inDir = await this.prepareInDir(libManifest);
|
|
46996
47013
|
this.log(`npm pack --json`);
|
|
46997
47014
|
const result = await execa("npm", ["pack", "--json"], {
|
|
46998
47015
|
shell: true,
|
|
@@ -47112,29 +47129,29 @@ class AddPlatform {
|
|
|
47112
47129
|
console.error("[neon add-platform] " + msg);
|
|
47113
47130
|
}
|
|
47114
47131
|
}
|
|
47115
|
-
async addPlatform(
|
|
47132
|
+
async addPlatform(libManifest) {
|
|
47116
47133
|
if (!this._platform) {
|
|
47117
47134
|
this.log('adding default system platform');
|
|
47118
|
-
return optionArray(await
|
|
47135
|
+
return optionArray(await libManifest.addRustTarget(await getCurrentTarget(msg => this.log(msg))));
|
|
47119
47136
|
}
|
|
47120
47137
|
else if (isRustTarget(this._platform)) {
|
|
47121
47138
|
this.log(`adding Rust target ${this._platform}`);
|
|
47122
|
-
return optionArray(await
|
|
47139
|
+
return optionArray(await libManifest.addRustTarget(this._platform));
|
|
47123
47140
|
}
|
|
47124
47141
|
else if (isNodePlatform(this._platform)) {
|
|
47125
47142
|
this.log(`adding Node platform ${this._platform}`);
|
|
47126
|
-
return optionArray(await
|
|
47143
|
+
return optionArray(await libManifest.addNodePlatform(this._platform));
|
|
47127
47144
|
}
|
|
47128
47145
|
else if (isPlatformPreset(this._platform)) {
|
|
47129
|
-
return
|
|
47146
|
+
return libManifest.addPlatformPreset(this._platform);
|
|
47130
47147
|
}
|
|
47131
47148
|
else {
|
|
47132
47149
|
throw new Error(`unrecognized platform or preset ${this._platform}`);
|
|
47133
47150
|
}
|
|
47134
47151
|
}
|
|
47135
|
-
async createTemplateTree(
|
|
47152
|
+
async createTemplateTree(libManifest, pair) {
|
|
47136
47153
|
const { node, rust } = pair;
|
|
47137
|
-
const binaryManifest =
|
|
47154
|
+
const binaryManifest = libManifest.manifestFor(rust);
|
|
47138
47155
|
this.log(`prebuild manifest: ${binaryManifest.stringify()}`);
|
|
47139
47156
|
const treeDir = external_node_path_namespaceObject.join(this._outDir, node);
|
|
47140
47157
|
this.log(`creating ${treeDir}`);
|
|
@@ -47147,13 +47164,13 @@ class AddPlatform {
|
|
|
47147
47164
|
}
|
|
47148
47165
|
async run() {
|
|
47149
47166
|
this.log(`reading package.json`);
|
|
47150
|
-
const
|
|
47151
|
-
this.log(`manifest: ${
|
|
47152
|
-
const modified = await this.addPlatform(
|
|
47167
|
+
const libManifest = await LibraryManifest.load();
|
|
47168
|
+
this.log(`manifest: ${libManifest.stringify()}`);
|
|
47169
|
+
const modified = await this.addPlatform(libManifest);
|
|
47153
47170
|
if (modified.length) {
|
|
47154
|
-
|
|
47171
|
+
libManifest.updateTargets(msg => this.log(msg), this._bundle);
|
|
47155
47172
|
for (const pair of modified) {
|
|
47156
|
-
await this.createTemplateTree(
|
|
47173
|
+
await this.createTemplateTree(libManifest, pair);
|
|
47157
47174
|
}
|
|
47158
47175
|
}
|
|
47159
47176
|
}
|
|
@@ -47199,15 +47216,15 @@ class UpdatePlatforms {
|
|
|
47199
47216
|
}
|
|
47200
47217
|
async run() {
|
|
47201
47218
|
this.log(`reading package.json (CWD=${process.cwd()})`);
|
|
47202
|
-
const
|
|
47203
|
-
const version =
|
|
47204
|
-
this.log(`package.json before: ${
|
|
47219
|
+
const libManifest = await LibraryManifest.load();
|
|
47220
|
+
const version = libManifest.version;
|
|
47221
|
+
this.log(`package.json before: ${libManifest.stringify()}`);
|
|
47205
47222
|
this.log(`determined version: ${version}`);
|
|
47206
|
-
if (
|
|
47223
|
+
if (libManifest.upgraded) {
|
|
47207
47224
|
this.log(`upgrading manifest format`);
|
|
47208
|
-
await
|
|
47225
|
+
await libManifest.save();
|
|
47209
47226
|
}
|
|
47210
|
-
|
|
47227
|
+
libManifest.updateTargets(msg => this.log(msg), this._bundle);
|
|
47211
47228
|
}
|
|
47212
47229
|
}
|
|
47213
47230
|
|
|
@@ -47239,9 +47256,9 @@ class ListPlatforms {
|
|
|
47239
47256
|
}
|
|
47240
47257
|
async run() {
|
|
47241
47258
|
this.log(`reading package.json`);
|
|
47242
|
-
const
|
|
47243
|
-
this.log(`manifest: ${
|
|
47244
|
-
const platforms =
|
|
47259
|
+
const libManifest = await LibraryManifest.load();
|
|
47260
|
+
this.log(`manifest: ${libManifest.stringify()}`);
|
|
47261
|
+
const platforms = libManifest.allPlatforms();
|
|
47245
47262
|
console.log(JSON.stringify(platforms, null, 2));
|
|
47246
47263
|
}
|
|
47247
47264
|
}
|
|
@@ -47363,9 +47380,9 @@ class RustTarget {
|
|
|
47363
47380
|
}
|
|
47364
47381
|
async run() {
|
|
47365
47382
|
this.log(`reading package.json`);
|
|
47366
|
-
const
|
|
47367
|
-
this.log(`manifest: ${
|
|
47368
|
-
const rust =
|
|
47383
|
+
const libManifest = await LibraryManifest.load();
|
|
47384
|
+
this.log(`manifest: ${libManifest.stringify()}`);
|
|
47385
|
+
const rust = libManifest.rustTargetFor(this._platform);
|
|
47369
47386
|
if (!rust) {
|
|
47370
47387
|
throw new Error(`no Rust target found for ${this._platform}`);
|
|
47371
47388
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neon-rs/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.185",
|
|
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.
|
|
31
|
-
"@cargo-messages/darwin-arm64": "0.0.
|
|
32
|
-
"@cargo-messages/darwin-x64": "0.0.
|
|
33
|
-
"@cargo-messages/linux-arm-gnueabihf": "0.0.
|
|
34
|
-
"@cargo-messages/linux-x64-gnu": "0.0.
|
|
35
|
-
"@cargo-messages/win32-arm64-msvc": "0.0.
|
|
36
|
-
"@cargo-messages/win32-x64-msvc": "0.0.
|
|
30
|
+
"@cargo-messages/android-arm-eabi": "0.0.185",
|
|
31
|
+
"@cargo-messages/darwin-arm64": "0.0.185",
|
|
32
|
+
"@cargo-messages/darwin-x64": "0.0.185",
|
|
33
|
+
"@cargo-messages/linux-arm-gnueabihf": "0.0.185",
|
|
34
|
+
"@cargo-messages/linux-x64-gnu": "0.0.185",
|
|
35
|
+
"@cargo-messages/win32-arm64-msvc": "0.0.185",
|
|
36
|
+
"@cargo-messages/win32-x64-msvc": "0.0.185"
|
|
37
37
|
}
|
|
38
38
|
}
|