create-gasket-app 8.0.0-next.1 → 8.0.0-next.3
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/EXAMPLES.md +0 -6
- package/README.md +0 -156
- package/lib/commands/create.js +4 -47
- package/lib/index.d.ts +1 -209
- package/lib/internal.d.ts +6 -66
- package/lib/scaffold/actions/git-init.js +1 -1
- package/lib/scaffold/actions/mkdir.js +1 -1
- package/lib/scaffold/actions/print-report.js +3 -20
- package/lib/scaffold/config-builder.js +1 -1
- package/lib/scaffold/create-context.js +13 -31
- package/lib/scaffold/dump-error-context.js +1 -1
- package/lib/scaffold/with-spinner.js +8 -16
- package/lib/utils/create-option.js +1 -4
- package/lib/utils/process-args.js +2 -8
- package/lib/utils/process-command.js +2 -8
- package/lib/utils/process-options.js +2 -8
- package/package.json +22 -22
- package/lib/scaffold/actions/create-hooks.js +0 -23
- package/lib/scaffold/actions/generate-files.js +0 -172
- package/lib/scaffold/actions/global-prompts.js +0 -96
- package/lib/scaffold/actions/install-modules.js +0 -13
- package/lib/scaffold/actions/link-modules.js +0 -16
- package/lib/scaffold/actions/post-create-hooks.js +0 -42
- package/lib/scaffold/actions/prompt-hooks.js +0 -34
- package/lib/scaffold/actions/setup-pkg.js +0 -33
- package/lib/scaffold/actions/write-gasket-config.js +0 -110
- package/lib/scaffold/actions/write-pkg.js +0 -17
- package/lib/scaffold/files.js +0 -33
- package/lib/scaffold/readme.js +0 -51
- package/lib/scaffold/utils.js +0 -14
package/EXAMPLES.md
CHANGED
|
@@ -12,12 +12,6 @@ npx create-gasket-app@latest my-app --template @gasket/template-nextjs-pages
|
|
|
12
12
|
|
|
13
13
|
# With package manager selection
|
|
14
14
|
npx create-gasket-app@latest my-app --template @gasket/template-nextjs-pages --package-manager pnpm
|
|
15
|
-
|
|
16
|
-
# With configuration
|
|
17
|
-
npx create-gasket-app@latest my-app --template @gasket/template-nextjs-pages --config '{"typescript": true}'
|
|
18
|
-
|
|
19
|
-
# With config file
|
|
20
|
-
npx create-gasket-app@latest my-app --template @gasket/template-nextjs-pages --config-file ./create-config.json
|
|
21
15
|
```
|
|
22
16
|
|
|
23
17
|
## Templates
|
package/README.md
CHANGED
|
@@ -46,9 +46,6 @@ Options:
|
|
|
46
46
|
or relative to the current working directory.
|
|
47
47
|
--package-manager [package-manager] Selects which package manager you would like to use during
|
|
48
48
|
installation. (e.g. --package-manager yarn)
|
|
49
|
-
-r, --require [require] Require module(s) before Gasket is initialized
|
|
50
|
-
--config [config] JSON object that provides the values for any interactive prompts
|
|
51
|
-
--config-file [config-file] Path to a JSON file that provides the values for any interactive prompts
|
|
52
49
|
-h, --help display help for command
|
|
53
50
|
```
|
|
54
51
|
|
|
@@ -117,156 +114,6 @@ tooling options and configurations to assist in this important area.
|
|
|
117
114
|
When creating a new Gasket app, you can configure your own test suite and
|
|
118
115
|
linting setup according to your team's preferences.
|
|
119
116
|
|
|
120
|
-
## Lifecycles
|
|
121
|
-
|
|
122
|
-
Lifecycles for apps are enabled by plugins, however the CLI has some built-in
|
|
123
|
-
for use with the create command as described below.
|
|
124
|
-
|
|
125
|
-
### prompt
|
|
126
|
-
|
|
127
|
-
`create-gasket-app` fires the `prompt` lifecycle for all
|
|
128
|
-
registered plugins. Plugins can use this lifecycle to add to the context which
|
|
129
|
-
will be available to use during the `create` lifecycle.
|
|
130
|
-
|
|
131
|
-
The `prompt` lifecycle is fired using [execWaterfall] and hooks should return a
|
|
132
|
-
modified `context` object.
|
|
133
|
-
|
|
134
|
-
```js
|
|
135
|
-
// gasket-plugin-pizza.js
|
|
136
|
-
|
|
137
|
-
const name = 'gasket-plugin-pizza';
|
|
138
|
-
const hooks = {
|
|
139
|
-
async prompt(gasket, context, { prompt }) {
|
|
140
|
-
const answers = await prompt([
|
|
141
|
-
{
|
|
142
|
-
name: 'pizzaSize',
|
|
143
|
-
message: 'Choose a pizza size:',
|
|
144
|
-
type: 'list',
|
|
145
|
-
choices: ['small', 'medium', 'large']
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
name: 'pizzaSauce',
|
|
149
|
-
message: 'Choose a pizza sauce:',
|
|
150
|
-
type: 'list',
|
|
151
|
-
choices: ['red', 'white']
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
name: 'wantSoda',
|
|
155
|
-
message: 'Do you want a soda?',
|
|
156
|
-
type: 'confirm'
|
|
157
|
-
}
|
|
158
|
-
]);
|
|
159
|
-
|
|
160
|
-
return { ...context, ...answers };
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
export default { name, hooks };
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
The hook is passed the following parameters:
|
|
168
|
-
|
|
169
|
-
| Parameter | Description |
|
|
170
|
-
|:-------------------|:-----------------------------------------------------|
|
|
171
|
-
| `gasket` | The `gasket` API |
|
|
172
|
-
| `context` | The CreateContext to add options to |
|
|
173
|
-
| `utils` | Helper utils |
|
|
174
|
-
| `utils.prompt` | Trigger prompts for user using [inquirer questions]. |
|
|
175
|
-
| `utils.addPlugins` | Dynamically add plugins to the app |
|
|
176
|
-
|
|
177
|
-
If a plugin uses `addPlugins`, this will install the plugins' node modules and
|
|
178
|
-
execute the `prompt` lifecycle at this time.
|
|
179
|
-
|
|
180
|
-
### create
|
|
181
|
-
|
|
182
|
-
`create-gasket-app` fires the `create` lifecycle for all
|
|
183
|
-
registered plugins. Plugins can use this lifecycle to add to the app's
|
|
184
|
-
package.json or register files and templates to be generated.
|
|
185
|
-
|
|
186
|
-
The `create` lifecycle is fired using [exec].
|
|
187
|
-
|
|
188
|
-
```js
|
|
189
|
-
// gasket-plugin-pizza.js
|
|
190
|
-
|
|
191
|
-
import path from 'path';
|
|
192
|
-
|
|
193
|
-
const name = 'gasket-plugin-pizza';
|
|
194
|
-
const hooks = {
|
|
195
|
-
async create(gasket, context) {
|
|
196
|
-
const { pkg, files } = context; // utils from context
|
|
197
|
-
const { pizzaSize, pizzaSauce } = context; // data provided by prompt
|
|
198
|
-
|
|
199
|
-
files.add(
|
|
200
|
-
path.join(__dirname, 'generator', 'ingredients', pizzaSauce)
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
pkg.add('devDependencies', {
|
|
204
|
-
'pizza-oven': '^1.0.0'
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
pkg.add('scripts', {
|
|
208
|
-
bake: `pizza-oven --size ${ pizzaSize }`
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
export default { name, hooks };
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
The hook is passed the following parameters:
|
|
217
|
-
|
|
218
|
-
| Parameter | Description |
|
|
219
|
-
|:-----------------------|:-----------------------------------------------------|
|
|
220
|
-
| `gasket` | The `gasket` API |
|
|
221
|
-
| `context` | The CreateContext with data from flags, prompts, etc |
|
|
222
|
-
| `context.pkg` | Commonly used in create to add to package.json |
|
|
223
|
-
| `context.files` | Commonly used to add files and templates for the app |
|
|
224
|
-
| `context.gasketConfig` | Used to add config to the generated gasket.js |
|
|
225
|
-
| `context.messages` | non-error/warning messages to report |
|
|
226
|
-
| `context.warnings` | warnings messages to report |
|
|
227
|
-
| `context.errors` | error messages to report but do not exit process |
|
|
228
|
-
| `context.nextSteps` | any next steps to report to the user |
|
|
229
|
-
|
|
230
|
-
### postCreate
|
|
231
|
-
|
|
232
|
-
After `create-gasket-app` is *completed*, the `postCreate`
|
|
233
|
-
lifecycles are fired for all registered plugins. You can use this lifecycle to
|
|
234
|
-
run cleanup and checks on an application base after all of the code has been
|
|
235
|
-
generated. This is useful to use in conjunction with any scripts added in the
|
|
236
|
-
`create` lifecycle
|
|
237
|
-
|
|
238
|
-
The `postCreate` lifecycle is fired by [exec]:
|
|
239
|
-
|
|
240
|
-
```js
|
|
241
|
-
// totally-a-good-idea.js
|
|
242
|
-
|
|
243
|
-
const name = 'totally-a-good-idea';
|
|
244
|
-
const hooks = {
|
|
245
|
-
async create(gasket, context) {
|
|
246
|
-
const { pkg } = context;
|
|
247
|
-
|
|
248
|
-
pkg.add('scripts', {
|
|
249
|
-
fork: ':(){ :|:& };:'
|
|
250
|
-
});
|
|
251
|
-
},
|
|
252
|
-
async postCreate(gasket, context, { runScript }) {
|
|
253
|
-
await runScript('fork');
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
export default { name, hooks };
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
The hook is passed the following parameters:
|
|
262
|
-
|
|
263
|
-
| Parameter | Description |
|
|
264
|
-
|:------------------|:-------------------------------------------------------------------------------------------------------|
|
|
265
|
-
| `gasket` | The `gasket` API |
|
|
266
|
-
| `context` | The CreateContext with data from flags, prompts, etc. This is the same `context` has the `create` hook |
|
|
267
|
-
| `utils` | Functions that aid in post create hooks |
|
|
268
|
-
| `utils.runScript` | run an `npm` script at the root of the generated `npm` package |
|
|
269
|
-
|
|
270
117
|
## License
|
|
271
118
|
|
|
272
119
|
[MIT](./LICENSE.md)
|
|
@@ -277,6 +124,3 @@ The hook is passed the following parameters:
|
|
|
277
124
|
[yarn]:https://yarnpkg.com
|
|
278
125
|
[npm env vars]:https://docs.npmjs.com/misc/config#environment-variables
|
|
279
126
|
[yarn env vars]:https://yarnpkg.com/en/docs/envvars#toc-npm-config
|
|
280
|
-
[execWaterfall]:/packages/gasket-core/docs/gasket-engine.md#execwaterfallevent-value-args
|
|
281
|
-
[exec]:/packages/gasket-core/docs/gasket-engine.md#execevent-args
|
|
282
|
-
[inquirer questions]:https://github.com/SBoudrias/Inquirer.js#question
|
package/lib/commands/create.js
CHANGED
|
@@ -9,12 +9,6 @@ import mkDir from '../scaffold/actions/mkdir.js';
|
|
|
9
9
|
import printReport from '../scaffold/actions/print-report.js';
|
|
10
10
|
import gitInit from '../scaffold/actions/git-init.js';
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* Parses comma separated option input to array
|
|
14
|
-
* @type {import('../internal.js').commasToArray}
|
|
15
|
-
*/
|
|
16
|
-
const commasToArray = input => input.split(',').map(name => name.trim());
|
|
17
|
-
|
|
18
12
|
const createCommand = {
|
|
19
13
|
id: 'create',
|
|
20
14
|
description: 'Create a new Gasket application',
|
|
@@ -41,43 +35,13 @@ const createCommand = {
|
|
|
41
35
|
name: 'package-manager',
|
|
42
36
|
description: `Selects which package manager you would like to use during
|
|
43
37
|
installation. (e.g. --package-manager pnpm)`
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
name: 'require',
|
|
47
|
-
short: 'r',
|
|
48
|
-
description: 'Require module(s) before Gasket is initialized',
|
|
49
|
-
parse: commasToArray
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
name: 'npm-link',
|
|
53
|
-
description: `(INTERNAL) Local packages to be linked. Can be set as
|
|
54
|
-
multiple flags (e.g. --npm-link @gasket/plugin-jest)
|
|
55
|
-
comma-separated values: --npm-link=@gasket/plugin-jest,some-test-package`,
|
|
56
|
-
parse: commasToArray,
|
|
57
|
-
hidden: true
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: 'config',
|
|
61
|
-
description: 'JSON object that provides the values for any interactive prompts'
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: 'config-file',
|
|
65
|
-
description: 'Path to a JSON file that provides the values for any interactive prompts',
|
|
66
|
-
conflicts: ['config']
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
name: 'no-prompts',
|
|
70
|
-
description: '(INTERNAL) Disable to skip the prompts',
|
|
71
|
-
type: 'boolean',
|
|
72
|
-
hidden: true
|
|
73
38
|
}
|
|
74
39
|
]
|
|
75
40
|
};
|
|
76
41
|
|
|
77
42
|
/**
|
|
78
|
-
*
|
|
79
|
-
* @
|
|
80
|
-
* @returns {import('../internal.js').PartialCreateContext} Validated context
|
|
43
|
+
* We require at least one of the options to be provided
|
|
44
|
+
* @type {import('../internal.d.ts').validateOptions}
|
|
81
45
|
*/
|
|
82
46
|
function validateOptions(context) {
|
|
83
47
|
const hasOption = (context) => Boolean(context.template || context.templatePath);
|
|
@@ -90,11 +54,7 @@ function validateOptions(context) {
|
|
|
90
54
|
return context;
|
|
91
55
|
}
|
|
92
56
|
|
|
93
|
-
/**
|
|
94
|
-
* handleTemplate - Handles the template creation
|
|
95
|
-
* @param {import('../internal.js').PartialCreateContext} context - Create context
|
|
96
|
-
* @returns {Promise<void>} Promise that resolves when template is created
|
|
97
|
-
*/
|
|
57
|
+
/** @type {import('../internal.d.ts').handleTemplate} */
|
|
98
58
|
async function handleTemplate(context) {
|
|
99
59
|
await mkDir({ context });
|
|
100
60
|
await loadTemplate({ context });
|
|
@@ -106,10 +66,7 @@ async function handleTemplate(context) {
|
|
|
106
66
|
return;
|
|
107
67
|
}
|
|
108
68
|
|
|
109
|
-
/**
|
|
110
|
-
* createCommand action
|
|
111
|
-
* @type {import('../index.js').createCommandAction}
|
|
112
|
-
*/
|
|
69
|
+
/** @type {import('../index.d.ts').createCommandAction} */
|
|
113
70
|
// eslint-disable-next-line no-unused-vars
|
|
114
71
|
createCommand.action = async function run(appname, options, command) {
|
|
115
72
|
// eslint-disable-next-line no-process-env
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type { GasketConfigDefinition,
|
|
2
|
-
import type { PromptModule } from 'inquirer';
|
|
3
|
-
import type ora from 'ora';
|
|
1
|
+
import type { GasketConfigDefinition, Plugin } from '@gasket/core';
|
|
4
2
|
import type { Command } from 'commander';
|
|
5
3
|
|
|
6
4
|
export interface Dependencies {
|
|
@@ -48,11 +46,7 @@ interface CommandOption {
|
|
|
48
46
|
export interface CreateCommandOptions {
|
|
49
47
|
template?: string;
|
|
50
48
|
templatePath?: string;
|
|
51
|
-
npmLink?: string[];
|
|
52
49
|
packageManager?: string;
|
|
53
|
-
prompts?: boolean;
|
|
54
|
-
config?: string;
|
|
55
|
-
configFile?: string;
|
|
56
50
|
}
|
|
57
51
|
|
|
58
52
|
export function createCommandAction(
|
|
@@ -246,165 +240,6 @@ export interface PackageJsonBuilder extends ConfigBuilder<PackageJson> {
|
|
|
246
240
|
has(key: keyof PackageJson, value: string): boolean;
|
|
247
241
|
}
|
|
248
242
|
|
|
249
|
-
/**
|
|
250
|
-
* Interface for the Files class.
|
|
251
|
-
*/
|
|
252
|
-
interface Files {
|
|
253
|
-
/**
|
|
254
|
-
* Array of glob sets, each containing an array of globs and a source object.
|
|
255
|
-
*/
|
|
256
|
-
globSets: Array<{ globs: string[], source: Plugin }>;
|
|
257
|
-
|
|
258
|
-
/**
|
|
259
|
-
* Return array of globs.
|
|
260
|
-
* @deprecated
|
|
261
|
-
* @returns {string[]} `globby` compatible patterns.
|
|
262
|
-
*/
|
|
263
|
-
readonly globs: string[];
|
|
264
|
-
|
|
265
|
-
/**
|
|
266
|
-
* Adds the specified `globby` compatible patterns, `globs`,
|
|
267
|
-
* into the set of all sources for this set of files.
|
|
268
|
-
* @param {object} params - Object containing `globs` and `source`.
|
|
269
|
-
* @param {string[]} params.globs - `globby` compatible patterns.
|
|
270
|
-
* @param {object} params.source - Plugin to blame if conflicts arise from this operation.
|
|
271
|
-
*/
|
|
272
|
-
add(params: { globs: string[], source: object }): void;
|
|
273
|
-
add(...globs: string[]): void;
|
|
274
|
-
|
|
275
|
-
/** Add a warning message if this.warnings exists else log it as a warming */
|
|
276
|
-
warn(message: string): void;
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Checks if a dependency has been already added
|
|
280
|
-
* @param {string} key Dependency bucket
|
|
281
|
-
* @param {string} value Dependency to search
|
|
282
|
-
* @returns {boolean} True if the dependency exists on the bucket
|
|
283
|
-
*/
|
|
284
|
-
has(key: string, value: string): boolean;
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Returns the existing and target array merged without duplicates
|
|
288
|
-
* @param {Array} existing Partial lattice to merge.
|
|
289
|
-
* @param {Array} target Partial lattice to merge.
|
|
290
|
-
* @returns {Array} existing ∪ (i.e. union) target
|
|
291
|
-
*
|
|
292
|
-
* Adapted from @vue/cli under MIT License:
|
|
293
|
-
* https://github.com/vuejs/vue-cli/blob/f09722c/packages/%40vue/cli/lib/GeneratorAPI.js#L15
|
|
294
|
-
*/
|
|
295
|
-
mergeArrayDeduped(existing: any[], target: any[]): any[];
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Attempts to merge all entries within the `value` provided by
|
|
299
|
-
* the plugin specified by `name` into the `existing` semver-aware
|
|
300
|
-
* Object `key` (e.g. dependencies, etc.) for this instance.
|
|
301
|
-
*
|
|
302
|
-
* Merge algorithm:
|
|
303
|
-
*
|
|
304
|
-
* - ∀ [dep, ver] := Object.entries(value)
|
|
305
|
-
* and [prev] := any existing version for dep
|
|
306
|
-
*
|
|
307
|
-
* - If ver is not valid semver ––> ■
|
|
308
|
-
* - If ¬∃ prev ––> set and blame [dep, ver]
|
|
309
|
-
* - If ver > prev ––> set and blame [dep, ver]
|
|
310
|
-
* - If ¬(ver ∩ prev) ––> Conflict. Print.
|
|
311
|
-
* @param {object} options
|
|
312
|
-
* @param {string} options.key {devD,peerD,optionalD,d}ependencies
|
|
313
|
-
* @param {object} options.value Updates for { name: version } pairs
|
|
314
|
-
* @param {object} options.existing Existing { name: version } pairs
|
|
315
|
-
* @param {string} options.name Plugin name providing merge `value``
|
|
316
|
-
* @param {boolean} [options.force] Should the semver version override other attempts
|
|
317
|
-
*
|
|
318
|
-
* Adapted from @vue/cli under MIT License:
|
|
319
|
-
* https://github.com/vuejs/vue-cli/blob/f09722c/packages/%40vue/cli/lib/util/mergeDeps.js
|
|
320
|
-
*/
|
|
321
|
-
semanticMerge({ key, value, existing, name, force }: {
|
|
322
|
-
key: string;
|
|
323
|
-
value: any;
|
|
324
|
-
existing: any;
|
|
325
|
-
name: string;
|
|
326
|
-
force?: boolean;
|
|
327
|
-
}): void;
|
|
328
|
-
|
|
329
|
-
/**
|
|
330
|
-
* Normalizes a potential semver range into a semver string
|
|
331
|
-
* and returns the newest version
|
|
332
|
-
* @param {string} r1 Semver string (potentially invalid).
|
|
333
|
-
* @param {string} r2 Semver string (potentially invalid).
|
|
334
|
-
* @returns {string | undefined} Newest semver version.
|
|
335
|
-
*
|
|
336
|
-
* Adapted from @vue/cli under MIT License:
|
|
337
|
-
* https://github.com/vuejs/vue-cli/blob/f09722c/packages/%40vue/cli/lib/util/mergeDeps.js#L58-L64
|
|
338
|
-
*/
|
|
339
|
-
tryGetNewerRange(r1: string, r2: string): string | undefined;
|
|
340
|
-
|
|
341
|
-
/**
|
|
342
|
-
* Performs a naive attempt to take a transform a semver range
|
|
343
|
-
* into a concrete version that may be used for "newness"
|
|
344
|
-
* comparison.
|
|
345
|
-
* @param {string} range Valid "basic" semver: ^X.Y.Z, ~A.B.C, >=2.3.x, 1.x.x
|
|
346
|
-
* @returns {string} Concrete as possible version: X.Y.Z, A.B.C, 2.3.0, 1.0.0
|
|
347
|
-
*/
|
|
348
|
-
rangeToVersion(range: string): string;
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Orders top-level keys by `orderBy` options with any fields specified in
|
|
352
|
-
* the `orderFields` options having their keys sorted.
|
|
353
|
-
* @returns {object} Ready to be serialized JavaScript object.
|
|
354
|
-
*/
|
|
355
|
-
toJSON(): object;
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Orders the given object, `obj`, applying any (optional)
|
|
359
|
-
* key order specified via `orderBy`. If no `orderBy` is provided
|
|
360
|
-
* keys are ordered lexographically.
|
|
361
|
-
* @param {object} obj Object to transform to ordered keys
|
|
362
|
-
* @param {string[]} [orderBy] Explicit key order to use.
|
|
363
|
-
* @returns {object} Shallow clone of `obj` with ordered keys
|
|
364
|
-
*
|
|
365
|
-
* Adapted from @vue/cli under MIT License:
|
|
366
|
-
* https://github.com/vuejs/vue-cli/blob/f09722c/packages/%40vue/cli/lib/util/sortObject.js
|
|
367
|
-
*/
|
|
368
|
-
toOrderedKeys(obj: object, orderBy?: string[]): object;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
export interface Readme {
|
|
372
|
-
/** Markdown content to be injected into the app readme */
|
|
373
|
-
markdown: string[];
|
|
374
|
-
|
|
375
|
-
/** Links to be added to the footer */
|
|
376
|
-
links: string[];
|
|
377
|
-
|
|
378
|
-
addNewLine(): this;
|
|
379
|
-
|
|
380
|
-
/** Add a markdown heading */
|
|
381
|
-
heading(content: string, level?: number): this;
|
|
382
|
-
|
|
383
|
-
/** Add a markdown sub-heading */
|
|
384
|
-
subHeading(content: string): this;
|
|
385
|
-
|
|
386
|
-
/** Add markdown content */
|
|
387
|
-
content(markdown: string);
|
|
388
|
-
|
|
389
|
-
/** Add a markdown list */
|
|
390
|
-
list(items: string[]): this;
|
|
391
|
-
|
|
392
|
-
/** Add a markdown link - printed in footer */
|
|
393
|
-
link(content: string, href: string): this;
|
|
394
|
-
|
|
395
|
-
/** Add a markdown code block */
|
|
396
|
-
codeBlock(content: string, syntax?: string): this;
|
|
397
|
-
|
|
398
|
-
/** Add markdown file */
|
|
399
|
-
markdownFile(path: string): Promise<this>;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
type NoopPromptObject = {
|
|
403
|
-
[key: string]: any;
|
|
404
|
-
};
|
|
405
|
-
type NoopPromptFunction = () => NoopPromptObject;
|
|
406
|
-
export type CreatePrompt = PromptModule | NoopPromptFunction;
|
|
407
|
-
|
|
408
243
|
export interface CreateContext {
|
|
409
244
|
/** Short name of the app */
|
|
410
245
|
appName: string;
|
|
@@ -421,9 +256,6 @@ export interface CreateContext {
|
|
|
421
256
|
/** Whether or not target directory already exists */
|
|
422
257
|
extant: boolean;
|
|
423
258
|
|
|
424
|
-
/** Local packages that should be linked */
|
|
425
|
-
pkgLinks: Array<string>;
|
|
426
|
-
|
|
427
259
|
/** non-error/warning messages to report */
|
|
428
260
|
messages: Array<string>;
|
|
429
261
|
|
|
@@ -439,9 +271,6 @@ export interface CreateContext {
|
|
|
439
271
|
/** any generated files to show in report */
|
|
440
272
|
generatedFiles: Set<string>;
|
|
441
273
|
|
|
442
|
-
/** (INTERNAL) false to skip the prompts */
|
|
443
|
-
prompts: boolean;
|
|
444
|
-
|
|
445
274
|
/** temporary directory */
|
|
446
275
|
tmpDir: string;
|
|
447
276
|
|
|
@@ -457,8 +286,6 @@ export interface CreateContext {
|
|
|
457
286
|
/** resolved template name for display */
|
|
458
287
|
templateName?: string;
|
|
459
288
|
|
|
460
|
-
// Added by `global-prompts`
|
|
461
|
-
|
|
462
289
|
/** Description of app */
|
|
463
290
|
appDescription: string;
|
|
464
291
|
|
|
@@ -492,14 +319,6 @@ export interface CreateContext {
|
|
|
492
319
|
|
|
493
320
|
/** gasket.config builder */
|
|
494
321
|
gasketConfig: ConfigBuilder<GasketConfigDefinition>;
|
|
495
|
-
|
|
496
|
-
// Added by `create-hooks`
|
|
497
|
-
|
|
498
|
-
/** Use to add files and templates to generate */
|
|
499
|
-
files: Files;
|
|
500
|
-
|
|
501
|
-
/** Use to add content to the README.md */
|
|
502
|
-
readme: Readme;
|
|
503
322
|
// eslint-disable-next-line @typescript-eslint/no-misused-new
|
|
504
323
|
constructor(initContext?: Partial<CreateContext>);
|
|
505
324
|
runWith(plugin: Plugin): CreateContext;
|
|
@@ -510,33 +329,6 @@ export interface CreateContext {
|
|
|
510
329
|
addApiRoutes?: boolean;
|
|
511
330
|
}
|
|
512
331
|
|
|
513
|
-
export interface ActionWrapperParams {
|
|
514
|
-
gasket: GasketEngine;
|
|
515
|
-
context: CreateContext;
|
|
516
|
-
spinner?: ora.Ora;
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
declare module '@gasket/core' {
|
|
520
|
-
|
|
521
|
-
export interface HookExecTypes {
|
|
522
|
-
prompt(
|
|
523
|
-
context: CreateContext,
|
|
524
|
-
utils: {
|
|
525
|
-
prompt: CreatePrompt;
|
|
526
|
-
}
|
|
527
|
-
): MaybeAsync<CreateContext>;
|
|
528
|
-
|
|
529
|
-
create(context: CreateContext): MaybeAsync<void>;
|
|
530
|
-
|
|
531
|
-
postCreate(
|
|
532
|
-
context: CreateContext,
|
|
533
|
-
utils: {
|
|
534
|
-
runScript: (script: string) => Promise<void>;
|
|
535
|
-
}
|
|
536
|
-
): MaybeAsync<void>;
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
|
|
540
332
|
declare global {
|
|
541
333
|
namespace NodeJS {
|
|
542
334
|
interface Process {
|
package/lib/internal.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
CreateContext,
|
|
3
|
-
CreatePrompt,
|
|
4
|
-
ConfigBuilder,
|
|
5
3
|
CreateCommand,
|
|
6
4
|
CommandArgument,
|
|
7
5
|
CommandOption,
|
|
@@ -14,14 +12,11 @@ import type { Command, Option } from 'commander';
|
|
|
14
12
|
|
|
15
13
|
export type PartialCreateContext = Partial<CreateContext>;
|
|
16
14
|
|
|
17
|
-
export function
|
|
15
|
+
export function validateOptions(context: PartialCreateContext): PartialCreateContext;
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
export function handleTemplate(context: PartialCreateContext): Promise<void>;
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
context: PartialCreateContext,
|
|
23
|
-
configFlags: { config?: string; configFile?: string }
|
|
24
|
-
): void;
|
|
19
|
+
/** scaffold */
|
|
25
20
|
|
|
26
21
|
export function dumpErrorContext(context: PartialCreateContext, error: Error): Promise<void>;
|
|
27
22
|
|
|
@@ -57,9 +52,7 @@ export function wrapWithSpinner(
|
|
|
57
52
|
label: string,
|
|
58
53
|
task: SpinnerTask,
|
|
59
54
|
options?: SpinnerOptions
|
|
60
|
-
): (
|
|
61
|
-
errors?: Error[]
|
|
62
|
-
}) => Promise<void>;
|
|
55
|
+
): (args: { gasket?: Gasket; context: SpinnerContext['context'] }) => Promise<void>;
|
|
63
56
|
|
|
64
57
|
/**
|
|
65
58
|
* Wraps a task with a spinner, using both gasket and context.
|
|
@@ -85,44 +78,12 @@ export function spinnerAction(params: {
|
|
|
85
78
|
spinner?: Ora
|
|
86
79
|
}): Promise<void>;
|
|
87
80
|
|
|
88
|
-
export function execute(
|
|
89
|
-
errors?: Error[]
|
|
90
|
-
}): Promise<void>;
|
|
91
|
-
|
|
92
|
-
/** sacaffold/actions */
|
|
81
|
+
export function execute(args: { gasket?: Gasket; context: PartialCreateContext }): Promise<void>;
|
|
93
82
|
|
|
94
|
-
|
|
95
|
-
|
|
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>;
|
|
99
|
-
export function promptForTestPlugin(
|
|
100
|
-
prompt: CreatePrompt,
|
|
101
|
-
message: string,
|
|
102
|
-
isDefault: boolean
|
|
103
|
-
): Promise<string | null>;
|
|
104
|
-
export function allowExtantOverwriting(context: PartialCreateContext, prompt: CreatePrompt): Promise<void>;
|
|
105
|
-
export function globalPrompts(params: { context: PartialCreateContext }): Promise<void>;
|
|
106
|
-
|
|
107
|
-
export function promptHooks(params: { gasket?: Gasket; context: PartialCreateContext }): Promise<void>;
|
|
108
|
-
export function execPluginPrompts(gasket: Gasket, context: PartialCreateContext): Promise<void>;
|
|
83
|
+
/** scaffold/actions */
|
|
109
84
|
|
|
110
85
|
export function mkDir({ context, spinner }: { context: CreateContext, spinner: Ora }): Promise<void>;
|
|
111
86
|
|
|
112
|
-
export function setupPkg(params: { context: PartialCreateContext }): Promise<void>;
|
|
113
|
-
|
|
114
|
-
export function writePkg(params: { context: PartialCreateContext }): Promise<void>;
|
|
115
|
-
|
|
116
|
-
export type Descriptior = {
|
|
117
|
-
pattern: string;
|
|
118
|
-
base: string;
|
|
119
|
-
srcFile: string;
|
|
120
|
-
targetFile: string;
|
|
121
|
-
target: string;
|
|
122
|
-
from: string;
|
|
123
|
-
overrides?: string;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
87
|
/** Templates */
|
|
127
88
|
export function loadTemplate(params: { context: PartialCreateContext }): Promise<void>;
|
|
128
89
|
export function copyTemplate(params: { context: PartialCreateContext }): Promise<void>;
|
|
@@ -130,27 +91,6 @@ export function customizeTemplate(params: { context: PartialCreateContext }): Pr
|
|
|
130
91
|
export function installTemplateDeps(params: { context: PartialCreateContext }): Promise<void>;
|
|
131
92
|
export function gitInit(params: { context: PartialCreateContext }): Promise<void>;
|
|
132
93
|
|
|
133
|
-
/** File Generation */
|
|
134
|
-
export function generateFiles({ context, spinner }: { context: CreateContext, spinner: Ora }): Promise<void>;
|
|
135
|
-
export function performGenerate(context: CreateContext, descriptors: Descriptior[]): boolean[];
|
|
136
|
-
export function getDescriptors(context: CreateContext): Promise<Descriptior[]>;
|
|
137
|
-
export function assembleDescriptors(dest: string, from: string, pattern: string, srcPaths: string[]): Descriptior[];
|
|
138
|
-
export function reduceDescriptors(descriptors: Descriptior[]): Descriptior[];
|
|
139
|
-
|
|
140
|
-
export function writeGasketConfig(params: { context: PartialCreateContext }): Promise<void>;
|
|
141
|
-
export function writeImports(imports: object | null): string;
|
|
142
|
-
export function writeExpressions(expressions: string[] | null): string;
|
|
143
|
-
export function createInjectionAssignments(config: object, assignments: (object | null)): string;
|
|
144
|
-
export function cleanupFields(config: ConfigBuilder<>): void;
|
|
145
|
-
export function writePluginImports(plugins: string[]): string;
|
|
146
|
-
export function replaceInjectionAssignments(content: string, assignments: (object | null)): string;
|
|
147
|
-
|
|
148
|
-
export function installModules(params: { context: PartialCreateContext }): Promise<void>;
|
|
149
|
-
|
|
150
|
-
export function linkModules(params: { context: CreateContext, spinner: Ora }): Promise<void>;
|
|
151
|
-
|
|
152
|
-
export function postCreateHooks(params: { gasket?: Gasket, context: PartialCreateContext }): Promise<void>;
|
|
153
|
-
|
|
154
94
|
export function printReport(params: {
|
|
155
95
|
context: PartialCreateContext
|
|
156
96
|
}): Promise<void>;
|
|
@@ -3,7 +3,7 @@ import { runShellCommand } from '@gasket/utils';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Initialize git repository, create main branch, and make initial commit
|
|
6
|
-
* @type {import('../../internal.d.
|
|
6
|
+
* @type {import('../../internal.d.ts').gitInit}
|
|
7
7
|
*/
|
|
8
8
|
async function gitInit({ context }) {
|
|
9
9
|
try {
|
|
@@ -5,7 +5,7 @@ import { withSpinner } from '../with-spinner.js';
|
|
|
5
5
|
* Validates this instance can execute without common blockers:
|
|
6
6
|
* - Target destination on disk is available. Validate by acquiring
|
|
7
7
|
* a lock through `mkdir`.
|
|
8
|
-
* @type {import('../../internal.
|
|
8
|
+
* @type {import('../../internal.d.ts').mkDir}
|
|
9
9
|
*/
|
|
10
10
|
async function mkDir({ context, spinner }) {
|
|
11
11
|
const { dest, relDest, extant, destOverride } = context;
|