@travetto/scaffold 6.0.0 → 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/README.md CHANGED
@@ -25,7 +25,7 @@ $ npx @travetto/scaffold@<version-or-tag>
25
25
  The generator will ask about enabling the following features:
26
26
 
27
27
  ## Web Application
28
- The [Web API](https://github.com/travetto/travetto/tree/main/module/web#readme "Declarative api for Web Applications with support for the dependency injection.") provides the necessary integration for exposing web apis. When selecting the `web` feature, you will need to specify which backend you want to include with your application, the default being [express](https://expressjs.com). Currently you can select from:
28
+ The [Web API](https://github.com/travetto/travetto/tree/main/module/web#readme "Declarative support for creating Web Applications") provides the necessary integration for exposing web apis. When selecting the `web` feature, you will need to specify which backend you want to include with your application, the default being [express](https://expressjs.com). Currently you can select from:
29
29
  * [express](https://expressjs.com)
30
30
  * [koa](https://koajs.com/)
31
31
  * [fastify](https://www.fastify.io/)
@@ -2,7 +2,7 @@
2
2
  // @ts-check
3
3
 
4
4
  async function getScaffoldCwd() {
5
- if (process.env.npm_lifecycle_script === 'trv-scaffold') { // Is npx run
5
+ if (process.env.npm_lifecycle_script?.includes('trv-scaffold')) { // Is npx run
6
6
  const { delimiter } = await import('node:path');
7
7
  const parts = process.env.PATH?.split(delimiter) ?? [];
8
8
  const loc = parts.find(p => p.includes('npx') && p.includes('.bin'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/scaffold",
3
- "version": "6.0.0",
3
+ "version": "7.0.0-rc.0",
4
4
  "description": "App Scaffold for the Travetto framework",
5
5
  "keywords": [
6
6
  "generator",
@@ -27,14 +27,14 @@
27
27
  "trv-scaffold": "bin/trv-scaffold.js"
28
28
  },
29
29
  "dependencies": {
30
- "@travetto/cli": "^6.0.0",
31
- "@travetto/runtime": "^6.0.0",
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.0",
37
- "@types/mustache": "^4.2.5"
36
+ "@travetto/model": "^7.0.0-rc.0",
37
+ "@types/mustache": "^4.2.6"
38
38
  },
39
39
  "travetto": {
40
40
  "displayName": "App Scaffold"
@@ -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",
@@ -1,7 +1,7 @@
1
1
  # {{#modules.web}}
2
2
  web:
3
- http.ssl:
4
- active: false
3
+ http:
4
+ tls: false
5
5
  context:
6
6
  active: true
7
7
  cors:
@@ -57,7 +57,6 @@ export class Context {
57
57
  const proc = spawn(cmd, args, {
58
58
  cwd: this.destination(),
59
59
  stdio: [0, 'pipe', 'pipe'],
60
- shell: false,
61
60
  env: { PATH: process.env.PATH },
62
61
  });
63
62
 
@@ -117,14 +116,18 @@ export class Context {
117
116
  PackageUtil.resolveImport('@travetto/manifest/package.json')
118
117
  );
119
118
 
120
- const context = Object.assign({
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
- }, ...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
+ );
128
131
 
129
132
  return context;
130
133
  }
@@ -204,7 +207,7 @@ export class Context {
204
207
  await this.#exec('npx', ['trvc', 'build']);
205
208
  if (this.#devDependencies.includes('@travetto/eslint')) {
206
209
  yield cliTpl`${{ type: 'ESLint Registration' }} `;
207
- await this.#exec('npx', ['trv', 'lint:register']);
210
+ await this.#exec('npx', ['trv', 'eslint:register']);
208
211
  }
209
212
 
210
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
  }