@gx-design-vue/create-gx-cli 0.0.6 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/cli.js +2 -2
- package/src/main.js +10 -18
- package/template-mobile-vant-cli/build/generateModifyVars.ts +7 -0
- package/template-mobile-vant-cli/build/script/postBuild.ts +0 -1
- package/template-mobile-vant-cli/src/design/config.less +0 -0
- package/template-mobile-vant-cli/types/components.d.ts +0 -2
- package/template-mobile-vant-cli/types/global.d.ts +3 -3
- package/template-mobile-vant-cli/types/module.d.ts +0 -2
- package/template-mobile-vant-cli/vite.config.ts +6 -7
package/package.json
CHANGED
package/src/cli.js
CHANGED
@@ -48,7 +48,7 @@ async function promptForMissingOptions(options) {
|
|
48
48
|
type: options.projectName ? null : 'text',
|
49
49
|
name: 'projectName',
|
50
50
|
message: reset('Project name:'),
|
51
|
-
initial: defaultTargetDir
|
51
|
+
initial: defaultTargetDir
|
52
52
|
},
|
53
53
|
{
|
54
54
|
type: options.template && TEMPLATES.includes(options.template) ? null : 'select',
|
@@ -56,7 +56,7 @@ async function promptForMissingOptions(options) {
|
|
56
56
|
message:
|
57
57
|
typeof options.template === 'string' && !TEMPLATES.includes(options.template)
|
58
58
|
? reset(
|
59
|
-
`"${options.template}" isn't a valid template. Please choose from below:
|
59
|
+
`"${options.template}" isn't a valid template. Please choose from below: `
|
60
60
|
)
|
61
61
|
: reset('Select a Template:'),
|
62
62
|
choices: FRAMEWORKS.map((framework) => {
|
package/src/main.js
CHANGED
@@ -8,9 +8,7 @@ import { promisify } from 'util'
|
|
8
8
|
import { createSpinner } from 'nanospinner'
|
9
9
|
import { download } from 'obtain-git-repo'
|
10
10
|
|
11
|
-
const access = promisify(fs.access)
|
12
11
|
const copy = promisify(ncp)
|
13
|
-
const writeFileSync = promisify(fs.writeFileSync)
|
14
12
|
|
15
13
|
const gitRepositoryList = [
|
16
14
|
{
|
@@ -31,7 +29,7 @@ async function copyTemplateFiles(templateDir, root) {
|
|
31
29
|
|
32
30
|
function writeFile(path, content) {
|
33
31
|
if (Object.keys(content).length > 0) {
|
34
|
-
writeFileSync(path, content)
|
32
|
+
fs.writeFileSync(path, content)
|
35
33
|
}
|
36
34
|
}
|
37
35
|
|
@@ -44,9 +42,8 @@ function editPackageJson(root, projectName) {
|
|
44
42
|
)
|
45
43
|
|
46
44
|
pkg.name = projectName
|
45
|
+
writeFile(path.join(root, 'package.json'), JSON.stringify(pkg, null, 2))
|
47
46
|
}
|
48
|
-
|
49
|
-
writeFile(path.join(root, 'package.json'), JSON.stringify(pkg, null, 2))
|
50
47
|
}
|
51
48
|
|
52
49
|
function doneLog(cwd, root) {
|
@@ -75,7 +72,7 @@ export async function createProject(options) {
|
|
75
72
|
)
|
76
73
|
|
77
74
|
try {
|
78
|
-
await access(templateDir, fs.constants.R_OK)
|
75
|
+
await fs.access(templateDir, fs.constants.R_OK)
|
79
76
|
} catch (err) {
|
80
77
|
if (!downloadGit) {
|
81
78
|
console.log(chalk.redBright('模版目录不存在'))
|
@@ -96,31 +93,26 @@ export async function createProject(options) {
|
|
96
93
|
// 下载git代码
|
97
94
|
download(`direct:${downloadGit.git}`, root, { clone: true }, async function(err) {
|
98
95
|
if (err) {
|
99
|
-
console.log(err)
|
100
96
|
spinner.error({ text: '下载失败' })
|
101
97
|
} else {
|
102
98
|
await editPackageJson(root, options.projectName || getProjectName())
|
103
99
|
spinner.success({
|
104
100
|
text: '项目创建成功,请依次执行以下命令'
|
105
101
|
})
|
102
|
+
fs.
|
106
103
|
doneLog(cwd, root)
|
107
104
|
}
|
108
105
|
})
|
109
106
|
} else {
|
110
|
-
let pkg = {}
|
111
|
-
|
112
|
-
if (fs.existsSync(path.join(templateDir, `package.json`))) {
|
113
|
-
pkg = JSON.parse(
|
114
|
-
fs.readFileSync(path.join(templateDir, `package.json`), 'utf-8')
|
115
|
-
)
|
116
|
-
|
117
|
-
pkg.name = options.projectName || getProjectName()
|
118
|
-
}
|
119
107
|
const tasks = new Listr(
|
120
108
|
[
|
121
109
|
{
|
122
|
-
title: '
|
110
|
+
title: '项目创建',
|
123
111
|
task: () => copyTemplateFiles(templateDir, root)
|
112
|
+
},
|
113
|
+
{
|
114
|
+
title: '项目文件修改',
|
115
|
+
task: () => editPackageJson(root, options.projectName || getProjectName())
|
124
116
|
}
|
125
117
|
],
|
126
118
|
{
|
@@ -129,7 +121,7 @@ export async function createProject(options) {
|
|
129
121
|
)
|
130
122
|
|
131
123
|
await tasks.run()
|
132
|
-
|
124
|
+
|
133
125
|
doneLog(cwd, root)
|
134
126
|
}
|
135
127
|
return true
|
File without changes
|
@@ -11,7 +11,5 @@ declare module '@vue/runtime-core' {
|
|
11
11
|
RouterView: typeof import('vue-router')['RouterView']
|
12
12
|
VanButton: typeof import('vant/es')['Button']
|
13
13
|
VanCell: typeof import('vant/es')['Cell']
|
14
|
-
VanSwipe: typeof import('vant/es')['Swipe']
|
15
|
-
VanSwipeItem: typeof import('vant/es')['SwipeItem']
|
16
14
|
}
|
17
15
|
}
|
@@ -5,8 +5,8 @@ declare global {
|
|
5
5
|
pkg: {
|
6
6
|
name: string;
|
7
7
|
version: string;
|
8
|
-
dependencies:
|
9
|
-
devDependencies:
|
8
|
+
dependencies: RecordType;
|
9
|
+
devDependencies: RecordType;
|
10
10
|
};
|
11
11
|
lastBuildTime: string;
|
12
12
|
}
|
@@ -19,7 +19,7 @@ declare global {
|
|
19
19
|
|
20
20
|
declare type PropType<T> = VuePropType<T>;
|
21
21
|
|
22
|
-
declare type RecordType<T = string, K = any> = Record<
|
22
|
+
declare type RecordType<T = string, K = any> = Record<T, K>;
|
23
23
|
|
24
24
|
declare interface ViteEnv {
|
25
25
|
VITE_USE_MODE: string;
|
@@ -5,6 +5,7 @@ import dayjs from 'dayjs'
|
|
5
5
|
|
6
6
|
import { configManualChunk } from './build/optimizer'
|
7
7
|
import { createVitePlugins } from './build/plugin'
|
8
|
+
import { generateModifyVars } from './build/generateModifyVars'
|
8
9
|
|
9
10
|
import pkg from './package.json'
|
10
11
|
|
@@ -52,7 +53,7 @@ export default ({ mode, command }: ConfigEnv): UserConfig => {
|
|
52
53
|
// The boolean type read by loadEnv is a string. This function can be converted to boolean type
|
53
54
|
const viteEnv = wrapperEnv(env)
|
54
55
|
|
55
|
-
const { VITE_BASE_URL } = viteEnv
|
56
|
+
const { VITE_BASE_URL, VITE_DROP_CONSOLE } = viteEnv
|
56
57
|
|
57
58
|
const isBuild = command === 'build'
|
58
59
|
|
@@ -85,15 +86,12 @@ export default ({ mode, command }: ConfigEnv): UserConfig => {
|
|
85
86
|
__INTLIFY_PROD_DEVTOOLS__: false,
|
86
87
|
__APP_INFO__: JSON.stringify(__APP_INFO__)
|
87
88
|
},
|
89
|
+
esbuild: {
|
90
|
+
drop: VITE_DROP_CONSOLE ? [ 'console', 'debugger' ] : []
|
91
|
+
},
|
88
92
|
build: {
|
89
93
|
assetsDir: 'assets',
|
90
|
-
target: 'es2015',
|
91
|
-
cssTarget: 'chrome80',
|
92
|
-
reportCompressedSize: false,
|
93
94
|
chunkSizeWarningLimit: 2500,
|
94
|
-
commonjsOptions: {
|
95
|
-
ignoreTryCatch: false
|
96
|
-
},
|
97
95
|
rollupOptions: {
|
98
96
|
output: {
|
99
97
|
manualChunks: configManualChunk
|
@@ -106,6 +104,7 @@ export default ({ mode, command }: ConfigEnv): UserConfig => {
|
|
106
104
|
},
|
107
105
|
preprocessorOptions: {
|
108
106
|
less: {
|
107
|
+
modifyVars: generateModifyVars(),
|
109
108
|
javascriptEnabled: true
|
110
109
|
}
|
111
110
|
}
|