@neon-rs/manifest 0.1.3 → 0.2.0
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/lib/cache/npm/legacy.cjs +1 -2
- package/lib/cache/npm/npm.cjs +2 -2
- package/lib/library/legacy.cjs +1 -2
- package/lib/library/library.cjs +5 -0
- package/lib/library/library.d.cts +1 -0
- package/lib/library/neon.cjs +1 -2
- package/lib/platform.cjs +14 -15
- package/lib/util.cjs +4 -4
- package/package.json +1 -1
package/lib/cache/npm/legacy.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeBinaryCfg =
|
|
3
|
+
exports.normalizeBinaryCfg = normalizeBinaryCfg;
|
|
4
4
|
const platform_cjs_1 = require("../../platform.cjs");
|
|
5
5
|
const util_cjs_1 = require("../../util.cjs");
|
|
6
6
|
const neon_cjs_1 = require("../../library/neon.cjs");
|
|
@@ -91,7 +91,6 @@ function normalizeBinaryCfg(json) {
|
|
|
91
91
|
json.neon = upgradeBinaryV1(json.neon);
|
|
92
92
|
return true;
|
|
93
93
|
}
|
|
94
|
-
exports.normalizeBinaryCfg = normalizeBinaryCfg;
|
|
95
94
|
function upgradeBinaryV1(json) {
|
|
96
95
|
assertIsBinaryV1(json);
|
|
97
96
|
return {
|
package/lib/cache/npm/npm.cjs
CHANGED
|
@@ -110,7 +110,7 @@ class NPMCacheCfg {
|
|
|
110
110
|
.filter(isPlatformTable)
|
|
111
111
|
.replaceWith((p) => {
|
|
112
112
|
const newProps = platforms.map(platform => {
|
|
113
|
-
return jscodeshift_1.default.property('init', jscodeshift_1.default.literal(platform), jscodeshift_1.default.arrowFunctionExpression([], jscodeshift_1.default.callExpression(jscodeshift_1.default.identifier('require'), [jscodeshift_1.default.literal(`${cfg.org}/${platform}`)])));
|
|
113
|
+
return jscodeshift_1.default.property('init', jscodeshift_1.default.literal(platform), jscodeshift_1.default.arrowFunctionExpression([], jscodeshift_1.default.callExpression(jscodeshift_1.default.identifier('require'), [jscodeshift_1.default.literal(`${cfg.org}/${cfg.prefix ?? ''}${platform}`)])));
|
|
114
114
|
});
|
|
115
115
|
return jscodeshift_1.default.objectExpression([...p.value.properties, ...newProps]);
|
|
116
116
|
})
|
|
@@ -119,7 +119,7 @@ class NPMCacheCfg {
|
|
|
119
119
|
}
|
|
120
120
|
packageNames() {
|
|
121
121
|
const cfg = this.manifest.cfg();
|
|
122
|
-
return Object.keys(this.manifest.allPlatforms()).map(key => `${cfg.org}/${key}`);
|
|
122
|
+
return Object.keys(this.manifest.allPlatforms()).map(key => `${cfg.org}/${cfg.prefix ?? ''}${key}`);
|
|
123
123
|
}
|
|
124
124
|
updatePlatforms(lib) {
|
|
125
125
|
let changed = false;
|
package/lib/library/legacy.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeLibraryCfg =
|
|
3
|
+
exports.normalizeLibraryCfg = normalizeLibraryCfg;
|
|
4
4
|
const platform_cjs_1 = require("../platform.cjs");
|
|
5
5
|
const util_cjs_1 = require("../util.cjs");
|
|
6
6
|
const neon_cjs_1 = require("./neon.cjs");
|
|
@@ -83,7 +83,6 @@ function normalizeLibraryCfg(json) {
|
|
|
83
83
|
json.neon = upgradeLibraryV1(targets);
|
|
84
84
|
return true;
|
|
85
85
|
}
|
|
86
|
-
exports.normalizeLibraryCfg = normalizeLibraryCfg;
|
|
87
86
|
function upgradeLibraryV1(object) {
|
|
88
87
|
function splitSwap([key, value]) {
|
|
89
88
|
if (!/^@.*\//.test(value)) {
|
package/lib/library/library.cjs
CHANGED
|
@@ -20,6 +20,11 @@ function assertIsLibraryCfg(json) {
|
|
|
20
20
|
throw new TypeError(`expected "neon.load" to be a string, found ${json.load}`);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
if ('prefix' in json) {
|
|
24
|
+
if (typeof json.prefix !== 'string' && typeof json.prefix !== 'undefined') {
|
|
25
|
+
throw new TypeError(`expected "neon.prefix" to be a string, found ${json.prefix}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
23
28
|
}
|
|
24
29
|
function isEmptyFamily(family) {
|
|
25
30
|
if (typeof family === 'string') {
|
package/lib/library/neon.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertHasNeonCfg =
|
|
3
|
+
exports.assertHasNeonCfg = assertHasNeonCfg;
|
|
4
4
|
const util_cjs_1 = require("../util.cjs");
|
|
5
5
|
function assertHasNeonCfg(json) {
|
|
6
6
|
if (!('neon' in json)) {
|
|
@@ -8,4 +8,3 @@ function assertHasNeonCfg(json) {
|
|
|
8
8
|
}
|
|
9
9
|
(0, util_cjs_1.assertIsObject)(json.neon, "neon");
|
|
10
10
|
}
|
|
11
|
-
exports.assertHasNeonCfg = assertHasNeonCfg;
|
package/lib/platform.cjs
CHANGED
|
@@ -3,7 +3,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.isRustTarget = isRustTarget;
|
|
7
|
+
exports.assertIsRustTarget = assertIsRustTarget;
|
|
8
|
+
exports.isNodePlatform = isNodePlatform;
|
|
9
|
+
exports.assertIsNodePlatform = assertIsNodePlatform;
|
|
10
|
+
exports.isPlatformPreset = isPlatformPreset;
|
|
11
|
+
exports.assertIsPlatformName = assertIsPlatformName;
|
|
12
|
+
exports.assertIsPlatformPreset = assertIsPlatformPreset;
|
|
13
|
+
exports.assertIsPlatformMap = assertIsPlatformMap;
|
|
14
|
+
exports.assertIsPlatformFamily = assertIsPlatformFamily;
|
|
15
|
+
exports.expandPlatformPreset = expandPlatformPreset;
|
|
16
|
+
exports.expandPlatformFamily = expandPlatformFamily;
|
|
17
|
+
exports.describeTarget = describeTarget;
|
|
18
|
+
exports.node2Rust = node2Rust;
|
|
19
|
+
exports.rust2Node = rust2Node;
|
|
7
20
|
const rust_json_1 = __importDefault(require("../data/rust.json"));
|
|
8
21
|
const node_json_1 = __importDefault(require("../data/node.json"));
|
|
9
22
|
const preset_json_1 = __importDefault(require("../data/preset.json"));
|
|
@@ -11,39 +24,32 @@ const util_cjs_1 = require("./util.cjs");
|
|
|
11
24
|
function isRustTarget(x) {
|
|
12
25
|
return (typeof x === 'string') && (x in rust_json_1.default);
|
|
13
26
|
}
|
|
14
|
-
exports.isRustTarget = isRustTarget;
|
|
15
27
|
function assertIsRustTarget(x) {
|
|
16
28
|
if (!isRustTarget(x)) {
|
|
17
29
|
throw new RangeError(`invalid Rust target: ${x}`);
|
|
18
30
|
}
|
|
19
31
|
}
|
|
20
|
-
exports.assertIsRustTarget = assertIsRustTarget;
|
|
21
32
|
function isNodePlatform(x) {
|
|
22
33
|
return (typeof x === 'string') && (x in node_json_1.default);
|
|
23
34
|
}
|
|
24
|
-
exports.isNodePlatform = isNodePlatform;
|
|
25
35
|
function assertIsNodePlatform(x) {
|
|
26
36
|
if (!isNodePlatform(x)) {
|
|
27
37
|
throw new RangeError(`invalid platform: ${x}`);
|
|
28
38
|
}
|
|
29
39
|
}
|
|
30
|
-
exports.assertIsNodePlatform = assertIsNodePlatform;
|
|
31
40
|
function isPlatformPreset(x) {
|
|
32
41
|
return (typeof x === 'string') && (x in preset_json_1.default);
|
|
33
42
|
}
|
|
34
|
-
exports.isPlatformPreset = isPlatformPreset;
|
|
35
43
|
function assertIsPlatformName(x) {
|
|
36
44
|
if (!isPlatformPreset(x) && !isNodePlatform(x)) {
|
|
37
45
|
throw new RangeError(`invalid platform name: ${x}`);
|
|
38
46
|
}
|
|
39
47
|
}
|
|
40
|
-
exports.assertIsPlatformName = assertIsPlatformName;
|
|
41
48
|
function assertIsPlatformPreset(x) {
|
|
42
49
|
if (!isPlatformPreset(x)) {
|
|
43
50
|
throw new RangeError(`invalid platform family preset: ${x}`);
|
|
44
51
|
}
|
|
45
52
|
}
|
|
46
|
-
exports.assertIsPlatformPreset = assertIsPlatformPreset;
|
|
47
53
|
function assertIsPlatformMap(json, path) {
|
|
48
54
|
(0, util_cjs_1.assertIsObject)(json, path);
|
|
49
55
|
for (const key in json) {
|
|
@@ -56,7 +62,6 @@ function assertIsPlatformMap(json, path) {
|
|
|
56
62
|
}
|
|
57
63
|
}
|
|
58
64
|
}
|
|
59
|
-
exports.assertIsPlatformMap = assertIsPlatformMap;
|
|
60
65
|
function assertIsPlatformFamily(json, path) {
|
|
61
66
|
if (typeof json === 'string') {
|
|
62
67
|
assertIsPlatformName(json);
|
|
@@ -70,7 +75,6 @@ function assertIsPlatformFamily(json, path) {
|
|
|
70
75
|
}
|
|
71
76
|
assertIsPlatformMap(json, path);
|
|
72
77
|
}
|
|
73
|
-
exports.assertIsPlatformFamily = assertIsPlatformFamily;
|
|
74
78
|
function lookupPlatformPreset(key) {
|
|
75
79
|
return preset_json_1.default[key];
|
|
76
80
|
}
|
|
@@ -84,7 +88,6 @@ function merge(maps) {
|
|
|
84
88
|
function expandPlatformPreset(preset) {
|
|
85
89
|
return expandPlatformFamily(lookupPlatformPreset(preset));
|
|
86
90
|
}
|
|
87
|
-
exports.expandPlatformPreset = expandPlatformPreset;
|
|
88
91
|
function expandPlatformFamily(family) {
|
|
89
92
|
return isPlatformPreset(family)
|
|
90
93
|
? expandPlatformPreset(family)
|
|
@@ -94,7 +97,6 @@ function expandPlatformFamily(family) {
|
|
|
94
97
|
? merge(family.map(expandPlatformFamily))
|
|
95
98
|
: family;
|
|
96
99
|
}
|
|
97
|
-
exports.expandPlatformFamily = expandPlatformFamily;
|
|
98
100
|
function describeTarget(target) {
|
|
99
101
|
const node = rust_json_1.default[target];
|
|
100
102
|
if (!isNodePlatform(node)) {
|
|
@@ -113,17 +115,14 @@ function describeTarget(target) {
|
|
|
113
115
|
llvm: nodeDescriptor.llvm
|
|
114
116
|
};
|
|
115
117
|
}
|
|
116
|
-
exports.describeTarget = describeTarget;
|
|
117
118
|
function node2Rust(target) {
|
|
118
119
|
return node_json_1.default[target].llvm.map(rt => {
|
|
119
120
|
assertIsRustTarget(rt);
|
|
120
121
|
return rt;
|
|
121
122
|
});
|
|
122
123
|
}
|
|
123
|
-
exports.node2Rust = node2Rust;
|
|
124
124
|
function rust2Node(target) {
|
|
125
125
|
const nt = rust_json_1.default[target];
|
|
126
126
|
assertIsNodePlatform(nt);
|
|
127
127
|
return nt;
|
|
128
128
|
}
|
|
129
|
-
exports.rust2Node = rust2Node;
|
package/lib/util.cjs
CHANGED
|
@@ -23,7 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.AbstractManifest =
|
|
26
|
+
exports.AbstractManifest = void 0;
|
|
27
|
+
exports.assertIsObject = assertIsObject;
|
|
28
|
+
exports.assertHasProps = assertHasProps;
|
|
29
|
+
exports.readManifest = readManifest;
|
|
27
30
|
const fs = __importStar(require("node:fs/promises"));
|
|
28
31
|
const path = __importStar(require("node:path"));
|
|
29
32
|
function assertIsObject(json, path) {
|
|
@@ -31,7 +34,6 @@ function assertIsObject(json, path) {
|
|
|
31
34
|
throw new TypeError(`expected "${path}" property to be an object, found ${json}`);
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
|
-
exports.assertIsObject = assertIsObject;
|
|
35
37
|
// Idea thanks to https://www.lucaspaganini.com/academy/assertion-functions-typescript-narrowing-5
|
|
36
38
|
function assertHasProps(keys, json, path) {
|
|
37
39
|
assertIsObject(json, path);
|
|
@@ -41,14 +43,12 @@ function assertHasProps(keys, json, path) {
|
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
|
-
exports.assertHasProps = assertHasProps;
|
|
45
46
|
async function readManifest(dir) {
|
|
46
47
|
dir = dir ?? process.cwd();
|
|
47
48
|
const json = JSON.parse(await fs.readFile(path.join(dir, "package.json"), { encoding: 'utf8' }));
|
|
48
49
|
assertIsPreamble(json);
|
|
49
50
|
return json;
|
|
50
51
|
}
|
|
51
|
-
exports.readManifest = readManifest;
|
|
52
52
|
function assertIsPreamble(json) {
|
|
53
53
|
if (!json || typeof json !== 'object' || Array.isArray(json)) {
|
|
54
54
|
throw new TypeError(`expected Neon package manifest, found ${json}`);
|