@pixpilot/scaffoldfy 0.29.2 → 0.30.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
@@ -280,9 +280,9 @@ See color-coded diffs for all file modifications, deletions, and additions.
280
280
  Create custom task types for specialized operations:
281
281
 
282
282
  ```typescript
283
- import { createPlugin, registerPlugin } from '@pixpilot/scaffoldfy';
283
+ import { createTaskPlugin, registerPlugin } from '@pixpilot/scaffoldfy';
284
284
 
285
- const myPlugin = createPlugin(
285
+ const myPlugin = createTaskPlugin(
286
286
  'my-plugin',
287
287
  'custom-task',
288
288
  async (task, config, options) => {
@@ -431,7 +431,7 @@ Control execution order:
431
431
 
432
432
  ### Resources
433
433
 
434
- - **[JSON Schema](schema/tasks.schema.json)** - For IDE autocomplete and validation
434
+ - **[JSON Schema](schema/scaffoldfy.schema.json)** - For IDE autocomplete and validation
435
435
  - **[Example Files](examples/)** - Sample task configurations
436
436
 
437
437
  ## JSON Schema Support
@@ -440,7 +440,7 @@ Enable autocomplete and validation in your IDE:
440
440
 
441
441
  ```json
442
442
  {
443
- "$schema": "node_modules/@pixpilot/scaffoldfy/schema/tasks.schema.json",
443
+ "$schema": "https://unpkg.com/@pixpilot/scaffoldfy/schema",
444
444
  "tasks": []
445
445
  }
446
446
  ```
@@ -0,0 +1 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return s}});
package/dist/cli.cjs CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- const e=require(`./utils-BeqQVvh1.cjs`);require(`./config-DlJs75hK.cjs`);const t=require(`./run-tasks-BPiZCUDh.cjs`),n=require(`./src-DJXRbf0z.cjs`);let r=require(`node:fs`);r=e.S(r);let i=require(`node:path`);i=e.S(i);let a=require(`node:process`);a=e.S(a);let o=require(`commander`);o=e.S(o);let s=require(`node:url`);s=e.S(s);let c=require(`ajv`);c=e.S(c);const l=1,u=(0,s.fileURLToPath)(require(`url`).pathToFileURL(__filename).href),d=i.default.dirname(u);function f(){return new c.default({allErrors:!0,verbose:!0,strict:!1,discriminator:!0})}function p(){let e=i.default.join(d,`..`,`schema`,`tasks.schema.json`);try{let t=r.default.readFileSync(e,`utf-8`);return JSON.parse(t)}catch(t){throw Error(`Failed to load tasks schema from ${e}: ${t instanceof Error?t.message:String(t)}`)}}function m(e){return e.filter(t=>{if(t.keyword===`oneOf`){let e=t.params;if(e.passingSchemas&&e.passingSchemas.length>0)return!1}if(t.keyword===`required`){let n=e.find(e=>e.keyword===`oneOf`&&e.instancePath===t.instancePath);if(n){let e=n.params;if(e.passingSchemas&&e.passingSchemas.length>0)return!1}}return!0}).map(e=>{let t=e.instancePath||`root`,n=e.message??`Unknown error`;switch(e.keyword){case`required`:return`${t}: Missing required property "${String(e.params.missingProperty??`unknown`)}"`;case`type`:return`${t}: Expected type "${String(e.params.type??`unknown`)}", received "${typeof e.data}"`;case`enum`:{let r=e.params.allowedValues;return`${t}: ${n}. Allowed values: ${Array.isArray(r)?r.join(`, `):String(r)}`}case`pattern`:{let{pattern:r}=e.params;return`${t}: ${n}. Value must match pattern: ${String(r)}`}case`oneOf`:return`${t}: ${n}. Configuration must match exactly one of the allowed schemas`;case`additionalProperties`:return`${t}: ${n}. Unknown property: "${String(e.params.additionalProperty??`unknown`)}"`;default:return`${t}: ${n}`}})}function h(t,n={}){try{let e=f(),r=p(),i=e.compile(r);if(!i(t)&&i.errors){let e=m(i.errors);return e.length===0?{valid:!0,errors:[]}:(n.silent||g(e),{valid:!1,errors:e})}return{valid:!0,errors:[]}}catch(t){let r=t instanceof Error?t.message:`Unknown error occurred during schema validation`;return n.silent||(e.i(`❌ Schema validation error:`,`error`),e.i(` ${r}`,`error`)),{valid:!1,errors:[r]}}}function g(t){e.i(`❌ Schema validation failed:`,`error`),e.i(``,`error`),e.i(`The following validation errors were found:`,`error`),e.i(``,`error`);for(let n of t)e.i(` • ${n}`,`error`);e.i(``,`error`),e.i(`Please fix these errors in your template configuration file.`,`error`),e.i(``,`error`),e.i(`For schema documentation, see: https://github.com/pixpilot/scaffoldfy/tree/main/packages/scaffoldfy/schema`,`info`)}const _=new o.Command,v=i.default.join(__dirname,`..`,`package.json`);let y=`0.0.0`;try{y=JSON.parse(r.default.readFileSync(v,`utf-8`)).version??`0.0.0`}catch{}_.name(`scaffoldfy`).description(`Automate project setup and configuration with customizable tasks`).version(y),_.option(`--dry-run`,`Run in dry mode without making any changes`).option(`--force`,`Force execution even if checks fail`).option(`--config <path>`,`Path to task configuration file (JSON or TypeScript)`,`./template-tasks.json`).option(`--no-validate`,`Skip schema validation of task configuration (validation is enabled by default)`).option(`--debug`,`Enable debug logging for verbose output`).action(async o=>{o.debug===!0&&e.f(!0);try{let s=[],c,l,u,d;if(o.config!=null&&o.config!==``){let n=i.default.resolve(a.default.cwd(),o.config);if(r.default.existsSync(n))if(d=n,n.endsWith(`.ts`)||n.endsWith(`.mts`)){e.i(`Loading tasks from TypeScript file: ${o.config}`,`info`);try{let t=await import(n);s=t.default??t.tasks??[],(!Array.isArray(s)||s.length===0)&&(e.i(`⚠️ No tasks found in TypeScript file or invalid format`,`warn`),e.i(`Expected default export or named export "tasks" with TaskDefinition[]`,`info`))}catch(t){e.i(`Failed to load TypeScript config file: ${o.config}`,`error`),t instanceof Error&&e.i(` Error: ${t.message}`,`error`),a.default.exit(1)}}else try{if(o.validate!==!1){e.u(`Validating task configuration against schema...`);let t=r.default.readFileSync(n,`utf-8`);h(JSON.parse(t),{silent:!1}).valid||(e.i(``,`error`),e.i(`💡 You can skip validation with --no-validate flag, but this is not recommended.`,`info`),a.default.exit(1)),e.i(`Configuration validated`,`success`)}let i=await t.q(n,{sequential:!0});if(i.templates!=null&&i.templates.length>0){let{runTemplatesSequentially:e}=await Promise.resolve().then(()=>require(`./run-tasks-BwR-eZSD.cjs`)),{createInitialConfig:t}=await Promise.resolve().then(()=>require(`./config-DmK0Erv2.cjs`));await e(i.templates,{dryRun:o.dryRun??!1,force:o.force??!1,tasksFilePath:n},t()),a.default.exit(0)}s=i.tasks,c=i.variables,l=i.prompts,u=i.enabled,Array.isArray(s)||(e.i(`❌ Invalid config file format`,`error`),e.i(`Expected JSON with { "tasks": [...] } structure`,`info`),a.default.exit(1))}catch(t){e.i(`Failed to load JSON config file: ${o.config}`,`error`),t instanceof Error&&e.i(` Error: ${t.message}`,`error`),a.default.exit(1)}else e.i(`Config file not found: ${o.config}`,`warn`)}let f=l!=null&&l.length>0||c!=null&&c.length>0;s.length===0&&!f&&(e.i(`❌ No tasks defined`,`error`),e.i(`Please provide tasks using one of these methods:`,`info`),e.i(` 1. Create a template-tasks.json file in the current directory`,`info`),e.i(` 2. Create a template-tasks.ts file in the current directory`,`info`),e.i(` 3. Use --config option to specify a different config file`,`info`),e.i(`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)),a.default.exit(1)),s.length===0?e.i(`Loaded template with 0 tasks (template may only provide prompts/variables for extending)`,`info`):e.i(`Loaded ${s.length} task(s)`,`success`),await n.n(s,{dryRun:o.dryRun,force:o.force,tasksFilePath:d,variables:c,prompts:l,templateEnabled:u})}catch(t){if(e.i(`❌ CLI execution failed`,`error`),t instanceof Error){e.i(`Error: ${t.message}`,`error`);let n=a.default.env.DEBUG;n!=null&&n!==``&&console.error(t.stack)}else console.error(t);a.default.exit(1)}}),_.parse(a.default.argv);
2
+ const e=require(`./chunk-DjWAcSYV.cjs`);require(`./config-DlJs75hK.cjs`);const t=require(`./utils-DjBGLPnu.cjs`),n=require(`./run-tasks-C6Bkzhq7.cjs`),r=require(`./src-CmBriDDR.cjs`);let i=require(`node:fs`);i=e.t(i);let a=require(`node:path`);a=e.t(a);let o=require(`node:process`);o=e.t(o);let s=require(`commander`);s=e.t(s);let c=require(`node:url`);c=e.t(c);let l=require(`ajv`);l=e.t(l);const u=1,d=(0,c.fileURLToPath)(require(`url`).pathToFileURL(__filename).href),f=a.default.dirname(d);function p(){return new l.default({allErrors:!0,verbose:!0,strict:!1,discriminator:!0})}function m(){let e=a.default.join(f,`..`,`schema`,`scaffoldfy.schema.json`);try{let t=i.default.readFileSync(e,`utf-8`);return JSON.parse(t)}catch(t){throw Error(`Failed to load tasks schema from ${e}: ${t instanceof Error?t.message:String(t)}`)}}function h(e){return e.filter(t=>{if(t.keyword===`oneOf`){let e=t.params;if(e.passingSchemas&&e.passingSchemas.length>0)return!1}if(t.keyword===`required`){let n=e.find(e=>e.keyword===`oneOf`&&e.instancePath===t.instancePath);if(n){let e=n.params;if(e.passingSchemas&&e.passingSchemas.length>0)return!1}}return!0}).map(e=>{let t=e.instancePath||`root`,n=e.message??`Unknown error`;switch(e.keyword){case`required`:return`${t}: Missing required property "${String(e.params.missingProperty??`unknown`)}"`;case`type`:return`${t}: Expected type "${String(e.params.type??`unknown`)}", received "${typeof e.data}"`;case`enum`:{let r=e.params.allowedValues;return`${t}: ${n}. Allowed values: ${Array.isArray(r)?r.join(`, `):String(r)}`}case`pattern`:{let{pattern:r}=e.params;return`${t}: ${n}. Value must match pattern: ${String(r)}`}case`oneOf`:return`${t}: ${n}. Configuration must match exactly one of the allowed schemas`;case`additionalProperties`:return`${t}: ${n}. Unknown property: "${String(e.params.additionalProperty??`unknown`)}"`;default:return`${t}: ${n}`}})}function g(e,n={}){try{let t=p(),r=m(),i=t.compile(r);if(!i(e)&&i.errors){let e=h(i.errors);return e.length===0?{valid:!0,errors:[]}:(n.silent||_(e),{valid:!1,errors:e})}return{valid:!0,errors:[]}}catch(e){let r=e instanceof Error?e.message:`Unknown error occurred during schema validation`;return n.silent||(t.a(`❌ Schema validation error:`,`error`),t.a(` ${r}`,`error`)),{valid:!1,errors:[r]}}}function _(e){t.a(`❌ Schema validation failed:`,`error`),t.a(``,`error`),t.a(`The following validation errors were found:`,`error`),t.a(``,`error`);for(let n of e)t.a(` • ${n}`,`error`);t.a(``,`error`),t.a(`Please fix these errors in your template configuration file.`,`error`),t.a(``,`error`),t.a(`For schema documentation, see: https://github.com/pixpilot/scaffoldfy/tree/main/packages/scaffoldfy/schema`,`info`)}const v=new s.Command,y=a.default.join(__dirname,`..`,`package.json`);let b=`0.0.0`;try{b=JSON.parse(i.default.readFileSync(y,`utf-8`)).version??`0.0.0`}catch{}v.name(`scaffoldfy`).description(`Automate project setup and configuration with customizable tasks`).version(b),v.option(`--dry-run`,`Run in dry mode without making any changes`).option(`--force`,`Force execution even if checks fail`).option(`--config <path>`,`Path to task configuration file (JSON or TypeScript)`,`./template-tasks.json`).option(`--no-validate`,`Skip schema validation of task configuration (validation is enabled by default)`).option(`--debug`,`Enable debug logging for verbose output`).action(async e=>{e.debug===!0&&t.p(!0);try{let s=[],c,l,u,d,f;if(e.config!=null&&e.config!==``){let r=a.default.resolve(o.default.cwd(),e.config);if(i.default.existsSync(r))if(f=r,r.endsWith(`.ts`)||r.endsWith(`.mts`)){t.a(`Loading tasks from TypeScript file: ${e.config}`,`info`);try{let e=await import(r);s=e.default??e.tasks??[],(!Array.isArray(s)||s.length===0)&&(t.a(`⚠️ No tasks found in TypeScript file or invalid format`,`warn`),t.a(`Expected default export or named export "tasks" with TaskDefinition[]`,`info`))}catch(n){t.a(`Failed to load TypeScript config file: ${e.config}`,`error`),n instanceof Error&&t.a(` Error: ${n.message}`,`error`),o.default.exit(1)}}else try{if(e.validate!==!1){t.d(`Validating task configuration against schema...`);let e=i.default.readFileSync(r,`utf-8`);g(JSON.parse(e),{silent:!1}).valid||(t.a(``,`error`),t.a(`💡 You can skip validation with --no-validate flag, but this is not recommended.`,`info`),o.default.exit(1)),t.a(`Configuration validated`,`success`)}let a=await n.q(r,{sequential:!0});if(a.templates!=null&&a.templates.length>0){let{runTemplatesSequentially:t}=await Promise.resolve().then(()=>require(`./run-tasks-BZwbB2B0.cjs`)),{createInitialConfig:n}=await Promise.resolve().then(()=>require(`./config-DmK0Erv2.cjs`));await t(a.templates,{dryRun:e.dryRun??!1,force:e.force??!1,tasksFilePath:r},n()),o.default.exit(0)}s=a.tasks,c=a.variables,l=a.prompts,u=a.enabled,d=a.transformers,Array.isArray(s)||(t.a(`❌ Invalid config file format`,`error`),t.a(`Expected JSON with { "tasks": [...] } structure`,`info`),o.default.exit(1))}catch(n){t.a(`Failed to load JSON config file: ${e.config}`,`error`),n instanceof Error&&t.a(` Error: ${n.message}`,`error`),o.default.exit(1)}else t.a(`Config file not found: ${e.config}`,`warn`)}let p=l!=null&&l.length>0||c!=null&&c.length>0;s.length===0&&!p&&(t.a(`❌ No tasks defined`,`error`),t.a(`Please provide tasks using one of these methods:`,`info`),t.a(` 1. Create a template-tasks.json file in the current directory`,`info`),t.a(` 2. Create a template-tasks.ts file in the current directory`,`info`),t.a(` 3. Use --config option to specify a different config file`,`info`),t.a(`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)),o.default.exit(1)),s.length===0?t.a(`Loaded template with 0 tasks (template may only provide prompts/variables for extending)`,`info`):t.a(`Loaded ${s.length} task(s)`,`success`),await r.n(s,{dryRun:e.dryRun,force:e.force,tasksFilePath:f,variables:c,prompts:l,templateEnabled:u,transformers:d})}catch(e){if(t.a(`❌ CLI execution failed`,`error`),e instanceof Error){t.a(`Error: ${e.message}`,`error`);let n=o.default.env.DEBUG;n!=null&&n!==``&&console.error(e.stack)}else console.error(e);o.default.exit(1)}}),v.parse(o.default.argv);
package/dist/cli.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import"./config-DfRbCqsT.js";import{f as e,i as t,u as n}from"./utils-C3bHtTZl.js";import{q as r}from"./run-tasks-CzHOfpfu.js";import{n as i}from"./src-DcsCaCmY.js";import a from"node:path";import{fileURLToPath as o}from"node:url";import s from"node:fs";import c from"node:process";import{Command as l}from"commander";import u from"ajv";const d=()=>o(import.meta.url),f=(()=>a.dirname(d()))(),p=o(import.meta.url),m=a.dirname(p);function h(){return new u({allErrors:!0,verbose:!0,strict:!1,discriminator:!0})}function g(){let e=a.join(m,`..`,`schema`,`tasks.schema.json`);try{let t=s.readFileSync(e,`utf-8`);return JSON.parse(t)}catch(t){throw Error(`Failed to load tasks schema from ${e}: ${t instanceof Error?t.message:String(t)}`)}}function _(e){return e.filter(t=>{if(t.keyword===`oneOf`){let e=t.params;if(e.passingSchemas&&e.passingSchemas.length>0)return!1}if(t.keyword===`required`){let n=e.find(e=>e.keyword===`oneOf`&&e.instancePath===t.instancePath);if(n){let e=n.params;if(e.passingSchemas&&e.passingSchemas.length>0)return!1}}return!0}).map(e=>{let t=e.instancePath||`root`,n=e.message??`Unknown error`;switch(e.keyword){case`required`:return`${t}: Missing required property "${String(e.params.missingProperty??`unknown`)}"`;case`type`:return`${t}: Expected type "${String(e.params.type??`unknown`)}", received "${typeof e.data}"`;case`enum`:{let r=e.params.allowedValues;return`${t}: ${n}. Allowed values: ${Array.isArray(r)?r.join(`, `):String(r)}`}case`pattern`:{let{pattern:r}=e.params;return`${t}: ${n}. Value must match pattern: ${String(r)}`}case`oneOf`:return`${t}: ${n}. Configuration must match exactly one of the allowed schemas`;case`additionalProperties`:return`${t}: ${n}. Unknown property: "${String(e.params.additionalProperty??`unknown`)}"`;default:return`${t}: ${n}`}})}function v(e,n={}){try{let t=h(),r=g(),i=t.compile(r);if(!i(e)&&i.errors){let e=_(i.errors);return e.length===0?{valid:!0,errors:[]}:(n.silent||y(e),{valid:!1,errors:e})}return{valid:!0,errors:[]}}catch(e){let r=e instanceof Error?e.message:`Unknown error occurred during schema validation`;return n.silent||(t(`❌ Schema validation error:`,`error`),t(` ${r}`,`error`)),{valid:!1,errors:[r]}}}function y(e){t(`❌ Schema validation failed:`,`error`),t(``,`error`),t(`The following validation errors were found:`,`error`),t(``,`error`);for(let n of e)t(` • ${n}`,`error`);t(``,`error`),t(`Please fix these errors in your template configuration file.`,`error`),t(``,`error`),t(`For schema documentation, see: https://github.com/pixpilot/scaffoldfy/tree/main/packages/scaffoldfy/schema`,`info`)}const b=new l,x=a.join(f,`..`,`package.json`);let S=`0.0.0`;try{S=JSON.parse(s.readFileSync(x,`utf-8`)).version??`0.0.0`}catch{}b.name(`scaffoldfy`).description(`Automate project setup and configuration with customizable tasks`).version(S),b.option(`--dry-run`,`Run in dry mode without making any changes`).option(`--force`,`Force execution even if checks fail`).option(`--config <path>`,`Path to task configuration file (JSON or TypeScript)`,`./template-tasks.json`).option(`--no-validate`,`Skip schema validation of task configuration (validation is enabled by default)`).option(`--debug`,`Enable debug logging for verbose output`).action(async o=>{o.debug===!0&&e(!0);try{let e=[],l,u,d,f;if(o.config!=null&&o.config!==``){let i=a.resolve(c.cwd(),o.config);if(s.existsSync(i))if(f=i,i.endsWith(`.ts`)||i.endsWith(`.mts`)){t(`Loading tasks from TypeScript file: ${o.config}`,`info`);try{let n=await import(i);e=n.default??n.tasks??[],(!Array.isArray(e)||e.length===0)&&(t(`⚠️ No tasks found in TypeScript file or invalid format`,`warn`),t(`Expected default export or named export "tasks" with TaskDefinition[]`,`info`))}catch(e){t(`Failed to load TypeScript config file: ${o.config}`,`error`),e instanceof Error&&t(` Error: ${e.message}`,`error`),c.exit(1)}}else try{if(o.validate!==!1){n(`Validating task configuration against schema...`);let e=s.readFileSync(i,`utf-8`);v(JSON.parse(e),{silent:!1}).valid||(t(``,`error`),t(`💡 You can skip validation with --no-validate flag, but this is not recommended.`,`info`),c.exit(1)),t(`Configuration validated`,`success`)}let a=await r(i,{sequential:!0});if(a.templates!=null&&a.templates.length>0){let{runTemplatesSequentially:e}=await import(`./run-tasks-DfX2OfFK.js`),{createInitialConfig:t}=await import(`./config-C8hh88Lc.js`);await e(a.templates,{dryRun:o.dryRun??!1,force:o.force??!1,tasksFilePath:i},t()),c.exit(0)}e=a.tasks,l=a.variables,u=a.prompts,d=a.enabled,Array.isArray(e)||(t(`❌ Invalid config file format`,`error`),t(`Expected JSON with { "tasks": [...] } structure`,`info`),c.exit(1))}catch(e){t(`Failed to load JSON config file: ${o.config}`,`error`),e instanceof Error&&t(` Error: ${e.message}`,`error`),c.exit(1)}else t(`Config file not found: ${o.config}`,`warn`)}let p=u!=null&&u.length>0||l!=null&&l.length>0;e.length===0&&!p&&(t(`❌ No tasks defined`,`error`),t(`Please provide tasks using one of these methods:`,`info`),t(` 1. Create a template-tasks.json file in the current directory`,`info`),t(` 2. Create a template-tasks.ts file in the current directory`,`info`),t(` 3. Use --config option to specify a different config file`,`info`),t(`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)),c.exit(1)),e.length===0?t(`Loaded template with 0 tasks (template may only provide prompts/variables for extending)`,`info`):t(`Loaded ${e.length} task(s)`,`success`),await i(e,{dryRun:o.dryRun,force:o.force,tasksFilePath:f,variables:l,prompts:u,templateEnabled:d})}catch(e){if(t(`❌ CLI execution failed`,`error`),e instanceof Error){t(`Error: ${e.message}`,`error`);let n=c.env.DEBUG;n!=null&&n!==``&&console.error(e.stack)}else console.error(e);c.exit(1)}}),b.parse(c.argv);export{};
2
+ import"./config-DfRbCqsT.js";import{a as e,d as t,p as n}from"./utils-CmYva5oB.js";import{q as r}from"./run-tasks-D5KLV8Tk.js";import{n as i}from"./src-DbtBS6he.js";import a from"node:path";import{fileURLToPath as o}from"node:url";import s from"node:fs";import c from"node:process";import{Command as l}from"commander";import u from"ajv";const d=()=>o(import.meta.url),f=(()=>a.dirname(d()))(),p=o(import.meta.url),m=a.dirname(p);function h(){return new u({allErrors:!0,verbose:!0,strict:!1,discriminator:!0})}function g(){let e=a.join(m,`..`,`schema`,`scaffoldfy.schema.json`);try{let t=s.readFileSync(e,`utf-8`);return JSON.parse(t)}catch(t){throw Error(`Failed to load tasks schema from ${e}: ${t instanceof Error?t.message:String(t)}`)}}function _(e){return e.filter(t=>{if(t.keyword===`oneOf`){let e=t.params;if(e.passingSchemas&&e.passingSchemas.length>0)return!1}if(t.keyword===`required`){let n=e.find(e=>e.keyword===`oneOf`&&e.instancePath===t.instancePath);if(n){let e=n.params;if(e.passingSchemas&&e.passingSchemas.length>0)return!1}}return!0}).map(e=>{let t=e.instancePath||`root`,n=e.message??`Unknown error`;switch(e.keyword){case`required`:return`${t}: Missing required property "${String(e.params.missingProperty??`unknown`)}"`;case`type`:return`${t}: Expected type "${String(e.params.type??`unknown`)}", received "${typeof e.data}"`;case`enum`:{let r=e.params.allowedValues;return`${t}: ${n}. Allowed values: ${Array.isArray(r)?r.join(`, `):String(r)}`}case`pattern`:{let{pattern:r}=e.params;return`${t}: ${n}. Value must match pattern: ${String(r)}`}case`oneOf`:return`${t}: ${n}. Configuration must match exactly one of the allowed schemas`;case`additionalProperties`:return`${t}: ${n}. Unknown property: "${String(e.params.additionalProperty??`unknown`)}"`;default:return`${t}: ${n}`}})}function v(t,n={}){try{let e=h(),r=g(),i=e.compile(r);if(!i(t)&&i.errors){let e=_(i.errors);return e.length===0?{valid:!0,errors:[]}:(n.silent||y(e),{valid:!1,errors:e})}return{valid:!0,errors:[]}}catch(t){let r=t instanceof Error?t.message:`Unknown error occurred during schema validation`;return n.silent||(e(`❌ Schema validation error:`,`error`),e(` ${r}`,`error`)),{valid:!1,errors:[r]}}}function y(t){e(`❌ Schema validation failed:`,`error`),e(``,`error`),e(`The following validation errors were found:`,`error`),e(``,`error`);for(let n of t)e(` • ${n}`,`error`);e(``,`error`),e(`Please fix these errors in your template configuration file.`,`error`),e(``,`error`),e(`For schema documentation, see: https://github.com/pixpilot/scaffoldfy/tree/main/packages/scaffoldfy/schema`,`info`)}const b=new l,x=a.join(f,`..`,`package.json`);let S=`0.0.0`;try{S=JSON.parse(s.readFileSync(x,`utf-8`)).version??`0.0.0`}catch{}b.name(`scaffoldfy`).description(`Automate project setup and configuration with customizable tasks`).version(S),b.option(`--dry-run`,`Run in dry mode without making any changes`).option(`--force`,`Force execution even if checks fail`).option(`--config <path>`,`Path to task configuration file (JSON or TypeScript)`,`./template-tasks.json`).option(`--no-validate`,`Skip schema validation of task configuration (validation is enabled by default)`).option(`--debug`,`Enable debug logging for verbose output`).action(async o=>{o.debug===!0&&n(!0);try{let n=[],l,u,d,f,p;if(o.config!=null&&o.config!==``){let i=a.resolve(c.cwd(),o.config);if(s.existsSync(i))if(p=i,i.endsWith(`.ts`)||i.endsWith(`.mts`)){e(`Loading tasks from TypeScript file: ${o.config}`,`info`);try{let t=await import(i);n=t.default??t.tasks??[],(!Array.isArray(n)||n.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 config file: ${o.config}`,`error`),t instanceof Error&&e(` Error: ${t.message}`,`error`),c.exit(1)}}else try{if(o.validate!==!1){t(`Validating task configuration against schema...`);let n=s.readFileSync(i,`utf-8`);v(JSON.parse(n),{silent:!1}).valid||(e(``,`error`),e(`💡 You can skip validation with --no-validate flag, but this is not recommended.`,`info`),c.exit(1)),e(`Configuration validated`,`success`)}let a=await r(i,{sequential:!0});if(a.templates!=null&&a.templates.length>0){let{runTemplatesSequentially:e}=await import(`./run-tasks-DhVlAr4C.js`),{createInitialConfig:t}=await import(`./config-C8hh88Lc.js`);await e(a.templates,{dryRun:o.dryRun??!1,force:o.force??!1,tasksFilePath:i},t()),c.exit(0)}n=a.tasks,l=a.variables,u=a.prompts,d=a.enabled,f=a.transformers,Array.isArray(n)||(e(`❌ Invalid config file format`,`error`),e(`Expected JSON with { "tasks": [...] } structure`,`info`),c.exit(1))}catch(t){e(`Failed to load JSON config file: ${o.config}`,`error`),t instanceof Error&&e(` Error: ${t.message}`,`error`),c.exit(1)}else e(`Config file not found: ${o.config}`,`warn`)}let m=u!=null&&u.length>0||l!=null&&l.length>0;n.length===0&&!m&&(e(`❌ No tasks defined`,`error`),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 --config option to specify a different config file`,`info`),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)),c.exit(1)),n.length===0?e(`Loaded template with 0 tasks (template may only provide prompts/variables for extending)`,`info`):e(`Loaded ${n.length} task(s)`,`success`),await i(n,{dryRun:o.dryRun,force:o.force,tasksFilePath:p,variables:l,prompts:u,templateEnabled:d,transformers:f})}catch(t){if(e(`❌ CLI execution failed`,`error`),t instanceof Error){e(`Error: ${t.message}`,`error`);let n=c.env.DEBUG;n!=null&&n!==``&&console.error(t.stack)}else console.error(t);c.exit(1)}}),b.parse(c.argv);export{};
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- const e=require(`./utils-BeqQVvh1.cjs`);require(`./config-DlJs75hK.cjs`);const t=require(`./run-tasks-BPiZCUDh.cjs`),n=require(`./src-DJXRbf0z.cjs`);exports.callHook=t.h,exports.clearPlugins=t.g,exports.clearTemplateCache=t.G,exports.collectPrompts=t.p,exports.collectVariables=t.o,exports.createPlugin=t._,exports.displayTasksDiff=t.O,exports.evaluateCondition=e.t,exports.executePluginTask=t.v,exports.executeTask=t.c,exports.getCreateDiff=t.k,exports.getDeleteDiff=t.A,exports.getExecDiff=t.j,exports.getGitInitDiff=t.M,exports.getGitRepoInfo=e.n,exports.getPlugin=t.y,exports.getPluginForTaskType=t.b,exports.getPluginTaskDiff=t.x,exports.getRegexReplaceDiff=t.N,exports.getRenameDiff=t.P,exports.getReplaceInFileDiff=t.F,exports.getTaskDiff=t.I,exports.getTemplateSourceDescription=t.z,exports.getUpdateJsonDiff=t.L,exports.getWriteDiff=t.R,exports.hasInlineTemplate=t.B,exports.hasTemplateFile=t.V,exports.interpolateTemplate=e.r,exports.isPluginTaskType=t.S,exports.listPlugins=t.C,exports.loadAndMergeTemplate=t.K,exports.loadTasksWithInheritance=t.q,exports.loadTemplate=t.J,exports.loadTemplatesInOrder=t.Y,exports.log=e.i,exports.main=n.t,exports.mergeTemplates=t.X,exports.processTemplate=t.H,exports.prompt=e.a,exports.promptYesNo=e.o,exports.registerBuiltInPlugins=t.l,exports.registerHooks=t.w,exports.registerPlugin=t.T,exports.resolveAllDefaultValues=t.f,exports.resolveAllVariableValues=t.i,exports.resolveDefaultValue=t.m,exports.resolveVariableValue=t.a,exports.runTask=t.u,exports.runTasks=t.t,exports.runTemplatesSequentially=t.n,exports.runWithTasks=n.n,exports.setNestedProperty=e.s,exports.shouldUseHandlebars=t.U,exports.topologicalSort=t.s,exports.unregisterPlugin=t.E,exports.validatePluginTask=t.D,exports.validatePrompts=t.d,exports.validateTemplateConfig=t.W,exports.validateVariables=t.r;
1
+ require(`./config-DlJs75hK.cjs`);const e=require(`./utils-DjBGLPnu.cjs`),t=require(`./run-tasks-C6Bkzhq7.cjs`),n=require(`./src-CmBriDDR.cjs`);exports.callHook=t.h,exports.clearPlugins=t.g,exports.clearTemplateCache=t.G,exports.collectPrompts=t.p,exports.collectVariables=t.o,exports.createTaskPlugin=t._,exports.displayTasksDiff=t.O,exports.evaluateCondition=e.t,exports.executePluginTask=t.v,exports.executeTask=t.c,exports.getCreateDiff=t.k,exports.getDeleteDiff=t.A,exports.getExecDiff=t.j,exports.getGitInitDiff=t.M,exports.getGitRepoInfo=e.n,exports.getPlugin=t.y,exports.getPluginForTaskType=t.b,exports.getPluginTaskDiff=t.x,exports.getRegexReplaceDiff=t.N,exports.getRenameDiff=t.P,exports.getReplaceInFileDiff=t.F,exports.getTaskDiff=t.I,exports.getTemplateSourceDescription=t.z,exports.getUpdateJsonDiff=t.L,exports.getWriteDiff=t.R,exports.hasInlineTemplate=t.B,exports.hasTemplateFile=t.V,exports.interpolateTemplate=e.i,exports.isPluginTaskType=t.S,exports.listPlugins=t.C,exports.loadAndMergeTemplate=t.K,exports.loadTasksWithInheritance=t.q,exports.loadTemplate=t.J,exports.loadTemplatesInOrder=t.Y,exports.log=e.a,exports.main=n.t,exports.mergeTemplates=t.X,exports.processTemplate=t.H,exports.prompt=e.o,exports.promptYesNo=e.s,exports.registerBuiltInPlugins=t.l,exports.registerHooks=t.w,exports.registerPlugin=t.T,exports.resolveAllDefaultValues=t.f,exports.resolveAllVariableValues=t.i,exports.resolveDefaultValue=t.m,exports.resolveVariableValue=t.a,exports.runTask=t.u,exports.runTasks=t.t,exports.runTemplatesSequentially=t.n,exports.runWithTasks=n.n,exports.setNestedProperty=e.c,exports.shouldUseHandlebars=t.U,exports.topologicalSort=t.s,exports.unregisterPlugin=t.E,exports.validatePluginTask=t.D,exports.validatePrompts=t.d,exports.validateTemplateConfig=t.W,exports.validateVariables=t.r;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,71 @@
1
- //#region src/plugins/append/types.d.ts
1
+ //#region src/transformers/types.d.ts
2
+ /**
3
+ * Transformer types for value transformation
4
+ */
5
+ type BuiltInTransformerType = 'lowercase' | 'uppercase' | 'trim' | 'slugify' | 'capitalize' | 'titlecase' | 'camelcase' | 'pascalcase' | 'snakecase' | 'kebabcase' | 'constantcase' | 'alphanumeric' | 'collapse-spaces' | 'remove-spaces' | 'urlencode' | 'dasherize' | 'underscore';
6
+ /**
7
+ * Available transformer types
8
+ */
2
9
 
10
+ /**
11
+ * Base transformer interface
12
+ */
13
+ interface BaseTransformer {
14
+ id: string;
15
+ name?: string;
16
+ description?: string;
17
+ }
18
+ /**
19
+ * Regex transformer - applies regex pattern replacement
20
+ */
21
+ interface RegexTransformer extends BaseTransformer {
22
+ type: 'regex';
23
+ config: {
24
+ pattern: string;
25
+ flags?: string;
26
+ replacement: string;
27
+ };
28
+ }
29
+ /**
30
+ * Computed transformer - evaluates JavaScript expression
31
+ */
32
+ interface ComputedTransformer extends BaseTransformer {
33
+ type: 'computed';
34
+ config: {
35
+ expression: string;
36
+ };
37
+ }
38
+ /**
39
+ * Built-in transformers with standard behavior
40
+ */
41
+ interface BuiltInTransformer extends BaseTransformer {
42
+ type: BuiltInTransformerType;
43
+ config?: Record<string, unknown>;
44
+ }
45
+ /**
46
+ * Custom transformer with handler function
47
+ */
48
+ interface CustomTransformer extends BaseTransformer {
49
+ type: 'custom';
50
+ config: {
51
+ handler: string | ((value: unknown, context?: unknown) => unknown);
52
+ };
53
+ }
54
+ /**
55
+ * Chain transformer - executes multiple transformers in sequence
56
+ */
57
+ interface ChainTransformer extends BaseTransformer {
58
+ type: 'chain';
59
+ config: {
60
+ transformers: string[];
61
+ };
62
+ }
63
+ /**
64
+ * Union type of all transformer types
65
+ */
66
+ type Transformer = RegexTransformer | ComputedTransformer | BuiltInTransformer | CustomTransformer | ChainTransformer;
67
+ //#endregion
68
+ //#region src/plugins/append/types.d.ts
3
69
  interface AppendConfig {
4
70
  file: string;
5
71
  content?: string;
@@ -117,8 +183,9 @@ type PromptType = 'input' | 'select' | 'confirm' | 'password' | 'number';
117
183
  * - 'static': Static value provided directly
118
184
  * - 'exec': Execute a command to get the value dynamically
119
185
  * - 'conditional': Choose value based on a condition
186
+ * - 'interpolate': Reference string with {{variable}} placeholders that will be interpolated with previously resolved prompts/variables
120
187
  */
121
- type DefaultValueType = 'static' | 'exec' | 'conditional';
188
+ type DefaultValueType = 'static' | 'exec' | 'conditional' | 'interpolate';
122
189
  /**
123
190
  * Conditional default value configuration
124
191
  * Evaluates a condition and returns different values based on the result
@@ -126,8 +193,8 @@ type DefaultValueType = 'static' | 'exec' | 'conditional';
126
193
  interface ConditionalDefaultConfig<T = string | number | boolean> {
127
194
  type: 'conditional';
128
195
  condition: string;
129
- ifTrue: T | string;
130
- ifFalse: T | string;
196
+ ifTrue: T | DefaultValueConfig<T>;
197
+ ifFalse: T | DefaultValueConfig<T>;
131
198
  }
132
199
  /**
133
200
  * Default value configuration for prompts
@@ -142,6 +209,7 @@ interface DefaultValueConfig<T = string | number | boolean> {
142
209
  * - For executable defaults, use { type: 'exec', value: 'command' }
143
210
  * - For explicit static values, use { type: 'static', value: yourValue }
144
211
  * - For conditional defaults, use { type: 'conditional', condition: 'expression', ifTrue: value, ifFalse: value }
212
+ * - For interpolate strings, use { type: 'interpolate', value: '{{variable}}' } (will be interpolated with previously resolved prompts/variables)
145
213
  */
146
214
  type DefaultValue<T = string | number | boolean> = T | DefaultValueConfig<T> | ConditionalDefaultConfig<T>;
147
215
  /**
@@ -175,6 +243,7 @@ interface BasePrompt {
175
243
  enabled?: EnabledValue;
176
244
  override?: MergeStrategy;
177
245
  $templateEnabled?: EnabledValue;
246
+ transformers?: string[];
178
247
  }
179
248
  interface InputPrompt extends BasePrompt {
180
249
  type: 'input' | 'password';
@@ -211,6 +280,7 @@ interface VariableDefinition {
211
280
  value: DefaultValue;
212
281
  override?: MergeStrategy;
213
282
  $templateEnabled?: EnabledValue;
283
+ transformers?: string[];
214
284
  }
215
285
  /**
216
286
  * JavaScript expression evaluated at runtime to determine if a task or operation should execute.
@@ -254,6 +324,7 @@ interface TasksConfiguration {
254
324
  enabled?: EnabledValue;
255
325
  dependencies?: string[];
256
326
  extends?: string | string[];
327
+ transformers?: Transformer[];
257
328
  variables?: VariableDefinition[];
258
329
  prompts?: PromptDefinition[];
259
330
  tasks?: TaskDefinition[];
@@ -416,7 +487,7 @@ declare function getPluginTaskDiff(task: TaskDefinition, config: InitConfig): Pr
416
487
  */
417
488
  declare function validatePluginTask(task: TaskDefinition): string[];
418
489
  /**
419
- * Create a simple plugin
490
+ * Create a simple task plugin
420
491
  * @param name - Plugin name
421
492
  * @param taskType - Task type this plugin handles
422
493
  * @param execute - Execute function
@@ -426,7 +497,7 @@ declare function validatePluginTask(task: TaskDefinition): string[];
426
497
  * @param options.validate - Function to validate task configuration
427
498
  * @returns A TaskPlugin object
428
499
  */
429
- declare function createPlugin(name: string, taskType: string, execute: (task: TaskDefinition, config: InitConfig, options: {
500
+ declare function createTaskPlugin(name: string, taskType: string, execute: (task: TaskDefinition, config: InitConfig, options: {
430
501
  dryRun: boolean;
431
502
  }) => Promise<void>, options?: {
432
503
  version?: string;
@@ -449,9 +520,10 @@ declare function collectPrompts(prompts: PromptDefinition[], resolvedDefaults?:
449
520
  /**
450
521
  * Pre-resolve all executable default values in parallel
451
522
  * @param prompts - Array of prompt definitions
523
+ * @param context - Optional context for interpolating template variables
452
524
  * @returns Map of prompt IDs to their resolved default values
453
525
  */
454
- declare function resolveAllDefaultValues(prompts: PromptDefinition[]): Promise<Map<string, unknown>>;
526
+ declare function resolveAllDefaultValues(prompts: PromptDefinition[], context?: InitConfig): Promise<Map<string, unknown>>;
455
527
  //#endregion
456
528
  //#region src/prompts/resolve-default-value.d.ts
457
529
  /**
@@ -482,6 +554,7 @@ declare function runTasks(tasks: TaskDefinition[], options: {
482
554
  variables?: VariableDefinition[];
483
555
  prompts?: PromptDefinition[];
484
556
  templateEnabled?: EnabledValue;
557
+ transformers?: Transformer[];
485
558
  }): Promise<void>;
486
559
  /**
487
560
  * Run templates sequentially for variables/prompts, then all tasks together
@@ -564,6 +637,7 @@ declare function loadTasksWithInheritance(tasksFilePath: string, options?: {
564
637
  prompts?: PromptDefinition[];
565
638
  enabled?: EnabledValue;
566
639
  templates?: TasksConfiguration[];
640
+ transformers?: Transformer[];
567
641
  }>;
568
642
  //#endregion
569
643
  //#region src/template-utils.d.ts
@@ -684,9 +758,10 @@ declare function evaluateCondition(condition: string, config: InitConfig, option
684
758
  *
685
759
  * @param variables - Array of variable definitions
686
760
  * @param resolvedValues - Map of pre-resolved variable values
761
+ * @param context - Current configuration context (for transformer evaluation)
687
762
  * @returns Object mapping variable IDs to their values
688
763
  */
689
- declare function collectVariables(variables: VariableDefinition[], resolvedValues?: Map<string, unknown>): Record<string, unknown>;
764
+ declare function collectVariables(variables: VariableDefinition[], resolvedValues?: Map<string, unknown>, context?: InitConfig): Promise<Record<string, unknown>>;
690
765
  //#endregion
691
766
  //#region src/variables/resolve-all-variable-values.d.ts
692
767
  /**
@@ -736,6 +811,7 @@ declare function main(customTasks?: TaskDefinition[]): Promise<void>;
736
811
  * @param options.variables - Optional top-level global variables
737
812
  * @param options.prompts - Optional top-level global prompts
738
813
  * @param options.templateEnabled - Optional template-level enabled condition
814
+ * @param options.transformers - Optional transformer definitions
739
815
  */
740
816
  declare function runWithTasks(customTasks: TaskDefinition[], options?: {
741
817
  dryRun?: boolean | undefined;
@@ -744,6 +820,7 @@ declare function runWithTasks(customTasks: TaskDefinition[], options?: {
744
820
  variables?: VariableDefinition[] | undefined;
745
821
  prompts?: PromptDefinition[] | undefined;
746
822
  templateEnabled?: EnabledValue | undefined;
823
+ transformers?: Transformer[] | undefined;
747
824
  }): Promise<void>;
748
825
  //#endregion
749
- export { type AppendConfig, BasePrompt, ConditionExpression, ConditionalDefaultConfig, ConditionalEnabled, ConfirmPrompt, type CopyConfig, type CreateConfig, DefaultValue, DefaultValueConfig, DefaultValueType, type DeleteConfig, EnabledValue, type ExecConfig, ExecutableEnabled, type GitInitConfig, InitConfig, InputPrompt, MergeStrategy, type MkdirConfig, type MoveConfig, NumberPrompt, PluginHooks, PromptDefinition, PromptType, type RegexReplaceConfig, type RenameConfig, type ReplaceInFileConfig, RollbackConfig, SelectPrompt, TaskDefinition, TaskPlugin, TaskType, TasksConfiguration, type UpdateJsonConfig, VariableDefinition, type WriteConfig, callHook, clearPlugins, clearTemplateCache, collectPrompts, collectVariables, createPlugin, displayTasksDiff, evaluateCondition, executePluginTask, executeTask, getCreateDiff, getDeleteDiff, getExecDiff, getGitInitDiff, getGitRepoInfo, getPlugin, getPluginForTaskType, getPluginTaskDiff, getRegexReplaceDiff, getRenameDiff, getReplaceInFileDiff, getTaskDiff, getTemplateSourceDescription, getUpdateJsonDiff, getWriteDiff, hasInlineTemplate, hasTemplateFile, interpolateTemplate, isPluginTaskType, listPlugins, loadAndMergeTemplate, loadTasksWithInheritance, loadTemplate, loadTemplatesInOrder, log, main, mergeTemplates, processTemplate, prompt, promptYesNo, registerBuiltInPlugins, registerHooks, registerPlugin, resolveAllDefaultValues, resolveAllVariableValues, resolveDefaultValue, resolveVariableValue, runTask, runTasks, runTemplatesSequentially, runWithTasks, setNestedProperty, shouldUseHandlebars, topologicalSort, unregisterPlugin, validatePluginTask, validatePrompts, validateTemplateConfig, validateVariables };
826
+ export { type AppendConfig, BasePrompt, ConditionExpression, ConditionalDefaultConfig, ConditionalEnabled, ConfirmPrompt, type CopyConfig, type CreateConfig, DefaultValue, DefaultValueConfig, DefaultValueType, type DeleteConfig, EnabledValue, type ExecConfig, ExecutableEnabled, type GitInitConfig, InitConfig, InputPrompt, MergeStrategy, type MkdirConfig, type MoveConfig, NumberPrompt, PluginHooks, PromptDefinition, PromptType, type RegexReplaceConfig, type RenameConfig, type ReplaceInFileConfig, RollbackConfig, SelectPrompt, TaskDefinition, TaskPlugin, TaskType, TasksConfiguration, type UpdateJsonConfig, VariableDefinition, type WriteConfig, callHook, clearPlugins, clearTemplateCache, collectPrompts, collectVariables, createTaskPlugin, displayTasksDiff, evaluateCondition, executePluginTask, executeTask, getCreateDiff, getDeleteDiff, getExecDiff, getGitInitDiff, getGitRepoInfo, getPlugin, getPluginForTaskType, getPluginTaskDiff, getRegexReplaceDiff, getRenameDiff, getReplaceInFileDiff, getTaskDiff, getTemplateSourceDescription, getUpdateJsonDiff, getWriteDiff, hasInlineTemplate, hasTemplateFile, interpolateTemplate, isPluginTaskType, listPlugins, loadAndMergeTemplate, loadTasksWithInheritance, loadTemplate, loadTemplatesInOrder, log, main, mergeTemplates, processTemplate, prompt, promptYesNo, registerBuiltInPlugins, registerHooks, registerPlugin, resolveAllDefaultValues, resolveAllVariableValues, resolveDefaultValue, resolveVariableValue, runTask, runTasks, runTemplatesSequentially, runWithTasks, setNestedProperty, shouldUseHandlebars, topologicalSort, unregisterPlugin, validatePluginTask, validatePrompts, validateTemplateConfig, validateVariables };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,71 @@
1
- //#region src/plugins/append/types.d.ts
1
+ //#region src/transformers/types.d.ts
2
+ /**
3
+ * Transformer types for value transformation
4
+ */
5
+ type BuiltInTransformerType = 'lowercase' | 'uppercase' | 'trim' | 'slugify' | 'capitalize' | 'titlecase' | 'camelcase' | 'pascalcase' | 'snakecase' | 'kebabcase' | 'constantcase' | 'alphanumeric' | 'collapse-spaces' | 'remove-spaces' | 'urlencode' | 'dasherize' | 'underscore';
6
+ /**
7
+ * Available transformer types
8
+ */
2
9
 
10
+ /**
11
+ * Base transformer interface
12
+ */
13
+ interface BaseTransformer {
14
+ id: string;
15
+ name?: string;
16
+ description?: string;
17
+ }
18
+ /**
19
+ * Regex transformer - applies regex pattern replacement
20
+ */
21
+ interface RegexTransformer extends BaseTransformer {
22
+ type: 'regex';
23
+ config: {
24
+ pattern: string;
25
+ flags?: string;
26
+ replacement: string;
27
+ };
28
+ }
29
+ /**
30
+ * Computed transformer - evaluates JavaScript expression
31
+ */
32
+ interface ComputedTransformer extends BaseTransformer {
33
+ type: 'computed';
34
+ config: {
35
+ expression: string;
36
+ };
37
+ }
38
+ /**
39
+ * Built-in transformers with standard behavior
40
+ */
41
+ interface BuiltInTransformer extends BaseTransformer {
42
+ type: BuiltInTransformerType;
43
+ config?: Record<string, unknown>;
44
+ }
45
+ /**
46
+ * Custom transformer with handler function
47
+ */
48
+ interface CustomTransformer extends BaseTransformer {
49
+ type: 'custom';
50
+ config: {
51
+ handler: string | ((value: unknown, context?: unknown) => unknown);
52
+ };
53
+ }
54
+ /**
55
+ * Chain transformer - executes multiple transformers in sequence
56
+ */
57
+ interface ChainTransformer extends BaseTransformer {
58
+ type: 'chain';
59
+ config: {
60
+ transformers: string[];
61
+ };
62
+ }
63
+ /**
64
+ * Union type of all transformer types
65
+ */
66
+ type Transformer = RegexTransformer | ComputedTransformer | BuiltInTransformer | CustomTransformer | ChainTransformer;
67
+ //#endregion
68
+ //#region src/plugins/append/types.d.ts
3
69
  interface AppendConfig {
4
70
  file: string;
5
71
  content?: string;
@@ -117,8 +183,9 @@ type PromptType = 'input' | 'select' | 'confirm' | 'password' | 'number';
117
183
  * - 'static': Static value provided directly
118
184
  * - 'exec': Execute a command to get the value dynamically
119
185
  * - 'conditional': Choose value based on a condition
186
+ * - 'interpolate': Reference string with {{variable}} placeholders that will be interpolated with previously resolved prompts/variables
120
187
  */
121
- type DefaultValueType = 'static' | 'exec' | 'conditional';
188
+ type DefaultValueType = 'static' | 'exec' | 'conditional' | 'interpolate';
122
189
  /**
123
190
  * Conditional default value configuration
124
191
  * Evaluates a condition and returns different values based on the result
@@ -126,8 +193,8 @@ type DefaultValueType = 'static' | 'exec' | 'conditional';
126
193
  interface ConditionalDefaultConfig<T = string | number | boolean> {
127
194
  type: 'conditional';
128
195
  condition: string;
129
- ifTrue: T | string;
130
- ifFalse: T | string;
196
+ ifTrue: T | DefaultValueConfig<T>;
197
+ ifFalse: T | DefaultValueConfig<T>;
131
198
  }
132
199
  /**
133
200
  * Default value configuration for prompts
@@ -142,6 +209,7 @@ interface DefaultValueConfig<T = string | number | boolean> {
142
209
  * - For executable defaults, use { type: 'exec', value: 'command' }
143
210
  * - For explicit static values, use { type: 'static', value: yourValue }
144
211
  * - For conditional defaults, use { type: 'conditional', condition: 'expression', ifTrue: value, ifFalse: value }
212
+ * - For interpolate strings, use { type: 'interpolate', value: '{{variable}}' } (will be interpolated with previously resolved prompts/variables)
145
213
  */
146
214
  type DefaultValue<T = string | number | boolean> = T | DefaultValueConfig<T> | ConditionalDefaultConfig<T>;
147
215
  /**
@@ -175,6 +243,7 @@ interface BasePrompt {
175
243
  enabled?: EnabledValue;
176
244
  override?: MergeStrategy;
177
245
  $templateEnabled?: EnabledValue;
246
+ transformers?: string[];
178
247
  }
179
248
  interface InputPrompt extends BasePrompt {
180
249
  type: 'input' | 'password';
@@ -211,6 +280,7 @@ interface VariableDefinition {
211
280
  value: DefaultValue;
212
281
  override?: MergeStrategy;
213
282
  $templateEnabled?: EnabledValue;
283
+ transformers?: string[];
214
284
  }
215
285
  /**
216
286
  * JavaScript expression evaluated at runtime to determine if a task or operation should execute.
@@ -254,6 +324,7 @@ interface TasksConfiguration {
254
324
  enabled?: EnabledValue;
255
325
  dependencies?: string[];
256
326
  extends?: string | string[];
327
+ transformers?: Transformer[];
257
328
  variables?: VariableDefinition[];
258
329
  prompts?: PromptDefinition[];
259
330
  tasks?: TaskDefinition[];
@@ -416,7 +487,7 @@ declare function getPluginTaskDiff(task: TaskDefinition, config: InitConfig): Pr
416
487
  */
417
488
  declare function validatePluginTask(task: TaskDefinition): string[];
418
489
  /**
419
- * Create a simple plugin
490
+ * Create a simple task plugin
420
491
  * @param name - Plugin name
421
492
  * @param taskType - Task type this plugin handles
422
493
  * @param execute - Execute function
@@ -426,7 +497,7 @@ declare function validatePluginTask(task: TaskDefinition): string[];
426
497
  * @param options.validate - Function to validate task configuration
427
498
  * @returns A TaskPlugin object
428
499
  */
429
- declare function createPlugin(name: string, taskType: string, execute: (task: TaskDefinition, config: InitConfig, options: {
500
+ declare function createTaskPlugin(name: string, taskType: string, execute: (task: TaskDefinition, config: InitConfig, options: {
430
501
  dryRun: boolean;
431
502
  }) => Promise<void>, options?: {
432
503
  version?: string;
@@ -449,9 +520,10 @@ declare function collectPrompts(prompts: PromptDefinition[], resolvedDefaults?:
449
520
  /**
450
521
  * Pre-resolve all executable default values in parallel
451
522
  * @param prompts - Array of prompt definitions
523
+ * @param context - Optional context for interpolating template variables
452
524
  * @returns Map of prompt IDs to their resolved default values
453
525
  */
454
- declare function resolveAllDefaultValues(prompts: PromptDefinition[]): Promise<Map<string, unknown>>;
526
+ declare function resolveAllDefaultValues(prompts: PromptDefinition[], context?: InitConfig): Promise<Map<string, unknown>>;
455
527
  //#endregion
456
528
  //#region src/prompts/resolve-default-value.d.ts
457
529
  /**
@@ -482,6 +554,7 @@ declare function runTasks(tasks: TaskDefinition[], options: {
482
554
  variables?: VariableDefinition[];
483
555
  prompts?: PromptDefinition[];
484
556
  templateEnabled?: EnabledValue;
557
+ transformers?: Transformer[];
485
558
  }): Promise<void>;
486
559
  /**
487
560
  * Run templates sequentially for variables/prompts, then all tasks together
@@ -564,6 +637,7 @@ declare function loadTasksWithInheritance(tasksFilePath: string, options?: {
564
637
  prompts?: PromptDefinition[];
565
638
  enabled?: EnabledValue;
566
639
  templates?: TasksConfiguration[];
640
+ transformers?: Transformer[];
567
641
  }>;
568
642
  //#endregion
569
643
  //#region src/template-utils.d.ts
@@ -684,9 +758,10 @@ declare function evaluateCondition(condition: string, config: InitConfig, option
684
758
  *
685
759
  * @param variables - Array of variable definitions
686
760
  * @param resolvedValues - Map of pre-resolved variable values
761
+ * @param context - Current configuration context (for transformer evaluation)
687
762
  * @returns Object mapping variable IDs to their values
688
763
  */
689
- declare function collectVariables(variables: VariableDefinition[], resolvedValues?: Map<string, unknown>): Record<string, unknown>;
764
+ declare function collectVariables(variables: VariableDefinition[], resolvedValues?: Map<string, unknown>, context?: InitConfig): Promise<Record<string, unknown>>;
690
765
  //#endregion
691
766
  //#region src/variables/resolve-all-variable-values.d.ts
692
767
  /**
@@ -736,6 +811,7 @@ declare function main(customTasks?: TaskDefinition[]): Promise<void>;
736
811
  * @param options.variables - Optional top-level global variables
737
812
  * @param options.prompts - Optional top-level global prompts
738
813
  * @param options.templateEnabled - Optional template-level enabled condition
814
+ * @param options.transformers - Optional transformer definitions
739
815
  */
740
816
  declare function runWithTasks(customTasks: TaskDefinition[], options?: {
741
817
  dryRun?: boolean | undefined;
@@ -744,6 +820,7 @@ declare function runWithTasks(customTasks: TaskDefinition[], options?: {
744
820
  variables?: VariableDefinition[] | undefined;
745
821
  prompts?: PromptDefinition[] | undefined;
746
822
  templateEnabled?: EnabledValue | undefined;
823
+ transformers?: Transformer[] | undefined;
747
824
  }): Promise<void>;
748
825
  //#endregion
749
- export { type AppendConfig, BasePrompt, ConditionExpression, ConditionalDefaultConfig, ConditionalEnabled, ConfirmPrompt, type CopyConfig, type CreateConfig, DefaultValue, DefaultValueConfig, DefaultValueType, type DeleteConfig, EnabledValue, type ExecConfig, ExecutableEnabled, type GitInitConfig, InitConfig, InputPrompt, MergeStrategy, type MkdirConfig, type MoveConfig, NumberPrompt, PluginHooks, PromptDefinition, PromptType, type RegexReplaceConfig, type RenameConfig, type ReplaceInFileConfig, RollbackConfig, SelectPrompt, TaskDefinition, TaskPlugin, TaskType, TasksConfiguration, type UpdateJsonConfig, VariableDefinition, type WriteConfig, callHook, clearPlugins, clearTemplateCache, collectPrompts, collectVariables, createPlugin, displayTasksDiff, evaluateCondition, executePluginTask, executeTask, getCreateDiff, getDeleteDiff, getExecDiff, getGitInitDiff, getGitRepoInfo, getPlugin, getPluginForTaskType, getPluginTaskDiff, getRegexReplaceDiff, getRenameDiff, getReplaceInFileDiff, getTaskDiff, getTemplateSourceDescription, getUpdateJsonDiff, getWriteDiff, hasInlineTemplate, hasTemplateFile, interpolateTemplate, isPluginTaskType, listPlugins, loadAndMergeTemplate, loadTasksWithInheritance, loadTemplate, loadTemplatesInOrder, log, main, mergeTemplates, processTemplate, prompt, promptYesNo, registerBuiltInPlugins, registerHooks, registerPlugin, resolveAllDefaultValues, resolveAllVariableValues, resolveDefaultValue, resolveVariableValue, runTask, runTasks, runTemplatesSequentially, runWithTasks, setNestedProperty, shouldUseHandlebars, topologicalSort, unregisterPlugin, validatePluginTask, validatePrompts, validateTemplateConfig, validateVariables };
826
+ export { type AppendConfig, BasePrompt, ConditionExpression, ConditionalDefaultConfig, ConditionalEnabled, ConfirmPrompt, type CopyConfig, type CreateConfig, DefaultValue, DefaultValueConfig, DefaultValueType, type DeleteConfig, EnabledValue, type ExecConfig, ExecutableEnabled, type GitInitConfig, InitConfig, InputPrompt, MergeStrategy, type MkdirConfig, type MoveConfig, NumberPrompt, PluginHooks, PromptDefinition, PromptType, type RegexReplaceConfig, type RenameConfig, type ReplaceInFileConfig, RollbackConfig, SelectPrompt, TaskDefinition, TaskPlugin, TaskType, TasksConfiguration, type UpdateJsonConfig, VariableDefinition, type WriteConfig, callHook, clearPlugins, clearTemplateCache, collectPrompts, collectVariables, createTaskPlugin, displayTasksDiff, evaluateCondition, executePluginTask, executeTask, getCreateDiff, getDeleteDiff, getExecDiff, getGitInitDiff, getGitRepoInfo, getPlugin, getPluginForTaskType, getPluginTaskDiff, getRegexReplaceDiff, getRenameDiff, getReplaceInFileDiff, getTaskDiff, getTemplateSourceDescription, getUpdateJsonDiff, getWriteDiff, hasInlineTemplate, hasTemplateFile, interpolateTemplate, isPluginTaskType, listPlugins, loadAndMergeTemplate, loadTasksWithInheritance, loadTemplate, loadTemplatesInOrder, log, main, mergeTemplates, processTemplate, prompt, promptYesNo, registerBuiltInPlugins, registerHooks, registerPlugin, resolveAllDefaultValues, resolveAllVariableValues, resolveDefaultValue, resolveVariableValue, runTask, runTasks, runTemplatesSequentially, runWithTasks, setNestedProperty, shouldUseHandlebars, topologicalSort, unregisterPlugin, validatePluginTask, validatePrompts, validateTemplateConfig, validateVariables };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import"./config-DfRbCqsT.js";import{a as e,i as t,n,o as r,r as i,s as a,t as o}from"./utils-C3bHtTZl.js";import{A as s,B as c,C as l,D as u,E as d,F as f,G as p,H as m,I as h,J as g,K as _,L as v,M as y,N as b,O as x,P as S,R as C,S as w,T,U as E,V as D,W as O,X as k,Y as A,_ as j,a as M,b as N,c as P,d as F,f as I,g as L,h as R,i as z,j as B,k as V,l as H,m as U,n as W,o as G,p as K,q,r as J,s as Y,t as X,u as Z,v as Q,w as $,x as ee,y as te,z as ne}from"./run-tasks-CzHOfpfu.js";import{n as re,t as ie}from"./src-DcsCaCmY.js";export{R as callHook,L as clearPlugins,p as clearTemplateCache,K as collectPrompts,G as collectVariables,j as createPlugin,x as displayTasksDiff,o as evaluateCondition,Q as executePluginTask,P as executeTask,V as getCreateDiff,s as getDeleteDiff,B as getExecDiff,y as getGitInitDiff,n as getGitRepoInfo,te as getPlugin,N as getPluginForTaskType,ee as getPluginTaskDiff,b as getRegexReplaceDiff,S as getRenameDiff,f as getReplaceInFileDiff,h as getTaskDiff,ne as getTemplateSourceDescription,v as getUpdateJsonDiff,C as getWriteDiff,c as hasInlineTemplate,D as hasTemplateFile,i as interpolateTemplate,w as isPluginTaskType,l as listPlugins,_ as loadAndMergeTemplate,q as loadTasksWithInheritance,g as loadTemplate,A as loadTemplatesInOrder,t as log,ie as main,k as mergeTemplates,m as processTemplate,e as prompt,r as promptYesNo,H as registerBuiltInPlugins,$ as registerHooks,T as registerPlugin,I as resolveAllDefaultValues,z as resolveAllVariableValues,U as resolveDefaultValue,M as resolveVariableValue,Z as runTask,X as runTasks,W as runTemplatesSequentially,re as runWithTasks,a as setNestedProperty,E as shouldUseHandlebars,Y as topologicalSort,d as unregisterPlugin,u as validatePluginTask,F as validatePrompts,O as validateTemplateConfig,J as validateVariables};
1
+ import"./config-DfRbCqsT.js";import{a as e,c as t,i as n,n as r,o as i,s as a,t as o}from"./utils-CmYva5oB.js";import{A as s,B as c,C as l,D as u,E as d,F as f,G as p,H as m,I as h,J as g,K as _,L as v,M as y,N as b,O as x,P as S,R as C,S as w,T,U as E,V as D,W as O,X as k,Y as A,_ as j,a as M,b as N,c as P,d as F,f as I,g as L,h as R,i as z,j as B,k as V,l as H,m as U,n as W,o as G,p as K,q,r as J,s as Y,t as X,u as Z,v as Q,w as $,x as ee,y as te,z as ne}from"./run-tasks-D5KLV8Tk.js";import{n as re,t as ie}from"./src-DbtBS6he.js";export{R as callHook,L as clearPlugins,p as clearTemplateCache,K as collectPrompts,G as collectVariables,j as createTaskPlugin,x as displayTasksDiff,o as evaluateCondition,Q as executePluginTask,P as executeTask,V as getCreateDiff,s as getDeleteDiff,B as getExecDiff,y as getGitInitDiff,r as getGitRepoInfo,te as getPlugin,N as getPluginForTaskType,ee as getPluginTaskDiff,b as getRegexReplaceDiff,S as getRenameDiff,f as getReplaceInFileDiff,h as getTaskDiff,ne as getTemplateSourceDescription,v as getUpdateJsonDiff,C as getWriteDiff,c as hasInlineTemplate,D as hasTemplateFile,n as interpolateTemplate,w as isPluginTaskType,l as listPlugins,_ as loadAndMergeTemplate,q as loadTasksWithInheritance,g as loadTemplate,A as loadTemplatesInOrder,e as log,ie as main,k as mergeTemplates,m as processTemplate,i as prompt,a as promptYesNo,H as registerBuiltInPlugins,$ as registerHooks,T as registerPlugin,I as resolveAllDefaultValues,z as resolveAllVariableValues,U as resolveDefaultValue,M as resolveVariableValue,Z as runTask,X as runTasks,W as runTemplatesSequentially,re as runWithTasks,t as setNestedProperty,E as shouldUseHandlebars,Y as topologicalSort,d as unregisterPlugin,u as validatePluginTask,F as validatePrompts,O as validateTemplateConfig,J as validateVariables};
@@ -0,0 +1 @@
1
+ require(`./config-DlJs75hK.cjs`),require(`./utils-DjBGLPnu.cjs`);const e=require(`./run-tasks-C6Bkzhq7.cjs`);exports.runTasks=e.t,exports.runTemplatesSequentially=e.n;