grimoire-wizard 0.6.0 → 0.6.1

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/cli.js CHANGED
@@ -1457,7 +1457,7 @@ function clearCache(wizardName, customDir) {
1457
1457
  }
1458
1458
 
1459
1459
  // src/progress.ts
1460
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2, unlinkSync as unlinkSync2 } from "fs";
1460
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, readdirSync as readdirSync2, writeFileSync as writeFileSync2, unlinkSync as unlinkSync2 } from "fs";
1461
1461
  import { join as join2 } from "path";
1462
1462
  import { homedir as homedir2 } from "os";
1463
1463
  var DEFAULT_PROGRESS_DIR = join2(homedir2(), ".config", "grimoire", "progress");
@@ -1507,6 +1507,20 @@ function clearProgress(wizardName, customDir) {
1507
1507
  } catch {
1508
1508
  }
1509
1509
  }
1510
+ function clearAllProgress(customDir) {
1511
+ try {
1512
+ const dir = customDir ?? DEFAULT_PROGRESS_DIR;
1513
+ for (const file of readdirSync2(dir)) {
1514
+ if (file.endsWith(".json")) {
1515
+ try {
1516
+ unlinkSync2(join2(dir, file));
1517
+ } catch {
1518
+ }
1519
+ }
1520
+ }
1521
+ } catch {
1522
+ }
1523
+ }
1510
1524
 
1511
1525
  // src/mru.ts
1512
1526
  import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3, existsSync } from "fs";
@@ -1717,7 +1731,7 @@ async function runWizard(config, options) {
1717
1731
  const cacheDir = typeof options?.cache === "object" ? options.cache.dir : void 0;
1718
1732
  const mruEnabled = !isMock && options?.mru !== false;
1719
1733
  let state = createWizardState(config);
1720
- const resumeEnabled = !isMock && options?.resume !== false;
1734
+ const resumeEnabled = !isMock && options?.resume !== false && options?.cache !== false;
1721
1735
  if (resumeEnabled) {
1722
1736
  const saved = loadProgress(config.meta.name);
1723
1737
  if (saved) {
@@ -1744,12 +1758,14 @@ async function runWizard(config, options) {
1744
1758
  if (cancelFired) return;
1745
1759
  cancelFired = true;
1746
1760
  state = wizardReducer(state, { type: "CANCEL" }, config);
1747
- const passwordStepIds = config.steps.filter((s) => s.type === "password").map((s) => s.id);
1748
- saveProgress(config.meta.name, {
1749
- currentStepId: state.currentStepId,
1750
- answers: state.answers,
1751
- history: state.history
1752
- }, void 0, passwordStepIds);
1761
+ if (resumeEnabled) {
1762
+ const passwordStepIds = config.steps.filter((s) => s.type === "password").map((s) => s.id);
1763
+ saveProgress(config.meta.name, {
1764
+ currentStepId: state.currentStepId,
1765
+ answers: state.answers,
1766
+ history: state.history
1767
+ }, void 0, passwordStepIds);
1768
+ }
1753
1769
  try {
1754
1770
  await options?.onCancel?.(state);
1755
1771
  } catch {
@@ -2662,7 +2678,7 @@ complete -c grimoire -n "__fish_seen_subcommand_from completion" -f -a "fish" -d
2662
2678
  }
2663
2679
 
2664
2680
  // src/templates.ts
2665
- import { mkdirSync as mkdirSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync5, unlinkSync as unlinkSync3, readdirSync as readdirSync2, existsSync as existsSync2 } from "fs";
2681
+ import { mkdirSync as mkdirSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync5, unlinkSync as unlinkSync3, readdirSync as readdirSync3, existsSync as existsSync2 } from "fs";
2666
2682
  import { join as join4 } from "path";
2667
2683
  import { homedir as homedir4 } from "os";
2668
2684
  var TEMPLATES_DIR = join4(homedir4(), ".config", "grimoire", "templates");
@@ -2689,7 +2705,7 @@ function listTemplates(wizardName) {
2689
2705
  try {
2690
2706
  const dir = getWizardTemplateDir(wizardName);
2691
2707
  if (!existsSync2(dir)) return [];
2692
- return readdirSync2(dir).filter((f) => f.endsWith(".json")).map((f) => f.replace(/\.json$/, ""));
2708
+ return readdirSync3(dir).filter((f) => f.endsWith(".json")).map((f) => f.replace(/\.json$/, ""));
2693
2709
  } catch {
2694
2710
  return [];
2695
2711
  }
@@ -3256,11 +3272,13 @@ var cacheCommand = program.command("cache").description("Manage cached wizard an
3256
3272
  cacheCommand.command("clear").description("Delete cached wizard answers").argument("[name]", "Wizard name to clear (clears all if omitted)").action((name) => {
3257
3273
  clearCache(name);
3258
3274
  if (name) {
3275
+ clearProgress(name);
3259
3276
  console.log(`
3260
- Cache cleared for "${name}".
3277
+ Cache and progress cleared for "${name}".
3261
3278
  `);
3262
3279
  } else {
3263
- console.log("\n All cached answers cleared.\n");
3280
+ clearAllProgress();
3281
+ console.log("\n All cached answers and progress cleared.\n");
3264
3282
  }
3265
3283
  });
3266
3284
  var templateCommand = program.command("template").description("Manage saved wizard answer templates");