@algolia/wizard 0.48.0-rc.141.344 → 0.49.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.
Files changed (2) hide show
  1. package/dist/main.js +28 -7
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -1710,11 +1710,31 @@ async function runStep(state, index, step, appId) {
1710
1710
  durationMs: Date.now() - startedAt
1711
1711
  });
1712
1712
  }
1713
- async function runWorkflow(workflow, appId, resumableState) {
1713
+ var RESUME_OPTION = "Resume";
1714
+ var START_NEW_OPTION = "Start a new one";
1715
+ async function resolveWorkflowState(workflow, appId, options) {
1716
+ const resumed = options?.resumableState !== void 0 ? options.resumableState : await loadResumableState(workflow);
1717
+ if (!resumed) {
1718
+ return initWorkflowState(workflow, nowIso(), appId);
1719
+ }
1720
+ if (options?.skipResumePrompt) {
1721
+ return resumed;
1722
+ }
1723
+ const answer = await useWizard.getState().requestUserInput({
1724
+ prompt: "You have a previous session. Do you want to resume, or start a new one?",
1725
+ promptType: "multipleChoice",
1726
+ options: [RESUME_OPTION, START_NEW_OPTION]
1727
+ });
1728
+ if (answer === START_NEW_OPTION) {
1729
+ await clearWorkflowState(workflow.id);
1730
+ return initWorkflowState(workflow, nowIso(), appId);
1731
+ }
1732
+ return resumed;
1733
+ }
1734
+ async function runWorkflow(workflow, appId, options) {
1714
1735
  const store = useWizard.getState();
1715
1736
  try {
1716
- const resolved2 = resumableState !== void 0 ? resumableState : await loadResumableState(workflow);
1717
- const state = resolved2 ?? initWorkflowState(workflow, nowIso(), appId);
1737
+ const state = await resolveWorkflowState(workflow, appId, options);
1718
1738
  ensureExecutedStepCount(state);
1719
1739
  store.startWorkflow(
1720
1740
  {
@@ -3584,7 +3604,7 @@ async function runAnalysis(mode, extraInstructions = []) {
3584
3604
  // package.json
3585
3605
  var package_default = {
3586
3606
  name: "@algolia/wizard",
3587
- version: "0.48.0-rc.141.344",
3607
+ version: "0.49.0",
3588
3608
  description: "Magically implement Algolia functionality in your codebase",
3589
3609
  type: "module",
3590
3610
  engines: {
@@ -6322,9 +6342,10 @@ ${formatStepList(workflow)}`);
6322
6342
  return 1;
6323
6343
  }
6324
6344
  }
6325
- return workflow;
6345
+ return { workflow, skipResumePrompt: args.seed !== void 0 };
6326
6346
  }
6327
- async function run(workflow) {
6347
+ async function run(opts) {
6348
+ const { workflow, skipResumePrompt } = opts;
6328
6349
  const store = useWizard.getState();
6329
6350
  const instance = render(/* @__PURE__ */ jsx19(App, {}), { incrementalRendering: true });
6330
6351
  await store.waitForStart();
@@ -6369,7 +6390,7 @@ async function run(workflow) {
6369
6390
  await instance.waitUntilExit();
6370
6391
  process.exit(1);
6371
6392
  }
6372
- runWorkflow(workflow, app.id, resumableState);
6393
+ runWorkflow(workflow, app.id, { skipResumePrompt, resumableState });
6373
6394
  }
6374
6395
  await requestTerminalSize();
6375
6396
  var started = await startup();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algolia/wizard",
3
- "version": "0.48.0-rc.141.344",
3
+ "version": "0.49.0",
4
4
  "description": "Magically implement Algolia functionality in your codebase",
5
5
  "type": "module",
6
6
  "engines": {