@model-go/cli 0.1.5 → 0.1.6
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/package.json +1 -1
- package/scripts/install-wizard.js +25 -3
package/package.json
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
// SPDX-License-Identifier: MIT
|
|
4
4
|
|
|
5
5
|
const { execFileSync, execFile } = require("child_process");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const path = require("path");
|
|
6
8
|
const p = require("@clack/prompts");
|
|
7
9
|
const { semverLessThan } = require("./install.js");
|
|
8
10
|
|
|
@@ -111,6 +113,25 @@ function getGloballyInstalledVersion() {
|
|
|
111
113
|
}
|
|
112
114
|
}
|
|
113
115
|
|
|
116
|
+
// `npx <pkg> install` prepends this run's own temporary package directory
|
|
117
|
+
// (~/.npm/_npx/<hash>/node_modules/.bin) to PATH, ahead of the real global
|
|
118
|
+
// npm bin dir. A bare `execFileSync("modelgo", ...)` below would then resolve
|
|
119
|
+
// back to *this* npx-cached copy — whose bin/modelgo was never downloaded,
|
|
120
|
+
// since install.js intentionally skips the binary fetch under npx and defers
|
|
121
|
+
// to the `npm install -g` in stepInstallGlobally. Resolve the actual global
|
|
122
|
+
// bin path explicitly so env/auth steps always run the real installed CLI.
|
|
123
|
+
function getGlobalModelgoBin() {
|
|
124
|
+
try {
|
|
125
|
+
const prefix = runSilent("npm", ["prefix", "-g"], { timeout: 15000 }).toString().trim();
|
|
126
|
+
const binPath = isWindows
|
|
127
|
+
? path.join(prefix, "modelgo.cmd")
|
|
128
|
+
: path.join(prefix, "bin", "modelgo");
|
|
129
|
+
return fs.existsSync(binPath) ? binPath : null;
|
|
130
|
+
} catch (_) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
114
135
|
function parseLangArg() {
|
|
115
136
|
const args = process.argv.slice(2);
|
|
116
137
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -230,8 +251,8 @@ async function stepSelectEnv(msg) {
|
|
|
230
251
|
msg
|
|
231
252
|
);
|
|
232
253
|
try {
|
|
233
|
-
|
|
234
|
-
runSilent(
|
|
254
|
+
const modelgoBin = getGlobalModelgoBin() || "modelgo";
|
|
255
|
+
runSilent(modelgoBin, ["env", "use", env], { timeout: 15000 });
|
|
235
256
|
p.log.success(fmt(msg.envDone, env));
|
|
236
257
|
} catch (_) {
|
|
237
258
|
p.log.warn(fmt(msg.envFail, env));
|
|
@@ -247,7 +268,8 @@ async function stepAuthLogin(msg) {
|
|
|
247
268
|
try {
|
|
248
269
|
// `auth login` prints a verification URL and blocks polling until the user
|
|
249
270
|
// approves in the browser — inherit stdio so the URL and progress show.
|
|
250
|
-
|
|
271
|
+
const modelgoBin = getGlobalModelgoBin() || "modelgo";
|
|
272
|
+
execCmd(modelgoBin, ["auth", "login"], { stdio: "inherit" });
|
|
251
273
|
p.log.success(msg.authDone);
|
|
252
274
|
} catch (_) {
|
|
253
275
|
p.log.warn(msg.authFail);
|