@pixpilot/scaffoldfy 0.7.0 → 0.9.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.
package/README.md CHANGED
@@ -9,7 +9,8 @@ A flexible and powerful template initialization utility for automating project s
9
9
  - 🔍 **Dry-Run Mode with Diff** - Preview exact changes before applying
10
10
  - 🔌 **Plugin System** - Create custom task types and lifecycle hooks
11
11
  - 💬 **Interactive Prompts** - Collect user input with input, select, confirm, number, and password prompts
12
- - 📦 **JSON/TypeScript Config** - Define tasks in JSON or TypeScript files
12
+ - **Variables** - Define reusable values from static or executable sources without user interaction
13
+ - �📦 **JSON/TypeScript Config** - Define tasks in JSON or TypeScript files
13
14
  - 🔗 **Task Dependencies** - Ensure tasks run in the correct order
14
15
  - ✅ **Type-Safe** - Full TypeScript support with JSON schema validation
15
16
  - 🎯 **Template Variables** - Use `{{variable}}` syntax for dynamic configuration
@@ -346,6 +347,7 @@ Control execution order:
346
347
  - **[Getting Started](https://pixpilot.github.io/scaffoldfy/GETTING_STARTED.html)** - Installation, CLI usage, and examples
347
348
  - **[Task Types Reference](https://pixpilot.github.io/scaffoldfy/TASK_TYPES.html)** - All 9 built-in task types
348
349
  - **[Interactive Prompts](https://pixpilot.github.io/scaffoldfy/PROMPTS.html)** - Collect user input
350
+ - **[Variables](https://pixpilot.github.io/scaffoldfy/VARIABLES.html)** - Reusable values without user interaction
349
351
  - **[Advanced Features](https://pixpilot.github.io/scaffoldfy/FEATURES.html)** - Conditional execution, global prompts, Handlebars
350
352
  - **[Template Inheritance](https://pixpilot.github.io/scaffoldfy/TEMPLATE_INHERITANCE.html)** - Extend and compose templates
351
353
  - **[Plugin System](https://pixpilot.github.io/scaffoldfy/PLUGINS.html)** - Create custom task types
package/dist/cli.cjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- const e=require(`./src-BhknM6fX.cjs`);let t=require(`node:fs`);t=e.q(t);let n=require(`node:path`);n=e.q(n);let r=require(`node:process`);r=e.q(r);let i=require(`commander`);i=e.q(i);const a=1,o=new i.Command,s=n.default.join(__dirname,`..`,`package.json`);let c=`0.0.0`;try{c=JSON.parse(t.default.readFileSync(s,`utf-8`)).version??`0.0.0`}catch{}o.name(`scaffoldfy`).description(`Initialize and configure project templates with customizable tasks`).version(c),o.option(`--dry-run`,`Run in dry mode without making any changes`).option(`--force`,`Force re-initialization even if already initialized`).option(`--tasks-file <path>`,`Path to JSON file containing task definitions`,`./template-tasks.json`).option(`--tasks-ts <path>`,`Path to TypeScript file exporting tasks`,`./template-tasks.ts`).action(async i=>{try{let a=[],o;if(i.tasksTs!=null&&i.tasksTs!==``){let s=n.default.resolve(r.default.cwd(),i.tasksTs);if(t.default.existsSync(s)){e.U(`Loading tasks from TypeScript file: ${i.tasksTs}`,`info`),o=s;try{let t=await import(s);a=t.default??t.tasks??[],(!Array.isArray(a)||a.length===0)&&(e.U(`⚠️ No tasks found in TypeScript file or invalid format`,`warn`),e.U(`Expected default export or named export "tasks" with TaskDefinition[]`,`info`))}catch(t){e.U(`Failed to load TypeScript tasks file: ${i.tasksTs}`,`error`),t instanceof Error&&e.U(` Error: ${t.message}`,`error`),r.default.exit(1)}}}if(a.length===0&&i.tasksFile!=null&&i.tasksFile!==``){let s=n.default.resolve(r.default.cwd(),i.tasksFile);if(t.default.existsSync(s)){o=s;try{a=await e.a(s),Array.isArray(a)||(e.U(`❌ Invalid tasks file format`,`error`),e.U(`Expected JSON with { "tasks": [...] } structure`,`info`),r.default.exit(1))}catch(t){e.U(`Failed to load JSON tasks file: ${i.tasksFile}`,`error`),t instanceof Error&&e.U(` Error: ${t.message}`,`error`),r.default.exit(1)}}else e.U(`Tasks file not found: ${i.tasksFile}`,`warn`)}a.length===0&&(e.U(`❌ No tasks defined`,`error`),console.log(``),e.U(`Please provide tasks using one of these methods:`,`info`),e.U(` 1. Create a template-tasks.json file in the current directory`,`info`),e.U(` 2. Create a template-tasks.ts file in the current directory`,`info`),e.U(` 3. Use --tasks-file option to specify a different JSON file`,`info`),e.U(` 4. Use --tasks-ts option to specify a different TypeScript file`,`info`),console.log(``),e.U(`Example JSON structure:`,`info`),console.log(JSON.stringify({tasks:[{id:`update-package`,name:`Update package.json`,description:`Update package.json with repository information`,required:!0,enabled:!0,type:`update-json`,prompts:[{id:`projectName`,type:`input`,message:`What is your project name?`,default:`my-project`,required:!0},{id:`includeTests`,type:`confirm`,message:`Include test files?`,default:!0}],config:{file:`package.json`,updates:{name:`{{projectName}}`,author:`{{author}}`}}}]},null,2)),console.log(``),r.default.exit(1)),console.log(``),e.U(`Loaded ${a.length} task(s)`,`success`),console.log(``),await e.n(a,{dryRun:i.dryRun,force:i.force,tasksFilePath:o})}catch(t){if(e.U(`❌ CLI execution failed`,`error`),t instanceof Error){e.U(`Error: ${t.message}`,`error`);let n=r.default.env.DEBUG;n!=null&&n!==``&&console.error(t.stack)}else console.error(t);r.default.exit(1)}}),o.parse(r.default.argv);
2
+ const e=require(`./src-DxvGGX8s.cjs`);let t=require(`node:fs`);t=e.Z(t);let n=require(`node:path`);n=e.Z(n);let r=require(`node:process`);r=e.Z(r);let i=require(`commander`);i=e.Z(i);const a=1,o=new i.Command,s=n.default.join(__dirname,`..`,`package.json`);let c=`0.0.0`;try{c=JSON.parse(t.default.readFileSync(s,`utf-8`)).version??`0.0.0`}catch{}o.name(`scaffoldfy`).description(`Initialize and configure project templates with customizable tasks`).version(c),o.option(`--dry-run`,`Run in dry mode without making any changes`).option(`--force`,`Force re-initialization even if already initialized`).option(`--tasks-file <path>`,`Path to JSON file containing task definitions`,`./template-tasks.json`).option(`--tasks-ts <path>`,`Path to TypeScript file exporting tasks`,`./template-tasks.ts`).action(async i=>{try{let a=[],o,s,c;if(i.tasksTs!=null&&i.tasksTs!==``){let o=n.default.resolve(r.default.cwd(),i.tasksTs);if(t.default.existsSync(o)){e.q(`Loading tasks from TypeScript file: ${i.tasksTs}`,`info`),c=o;try{let t=await import(o);a=t.default??t.tasks??[],(!Array.isArray(a)||a.length===0)&&(e.q(`⚠️ No tasks found in TypeScript file or invalid format`,`warn`),e.q(`Expected default export or named export "tasks" with TaskDefinition[]`,`info`))}catch(t){e.q(`Failed to load TypeScript tasks file: ${i.tasksTs}`,`error`),t instanceof Error&&e.q(` Error: ${t.message}`,`error`),r.default.exit(1)}}}if(a.length===0&&i.tasksFile!=null&&i.tasksFile!==``){let l=n.default.resolve(r.default.cwd(),i.tasksFile);if(t.default.existsSync(l)){c=l;try{let t=await e.a(l);a=t.tasks,o=t.variables,s=t.prompts,Array.isArray(a)||(e.q(`❌ Invalid tasks file format`,`error`),e.q(`Expected JSON with { "tasks": [...] } structure`,`info`),r.default.exit(1))}catch(t){e.q(`Failed to load JSON tasks file: ${i.tasksFile}`,`error`),t instanceof Error&&e.q(` Error: ${t.message}`,`error`),r.default.exit(1)}}else e.q(`Tasks file not found: ${i.tasksFile}`,`warn`)}a.length===0&&(e.q(`❌ No tasks defined`,`error`),console.log(``),e.q(`Please provide tasks using one of these methods:`,`info`),e.q(` 1. Create a template-tasks.json file in the current directory`,`info`),e.q(` 2. Create a template-tasks.ts file in the current directory`,`info`),e.q(` 3. Use --tasks-file option to specify a different JSON file`,`info`),e.q(` 4. Use --tasks-ts option to specify a different TypeScript file`,`info`),console.log(``),e.q(`Example JSON structure:`,`info`),console.log(JSON.stringify({tasks:[{id:`update-package`,name:`Update package.json`,description:`Update package.json with repository information`,required:!0,enabled:!0,type:`update-json`,prompts:[{id:`projectName`,type:`input`,message:`What is your project name?`,default:`my-project`,required:!0},{id:`includeTests`,type:`confirm`,message:`Include test files?`,default:!0}],config:{file:`package.json`,updates:{name:`{{projectName}}`,author:`{{author}}`}}}]},null,2)),console.log(``),r.default.exit(1)),console.log(``),e.q(`Loaded ${a.length} task(s)`,`success`),console.log(``),await e.n(a,{dryRun:i.dryRun,force:i.force,tasksFilePath:c,globalVariables:o,globalPrompts:s})}catch(t){if(e.q(`❌ CLI execution failed`,`error`),t instanceof Error){e.q(`Error: ${t.message}`,`error`);let n=r.default.env.DEBUG;n!=null&&n!==``&&console.error(t.stack)}else console.error(t);r.default.exit(1)}}),o.parse(r.default.argv);
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{U as e,a as t,n}from"./src-_h_NfVky.js";import r from"node:path";import{fileURLToPath as i}from"node:url";import a from"node:fs";import o from"node:process";import{Command as s}from"commander";const c=()=>i(import.meta.url),l=(()=>r.dirname(c()))(),u=new s,d=r.join(l,`..`,`package.json`);let f=`0.0.0`;try{f=JSON.parse(a.readFileSync(d,`utf-8`)).version??`0.0.0`}catch{}u.name(`scaffoldfy`).description(`Initialize and configure project templates with customizable tasks`).version(f),u.option(`--dry-run`,`Run in dry mode without making any changes`).option(`--force`,`Force re-initialization even if already initialized`).option(`--tasks-file <path>`,`Path to JSON file containing task definitions`,`./template-tasks.json`).option(`--tasks-ts <path>`,`Path to TypeScript file exporting tasks`,`./template-tasks.ts`).action(async i=>{try{let s=[],c;if(i.tasksTs!=null&&i.tasksTs!==``){let t=r.resolve(o.cwd(),i.tasksTs);if(a.existsSync(t)){e(`Loading tasks from TypeScript file: ${i.tasksTs}`,`info`),c=t;try{let n=await import(t);s=n.default??n.tasks??[],(!Array.isArray(s)||s.length===0)&&(e(`⚠️ No tasks found in TypeScript file or invalid format`,`warn`),e(`Expected default export or named export "tasks" with TaskDefinition[]`,`info`))}catch(t){e(`Failed to load TypeScript tasks file: ${i.tasksTs}`,`error`),t instanceof Error&&e(` Error: ${t.message}`,`error`),o.exit(1)}}}if(s.length===0&&i.tasksFile!=null&&i.tasksFile!==``){let n=r.resolve(o.cwd(),i.tasksFile);if(a.existsSync(n)){c=n;try{s=await t(n),Array.isArray(s)||(e(`❌ Invalid tasks file format`,`error`),e(`Expected JSON with { "tasks": [...] } structure`,`info`),o.exit(1))}catch(t){e(`Failed to load JSON tasks file: ${i.tasksFile}`,`error`),t instanceof Error&&e(` Error: ${t.message}`,`error`),o.exit(1)}}else e(`Tasks file not found: ${i.tasksFile}`,`warn`)}s.length===0&&(e(`❌ No tasks defined`,`error`),console.log(``),e(`Please provide tasks using one of these methods:`,`info`),e(` 1. Create a template-tasks.json file in the current directory`,`info`),e(` 2. Create a template-tasks.ts file in the current directory`,`info`),e(` 3. Use --tasks-file option to specify a different JSON file`,`info`),e(` 4. Use --tasks-ts option to specify a different TypeScript file`,`info`),console.log(``),e(`Example JSON structure:`,`info`),console.log(JSON.stringify({tasks:[{id:`update-package`,name:`Update package.json`,description:`Update package.json with repository information`,required:!0,enabled:!0,type:`update-json`,prompts:[{id:`projectName`,type:`input`,message:`What is your project name?`,default:`my-project`,required:!0},{id:`includeTests`,type:`confirm`,message:`Include test files?`,default:!0}],config:{file:`package.json`,updates:{name:`{{projectName}}`,author:`{{author}}`}}}]},null,2)),console.log(``),o.exit(1)),console.log(``),e(`Loaded ${s.length} task(s)`,`success`),console.log(``),await n(s,{dryRun:i.dryRun,force:i.force,tasksFilePath:c})}catch(t){if(e(`❌ CLI execution failed`,`error`),t instanceof Error){e(`Error: ${t.message}`,`error`);let n=o.env.DEBUG;n!=null&&n!==``&&console.error(t.stack)}else console.error(t);o.exit(1)}}),u.parse(o.argv);export{};
2
+ import{a as e,n as t,q as n}from"./src-IzX9FHaO.js";import r from"node:path";import{fileURLToPath as i}from"node:url";import a from"node:fs";import o from"node:process";import{Command as s}from"commander";const c=()=>i(import.meta.url),l=(()=>r.dirname(c()))(),u=new s,d=r.join(l,`..`,`package.json`);let f=`0.0.0`;try{f=JSON.parse(a.readFileSync(d,`utf-8`)).version??`0.0.0`}catch{}u.name(`scaffoldfy`).description(`Initialize and configure project templates with customizable tasks`).version(f),u.option(`--dry-run`,`Run in dry mode without making any changes`).option(`--force`,`Force re-initialization even if already initialized`).option(`--tasks-file <path>`,`Path to JSON file containing task definitions`,`./template-tasks.json`).option(`--tasks-ts <path>`,`Path to TypeScript file exporting tasks`,`./template-tasks.ts`).action(async i=>{try{let s=[],c,l,u;if(i.tasksTs!=null&&i.tasksTs!==``){let e=r.resolve(o.cwd(),i.tasksTs);if(a.existsSync(e)){n(`Loading tasks from TypeScript file: ${i.tasksTs}`,`info`),u=e;try{let t=await import(e);s=t.default??t.tasks??[],(!Array.isArray(s)||s.length===0)&&(n(`⚠️ No tasks found in TypeScript file or invalid format`,`warn`),n(`Expected default export or named export "tasks" with TaskDefinition[]`,`info`))}catch(e){n(`Failed to load TypeScript tasks file: ${i.tasksTs}`,`error`),e instanceof Error&&n(` Error: ${e.message}`,`error`),o.exit(1)}}}if(s.length===0&&i.tasksFile!=null&&i.tasksFile!==``){let t=r.resolve(o.cwd(),i.tasksFile);if(a.existsSync(t)){u=t;try{let r=await e(t);s=r.tasks,c=r.variables,l=r.prompts,Array.isArray(s)||(n(`❌ Invalid tasks file format`,`error`),n(`Expected JSON with { "tasks": [...] } structure`,`info`),o.exit(1))}catch(e){n(`Failed to load JSON tasks file: ${i.tasksFile}`,`error`),e instanceof Error&&n(` Error: ${e.message}`,`error`),o.exit(1)}}else n(`Tasks file not found: ${i.tasksFile}`,`warn`)}s.length===0&&(n(`❌ No tasks defined`,`error`),console.log(``),n(`Please provide tasks using one of these methods:`,`info`),n(` 1. Create a template-tasks.json file in the current directory`,`info`),n(` 2. Create a template-tasks.ts file in the current directory`,`info`),n(` 3. Use --tasks-file option to specify a different JSON file`,`info`),n(` 4. Use --tasks-ts option to specify a different TypeScript file`,`info`),console.log(``),n(`Example JSON structure:`,`info`),console.log(JSON.stringify({tasks:[{id:`update-package`,name:`Update package.json`,description:`Update package.json with repository information`,required:!0,enabled:!0,type:`update-json`,prompts:[{id:`projectName`,type:`input`,message:`What is your project name?`,default:`my-project`,required:!0},{id:`includeTests`,type:`confirm`,message:`Include test files?`,default:!0}],config:{file:`package.json`,updates:{name:`{{projectName}}`,author:`{{author}}`}}}]},null,2)),console.log(``),o.exit(1)),console.log(``),n(`Loaded ${s.length} task(s)`,`success`),console.log(``),await t(s,{dryRun:i.dryRun,force:i.force,tasksFilePath:u,globalVariables:c,globalPrompts:l})}catch(e){if(n(`❌ CLI execution failed`,`error`),e instanceof Error){n(`Error: ${e.message}`,`error`);let t=o.env.DEBUG;t!=null&&t!==``&&console.error(e.stack)}else console.error(e);o.exit(1)}}),u.parse(o.argv);export{};
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- const e=require(`./src-BhknM6fX.cjs`);exports.callHook=e._,exports.clearPlugins=e.v,exports.clearTemplateCache=e.r,exports.collectPrompts=e.g,exports.createPlugin=e.y,exports.displayTasksDiff=e.A,exports.evaluateCondition=e.B,exports.executePluginTask=e.b,exports.executeTask=e.l,exports.getDeleteDiff=e.j,exports.getExecDiff=e.M,exports.getGitInitDiff=e.N,exports.getGitRepoInfo=e.V,exports.getPlugin=e.x,exports.getPluginForTaskType=e.S,exports.getPluginTaskDiff=e.C,exports.getRegexReplaceDiff=e.P,exports.getRenameDiff=e.F,exports.getReplaceInFileDiff=e.I,exports.getTaskDiff=e.L,exports.getTemplateDiff=e.R,exports.getUpdateJsonDiff=e.z,exports.interpolateTemplate=e.H,exports.isPluginTaskType=e.w,exports.listPlugins=e.T,exports.loadAndMergeTemplate=e.i,exports.loadInitializationState=e.d,exports.loadTasksWithInheritance=e.a,exports.loadTemplate=e.o,exports.log=e.U,exports.main=e.t,exports.mergeTemplates=e.s,exports.prompt=e.W,exports.promptYesNo=e.G,exports.registerHooks=e.E,exports.registerPlugin=e.D,exports.resolveAllDefaultValues=e.m,exports.resolveDefaultValue=e.h,exports.runTask=e.u,exports.runWithTasks=e.n,exports.saveInitializationState=e.f,exports.setNestedProperty=e.K,exports.topologicalSort=e.c,exports.unregisterPlugin=e.O,exports.validatePluginTask=e.k,exports.validatePrompts=e.p;
1
+ const e=require(`./src-DxvGGX8s.cjs`);exports.callHook=e.x,exports.clearPlugins=e.S,exports.clearTemplateCache=e.r,exports.collectPrompts=e.b,exports.collectVariables=e.d,exports.createPlugin=e.C,exports.displayTasksDiff=e.P,exports.evaluateCondition=e.W,exports.executePluginTask=e.w,exports.executeTask=e.p,exports.getDeleteDiff=e.F,exports.getExecDiff=e.I,exports.getGitInitDiff=e.L,exports.getGitRepoInfo=e.G,exports.getPlugin=e.T,exports.getPluginForTaskType=e.E,exports.getPluginTaskDiff=e.D,exports.getRegexReplaceDiff=e.R,exports.getRenameDiff=e.z,exports.getReplaceInFileDiff=e.B,exports.getTaskDiff=e.V,exports.getTemplateDiff=e.H,exports.getUpdateJsonDiff=e.U,exports.interpolateTemplate=e.K,exports.isPluginTaskType=e.O,exports.listPlugins=e.k,exports.loadAndMergeTemplate=e.i,exports.loadInitializationState=e.h,exports.loadTasksWithInheritance=e.a,exports.loadTemplate=e.o,exports.log=e.q,exports.main=e.t,exports.mergeTemplates=e.s,exports.prompt=e.J,exports.promptYesNo=e.Y,exports.registerHooks=e.A,exports.registerPlugin=e.j,exports.resolveAllDefaultValues=e.v,exports.resolveAllVariableValues=e.l,exports.resolveDefaultValue=e.y,exports.resolveVariableValue=e.u,exports.runTask=e.m,exports.runWithTasks=e.n,exports.saveInitializationState=e.g,exports.setNestedProperty=e.X,exports.topologicalSort=e.f,exports.unregisterPlugin=e.M,exports.validatePluginTask=e.N,exports.validatePrompts=e._,exports.validateVariables=e.c;
package/dist/index.d.cts CHANGED
@@ -1,7 +1,75 @@
1
+ //#region src/plugins/create/types.d.ts
2
+
3
+ interface CreateConfig {
4
+ file: string;
5
+ template?: string;
6
+ templateFile?: string;
7
+ condition?: ConditionExpression;
8
+ }
9
+ //#endregion
10
+ //#region src/plugins/delete/types.d.ts
11
+ interface DeleteConfig {
12
+ paths: string[];
13
+ condition?: ConditionExpression;
14
+ }
15
+ //#endregion
16
+ //#region src/plugins/exec/types.d.ts
17
+ interface ExecConfig {
18
+ command: string;
19
+ cwd?: string;
20
+ condition?: ConditionExpression;
21
+ }
22
+ //#endregion
23
+ //#region src/plugins/git-init/types.d.ts
24
+ interface GitInitConfig {
25
+ removeExisting: boolean;
26
+ initialCommit: boolean;
27
+ message?: string;
28
+ condition?: ConditionExpression;
29
+ }
30
+ //#endregion
31
+ //#region src/plugins/regex-replace/types.d.ts
32
+ interface RegexReplaceConfig {
33
+ file: string;
34
+ pattern: string;
35
+ flags?: string;
36
+ replacement: string;
37
+ condition?: ConditionExpression;
38
+ }
39
+ //#endregion
40
+ //#region src/plugins/rename/types.d.ts
41
+ interface RenameConfig {
42
+ from: string;
43
+ to: string;
44
+ condition?: ConditionExpression;
45
+ }
46
+ //#endregion
47
+ //#region src/plugins/replace-in-file/types.d.ts
48
+ interface ReplaceInFileConfig {
49
+ file: string;
50
+ replacements: Array<{
51
+ find: string;
52
+ replace: string;
53
+ }>;
54
+ condition?: ConditionExpression;
55
+ }
56
+ //#endregion
57
+ //#region src/plugins/template/types.d.ts
58
+ interface TemplateConfig {
59
+ file: string;
60
+ template?: string;
61
+ templateFile?: string;
62
+ condition?: ConditionExpression;
63
+ }
64
+ //#endregion
65
+ //#region src/plugins/update-json/types.d.ts
66
+ interface UpdateJsonConfig {
67
+ file: string;
68
+ updates: Record<string, unknown>;
69
+ condition?: ConditionExpression;
70
+ }
71
+ //#endregion
1
72
  //#region src/types.d.ts
2
- /**
3
- * Task Types and Interfaces for Template Initialization
4
- */
5
73
  interface InitConfig {
6
74
  [key: string]: unknown;
7
75
  }
@@ -11,10 +79,10 @@ interface InitConfig {
11
79
  type PromptType = 'input' | 'select' | 'confirm' | 'password' | 'number';
12
80
  /**
13
81
  * Default value types for prompts
14
- * - 'value': Static value
15
- * - 'execute': Execute a command to get the value
82
+ * - 'static': Static value provided directly
83
+ * - 'exec': Execute a command to get the value dynamically
16
84
  */
17
- type DefaultValueType = 'value' | 'execute';
85
+ type DefaultValueType = 'static' | 'exec';
18
86
  /**
19
87
  * Default value configuration for prompts
20
88
  */
@@ -23,15 +91,29 @@ interface DefaultValueConfig<T = string | number | boolean> {
23
91
  value: T | string;
24
92
  }
25
93
  /**
26
- * Type for default values that can be either static or executable
94
+ * Type for default values that can be either static or executable.
95
+ * - For simple static values, pass the value directly (e.g., "default-name", 42, true)
96
+ * - For executable defaults, use { type: 'exec', value: 'command' }
97
+ * - For explicit static values, use { type: 'static', value: yourValue }
27
98
  */
28
99
  type DefaultValue<T = string | number | boolean> = T | DefaultValueConfig<T>;
100
+ /**
101
+ * Conditional enabled configuration for prompts and tasks
102
+ * Allows dynamic enabling/disabling based on runtime conditions
103
+ */
104
+ interface ConditionalEnabled {
105
+ condition: ConditionExpression;
106
+ }
107
+ /**
108
+ * Type for enabled field that can be boolean or conditional
109
+ */
110
+ type EnabledValue = boolean | ConditionalEnabled;
29
111
  interface BasePrompt {
30
112
  id: string;
31
113
  type: PromptType;
32
114
  message: string;
33
115
  required?: boolean;
34
- global?: boolean;
116
+ enabled?: EnabledValue;
35
117
  }
36
118
  interface InputPrompt extends BasePrompt {
37
119
  type: 'input' | 'password';
@@ -57,7 +139,26 @@ interface ConfirmPrompt extends BasePrompt {
57
139
  default?: DefaultValue<boolean>;
58
140
  }
59
141
  type PromptDefinition = InputPrompt | NumberPrompt | SelectPrompt | ConfirmPrompt;
60
- type TaskType = 'update-json' | 'template' | 'regex-replace' | 'replace-in-file' | 'delete' | 'rename' | 'git-init' | 'exec';
142
+ /**
143
+ * Variable value configuration for defining optional global or task-scoped variables
144
+ * Variables are similar to prompts but don't require user input - they can have static
145
+ * values or values resolved from executable commands
146
+ *
147
+ * Note: Top-level variables are always global. Task-level variables are task-scoped.
148
+ */
149
+ interface VariableDefinition {
150
+ id: string;
151
+ value: DefaultValue;
152
+ }
153
+ /**
154
+ * JavaScript expression evaluated at runtime to determine if a task or operation should execute.
155
+ * Has access to all prompt values, variables, and config variables.
156
+ * @example "useTypeScript === true"
157
+ * @example "nodeVersion >= 16 && includeTests === true"
158
+ * @example "packageManager === 'pnpm'"
159
+ */
160
+ type ConditionExpression = string;
161
+ type TaskType = 'update-json' | 'template' | 'create' | 'regex-replace' | 'replace-in-file' | 'delete' | 'rename' | 'git-init' | 'exec';
61
162
  interface RollbackConfig {
62
163
  type: TaskType;
63
164
  config: unknown;
@@ -67,58 +168,13 @@ interface TaskDefinition {
67
168
  name: string;
68
169
  description: string;
69
170
  required: boolean;
70
- enabled: boolean;
171
+ enabled: EnabledValue;
71
172
  type: TaskType;
72
- config: unknown;
173
+ config: UpdateJsonConfig | TemplateConfig | CreateConfig | RegexReplaceConfig | ReplaceInFileConfig | DeleteConfig | RenameConfig | GitInitConfig | ExecConfig | Record<string, unknown>;
73
174
  dependencies?: string[];
74
175
  rollback?: RollbackConfig;
75
176
  prompts?: PromptDefinition[];
76
- }
77
- interface UpdateJsonConfig {
78
- file: string;
79
- updates: Record<string, unknown>;
80
- condition?: string;
81
- }
82
- interface TemplateConfig {
83
- file: string;
84
- template?: string;
85
- templateFile?: string;
86
- condition?: string;
87
- }
88
- interface RegexReplaceConfig {
89
- file: string;
90
- pattern: string;
91
- flags?: string;
92
- replacement: string;
93
- condition?: string;
94
- }
95
- interface ReplaceInFileConfig {
96
- file: string;
97
- replacements: Array<{
98
- find: string;
99
- replace: string;
100
- }>;
101
- condition?: string;
102
- }
103
- interface DeleteConfig {
104
- paths: string[];
105
- condition?: string;
106
- }
107
- interface RenameConfig {
108
- from: string;
109
- to: string;
110
- condition?: string;
111
- }
112
- interface GitInitConfig {
113
- removeExisting: boolean;
114
- initialCommit: boolean;
115
- message?: string;
116
- condition?: string;
117
- }
118
- interface ExecConfig {
119
- command: string;
120
- cwd?: string;
121
- condition?: string;
177
+ variables?: VariableDefinition[];
122
178
  }
123
179
  interface InitializationMetadata {
124
180
  initializedAt: string;
@@ -131,6 +187,8 @@ interface InitializationMetadata {
131
187
  */
132
188
  interface TasksConfiguration {
133
189
  extends?: string | string[];
190
+ variables?: VariableDefinition[];
191
+ prompts?: PromptDefinition[];
134
192
  tasks: TaskDefinition[];
135
193
  }
136
194
  /**
@@ -308,11 +366,13 @@ declare function createPlugin(name: string, taskType: string, execute: (task: Ta
308
366
  //#region src/prompts/collect-prompts.d.ts
309
367
  /**
310
368
  * Collect prompt answers from task-defined prompts
369
+ * Only prompts with enabled=true (or enabled condition that evaluates to true) will be shown
311
370
  * @param prompts - Array of prompt definitions from tasks
312
371
  * @param resolvedDefaults - Map of pre-resolved default values
372
+ * @param config - Current configuration context (for evaluating enabled conditions)
313
373
  * @returns Object mapping prompt IDs to their values
314
374
  */
315
- declare function collectPrompts(prompts: PromptDefinition[], resolvedDefaults?: Map<string, unknown>): Promise<Record<string, unknown>>;
375
+ declare function collectPrompts(prompts: PromptDefinition[], resolvedDefaults?: Map<string, unknown>, config?: InitConfig): Promise<Record<string, unknown>>;
316
376
  //#endregion
317
377
  //#region src/prompts/resolve-all-default-values.d.ts
318
378
  /**
@@ -395,9 +455,13 @@ declare function clearTemplateCache(): void;
395
455
  /**
396
456
  * Load tasks from a configuration file with template inheritance support
397
457
  * @param tasksFilePath - Path to the tasks configuration file
398
- * @returns Array of task definitions
458
+ * @returns Task configuration with tasks, optional variables, and optional prompts
399
459
  */
400
- declare function loadTasksWithInheritance(tasksFilePath: string): Promise<TaskDefinition[]>;
460
+ declare function loadTasksWithInheritance(tasksFilePath: string): Promise<{
461
+ tasks: TaskDefinition[];
462
+ variables?: VariableDefinition[];
463
+ prompts?: PromptDefinition[];
464
+ }>;
401
465
  //#endregion
402
466
  //#region src/utils.d.ts
403
467
  /**
@@ -433,6 +497,43 @@ declare function setNestedProperty(obj: Record<string, unknown>, propertyPath: s
433
497
  */
434
498
  declare function evaluateCondition(condition: string, config: InitConfig): boolean;
435
499
  //#endregion
500
+ //#region src/variables/collect-variables.d.ts
501
+ /**
502
+ * Collect variable values from resolved variables
503
+ * Variables don't require user interaction - they're just resolved from static
504
+ * values or executable commands
505
+ *
506
+ * @param variables - Array of variable definitions
507
+ * @param resolvedValues - Map of pre-resolved variable values
508
+ * @returns Object mapping variable IDs to their values
509
+ */
510
+ declare function collectVariables(variables: VariableDefinition[], resolvedValues?: Map<string, unknown>): Record<string, unknown>;
511
+ //#endregion
512
+ //#region src/variables/resolve-all-variable-values.d.ts
513
+ /**
514
+ * Pre-resolve all variable values (execute commands in parallel for efficiency)
515
+ * @param variables - Array of variable definitions
516
+ * @returns Map of variable IDs to their resolved values
517
+ */
518
+ declare function resolveAllVariableValues(variables: VariableDefinition[]): Promise<Map<string, unknown>>;
519
+ //#endregion
520
+ //#region src/variables/resolve-variable-value.d.ts
521
+ /**
522
+ * Resolve a variable value that may be static or executable
523
+ * @param value - The variable value configuration
524
+ * @param variableId - The variable ID for error reporting
525
+ * @returns The resolved variable value
526
+ */
527
+ declare function resolveVariableValue<T = string | number | boolean>(value: DefaultValue<T>, variableId: string): Promise<T | undefined>;
528
+ //#endregion
529
+ //#region src/variables/validate-variables.d.ts
530
+ /**
531
+ * Validate variable definitions for common errors
532
+ * @param variables - Array of variable definitions to validate
533
+ * @returns Array of error messages (empty if no errors)
534
+ */
535
+ declare function validateVariables(variables: VariableDefinition[]): string[];
536
+ //#endregion
436
537
  //#region src/index.d.ts
437
538
  /**
438
539
  * Main function for running initialization with default/empty tasks
@@ -446,11 +547,15 @@ declare function main(customTasks?: TaskDefinition[]): Promise<void>;
446
547
  * @param options.dryRun - Preview changes without applying them
447
548
  * @param options.force - Force re-initialization even if already initialized
448
549
  * @param options.tasksFilePath - Path to the tasks file
550
+ * @param options.globalVariables - Optional top-level global variables
551
+ * @param options.globalPrompts - Optional top-level global prompts
449
552
  */
450
553
  declare function runWithTasks(customTasks: TaskDefinition[], options?: {
451
554
  dryRun?: boolean | undefined;
452
555
  force?: boolean | undefined;
453
556
  tasksFilePath?: string | undefined;
557
+ globalVariables?: VariableDefinition[] | undefined;
558
+ globalPrompts?: PromptDefinition[] | undefined;
454
559
  }): Promise<void>;
455
560
  //#endregion
456
- export { BasePrompt, ConfirmPrompt, DefaultValue, DefaultValueConfig, DefaultValueType, DeleteConfig, ExecConfig, GitInitConfig, InitConfig, InitializationMetadata, InputPrompt, NumberPrompt, PluginHooks, PromptDefinition, PromptType, RegexReplaceConfig, RenameConfig, ReplaceInFileConfig, RollbackConfig, SelectPrompt, TaskDefinition, TaskPlugin, TaskType, TasksConfiguration, TemplateConfig, UpdateJsonConfig, callHook, clearPlugins, clearTemplateCache, collectPrompts, createPlugin, displayTasksDiff, evaluateCondition, executePluginTask, executeTask, getDeleteDiff, getExecDiff, getGitInitDiff, getGitRepoInfo, getPlugin, getPluginForTaskType, getPluginTaskDiff, getRegexReplaceDiff, getRenameDiff, getReplaceInFileDiff, getTaskDiff, getTemplateDiff, getUpdateJsonDiff, interpolateTemplate, isPluginTaskType, listPlugins, loadAndMergeTemplate, loadInitializationState, loadTasksWithInheritance, loadTemplate, log, main, mergeTemplates, prompt, promptYesNo, registerHooks, registerPlugin, resolveAllDefaultValues, resolveDefaultValue, runTask, runWithTasks, saveInitializationState, setNestedProperty, topologicalSort, unregisterPlugin, validatePluginTask, validatePrompts };
561
+ export { BasePrompt, ConditionExpression, ConditionalEnabled, ConfirmPrompt, type CreateConfig, DefaultValue, DefaultValueConfig, DefaultValueType, type DeleteConfig, EnabledValue, type ExecConfig, type GitInitConfig, InitConfig, InitializationMetadata, InputPrompt, NumberPrompt, PluginHooks, PromptDefinition, PromptType, type RegexReplaceConfig, type RenameConfig, type ReplaceInFileConfig, RollbackConfig, SelectPrompt, TaskDefinition, TaskPlugin, TaskType, TasksConfiguration, type TemplateConfig, type UpdateJsonConfig, VariableDefinition, callHook, clearPlugins, clearTemplateCache, collectPrompts, collectVariables, createPlugin, displayTasksDiff, evaluateCondition, executePluginTask, executeTask, getDeleteDiff, getExecDiff, getGitInitDiff, getGitRepoInfo, getPlugin, getPluginForTaskType, getPluginTaskDiff, getRegexReplaceDiff, getRenameDiff, getReplaceInFileDiff, getTaskDiff, getTemplateDiff, getUpdateJsonDiff, interpolateTemplate, isPluginTaskType, listPlugins, loadAndMergeTemplate, loadInitializationState, loadTasksWithInheritance, loadTemplate, log, main, mergeTemplates, prompt, promptYesNo, registerHooks, registerPlugin, resolveAllDefaultValues, resolveAllVariableValues, resolveDefaultValue, resolveVariableValue, runTask, runWithTasks, saveInitializationState, setNestedProperty, topologicalSort, unregisterPlugin, validatePluginTask, validatePrompts, validateVariables };