@travetto/scaffold 3.4.10 → 4.0.0-rc.1

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.
@@ -13,5 +13,5 @@
13
13
  }
14
14
  }
15
15
  process.argv = args;
16
- await import('@travetto/compiler/bin/trv.js');
16
+ await import('@travetto/cli/bin/trv.js');
17
17
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/scaffold",
3
- "version": "3.4.10",
3
+ "version": "4.0.0-rc.1",
4
4
  "description": "App Scaffold for the Travetto framework",
5
5
  "keywords": [
6
6
  "generator",
@@ -27,9 +27,9 @@
27
27
  "trv-scaffold": "./bin/trv-scaffold.js"
28
28
  },
29
29
  "dependencies": {
30
- "@travetto/base": "^3.4.2",
31
- "@travetto/cli": "^3.4.10",
32
- "@travetto/compiler": "^3.4.3",
30
+ "@travetto/base": "^4.0.0-rc.1",
31
+ "@travetto/cli": "^4.0.0-rc.1",
32
+ "@travetto/compiler": "^4.0.0-rc.1",
33
33
  "enquirer": "^2.4.1",
34
34
  "mustache": "^4.2.0"
35
35
  },
@@ -1,4 +1,4 @@
1
- import assert from 'assert';
1
+ import assert from 'node:assert';
2
2
 
3
3
  import { Suite, Test } from '@travetto/test';
4
4
  import { ModelCrudSupport } from '@travetto/model';
@@ -1,10 +1,11 @@
1
- import fs from 'fs/promises';
1
+ import fs from 'node:fs/promises';
2
+ import { spawn } from 'node:child_process';
2
3
  import mustache from 'mustache';
3
4
 
5
+ import { ExecUtil, StreamUtil } from '@travetto/base';
4
6
  import { cliTpl } from '@travetto/cli';
5
- import { ManifestContext, path, RootIndex } from '@travetto/manifest';
6
- import { ExecUtil, ExecutionResult } from '@travetto/base';
7
- import { GlobalTerminal } from '@travetto/terminal';
7
+ import { path, RuntimeIndex, NodePackageManager, PackageUtil } from '@travetto/manifest';
8
+ import { Terminal } from '@travetto/terminal';
8
9
 
9
10
  import { Feature } from './features';
10
11
 
@@ -40,7 +41,7 @@ export class Context {
40
41
  #peerDependencies: string[] = [];
41
42
  #featureContexts: Record<string, unknown>[] = [];
42
43
 
43
- packageManager: ManifestContext['packageManager'] = 'npm';
44
+ packageManager: NodePackageManager = 'npm';
44
45
 
45
46
  readonly name: string;
46
47
 
@@ -50,19 +51,23 @@ export class Context {
50
51
  this.#targetDir = path.resolve(targetDir);
51
52
  }
52
53
 
53
- #exec(cmd: string, args: string[]): Promise<ExecutionResult> {
54
- const res = ExecUtil.spawn(cmd, args, {
54
+ #exec(cmd: string, args: string[]): Promise<void> {
55
+ const term = new Terminal();
56
+ const proc = spawn(cmd, args, {
55
57
  cwd: this.destination(),
56
58
  stdio: [0, 'pipe', 'pipe'],
57
- isolatedEnv: true,
58
- onStdErrorLine: line => GlobalTerminal.writeLines(cliTpl` ${{ identifier: [cmd, ...args].join(' ') }}: ${line}`)
59
- }).result;
59
+ shell: false,
60
+ env: { PATH: process.env.PATH },
61
+ });
60
62
 
61
- return res;
63
+ StreamUtil.onLine(proc.stderr,
64
+ line => term.writer.writeLine(cliTpl` ${{ identifier: [cmd, ...args].join(' ') }}: ${line}`).commit());
65
+
66
+ return ExecUtil.getResult(proc).then(() => { });
62
67
  }
63
68
 
64
69
  get selfPath(): string {
65
- return RootIndex.getModule('@travetto/scaffold')!.sourcePath;
70
+ return RuntimeIndex.getModule('@travetto/scaffold')!.sourcePath;
66
71
  }
67
72
 
68
73
  source(file?: string): string {
@@ -104,8 +109,13 @@ export class Context {
104
109
  .map(x => path.basename(x)).reduce((acc, v) => ({ ...acc, [v.replace(/[-]/g, '_')]: true }), {});
105
110
  const moduleNames = [...Object.keys(modules)];
106
111
 
112
+ /** Get framework version at runtime */
113
+ const { version: frameworkVersion } = PackageUtil.readPackage(
114
+ PackageUtil.resolveImport('@travetto/manifest/package.json')
115
+ );
116
+
107
117
  const context = Object.assign({
108
- frameworkVersion: RootIndex.manifest.frameworkVersion.replace(/[.]\d+$/, '.0'),
118
+ frameworkVersion: frameworkVersion.replace(/[.]\d+$/, '.0'),
109
119
  name: this.name,
110
120
  modules,
111
121
  moduleNames,
@@ -2,7 +2,7 @@ import enquirer from 'enquirer';
2
2
 
3
3
  import { path } from '@travetto/manifest';
4
4
  import { CliCommandShape, CliCommand, cliTpl } from '@travetto/cli';
5
- import { GlobalTerminal } from '@travetto/terminal';
5
+ import { Terminal } from '@travetto/terminal';
6
6
 
7
7
  import { Context } from './bin/context';
8
8
  import { Feature, FEATURES } from './bin/features';
@@ -99,11 +99,6 @@ export class ScaffoldCommand implements CliCommandShape {
99
99
 
100
100
  console.log(cliTpl`\n${{ title: 'Creating Application' }}\n${'-'.repeat(30)}`);
101
101
 
102
- await GlobalTerminal.streamLinesWithWaiting(ctx.install(), {
103
- position: 'inline',
104
- end: false,
105
- committedPrefix: '>',
106
- cycleDelay: 100
107
- });
102
+ await new Terminal().streamLines(ctx.install());
108
103
  }
109
104
  }