@algolia/wizard 0.9.0-rc.88.102 → 0.9.0-rc.88.103
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/main.js +25 -7
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -17,6 +17,9 @@ function npxArgs(args) {
|
|
|
17
17
|
return ["--yes", "@algolia/cli@latest", ...args];
|
|
18
18
|
}
|
|
19
19
|
var shell = process.platform === "win32";
|
|
20
|
+
function mask(text, secret) {
|
|
21
|
+
return secret ? text.replaceAll(secret, "***") : text;
|
|
22
|
+
}
|
|
20
23
|
function lineSplitter(emit) {
|
|
21
24
|
let buffer = "";
|
|
22
25
|
return {
|
|
@@ -40,9 +43,10 @@ var stderrSink = (stream, line) => {
|
|
|
40
43
|
if (stream === "stdout") return;
|
|
41
44
|
wizardSink(stream, line);
|
|
42
45
|
};
|
|
43
|
-
function runAlgoliaCli(args, { onOutput } = {}) {
|
|
46
|
+
function runAlgoliaCli(args, { onOutput, redact } = {}) {
|
|
44
47
|
const store = useWizard.getState();
|
|
45
|
-
const
|
|
48
|
+
const command = mask(args.join(" "), redact);
|
|
49
|
+
const logId = store.logStart("tool", `algolia ${command}`);
|
|
46
50
|
return new Promise((resolve4, reject) => {
|
|
47
51
|
const child = spawn("npx", npxArgs(args), { shell });
|
|
48
52
|
let stdout = "";
|
|
@@ -71,13 +75,13 @@ function runAlgoliaCli(args, { onOutput } = {}) {
|
|
|
71
75
|
const failed = stderr.trim();
|
|
72
76
|
let detail = "";
|
|
73
77
|
if (failed) {
|
|
74
|
-
detail = `: ${failed}`;
|
|
78
|
+
detail = `: ${mask(failed, redact)}`;
|
|
75
79
|
} else if (stdout.trim()) {
|
|
76
80
|
detail = " (no stderr; stdout withheld \u2014 it may contain credentials)";
|
|
77
81
|
}
|
|
78
82
|
reject(
|
|
79
83
|
new Error(
|
|
80
|
-
`Algolia CLI \`${
|
|
84
|
+
`Algolia CLI \`${command}\` failed (exit ${code})${detail}`
|
|
81
85
|
)
|
|
82
86
|
);
|
|
83
87
|
}
|
|
@@ -2477,6 +2481,14 @@ async function createKey(index, acls, description) {
|
|
|
2477
2481
|
if (!created) throw new Error("apikeys create returned no key value");
|
|
2478
2482
|
return created;
|
|
2479
2483
|
}
|
|
2484
|
+
async function keyExists(key) {
|
|
2485
|
+
try {
|
|
2486
|
+
await runAlgoliaCli(["apikeys", "get", key, "-o", "json"], { redact: key });
|
|
2487
|
+
return true;
|
|
2488
|
+
} catch (err) {
|
|
2489
|
+
return !/does not exist/i.test(err.message);
|
|
2490
|
+
}
|
|
2491
|
+
}
|
|
2480
2492
|
var resolved = /* @__PURE__ */ new Map();
|
|
2481
2493
|
async function forgetResolvedKeys() {
|
|
2482
2494
|
resolved.clear();
|
|
@@ -2498,8 +2510,14 @@ function resolveKey(kind, index, appId, acls, description) {
|
|
|
2498
2510
|
async function provisionKey(kind, index, appId, acls, description) {
|
|
2499
2511
|
const stored = await readStoredKey(kind, index, appId);
|
|
2500
2512
|
if (stored) {
|
|
2501
|
-
|
|
2502
|
-
|
|
2513
|
+
if (await keyExists(stored)) {
|
|
2514
|
+
logger.info({ kind, index, appId }, "reusing the stored API key");
|
|
2515
|
+
return { key: stored, source: "keychain" };
|
|
2516
|
+
}
|
|
2517
|
+
logger.info(
|
|
2518
|
+
{ kind, index, appId },
|
|
2519
|
+
"the stored API key no longer exists; creating another"
|
|
2520
|
+
);
|
|
2503
2521
|
}
|
|
2504
2522
|
const key = await createKey(index, acls, description);
|
|
2505
2523
|
await storeKey(kind, index, appId, key);
|
|
@@ -3150,7 +3168,7 @@ async function runAnalysis(mode, extraInstructions = []) {
|
|
|
3150
3168
|
// package.json
|
|
3151
3169
|
var package_default = {
|
|
3152
3170
|
name: "@algolia/wizard",
|
|
3153
|
-
version: "0.9.0-rc.88.
|
|
3171
|
+
version: "0.9.0-rc.88.103",
|
|
3154
3172
|
description: "Magically implement Algolia functionality in your codebase",
|
|
3155
3173
|
type: "module",
|
|
3156
3174
|
engines: {
|