@getxflow/cli 0.6.0 → 0.6.2
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/commands/mcp.js +6 -19
- package/dist/commands/update.js +12 -14
- package/dist/spawn.js +20 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/commands/mcp.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mcpInstall = mcpInstall;
|
|
4
|
-
const node_child_process_1 = require("node:child_process");
|
|
5
4
|
const node_os_1 = require("node:os");
|
|
6
5
|
const node_path_1 = require("node:path");
|
|
7
6
|
const api_1 = require("../api");
|
|
8
7
|
const args_1 = require("../args");
|
|
9
8
|
const config_1 = require("../config");
|
|
10
9
|
const session_1 = require("../session");
|
|
10
|
+
const spawn_1 = require("../spawn");
|
|
11
11
|
const ui_1 = require("../ui");
|
|
12
12
|
/** Clients with their own server-add command. */
|
|
13
13
|
const CLIENTS = [
|
|
@@ -28,23 +28,10 @@ const CLIENTS = [
|
|
|
28
28
|
reset: ['mcp', 'remove', 'xflow', '-s', 'local'],
|
|
29
29
|
},
|
|
30
30
|
];
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
* Windows needs a shell to resolve npm's .cmd shims, and the shell joins
|
|
34
|
-
* arguments instead of escaping them: quote by hand.
|
|
35
|
-
*/
|
|
36
|
-
function quote(value) {
|
|
37
|
-
return WINDOWS ? `"${value.replace(/"/g, '""')}"` : value;
|
|
38
|
-
}
|
|
39
|
-
function execute(binary, args) {
|
|
40
|
-
// Capture output: clients may echo the added header together with the key.
|
|
41
|
-
const options = { encoding: 'utf-8' };
|
|
42
|
-
return WINDOWS
|
|
43
|
-
? (0, node_child_process_1.spawnSync)([binary, ...args.map(quote)].join(' '), { ...options, shell: true })
|
|
44
|
-
: (0, node_child_process_1.spawnSync)(binary, args, options);
|
|
45
|
-
}
|
|
31
|
+
// Output is captured, not inherited: clients may echo the added header together
|
|
32
|
+
// with the key.
|
|
46
33
|
function hasBinary(binary) {
|
|
47
|
-
return
|
|
34
|
+
return (0, spawn_1.run)(binary, ['--version']).status === 0;
|
|
48
35
|
}
|
|
49
36
|
async function mcpInstall(args) {
|
|
50
37
|
// The server covers the organization: the command works outside a project folder too.
|
|
@@ -62,8 +49,8 @@ async function mcpInstall(args) {
|
|
|
62
49
|
continue;
|
|
63
50
|
found++;
|
|
64
51
|
(0, ui_1.step)(`Writing into ${target.label}`);
|
|
65
|
-
|
|
66
|
-
const result =
|
|
52
|
+
(0, spawn_1.run)(target.binary, [...target.reset]);
|
|
53
|
+
const result = (0, spawn_1.run)(target.binary, target.args(url, client.token));
|
|
67
54
|
if (result.status === 0) {
|
|
68
55
|
installed++;
|
|
69
56
|
(0, ui_1.ok)(`${target.label}: the xflow server is connected`);
|
package/dist/commands/update.js
CHANGED
|
@@ -6,6 +6,7 @@ const node_child_process_1 = require("node:child_process");
|
|
|
6
6
|
const node_fs_1 = require("node:fs");
|
|
7
7
|
const node_path_1 = require("node:path");
|
|
8
8
|
const errors_1 = require("../errors");
|
|
9
|
+
const spawn_1 = require("../spawn");
|
|
9
10
|
const ui_1 = require("../ui");
|
|
10
11
|
const version_1 = require("../version");
|
|
11
12
|
const PACKAGE = '@getxflow/cli';
|
|
@@ -55,19 +56,14 @@ function projectManifest(dir) {
|
|
|
55
56
|
return null;
|
|
56
57
|
}
|
|
57
58
|
function npmRoot() {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
stdio: ['ignore', 'pipe', 'ignore'],
|
|
64
|
-
});
|
|
65
|
-
const dir = output.trim();
|
|
66
|
-
return dir.length > 0 && (0, node_fs_1.existsSync)(dir) ? dir : null;
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
59
|
+
const result = (0, spawn_1.run)('npm', ['root', '-g'], {
|
|
60
|
+
timeout: 60_000,
|
|
61
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
62
|
+
});
|
|
63
|
+
if (result.error || result.status !== 0 || typeof result.stdout !== 'string')
|
|
69
64
|
return null;
|
|
70
|
-
|
|
65
|
+
const dir = result.stdout.trim();
|
|
66
|
+
return dir.length > 0 && (0, node_fs_1.existsSync)(dir) ? dir : null;
|
|
71
67
|
}
|
|
72
68
|
function packageDir(root) {
|
|
73
69
|
return (0, node_path_1.join)(root, '@getxflow', 'cli');
|
|
@@ -133,9 +129,11 @@ function update() {
|
|
|
133
129
|
return;
|
|
134
130
|
}
|
|
135
131
|
(0, ui_1.step)(`updating ${PACKAGE} from ${version_1.CLI_VERSION}`);
|
|
136
|
-
|
|
132
|
+
// --prefer-online: npm trusts its cached package metadata for five minutes, and a
|
|
133
|
+
// release younger than that installs as "already the latest" while the notice from
|
|
134
|
+
// the platform keeps saying otherwise. Update means ask the registry.
|
|
135
|
+
const result = (0, spawn_1.run)('npm', ['i', '-g', `${PACKAGE}@latest`, '--prefer-online'], {
|
|
137
136
|
stdio: 'inherit',
|
|
138
|
-
shell: WINDOWS,
|
|
139
137
|
});
|
|
140
138
|
if (result.error) {
|
|
141
139
|
throw new errors_1.CliError(`Could not run npm: ${result.error.message}`, `Install by hand: npm i -g ${PACKAGE}@latest`);
|
package/dist/spawn.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.run = run;
|
|
4
|
+
const node_child_process_1 = require("node:child_process");
|
|
5
|
+
const WINDOWS = process.platform === 'win32';
|
|
6
|
+
/**
|
|
7
|
+
* Windows resolves npm and other .cmd shims only through a shell, and a shell
|
|
8
|
+
* together with an args array is what Node deprecated in DEP0190: it joins them
|
|
9
|
+
* itself, without escaping, and says so in the middle of our output. So the command
|
|
10
|
+
* line is built and quoted here, and no other platform gets a shell at all.
|
|
11
|
+
*/
|
|
12
|
+
function quote(value) {
|
|
13
|
+
return WINDOWS ? `"${value.replace(/"/g, '""')}"` : value;
|
|
14
|
+
}
|
|
15
|
+
function run(binary, args, options = {}) {
|
|
16
|
+
const common = { stdio: options.stdio, timeout: options.timeout, encoding: 'utf-8' };
|
|
17
|
+
return WINDOWS
|
|
18
|
+
? (0, node_child_process_1.spawnSync)([binary, ...args.map(quote)].join(' '), { ...common, shell: true })
|
|
19
|
+
: (0, node_child_process_1.spawnSync)(binary, args, common);
|
|
20
|
+
}
|
package/dist/version.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEFAULT_API_URL = exports.CLI_VERSION = void 0;
|
|
4
4
|
/** Keep in sync with cli/package.json. */
|
|
5
|
-
exports.CLI_VERSION = '0.6.
|
|
5
|
+
exports.CLI_VERSION = '0.6.2';
|
|
6
6
|
/** Overridden by XFLOW_API_URL or the `api` field in xflow.json. */
|
|
7
7
|
exports.DEFAULT_API_URL = 'https://app.getxflow.com';
|