@gx-design-vue/create-gx-cli 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +4 -2
- package/src/cli.js +23 -24
- package/src/main.js +85 -29
- package/{template-mobile-ts → template-mobile-vant-cli}/.editorconfig +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/.env.development +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/.env.pro +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/.env.production +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/.eslintignore +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/.eslintrc.js +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/.prettierignore +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/.stylelintignore +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/README.md +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/build/cdn.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/build/optimizer.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/build/plugin/autoImport.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/build/plugin/html.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/build/plugin/index.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/build/plugin/mock.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/build/script/postBuild.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/index.html +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/mock/_createProductionServer.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/mock/api/index.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/mock/utils.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/package.json +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/postcss.config.js +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/prettier.config.js +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/public/favicon.ico +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/public/js/flexible.js +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/App.vue +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/components/PageContainer/ProSkeleton.tsx +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/components/PageContainer/index.tsx +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/components/PageContainer/style.module.less +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/core/gx-design/index.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/core/index.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/core/vant-design/index.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/design/index.less +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/design/reset.less +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/design/root.less +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/design/vant.less +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/global.less +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/hooks/web/index.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/hooks/web/usePageLoading.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/layout/BasicLayout.vue +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/layout/basicLayout.less +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/main.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/pages/home.vue +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/router/index.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/router/routes.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/router/typings.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/services/index.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/settings/index.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/store/index.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/store/modules/global.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/utils/cryptoJS.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/utils/env.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/utils/pageTitle.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/utils/request/XHR.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/utils/request/axiosCancel.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/utils/request/checkStatus.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/utils/request/index.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/utils/request/typings.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/utils/storage.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/utils/util.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/src/utils/validate.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/stylelint.config.js +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/tsconfig.json +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/types/auto-imports.d.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/types/components.d.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/types/global.d.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/types/gx-components.d.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/types/module.d.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/types/response.d.ts +0 -0
- package/{template-mobile-ts → template-mobile-vant-cli}/vite.config.ts +0 -0
- package/template-mobile-vant-html/README.md +4 -0
- package/template-mobile-vant-html/css/global.css +293 -0
- package/template-mobile-vant-html/css/global.css.map +1 -0
- package/template-mobile-vant-html/css/global.less +293 -0
- package/template-mobile-vant-html/css/index.css +20 -0
- package/template-mobile-vant-html/css/index.css.map +1 -0
- package/template-mobile-vant-html/css/index.less +21 -0
- package/template-mobile-vant-html/image/disconnected.svg +60 -0
- package/template-mobile-vant-html/image/empty.svg +52 -0
- package/template-mobile-vant-html/image/error.svg +53 -0
- package/template-mobile-vant-html/image/loading.svg +1 -0
- package/template-mobile-vant-html/index.html +91 -0
- package/template-mobile-vant-html/js/index.js +29 -0
- package/template-mobile-vant-html/js/plugin/day.min.js +1 -0
- package/template-mobile-vant-html/js/plugin/fastclick.js +730 -0
- package/template-mobile-vant-html/js/plugin/jquery.min.js +2 -0
- package/template-mobile-vant-html/js/plugin/rem.js +28 -0
- package/template-mobile-vant-html/js/utils/appUtil.js +70 -0
- package/template-mobile-vant-html/js/utils/config.js +3 -0
- package/template-mobile-vant-html/js/utils/request.js +61 -0
- package/template-mobile-vant-html/js/utils/utils.js +65 -0
- package/template-mobile-vant-html/js/utils/validate.js +292 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@gx-design-vue/create-gx-cli",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.4",
|
4
4
|
"license": "MIT",
|
5
5
|
"description": "a cli to bootstrap gx project",
|
6
6
|
"main": "src/index.js",
|
@@ -9,7 +9,7 @@
|
|
9
9
|
"access": "public"
|
10
10
|
},
|
11
11
|
"keywords": [
|
12
|
-
"gx-cli",
|
12
|
+
"create-gx-cli",
|
13
13
|
"create-project"
|
14
14
|
],
|
15
15
|
"author": "gx12358",
|
@@ -20,7 +20,9 @@
|
|
20
20
|
"kolorist": "^1.6.0",
|
21
21
|
"listr": "^0.14.3",
|
22
22
|
"minimist": "^1.2.7",
|
23
|
+
"nanospinner": "^1.1.0",
|
23
24
|
"ncp": "^2.0.0",
|
25
|
+
"obtain-git-repo": "^1.0.2",
|
24
26
|
"prompts": "^2.4.2"
|
25
27
|
},
|
26
28
|
"files": [
|
package/src/cli.js
CHANGED
@@ -1,28 +1,32 @@
|
|
1
|
-
import fs from 'fs'
|
2
|
-
import path from 'path'
|
3
1
|
import minimist from 'minimist'
|
4
2
|
import prompts from 'prompts'
|
5
|
-
import { yellow, reset } from 'kolorist'
|
3
|
+
import { yellow, reset, blue, red, green } from 'kolorist'
|
6
4
|
import { createProject } from './main'
|
7
5
|
|
8
6
|
const defaultTargetDir = 'gx-cli-project'
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
8
|
+
const FRAMEWORKS = [
|
9
|
+
{
|
10
|
+
name: 'gx-design-pro',
|
11
|
+
color: red
|
12
|
+
},
|
13
|
+
{
|
14
|
+
name: 'design-pro',
|
15
|
+
color: blue
|
16
|
+
},
|
17
|
+
{
|
18
|
+
name: 'mobile-vant-cli',
|
19
|
+
color: yellow
|
20
|
+
},
|
21
|
+
{
|
22
|
+
name: 'mobile-vant-html',
|
23
|
+
color: green
|
18
24
|
}
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
})
|
25
|
-
}
|
25
|
+
]
|
26
|
+
|
27
|
+
const TEMPLATES = FRAMEWORKS.map(
|
28
|
+
(f) => (f.variants && f.variants.map((v) => v.name)) || [f.name]
|
29
|
+
).reduce((a, b) => a.concat(b), [])
|
26
30
|
|
27
31
|
function formatTargetDir(targetDir) {
|
28
32
|
return targetDir ? targetDir.trim().replace(/\/+$/g, '') : ''
|
@@ -39,11 +43,6 @@ function parseArgumentsIntoOptions() {
|
|
39
43
|
}
|
40
44
|
|
41
45
|
async function promptForMissingOptions(options) {
|
42
|
-
const FRAMEWORKS = getTemplate()
|
43
|
-
|
44
|
-
const TEMPLATES = FRAMEWORKS.map(
|
45
|
-
(f) => (f.variants && f.variants.map((v) => v.name)) || [f.name]
|
46
|
-
).reduce((a, b) => a.concat(b), [])
|
47
46
|
const answers = await prompts([
|
48
47
|
{
|
49
48
|
type: options.projectName ? null : 'text',
|
@@ -59,7 +58,7 @@ async function promptForMissingOptions(options) {
|
|
59
58
|
? reset(
|
60
59
|
`"${options.template}" isn't a valid template. Please choose from below: `,
|
61
60
|
)
|
62
|
-
: reset('Select a
|
61
|
+
: reset('Select a Template:'),
|
63
62
|
choices: FRAMEWORKS.map((framework) => {
|
64
63
|
const frameworkColor = framework.color
|
65
64
|
return {
|
package/src/main.js
CHANGED
@@ -5,11 +5,20 @@ import Listr from 'listr'
|
|
5
5
|
import ncp from 'ncp'
|
6
6
|
import path from 'path'
|
7
7
|
import { promisify } from 'util'
|
8
|
+
import { createSpinner } from 'nanospinner'
|
9
|
+
import { download } from 'obtain-git-repo'
|
8
10
|
|
9
11
|
const access = promisify(fs.access)
|
10
12
|
const copy = promisify(ncp)
|
11
13
|
const writeFileSync = promisify(fs.writeFileSync)
|
12
14
|
|
15
|
+
const gitRepositoryList = [
|
16
|
+
{
|
17
|
+
name: 'gx-design-pro',
|
18
|
+
git: 'https://gitee.com/gx12358/vue-antd-admin.git#v2'
|
19
|
+
}
|
20
|
+
]
|
21
|
+
|
13
22
|
async function copyTemplateFiles(templateDir, root) {
|
14
23
|
return copy(templateDir, root, {
|
15
24
|
clobber: false
|
@@ -17,7 +26,32 @@ async function copyTemplateFiles(templateDir, root) {
|
|
17
26
|
}
|
18
27
|
|
19
28
|
function writeFile(path, content) {
|
20
|
-
|
29
|
+
if (Object.keys(content).length > 0) {
|
30
|
+
writeFileSync(path, content)
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
function editPackageJson(root, projectName) {
|
35
|
+
let pkg = {}
|
36
|
+
|
37
|
+
if (fs.existsSync(path.join(root, `package.json`))) {
|
38
|
+
pkg = JSON.parse(
|
39
|
+
fs.readFileSync(path.join(root, `package.json`), 'utf-8')
|
40
|
+
)
|
41
|
+
|
42
|
+
pkg.name = projectName
|
43
|
+
}
|
44
|
+
|
45
|
+
writeFile(path.join(root, 'package.json'), JSON.stringify(pkg, null, 2))
|
46
|
+
}
|
47
|
+
|
48
|
+
function doneLog(cwd, root) {
|
49
|
+
if (root !== cwd) {
|
50
|
+
console.log(chalk.blueBright(`cd ${path.relative(cwd, root)}`))
|
51
|
+
}
|
52
|
+
console.log(chalk.blueBright(`pnpm(yarn、npm) install`))
|
53
|
+
console.log(chalk.blueBright(`pnpm(yarn、npm) run dev`))
|
54
|
+
console.log()
|
21
55
|
}
|
22
56
|
|
23
57
|
export async function createProject(options) {
|
@@ -28,48 +62,70 @@ export async function createProject(options) {
|
|
28
62
|
const getProjectName = () =>
|
29
63
|
options.projectName === '.' ? path.basename(path.resolve()) : options.projectName
|
30
64
|
|
65
|
+
const downloadGit = gitRepositoryList.find(el => el.name === options.template)
|
66
|
+
|
31
67
|
const templateDir = path.resolve(
|
32
68
|
fileURLToPath(import.meta.url),
|
33
69
|
'../..',
|
34
|
-
`template-${options.template}
|
70
|
+
`template-${options.template}`
|
35
71
|
)
|
36
72
|
|
37
|
-
const pkg = JSON.parse(
|
38
|
-
fs.readFileSync(path.join(templateDir, `package.json`), 'utf-8')
|
39
|
-
)
|
40
|
-
|
41
|
-
pkg.name = options.projectName || getProjectName()
|
42
|
-
|
43
73
|
try {
|
44
74
|
await access(templateDir, fs.constants.R_OK)
|
45
75
|
} catch (err) {
|
46
|
-
|
76
|
+
if (!downloadGit) {
|
77
|
+
console.log(chalk.redBright('模版目录不存在'))
|
78
|
+
process.exit(1)
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
//目录是否已经存在
|
83
|
+
const dirIsExists = fs.existsSync(root)
|
84
|
+
|
85
|
+
if (dirIsExists) {
|
86
|
+
console.log(chalk.redBright('目录已经存在'))
|
47
87
|
process.exit(1)
|
48
88
|
}
|
49
89
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
{
|
57
|
-
|
58
|
-
|
90
|
+
if (downloadGit) {
|
91
|
+
const spinner = createSpinner(`开始下载...${downloadGit.git}`).start()
|
92
|
+
// 下载git代码
|
93
|
+
download(`direct:${downloadGit.git}`, root, { clone: true }, async function(err) {
|
94
|
+
if (err) {
|
95
|
+
spinner.error({ text: '下载失败' })
|
96
|
+
} else {
|
97
|
+
await editPackageJson(root, options.projectName || getProjectName())
|
98
|
+
spinner.success({
|
99
|
+
text: '项目创建成功,请依次执行以下命令'
|
100
|
+
})
|
101
|
+
doneLog(cwd, root)
|
59
102
|
}
|
60
|
-
|
61
|
-
|
62
|
-
|
103
|
+
})
|
104
|
+
} else {
|
105
|
+
let pkg = {}
|
106
|
+
|
107
|
+
if (fs.existsSync(path.join(templateDir, `package.json`))) {
|
108
|
+
pkg = JSON.parse(
|
109
|
+
fs.readFileSync(path.join(templateDir, `package.json`), 'utf-8')
|
110
|
+
)
|
111
|
+
|
112
|
+
pkg.name = options.projectName || getProjectName()
|
63
113
|
}
|
64
|
-
|
114
|
+
const tasks = new Listr(
|
115
|
+
[
|
116
|
+
{
|
117
|
+
title: '项目创建成功,请依次执行以下命令',
|
118
|
+
task: () => copyTemplateFiles(templateDir, root)
|
119
|
+
}
|
120
|
+
],
|
121
|
+
{
|
122
|
+
exitOnError: false
|
123
|
+
}
|
124
|
+
)
|
65
125
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
console.log(`cd ${path.relative(cwd, root)}`)
|
126
|
+
await tasks.run()
|
127
|
+
await editPackageJson(root)
|
128
|
+
doneLog(cwd, root)
|
70
129
|
}
|
71
|
-
console.log(`pnpm(yarn、npm) install`)
|
72
|
-
console.log(`pnpm(yarn、npm) run dev`)
|
73
|
-
console.log()
|
74
130
|
return true
|
75
131
|
}
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
package/{template-mobile-ts → template-mobile-vant-cli}/src/components/PageContainer/ProSkeleton.tsx
RENAMED
File without changes
|
package/{template-mobile-ts → template-mobile-vant-cli}/src/components/PageContainer/index.tsx
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|