@mushi-mushi/cli 0.7.0 → 0.8.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 +402 -69
- package/dist/chunk-KUQZQFOL.js +6 -0
- package/dist/index.js +638 -190
- package/dist/init.js +23 -15
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-LBQX6RYS.js +0 -6
package/dist/init.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "./chunk-XHD3H54W.js";
|
|
9
9
|
import {
|
|
10
10
|
MUSHI_CLI_VERSION
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-KUQZQFOL.js";
|
|
12
12
|
|
|
13
13
|
// src/init.ts
|
|
14
14
|
import * as p from "@clack/prompts";
|
|
@@ -24,13 +24,20 @@ import { homedir } from "os";
|
|
|
24
24
|
var CONFIG_PATH = join(homedir(), ".mushirc");
|
|
25
25
|
var SECURE_FILE_MODE = 384;
|
|
26
26
|
function loadConfig(path = CONFIG_PATH) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
let file = {};
|
|
28
|
+
if (existsSync(path)) {
|
|
29
|
+
tightenPermissions(path);
|
|
30
|
+
try {
|
|
31
|
+
file = JSON.parse(readFileSync(path, "utf-8"));
|
|
32
|
+
} catch {
|
|
33
|
+
}
|
|
33
34
|
}
|
|
35
|
+
const fromEnv = {
|
|
36
|
+
...process.env["MUSHI_API_KEY"] ? { apiKey: process.env["MUSHI_API_KEY"] } : {},
|
|
37
|
+
...process.env["MUSHI_PROJECT_ID"] ? { projectId: process.env["MUSHI_PROJECT_ID"] } : {},
|
|
38
|
+
...process.env["MUSHI_API_ENDPOINT"] ? { endpoint: process.env["MUSHI_API_ENDPOINT"] } : {}
|
|
39
|
+
};
|
|
40
|
+
return { ...file, ...fromEnv };
|
|
34
41
|
}
|
|
35
42
|
function saveConfig(config, path = CONFIG_PATH) {
|
|
36
43
|
writeFileSync(path, JSON.stringify(config, null, 2), { mode: SECURE_FILE_MODE });
|
|
@@ -215,7 +222,7 @@ function getFrameworkFromPkg(pkg) {
|
|
|
215
222
|
|
|
216
223
|
// src/init.ts
|
|
217
224
|
var ENV_FILES = [".env.local", ".env"];
|
|
218
|
-
var PROJECT_ID_PATTERN = /^proj_[A-Za-z0-9_-]{10,}
|
|
225
|
+
var PROJECT_ID_PATTERN = /^(?:proj_[A-Za-z0-9_-]{10,}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i;
|
|
219
226
|
var API_KEY_PATTERN = /^mushi_[A-Za-z0-9_-]{10,}$/;
|
|
220
227
|
async function runInit(options = {}) {
|
|
221
228
|
const cwd = options.cwd ?? process.cwd();
|
|
@@ -260,7 +267,7 @@ function ensureInteractiveOrBailOut(options) {
|
|
|
260
267
|
);
|
|
261
268
|
if (hasAllFlags) return;
|
|
262
269
|
process.stderr.write(
|
|
263
|
-
"mushi-mushi: non-interactive terminal detected.\nPass all of --yes (or --framework), --project-id, and --api-key to run unattended.\nExample: npx mushi-mushi --yes --project-id
|
|
270
|
+
"mushi-mushi: non-interactive terminal detected.\nPass all of --yes (or --framework), --project-id, and --api-key to run unattended.\nExample: npx mushi-mushi --yes --project-id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --api-key mushi_xxx\nYour project ID is the UUID shown in the Projects page of the Mushi admin console.\n"
|
|
264
271
|
);
|
|
265
272
|
process.exit(1);
|
|
266
273
|
}
|
|
@@ -294,21 +301,22 @@ async function collectCredentials(options) {
|
|
|
294
301
|
const existing = loadConfig();
|
|
295
302
|
const rawProjectId = options.projectId ?? existing.projectId ?? await promptText({
|
|
296
303
|
message: "Project ID",
|
|
297
|
-
placeholder: "
|
|
298
|
-
hint: "
|
|
299
|
-
validate: (v) => PROJECT_ID_PATTERN.test(v) ? void 0 : "Expected
|
|
304
|
+
placeholder: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
|
305
|
+
hint: "Where to find it: https://kensaur.us/mushi-mushi/projects \u2192 click your project \u2192 copy the UUID below the project name.",
|
|
306
|
+
validate: (v) => PROJECT_ID_PATTERN.test(v) ? void 0 : "Expected a UUID (xxxxxxxx-xxxx-...) \u2014 copy it from the Mushi admin console Projects page."
|
|
300
307
|
});
|
|
301
308
|
const rawApiKey = options.apiKey ?? existing.apiKey ?? await promptText({
|
|
302
309
|
message: "API key",
|
|
303
310
|
placeholder: "mushi_xxxxxxxxxxxx",
|
|
304
|
-
hint: "Treat
|
|
311
|
+
hint: "Where to find it: https://kensaur.us/mushi-mushi/settings \u2192 API Keys tab. Treat it like a password \u2014 env file only, never commit it.",
|
|
305
312
|
validate: (v) => API_KEY_PATTERN.test(v) ? void 0 : "Expected format: mushi_ followed by 10+ alphanumeric characters"
|
|
306
313
|
});
|
|
307
314
|
const projectId = sanitizeSecret(rawProjectId);
|
|
308
315
|
const apiKey = sanitizeSecret(rawApiKey);
|
|
309
316
|
if (!PROJECT_ID_PATTERN.test(projectId)) {
|
|
310
317
|
throw new Error(
|
|
311
|
-
`Invalid project ID.
|
|
318
|
+
`Invalid project ID. Got: ${redact(projectId)}
|
|
319
|
+
Expected a UUID (e.g. 542b34e0-019e-41fe-b900-7b637717bb86) \u2014 copy it from the Projects page in the Mushi console at https://kensaur.us/mushi-mushi/projects`
|
|
312
320
|
);
|
|
313
321
|
}
|
|
314
322
|
if (!API_KEY_PATTERN.test(apiKey)) {
|
|
@@ -326,6 +334,7 @@ function redact(value) {
|
|
|
326
334
|
return `${value.slice(0, 4)}\u2026${value.slice(-2)}`;
|
|
327
335
|
}
|
|
328
336
|
async function promptText(opts) {
|
|
337
|
+
if (opts.hint) p.log.info(opts.hint);
|
|
329
338
|
const value = await p.text({
|
|
330
339
|
message: opts.message,
|
|
331
340
|
placeholder: opts.placeholder,
|
|
@@ -342,7 +351,6 @@ async function promptText(opts) {
|
|
|
342
351
|
p.cancel("Aborted.");
|
|
343
352
|
process.exit(0);
|
|
344
353
|
}
|
|
345
|
-
if (opts.hint) p.log.info(opts.hint);
|
|
346
354
|
return value;
|
|
347
355
|
}
|
|
348
356
|
async function installPackages(pm, packages, cwd) {
|
package/dist/version.js
CHANGED
package/package.json
CHANGED