@travetto/scaffold 7.0.4 → 7.0.6

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
@@ -57,7 +57,7 @@ A default model is constructed, a [Todo](https://github.com/travetto/travetto/tr
57
57
 
58
58
  **Code: Todo Model**
59
59
  ```typescript
60
- import { Model, ModelType } from '@travetto/model';
60
+ import { Model, type ModelType } from '@travetto/model';
61
61
 
62
62
  @Model()
63
63
  export class Todo implements ModelType {
@@ -78,7 +78,7 @@ In the case both `web` and `model` features are enabled, the code will produce a
78
78
  import { Controller, Get, Put, Post, Delete } from '@travetto/web';
79
79
  import { NotFoundError } from '@travetto/model';
80
80
  import { Inject } from '@travetto/di';
81
- import { ModelQuery, ModelQueryCrudSupport } from '@travetto/model-query';
81
+ import type { ModelQuery, ModelQueryCrudSupport } from '@travetto/model-query';
82
82
  import { Schema } from '@travetto/schema';
83
83
 
84
84
  import { Todo } from './model.ts';
@@ -1,48 +1,29 @@
1
1
  #!/usr/bin/env node
2
2
  // @ts-check
3
+ import { delimiter } from 'node:path';
4
+ import fs from 'node:fs';
5
+ import { spawn, execSync } from 'node:child_process';
3
6
 
4
- async function getModuleDirectory() {
5
- if (process.env.npm_lifecycle_script?.includes('trv-scaffold')) { // Is npx run
6
- const { delimiter } = await import('node:path');
7
- const parts = process.env.PATH?.split(delimiter) ?? [];
8
- const loc = parts.find(part => part.includes('npx') && part.includes('.bin'));
9
- if (loc) {
10
- return loc.split('/node_modules')[0];
11
- }
12
- }
13
- return process.cwd();
14
- }
7
+ let workingDirectory = process.cwd();
15
8
 
16
- /**
17
- * @param {string} workingDirectory
18
- */
19
- async function getVersion(workingDirectory) {
20
- const fs = await import('node:fs/promises');
21
- const pkg = JSON.parse(await fs.readFile(`${workingDirectory}/package.json`, 'utf8'));
22
- const version = `${pkg.dependencies['@travetto/scaffold']}`.replace(/\d+$/, '0');
23
- return version;
9
+ if (process.env.npm_lifecycle_script?.includes('trv-scaffold')) { // Is npx run
10
+ const parts = process.env.PATH?.split(delimiter) ?? [];
11
+ const item = parts.find(part => part.includes('npx') && part.includes('.bin'));
12
+ if (item) {
13
+ workingDirectory = item.split('/node_modules')[0];
14
+ }
24
15
  }
25
16
 
26
- (async function () {
27
- const workingDirectory = await getModuleDirectory();
28
- const version = await getVersion(workingDirectory);
29
-
30
- const { spawn, execSync } = await import('node:child_process');
31
- // Ensure we install the compiler first
32
- execSync(`npm i @travetto/compiler@${version}`, { stdio: 'pipe', cwd: workingDirectory });
17
+ const pkg = JSON.parse(fs.readFileSync(`${workingDirectory}/package.json`, 'utf8'));
18
+ const pkgVersion = `${pkg.dependencies?.['@travetto/scaffold']}`.replace(/\d+$/, '0');
33
19
 
34
- spawn('npx', [
35
- 'trvc', 'exec',
36
- '@travetto/cli/support/entry.trv.js',
37
- 'scaffold',
38
- '-c', process.cwd(),
39
- ...process.argv.slice(2)
40
- ], {
41
- stdio: 'inherit',
42
- cwd: workingDirectory,
43
- env: {
44
- ...process.env,
45
- TRV_QUIET: '1',
46
- }
47
- });
48
- })();
20
+ // Ensure we install the compiler first
21
+ execSync(`npm i @travetto/compiler@${pkgVersion}`, { stdio: 'pipe', cwd: workingDirectory });
22
+ spawn('npx', [
23
+ 'trvc', 'exec', '@travetto/cli/support/entry.trv.js',
24
+ 'scaffold', '-c', process.cwd(), ...process.argv.slice(2)
25
+ ], {
26
+ stdio: 'inherit',
27
+ cwd: workingDirectory,
28
+ env: { ...process.env, TRV_QUIET: '1', }
29
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/scaffold",
3
- "version": "7.0.4",
3
+ "version": "7.0.6",
4
4
  "type": "module",
5
5
  "description": "App Scaffold for the Travetto framework",
6
6
  "keywords": [
@@ -28,13 +28,13 @@
28
28
  "trv-scaffold": "bin/trv-scaffold.js"
29
29
  },
30
30
  "dependencies": {
31
- "@travetto/cli": "^7.0.4",
32
- "@travetto/runtime": "^7.0.3",
31
+ "@travetto/cli": "^7.0.6",
32
+ "@travetto/runtime": "^7.0.4",
33
33
  "enquirer": "^2.4.1",
34
34
  "mustache": "^4.2.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@travetto/model": "^7.0.4",
37
+ "@travetto/model": "^7.0.5",
38
38
  "@types/mustache": "^4.2.6"
39
39
  },
40
40
  "travetto": {
@@ -6,10 +6,10 @@ import mustache from 'mustache';
6
6
 
7
7
  import { castKey, castTo, ExecUtil, JSONUtil, RuntimeIndex } from '@travetto/runtime';
8
8
  import { cliTpl } from '@travetto/cli';
9
- import { NodePackageManager, PackageUtil } from '@travetto/manifest';
9
+ import { type NodePackageManager, PackageUtil } from '@travetto/manifest';
10
10
  import { Terminal } from '@travetto/terminal';
11
11
 
12
- import { Feature } from './features.ts';
12
+ import type { Feature } from './features.ts';
13
13
 
14
14
  type ListingEntry = { requires?: string[], rename?: string };
15
15
  type Listing = Record<string, ListingEntry>;
@@ -26,8 +26,8 @@ export class Context {
26
26
 
27
27
  static #meetsRequirement(modules: string[], desired: string[]): boolean {
28
28
  let valid = true;
29
- for (const mod of desired) {
30
- valid = valid && modules.includes(mod);
29
+ for (const module of desired) {
30
+ valid = valid && modules.includes(module);
31
31
  if (!valid) {
32
32
  break;
33
33
  }
@@ -108,7 +108,7 @@ export class Context {
108
108
 
109
109
  templateContext(): Record<string, unknown> {
110
110
  const modules = [...this.#dependencies, ...this.#devDependencies]
111
- .map(mod => path.basename(mod))
111
+ .map(module => path.basename(module))
112
112
  .reduce((ctx, value) => ({ ...ctx, [value.replace(/[-]/g, '_')]: true }), {});
113
113
  const moduleNames = [...Object.keys(modules)];
114
114
 
@@ -127,7 +127,7 @@ export class Context {
127
127
  devDependencies: [...new Set(this.#devDependencies)].toSorted((a, b) => a.localeCompare(b)),
128
128
  },
129
129
  ...this.#featureContexts,
130
- ...moduleNames.map(mod => ({ [`module_${mod}`]: true }))
130
+ ...moduleNames.map(module => ({ [`module_${module}`]: true }))
131
131
  );
132
132
 
133
133
  return context;
@@ -4,11 +4,11 @@ import * as enquirer from 'enquirer';
4
4
 
5
5
  const { prompt } = enquirer.default;
6
6
 
7
- import { CliCommandShape, CliCommand, cliTpl, CliFlag } from '@travetto/cli';
7
+ import { type CliCommandShape, CliCommand, cliTpl, CliFlag } from '@travetto/cli';
8
8
  import { Terminal } from '@travetto/terminal';
9
9
 
10
10
  import { Context } from './bin/context.ts';
11
- import { Feature, FEATURES } from './bin/features.ts';
11
+ import { type Feature, FEATURES } from './bin/features.ts';
12
12
 
13
13
  /**
14
14
  * Command to run scaffolding