create-gasket-app 7.2.0-canary.1 → 7.2.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.
Files changed (34) hide show
  1. package/README.md +55 -57
  2. package/lib/commands/create.js +4 -9
  3. package/lib/index.d.ts +312 -73
  4. package/lib/index.js +3 -0
  5. package/lib/internal.d.ts +133 -0
  6. package/lib/scaffold/action-wrapper.js +2 -10
  7. package/lib/scaffold/actions/create-hooks.js +6 -8
  8. package/lib/scaffold/actions/generate-files.js +9 -20
  9. package/lib/scaffold/actions/global-prompts.js +24 -29
  10. package/lib/scaffold/actions/install-modules.js +1 -3
  11. package/lib/scaffold/actions/link-modules.js +1 -4
  12. package/lib/scaffold/actions/load-preset.js +9 -9
  13. package/lib/scaffold/actions/mkdir.js +3 -6
  14. package/lib/scaffold/actions/post-create-hooks.js +2 -5
  15. package/lib/scaffold/actions/preset-config-hooks.js +1 -2
  16. package/lib/scaffold/actions/preset-prompt-hooks.js +1 -2
  17. package/lib/scaffold/actions/print-report.js +3 -12
  18. package/lib/scaffold/actions/prompt-hooks.js +3 -12
  19. package/lib/scaffold/actions/setup-pkg.js +5 -6
  20. package/lib/scaffold/actions/write-gasket-config.js +13 -20
  21. package/lib/scaffold/actions/write-pkg.js +1 -3
  22. package/lib/scaffold/config-builder.js +41 -42
  23. package/lib/scaffold/create-context.js +7 -67
  24. package/lib/scaffold/dump-error-context.js +1 -4
  25. package/lib/scaffold/files.js +8 -5
  26. package/lib/scaffold/readme.js +51 -0
  27. package/lib/scaffold/utils.js +1 -9
  28. package/lib/utils/create-option.js +1 -2
  29. package/lib/utils/logo.js +10 -10
  30. package/lib/utils/process-args.js +5 -7
  31. package/lib/utils/process-command.js +2 -4
  32. package/lib/utils/process-options.js +6 -8
  33. package/package.json +31 -21
  34. package/lib/config/default-plugins.js +0 -7
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # create-gasket-app
2
2
 
3
- Starter Pack for creating Gasket apps.
3
+ Starter Pack for creating Gasket apps.
4
4
 
5
5
  ### Get Started Immediately
6
6
 
@@ -43,9 +43,6 @@ Options:
43
43
  -p, --presets [presets] Initial Gasket preset(s) to use.
44
44
  Can be set as short name with version (e.g. --presets nextjs@^1.0.0)
45
45
  Or other (multiple) custom presets (e.g. --presets my-gasket-preset@1.0.0.beta-1,nextjs@^1.0.0)
46
- --plugins [plugins] Additional plugin(s) to install. Can be set as
47
- multiple flags (e.g. --plugins jest --plugins zkconfig@^1.0.0)
48
- comma-separated values: --plugins=jest,zkconfig^1.0.0
49
46
  --package-manager [package-manager] Selects which package manager you would like to use during
50
47
  installation. (e.g. --package-manager yarn)
51
48
  -r, --require [require] Require module(s) before Gasket is initialized
@@ -84,7 +81,6 @@ Additional code style choices are prompted during the create command. Some
84
81
  predefined choices are provided from the [lint plugin], or you can specify your
85
82
  own config.
86
83
 
87
-
88
84
  ## Lifecycles
89
85
 
90
86
  Lifecycles for apps are enabled by plugins, however the CLI has some built-in
@@ -100,38 +96,36 @@ The `prompt` lifecycle is fired using [execWaterfall] and hooks should return a
100
96
  modified `context` object.
101
97
 
102
98
  ```js
103
- module.exports = {
104
- id: 'gasket-plugin-pizza',
105
- hooks: {
106
- async prompt(gasket, context, { prompt, addPlugins }) {
107
- const answers = await prompt([
108
- {
109
- name: 'pizzaSize',
110
- message: 'Choose a pizza size:',
111
- type: 'list',
112
- choices: ['small', 'medium', 'large']
113
- },
114
- {
115
- name: 'pizzaSauce',
116
- message: 'Choose a pizza sauce:',
117
- type: 'list',
118
- choices: ['red', 'white']
119
- },
120
- {
121
- name: 'wantSoda',
122
- message: 'Do you want a soda?',
123
- type: 'confirm'
124
- }
125
- ]);
126
-
127
- if (answers.wantSoda === true) {
128
- await addPlugins('gasket-plugin-soda@^2.0.0')
99
+ // gasket-plugin-pizza.js
100
+
101
+ const name = 'gasket-plugin-pizza';
102
+ const hooks = {
103
+ async prompt(gasket, context, { prompt }) {
104
+ const answers = await prompt([
105
+ {
106
+ name: 'pizzaSize',
107
+ message: 'Choose a pizza size:',
108
+ type: 'list',
109
+ choices: ['small', 'medium', 'large']
110
+ },
111
+ {
112
+ name: 'pizzaSauce',
113
+ message: 'Choose a pizza sauce:',
114
+ type: 'list',
115
+ choices: ['red', 'white']
116
+ },
117
+ {
118
+ name: 'wantSoda',
119
+ message: 'Do you want a soda?',
120
+ type: 'confirm'
129
121
  }
122
+ ]);
130
123
 
131
- return { ...context, ...answers };
132
- }
124
+ return { ...context, ...answers };
133
125
  }
134
126
  };
127
+
128
+ export default { name, hooks };
135
129
  ```
136
130
 
137
131
  The hook is passed the following parameters:
@@ -156,29 +150,31 @@ package.json or register files and templates to be generated.
156
150
  The `create` lifecycle is fired using [exec].
157
151
 
158
152
  ```js
159
- const path = require('path');
153
+ // gasket-plugin-pizza.js
160
154
 
161
- module.exports = {
162
- id: 'gasket-plugin-pizza',
163
- hooks: {
164
- async create(gasket, context) {
165
- const { pkg, files } = context; // utils from context
166
- const { pizzaSize, pizzaSauce } = context; // data provided by prompt
155
+ import path from 'path';
167
156
 
168
- files.add(
169
- path.join(__dirname, 'generator', 'ingredients', pizzaSauce)
170
- );
157
+ const name = 'gasket-plugin-pizza';
158
+ const hooks = {
159
+ async create(gasket, context) {
160
+ const { pkg, files } = context; // utils from context
161
+ const { pizzaSize, pizzaSauce } = context; // data provided by prompt
171
162
 
172
- pkg.add('devDependencies', {
173
- 'pizza-oven': '^1.0.0'
174
- });
163
+ files.add(
164
+ path.join(__dirname, 'generator', 'ingredients', pizzaSauce)
165
+ );
175
166
 
176
- pkg.add('scripts', {
177
- bake: `pizza-oven --size ${ pizzaSize }`
178
- });
179
- }
167
+ pkg.add('devDependencies', {
168
+ 'pizza-oven': '^1.0.0'
169
+ });
170
+
171
+ pkg.add('scripts', {
172
+ bake: `pizza-oven --size ${ pizzaSize }`
173
+ });
180
174
  }
181
175
  };
176
+
177
+ export default { name, hooks };
182
178
  ```
183
179
 
184
180
  The hook is passed the following parameters:
@@ -189,7 +185,7 @@ The hook is passed the following parameters:
189
185
  | `context` | The CreateContext with data from flags, prompts, etc |
190
186
  | `context.pkg` | Commonly used in create to add to package.json |
191
187
  | `context.file` | Commonly used to add files and templates for the app |
192
- | `context.gasketConfig` | Used to add config to the generated gasket.config.js |
188
+ | `context.gasketConfig` | Used to add config to the generated gasket.js |
193
189
  | `context.messages` | non-error/warning messages to report |
194
190
  | `context.warnings` | warnings messages to report |
195
191
  | `context.errors` | error messages to report but do not exit process |
@@ -206,9 +202,10 @@ generated. This is useful to use in conjunction with any scripts added in the
206
202
  The `postCreate` lifecycle is fired by [exec]:
207
203
 
208
204
  ```js
209
- module.exports = {
210
- id: 'totally-a-good-idea',
211
- hooks: {
205
+ // totally-a-good-idea.js
206
+
207
+ const name = 'totally-a-good-idea';
208
+ const hooks = {
212
209
  async create(gasket, context) {
213
210
  const { pkg } = context;
214
211
 
@@ -221,6 +218,8 @@ module.exports = {
221
218
  }
222
219
  }
223
220
  };
221
+
222
+ export default { name, hooks };
224
223
  ```
225
224
 
226
225
  The hook is passed the following parameters:
@@ -232,7 +231,6 @@ The hook is passed the following parameters:
232
231
  | `utils` | Functions that aid in post create hooks |
233
232
  | `utils.runScript` | run an `npm` script at the root of the generated `npm` package |
234
233
 
235
-
236
234
  ## License
237
235
 
238
236
  [MIT](./LICENSE.md)
@@ -245,7 +243,7 @@ The hook is passed the following parameters:
245
243
  [yarn env vars]:https://yarnpkg.com/en/docs/envvars#toc-npm-config
246
244
  [Jest plugin]:/packages/gasket-plugin-jest/README.md
247
245
  [Mocha plugin]:/packages/gasket-plugin-mocha/README.md
248
- [execWaterfall]:/packages/gasket-engine/README.md#execwaterfallevent-value-args
249
- [exec]:/packages/gasket-engine/README.md#execevent-args
246
+ [execWaterfall]:/packages/gasket-core/docs/gasket-engine.md#execwaterfallevent-value-args
247
+ [exec]:/packages/gasket-core/docs/gasket-engine.md#execevent-args
250
248
  [inquirer questions]:https://github.com/SBoudrias/Inquirer.js#question
251
249
  [lint plugin]:/packages/gasket-plugin-lint/README.md
@@ -4,7 +4,6 @@ import { makeCreateContext } from '../scaffold/create-context.js';
4
4
  import { dumpErrorContext } from '../scaffold/dump-error-context.js';
5
5
  import { rm } from 'fs/promises';
6
6
  import { makeGasket } from '@gasket/core';
7
- import { defaultPlugins } from '../config/default-plugins.js';
8
7
  import {
9
8
  createHooks,
10
9
  generateFiles,
@@ -25,9 +24,7 @@ import {
25
24
 
26
25
  /**
27
26
  * Parses comma separated option input to array
28
- *
29
- * @param {String} input - option argument
30
- * @returns {String[]} results
27
+ * @type {import('../internal').commasToArray}
31
28
  */
32
29
  const commasToArray = input => input.split(',').map(name => name.trim());
33
30
 
@@ -97,10 +94,7 @@ const createCommand = {
97
94
 
98
95
  /**
99
96
  * createCommand action
100
- * @param {string} appname Required cmd arg - name of the app to create
101
- * @param {object} options cmd options
102
- * @param {Command} command - the command instance
103
- * @returns {Promise<void>} void
97
+ * @type {import('../index').createCommandAction}
104
98
  */
105
99
  createCommand.action = async function run(appname, options, command) {
106
100
  process.env.GASKET_ENV = 'create';
@@ -111,6 +105,7 @@ createCommand.action = async function run(appname, options, command) {
111
105
  await globalPrompts({ context });
112
106
 
113
107
  if (rawPresets.length || localPresets.length) {
108
+
114
109
  await loadPreset({ context });
115
110
 
116
111
  const presetGasket = makeGasket({
@@ -123,7 +118,7 @@ createCommand.action = async function run(appname, options, command) {
123
118
 
124
119
  const pluginGasket = makeGasket({
125
120
  ...context.presetConfig,
126
- plugins: context.presets.concat(context.presetConfig.plugins, defaultPlugins)
121
+ plugins: context.presets.concat(context.presetConfig.plugins)
127
122
  });
128
123
 
129
124
  await promptHooks({ gasket: pluginGasket, context });