1
- import { Gasket } from '@gasket/core' ;
2
1
import type {
3
2
CreateContext ,
4
3
CreatePrompt ,
5
4
ConfigBuilder ,
6
5
CreateCommand ,
7
6
CommandArgument ,
8
- CommandOption
9
- } from './index' ;
10
- import type { GasketEngine , Plugin } from '@gasket/core' ;
11
- import type ora from 'ora' ;
7
+ CommandOption ,
8
+ CreateCommandOptions
9
+ } from 'create-gasket-app' ;
10
+ import type { GasketEngine , Plugin , Gasket } from '@gasket/core' ;
11
+ import type { Ora } from 'ora' ;
12
12
import type { Command , Option } from 'commander' ;
13
13
14
14
@@ -29,47 +29,91 @@ export function makeCreateContext(argv?: string[], options?: CreateCommandOption
29
29
30
30
export function makeCreateRuntime ( context : PartialCreateContext , source : Plugin ) : Proxy < CreateContext > ;
31
31
32
- export function spinnerAction ( { gasket, context, spinner } : {
33
- gasket ?: GasketEngine ;
34
- context ?: CreateContext ;
35
- spinner ?: ora . Ora
36
- } ) : Promise < void > ;
37
- export function withSpinnerWrapper ( { gasket, context } : { gasket : GasketEngine , context : CreateContext } ) : Promise < void > ;
32
+ /**
33
+ * Represents the execution context for a task.
34
+ */
35
+ export interface SpinnerContext {
36
+ gasket ?: Gasket ;
37
+ context : PartialCreateContext ;
38
+ spinner : Ora ;
39
+ }
40
+
41
+ /**
42
+ * Task function type that runs within a spinner wrapper.
43
+ */
44
+ export type SpinnerTask = ( params : SpinnerContext ) => Promise < void > ;
45
+
46
+ /**
47
+ * Options for the spinner wrapper.
48
+ */
49
+ export interface SpinnerOptions {
50
+ startSpinner ?: boolean ;
51
+ }
52
+
53
+ /**
54
+ * Wraps a task with a spinner, handling success and failure states.
55
+ */
56
+ export function wrapWithSpinner (
57
+ label : string ,
58
+ task : SpinnerTask ,
59
+ options ?: SpinnerOptions
60
+ ) : ( context : { context : SpinnerContext [ 'context' ] } & {
61
+ errors ?: Error [ ]
62
+ } ) => Promise < void > ;
63
+
64
+ /**
65
+ * Wraps a task with a spinner, using both gasket and context.
66
+ */
67
+ export function withGasketSpinner (
68
+ label : string ,
69
+ task : SpinnerTask ,
70
+ options ?: SpinnerOptions
71
+ ) : ( context : { gasket : any ; context : SpinnerContext [ 'context' ] } ) => Promise < void > ;
72
+
73
+ /**
74
+ * Wraps a task with a spinner, using only context.
75
+ */
38
76
export function withSpinner (
39
77
label : string ,
40
- fn : spinnerAction ,
41
- options ?: { startSpinner ?: boolean }
42
- ) : withSpinnerWrapper
78
+ task : SpinnerTask ,
79
+ options ?: SpinnerOptions
80
+ ) : ( context : { context : SpinnerContext [ 'context' ] } ) => Promise < void > ;
81
+
82
+ export function spinnerAction ( params : {
83
+ gasket ?: GasketEngine ;
84
+ context : PartialCreateContext ;
85
+ spinner ?: Ora
86
+ } ) : Promise < void > ;
87
+
88
+ export function execute ( params : { gasket : Gasket , context : PartialCreateContext } & {
89
+ errors ?: Error [ ]
90
+ } ) : Promise < void > ;
43
91
44
92
/** sacaffold/actions */
45
93
46
- export function createHooks ( { gasket , context } : { gasket : GasketEngine ; context : CreateContext } ) : Promise < void > ;
94
+ export function createHooks ( params : { gasket ?: Gasket ; context : PartialCreateContext } ) : Promise < void > ;
47
95
48
- export function chooseAppDescription ( context : CreateContext , prompt : CreatePrompt ) : Promise < void > ;
49
- export function choosePackageManager ( context : CreateContext , prompt : CreatePrompt ) : Promise < void > ;
50
- export function chooseTestPlugins ( context : CreateContext , prompt : CreatePrompt ) : Promise < void > ;
96
+ export function chooseAppDescription ( context : PartialCreateContext , prompt : CreatePrompt ) : Promise < void > ;
97
+ export function choosePackageManager ( context : PartialCreateContext , prompt : CreatePrompt ) : Promise < void > ;
98
+ export function chooseTestPlugins ( context : PartialCreateContext , prompt : CreatePrompt ) : Promise < void > ;
51
99
export function promptForTestPlugin (
52
- prompt : CreatePrompt ,
53
- message : string ,
100
+ prompt : CreatePrompt ,
101
+ message : string ,
54
102
choices : { name : string ; value : string ; } [ ]
55
103
) : Promise < string | null > ;
56
- export function allowExtantOverwriting ( context : CreateContext , prompt : CreatePrompt ) : Promise < void > ;
57
- export function globalPrompts ( { context } : { context : CreateContext } ) : Promise < void > ;
58
-
59
- export function loadPresets ( { context } : { context : CreateContext } ) : Promise < void > ;
60
-
61
- export function presetPromptHooks ( { gasket, context } : { gasket : GasketEngine ; context : CreateContext } ) : Promise < void > ;
104
+ export function allowExtantOverwriting ( context : PartialCreateContext , prompt : CreatePrompt ) : Promise < void > ;
105
+ export function globalPrompts ( params : { context : PartialCreateContext } ) : Promise < void > ;
106
+ export function loadPresets ( params : { context : PartialCreateContext } ) : Promise < void > ;
107
+ export function presetPromptHooks ( params : { gasket ?: Gasket ; context : PartialCreateContext } ) : Promise < void > ;
108
+ export function presetConfigHooks ( params : { gasket ?: Gasket ; context : PartialCreateContext } ) : Promise < void > ;
109
+ export function promptHooks ( params : { gasket ?: Gasket ; context : PartialCreateContext } ) : Promise < void > ;
110
+ export function execPluginPrompts ( gasket : Gasket , context : PartialCreateContext ) : Promise < void > ;
62
111
63
- export function presetConfigHooks ( { gasket , context } : { gasket : GasketEngine ; context : CreateContext } ) : Promise < void > ;
112
+ export function mkDir ( { context , spinner } : { context : CreateContext , spinner : Ora } ) : Promise < void > ;
64
113
65
- export function promptHooks ( { gasket, context } : { gasket : GasketEngine ; context : CreateContext } ) : Promise < void > ;
66
- export function execPluginPrompts ( gasket : GasketEngine , context : CreateContext ) : Promise < void > ;
114
+ export function setupPkg ( params : { context : PartialCreateContext } ) : Promise < void > ;
67
115
68
- export function mkDir ( { context, spinner } : { context : CreateContext , spinner : ora . Ora } ) : Promise < void > ;
69
-
70
- export function setupPkg ( { context } : { context : CreateContext } ) : Promise < void > ;
71
-
72
- export function writePkg ( { context } : { context : CreateContext } ) : Promise < void > ;
116
+ export function writePkg ( params : { context : PartialCreateContext } ) : Promise < void > ;
73
117
74
118
export type Descriptior = {
75
119
pattern : string ;
@@ -80,28 +124,30 @@ export type Descriptior = {
80
124
from : string ;
81
125
overrides ?: string ;
82
126
}
83
- export function generateFiles ( { context, spinner } : { context : CreateContext , spinner : ora . Ora } ) : Promise < void > ;
127
+ export function generateFiles ( { context, spinner } : { context : CreateContext , spinner : Ora } ) : Promise < void > ;
84
128
export function performGenerate ( context : CreateContext , descriptors : Descriptior [ ] ) : boolean [ ] ;
85
129
export function getDescriptors ( context : CreateContext ) : Promise < Descriptior [ ] > ;
86
- export function assembleDescriptors ( dest : string , from : string , pattern : string , srcPaths : sring [ ] ) : Descriptior [ ] ;
130
+ export function assembleDescriptors ( dest : string , from : string , pattern : string , srcPaths : string [ ] ) : Descriptior [ ] ;
87
131
export function reduceDescriptors ( descriptors : Descriptior [ ] ) : Descriptior [ ] ;
88
132
89
- export function writeGasketConfig ( { context } : { context : CreateContext } ) : Promise < void > ;
133
+ export function writeGasketConfig ( params : { context : PartialCreateContext } ) : Promise < void > ;
90
134
export function writeImports ( imports : object | null ) : string ;
91
135
export function writeExpressions ( expressions : string [ ] | null ) : string ;
92
136
export function createInjectionAssignments ( config : object , assignments : ( object | null ) ) : string ;
93
137
export function cleanupFields ( config : ConfigBuilder ) : void ;
94
138
export function writePluginImports ( plugins : string [ ] ) : string ;
95
139
export function replaceInjectionAssignments ( content : string , assignments : ( object | null ) ) : string ;
96
140
97
- export function installModules ( { context } : { context : CreateContext } ) : Promise < void > ;
141
+ export function installModules ( params : { context : PartialCreateContext } ) : Promise < void > ;
98
142
99
- export function linkModules ( { context , spinner } : { context : CreateContext , spinner : ora . Ora } ) : Promise < void > ;
143
+ export function linkModules ( params : { context : CreateContext , spinner : Ora } ) : Promise < void > ;
100
144
101
- export function postCreateHooks ( { gasket , context } : { gasket : GasketEngine , context : CreateContext } ) : Promise < void > ;
145
+ export function postCreateHooks ( params : { gasket ?: Gasket , context : PartialCreateContext } ) : Promise < void > ;
102
146
103
- export function printReport ( { context } : { context : CreateContext } ) : Promise < void > ;
104
- export function buildReport ( context : CreateContext ) : {
147
+ export function printReport ( params : {
148
+ context : PartialCreateContext
149
+ } ) : Promise < void > ;
150
+ export function buildReport ( context : PartialCreateContext ) : {
105
151
appName ?: string ;
106
152
output ?: string ;
107
153
generatedFiles ?: string [ ] ;
@@ -119,15 +165,14 @@ export function isValidCommand(command: CreateCommand): boolean;
119
165
export function processArgs ( args : CommandArgument [ ] ) : [ string , string ?, any ?] [ ] ;
120
166
export function isValidArg ( arg : CommandArgument ) : boolean ;
121
167
122
- interface OptionDefinition {
168
+ interface OptionDefinition {
123
169
options : [ string , string ] ;
124
170
conflicts : CommandOption [ 'conflicts' ] ;
125
171
hidden : CommandOption [ 'hidden' ] ;
126
172
required : CommandOption [ 'required' ] ;
127
173
defaultValue : CommandOption [ 'default' ] ;
128
174
parse : CommandOption [ 'parse' ]
129
- } ;
175
+ }
130
176
export function isValidOption ( option : CommandOption ) : boolean ;
131
- export function processOptions ( options : CommandOption [ ] ) : OptionDefinition [ ]
132
-
133
- export function createOption ( definition : OptionDefinition ) : Option
177
+ export function processOptions ( options : CommandOption [ ] ) : OptionDefinition [ ] ;
178
+ export function createOption ( definition : OptionDefinition ) : Option ;
0 commit comments