@varlet/cli 3.5.1-alpha.1726764162524 ā 3.5.2
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/lib/node/commands/create.js +8 -14
- package/lib/node/commands/gen.js +12 -15
- package/package.json +10 -11
|
@@ -2,13 +2,12 @@ import ejs from 'ejs';
|
|
|
2
2
|
import fse from 'fs-extra';
|
|
3
3
|
import logger from '../shared/logger.js';
|
|
4
4
|
import { bigCamelize, camelize, kebabCase } from '@varlet/shared';
|
|
5
|
-
import
|
|
5
|
+
import { input, confirm, select } from '@inquirer/prompts';
|
|
6
6
|
import { resolve } from 'path';
|
|
7
7
|
import { glob } from '../shared/fsUtils.js';
|
|
8
8
|
import { getVarletConfig } from '../config/varlet.config.js';
|
|
9
9
|
import { SRC_DIR, dirname } from '../shared/constant.js';
|
|
10
10
|
const { removeSync, readFileSync, copySync, pathExistsSync, writeFileSync, renameSync } = fse;
|
|
11
|
-
const { prompt } = inquirer;
|
|
12
11
|
async function renderTemplates(componentFolder, componentFolderName, renderData) {
|
|
13
12
|
const templates = await glob(`${componentFolder}/**/*.ejs`);
|
|
14
13
|
templates.forEach((template) => {
|
|
@@ -33,10 +32,9 @@ export async function create(options) {
|
|
|
33
32
|
camelizeName: 'componentName',
|
|
34
33
|
style: 'vue',
|
|
35
34
|
};
|
|
36
|
-
const
|
|
37
|
-
? options
|
|
38
|
-
: await
|
|
39
|
-
name: 'name',
|
|
35
|
+
const name = options.name
|
|
36
|
+
? options.name
|
|
37
|
+
: await input({
|
|
40
38
|
message: 'Name of the component created: ',
|
|
41
39
|
default: renderData.kebabCaseName,
|
|
42
40
|
});
|
|
@@ -49,11 +47,9 @@ export async function create(options) {
|
|
|
49
47
|
logger.warning(`${componentFolderName} already exist and cannot be recreated...`);
|
|
50
48
|
return;
|
|
51
49
|
}
|
|
52
|
-
const
|
|
53
|
-
? options
|
|
54
|
-
: await
|
|
55
|
-
name: 'locale',
|
|
56
|
-
type: 'confirm',
|
|
50
|
+
const locale = options.locale
|
|
51
|
+
? options.locale
|
|
52
|
+
: await confirm({
|
|
57
53
|
message: 'Whether to use i18n?',
|
|
58
54
|
default: false,
|
|
59
55
|
});
|
|
@@ -63,9 +59,7 @@ export async function create(options) {
|
|
|
63
59
|
renderData.style = options.sfc ? 'vue' : 'tsx';
|
|
64
60
|
}
|
|
65
61
|
else {
|
|
66
|
-
const
|
|
67
|
-
name: 'style',
|
|
68
|
-
type: 'list',
|
|
62
|
+
const style = await select({
|
|
69
63
|
message: 'Which style do you use to write your component ?',
|
|
70
64
|
choices: [
|
|
71
65
|
{ name: 'sfc', value: 'vue' },
|
package/lib/node/commands/gen.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import logger from '../shared/logger.js';
|
|
2
2
|
import fse from 'fs-extra';
|
|
3
|
-
import
|
|
3
|
+
import { input, confirm, select } from '@inquirer/prompts';
|
|
4
4
|
import { resolve } from 'path';
|
|
5
5
|
import { CLI_PACKAGE_JSON, CWD, GENERATORS_DIR } from '../shared/constant.js';
|
|
6
6
|
const { copy, pathExistsSync, readFileSync, writeFileSync, rename } = fse;
|
|
7
|
-
const { prompt } = inquirer;
|
|
8
7
|
function syncVersion(name) {
|
|
9
8
|
const file = resolve(CWD, name, 'package.json');
|
|
10
9
|
const pkg = JSON.parse(readFileSync(file, 'utf-8'));
|
|
@@ -19,10 +18,9 @@ function syncVersion(name) {
|
|
|
19
18
|
}
|
|
20
19
|
export async function gen(options) {
|
|
21
20
|
logger.title('\nš¦š¦ Generate cli application ! \n');
|
|
22
|
-
const
|
|
23
|
-
? options
|
|
24
|
-
: await
|
|
25
|
-
name: 'name',
|
|
21
|
+
const name = options.name
|
|
22
|
+
? options.name
|
|
23
|
+
: await input({
|
|
26
24
|
message: 'Name of the generate application: ',
|
|
27
25
|
default: 'varlet-cli-app',
|
|
28
26
|
});
|
|
@@ -37,19 +35,18 @@ export async function gen(options) {
|
|
|
37
35
|
codeStyle = options.sfc ? 'sfc' : 'tsx';
|
|
38
36
|
}
|
|
39
37
|
else {
|
|
40
|
-
const
|
|
41
|
-
name: 'style',
|
|
42
|
-
type: 'list',
|
|
38
|
+
const style = await select({
|
|
43
39
|
message: 'Please select your component library programming format',
|
|
44
|
-
choices: [
|
|
40
|
+
choices: [
|
|
41
|
+
{ name: 'sfc', value: 'sfc' },
|
|
42
|
+
{ name: 'tsx', value: 'tsx' },
|
|
43
|
+
],
|
|
45
44
|
});
|
|
46
45
|
codeStyle = style;
|
|
47
46
|
}
|
|
48
|
-
const
|
|
49
|
-
? options
|
|
50
|
-
: await
|
|
51
|
-
name: 'i18n',
|
|
52
|
-
type: 'confirm',
|
|
47
|
+
const i18n = options.i18n
|
|
48
|
+
? options.i18n
|
|
49
|
+
: await confirm({
|
|
53
50
|
message: 'Whether to use i18n?',
|
|
54
51
|
default: false,
|
|
55
52
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/cli",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "cli of varlet",
|
|
6
6
|
"bin": {
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@babel/core": "^7.25.2",
|
|
37
37
|
"@babel/preset-typescript": "^7.24.7",
|
|
38
|
+
"@inquirer/prompts": "^6.0.1",
|
|
38
39
|
"@varlet/icon-builder": "0.2.14",
|
|
39
40
|
"@varlet/release": "^0.2.5",
|
|
40
41
|
"@vitejs/plugin-vue": "5.1.4",
|
|
@@ -50,7 +51,6 @@
|
|
|
50
51
|
"fs-extra": "^9.0.1",
|
|
51
52
|
"glob": "^7.2.0",
|
|
52
53
|
"hash-sum": "^2.0.0",
|
|
53
|
-
"inquirer": "^9.1.4",
|
|
54
54
|
"less": "^3.12.2",
|
|
55
55
|
"markdown-it": "^12.2.3",
|
|
56
56
|
"nanospinner": "^1.1.0",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"vite": "5.4.6",
|
|
62
62
|
"vitest": "2.1.1",
|
|
63
63
|
"vue": "3.4.21",
|
|
64
|
-
"@varlet/vite-plugins": "3.5.
|
|
65
|
-
"@varlet/shared": "3.5.
|
|
64
|
+
"@varlet/vite-plugins": "3.5.2",
|
|
65
|
+
"@varlet/shared": "3.5.2"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/babel__core": "^7.20.1",
|
|
@@ -70,14 +70,13 @@
|
|
|
70
70
|
"@types/fs-extra": "^9.0.2",
|
|
71
71
|
"@types/glob": "^7.1.3",
|
|
72
72
|
"@types/hash-sum": "^1.0.0",
|
|
73
|
-
"@types/inquirer": "^9.0.2",
|
|
74
73
|
"@types/markdown-it": "^12.2.3",
|
|
75
74
|
"@types/node": "^18.7.20",
|
|
76
75
|
"@types/sharp": "0.31.1",
|
|
77
76
|
"rimraf": "^5.0.1",
|
|
78
|
-
"@varlet/
|
|
79
|
-
"@varlet/
|
|
80
|
-
"@varlet/
|
|
77
|
+
"@varlet/icons": "3.5.2",
|
|
78
|
+
"@varlet/touch-emulator": "3.5.2",
|
|
79
|
+
"@varlet/ui": "3.5.2"
|
|
81
80
|
},
|
|
82
81
|
"peerDependencies": {
|
|
83
82
|
"@vitest/coverage-istanbul": "2.0.5",
|
|
@@ -88,9 +87,9 @@
|
|
|
88
87
|
"live-server": "^1.2.1",
|
|
89
88
|
"vue": "3.4.21",
|
|
90
89
|
"vue-router": "4.2.0",
|
|
91
|
-
"@varlet/
|
|
92
|
-
"@varlet/
|
|
93
|
-
"@varlet/
|
|
90
|
+
"@varlet/icons": "3.5.2",
|
|
91
|
+
"@varlet/touch-emulator": "3.5.2",
|
|
92
|
+
"@varlet/ui": "3.5.2"
|
|
94
93
|
},
|
|
95
94
|
"scripts": {
|
|
96
95
|
"dev": "tsc --watch",
|