nodejs-sea 1.1.0 → 1.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/cli.js +24 -36
- package/package.json +27 -27
package/lib/cli.js
CHANGED
|
@@ -17,18 +17,6 @@ var nv = require('@pkgjs/nv');
|
|
|
17
17
|
var tar = require('tar');
|
|
18
18
|
var undici = require('undici');
|
|
19
19
|
|
|
20
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
21
|
-
|
|
22
|
-
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
23
|
-
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
24
|
-
var dotenv__default = /*#__PURE__*/_interopDefaultLegacy(dotenv);
|
|
25
|
-
var chalk__default = /*#__PURE__*/_interopDefaultLegacy(chalk);
|
|
26
|
-
var cliProgress__default = /*#__PURE__*/_interopDefaultLegacy(cliProgress);
|
|
27
|
-
var crypto__default = /*#__PURE__*/_interopDefaultLegacy(crypto);
|
|
28
|
-
var zlib__default = /*#__PURE__*/_interopDefaultLegacy(zlib);
|
|
29
|
-
var nv__default = /*#__PURE__*/_interopDefaultLegacy(nv);
|
|
30
|
-
var tar__default = /*#__PURE__*/_interopDefaultLegacy(tar);
|
|
31
|
-
|
|
32
20
|
class LoggerImpl {
|
|
33
21
|
constructor() {
|
|
34
22
|
this.currentStep = "";
|
|
@@ -39,7 +27,7 @@ class LoggerImpl {
|
|
|
39
27
|
this.stepCompleted();
|
|
40
28
|
}
|
|
41
29
|
this.currentStep = info;
|
|
42
|
-
console.warn(`${
|
|
30
|
+
console.warn(`${chalk.yellow("→")} ${info} ...`);
|
|
43
31
|
}
|
|
44
32
|
_stepDone() {
|
|
45
33
|
this.currentStep = "";
|
|
@@ -51,14 +39,14 @@ class LoggerImpl {
|
|
|
51
39
|
stepCompleted() {
|
|
52
40
|
const doneText = this.currentStep;
|
|
53
41
|
this._stepDone();
|
|
54
|
-
console.warn(
|
|
42
|
+
console.warn(chalk.green(` ✓ Completed: ${doneText}`));
|
|
55
43
|
}
|
|
56
44
|
stepFailed(err) {
|
|
57
45
|
this._stepDone();
|
|
58
|
-
console.warn(
|
|
46
|
+
console.warn(chalk.red(` ✖ Failed: ${err.message}`));
|
|
59
47
|
}
|
|
60
48
|
startProgress(maximum) {
|
|
61
|
-
this.cliProgress = new
|
|
49
|
+
this.cliProgress = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);
|
|
62
50
|
this.cliProgress.start(maximum, 0);
|
|
63
51
|
}
|
|
64
52
|
doProgress(current) {
|
|
@@ -82,17 +70,17 @@ class NodeUtils {
|
|
|
82
70
|
}
|
|
83
71
|
if (inputIsFileUrl) {
|
|
84
72
|
logger.stepStarting(`Extracting tarball from ${range} to ${dir}`);
|
|
85
|
-
|
|
86
|
-
await promises.pipeline(fs.createReadStream(url.fileURLToPath(range)),
|
|
73
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
74
|
+
await promises.pipeline(fs.createReadStream(url.fileURLToPath(range)), zlib.createGunzip(), tar.x({
|
|
87
75
|
cwd: dir,
|
|
88
76
|
}));
|
|
89
77
|
logger.stepCompleted();
|
|
90
|
-
const filesInDir =
|
|
78
|
+
const filesInDir = fs.readdirSync(dir, { withFileTypes: true });
|
|
91
79
|
const dirsInDir = filesInDir.filter((f) => f.isDirectory());
|
|
92
80
|
if (dirsInDir.length !== 1) {
|
|
93
81
|
throw new Error("Node.js tarballs should contain exactly one directory");
|
|
94
82
|
}
|
|
95
|
-
return
|
|
83
|
+
return path.join(dir, dirsInDir[0].name);
|
|
96
84
|
}
|
|
97
85
|
let releaseBaseUrl;
|
|
98
86
|
let version;
|
|
@@ -101,7 +89,7 @@ class NodeUtils {
|
|
|
101
89
|
releaseBaseUrl = `https://nodejs.org/download/nightly/${version}`;
|
|
102
90
|
}
|
|
103
91
|
else {
|
|
104
|
-
const ver = (await
|
|
92
|
+
const ver = (await nv(range)).pop();
|
|
105
93
|
if (!ver) {
|
|
106
94
|
throw new Error(`No node version found for ${range}`);
|
|
107
95
|
}
|
|
@@ -113,11 +101,11 @@ class NodeUtils {
|
|
|
113
101
|
const ext = platform === "win32" ? "zip" : "tar.gz";
|
|
114
102
|
const cachedName = `node-${version}-${nodePlatform}-${arch}`;
|
|
115
103
|
const tarballName = `${cachedName}.${ext}`;
|
|
116
|
-
const cachedTarballPath =
|
|
117
|
-
const cachedNodePath =
|
|
104
|
+
const cachedTarballPath = path.join(dir, tarballName);
|
|
105
|
+
const cachedNodePath = path.join(dir, cachedName, platform === "win32" ? "node.exe" : path.join("bin", "node"));
|
|
118
106
|
let hasCachedTarball = false;
|
|
119
107
|
try {
|
|
120
|
-
hasCachedTarball =
|
|
108
|
+
hasCachedTarball = fs.statSync(cachedTarballPath).size > 0;
|
|
121
109
|
}
|
|
122
110
|
catch { }
|
|
123
111
|
if (hasCachedTarball) {
|
|
@@ -141,7 +129,7 @@ class NodeUtils {
|
|
|
141
129
|
return null;
|
|
142
130
|
})(),
|
|
143
131
|
(async () => {
|
|
144
|
-
const hash =
|
|
132
|
+
const hash = crypto.createHash("sha256");
|
|
145
133
|
await promises.pipeline(fs.createReadStream(cachedTarballPath), hash);
|
|
146
134
|
return hash.digest("hex");
|
|
147
135
|
})(),
|
|
@@ -157,7 +145,7 @@ class NodeUtils {
|
|
|
157
145
|
let tarballStream;
|
|
158
146
|
let tarballWritePromise;
|
|
159
147
|
if (hasCachedTarball) {
|
|
160
|
-
const hasNodePath =
|
|
148
|
+
const hasNodePath = fs.statSync(cachedNodePath).size > 0;
|
|
161
149
|
if (hasNodePath) {
|
|
162
150
|
return cachedNodePath;
|
|
163
151
|
}
|
|
@@ -171,7 +159,7 @@ class NodeUtils {
|
|
|
171
159
|
throw new Error(`Could not download Node.js source tarball: ${tarball.statusCode}`);
|
|
172
160
|
}
|
|
173
161
|
logger.stepStarting(`Unpacking tarball to ${dir}`);
|
|
174
|
-
|
|
162
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
175
163
|
const contentLength = +((_a = tarball.headers["content-length"]) !== null && _a !== void 0 ? _a : 0);
|
|
176
164
|
if (contentLength) {
|
|
177
165
|
logger.startProgress(contentLength);
|
|
@@ -196,7 +184,7 @@ class NodeUtils {
|
|
|
196
184
|
}
|
|
197
185
|
else {
|
|
198
186
|
await Promise.all([
|
|
199
|
-
promises.pipeline(tarballStream,
|
|
187
|
+
promises.pipeline(tarballStream, zlib.createGunzip(), tar.x({
|
|
200
188
|
cwd: dir,
|
|
201
189
|
})),
|
|
202
190
|
tarballWritePromise,
|
|
@@ -259,9 +247,9 @@ class PackCommand extends clipanion.Command {
|
|
|
259
247
|
var _a, _b, _c, _d, _e, _f;
|
|
260
248
|
const logger = new LoggerImpl();
|
|
261
249
|
const nodeUtils = new NodeUtils();
|
|
262
|
-
const tmpdir =
|
|
250
|
+
const tmpdir = path.join(currentWorkingDirectory, "node_modules/.cache/nodejs-sea");
|
|
263
251
|
const configFilePath = (_a = this.input) !== null && _a !== void 0 ? _a : "sea/config.json";
|
|
264
|
-
const configContent =
|
|
252
|
+
const configContent = fs.readFileSync(configFilePath).toString();
|
|
265
253
|
const nodeVersion = (_b = this.nodeVersion) !== null && _b !== void 0 ? _b : "22.11.0";
|
|
266
254
|
let config;
|
|
267
255
|
try {
|
|
@@ -277,10 +265,10 @@ class PackCommand extends clipanion.Command {
|
|
|
277
265
|
const platform = (_d = this.platform) !== null && _d !== void 0 ? _d : process.platform;
|
|
278
266
|
const nodeSourcePath = await nodeUtils.getNodeSourceForVersion(nodeVersion, tmpdir, logger, platform);
|
|
279
267
|
const executableName = platform === "win32" ? "app.exe" : "app";
|
|
280
|
-
const appPath =
|
|
268
|
+
const appPath = path.join(outputPath, executableName);
|
|
281
269
|
logger.stepStarting("Cleaning dist directory");
|
|
282
270
|
await rimraf.rimraf(outputPath, { glob: false });
|
|
283
|
-
|
|
271
|
+
fs.mkdirSync(outputPath, { recursive: true });
|
|
284
272
|
logger.stepCompleted();
|
|
285
273
|
if (Array.isArray(copyFiles) && copyFiles.length > 0) {
|
|
286
274
|
logger.stepStarting("Copy files");
|
|
@@ -292,10 +280,10 @@ class PackCommand extends clipanion.Command {
|
|
|
292
280
|
if (esbuildConfig) {
|
|
293
281
|
// Load env file
|
|
294
282
|
const envFile = (_e = this.envFile) !== null && _e !== void 0 ? _e : ".env";
|
|
295
|
-
const envPath =
|
|
296
|
-
if (
|
|
283
|
+
const envPath = path.resolve(currentWorkingDirectory, envFile);
|
|
284
|
+
if (fs.existsSync(envPath)) {
|
|
297
285
|
logger.stepStarting("Run esbuild - with env");
|
|
298
|
-
|
|
286
|
+
dotenv.config({ path: envPath });
|
|
299
287
|
esbuildConfig.define = {
|
|
300
288
|
...esbuildConfig.define,
|
|
301
289
|
...Object.fromEntries(Object.entries(process.env).map(([key, value]) => [`process.env.${key}`, JSON.stringify(value)])),
|
|
@@ -328,7 +316,7 @@ class PackCommand extends clipanion.Command {
|
|
|
328
316
|
logger.stepStarting("Remove generated files");
|
|
329
317
|
const cleanFiles = [config.output];
|
|
330
318
|
if (esbuildConfig === null || esbuildConfig === void 0 ? void 0 : esbuildConfig.outfile) {
|
|
331
|
-
cleanFiles.push(
|
|
319
|
+
cleanFiles.push(path.resolve(currentWorkingDirectory, esbuildConfig.outfile));
|
|
332
320
|
}
|
|
333
321
|
await this.execCommand("rm", cleanFiles);
|
|
334
322
|
logger.stepCompleted();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nodejs-sea",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A powerful package for NodeJS single executable applications (SEA), support good for NestJS framework",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,46 +26,46 @@
|
|
|
26
26
|
"node": ">=18"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@rollup/plugin-commonjs": "^
|
|
30
|
-
"@rollup/plugin-node-resolve": "^
|
|
31
|
-
"@rollup/plugin-typescript": "^
|
|
29
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
30
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
31
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
32
32
|
"@types/adm-zip": "^0.5.7",
|
|
33
33
|
"@types/cli-progress": "^3.11.6",
|
|
34
|
-
"@types/node": "^
|
|
35
|
-
"@types/tar": "^
|
|
36
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
37
|
-
"@typescript-eslint/parser": "^
|
|
38
|
-
"@yarnpkg/eslint-config": "^1.0
|
|
39
|
-
"eslint": "^
|
|
40
|
-
"eslint-config-prettier": "^
|
|
34
|
+
"@types/node": "^25.3.2",
|
|
35
|
+
"@types/tar": "^7.0.87",
|
|
36
|
+
"@typescript-eslint/eslint-plugin": "^8.56.1",
|
|
37
|
+
"@typescript-eslint/parser": "^8.56.1",
|
|
38
|
+
"@yarnpkg/eslint-config": "^3.1.0",
|
|
39
|
+
"eslint": "^10.0.2",
|
|
40
|
+
"eslint-config-prettier": "^10.1.8",
|
|
41
41
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
|
42
42
|
"eslint-plugin-import": "^2.29.1",
|
|
43
|
-
"eslint-plugin-prettier": "^
|
|
44
|
-
"eslint-plugin-promise": "^
|
|
43
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
44
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
45
45
|
"husky": "^9.1.7",
|
|
46
|
-
"lint-staged": "^
|
|
47
|
-
"prettier": "
|
|
48
|
-
"rollup": "^
|
|
49
|
-
"rollup-plugin-multi-input": "^1.
|
|
46
|
+
"lint-staged": "^16.2.7",
|
|
47
|
+
"prettier": "3.8.1",
|
|
48
|
+
"rollup": "^4.59.0",
|
|
49
|
+
"rollup-plugin-multi-input": "^1.7.0",
|
|
50
50
|
"rollup-plugin-preserve-shebang": "^1.0.1",
|
|
51
51
|
"rollup-plugin-terser": "^7.0.2",
|
|
52
52
|
"standard-version": "^9.5.0",
|
|
53
|
-
"terser": "^5.
|
|
53
|
+
"terser": "^5.46.0",
|
|
54
54
|
"ts-node": "^10.9.1",
|
|
55
|
-
"typescript": "^
|
|
55
|
+
"typescript": "^5.9.3"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@pkgjs/nv": "^0.
|
|
58
|
+
"@pkgjs/nv": "^0.3.0",
|
|
59
59
|
"adm-zip": "^0.5.16",
|
|
60
|
-
"chalk": "^
|
|
60
|
+
"chalk": "^4.1.2",
|
|
61
61
|
"cli-progress": "^3.12.0",
|
|
62
|
-
"clipanion": "
|
|
63
|
-
"dotenv": "^17.
|
|
64
|
-
"esbuild": "^0.
|
|
62
|
+
"clipanion": "4.0.0-rc.4",
|
|
63
|
+
"dotenv": "^17.3.1",
|
|
64
|
+
"esbuild": "^0.27.3",
|
|
65
65
|
"postject": "^1.0.0-alpha.6",
|
|
66
|
-
"rimraf": "^6.
|
|
67
|
-
"tar": "^7.
|
|
68
|
-
"undici": "^7.
|
|
66
|
+
"rimraf": "^6.1.3",
|
|
67
|
+
"tar": "^7.5.9",
|
|
68
|
+
"undici": "^7.22.0"
|
|
69
69
|
},
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"main": "lib/index"
|