create-vitrify 0.4.6 → 0.5.0

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.
Files changed (2) hide show
  1. package/dist/cli.js +37 -50
  2. 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 inquirer from 'inquirer';
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 questions = [];
11
+ let templateName = argv.template;
12
12
  if (!argv.template) {
13
- questions = [
14
- ...questions,
15
- {
16
- type: 'list',
17
- name: 'template',
18
- message: 'Which template would you like to use?',
19
- choices: Object.entries(templates).map(([key, value]) => ({
20
- name: value.fullName,
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
- questions = [
28
- ...questions,
29
- {
30
- type: 'input',
31
- name: 'name',
32
- message: 'Package name',
33
- validate: (val) => val && val.length > 0,
34
- default: (answers) => {
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
- type: 'input',
51
- name: 'description',
52
- message: 'Project description',
53
- default: 'A Vitrify app',
54
- transformer: escape
55
- },
56
- {
57
- type: 'input',
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 = answers;
45
+ const templateVariables = {
46
+ template: templateName,
47
+ name,
48
+ productName,
49
+ description,
50
+ author
51
+ };
65
52
  // @ts-ignore
66
- const template = templates[answers.template] || templates[argv.template];
53
+ const template = templates[templateName];
67
54
  const directoryUrl = template.url;
68
- const outputDir = new URL(`./${answers.name}/`, cwdUrl);
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.4.6",
3
+ "version": "0.5.0",
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.7",
24
+ "@vitrify/tools": "^0.2.0",
25
25
  "handlebars": "^4.7.8",
26
- "inquirer": "^9.2.23",
26
+ "@inquirer/prompts": "^6.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": "^20.14.2",
34
- "typescript": "^5.4.5",
35
- "vite": "^5.2.12",
36
- "vue": "^3.4.27"
32
+ "@types/node": "^22.6.1",
33
+ "typescript": "^5.6.2",
34
+ "vite": "^5.4.7",
35
+ "vue": "^3.5.8"
37
36
  },
38
37
  "files": [
39
38
  "dist",