@algolia/wizard 0.38.0-rc.131.267 → 0.38.0-rc.131.269
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 +33 -49
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1432,9 +1432,9 @@ function reconcileWorkflowState(state, workflow) {
|
|
|
1432
1432
|
}
|
|
1433
1433
|
return state;
|
|
1434
1434
|
}
|
|
1435
|
-
async function
|
|
1435
|
+
async function loadResumableState(workflow) {
|
|
1436
1436
|
const persisted = await loadWorkflowState(workflow.id);
|
|
1437
|
-
return persisted
|
|
1437
|
+
return persisted ? reconcileWorkflowState(persisted, workflow) : null;
|
|
1438
1438
|
}
|
|
1439
1439
|
function initWorkflowState(workflow, now) {
|
|
1440
1440
|
return {
|
|
@@ -1538,11 +1538,11 @@ async function runStep(state, index, step, appId) {
|
|
|
1538
1538
|
durationMs: Date.now() - startedAt
|
|
1539
1539
|
});
|
|
1540
1540
|
}
|
|
1541
|
-
async function runWorkflow(workflow, appId) {
|
|
1541
|
+
async function runWorkflow(workflow, appId, resumableState) {
|
|
1542
1542
|
const store = useWizard.getState();
|
|
1543
1543
|
try {
|
|
1544
|
-
const
|
|
1545
|
-
const state =
|
|
1544
|
+
const resolved2 = resumableState !== void 0 ? resumableState : await loadResumableState(workflow);
|
|
1545
|
+
const state = resolved2 ?? initWorkflowState(workflow, nowIso());
|
|
1546
1546
|
ensureExecutedStepCount(state);
|
|
1547
1547
|
store.startWorkflow(
|
|
1548
1548
|
{
|
|
@@ -3330,7 +3330,7 @@ async function runAnalysis(mode, extraInstructions = []) {
|
|
|
3330
3330
|
// package.json
|
|
3331
3331
|
var package_default = {
|
|
3332
3332
|
name: "@algolia/wizard",
|
|
3333
|
-
version: "0.38.0-rc.131.
|
|
3333
|
+
version: "0.38.0-rc.131.269",
|
|
3334
3334
|
description: "Magically implement Algolia functionality in your codebase",
|
|
3335
3335
|
type: "module",
|
|
3336
3336
|
engines: {
|
|
@@ -5619,15 +5619,23 @@ function readValue(raw) {
|
|
|
5619
5619
|
function blockReasonFor(app) {
|
|
5620
5620
|
return app.status !== "active" ? "Paused" : "Missing permissions";
|
|
5621
5621
|
}
|
|
5622
|
-
function secondaryFor(app) {
|
|
5622
|
+
function secondaryFor(app, highlightId) {
|
|
5623
5623
|
if (!canSelectApplication(app)) {
|
|
5624
5624
|
return { kind: "text", value: blockReasonFor(app) };
|
|
5625
5625
|
}
|
|
5626
|
+
if (app.id === highlightId) {
|
|
5627
|
+
return { kind: "badge", value: "[DETECTED]" };
|
|
5628
|
+
}
|
|
5626
5629
|
return app.plan ? { kind: "badge", value: app.plan } : void 0;
|
|
5627
5630
|
}
|
|
5628
5631
|
function labelFor(app) {
|
|
5629
5632
|
return app.name.trim() ? `${app.name} \u2014 ${app.id}` : app.id;
|
|
5630
5633
|
}
|
|
5634
|
+
async function isEligible(app) {
|
|
5635
|
+
const apps = await listApplications();
|
|
5636
|
+
const full = apps.find((candidate) => candidate.id === app.id);
|
|
5637
|
+
return full != null && canSelectApplication(full);
|
|
5638
|
+
}
|
|
5631
5639
|
async function selectAndReport(app) {
|
|
5632
5640
|
const store = useWizard.getState();
|
|
5633
5641
|
store.setSettingUpApp(app.id);
|
|
@@ -5637,7 +5645,7 @@ async function selectAndReport(app) {
|
|
|
5637
5645
|
store.setSettingUpApp(null);
|
|
5638
5646
|
}
|
|
5639
5647
|
}
|
|
5640
|
-
async function promptForApplication(
|
|
5648
|
+
async function promptForApplication(highlight) {
|
|
5641
5649
|
const store = useWizard.getState();
|
|
5642
5650
|
const unordered = await listApplications();
|
|
5643
5651
|
if (unordered.length === 0) {
|
|
@@ -5654,14 +5662,22 @@ async function promptForApplication(leadIn = []) {
|
|
|
5654
5662
|
...unordered.filter(canSelectApplication),
|
|
5655
5663
|
...unordered.filter((app) => !canSelectApplication(app))
|
|
5656
5664
|
];
|
|
5657
|
-
const
|
|
5665
|
+
const envApp = highlight ? unordered.find((app) => app.id === highlight.id) : void 0;
|
|
5666
|
+
const highlightIndex = envApp && canSelectApplication(envApp) ? apps.indexOf(envApp) : -1;
|
|
5667
|
+
const messages = [];
|
|
5668
|
+
if (highlight && highlightIndex < 0) {
|
|
5669
|
+
messages.push(
|
|
5670
|
+
envApp ? `Could not use ${highlight.id} from ${highlight.file} \u2014 it\u2019s ${blockReasonFor(envApp).toLowerCase()}. Pick another below.` : `Could not use ${highlight.id} from ${highlight.file} \u2014 it may have been removed, or this account may not have access to it.`
|
|
5671
|
+
);
|
|
5672
|
+
}
|
|
5658
5673
|
for (; ; ) {
|
|
5659
5674
|
const choice = await store.requestUserInput({
|
|
5660
5675
|
prompt: "Which Algolia application should the wizard work in?",
|
|
5661
5676
|
promptType: "multipleChoice",
|
|
5662
5677
|
options: apps.map(labelFor),
|
|
5663
|
-
secondary: apps.map(secondaryFor),
|
|
5678
|
+
secondary: apps.map((app) => secondaryFor(app, highlight?.id)),
|
|
5664
5679
|
disabled: apps.map((app) => !canSelectApplication(app)),
|
|
5680
|
+
...highlightIndex >= 0 ? { defaultSelectedIndex: highlightIndex } : {},
|
|
5665
5681
|
messages
|
|
5666
5682
|
});
|
|
5667
5683
|
const chosen = apps.find((app) => labelFor(app) === choice);
|
|
@@ -5681,47 +5697,15 @@ async function promptForApplication(leadIn = []) {
|
|
|
5681
5697
|
}
|
|
5682
5698
|
}
|
|
5683
5699
|
}
|
|
5684
|
-
async function confirmEnvApplication(env, current) {
|
|
5685
|
-
const useEnv = `Use ${env.id} (from ${env.file})`;
|
|
5686
|
-
const choice = await useWizard.getState().requestUserInput({
|
|
5687
|
-
prompt: "Select an application",
|
|
5688
|
-
promptType: "multipleChoice",
|
|
5689
|
-
options: [
|
|
5690
|
-
useEnv,
|
|
5691
|
-
current ? `Use ${labelFor(current)} (already selected)` : "Pick a different application"
|
|
5692
|
-
],
|
|
5693
|
-
messages: [
|
|
5694
|
-
`${env.file} already sets ${env.name}=${env.id}.`,
|
|
5695
|
-
"Which Algolia application would you like to use?"
|
|
5696
|
-
]
|
|
5697
|
-
});
|
|
5698
|
-
if (choice === useEnv) return selectEnvApplication(env);
|
|
5699
|
-
return current ? selectAndReport(current) : null;
|
|
5700
|
-
}
|
|
5701
|
-
async function selectEnvApplication(env) {
|
|
5702
|
-
try {
|
|
5703
|
-
return await selectAndReport({ id: env.id, name: "" });
|
|
5704
|
-
} catch (err) {
|
|
5705
|
-
logger.warn(
|
|
5706
|
-
{ app: env.id, err: err.message },
|
|
5707
|
-
"could not select the application named in env; falling back to the picker"
|
|
5708
|
-
);
|
|
5709
|
-
return promptForApplication([
|
|
5710
|
-
`Could not select ${env.id} from ${env.file} \u2014 it may have been removed, or this account may not have access to it.`
|
|
5711
|
-
]);
|
|
5712
|
-
}
|
|
5713
|
-
}
|
|
5714
5700
|
async function ensureApplication(isResuming) {
|
|
5715
5701
|
const current = await currentApplication();
|
|
5716
5702
|
if (isResuming) {
|
|
5717
|
-
|
|
5703
|
+
if (current && await isEligible(current)) return current;
|
|
5704
|
+
return promptForApplication();
|
|
5718
5705
|
}
|
|
5719
5706
|
const env = await findEnvApplicationId();
|
|
5720
|
-
if (env
|
|
5721
|
-
|
|
5722
|
-
if (chosen) return chosen;
|
|
5723
|
-
}
|
|
5724
|
-
return promptForApplication();
|
|
5707
|
+
if (!env) return promptForApplication();
|
|
5708
|
+
return promptForApplication({ id: env.id, file: env.file });
|
|
5725
5709
|
}
|
|
5726
5710
|
|
|
5727
5711
|
// src/lib/seed.ts
|
|
@@ -6085,15 +6069,15 @@ async function run(workflow) {
|
|
|
6085
6069
|
}
|
|
6086
6070
|
store.setUser(user);
|
|
6087
6071
|
let app;
|
|
6072
|
+
const resumableState = await loadResumableState(workflow);
|
|
6088
6073
|
try {
|
|
6089
|
-
|
|
6090
|
-
app = await ensureApplication(resuming);
|
|
6074
|
+
app = await ensureApplication(resumableState != null);
|
|
6091
6075
|
} catch (err) {
|
|
6092
6076
|
store.setError(err instanceof Error ? err.message : String(err));
|
|
6093
6077
|
await instance.waitUntilExit();
|
|
6094
6078
|
process.exit(1);
|
|
6095
6079
|
}
|
|
6096
|
-
runWorkflow(workflow, app.id);
|
|
6080
|
+
runWorkflow(workflow, app.id, resumableState);
|
|
6097
6081
|
}
|
|
6098
6082
|
await requestTerminalSize();
|
|
6099
6083
|
var started = await startup();
|