@travetto/scaffold 6.0.1 → 7.0.0-rc.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/scaffold",
3
- "version": "6.0.1",
3
+ "version": "7.0.0-rc.0",
4
4
  "description": "App Scaffold for the Travetto framework",
5
5
  "keywords": [
6
6
  "generator",
@@ -27,13 +27,13 @@
27
27
  "trv-scaffold": "bin/trv-scaffold.js"
28
28
  },
29
29
  "dependencies": {
30
- "@travetto/cli": "^6.0.1",
31
- "@travetto/runtime": "^6.0.1",
30
+ "@travetto/cli": "^7.0.0-rc.0",
31
+ "@travetto/runtime": "^7.0.0-rc.0",
32
32
  "enquirer": "^2.4.1",
33
33
  "mustache": "^4.2.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@travetto/model": "^6.0.1",
36
+ "@travetto/model": "^7.0.0-rc.0",
37
37
  "@types/mustache": "^4.2.6"
38
38
  },
39
39
  "travetto": {
@@ -25,11 +25,11 @@
25
25
  ],
26
26
  "license": "MIT",
27
27
  "scripts": {
28
- "watch": "npx trvc watch",
29
- "build": "npx trvc build",
30
- "start": "npx trv web:http",
31
- "test": "npx trv test",
32
- "lint": "npx trv lint"
28
+ "build": "npx trvc build",
29
+ {{#module_web}}"start": "npx trv web:http",{{/module_web}}
30
+ {{#module_test}}"test": "npx trv test",{{/module_test}}
31
+ {{#module_eslint}}"lint": "npx trv eslint",{{/module_eslint}}
32
+ "watch": "npx trvc watch"
33
33
  },
34
34
  "files": [
35
35
  "src",
@@ -116,14 +116,18 @@ export class Context {
116
116
  PackageUtil.resolveImport('@travetto/manifest/package.json')
117
117
  );
118
118
 
119
- const context = Object.assign({
120
- frameworkVersion: frameworkVersion.replace(/[.]\d+$/, '.0'),
121
- name: this.name,
122
- modules,
123
- moduleNames,
124
- dependencies: [...new Set(this.#dependencies)].toSorted((a, b) => a.localeCompare(b)),
125
- devDependencies: [...new Set(this.#devDependencies)].toSorted((a, b) => a.localeCompare(b)),
126
- }, ...this.#featureContexts);
119
+ const context = Object.assign(
120
+ {
121
+ frameworkVersion: frameworkVersion.replace(/[.]\d+$/, '.0'),
122
+ name: this.name,
123
+ modules,
124
+ moduleNames,
125
+ dependencies: [...new Set(this.#dependencies)].toSorted((a, b) => a.localeCompare(b)),
126
+ devDependencies: [...new Set(this.#devDependencies)].toSorted((a, b) => a.localeCompare(b)),
127
+ },
128
+ ...this.#featureContexts,
129
+ ...moduleNames.map(x => ({ [`module_${x}`]: true }))
130
+ );
127
131
 
128
132
  return context;
129
133
  }
@@ -203,7 +207,7 @@ export class Context {
203
207
  await this.#exec('npx', ['trvc', 'build']);
204
208
  if (this.#devDependencies.includes('@travetto/eslint')) {
205
209
  yield cliTpl`${{ type: 'ESLint Registration' }} `;
206
- await this.#exec('npx', ['trv', 'lint:register']);
210
+ await this.#exec('npx', ['trv', 'eslint:register']);
207
211
  }
208
212
 
209
213
  yield cliTpl`${{ success: 'Successfully created' }} at ${{ path: this.#targetDir }} `;
@@ -22,25 +22,24 @@ export const FEATURES: Feature[] = [
22
22
  required: true,
23
23
  default: 'npm'
24
24
  },
25
+ { title: 'Logging', package: '@travetto/log', required: true },
25
26
  {
26
27
  title: 'Web Framework',
27
28
  package: '@travetto/web',
28
29
  addons: [
29
- { title: 'Web Node', package: '@travetto/web-node' },
30
- { title: 'Web Http Server', package: '@travetto/web-http-server' },
31
- { title: 'OpenAPI', package: '@travetto/openapi' },
32
- { title: 'Logging', package: '@travetto/log' }
30
+ { title: 'Web Http Server', package: '@travetto/web-http', required: true },
31
+ { title: 'OpenAPI', package: '@travetto/openapi', required: true },
32
+ {
33
+ title: 'Web Authentication',
34
+ package: '@travetto/auth-web',
35
+ addons: [
36
+ { title: 'Session Support', package: ['@travetto/auth-session', '@travetto/auth-web-session', '@travetto/model-memory'] },
37
+ ]
38
+ },
33
39
  ]
34
40
  },
35
41
  { title: 'Test Framework', package: '@travetto/test' },
36
42
  { title: 'ESLint Support', package: '@travetto/eslint' },
37
- {
38
- title: 'Web Authentication',
39
- package: '@travetto/auth-web',
40
- addons: [
41
- { title: 'Session Support', package: ['@travetto/auth-session', '@travetto/auth-web-session', '@travetto/model-memory'] },
42
- ]
43
- },
44
43
  {
45
44
  title: 'Data Modelling',
46
45
  package: '@travetto/model',
@@ -49,13 +49,13 @@ export class ScaffoldCommand implements CliCommandShape {
49
49
  return feature.choices?.find(x => x.title === response.choice);
50
50
  }
51
51
 
52
- async * #resolveFeatures(features: Feature[], chosen = false): AsyncGenerator<Feature> {
52
+ async * #resolveFeatures(features: Feature[], chosen = false, depth = 0): AsyncGenerator<Feature> {
53
53
  for (const feat of features) {
54
54
  if (!chosen && !feat.required) {
55
55
  const ans = await prompt<{ choice: boolean | string }>([{
56
56
  type: 'confirm',
57
57
  name: 'choice',
58
- message: `Include ${feat.title} support?`,
58
+ message: `${'='.repeat(depth * 2)}${depth > 0 ? '| ' : ''}Include ${feat.title} support?`,
59
59
  initial: true
60
60
  }]);
61
61
 
@@ -67,12 +67,14 @@ export class ScaffoldCommand implements CliCommandShape {
67
67
  if (feat.choices) {
68
68
  const choice = await this.#chooseFeature(feat);
69
69
  if (choice) {
70
- yield* this.#resolveFeatures([choice], true);
70
+ yield* this.#resolveFeatures([choice], true, depth);
71
71
  } else {
72
72
  throw new Error(`Invalid choice: ${feat}`);
73
73
  }
74
74
  }
75
75
 
76
+ yield* this.#resolveFeatures(feat.addons ?? [], false, depth + 1);
77
+
76
78
  yield feat;
77
79
  }
78
80
  }