create-vitrify 0.4.5 → 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 (3) hide show
  1. package/LICENCE +7 -0
  2. package/dist/cli.js +37 -50
  3. package/package.json +13 -14
package/LICENCE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2022-present Stefan van Herwijnen
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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,16 +1,12 @@
1
1
  {
2
2
  "name": "create-vitrify",
3
- "version": "0.4.5",
3
+ "version": "0.5.0",
4
4
  "license": "MIT",
5
5
  "author": "Stefan van Herwijnen",
6
6
  "type": "module",
7
7
  "bin": {
8
8
  "create-vitrify": "dist/cli.js"
9
9
  },
10
- "scripts": {
11
- "build": "tsc",
12
- "test": "echo \"Error: no test specified\" && exit 0"
13
- },
14
10
  "main": "dist/cli.js",
15
11
  "engines": {
16
12
  "node": ">=16.0.0"
@@ -25,19 +21,18 @@
25
21
  },
26
22
  "homepage": "https://github.com/simsustech/vitrify/tree/main/packages/create-vitrify#readme",
27
23
  "dependencies": {
28
- "@vitrify/tools": "^0.1.6",
24
+ "@vitrify/tools": "^0.2.0",
29
25
  "handlebars": "^4.7.8",
30
- "inquirer": "^9.2.14",
31
- "latest-version": "^8.0.0",
26
+ "@inquirer/prompts": "^6.0.1",
27
+ "latest-version": "^9.0.0",
32
28
  "minimist": "^1.2.8"
33
29
  },
34
30
  "devDependencies": {
35
- "@types/inquirer": "^9.0.7",
36
31
  "@types/minimist": "^1.2.5",
37
- "@types/node": "^20.11.19",
38
- "typescript": "^5.3.3",
39
- "vite": "^5.1.3",
40
- "vue": "^3.4.19"
32
+ "@types/node": "^22.6.1",
33
+ "typescript": "^5.6.2",
34
+ "vite": "^5.4.7",
35
+ "vue": "^3.5.8"
41
36
  },
42
37
  "files": [
43
38
  "dist",
@@ -46,5 +41,9 @@
46
41
  "publishConfig": {
47
42
  "access": "public",
48
43
  "registry": "https://registry.npmjs.org/"
44
+ },
45
+ "scripts": {
46
+ "build": "tsc",
47
+ "test": "echo \"Error: no test specified\" && exit 0"
49
48
  }
50
- }
49
+ }