@pippit-dev/cli 1.0.21 → 1.0.22
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 +65 -1
- package/checksums.txt +6 -6
- package/cmd/canvas/canvas.go +2 -0
- package/cmd/canvas/canvas_test.go +2 -2
- package/cmd/canvas/command_help.go +40 -0
- package/cmd/root.go +4 -3
- package/cmd/root_test.go +38 -0
- package/dist/checksums.txt +6 -6
- package/dist/xyq-canvas-command-runtime.cjs +14 -14
- package/dist/xyq-canvas-command-runtime.cjs.LEGAL.txt +235 -3
- package/dist/xyq-canvas-command-runtime.cjs.sha256 +2 -2
- package/package.json +7 -3
- package/scripts/canvas-command-discovery.js +202 -0
- package/scripts/canvas-command-guides.js +171 -0
- package/scripts/canvas-command.js +100 -23
- package/scripts/install-wizard.js +46 -22
- package/scripts/run.js +58 -42
package/scripts/run.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const { execFileSync } = require(
|
|
4
|
-
const fs = require(
|
|
5
|
-
const path = require(
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
runCanvasCommand,
|
|
9
|
-
} = require("./canvas-command");
|
|
10
|
-
const { maybeWarnNewVersion } = require("./version-check");
|
|
3
|
+
const { execFileSync } = require('child_process');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const { isCanvasCommand, runCanvasCommand } = require('./canvas-command');
|
|
7
|
+
const { maybeWarnNewVersion } = require('./version-check');
|
|
11
8
|
|
|
12
|
-
const ext = process.platform ===
|
|
13
|
-
const bin = path.join(__dirname,
|
|
9
|
+
const ext = process.platform === 'win32' ? '.exe' : '';
|
|
10
|
+
const bin = path.join(__dirname, '..', 'bin', 'pippit-tool-cli' + ext);
|
|
14
11
|
const args = process.argv.slice(2);
|
|
15
12
|
|
|
16
|
-
const oldBin = bin +
|
|
13
|
+
const oldBin = bin + '.old';
|
|
17
14
|
function restoreOldBinary() {
|
|
18
15
|
try {
|
|
19
16
|
if (fs.existsSync(bin)) {
|
|
@@ -26,57 +23,76 @@ function restoreOldBinary() {
|
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
25
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
function runCanvas() {
|
|
27
|
+
runCanvasCommand(args, {
|
|
28
|
+
nativeInvocation: { command: bin },
|
|
29
|
+
})
|
|
30
|
+
.then((exitCode) => {
|
|
31
|
+
if (exitCode) process.exitCode = exitCode;
|
|
32
|
+
})
|
|
33
|
+
.catch((error) => {
|
|
34
|
+
console.error(error && error.message ? error.message : String(error));
|
|
35
|
+
process.exitCode = 1;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function main() {
|
|
40
|
+
// Installation help must work before any native binary preparation.
|
|
41
|
+
if (args[0] === 'install') {
|
|
42
|
+
return require('./install-wizard.js').main(args.slice(1));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const helpRequested = args.includes('--help') || args.includes('-h') || args[0] === 'help';
|
|
46
|
+
if (isCanvasCommand(args) && (args[2] !== 'run' || helpRequested)) {
|
|
47
|
+
return runCanvas();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!helpRequested && args.length > 0 && process.platform === 'win32' && fs.existsSync(oldBin)) {
|
|
51
|
+
if (!fs.existsSync(bin)) {
|
|
37
52
|
restoreOldBinary();
|
|
53
|
+
} else {
|
|
54
|
+
try {
|
|
55
|
+
execFileSync(bin, ['--help'], { stdio: 'ignore', timeout: 10000 });
|
|
56
|
+
fs.rmSync(oldBin, { force: true });
|
|
57
|
+
} catch (_) {
|
|
58
|
+
restoreOldBinary();
|
|
59
|
+
}
|
|
38
60
|
}
|
|
39
61
|
}
|
|
40
|
-
}
|
|
41
62
|
|
|
42
|
-
|
|
43
|
-
// should run the JS setup flow before the native binary exists.
|
|
44
|
-
if (args[0] === "install") {
|
|
45
|
-
require("./install-wizard.js").main();
|
|
46
|
-
} else {
|
|
47
|
-
maybeWarnNewVersion(args);
|
|
63
|
+
if (!helpRequested && args.length > 0) maybeWarnNewVersion(args);
|
|
48
64
|
|
|
49
65
|
if (!fs.existsSync(bin)) {
|
|
66
|
+
if (helpRequested || args.length === 0) {
|
|
67
|
+
console.error(
|
|
68
|
+
'Native CLI binary is missing. Reinstall @pippit-dev/cli to restore native command help; canvas command --help and install --help remain available.',
|
|
69
|
+
);
|
|
70
|
+
process.exitCode = 1;
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
50
73
|
try {
|
|
51
|
-
execFileSync(process.execPath, [path.join(__dirname,
|
|
52
|
-
stdio:
|
|
53
|
-
env: { ...process.env, PIPPIT_CLI_RUN:
|
|
74
|
+
execFileSync(process.execPath, [path.join(__dirname, 'install.js')], {
|
|
75
|
+
stdio: 'inherit',
|
|
76
|
+
env: { ...process.env, PIPPIT_CLI_RUN: 'true' },
|
|
54
77
|
});
|
|
55
78
|
} catch (_) {
|
|
56
79
|
console.error(
|
|
57
|
-
|
|
58
|
-
|
|
80
|
+
'\nFailed to prepare pippit-tool-cli binary.\n' +
|
|
81
|
+
'Check your network connection and reinstall the npm package to download the prebuilt binary.\n',
|
|
59
82
|
);
|
|
60
83
|
process.exit(1);
|
|
61
84
|
}
|
|
62
85
|
}
|
|
63
86
|
|
|
64
87
|
if (isCanvasCommand(args)) {
|
|
65
|
-
|
|
66
|
-
nativeInvocation: { command: bin },
|
|
67
|
-
})
|
|
68
|
-
.then((exitCode) => {
|
|
69
|
-
if (exitCode) process.exitCode = exitCode;
|
|
70
|
-
})
|
|
71
|
-
.catch((error) => {
|
|
72
|
-
console.error(error && error.message ? error.message : String(error));
|
|
73
|
-
process.exitCode = 1;
|
|
74
|
-
});
|
|
88
|
+
runCanvas();
|
|
75
89
|
} else {
|
|
76
90
|
try {
|
|
77
|
-
execFileSync(bin, args, { stdio:
|
|
91
|
+
execFileSync(bin, args, { stdio: 'inherit' });
|
|
78
92
|
} catch (e) {
|
|
79
93
|
process.exit(e.status || 1);
|
|
80
94
|
}
|
|
81
95
|
}
|
|
82
96
|
}
|
|
97
|
+
|
|
98
|
+
main();
|