@solidactions/cli 3.1.0 → 3.3.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/dist/command-manifest.json +4101 -0
- package/dist/commands/connection-list.js +61 -0
- package/dist/commands/device-login.js +7 -5
- package/dist/commands/env-reset.js +60 -0
- package/dist/commands/env-set.js +19 -2
- package/dist/commands/login.js +201 -44
- package/dist/index.js +57 -28
- package/dist/utils/api.js +89 -5
- package/dist/utils/command-manifest.js +221 -0
- package/dist/utils/config-write-target.js +47 -10
- package/package.json +2 -2
|
@@ -12,6 +12,23 @@ const path_1 = __importDefault(require("path"));
|
|
|
12
12
|
const readline_1 = __importDefault(require("readline"));
|
|
13
13
|
const chalk_1 = __importDefault(require("chalk"));
|
|
14
14
|
const config_1 = require("./config");
|
|
15
|
+
async function askReadlineQuestion(rl, label) {
|
|
16
|
+
if (rl.closed)
|
|
17
|
+
return undefined;
|
|
18
|
+
return new Promise((resolve) => {
|
|
19
|
+
let answered = false;
|
|
20
|
+
const onClose = () => {
|
|
21
|
+
if (!answered)
|
|
22
|
+
resolve(undefined);
|
|
23
|
+
};
|
|
24
|
+
rl.once('close', onClose);
|
|
25
|
+
rl.question(label, (answer) => {
|
|
26
|
+
answered = true;
|
|
27
|
+
rl.removeListener('close', onClose);
|
|
28
|
+
resolve(answer);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
15
32
|
/**
|
|
16
33
|
* Decide whether a write should target the local or global config file,
|
|
17
34
|
* mirroring the contract used by `login`:
|
|
@@ -20,7 +37,7 @@ const config_1 = require("./config");
|
|
|
20
37
|
* - Else if TTY, prompt.
|
|
21
38
|
* - Else error and exit.
|
|
22
39
|
*/
|
|
23
|
-
async function decideWriteTarget(options, promptLabel = 'Save config locally (./.solidactions) or globally (~/.solidactions)? [global] ', refusalMessage = 'Refusing to write config non-interactively. Pass --local or --global.') {
|
|
40
|
+
async function decideWriteTarget(options, promptLabel = 'Save config locally (./.solidactions) or globally (~/.solidactions)? [global] ', refusalMessage = 'Refusing to write config non-interactively. Pass --local or --global.', dependencies = {}) {
|
|
24
41
|
if (options.local && options.global) {
|
|
25
42
|
console.error(chalk_1.default.red('Error: --local and --global are mutually exclusive.'));
|
|
26
43
|
process.exit(1);
|
|
@@ -29,11 +46,21 @@ async function decideWriteTarget(options, promptLabel = 'Save config locally (./
|
|
|
29
46
|
return 'local';
|
|
30
47
|
if (options.global)
|
|
31
48
|
return 'global';
|
|
32
|
-
|
|
33
|
-
|
|
49
|
+
const isTTY = dependencies.isTTY ?? process.stdin.isTTY === true;
|
|
50
|
+
if (isTTY) {
|
|
51
|
+
const rl = dependencies.question
|
|
52
|
+
? null
|
|
53
|
+
: readline_1.default.createInterface({ input: process.stdin, output: process.stdout });
|
|
34
54
|
try {
|
|
35
55
|
while (true) {
|
|
36
|
-
const
|
|
56
|
+
const label = chalk_1.default.blue(promptLabel);
|
|
57
|
+
const answer = dependencies.question
|
|
58
|
+
? await dependencies.question(label)
|
|
59
|
+
: await askReadlineQuestion(rl, label);
|
|
60
|
+
if (answer === undefined) {
|
|
61
|
+
console.error(chalk_1.default.red('Input closed before a config destination was selected. No changes were made.'));
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
37
64
|
const normalized = answer.trim().toLowerCase();
|
|
38
65
|
if (normalized === '' || normalized === 'global' || normalized === 'g')
|
|
39
66
|
return 'global';
|
|
@@ -43,7 +70,7 @@ async function decideWriteTarget(options, promptLabel = 'Save config locally (./
|
|
|
43
70
|
}
|
|
44
71
|
}
|
|
45
72
|
finally {
|
|
46
|
-
rl
|
|
73
|
+
rl?.close();
|
|
47
74
|
}
|
|
48
75
|
}
|
|
49
76
|
console.error(chalk_1.default.red(refusalMessage));
|
|
@@ -59,19 +86,29 @@ function pathForTarget(target) {
|
|
|
59
86
|
* automatically so they never wedge; an interactive TTY additionally asks a
|
|
60
87
|
* y/N confirm (default N).
|
|
61
88
|
*/
|
|
62
|
-
async function confirmOverwrite(existingPath, backupPath) {
|
|
89
|
+
async function confirmOverwrite(existingPath, backupPath, dependencies = {}) {
|
|
63
90
|
const notice = `Existing config at ${existingPath} will be overwritten (backup will be saved to ${backupPath}).`;
|
|
64
|
-
|
|
91
|
+
const isTTY = dependencies.isTTY ?? process.stdin.isTTY === true;
|
|
92
|
+
if (!isTTY) {
|
|
65
93
|
console.log(chalk_1.default.yellow(notice));
|
|
66
94
|
return true;
|
|
67
95
|
}
|
|
68
|
-
const rl =
|
|
96
|
+
const rl = dependencies.question
|
|
97
|
+
? null
|
|
98
|
+
: readline_1.default.createInterface({ input: process.stdin, output: process.stdout });
|
|
69
99
|
try {
|
|
70
|
-
const
|
|
100
|
+
const label = chalk_1.default.yellow(`${notice} Continue? [y/N] `);
|
|
101
|
+
const answer = dependencies.question
|
|
102
|
+
? await dependencies.question(label)
|
|
103
|
+
: await askReadlineQuestion(rl, label);
|
|
104
|
+
if (answer === undefined) {
|
|
105
|
+
console.log(chalk_1.default.yellow('Overwrite confirmation input closed; treating it as a decline.'));
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
71
108
|
return answer.trim().toLowerCase().startsWith('y');
|
|
72
109
|
}
|
|
73
110
|
finally {
|
|
74
|
-
rl
|
|
111
|
+
rl?.close();
|
|
75
112
|
}
|
|
76
113
|
}
|
|
77
114
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidactions/cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "SolidActions CLI - Deploy and manage workflow automation",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"deploy"
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
|
-
"build": "tsc && cp src/commands/dev-shim.mjs dist/commands/dev-shim.mjs && cp src/utils/archiver-loader.cjs dist/utils/archiver-loader.cjs",
|
|
35
|
+
"build": "tsc && cp src/commands/dev-shim.mjs dist/commands/dev-shim.mjs && cp src/utils/archiver-loader.cjs dist/utils/archiver-loader.cjs && node scripts/generate-command-manifest.mjs",
|
|
36
36
|
"check:release": "npm run build && npm run test && npm run smoke:init",
|
|
37
37
|
"prepublishOnly": "npm run build",
|
|
38
38
|
"smoke:init": "node scripts/smoke-init.mjs",
|