@pixpilot/scaffoldfy 0.37.0 → 0.38.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/dist/index.d.cts CHANGED
@@ -267,7 +267,7 @@ interface BasePrompt {
267
267
  required?: DynamicBooleanValue;
268
268
  enabled?: DynamicBooleanValue;
269
269
  override?: MergeStrategy;
270
- $templateEnabled?: DynamicBooleanValue;
270
+ $configEnabled?: DynamicBooleanValue;
271
271
  $sourceUrl?: string;
272
272
  transformers?: string[];
273
273
  }
@@ -307,7 +307,7 @@ interface VariableDefinition {
307
307
  enabled?: DynamicBooleanValue;
308
308
  required?: DynamicBooleanValue;
309
309
  override?: MergeStrategy;
310
- $templateEnabled?: DynamicBooleanValue;
310
+ $configEnabled?: DynamicBooleanValue;
311
311
  $sourceUrl?: string;
312
312
  transformers?: string[];
313
313
  }
@@ -342,7 +342,7 @@ interface TaskDefinition {
342
342
  rollback?: RollbackConfig;
343
343
  override?: MergeStrategy;
344
344
  $sourceUrl?: string;
345
- $templateEnabled?: DynamicBooleanValue;
345
+ $configEnabled?: DynamicBooleanValue;
346
346
  }
347
347
  /**
348
348
  * Configuration file structure for template tasks
@@ -382,19 +382,56 @@ interface PluginHooks {
382
382
  onError?: (error: Error, task?: TaskDefinition) => Promise<void>;
383
383
  }
384
384
  //#endregion
385
- //#region src/dry-run.d.ts
385
+ //#region src/config-inheritance.d.ts
386
386
  /**
387
- * Get diff for update-json task
387
+ * Load a configuration file from local path or remote URL
388
+ * @param configPath - Path or URL to the configuration file
389
+ * @param visitedPaths - Set of already visited paths to detect circular dependencies
390
+ * @returns The loaded configuration
388
391
  */
389
- declare function getUpdateJsonDiff(config: UpdateJsonConfig, initConfig: InitConfig): Promise<string>;
392
+ declare function loadConfiguration(configPath: string, visitedPaths?: Set<string>): Promise<TasksConfiguration>;
390
393
  /**
391
- * Get diff for write task
394
+ * Recursively load and merge configurations
395
+ * @param configPath - Path or URL to the configuration file
396
+ * @param baseDir - Base directory or URL for resolving relative paths in extends
397
+ * @param visitedPaths - Set of already visited paths
398
+ * @returns Merged configuration
399
+ */
400
+ declare function loadAndMergeConfiguration(configPath: string, baseDir?: string, visitedPaths?: Set<string>): Promise<TasksConfiguration>;
401
+ /**
402
+ * Merge multiple configurations
403
+ * Later configurations override earlier ones for conflicting task IDs
404
+ * @param configurations - Array of configurations to merge (in priority order)
405
+ * @returns Merged configuration
392
406
  */
393
- declare function getWriteDiff(config: WriteConfig, initConfig: InitConfig): Promise<string>;
407
+ declare function mergeConfigurations(configurations: TasksConfiguration[]): TasksConfiguration;
394
408
  /**
395
- * Get diff for create task
409
+ * Clear the configuration cache (useful for testing)
396
410
  */
397
- declare function getCreateDiff(config: CreateConfig, initConfig: InitConfig, task?: TaskDefinition): Promise<string>;
411
+ declare function clearConfigurationCache(): void;
412
+ /**
413
+ * Load tasks from a configuration file with configuration inheritance support
414
+ * @param tasksFilePath - Path to the tasks configuration file
415
+ * @param options - Optional configuration
416
+ * @param options.sequential - If true, return configurations as separate items for sequential processing
417
+ * @returns Task configuration with tasks, optional variables, and optional prompts
418
+ */
419
+ declare function loadTasksWithInheritance(tasksFilePath: string, options?: {
420
+ sequential?: boolean;
421
+ }): Promise<{
422
+ tasks: TaskDefinition[];
423
+ variables?: VariableDefinition[];
424
+ prompts?: PromptDefinition[];
425
+ enabled?: EnabledValue;
426
+ templates?: TasksConfiguration[];
427
+ transformers?: Transformer[];
428
+ }>;
429
+ //#endregion
430
+ //#region src/dry-run.d.ts
431
+ /**
432
+ * Get diff for update-json task
433
+ */
434
+ declare function getUpdateJsonDiff(config: UpdateJsonConfig, initConfig: InitConfig): Promise<string>;
398
435
  /**
399
436
  * Get diff for regex-replace task
400
437
  */
@@ -471,26 +508,6 @@ declare function clearPlugins(): void;
471
508
  * @param hooks - Hook functions to register
472
509
  */
473
510
  declare function registerHooks(hooks: Partial<PluginHooks>): void;
474
- /**
475
- * Call a lifecycle hook
476
- * @param hookName - Name of the hook
477
- * @param config - Initialization config for beforeAll/afterAll
478
- */
479
- declare function callHook(hookName: 'beforeAll' | 'afterAll', config: InitConfig): Promise<void>;
480
- /**
481
- * Call a lifecycle hook
482
- * @param hookName - Name of the hook
483
- * @param task - Task definition for beforeTask/afterTask
484
- * @param config - Initialization config
485
- */
486
- declare function callHook(hookName: 'beforeTask' | 'afterTask', task: TaskDefinition, config: InitConfig): Promise<void>;
487
- /**
488
- * Call a lifecycle hook
489
- * @param hookName - Name of the hook
490
- * @param error - Error that occurred
491
- * @param task - Optional task definition
492
- */
493
- declare function callHook(hookName: 'onError', error: Error, task?: TaskDefinition): Promise<void>;
494
511
  /**
495
512
  * Execute a plugin task
496
513
  * @param task - The task to execute
@@ -502,19 +519,6 @@ declare function callHook(hookName: 'onError', error: Error, task?: TaskDefiniti
502
519
  declare function executePluginTask(task: TaskDefinition, config: InitConfig, options: {
503
520
  dryRun: boolean;
504
521
  }): Promise<void>;
505
- /**
506
- * Get diff for a plugin task
507
- * @param task - The task to generate diff for
508
- * @param config - The initialization config
509
- * @returns Diff string or undefined if not supported
510
- */
511
- declare function getPluginTaskDiff(task: TaskDefinition, config: InitConfig): Promise<string | undefined>;
512
- /**
513
- * Validate a plugin task
514
- * @param task - The task to validate
515
- * @returns Array of validation errors
516
- */
517
- declare function validatePluginTask(task: TaskDefinition): string[];
518
522
  /**
519
523
  * Create a simple task plugin
520
524
  * @param name - Plugin name
@@ -534,280 +538,27 @@ declare function createTaskPlugin(name: string, taskType: string, execute: (task
534
538
  validate?: (task: TaskDefinition) => string[];
535
539
  }): TaskPlugin;
536
540
  //#endregion
537
- //#region src/prompts/collect-prompts.d.ts
538
- /**
539
- * Collect prompt answers from task-defined prompts
540
- * Only prompts with enabled=true (or enabled condition that evaluates to true) will be shown
541
- * @param prompts - Array of prompt definitions from tasks
542
- * @param resolvedDefaults - Map of pre-resolved default values
543
- * @param config - Current configuration context (for evaluating enabled conditions)
544
- * @returns Object mapping prompt IDs to their values
545
- */
546
- declare function collectPrompts(prompts: PromptDefinition[], resolvedDefaults?: Map<string, unknown>, config?: InitConfig): Promise<Record<string, unknown>>;
547
- //#endregion
548
- //#region src/prompts/resolve-all-default-values.d.ts
549
- /**
550
- * Pre-resolve all executable default values in parallel
551
- * @param prompts - Array of prompt definitions
552
- * @param context - Optional context for interpolating template variables
553
- * @returns Map of prompt IDs to their resolved default values
554
- */
555
- declare function resolveAllDefaultValues(prompts: PromptDefinition[], context?: InitConfig): Promise<Map<string, unknown>>;
556
- //#endregion
557
- //#region src/prompts/resolve-default-value.d.ts
558
- /**
559
- * Resolve a default value that may be static or executable
560
- * @param defaultValue - The default value configuration
561
- * @param promptId - The prompt ID for error reporting
562
- * @param context - Optional context for interpolating template variables in string defaults
563
- * @param prompt - Optional prompt definition for accessing $sourceUrl
564
- * @returns The resolved default value
565
- */
566
- declare function resolveDefaultValue<T = string | number | boolean>(defaultValue: DefaultValue<T> | undefined, promptId: string, context?: InitConfig, prompt?: PromptDefinition): Promise<T | undefined>;
567
- //#endregion
568
- //#region src/prompts/validate-prompts.d.ts
569
- /**
570
- * Validate prompt definitions
571
- * @param prompts - Array of prompt definitions to validate
572
- * @returns Array of validation error messages
573
- */
574
- declare function validatePrompts(prompts: PromptDefinition[]): string[];
575
- //#endregion
576
- //#region src/run-tasks.d.ts
577
- /**
578
- * Core task execution logic shared by both main() and runWithTasks()
579
- */
580
- declare function runTasks(tasks: TaskDefinition[], options: {
581
- dryRun: boolean;
582
- force: boolean;
583
- tasksFilePath: string | undefined;
584
- variables?: VariableDefinition[];
585
- prompts?: PromptDefinition[];
586
- templateEnabled?: EnabledValue;
587
- transformers?: Transformer[];
588
- }): Promise<void>;
589
- /**
590
- * Run templates sequentially for variables/prompts, then all tasks together
591
- * Phase 1: Process variables and prompts sequentially from each template
592
- * Phase 2: Collect all tasks from all enabled templates
593
- * Phase 3: Execute all tasks together at the end
594
- * This allows later templates to use values from earlier templates in their conditions,
595
- * while still executing all tasks together after all variables/prompts are resolved
596
- */
597
- declare function runTemplatesSequentially(templates: TasksConfiguration[], options: {
598
- dryRun: boolean;
599
- force: boolean;
600
- tasksFilePath: string | undefined;
601
- }, config?: InitConfig): Promise<void>;
602
- //#endregion
603
- //#region src/task-executors.d.ts
604
- declare function registerBuiltInPlugins(): void;
605
- /**
606
- * Execute a task based on its type
607
- */
608
- declare function executeTask(task: TaskDefinition, config: InitConfig, dryRun?: boolean): Promise<void>;
609
- /**
610
- * Run a single task with error handling
611
- */
612
- declare function runTask(task: TaskDefinition, config: InitConfig, taskNumber: number, totalTasks: number, dryRun?: boolean): Promise<boolean>;
613
- //#endregion
614
- //#region src/task-resolver.d.ts
615
- /**
616
- * Sort tasks by dependencies using topological sort
617
- */
618
- declare function topologicalSort(tasks: TaskDefinition[]): TaskDefinition[];
619
- //#endregion
620
- //#region src/template-inheritance.d.ts
621
- /**
622
- * Load a template configuration file from local path or remote URL
623
- * @param templatePath - Path or URL to the template file
624
- * @param visitedPaths - Set of already visited paths to detect circular dependencies
625
- * @returns The loaded template configuration
626
- */
627
- declare function loadTemplate(templatePath: string, visitedPaths?: Set<string>): Promise<TasksConfiguration>;
628
- /**
629
- * Load all templates in dependency order without merging
630
- * @param templatePath - Path or URL to the template file
631
- * @param baseDir - Base directory or URL for resolving relative paths in extends
632
- * @param visitedPaths - Set of already visited paths
633
- * @returns Array of sorted templates (in dependency order, ready for sequential processing)
634
- */
635
- declare function loadTemplatesInOrder(templatePath: string, baseDir?: string, visitedPaths?: Set<string>): Promise<TasksConfiguration[]>;
636
- /**
637
- * Recursively load and merge templates
638
- * @param templatePath - Path or URL to the template file
639
- * @param baseDir - Base directory or URL for resolving relative paths in extends
640
- * @param visitedPaths - Set of already visited paths
641
- * @returns Merged template configuration
642
- */
643
- declare function loadAndMergeTemplate(templatePath: string, baseDir?: string, visitedPaths?: Set<string>): Promise<TasksConfiguration>;
644
- /**
645
- * Merge multiple template configurations
646
- * Later templates override earlier ones for conflicting task IDs
647
- * @param templates - Array of templates to merge (in priority order)
648
- * @returns Merged template configuration
649
- */
650
- declare function mergeTemplates(templates: TasksConfiguration[]): TasksConfiguration;
651
- /**
652
- * Clear the template cache (useful for testing)
653
- */
654
- declare function clearTemplateCache(): void;
655
- /**
656
- * Load tasks from a configuration file with template inheritance support
657
- * @param tasksFilePath - Path to the tasks configuration file
658
- * @param options - Optional configuration
659
- * @param options.sequential - If true, return templates as separate items for sequential processing
660
- * @returns Task configuration with tasks, optional variables, and optional prompts
661
- */
662
- declare function loadTasksWithInheritance(tasksFilePath: string, options?: {
663
- sequential?: boolean;
664
- }): Promise<{
665
- tasks: TaskDefinition[];
666
- variables?: VariableDefinition[];
667
- prompts?: PromptDefinition[];
668
- enabled?: EnabledValue;
669
- templates?: TasksConfiguration[];
670
- transformers?: Transformer[];
671
- }>;
672
- //#endregion
673
- //#region src/template-utils.d.ts
674
- /**
675
- * Configuration for template/templateFile properties
676
- */
677
- interface TemplateSource {
678
- template?: string;
679
- templateFile?: string;
680
- }
681
- /**
682
- * Result of template validation
683
- */
684
- interface TemplateValidationResult {
685
- isValid: boolean;
686
- hasInlineTemplate: boolean;
687
- hasTemplateFile: boolean;
688
- error?: string;
689
- }
690
- /**
691
- * Options for processing templates
692
- */
693
- interface ProcessTemplateOptions {
694
- /** Enable Handlebars compilation for .hbs files */
695
- enableHandlebars?: boolean;
696
- /** Source URL for resolving relative template paths */
697
- sourceUrl?: string;
698
- }
699
- /**
700
- * Check if a config has an inline template
701
- * @param config - Configuration object with potential template property
702
- * @returns True if inline template is present and non-empty
703
- */
704
- declare function hasInlineTemplate(config: TemplateSource): boolean;
705
- /**
706
- * Check if a config has a template file reference
707
- * @param config - Configuration object with potential templateFile property
708
- * @returns True if templateFile is present and non-empty
709
- */
710
- declare function hasTemplateFile(config: TemplateSource): boolean;
711
- /**
712
- * Check if a template file should be processed with Handlebars
713
- * @param templateFile - Path to the template file
714
- * @returns True if the file has .hbs extension
715
- */
716
- declare function shouldUseHandlebars(templateFile: string): boolean;
717
- /**
718
- * Validate template configuration
719
- * @param config - Configuration object to validate
720
- * @returns Validation result with details
721
- */
722
- declare function validateTemplateConfig(config: TemplateSource): TemplateValidationResult;
723
- /**
724
- * Process a template and return the rendered content
725
- * @param config - Template configuration
726
- * @param initConfig - Initialization config with variable values
727
- * @param task - Optional task definition for $sourceUrl resolution
728
- * @param options - Processing options
729
- * @returns Processed template content
730
- */
731
- declare function processTemplate(config: TemplateSource, initConfig: InitConfig, task?: TaskDefinition, options?: ProcessTemplateOptions): Promise<string>;
732
- /**
733
- * Get a description of the template source for display purposes
734
- * @param config - Template configuration
735
- * @returns Human-readable description of the template source
736
- */
737
- declare function getTemplateSourceDescription(config: TemplateSource): string;
738
- //#endregion
739
- //#region src/variables/collect-variables.d.ts
740
- /**
741
- * Collect variable values from resolved variables
742
- * Variables don't require user interaction - they're just resolved from static
743
- * values or executable commands
744
- *
745
- * @param variables - Array of variable definitions
746
- * @param resolvedValues - Map of pre-resolved variable values
747
- * @param context - Current configuration context (for transformer evaluation)
748
- * @returns Object mapping variable IDs to their values
749
- */
750
- declare function collectVariables(variables: VariableDefinition[], resolvedValues?: Map<string, unknown>, context?: InitConfig): Promise<Record<string, unknown>>;
751
- //#endregion
752
- //#region src/variables/resolve-all-variable-values.d.ts
753
- /**
754
- * Resolve all variable values sequentially to allow lazy evaluation of template enabled conditions
755
- * Each variable can access values from previous variables and prompts
756
- * @param variables - Array of variable definitions
757
- * @param context - Optional context for evaluating conditional variables
758
- * @param options - Optional resolution options
759
- * @param options.skipConditional - If true, skip conditional variables (they will be resolved later)
760
- * @returns Map of variable IDs to their resolved values
761
- */
762
- declare function resolveAllVariableValues(variables: VariableDefinition[], context?: InitConfig, options?: {
763
- skipConditional?: boolean;
764
- }): Promise<Map<string, unknown>>;
765
- //#endregion
766
- //#region src/variables/resolve-variable-value.d.ts
767
- /**
768
- * Resolve a variable value that may be static, executable, or conditional
769
- * @param value - The variable value configuration
770
- * @param variableId - The variable ID for error reporting
771
- * @param context - Optional context for evaluating conditional values
772
- * @param sourceUrl - Optional source URL for resolving relative file paths in exec-file
773
- * @returns The resolved variable value
774
- */
775
- declare function resolveVariableValue<T = string | number | boolean>(value: DefaultValue<T>, variableId: string, context?: InitConfig, sourceUrl?: string): Promise<T | undefined>;
776
- //#endregion
777
- //#region src/variables/validate-variables.d.ts
778
- /**
779
- * Validate variable definitions for duplicate IDs
780
- * @param variables - Array of variable definitions to validate
781
- * @returns Array of error messages (empty if no errors)
782
- */
783
- declare function validateVariables(variables: VariableDefinition[]): string[];
784
- //#endregion
785
541
  //#region src/index.d.ts
786
- /**
787
- * Main function for executing tasks with default/empty tasks array
788
- * For most use cases, you should use runWithTasks() with your custom tasks
789
- */
790
- declare function main(customTasks?: TaskDefinition[]): Promise<void>;
791
542
  /**
792
543
  * Execute tasks with custom task definitions
793
544
  * @param customTasks - Array of task definitions to execute
794
545
  * @param options - Optional configuration
795
546
  * @param options.dryRun - Preview changes without applying them
796
547
  * @param options.force - Force execution even if checks fail
797
- * @param options.tasksFilePath - Path to the tasks file
548
+ * @param options.configFilePath - Path to the tasks file
798
549
  * @param options.variables - Optional top-level global variables
799
550
  * @param options.prompts - Optional top-level global prompts
800
- * @param options.templateEnabled - Optional template-level enabled condition
551
+ * @param options.configEnabled - Optional config-level enabled condition
801
552
  * @param options.transformers - Optional transformer definitions
802
553
  */
803
554
  declare function runWithTasks(customTasks: TaskDefinition[], options?: {
804
555
  dryRun?: boolean | undefined;
805
556
  force?: boolean | undefined;
806
- tasksFilePath?: string | undefined;
557
+ configFilePath?: string | undefined;
807
558
  variables?: VariableDefinition[] | undefined;
808
559
  prompts?: PromptDefinition[] | undefined;
809
- templateEnabled?: EnabledValue | undefined;
560
+ configEnabled?: EnabledValue | undefined;
810
561
  transformers?: Transformer[] | undefined;
811
562
  }): Promise<void>;
812
563
  //#endregion
813
- export { type AppendConfig, BasePrompt, ConditionExpression, ConditionalConfig, ConditionalDefaultConfig, ConfirmPrompt, type CopyConfig, type CreateConfig, DefaultValue, DefaultValueConfig, DefaultValueType, type DeleteConfig, DynamicBooleanValue, EnabledValue, type ExecConfig, ExecFileRuntime, ExecFileValueConfig, ExecutableConfig, 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, executePluginTask, executeTask, getCreateDiff, getDeleteDiff, getExecDiff, getGitInitDiff, getPlugin, getPluginForTaskType, getPluginTaskDiff, getRegexReplaceDiff, getRenameDiff, getReplaceInFileDiff, getTaskDiff, getTemplateSourceDescription, getUpdateJsonDiff, getWriteDiff, hasInlineTemplate, hasTemplateFile, isPluginTaskType, listPlugins, loadAndMergeTemplate, loadTasksWithInheritance, loadTemplate, loadTemplatesInOrder, main, mergeTemplates, processTemplate, registerBuiltInPlugins, registerHooks, registerPlugin, resolveAllDefaultValues, resolveAllVariableValues, resolveDefaultValue, resolveVariableValue, runTask, runTasks, runTemplatesSequentially, runWithTasks, shouldUseHandlebars, topologicalSort, unregisterPlugin, validatePluginTask, validatePrompts, validateScaffoldfyJsonFile, validateTemplateConfig, validateVariables };
564
+ export { type AppendConfig, BasePrompt, ConditionExpression, ConditionalConfig, ConditionalDefaultConfig, ConfirmPrompt, type CopyConfig, type CreateConfig, DefaultValue, DefaultValueConfig, DefaultValueType, type DeleteConfig, DynamicBooleanValue, EnabledValue, type ExecConfig, ExecFileRuntime, ExecFileValueConfig, ExecutableConfig, 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, clearConfigurationCache, clearPlugins, createTaskPlugin, displayTasksDiff, executePluginTask, getDeleteDiff, getExecDiff, getGitInitDiff, getPlugin, getPluginForTaskType, getRegexReplaceDiff, getRenameDiff, getReplaceInFileDiff, getTaskDiff, getUpdateJsonDiff, isPluginTaskType, listPlugins, loadAndMergeConfiguration, loadConfiguration, loadTasksWithInheritance, mergeConfigurations, registerHooks, registerPlugin, runWithTasks, unregisterPlugin, validateScaffoldfyJsonFile };