@travetto/scaffold 3.0.4 → 3.1.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/scaffold",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.1.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.0.
|
|
31
|
-
"@travetto/compiler": "^3.0.
|
|
32
|
-
"@travetto/cli": "^3.0.
|
|
30
|
+
"@travetto/base": "^3.1.0-rc.0",
|
|
31
|
+
"@travetto/compiler": "^3.1.0-rc.0",
|
|
32
|
+
"@travetto/cli": "^3.1.0-rc.1",
|
|
33
33
|
"enquirer": "^2.3.6",
|
|
34
34
|
"mustache": "^4.2.0"
|
|
35
35
|
},
|
package/support/cli.scaffold.ts
CHANGED
|
@@ -1,37 +1,25 @@
|
|
|
1
1
|
import enquirer from 'enquirer';
|
|
2
2
|
|
|
3
3
|
import { path } from '@travetto/manifest';
|
|
4
|
-
import { CliCommand, cliTpl
|
|
4
|
+
import { CliCommandShape, CliCommand, cliTpl } from '@travetto/cli';
|
|
5
5
|
import { GlobalTerminal } from '@travetto/terminal';
|
|
6
6
|
|
|
7
7
|
import { Context } from './bin/context';
|
|
8
8
|
import { Feature, FEATURES } from './bin/features';
|
|
9
9
|
|
|
10
|
-
type Options = {
|
|
11
|
-
template: OptionConfig<string>;
|
|
12
|
-
cwd: OptionConfig<string>;
|
|
13
|
-
dir: OptionConfig<string>;
|
|
14
|
-
force: OptionConfig<boolean>;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
10
|
/**
|
|
18
11
|
* Command to run scaffolding
|
|
19
12
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
getArgs(): string {
|
|
33
|
-
return '[name]';
|
|
34
|
-
}
|
|
13
|
+
@CliCommand()
|
|
14
|
+
export class ScaffoldCommand implements CliCommandShape {
|
|
15
|
+
/** Template */
|
|
16
|
+
template = 'todo';
|
|
17
|
+
/** Current Working Directory override */
|
|
18
|
+
cwd: string = path.cwd();
|
|
19
|
+
/** Target Directory */
|
|
20
|
+
dir?: string;
|
|
21
|
+
/** Force writing into an existing directory */
|
|
22
|
+
force = false;
|
|
35
23
|
|
|
36
24
|
async #getName(name?: string): Promise<string> {
|
|
37
25
|
if (!name) {
|
|
@@ -88,42 +76,25 @@ export class ScaffoldCommand extends CliCommand<Options> {
|
|
|
88
76
|
}
|
|
89
77
|
}
|
|
90
78
|
|
|
91
|
-
async
|
|
92
|
-
|
|
93
|
-
name = await this.#getName(name);
|
|
94
|
-
} catch (err) {
|
|
95
|
-
if (err instanceof Error) {
|
|
96
|
-
console.error('Failed to provide correct input', err.message);
|
|
97
|
-
}
|
|
98
|
-
return this.exit(1);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
this.cmd.cwd ??= path.cwd();
|
|
79
|
+
async main(name?: string): Promise<void> {
|
|
80
|
+
name = await this.#getName(name);
|
|
102
81
|
|
|
103
|
-
if (!name && this.
|
|
104
|
-
name = path.basename(this.
|
|
105
|
-
} else if (name && !this.
|
|
106
|
-
this.
|
|
107
|
-
} else if (!name && !this.
|
|
108
|
-
|
|
109
|
-
return this.exit(1);
|
|
82
|
+
if (!name && this.dir) {
|
|
83
|
+
name = path.basename(this.dir);
|
|
84
|
+
} else if (name && !this.dir) {
|
|
85
|
+
this.dir = path.resolve(this.cwd, name);
|
|
86
|
+
} else if (!name && !this.dir) {
|
|
87
|
+
throw new Error('Either a name or a target directory are required');
|
|
110
88
|
}
|
|
111
89
|
|
|
112
|
-
const ctx = new Context(name, this.
|
|
90
|
+
const ctx = new Context(name, this.template, path.resolve(this.cwd, this.dir!));
|
|
113
91
|
|
|
114
|
-
if (!this.
|
|
92
|
+
if (!this.force) {
|
|
115
93
|
await ctx.initialize();
|
|
116
94
|
}
|
|
117
95
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
await ctx.resolveFeature(feature);
|
|
121
|
-
}
|
|
122
|
-
} catch (err) {
|
|
123
|
-
if (err instanceof Error) {
|
|
124
|
-
console.error('Failed to provide correct input', err.message);
|
|
125
|
-
}
|
|
126
|
-
return this.exit(1);
|
|
96
|
+
for await (const feature of this.#resolveFeatures(FEATURES)) {
|
|
97
|
+
await ctx.resolveFeature(feature);
|
|
127
98
|
}
|
|
128
99
|
|
|
129
100
|
console.log(cliTpl`\n${{ title: 'Creating Application' }}\n${'-'.repeat(30)}`);
|