@yao-pkg/pkg 5.15.0 → 5.16.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/README.md +38 -2
- package/lib-es5/chmod.js +3 -3
- package/lib-es5/colors.js +12 -0
- package/lib-es5/help.js +22 -25
- package/lib-es5/index.js +17 -16
- package/lib-es5/packer.js +5 -7
- package/lib-es5/producer.js +16 -16
- package/lib-es5/refiner.js +2 -2
- package/lib-es5/walker.js +16 -14
- package/package.json +29 -32
package/README.md
CHANGED
|
@@ -162,7 +162,7 @@ use of `package.json` configuration.
|
|
|
162
162
|
|
|
163
163
|
### Scripts
|
|
164
164
|
|
|
165
|
-
`scripts` is a [glob](https://github.com/
|
|
165
|
+
`scripts` is a [glob](https://github.com/SuperchupuDev/tinyglobby)
|
|
166
166
|
or list of globs. Files specified as `scripts` will be compiled
|
|
167
167
|
using `v8::ScriptCompiler` and placed into executable without
|
|
168
168
|
sources. They must conform to the JS standards of those Node.js versions
|
|
@@ -170,7 +170,7 @@ you target (see [Targets](#targets)), i.e. be already transpiled.
|
|
|
170
170
|
|
|
171
171
|
### Assets
|
|
172
172
|
|
|
173
|
-
`assets` is a [glob](https://github.com/
|
|
173
|
+
`assets` is a [glob](https://github.com/SuperchupuDev/tinyglobby)
|
|
174
174
|
or list of globs. Files specified as `assets` will be packaged
|
|
175
175
|
into executable as raw content without modifications. Javascript
|
|
176
176
|
files may also be specified as `assets`. Their sources will
|
|
@@ -400,6 +400,14 @@ await exec(['app.js', '--target', 'host', '--output', 'app.exe']);
|
|
|
400
400
|
// do something with app.exe, run, test, upload, deploy, etc
|
|
401
401
|
```
|
|
402
402
|
|
|
403
|
+
## Use custom Node.js binary
|
|
404
|
+
|
|
405
|
+
In case you want to use custom node binary, you can set `PKG_NODE_PATH` environment variable to the path of the node binary you want to use and `pkg` will use it instead of the default one.
|
|
406
|
+
|
|
407
|
+
```bash
|
|
408
|
+
PKG_NODE_PATH=/path/to/node pkg app.js
|
|
409
|
+
```
|
|
410
|
+
|
|
403
411
|
## Troubleshooting
|
|
404
412
|
|
|
405
413
|
### Error: Cannot find module XXX (when using `child_process`)
|
|
@@ -419,6 +427,34 @@ const child = spawn(process.execPath, [process.argv[1]], {
|
|
|
419
427
|
|
|
420
428
|
More info [here](https://github.com/yao-pkg/pkg/pull/90)
|
|
421
429
|
|
|
430
|
+
### Error: Cannot execute binaray from snapshot
|
|
431
|
+
|
|
432
|
+
Binaries must be extracted from snapshot in order to be executed. In order to do this you can use this approach:
|
|
433
|
+
|
|
434
|
+
```js
|
|
435
|
+
const cp = require('child_process');
|
|
436
|
+
const fs = require('fs');
|
|
437
|
+
const { pipeline } = require('stream/promises');
|
|
438
|
+
|
|
439
|
+
let ffmpeg = require('@ffmpeg-installer/ffmpeg').path;
|
|
440
|
+
|
|
441
|
+
const loadPlugin = async () => {
|
|
442
|
+
if (process.pkg) {
|
|
443
|
+
// copy ffmpeg to the current directory
|
|
444
|
+
const file = fs.createWriteStream('ffmpeg');
|
|
445
|
+
await pipeline(fs.createReadStream(ffmpeg), file);
|
|
446
|
+
|
|
447
|
+
fs.chmodSync('ffmpeg', 0o755);
|
|
448
|
+
console.log('ffmpeg copied to the current directory');
|
|
449
|
+
ffmpeg = './ffmpeg';
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
cp.execSync(ffmpeg);
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
loadPlugin();
|
|
456
|
+
```
|
|
457
|
+
|
|
422
458
|
### Error: ENOENT: no such file or directory, uv_chdir
|
|
423
459
|
|
|
424
460
|
This error can be caused by deleting the directory the application is
|
package/lib-es5/chmod.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.plusx = void 0;
|
|
4
|
-
const
|
|
4
|
+
const promises_1 = require("fs/promises");
|
|
5
5
|
async function plusx(file) {
|
|
6
|
-
const s = await (0,
|
|
6
|
+
const s = await (0, promises_1.stat)(file);
|
|
7
7
|
const newMode = s.mode | 64 | 8 | 1;
|
|
8
8
|
if (s.mode === newMode) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
11
|
const base8 = newMode.toString(8).slice(-3);
|
|
12
|
-
await (0,
|
|
12
|
+
await (0, promises_1.chmod)(file, base8);
|
|
13
13
|
}
|
|
14
14
|
exports.plusx = plusx;
|
|
15
15
|
//# sourceMappingURL=chmod.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.pc = void 0;
|
|
7
|
+
const picocolors_1 = __importDefault(require("picocolors"));
|
|
8
|
+
const tty_1 = require("tty");
|
|
9
|
+
// makes color detection more accurate using node's own API for it
|
|
10
|
+
// https://github.com/alexeyraspopov/picocolors/issues/85
|
|
11
|
+
exports.pc = picocolors_1.default.createColors(tty_1.WriteStream.prototype.hasColors());
|
|
12
|
+
//# sourceMappingURL=colors.js.map
|
package/lib-es5/help.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
3
|
+
const colors_1 = require("./colors");
|
|
7
4
|
function help() {
|
|
8
5
|
// eslint-disable-next-line no-console
|
|
9
6
|
console.log(`
|
|
10
|
-
${
|
|
7
|
+
${colors_1.pc.bold('pkg')} [options] <input>
|
|
11
8
|
|
|
12
|
-
${
|
|
9
|
+
${colors_1.pc.dim('Options:')}
|
|
13
10
|
|
|
14
11
|
-h, --help output usage information
|
|
15
12
|
-v, --version output pkg version
|
|
@@ -27,26 +24,26 @@ function help() {
|
|
|
27
24
|
--no-dict comma-separated list of packages names to ignore dictionaries. Use --no-dict * to disable all dictionaries
|
|
28
25
|
-C, --compress [default=None] compression algorithm = Brotli or GZip
|
|
29
26
|
|
|
30
|
-
${
|
|
27
|
+
${colors_1.pc.dim('Examples:')}
|
|
31
28
|
|
|
32
|
-
${
|
|
33
|
-
${
|
|
34
|
-
${
|
|
35
|
-
${
|
|
36
|
-
${
|
|
37
|
-
${
|
|
38
|
-
${
|
|
39
|
-
${
|
|
40
|
-
${
|
|
41
|
-
${
|
|
42
|
-
${
|
|
43
|
-
${
|
|
44
|
-
${
|
|
45
|
-
${
|
|
46
|
-
${
|
|
47
|
-
${
|
|
48
|
-
${
|
|
49
|
-
${
|
|
29
|
+
${colors_1.pc.gray('–')} Makes executables for Linux, macOS and Windows
|
|
30
|
+
${colors_1.pc.cyan('$ pkg index.js')}
|
|
31
|
+
${colors_1.pc.gray('–')} Takes package.json from cwd and follows 'bin' entry
|
|
32
|
+
${colors_1.pc.cyan('$ pkg .')}
|
|
33
|
+
${colors_1.pc.gray('–')} Makes executable for particular target machine
|
|
34
|
+
${colors_1.pc.cyan('$ pkg -t node14-win-arm64 index.js')}
|
|
35
|
+
${colors_1.pc.gray('–')} Makes executables for target machines of your choice
|
|
36
|
+
${colors_1.pc.cyan('$ pkg -t node16-linux,node18-linux,node18-win index.js')}
|
|
37
|
+
${colors_1.pc.gray('–')} Bakes '--expose-gc' and '--max-heap-size=34' into executable
|
|
38
|
+
${colors_1.pc.cyan('$ pkg --options "expose-gc,max-heap-size=34" index.js')}
|
|
39
|
+
${colors_1.pc.gray('–')} Consider packageA and packageB to be public
|
|
40
|
+
${colors_1.pc.cyan('$ pkg --public-packages "packageA,packageB" index.js')}
|
|
41
|
+
${colors_1.pc.gray('–')} Consider all packages to be public
|
|
42
|
+
${colors_1.pc.cyan('$ pkg --public-packages "*" index.js')}
|
|
43
|
+
${colors_1.pc.gray('–')} Bakes '--expose-gc' into executable
|
|
44
|
+
${colors_1.pc.cyan('$ pkg --options expose-gc index.js')}
|
|
45
|
+
${colors_1.pc.gray('–')} reduce size of the data packed inside the executable with GZip
|
|
46
|
+
${colors_1.pc.cyan('$ pkg --compress GZip index.js')}
|
|
50
47
|
`);
|
|
51
48
|
}
|
|
52
49
|
exports.default = help;
|
package/lib-es5/index.js
CHANGED
|
@@ -6,7 +6,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.exec = void 0;
|
|
8
8
|
const assert_1 = __importDefault(require("assert"));
|
|
9
|
-
const
|
|
9
|
+
const fs_1 = require("fs");
|
|
10
|
+
const promises_1 = require("fs/promises");
|
|
10
11
|
const minimist_1 = __importDefault(require("minimist"));
|
|
11
12
|
const pkg_fetch_1 = require("@yao-pkg/pkg-fetch");
|
|
12
13
|
const path_1 = __importDefault(require("path"));
|
|
@@ -22,7 +23,7 @@ const walker_1 = __importDefault(require("./walker"));
|
|
|
22
23
|
const compress_type_1 = require("./compress_type");
|
|
23
24
|
const mach_o_1 = require("./mach-o");
|
|
24
25
|
const options_1 = __importDefault(require("./options"));
|
|
25
|
-
const { version } = JSON.parse((0,
|
|
26
|
+
const { version } = JSON.parse((0, fs_1.readFileSync)(path_1.default.join(__dirname, '../package.json'), 'utf-8'));
|
|
26
27
|
function isConfiguration(file) {
|
|
27
28
|
return (0, common_1.isPackageJson)(file) || file.endsWith('.config.json');
|
|
28
29
|
}
|
|
@@ -230,12 +231,12 @@ async function exec(argv2) {
|
|
|
230
231
|
}
|
|
231
232
|
// input
|
|
232
233
|
let input = path_1.default.resolve(argv._[0]);
|
|
233
|
-
if (!(0,
|
|
234
|
+
if (!(0, fs_1.existsSync)(input)) {
|
|
234
235
|
throw (0, log_1.wasReported)('Input file does not exist', [input]);
|
|
235
236
|
}
|
|
236
|
-
if ((await (0,
|
|
237
|
+
if ((await (0, promises_1.stat)(input)).isDirectory()) {
|
|
237
238
|
input = path_1.default.join(input, 'package.json');
|
|
238
|
-
if (!(0,
|
|
239
|
+
if (!(0, fs_1.existsSync)(input)) {
|
|
239
240
|
throw (0, log_1.wasReported)('Input file does not exist', [input]);
|
|
240
241
|
}
|
|
241
242
|
}
|
|
@@ -243,7 +244,7 @@ async function exec(argv2) {
|
|
|
243
244
|
let inputJson;
|
|
244
245
|
let inputJsonName;
|
|
245
246
|
if (isConfiguration(input)) {
|
|
246
|
-
inputJson = JSON.parse(await (0,
|
|
247
|
+
inputJson = JSON.parse(await (0, promises_1.readFile)(input, 'utf-8'));
|
|
247
248
|
inputJsonName = inputJson.name;
|
|
248
249
|
if (inputJsonName) {
|
|
249
250
|
inputJsonName = inputJsonName.split('/').pop(); // @org/foo
|
|
@@ -263,7 +264,7 @@ async function exec(argv2) {
|
|
|
263
264
|
}
|
|
264
265
|
}
|
|
265
266
|
inputBin = path_1.default.resolve(path_1.default.dirname(input), bin);
|
|
266
|
-
if (!(0,
|
|
267
|
+
if (!(0, fs_1.existsSync)(inputBin)) {
|
|
267
268
|
throw (0, log_1.wasReported)('Bin file does not exist (taken from package.json ' +
|
|
268
269
|
"'bin' property)", [inputBin]);
|
|
269
270
|
}
|
|
@@ -283,7 +284,7 @@ async function exec(argv2) {
|
|
|
283
284
|
let configJson;
|
|
284
285
|
if (config) {
|
|
285
286
|
config = path_1.default.resolve(config);
|
|
286
|
-
if (!(0,
|
|
287
|
+
if (!(0, fs_1.existsSync)(config)) {
|
|
287
288
|
throw (0, log_1.wasReported)('Config file does not exist', [config]);
|
|
288
289
|
}
|
|
289
290
|
// eslint-disable-next-line import/no-dynamic-require, global-require
|
|
@@ -418,8 +419,8 @@ async function exec(argv2) {
|
|
|
418
419
|
// ad-hoc sign the base binary temporarily to generate bytecode
|
|
419
420
|
// due to the new mandatory signing requirement
|
|
420
421
|
const signedBinaryPath = `${f.binaryPath}-signed`;
|
|
421
|
-
await (0,
|
|
422
|
-
(0,
|
|
422
|
+
await (0, promises_1.rm)(signedBinaryPath, { recursive: true, force: true });
|
|
423
|
+
(0, fs_1.copyFileSync)(f.binaryPath, signedBinaryPath);
|
|
423
424
|
try {
|
|
424
425
|
(0, mach_o_1.signMachOExecutable)(signedBinaryPath);
|
|
425
426
|
}
|
|
@@ -489,9 +490,9 @@ async function exec(argv2) {
|
|
|
489
490
|
const backpack = (0, packer_1.default)({ records, entrypoint, bytecode, symLinks });
|
|
490
491
|
log_1.log.debug('Targets:', JSON.stringify(targets, null, 2));
|
|
491
492
|
for (const target of targets) {
|
|
492
|
-
if (target.output && (0,
|
|
493
|
-
if ((await (0,
|
|
494
|
-
await (0,
|
|
493
|
+
if (target.output && (0, fs_1.existsSync)(target.output)) {
|
|
494
|
+
if ((await (0, promises_1.stat)(target.output)).isFile()) {
|
|
495
|
+
await (0, promises_1.rm)(target.output, { recursive: true, force: true });
|
|
495
496
|
}
|
|
496
497
|
else {
|
|
497
498
|
throw (0, log_1.wasReported)('Refusing to overwrite non-file output', [
|
|
@@ -500,7 +501,7 @@ async function exec(argv2) {
|
|
|
500
501
|
}
|
|
501
502
|
}
|
|
502
503
|
else if (target.output) {
|
|
503
|
-
await (0,
|
|
504
|
+
await (0, promises_1.mkdir)(path_1.default.dirname(target.output), { recursive: true });
|
|
504
505
|
}
|
|
505
506
|
await (0, producer_1.default)({
|
|
506
507
|
backpack,
|
|
@@ -514,8 +515,8 @@ async function exec(argv2) {
|
|
|
514
515
|
if (target.platform !== 'win' && target.output) {
|
|
515
516
|
if (argv.signature && target.platform === 'macos') {
|
|
516
517
|
// patch executable to allow code signing
|
|
517
|
-
const buf = (0, mach_o_1.patchMachOExecutable)((0,
|
|
518
|
-
(0,
|
|
518
|
+
const buf = (0, mach_o_1.patchMachOExecutable)((0, fs_1.readFileSync)(target.output));
|
|
519
|
+
(0, fs_1.writeFileSync)(target.output, buf);
|
|
519
520
|
try {
|
|
520
521
|
// sign executable ad-hoc to workaround the new mandatory signing requirement
|
|
521
522
|
// users can always replace the signature if necessary
|
package/lib-es5/packer.js
CHANGED
|
@@ -5,16 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
const assert_1 = __importDefault(require("assert"));
|
|
8
|
-
const
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const common_1 = require("./common");
|
|
11
11
|
const log_1 = require("./log");
|
|
12
|
-
const { version } = JSON.parse(
|
|
13
|
-
const bootstrapText =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const commonText = fs_extra_1.default.readFileSync(require.resolve('./common'), 'utf8');
|
|
17
|
-
const diagnosticText = fs_extra_1.default.readFileSync(require.resolve('../prelude/diagnostic.js'), 'utf8');
|
|
12
|
+
const { version } = JSON.parse((0, fs_1.readFileSync)(path_1.default.join(__dirname, '../package.json'), 'utf-8'));
|
|
13
|
+
const bootstrapText = (0, fs_1.readFileSync)(require.resolve('../prelude/bootstrap.js'), 'utf8').replace('%VERSION%', version);
|
|
14
|
+
const commonText = (0, fs_1.readFileSync)(require.resolve('./common'), 'utf8');
|
|
15
|
+
const diagnosticText = (0, fs_1.readFileSync)(require.resolve('../prelude/diagnostic.js'), 'utf8');
|
|
18
16
|
function itemsToText(items) {
|
|
19
17
|
const len = items.length;
|
|
20
18
|
return len.toString() + (len % 10 === 1 ? ' item' : ' items');
|
package/lib-es5/producer.js
CHANGED
|
@@ -7,7 +7,7 @@ const zlib_1 = require("zlib");
|
|
|
7
7
|
const multistream_1 = __importDefault(require("multistream"));
|
|
8
8
|
const assert_1 = __importDefault(require("assert"));
|
|
9
9
|
const child_process_1 = require("child_process");
|
|
10
|
-
const
|
|
10
|
+
const fs_1 = __importDefault(require("fs"));
|
|
11
11
|
const into_stream_1 = __importDefault(require("into-stream"));
|
|
12
12
|
const path_1 = __importDefault(require("path"));
|
|
13
13
|
const stream_meter_1 = __importDefault(require("stream-meter"));
|
|
@@ -57,7 +57,7 @@ function injectPlaceholder(fd, placeholder, value, cb) {
|
|
|
57
57
|
}
|
|
58
58
|
const padding = Buffer.from(padder.repeat(size - stringValue.length));
|
|
59
59
|
stringValue = Buffer.concat([stringValue, padding]);
|
|
60
|
-
|
|
60
|
+
fs_1.default.write(fd, stringValue, 0, stringValue.length, position, cb);
|
|
61
61
|
}
|
|
62
62
|
function discoverPlaceholders(binaryBuffer) {
|
|
63
63
|
return {
|
|
@@ -112,7 +112,7 @@ function findPackageJson(nodeFile) {
|
|
|
112
112
|
let dir = nodeFile;
|
|
113
113
|
while (dir !== '/') {
|
|
114
114
|
dir = path_1.default.dirname(dir);
|
|
115
|
-
if (
|
|
115
|
+
if (fs_1.default.existsSync(path_1.default.join(dir, 'package.json'))) {
|
|
116
116
|
break;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
@@ -130,7 +130,7 @@ function nativePrebuildInstall(target, nodeFile) {
|
|
|
130
130
|
var _a, _b;
|
|
131
131
|
const prebuildInstall = path_1.default.join(__dirname, '../node_modules/.bin/prebuild-install');
|
|
132
132
|
const dir = findPackageJson(nodeFile);
|
|
133
|
-
const packageJson = JSON.parse(
|
|
133
|
+
const packageJson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(dir, 'package.json'), { encoding: 'utf-8' }));
|
|
134
134
|
// only try prebuild-install for packages that actually use it or if
|
|
135
135
|
// explicitly configured via environment variables
|
|
136
136
|
const envPrefix = getPrebuildEnvPrefix(packageJson.name);
|
|
@@ -148,12 +148,12 @@ function nativePrebuildInstall(target, nodeFile) {
|
|
|
148
148
|
throw new Error(`Couldn't find node version, instead got: ${nodeVersion}`);
|
|
149
149
|
}
|
|
150
150
|
const nativeFile = `${nodeFile}.${target.platform}.${target.arch}.${nodeVersion}`;
|
|
151
|
-
if (
|
|
151
|
+
if (fs_1.default.existsSync(nativeFile)) {
|
|
152
152
|
return nativeFile;
|
|
153
153
|
}
|
|
154
154
|
// prebuild-install will overwrite the target .node file, so take a backup
|
|
155
|
-
if (!
|
|
156
|
-
|
|
155
|
+
if (!fs_1.default.existsSync(`${nodeFile}.bak`)) {
|
|
156
|
+
fs_1.default.copyFileSync(nodeFile, `${nodeFile}.bak`);
|
|
157
157
|
}
|
|
158
158
|
const napiVersions = (_b = packageJson === null || packageJson === void 0 ? void 0 : packageJson.binary) === null || _b === void 0 ? void 0 : _b.napi_versions;
|
|
159
159
|
const options = [
|
|
@@ -172,9 +172,9 @@ function nativePrebuildInstall(target, nodeFile) {
|
|
|
172
172
|
// run prebuild
|
|
173
173
|
(0, child_process_1.execFileSync)(prebuildInstall, options, { cwd: dir });
|
|
174
174
|
// move the prebuild to a new name with a platform/version extension
|
|
175
|
-
|
|
175
|
+
fs_1.default.copyFileSync(nodeFile, nativeFile);
|
|
176
176
|
// put the backed up file back
|
|
177
|
-
|
|
177
|
+
fs_1.default.renameSync(`${nodeFile}.bak`, nodeFile);
|
|
178
178
|
return nativeFile;
|
|
179
179
|
}
|
|
180
180
|
/**
|
|
@@ -269,7 +269,7 @@ function producer({ backpack, bakes, slash, target, symLinks, doCompress, native
|
|
|
269
269
|
count += 1;
|
|
270
270
|
return pipeToNewMeter(s);
|
|
271
271
|
}
|
|
272
|
-
const binaryBuffer =
|
|
272
|
+
const binaryBuffer = fs_1.default.readFileSync(target.binaryPath);
|
|
273
273
|
const placeholders = discoverPlaceholders(binaryBuffer);
|
|
274
274
|
let track = 0;
|
|
275
275
|
let prevStripe;
|
|
@@ -322,15 +322,15 @@ function producer({ backpack, bakes, slash, target, symLinks, doCompress, native
|
|
|
322
322
|
if ((0, common_1.isDotNODE)(stripe.file) && nativeBuild) {
|
|
323
323
|
try {
|
|
324
324
|
const platformFile = nativePrebuildInstall(target, stripe.file);
|
|
325
|
-
if (platformFile &&
|
|
326
|
-
return cb(null, pipeMayCompressToNewMeter(
|
|
325
|
+
if (platformFile && fs_1.default.existsSync(platformFile)) {
|
|
326
|
+
return cb(null, pipeMayCompressToNewMeter(fs_1.default.createReadStream(platformFile)));
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
catch (err) {
|
|
330
330
|
log_1.log.debug(`prebuild-install failed[${stripe.file}]:`, err.message);
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
|
-
return cb(null, pipeMayCompressToNewMeter(
|
|
333
|
+
return cb(null, pipeMayCompressToNewMeter(fs_1.default.createReadStream(stripe.file)));
|
|
334
334
|
}
|
|
335
335
|
(0, assert_1.default)(false, 'producer: bad stripe');
|
|
336
336
|
}
|
|
@@ -347,13 +347,13 @@ function producer({ backpack, bakes, slash, target, symLinks, doCompress, native
|
|
|
347
347
|
.on('error', (error) => {
|
|
348
348
|
reject(error);
|
|
349
349
|
})
|
|
350
|
-
.pipe(
|
|
350
|
+
.pipe(fs_1.default.createWriteStream(target.output))
|
|
351
351
|
.on('error', (error) => {
|
|
352
352
|
reject(error);
|
|
353
353
|
})
|
|
354
354
|
.on('close', () => {
|
|
355
355
|
preludeSize = meter.bytes;
|
|
356
|
-
|
|
356
|
+
fs_1.default.open(target.output, 'r+', (error, fd) => {
|
|
357
357
|
if (error)
|
|
358
358
|
return reject(error);
|
|
359
359
|
injectPlaceholders(fd, placeholders, {
|
|
@@ -365,7 +365,7 @@ function producer({ backpack, bakes, slash, target, symLinks, doCompress, native
|
|
|
365
365
|
}, (error2) => {
|
|
366
366
|
if (error2)
|
|
367
367
|
return reject(error2);
|
|
368
|
-
|
|
368
|
+
fs_1.default.close(fd, (error3) => {
|
|
369
369
|
if (error3)
|
|
370
370
|
return reject(error3);
|
|
371
371
|
resolve();
|
package/lib-es5/refiner.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const path_1 = __importDefault(require("path"));
|
|
7
|
-
const
|
|
7
|
+
const colors_1 = require("./colors");
|
|
8
8
|
const common_1 = require("./common");
|
|
9
9
|
const log_1 = require("./log");
|
|
10
10
|
const win32 = process.platform === 'win32';
|
|
@@ -34,7 +34,7 @@ function purgeTopDirectories(records) {
|
|
|
34
34
|
const links3 = record3[common_1.STORE_LINKS];
|
|
35
35
|
if (links3) {
|
|
36
36
|
delete records[file];
|
|
37
|
-
log_1.log.debug(
|
|
37
|
+
log_1.log.debug(colors_1.pc.cyan(`Deleting record file: ${file}`));
|
|
38
38
|
found = true;
|
|
39
39
|
}
|
|
40
40
|
}
|
package/lib-es5/walker.js
CHANGED
|
@@ -28,13 +28,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
30
|
const assert_1 = __importDefault(require("assert"));
|
|
31
|
-
const
|
|
32
|
-
const globby_1 = __importDefault(require("globby"));
|
|
31
|
+
const promises_1 = __importDefault(require("fs/promises"));
|
|
33
32
|
const path_1 = __importDefault(require("path"));
|
|
34
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
35
|
-
const minimatch_1 = require("minimatch");
|
|
36
33
|
const module_1 = require("module");
|
|
34
|
+
const picomatch_1 = __importDefault(require("picomatch"));
|
|
35
|
+
const tinyglobby_1 = require("tinyglobby");
|
|
37
36
|
const common_1 = require("./common");
|
|
37
|
+
const colors_1 = require("./colors");
|
|
38
38
|
const follow_1 = require("./follow");
|
|
39
39
|
const log_1 = require("./log");
|
|
40
40
|
const detector = __importStar(require("./detector"));
|
|
@@ -141,7 +141,7 @@ function upon(p, base) {
|
|
|
141
141
|
return p;
|
|
142
142
|
}
|
|
143
143
|
function collect(ps) {
|
|
144
|
-
return
|
|
144
|
+
return (0, tinyglobby_1.globSync)(ps, { absolute: true, dot: true });
|
|
145
145
|
}
|
|
146
146
|
function expandFiles(efs, base) {
|
|
147
147
|
if (!Array.isArray(efs)) {
|
|
@@ -156,7 +156,7 @@ async function stepRead(record) {
|
|
|
156
156
|
}
|
|
157
157
|
let body;
|
|
158
158
|
try {
|
|
159
|
-
body = await
|
|
159
|
+
body = await promises_1.default.readFile(record.file);
|
|
160
160
|
}
|
|
161
161
|
catch (error) {
|
|
162
162
|
const exception = error;
|
|
@@ -347,7 +347,9 @@ class Walker {
|
|
|
347
347
|
const { ignore } = options_1.default.get();
|
|
348
348
|
if (ignore) {
|
|
349
349
|
// check if the file matches one of the ignore regex patterns
|
|
350
|
-
const match =
|
|
350
|
+
const match = picomatch_1.default.isMatch(realFile, ignore, {
|
|
351
|
+
windows: win32,
|
|
352
|
+
});
|
|
351
353
|
if (match) {
|
|
352
354
|
log_1.log.debug(`Ignoring file: ${realFile} due to top level config ignore pattern`);
|
|
353
355
|
return;
|
|
@@ -372,7 +374,7 @@ class Walker {
|
|
|
372
374
|
if (scripts) {
|
|
373
375
|
scripts = expandFiles(scripts, base);
|
|
374
376
|
for (const script of scripts) {
|
|
375
|
-
const stat = await
|
|
377
|
+
const stat = await promises_1.default.stat(script);
|
|
376
378
|
if (stat.isFile()) {
|
|
377
379
|
if (!(0, common_1.isDotJS)(script) && !(0, common_1.isDotJSON)(script) && !(0, common_1.isDotNODE)(script)) {
|
|
378
380
|
log_1.log.warn("Non-javascript file is specified in 'scripts'.", [
|
|
@@ -394,7 +396,7 @@ class Walker {
|
|
|
394
396
|
assets = expandFiles(assets, base);
|
|
395
397
|
for (const asset of assets) {
|
|
396
398
|
log_1.log.debug(' Adding asset : .... ', asset);
|
|
397
|
-
const stat = await
|
|
399
|
+
const stat = await promises_1.default.stat(asset);
|
|
398
400
|
if (stat.isFile()) {
|
|
399
401
|
this.appendBlobOrContent({
|
|
400
402
|
file: (0, common_1.normalizePath)(asset),
|
|
@@ -412,7 +414,7 @@ class Walker {
|
|
|
412
414
|
files = expandFiles(files, base);
|
|
413
415
|
for (let file of files) {
|
|
414
416
|
file = (0, common_1.normalizePath)(file);
|
|
415
|
-
const stat = await
|
|
417
|
+
const stat = await promises_1.default.stat(file);
|
|
416
418
|
if (stat.isFile()) {
|
|
417
419
|
// 1) remove sources of top-level(!) package 'files' i.e. ship as BLOB
|
|
418
420
|
// 2) non-source (non-js) files of top-level package are shipped as CONTENT
|
|
@@ -561,7 +563,7 @@ class Walker {
|
|
|
561
563
|
const file = (0, common_1.normalizePath)(path_1.default.join(path_1.default.dirname(record.file), derivative.alias));
|
|
562
564
|
let stat;
|
|
563
565
|
try {
|
|
564
|
-
stat = await
|
|
566
|
+
stat = await promises_1.default.stat(file);
|
|
565
567
|
}
|
|
566
568
|
catch (error) {
|
|
567
569
|
const { toplevel } = marker;
|
|
@@ -630,7 +632,7 @@ class Walker {
|
|
|
630
632
|
]);
|
|
631
633
|
}
|
|
632
634
|
else {
|
|
633
|
-
log_1.log[level](`${
|
|
635
|
+
log_1.log[level](`${colors_1.pc.yellow(failure.message)} in ${record.file}`);
|
|
634
636
|
}
|
|
635
637
|
return;
|
|
636
638
|
}
|
|
@@ -766,7 +768,7 @@ class Walker {
|
|
|
766
768
|
});
|
|
767
769
|
}
|
|
768
770
|
try {
|
|
769
|
-
const valueStat = await
|
|
771
|
+
const valueStat = await promises_1.default.stat(record.file);
|
|
770
772
|
const value = {
|
|
771
773
|
mode: valueStat.mode,
|
|
772
774
|
size: valueStat.isFile() ? valueStat.size : 0,
|
|
@@ -816,7 +818,7 @@ class Walker {
|
|
|
816
818
|
return;
|
|
817
819
|
}
|
|
818
820
|
const dd = path_1.default.join(__dirname, '../dictionary');
|
|
819
|
-
const files = await
|
|
821
|
+
const files = await promises_1.default.readdir(dd);
|
|
820
822
|
for (const file of files) {
|
|
821
823
|
if (/\.js$/.test(file)) {
|
|
822
824
|
const name = file.slice(0, -3);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yao-pkg/pkg",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.16.0",
|
|
4
4
|
"description": "Package your Node.js project into an executable",
|
|
5
5
|
"main": "lib-es5/index.js",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,47 +22,44 @@
|
|
|
22
22
|
"singleQuote": true
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@babel/generator": "7.23.0",
|
|
26
|
-
"@babel/parser": "7.23.0",
|
|
27
|
-
"@babel/types": "7.23.0",
|
|
28
|
-
"@yao-pkg/pkg-fetch": "3.5.
|
|
29
|
-
"chalk": "^4.1.2",
|
|
30
|
-
"fs-extra": "^9.1.0",
|
|
31
|
-
"globby": "^11.1.0",
|
|
25
|
+
"@babel/generator": "^7.23.0",
|
|
26
|
+
"@babel/parser": "^7.23.0",
|
|
27
|
+
"@babel/types": "^7.23.0",
|
|
28
|
+
"@yao-pkg/pkg-fetch": "3.5.15",
|
|
32
29
|
"into-stream": "^6.0.0",
|
|
33
|
-
"minimatch": "9.0.4",
|
|
34
30
|
"minimist": "^1.2.6",
|
|
35
31
|
"multistream": "^4.1.0",
|
|
36
|
-
"
|
|
32
|
+
"picocolors": "^1.1.0",
|
|
33
|
+
"picomatch": "^4.0.2",
|
|
34
|
+
"prebuild-install": "^7.1.1",
|
|
37
35
|
"resolve": "^1.22.0",
|
|
38
|
-
"stream-meter": "^1.0.4"
|
|
36
|
+
"stream-meter": "^1.0.4",
|
|
37
|
+
"tinyglobby": "^0.2.9"
|
|
39
38
|
},
|
|
40
39
|
"devDependencies": {
|
|
41
|
-
"@babel/core": "7.23.0",
|
|
42
|
-
"@release-it/conventional-changelog": "7.0.2",
|
|
43
|
-
"@types/babel__generator": "7.6.5",
|
|
44
|
-
"@types/
|
|
45
|
-
"@types/
|
|
46
|
-
"@types/
|
|
47
|
-
"@types/
|
|
48
|
-
"@types/
|
|
49
|
-
"@types/
|
|
50
|
-
"@
|
|
51
|
-
"@typescript-eslint/
|
|
52
|
-
"
|
|
53
|
-
"eslint": "
|
|
54
|
-
"eslint-config-airbnb-
|
|
55
|
-
"eslint-config-
|
|
56
|
-
"eslint-
|
|
57
|
-
"eslint-plugin-import": "2.28.1",
|
|
40
|
+
"@babel/core": "^7.23.0",
|
|
41
|
+
"@release-it/conventional-changelog": "^7.0.2",
|
|
42
|
+
"@types/babel__generator": "^7.6.5",
|
|
43
|
+
"@types/minimist": "^1.2.2",
|
|
44
|
+
"@types/multistream": "^4.1.0",
|
|
45
|
+
"@types/node": "^16.18.113",
|
|
46
|
+
"@types/picomatch": "^3.0.1",
|
|
47
|
+
"@types/resolve": "^1.20.2",
|
|
48
|
+
"@types/stream-meter": "^0.0.22",
|
|
49
|
+
"@typescript-eslint/eslint-plugin": "^6.7.4",
|
|
50
|
+
"@typescript-eslint/parser": "^6.7.4",
|
|
51
|
+
"eslint": "^8.50.0",
|
|
52
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
53
|
+
"eslint-config-airbnb-typescript": "^17.1.0",
|
|
54
|
+
"eslint-config-prettier": "^9.0.0",
|
|
55
|
+
"eslint-plugin-import": "^2.28.1",
|
|
58
56
|
"json-stable-stringify": "^1.0.1",
|
|
59
57
|
"lint-staged": "^10.5.4",
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"release-it": "16.2.1",
|
|
58
|
+
"prettier": "^3.0.3",
|
|
59
|
+
"release-it": "^16.2.1",
|
|
63
60
|
"rimraf": "^3.0.2",
|
|
64
61
|
"simple-git-hooks": ">=2.8.0",
|
|
65
|
-
"typescript": "4.7.2"
|
|
62
|
+
"typescript": "^4.7.2"
|
|
66
63
|
},
|
|
67
64
|
"scripts": {
|
|
68
65
|
"clean": "rimraf lib-es5",
|