@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.
package/bin/trv-scaffold.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/scaffold",
|
|
3
|
-
"version": "
|
|
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": "^
|
|
31
|
-
"@travetto/cli": "^
|
|
32
|
-
"@travetto/compiler": "^
|
|
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
|
},
|
package/support/bin/context.ts
CHANGED
|
@@ -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 {
|
|
6
|
-
import {
|
|
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:
|
|
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<
|
|
54
|
-
const
|
|
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
|
-
|
|
58
|
-
|
|
59
|
-
})
|
|
59
|
+
shell: false,
|
|
60
|
+
env: { PATH: process.env.PATH },
|
|
61
|
+
});
|
|
60
62
|
|
|
61
|
-
|
|
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
|
|
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:
|
|
118
|
+
frameworkVersion: frameworkVersion.replace(/[.]\d+$/, '.0'),
|
|
109
119
|
name: this.name,
|
|
110
120
|
modules,
|
|
111
121
|
moduleNames,
|
package/support/cli.scaffold.ts
CHANGED
|
@@ -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 {
|
|
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
|
|
103
|
-
position: 'inline',
|
|
104
|
-
end: false,
|
|
105
|
-
committedPrefix: '>',
|
|
106
|
-
cycleDelay: 100
|
|
107
|
-
});
|
|
102
|
+
await new Terminal().streamLines(ctx.install());
|
|
108
103
|
}
|
|
109
104
|
}
|