create-vitrify 0.4.6 → 0.5.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/dist/cli.js +37 -50
- package/package.json +7 -8
package/dist/cli.js
CHANGED
@@ -1,71 +1,58 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
import { renderDirectory, renderPackageJson, renderTsconfigJson } from '@vitrify/tools/render';
|
3
3
|
import parseArgs from 'minimist';
|
4
|
-
import
|
4
|
+
import { input, rawlist } from '@inquirer/prompts';
|
5
5
|
import { promises } from 'fs';
|
6
6
|
import { templates } from './templates.js';
|
7
7
|
const escape = (val) => JSON.stringify(val).slice(1, -1);
|
8
8
|
const argv = parseArgs(process.argv.slice(2), {
|
9
9
|
string: ['template']
|
10
10
|
});
|
11
|
-
let
|
11
|
+
let templateName = argv.template;
|
12
12
|
if (!argv.template) {
|
13
|
-
|
14
|
-
|
15
|
-
{
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
value: key,
|
22
|
-
short: value.description
|
23
|
-
}))
|
24
|
-
}
|
25
|
-
];
|
13
|
+
templateName = await rawlist({
|
14
|
+
message: 'Which template would you like to use?',
|
15
|
+
choices: Object.entries(templates).map(([key, value]) => ({
|
16
|
+
name: value.fullName,
|
17
|
+
value: key,
|
18
|
+
short: value.description
|
19
|
+
}))
|
20
|
+
});
|
26
21
|
}
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
return argv._[0];
|
36
|
-
}
|
37
|
-
},
|
38
|
-
{
|
39
|
-
type: 'input',
|
40
|
-
name: 'productName',
|
22
|
+
const name = await input({
|
23
|
+
message: 'Package name',
|
24
|
+
validate: (val) => val && val.length > 0,
|
25
|
+
default: argv._[0]
|
26
|
+
});
|
27
|
+
let productName = 'App';
|
28
|
+
if (templateName !== 'plugin') {
|
29
|
+
productName = await input({
|
41
30
|
message: 'Project product name',
|
42
31
|
default: 'App',
|
43
|
-
when: (answers) => {
|
44
|
-
return answers.template !== 'plugin';
|
45
|
-
},
|
46
32
|
validate: (val) => val && val.length > 0,
|
47
33
|
transformer: escape
|
48
|
-
}
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
name: 'author',
|
59
|
-
message: 'Author'
|
60
|
-
}
|
61
|
-
];
|
62
|
-
const answers = await inquirer.prompt(questions);
|
34
|
+
});
|
35
|
+
}
|
36
|
+
const description = await input({
|
37
|
+
message: 'Project description',
|
38
|
+
default: 'A Vitrify app',
|
39
|
+
transformer: escape
|
40
|
+
});
|
41
|
+
const author = await input({
|
42
|
+
message: 'Author'
|
43
|
+
});
|
63
44
|
const cwdUrl = new URL('', `file://${process.cwd()}/`);
|
64
|
-
const templateVariables =
|
45
|
+
const templateVariables = {
|
46
|
+
template: templateName,
|
47
|
+
name,
|
48
|
+
productName,
|
49
|
+
description,
|
50
|
+
author
|
51
|
+
};
|
65
52
|
// @ts-ignore
|
66
|
-
const template = templates[
|
53
|
+
const template = templates[templateName];
|
67
54
|
const directoryUrl = template.url;
|
68
|
-
const outputDir = new URL(`./${
|
55
|
+
const outputDir = new URL(`./${name}/`, cwdUrl);
|
69
56
|
await renderDirectory({
|
70
57
|
directoryUrl,
|
71
58
|
templateVariables,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "create-vitrify",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.5.1",
|
4
4
|
"license": "MIT",
|
5
5
|
"author": "Stefan van Herwijnen",
|
6
6
|
"type": "module",
|
@@ -21,19 +21,18 @@
|
|
21
21
|
},
|
22
22
|
"homepage": "https://github.com/simsustech/vitrify/tree/main/packages/create-vitrify#readme",
|
23
23
|
"dependencies": {
|
24
|
-
"@vitrify/tools": "^0.1
|
24
|
+
"@vitrify/tools": "^0.2.1",
|
25
25
|
"handlebars": "^4.7.8",
|
26
|
-
"inquirer": "^
|
26
|
+
"@inquirer/prompts": "^7.0.1",
|
27
27
|
"latest-version": "^9.0.0",
|
28
28
|
"minimist": "^1.2.8"
|
29
29
|
},
|
30
30
|
"devDependencies": {
|
31
|
-
"@types/inquirer": "^9.0.7",
|
32
31
|
"@types/minimist": "^1.2.5",
|
33
|
-
"@types/node": "^
|
34
|
-
"typescript": "^5.
|
35
|
-
"vite": "^5.
|
36
|
-
"vue": "^3.
|
32
|
+
"@types/node": "^22.8.1",
|
33
|
+
"typescript": "^5.6.3",
|
34
|
+
"vite": "^5.4.10",
|
35
|
+
"vue": "^3.5.12"
|
37
36
|
},
|
38
37
|
"files": [
|
39
38
|
"dist",
|