@travetto/scaffold 7.1.2 → 7.1.4

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,12 +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 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
- * [express](https://expressjs.com)
30
- * [koa](https://koajs.com/)
31
- * [fastify](https://www.fastify.io/)
32
-
33
- The code will establish some basic endpoints, specifically, `GET / ` as the root endpoint. This will return the contents of your `package.json` as an identification operation.
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, leveraging [Web HTTP Server Support](https://github.com/travetto/travetto/tree/main/module/web-http#readme "Web HTTP Server Support"). The code will establish some basic endpoints, specifically, `GET / ` as the root endpoint. This will return the contents of your `package.json` as an identification operation.
34
29
 
35
30
  ### Additional Web Features
36
31
  In addition to the core functionality, the `web` feature has some useful sub-features. Specifically:
@@ -49,7 +44,9 @@ Authentication is also supported on the Web endpoints by selecting [Web Auth](ht
49
44
  The [Data Modeling Support](https://github.com/travetto/travetto/tree/main/module/model#readme "Datastore abstraction for core operations.") allows for modeling of application data, and provides mechanisms for storage and retrieval. When setting up your application, you will need to select which database backend you want to use:
50
45
  * [elasticsearch](https://elastic.co)
51
46
  * [mongodb](https://mongodb.com)
52
- * [SQL](https://en.wikipedia.org/wiki/SQL)
47
+ * [Postgres](https://postgresql.org)
48
+ * [MySQL](https://www.mysql.com/)
49
+ * [SQLite](https://www.sqlite.org/)
53
50
  * [DynamoDB](https://aws.amazon.com/dynamodb/)
54
51
  * [Firestore](https://firebase.google.com/docs/firestore)
55
52
 
@@ -6,7 +6,7 @@ import '@travetto/compiler/bin/hook.js';
6
6
 
7
7
  const current = process.cwd();
8
8
 
9
- if (process.env.npm_lifecycle_script?.includes('trv-scaffold')) { // Is npx run
9
+ if (process.env.npm_lifecycle_script?.includes('trv-scaffold')) { // Is global run (not installed)
10
10
  const folder = import.meta.dirname.split('node_modules')[0];
11
11
  const pkg = resolve(folder, 'package.json');
12
12
  writeFileSync(pkg, JSON.stringify({ ...JSON.parse(readFileSync(pkg, 'utf-8')), type: 'module' }));
@@ -14,4 +14,4 @@ if (process.env.npm_lifecycle_script?.includes('trv-scaffold')) { // Is npx run
14
14
  }
15
15
 
16
16
  const { invoke } = await import('@travetto/compiler/support/invoke.ts');
17
- await invoke('exec', ['@travetto/cli/support/entry.trv.js', 'scaffold', '-c', current, ...process.argv.slice(2)]);
17
+ await invoke('exec', ['@travetto/cli/support/entry.trv.ts', 'scaffold', '-c', current, ...process.argv.slice(2)]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/scaffold",
3
- "version": "7.1.2",
3
+ "version": "7.1.4",
4
4
  "type": "module",
5
5
  "description": "App Scaffold for the Travetto framework",
6
6
  "keywords": [
@@ -28,14 +28,14 @@
28
28
  "trv-scaffold": "bin/trv-scaffold.js"
29
29
  },
30
30
  "dependencies": {
31
- "@travetto/cli": "^7.1.2",
32
- "@travetto/compiler": "^7.1.1",
33
- "@travetto/runtime": "^7.1.2",
31
+ "@travetto/cli": "^7.1.4",
32
+ "@travetto/compiler": "^7.1.3",
33
+ "@travetto/runtime": "^7.1.4",
34
34
  "enquirer": "^2.4.1",
35
35
  "mustache": "^4.2.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@travetto/model": "^7.1.2",
38
+ "@travetto/model": "^7.1.4",
39
39
  "@types/mustache": "^4.2.6"
40
40
  },
41
41
  "travetto": {
@@ -25,11 +25,11 @@
25
25
  ],
26
26
  "license": "MIT",
27
27
  "scripts": {
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"
28
+ "build": "trvc build",
29
+ {{#module_web}}"start": "trv web:http",{{/module_web}}
30
+ {{#module_test}}"test": "trv test",{{/module_test}}
31
+ {{#module_eslint}}"lint": "trv eslint",{{/module_eslint}}
32
+ "watch": "trvc watch"
33
33
  },
34
34
  "files": [
35
35
  "src",
@@ -1,5 +1,5 @@
1
1
  import fs from 'node:fs/promises';
2
- import { spawn } from 'node:child_process';
2
+ import { spawn, type ChildProcess, type SpawnOptions } from 'node:child_process';
3
3
  import path from 'node:path';
4
4
 
5
5
  import mustache from 'mustache';
@@ -52,9 +52,11 @@ export class Context {
52
52
  this.#targetDirectory = path.resolve(targetDirectory);
53
53
  }
54
54
 
55
- #exec(cmd: string, args: string[]): Promise<void> {
55
+ #exec(cmd: string, args: string[], options?: { spawn?: (cmd: string, args: string[], options?: SpawnOptions) => ChildProcess }): Promise<void> {
56
56
  const terminal = new Terminal();
57
- const subProcess = spawn(cmd, args, {
57
+ const spawnCmd = options?.spawn ?? spawn;
58
+ const subProcess = spawnCmd(cmd, args, {
59
+ ...options,
58
60
  cwd: this.destination(),
59
61
  stdio: [0, 'pipe', 'pipe'],
60
62
  env: { PATH: process.env.PATH },
@@ -194,21 +196,21 @@ export class Context {
194
196
  switch (this.packageManager) {
195
197
  case 'npm': await this.#exec('npm', ['i']); break;
196
198
  case 'yarn': await this.#exec('yarn', []); break;
197
- default: throw new Error(`Unknown package manager: ${this.packageManager} `);
199
+ case 'pnpm': await this.#exec('pnpm', ['install']); break;
198
200
  }
199
201
 
200
202
  yield cliTpl`${{ type: 'Ensuring latest dependencies' }} `;
201
203
  switch (this.packageManager) {
202
204
  case 'npm': await this.#exec('npm', ['update', '-S']); break;
203
205
  case 'yarn': await this.#exec('yarn', ['upgrade']); break;
204
- default: throw new Error(`Unknown package manager: ${this.packageManager} `);
206
+ case 'pnpm': await this.#exec('pnpm', ['update', '--latest']); break;
205
207
  }
206
208
 
207
209
  yield cliTpl`${{ type: 'Initial Build' }} `;
208
- await this.#exec('npx', ['trvc', 'build']);
210
+ await this.#exec('trvc', ['build'], { spawn: ExecUtil.spawnPackageCommand });
209
211
  if (this.#devDependencies.includes('@travetto/eslint')) {
210
212
  yield cliTpl`${{ type: 'ESLint Registration' }} `;
211
- await this.#exec('npx', ['trv', 'eslint:register']);
213
+ await this.#exec('trv', ['eslint:register'], { spawn: ExecUtil.spawnPackageCommand });
212
214
  }
213
215
 
214
216
  yield cliTpl`${{ success: 'Successfully created' }} at ${{ path: this.#targetDirectory }} `;
@@ -1,3 +1,5 @@
1
+ import { PACKAGE_MANAGERS } from '@travetto/manifest';
2
+
1
3
  export type Feature = {
2
4
  title?: string;
3
5
  package?: string | string[];
@@ -15,10 +17,7 @@ export type Feature = {
15
17
  export const FEATURES: Feature[] = [
16
18
  {
17
19
  title: 'Package Manager',
18
- choices: [
19
- { title: 'NPM', field: 'packageManager', value: 'npm' },
20
- { title: 'Yarn', field: 'packageManager', value: 'yarn' }
21
- ],
20
+ choices: PACKAGE_MANAGERS.map(manager => ({ title: manager.title, field: 'packageManager', value: manager.type })),
22
21
  required: true,
23
22
  default: 'npm'
24
23
  },