@neon-rs/cli 0.0.3 → 0.0.5
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 +15381 -0
- package/package.json +7 -33
- package/data/llvm.json +0 -42
- package/data/node.json +0 -281
- package/dist/cargo.js +0 -154
- package/dist/command.js +0 -39
- package/dist/commands/dist.js +0 -75
- package/dist/commands/help.js +0 -26
- package/dist/commands/install-builds.js +0 -65
- package/dist/commands/pack-build.js +0 -106
- package/dist/index.js +0 -33
- package/dist/print.js +0 -69
- package/types/cargo.d.ts +0 -43
- package/types/command.d.ts +0 -24
- package/types/commands/cross-dist.d.ts +0 -14
- package/types/commands/cross-install.d.ts +0 -10
- package/types/commands/cross-pack.d.ts +0 -12
- package/types/commands/dist.d.ts +0 -16
- package/types/commands/help.d.ts +0 -10
- package/types/commands/install-builds.d.ts +0 -10
- package/types/commands/pack-build.d.ts +0 -13
- package/types/index.d.ts +0 -2
- package/types/print.d.ts +0 -5
- package/types/usage.d.ts +0 -2
package/package.json
CHANGED
|
@@ -1,25 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neon-rs/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Command-line build tool for Neon modules.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"exports": "./
|
|
7
|
-
"types": "types/index.d.ts",
|
|
6
|
+
"exports": "./index.js",
|
|
8
7
|
"files": [
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"types/**/*",
|
|
12
|
-
"LICENSE*"
|
|
8
|
+
"LICENSE*",
|
|
9
|
+
"index.js"
|
|
13
10
|
],
|
|
14
11
|
"bin": {
|
|
15
|
-
"neon": "
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "tsc",
|
|
19
|
-
"pretest": "npm run build",
|
|
20
|
-
"prepack": "npm run build",
|
|
21
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
12
|
+
"neon": "./index.js"
|
|
22
13
|
},
|
|
14
|
+
"author": "Dave Herman <david.herman@gmail.com>",
|
|
23
15
|
"repository": {
|
|
24
16
|
"type": "git",
|
|
25
17
|
"url": "git+https://github.com/dherman/neon-rs.git"
|
|
@@ -29,28 +21,10 @@
|
|
|
29
21
|
"Rust",
|
|
30
22
|
"Node"
|
|
31
23
|
],
|
|
32
|
-
"author": "Dave Herman <david.herman@gmail.com>",
|
|
33
24
|
"license": "MIT",
|
|
34
25
|
"bugs": {
|
|
35
26
|
"url": "https://github.com/dherman/neon-rs/issues"
|
|
36
27
|
},
|
|
37
28
|
"homepage": "https://github.com/dherman/neon-rs#readme",
|
|
38
|
-
"
|
|
39
|
-
"@tsconfig/node16": "^1.0.3",
|
|
40
|
-
"@types/command-line-args": "^5.2.0",
|
|
41
|
-
"@types/command-line-commands": "^2.0.1",
|
|
42
|
-
"@types/command-line-usage": "^5.0.2",
|
|
43
|
-
"@types/node": "^18.15.11",
|
|
44
|
-
"@types/temp": "^0.9.1",
|
|
45
|
-
"typescript": "^5.0.4"
|
|
46
|
-
},
|
|
47
|
-
"dependencies": {
|
|
48
|
-
"chalk": "^5.2.0",
|
|
49
|
-
"command-line-args": "^5.2.1",
|
|
50
|
-
"command-line-commands": "^3.0.2",
|
|
51
|
-
"command-line-usage": "^7.0.1",
|
|
52
|
-
"execa": "^7.1.1",
|
|
53
|
-
"stream-to-string": "^1.2.1",
|
|
54
|
-
"temp": "^0.9.4"
|
|
55
|
-
}
|
|
29
|
+
"neon": null
|
|
56
30
|
}
|
package/data/llvm.json
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"aarch64-apple-darwin": ["darwin", "arm64", 0],
|
|
3
|
-
"x86_64-apple-darwin": ["darwin", "x64", 0],
|
|
4
|
-
"aarch64-apple-ios": ["ios", "arm64", 0],
|
|
5
|
-
"x86_64-apple-ios": ["ios", "x64", 0],
|
|
6
|
-
"aarch64-linux-android": ["android", "arm64", 0],
|
|
7
|
-
"armv7-linux-androideabi": ["android", "arm", 0],
|
|
8
|
-
"i686-linux-android": ["android", "ia32", 0],
|
|
9
|
-
"x86_64-linux-android": ["android", "x64", 0],
|
|
10
|
-
"aarch64-pc-windows-msvc": ["win32", "arm64", 0],
|
|
11
|
-
"i686-pc-windows-gnu": ["win32", "ia32", 0],
|
|
12
|
-
"i686-pc-windows-msvc": ["win32", "ia32", 1],
|
|
13
|
-
"x86_64-pc-windows-gnu": ["win32", "x64", 0],
|
|
14
|
-
"x86_64-pc-windows-msvc": ["win32", "x64", 1],
|
|
15
|
-
"aarch64-unknown-linux-gnu": ["linux", "arm64", 0],
|
|
16
|
-
"aarch64-unknown-linux-musl": ["linux", "arm64", 1],
|
|
17
|
-
"arm-unknown-linux-gnueabihf": ["linux", "arm", 0],
|
|
18
|
-
"arm-unknown-linux-musleabihf": ["linux", "arm", 1],
|
|
19
|
-
"armv7-unknown-linux-gnueabihf": ["linux", "arm", 2],
|
|
20
|
-
"armv7-unknown-linux-musleabihf": ["linux", "arm", 3],
|
|
21
|
-
"i686-unknown-linux-gnu": ["linux", "ia32", 0],
|
|
22
|
-
"i686-unknown-linux-musl": ["linux", "ia32", 1],
|
|
23
|
-
"mips-unknown-linux-gnu": ["linux", "mips", 0],
|
|
24
|
-
"mips-unknown-linux-musl": ["linux", "mips", 1],
|
|
25
|
-
"mips64-unknown-linux-gnuabi64": ["linux", "mips64", 0],
|
|
26
|
-
"mips64-unknown-linux-muslabi64": ["linux", "mips64", 1],
|
|
27
|
-
"mips64el-unknown-linux-gnuabi64": ["linux", "mips64el", 0],
|
|
28
|
-
"mips64el-unknown-linux-muslabi64": ["linux", "mips64el", 1],
|
|
29
|
-
"mipsel-unknown-linux-gnu": ["linux", "mipsel", 0],
|
|
30
|
-
"mipsel-unknown-linux-musl": ["linux", "mipsel", 1],
|
|
31
|
-
"powerpc-unknown-linux-gnu": ["linux", "powerpc", 0],
|
|
32
|
-
"powerpc64-unknown-linux-gnu": ["linux", "powerpc64", 0],
|
|
33
|
-
"powerpc64le-unknown-linux-gnu": ["linux", "powerpc64le", 0],
|
|
34
|
-
"riscv64gc-unknown-linux-gnu": ["linux", "riscv64gc", 0],
|
|
35
|
-
"s390x-unknown-linux-gnu": ["linux", "s390x", 0],
|
|
36
|
-
"sparc64-unknown-linux-gnu": ["linux", "sparc64", 0],
|
|
37
|
-
"x86_64-unknown-linux-gnu": ["linux", "x64", 0],
|
|
38
|
-
"x86_64-unknown-linux-gnux32": ["linux", "x64", 1],
|
|
39
|
-
"x86_64-unknown-linux-musl": ["linux", "x64", 2],
|
|
40
|
-
"i686-unknown-freebsd": ["freebsd", "ia32", 0],
|
|
41
|
-
"x86_64-unknown-freebsd": ["freebsd", "x64", 0]
|
|
42
|
-
}
|
package/data/node.json
DELETED
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"darwin": {
|
|
3
|
-
"arm64": [{
|
|
4
|
-
"platform": "darwin",
|
|
5
|
-
"arch": "arm64",
|
|
6
|
-
"abi": null,
|
|
7
|
-
"node": "darwin-arm64",
|
|
8
|
-
"llvm": "aarch64-apple-darwin"
|
|
9
|
-
}],
|
|
10
|
-
"x64": [{
|
|
11
|
-
"platform": "darwin",
|
|
12
|
-
"arch": "x64",
|
|
13
|
-
"abi": null,
|
|
14
|
-
"node": "darwin-x64",
|
|
15
|
-
"llvm": "x86_64-apple-darwin"
|
|
16
|
-
}]
|
|
17
|
-
},
|
|
18
|
-
"ios": {
|
|
19
|
-
"arm64": [{
|
|
20
|
-
"platform": "ios",
|
|
21
|
-
"arch": "arm64",
|
|
22
|
-
"abi": null,
|
|
23
|
-
"node": "ios-arm64",
|
|
24
|
-
"llvm": "aarch64-apple-ios"
|
|
25
|
-
}],
|
|
26
|
-
"x64": [{
|
|
27
|
-
"platform": "ios",
|
|
28
|
-
"arch": "x64",
|
|
29
|
-
"abi": null,
|
|
30
|
-
"node": "ios-x64",
|
|
31
|
-
"llvm": "x86_64-apple-ios"
|
|
32
|
-
}]
|
|
33
|
-
},
|
|
34
|
-
"android": {
|
|
35
|
-
"arm64": [{
|
|
36
|
-
"platform": "android",
|
|
37
|
-
"arch": "arm64",
|
|
38
|
-
"abi": null,
|
|
39
|
-
"node": "android-arm64",
|
|
40
|
-
"llvm": "aarch64-linux-android"
|
|
41
|
-
}],
|
|
42
|
-
"arm": [{
|
|
43
|
-
"platform": "android",
|
|
44
|
-
"arch": "arm",
|
|
45
|
-
"abi": "eabi",
|
|
46
|
-
"node": "android-arm-eabi",
|
|
47
|
-
"llvm": "armv7-linux-androideabi"
|
|
48
|
-
}],
|
|
49
|
-
"ia32": [{
|
|
50
|
-
"platform": "android",
|
|
51
|
-
"arch": "ia32",
|
|
52
|
-
"abi": null,
|
|
53
|
-
"node": "android-ia32",
|
|
54
|
-
"llvm": "i686-linux-android"
|
|
55
|
-
}],
|
|
56
|
-
"x64": [{
|
|
57
|
-
"platform": "android",
|
|
58
|
-
"arch": "x64",
|
|
59
|
-
"abi": null,
|
|
60
|
-
"node": "android-x64",
|
|
61
|
-
"llvm": "x86_64-linux-android"
|
|
62
|
-
}]
|
|
63
|
-
},
|
|
64
|
-
"win32": {
|
|
65
|
-
"arm64": [{
|
|
66
|
-
"platform": "win32",
|
|
67
|
-
"arch": "arm64",
|
|
68
|
-
"abi": "msvc",
|
|
69
|
-
"node": "win32-arm64-msvc",
|
|
70
|
-
"llvm": "aarch64-pc-windows-msvc"
|
|
71
|
-
}],
|
|
72
|
-
"ia32": [{
|
|
73
|
-
"platform": "win32",
|
|
74
|
-
"arch": "ia32",
|
|
75
|
-
"abi": "gnu",
|
|
76
|
-
"node": "win32-ia32-gnu",
|
|
77
|
-
"llvm": "i686-pc-windows-gnu"
|
|
78
|
-
}, {
|
|
79
|
-
"platform": "win32",
|
|
80
|
-
"arch": "ia32",
|
|
81
|
-
"abi": "msvc",
|
|
82
|
-
"node": "win32-ia32-msvc",
|
|
83
|
-
"llvm": "i686-pc-windows-msvc"
|
|
84
|
-
}],
|
|
85
|
-
"x64": [{
|
|
86
|
-
"platform": "win32",
|
|
87
|
-
"arch": "x64",
|
|
88
|
-
"abi": "gnu",
|
|
89
|
-
"node": "win32-x64-gnu",
|
|
90
|
-
"llvm": "x86_64-pc-windows-gnu"
|
|
91
|
-
}, {
|
|
92
|
-
"platform": "win32",
|
|
93
|
-
"arch": "x64",
|
|
94
|
-
"abi": "msvc",
|
|
95
|
-
"node": "win32-x64-msvc",
|
|
96
|
-
"llvm": "x86_64-pc-windows-msvc"
|
|
97
|
-
}]
|
|
98
|
-
},
|
|
99
|
-
"linux": {
|
|
100
|
-
"arm64": [{
|
|
101
|
-
"platform": "linux",
|
|
102
|
-
"arch": "arm64",
|
|
103
|
-
"abi": "gnu",
|
|
104
|
-
"node": "linux-arm64-gnu",
|
|
105
|
-
"llvm": "aarch64-unknown-linux-gnu"
|
|
106
|
-
}, {
|
|
107
|
-
"platform": "linux",
|
|
108
|
-
"arch": "arm64",
|
|
109
|
-
"abi": "musl",
|
|
110
|
-
"node": "linux-arm64-musl",
|
|
111
|
-
"llvm": "aarch64-unknown-linux-musl"
|
|
112
|
-
}],
|
|
113
|
-
"arm": [{
|
|
114
|
-
"platform": "linux",
|
|
115
|
-
"arch": "arm",
|
|
116
|
-
"abi": "gnueabihf",
|
|
117
|
-
"node": "linux-arm-gnueabihf",
|
|
118
|
-
"llvm": "arm-unknown-linux-gnueabihf"
|
|
119
|
-
}, {
|
|
120
|
-
"platform": "linux",
|
|
121
|
-
"arch": "arm",
|
|
122
|
-
"abi": "musleabihf",
|
|
123
|
-
"node": "linux-arm-musleabihf",
|
|
124
|
-
"llvm": "arm-unknown-linux-musleabihf"
|
|
125
|
-
}, {
|
|
126
|
-
"platform": "linux",
|
|
127
|
-
"arch": "arm",
|
|
128
|
-
"abi": "gnueabihf",
|
|
129
|
-
"node": "linux-arm-gnueabihf",
|
|
130
|
-
"llvm": "armv7-unknown-linux-gnueabihf"
|
|
131
|
-
}, {
|
|
132
|
-
"platform": "linux",
|
|
133
|
-
"arch": "arm",
|
|
134
|
-
"abi": "musleabihf",
|
|
135
|
-
"node": "linux-arm-musleabihf",
|
|
136
|
-
"llvm": "armv7-unknown-linux-musleabihf"
|
|
137
|
-
}],
|
|
138
|
-
"ia32": [{
|
|
139
|
-
"platform": "linux",
|
|
140
|
-
"arch": "ia32",
|
|
141
|
-
"abi": "gnu",
|
|
142
|
-
"node": "linux-ia32-gnu",
|
|
143
|
-
"llvm": "i686-unknown-linux-gnu"
|
|
144
|
-
}, {
|
|
145
|
-
"platform": "linux",
|
|
146
|
-
"arch": "ia32",
|
|
147
|
-
"abi": "musl",
|
|
148
|
-
"node": "linux-ia32-musl",
|
|
149
|
-
"llvm": "i686-unknown-linux-musl"
|
|
150
|
-
}],
|
|
151
|
-
"mips": [{
|
|
152
|
-
"platform": "linux",
|
|
153
|
-
"arch": "mips",
|
|
154
|
-
"abi": "gnu",
|
|
155
|
-
"node": "linux-mips-gnu",
|
|
156
|
-
"llvm": "mips-unknown-linux-gnu"
|
|
157
|
-
}, {
|
|
158
|
-
"platform": "linux",
|
|
159
|
-
"arch": "mips",
|
|
160
|
-
"abi": "musl",
|
|
161
|
-
"node": "linux-mips-musl",
|
|
162
|
-
"llvm": "mips-unknown-linux-musl"
|
|
163
|
-
}],
|
|
164
|
-
"mips64": [{
|
|
165
|
-
"platform": "linux",
|
|
166
|
-
"arch": "mips64",
|
|
167
|
-
"abi": "gnuabi64",
|
|
168
|
-
"node": "linux-mips64-gnuabi64",
|
|
169
|
-
"llvm": "mips64-unknown-linux-gnuabi64"
|
|
170
|
-
}, {
|
|
171
|
-
"platform": "linux",
|
|
172
|
-
"arch": "mips64",
|
|
173
|
-
"abi": "muslabi64",
|
|
174
|
-
"node": "linux-mips64-muslabi64",
|
|
175
|
-
"llvm": "mips64-unknown-linux-muslabi64"
|
|
176
|
-
}],
|
|
177
|
-
"mips64el": [{
|
|
178
|
-
"platform": "linux",
|
|
179
|
-
"arch": "mips64el",
|
|
180
|
-
"abi": "gnuabi64",
|
|
181
|
-
"node": "linux-mips64el-gnuabi64",
|
|
182
|
-
"llvm": "mips64el-unknown-linux-gnuabi64"
|
|
183
|
-
}, {
|
|
184
|
-
"platform": "linux",
|
|
185
|
-
"arch": "mips64el",
|
|
186
|
-
"abi": "muslabi64",
|
|
187
|
-
"node": "linux-mips64el-muslabi64",
|
|
188
|
-
"llvm": "mips64el-unknown-linux-muslabi64"
|
|
189
|
-
}],
|
|
190
|
-
"mipsel": [{
|
|
191
|
-
"platform": "linux",
|
|
192
|
-
"arch": "mipsel",
|
|
193
|
-
"abi": "gnu",
|
|
194
|
-
"node": "linux-mipsel-gnu",
|
|
195
|
-
"llvm": "mipsel-unknown-linux-gnu"
|
|
196
|
-
}, {
|
|
197
|
-
"platform": "linux",
|
|
198
|
-
"arch": "mipsel",
|
|
199
|
-
"abi": "musl",
|
|
200
|
-
"node": "linux-mipsel-musl",
|
|
201
|
-
"llvm": "mipsel-unknown-linux-musl"
|
|
202
|
-
}],
|
|
203
|
-
"powerpc": [{
|
|
204
|
-
"platform": "linux",
|
|
205
|
-
"arch": "powerpc",
|
|
206
|
-
"abi": "gnu",
|
|
207
|
-
"node": "linux-powerpc-gnu",
|
|
208
|
-
"llvm": "powerpc-unknown-linux-gnu"
|
|
209
|
-
}],
|
|
210
|
-
"powerpc64": [{
|
|
211
|
-
"platform": "linux",
|
|
212
|
-
"arch": "powerpc64",
|
|
213
|
-
"abi": "gnu",
|
|
214
|
-
"node": "linux-powerpc64-gnu",
|
|
215
|
-
"llvm": "powerpc64-unknown-linux-gnu"
|
|
216
|
-
}],
|
|
217
|
-
"powerpc64le": [{
|
|
218
|
-
"platform": "linux",
|
|
219
|
-
"arch": "powerpc64le",
|
|
220
|
-
"abi": "gnu",
|
|
221
|
-
"node": "linux-powerpc64le-gnu",
|
|
222
|
-
"llvm": "powerpc64le-unknown-linux-gnu"
|
|
223
|
-
}],
|
|
224
|
-
"riscv64gc": [{
|
|
225
|
-
"platform": "linux",
|
|
226
|
-
"arch": "riscv64gc",
|
|
227
|
-
"abi": "gnu",
|
|
228
|
-
"node": "linux-riscv64gc-gnu",
|
|
229
|
-
"llvm": "riscv64gc-unknown-linux-gnu"
|
|
230
|
-
}],
|
|
231
|
-
"s390x": [{
|
|
232
|
-
"platform": "linux",
|
|
233
|
-
"arch": "s390x",
|
|
234
|
-
"abi": "gnu",
|
|
235
|
-
"node": "linux-s390x-gnu",
|
|
236
|
-
"llvm": "s390x-unknown-linux-gnu"
|
|
237
|
-
}],
|
|
238
|
-
"sparc64": [{
|
|
239
|
-
"platform": "linux",
|
|
240
|
-
"arch": "sparc64",
|
|
241
|
-
"abi": "gnu",
|
|
242
|
-
"node": "linux-sparc64-gnu",
|
|
243
|
-
"llvm": "sparc64-unknown-linux-gnu"
|
|
244
|
-
}],
|
|
245
|
-
"x64": [{
|
|
246
|
-
"platform": "linux",
|
|
247
|
-
"arch": "x64",
|
|
248
|
-
"abi": "gnu",
|
|
249
|
-
"node": "linux-x64-gnu",
|
|
250
|
-
"llvm": "x86_64-unknown-linux-gnu"
|
|
251
|
-
}, {
|
|
252
|
-
"platform": "linux",
|
|
253
|
-
"arch": "x64",
|
|
254
|
-
"abi": "gnux32",
|
|
255
|
-
"node": "linux-x64-gnux32",
|
|
256
|
-
"llvm": "x86_64-unknown-linux-gnux32"
|
|
257
|
-
}, {
|
|
258
|
-
"platform": "linux",
|
|
259
|
-
"arch": "x64",
|
|
260
|
-
"abi": "musl",
|
|
261
|
-
"node": "linux-x64-musl",
|
|
262
|
-
"llvm": "x86_64-unknown-linux-musl"
|
|
263
|
-
}]
|
|
264
|
-
},
|
|
265
|
-
"freebsd": {
|
|
266
|
-
"ia32": [{
|
|
267
|
-
"platform": "freebsd",
|
|
268
|
-
"arch": "ia32",
|
|
269
|
-
"abi": null,
|
|
270
|
-
"node": "freebsd-ia32",
|
|
271
|
-
"llvm": "i686-unknown-freebsd"
|
|
272
|
-
}],
|
|
273
|
-
"x64": [{
|
|
274
|
-
"platform": "freebsd",
|
|
275
|
-
"arch": "x64",
|
|
276
|
-
"abi": null,
|
|
277
|
-
"node": "freebsd-x64",
|
|
278
|
-
"llvm": "x86_64-unknown-freebsd"
|
|
279
|
-
}]
|
|
280
|
-
}
|
|
281
|
-
}
|
package/dist/cargo.js
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { createReadStream } from 'node:fs';
|
|
2
|
-
import * as path from 'node:path';
|
|
3
|
-
import * as readline from 'node:readline';
|
|
4
|
-
import { execa } from 'execa';
|
|
5
|
-
export function messageReason(message) {
|
|
6
|
-
return message.reason;
|
|
7
|
-
}
|
|
8
|
-
export function isCompilerMessage(json) {
|
|
9
|
-
if (!(json instanceof Object)) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
if (!('reason' in json) || (json.reason !== 'compiler-message')) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
export function isBuildScriptExecuted(json) {
|
|
18
|
-
if (!(json instanceof Object)) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
if (!('reason' in json) || (json.reason !== 'build-script-executed')) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
export function isCompilerTarget(json) {
|
|
27
|
-
if (!(json instanceof Object)) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
|
-
if (!('kind' in json) || !isStringArray(json.kind)) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
if (!('crate_types' in json) || !isStringArray(json.crate_types)) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
if (!('name' in json) || (typeof json.name !== 'string')) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
export function isCompilerArtifact(json) {
|
|
42
|
-
if (!(json instanceof Object)) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
if (!('reason' in json) || (json.reason !== 'compiler-artifact')) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
if (!('package_id' in json) || (typeof json.package_id !== 'string')) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
if (!('manifest_path' in json) || (typeof json.manifest_path !== 'string')) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
if (!('target' in json) || !isCompilerTarget(json.target)) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
if (!('filenames' in json) || !isStringArray(json.filenames)) {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
function isStringArray(json) {
|
|
63
|
-
if (!Array.isArray(json)) {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
for (const val of json) {
|
|
67
|
-
if (typeof val !== 'string') {
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
export function isBuildFinished(json) {
|
|
74
|
-
if (!(json instanceof Object)) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
if (!('reason' in json) || (json.reason !== 'build-finished')) {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
return ('success' in json) && (typeof json.success === 'boolean');
|
|
81
|
-
}
|
|
82
|
-
export function parseMessage(line) {
|
|
83
|
-
try {
|
|
84
|
-
const json = JSON.parse(line);
|
|
85
|
-
if (isCompilerMessage(json) ||
|
|
86
|
-
isBuildScriptExecuted(json) ||
|
|
87
|
-
isCompilerArtifact(json) ||
|
|
88
|
-
isBuildFinished(json)) {
|
|
89
|
-
return json;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
catch (nope) { }
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
export class MessageStream {
|
|
96
|
-
constructor(file) {
|
|
97
|
-
const input = file ? createReadStream(file) : process.stdin;
|
|
98
|
-
this._stream = readline.createInterface({
|
|
99
|
-
input,
|
|
100
|
-
terminal: false
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
async findPath(pred) {
|
|
104
|
-
try {
|
|
105
|
-
for await (const line of this._stream) {
|
|
106
|
-
const msg = parseMessage(line);
|
|
107
|
-
if (!msg) {
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
const result = pred(msg);
|
|
111
|
-
if (result !== null) {
|
|
112
|
-
return result;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return null;
|
|
116
|
-
}
|
|
117
|
-
finally {
|
|
118
|
-
this._stream.close();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
export class UnmountMessageStream extends MessageStream {
|
|
123
|
-
constructor(mount, manifestPath, file) {
|
|
124
|
-
super(file);
|
|
125
|
-
this._mount = mount;
|
|
126
|
-
this._manifestPath = manifestPath;
|
|
127
|
-
}
|
|
128
|
-
async findPath(pred) {
|
|
129
|
-
// The base class's version reports paths as absolute paths from within
|
|
130
|
-
// a mount in a virtual filesystem.
|
|
131
|
-
const mountedPath = await super.findPath(pred);
|
|
132
|
-
if (!mountedPath) {
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
// The path relative to the workspace's target directory.
|
|
136
|
-
const relPath = path.relative(this._mount, mountedPath);
|
|
137
|
-
// Now find the true absolute path of the target directory on the host system.
|
|
138
|
-
const cargo = await execa('cargo', [
|
|
139
|
-
'metadata',
|
|
140
|
-
'--format-version=1',
|
|
141
|
-
'--no-deps',
|
|
142
|
-
...(this._manifestPath ? ['--manifest-path', this._manifestPath] : [])
|
|
143
|
-
], {
|
|
144
|
-
shell: true
|
|
145
|
-
});
|
|
146
|
-
if (cargo.exitCode !== 0) {
|
|
147
|
-
throw new Error(`Invoking \`cargo metadata\` failed: ${cargo.stderr}`);
|
|
148
|
-
}
|
|
149
|
-
const cargoMetadata = JSON.parse(cargo.stdout);
|
|
150
|
-
// Finally, re-parent the relative path into an absolute path on the host system.
|
|
151
|
-
const absPath = path.join(cargoMetadata.target_directory, relPath);
|
|
152
|
-
return absPath;
|
|
153
|
-
}
|
|
154
|
-
}
|
package/dist/command.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import Dist from './commands/dist.js';
|
|
2
|
-
import PackBuild from './commands/pack-build.js';
|
|
3
|
-
import InstallBuilds from './commands/install-builds.js';
|
|
4
|
-
import Help from './commands/help.js';
|
|
5
|
-
export var CommandName;
|
|
6
|
-
(function (CommandName) {
|
|
7
|
-
CommandName["Help"] = "help";
|
|
8
|
-
CommandName["Dist"] = "dist";
|
|
9
|
-
CommandName["PackBuild"] = "pack-build";
|
|
10
|
-
CommandName["InstallBuilds"] = "install-builds";
|
|
11
|
-
})(CommandName = CommandName || (CommandName = {}));
|
|
12
|
-
;
|
|
13
|
-
export function isCommandName(s) {
|
|
14
|
-
const keys = Object.values(CommandName);
|
|
15
|
-
return keys.includes(s);
|
|
16
|
-
}
|
|
17
|
-
export function asCommandName(name) {
|
|
18
|
-
if (!isCommandName(name)) {
|
|
19
|
-
throw new RangeError(`Command not recognized: ${name}`);
|
|
20
|
-
}
|
|
21
|
-
return name;
|
|
22
|
-
}
|
|
23
|
-
const COMMANDS = {
|
|
24
|
-
[CommandName.Help]: Help,
|
|
25
|
-
[CommandName.Dist]: Dist,
|
|
26
|
-
[CommandName.PackBuild]: PackBuild,
|
|
27
|
-
[CommandName.InstallBuilds]: InstallBuilds
|
|
28
|
-
};
|
|
29
|
-
export function commandFor(name) {
|
|
30
|
-
return COMMANDS[name];
|
|
31
|
-
}
|
|
32
|
-
export function summaries() {
|
|
33
|
-
return [
|
|
34
|
-
{ name: CommandName.Help, summary: Help.summary() },
|
|
35
|
-
{ name: CommandName.Dist, summary: Dist.summary() },
|
|
36
|
-
{ name: CommandName.PackBuild, summary: PackBuild.summary() },
|
|
37
|
-
{ name: CommandName.InstallBuilds, summary: InstallBuilds.summary() }
|
|
38
|
-
];
|
|
39
|
-
}
|
package/dist/commands/dist.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { copyFile } from 'node:fs/promises';
|
|
2
|
-
import commandLineArgs from 'command-line-args';
|
|
3
|
-
import { MessageStream, UnmountMessageStream, isCompilerArtifact } from '../cargo.js';
|
|
4
|
-
// FIXME: add options to infer crate name from manifests
|
|
5
|
-
// --package <path/to/package.json>
|
|
6
|
-
// --crate <path/to/Cargo.toml>
|
|
7
|
-
const OPTIONS = [
|
|
8
|
-
{ name: 'name', alias: 'n', type: String, defaultValue: null },
|
|
9
|
-
{ name: 'file', alias: 'f', type: String, defaultValue: null },
|
|
10
|
-
{ name: 'log', alias: 'l', type: String, defaultValue: null },
|
|
11
|
-
{ name: 'mount', alias: 'm', type: String, defaultValue: null },
|
|
12
|
-
{ name: 'manifest-path', type: String, defaultValue: null },
|
|
13
|
-
{ name: 'out', alias: 'o', type: String, defaultValue: 'index.node' }
|
|
14
|
-
];
|
|
15
|
-
export default class Dist {
|
|
16
|
-
static summary() { return 'Generate a .node file from a build.'; }
|
|
17
|
-
static syntax() { return 'neon dist [-n <name>] [-f <dylib>|[-l <log>] [-m <path>]] [-o <dist>]'; }
|
|
18
|
-
static options() {
|
|
19
|
-
return [
|
|
20
|
-
{ name: '-n, --name', summary: 'Crate name. (Default: $npm_package_name)' },
|
|
21
|
-
{ name: '-f, --file <dylib>', summary: 'Build .node from dylib file <dylib>.' },
|
|
22
|
-
{ name: '-l, --log <log>', summary: 'Find dylib path from cargo messages <log>. (Default: stdin)' },
|
|
23
|
-
{
|
|
24
|
-
name: '-m, --mount <path>',
|
|
25
|
-
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.'
|
|
26
|
-
},
|
|
27
|
-
{ name: '--manifest-path <path>', summary: 'Real path to Cargo.toml. (Default: cargo behavior)' },
|
|
28
|
-
{ name: '-o, --out <dist>', summary: 'Copy output to file <dist>. (Default: index.node)' }
|
|
29
|
-
];
|
|
30
|
-
}
|
|
31
|
-
static seeAlso() {
|
|
32
|
-
return [
|
|
33
|
-
{ name: 'cargo messages', summary: '<https://doc.rust-lang.org/cargo/reference/external-tools.html>' },
|
|
34
|
-
{ name: 'cross-rs', summary: '<https://github.com/cross-rs/cross>' }
|
|
35
|
-
];
|
|
36
|
-
}
|
|
37
|
-
constructor(argv) {
|
|
38
|
-
const options = commandLineArgs(OPTIONS, { argv });
|
|
39
|
-
if (options.log && options.file) {
|
|
40
|
-
throw new Error("Options --log and --file cannot both be enabled.");
|
|
41
|
-
}
|
|
42
|
-
if (options.file && options.mount) {
|
|
43
|
-
throw new Error("Options --mount and --file cannot both be enabled.");
|
|
44
|
-
}
|
|
45
|
-
if (options['manifest-path'] && !options.mount) {
|
|
46
|
-
throw new Error("Option --manifest-path requires option --mount to be provided.");
|
|
47
|
-
}
|
|
48
|
-
this._log = options.log ?? null;
|
|
49
|
-
this._file = options.file ?? null;
|
|
50
|
-
this._mount = options.mount;
|
|
51
|
-
this._manifestPath = options['manifest-path'];
|
|
52
|
-
this._crateName = options.name || process.env['npm_package_name'];
|
|
53
|
-
this._out = options.out;
|
|
54
|
-
}
|
|
55
|
-
async findArtifact() {
|
|
56
|
-
const stream = this._mount
|
|
57
|
-
? new UnmountMessageStream(this._mount, this._manifestPath, this._log)
|
|
58
|
-
: new MessageStream(this._log);
|
|
59
|
-
return await stream.findPath((msg) => {
|
|
60
|
-
if (!isCompilerArtifact(msg) || (msg.target.name !== this._crateName)) {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
const index = msg.target.crate_types.indexOf('cdylib');
|
|
64
|
-
return (index < 0) ? null : msg.filenames[index];
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
async run() {
|
|
68
|
-
const file = this._file || await this.findArtifact();
|
|
69
|
-
if (!file) {
|
|
70
|
-
throw new Error(`No library found for crate ${this._crateName}`);
|
|
71
|
-
}
|
|
72
|
-
// FIXME: needs all the logic of cargo-cp-artifact (timestamp check, M1 workaround, async, errors)
|
|
73
|
-
await copyFile(file, this._out);
|
|
74
|
-
}
|
|
75
|
-
}
|
package/dist/commands/help.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { printMainUsage, printCommandUsage } from '../print.js';
|
|
2
|
-
import { asCommandName } from '../command.js';
|
|
3
|
-
export default class Help {
|
|
4
|
-
static summary() { return 'Display help information about Neon.'; }
|
|
5
|
-
static syntax() { return 'neon help <command>'; }
|
|
6
|
-
static options() {
|
|
7
|
-
return [
|
|
8
|
-
{ name: '<command>', summary: 'Command to display help information about.' }
|
|
9
|
-
];
|
|
10
|
-
}
|
|
11
|
-
static seeAlso() { }
|
|
12
|
-
constructor(argv) {
|
|
13
|
-
this._name = argv.length > 0 ? asCommandName(argv[0]) : undefined;
|
|
14
|
-
if (argv.length > 1) {
|
|
15
|
-
throw new Error(`Unexpected argument: ${argv[1]}`);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
async run() {
|
|
19
|
-
if (this._name) {
|
|
20
|
-
printCommandUsage(this._name);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
printMainUsage();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|