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/index.d.ts CHANGED
@@ -651,6 +651,7 @@ declare function saveProgress(wizardName: string, state: {
651
651
  }, customDir?: string, excludeStepIds?: string[]): void;
652
652
  declare function loadProgress(wizardName: string, customDir?: string): SavedProgress | null;
653
653
  declare function clearProgress(wizardName: string, customDir?: string): void;
654
+ declare function clearAllProgress(customDir?: string): void;
654
655
 
655
656
  interface PipelineStep {
656
657
  config: WizardConfig | string;
@@ -660,4 +661,4 @@ interface PipelineStep {
660
661
  }
661
662
  declare function runPipeline(steps: PipelineStep[], globalOptions?: Omit<RunWizardOptions, 'mockAnswers' | 'templateAnswers'>): Promise<Record<string, Record<string, unknown>>>;
662
663
 
663
- export { type ActionConfig, type BrowserStepConfig, type ChecksStyle, ClackRenderer, type Condition, type ConfirmStepConfig, DEFAULT_SPINNER, type EditorStepConfig, type GrimoirePlugin, type HookContext, InkRenderer, InquirerRenderer, type MessageStepConfig, type MultiSelectStepConfig, type NoteStepConfig, type NoteStyle, type NumberStepConfig, type OnCompleteHandler, type PasswordStepConfig, type PathStepConfig, type PipelineStep, type PreFlightCheck, type ProgressBarConfig, type ProgressBarStyle, type PromptConfig, type ResolvedProgressBar, type ResolvedTheme, type ReviewFormat, type RunWizardOptions, type SavedProgress, type SearchStepConfig, type SelectChoice, type SelectOption, type SelectStepConfig, type SeparatorOption, type SpinnerConfig, type SpinnerName, type StepConfig, type StepPlugin, type StepReviewConfig, type TextStepConfig, type ThemeConfig, type ToggleStepConfig, type ValidationRule, type WizardConfig, type WizardEvent, type WizardRenderer, type WizardState, type WizardTransition, applyColumns, clearCache, clearMruData, clearPlugins, clearProgress, createWizardState, defineWizard, deleteTemplate, evaluateCondition, getCacheDir, getOrderedOptions, getPluginStep, getVisibleSteps, isStepVisible, listTemplates, loadCachedAnswers, loadProgress, loadTemplate, loadWizardConfig, parseWizardConfig, parseWizardYAML, recordSelection, registerPlugin, renderBanner, resolveEnvDefault, resolveNextStep, resolveSpinner, resolveTemplate, resolveTemplateStrict, resolveTheme, runPipeline, runPreFlightChecks, runWizard, saveCachedAnswers, saveProgress, saveTemplate, slugify, spinners, validateStepAnswer, wizardReducer };
664
+ export { type ActionConfig, type BrowserStepConfig, type ChecksStyle, ClackRenderer, type Condition, type ConfirmStepConfig, DEFAULT_SPINNER, type EditorStepConfig, type GrimoirePlugin, type HookContext, InkRenderer, InquirerRenderer, type MessageStepConfig, type MultiSelectStepConfig, type NoteStepConfig, type NoteStyle, type NumberStepConfig, type OnCompleteHandler, type PasswordStepConfig, type PathStepConfig, type PipelineStep, type PreFlightCheck, type ProgressBarConfig, type ProgressBarStyle, type PromptConfig, type ResolvedProgressBar, type ResolvedTheme, type ReviewFormat, type RunWizardOptions, type SavedProgress, type SearchStepConfig, type SelectChoice, type SelectOption, type SelectStepConfig, type SeparatorOption, type SpinnerConfig, type SpinnerName, type StepConfig, type StepPlugin, type StepReviewConfig, type TextStepConfig, type ThemeConfig, type ToggleStepConfig, type ValidationRule, type WizardConfig, type WizardEvent, type WizardRenderer, type WizardState, type WizardTransition, applyColumns, clearAllProgress, clearCache, clearMruData, clearPlugins, clearProgress, createWizardState, defineWizard, deleteTemplate, evaluateCondition, getCacheDir, getOrderedOptions, getPluginStep, getVisibleSteps, isStepVisible, listTemplates, loadCachedAnswers, loadProgress, loadTemplate, loadWizardConfig, parseWizardConfig, parseWizardYAML, recordSelection, registerPlugin, renderBanner, resolveEnvDefault, resolveNextStep, resolveSpinner, resolveTemplate, resolveTemplateStrict, resolveTheme, runPipeline, runPreFlightChecks, runWizard, saveCachedAnswers, saveProgress, saveTemplate, slugify, spinners, validateStepAnswer, wizardReducer };
package/dist/index.js CHANGED
@@ -1504,7 +1504,7 @@ function clearCache(wizardName, customDir) {
1504
1504
  }
1505
1505
 
1506
1506
  // src/progress.ts
1507
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2, unlinkSync as unlinkSync2 } from "fs";
1507
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, readdirSync as readdirSync2, writeFileSync as writeFileSync2, unlinkSync as unlinkSync2 } from "fs";
1508
1508
  import { join as join2 } from "path";
1509
1509
  import { homedir as homedir2 } from "os";
1510
1510
  var DEFAULT_PROGRESS_DIR = join2(homedir2(), ".config", "grimoire", "progress");
@@ -1554,6 +1554,20 @@ function clearProgress(wizardName, customDir) {
1554
1554
  } catch {
1555
1555
  }
1556
1556
  }
1557
+ function clearAllProgress(customDir) {
1558
+ try {
1559
+ const dir = customDir ?? DEFAULT_PROGRESS_DIR;
1560
+ for (const file of readdirSync2(dir)) {
1561
+ if (file.endsWith(".json")) {
1562
+ try {
1563
+ unlinkSync2(join2(dir, file));
1564
+ } catch {
1565
+ }
1566
+ }
1567
+ }
1568
+ } catch {
1569
+ }
1570
+ }
1557
1571
 
1558
1572
  // src/mru.ts
1559
1573
  import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3, existsSync } from "fs";
@@ -1773,7 +1787,7 @@ async function runWizard(config, options) {
1773
1787
  const cacheDir = typeof options?.cache === "object" ? options.cache.dir : void 0;
1774
1788
  const mruEnabled = !isMock && options?.mru !== false;
1775
1789
  let state = createWizardState(config);
1776
- const resumeEnabled = !isMock && options?.resume !== false;
1790
+ const resumeEnabled = !isMock && options?.resume !== false && options?.cache !== false;
1777
1791
  if (resumeEnabled) {
1778
1792
  const saved = loadProgress(config.meta.name);
1779
1793
  if (saved) {
@@ -1800,12 +1814,14 @@ async function runWizard(config, options) {
1800
1814
  if (cancelFired) return;
1801
1815
  cancelFired = true;
1802
1816
  state = wizardReducer(state, { type: "CANCEL" }, config);
1803
- const passwordStepIds = config.steps.filter((s) => s.type === "password").map((s) => s.id);
1804
- saveProgress(config.meta.name, {
1805
- currentStepId: state.currentStepId,
1806
- answers: state.answers,
1807
- history: state.history
1808
- }, void 0, passwordStepIds);
1817
+ if (resumeEnabled) {
1818
+ const passwordStepIds = config.steps.filter((s) => s.type === "password").map((s) => s.id);
1819
+ saveProgress(config.meta.name, {
1820
+ currentStepId: state.currentStepId,
1821
+ answers: state.answers,
1822
+ history: state.history
1823
+ }, void 0, passwordStepIds);
1824
+ }
1809
1825
  try {
1810
1826
  await options?.onCancel?.(state);
1811
1827
  } catch {
@@ -2804,7 +2820,7 @@ var ClackRenderer = class extends InquirerRenderer {
2804
2820
  };
2805
2821
 
2806
2822
  // src/templates.ts
2807
- import { mkdirSync as mkdirSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync4, unlinkSync as unlinkSync3, readdirSync as readdirSync2, existsSync as existsSync2 } from "fs";
2823
+ import { mkdirSync as mkdirSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync4, unlinkSync as unlinkSync3, readdirSync as readdirSync3, existsSync as existsSync2 } from "fs";
2808
2824
  import { join as join4 } from "path";
2809
2825
  import { homedir as homedir4 } from "os";
2810
2826
  var TEMPLATES_DIR = join4(homedir4(), ".config", "grimoire", "templates");
@@ -2847,7 +2863,7 @@ function listTemplates(wizardName) {
2847
2863
  try {
2848
2864
  const dir = getWizardTemplateDir(wizardName);
2849
2865
  if (!existsSync2(dir)) return [];
2850
- return readdirSync2(dir).filter((f) => f.endsWith(".json")).map((f) => f.replace(/\.json$/, ""));
2866
+ return readdirSync3(dir).filter((f) => f.endsWith(".json")).map((f) => f.replace(/\.json$/, ""));
2851
2867
  } catch {
2852
2868
  return [];
2853
2869
  }
@@ -2892,6 +2908,7 @@ export {
2892
2908
  InkRenderer,
2893
2909
  InquirerRenderer,
2894
2910
  applyColumns,
2911
+ clearAllProgress,
2895
2912
  clearCache,
2896
2913
  clearMruData,
2897
2914
  clearPlugins,