@htyf-mp/cli 0.0.6 → 0.0.8
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/cli.js +93 -14
- package/package.json +2 -1
package/cli.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import chalk from 'chalk'
|
|
4
4
|
import path from 'path'
|
|
5
5
|
import fs from 'fs'
|
|
6
|
+
import fse from 'fs-extra'
|
|
6
7
|
import { Command } from 'commander'
|
|
7
8
|
import select from '@inquirer/select'
|
|
8
9
|
import { input } from '@inquirer/prompts';
|
|
@@ -23,9 +24,10 @@ const program = new Command()
|
|
|
23
24
|
const green = chalk.green
|
|
24
25
|
|
|
25
26
|
const repoUrl = 'https://github.com/htyf-mp-community/htyf-mp.git'
|
|
27
|
+
const codingRepoUrl = 'https://e.coding.net/dagouzhi/hongtangyun_mobile/htyf-mp.git'
|
|
26
28
|
|
|
27
|
-
const taroTempPath = 'mini-apps-template
|
|
28
|
-
const expoTempPath = 'mini-apps-template
|
|
29
|
+
const taroTempPath = 'mini-apps-template';
|
|
30
|
+
const expoTempPath = 'mini-apps-template';
|
|
29
31
|
const gameTempPath = 'mini-game-template-cocos';
|
|
30
32
|
|
|
31
33
|
const isYarnInstalled = () => {
|
|
@@ -109,6 +111,20 @@ async function main() {
|
|
|
109
111
|
]
|
|
110
112
|
})
|
|
111
113
|
|
|
114
|
+
const repoType = await select({
|
|
115
|
+
message: '请选择模板镜像?',
|
|
116
|
+
choices: [
|
|
117
|
+
{
|
|
118
|
+
name: 'github(最新)',
|
|
119
|
+
value: repoUrl,
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: 'github(最快)',
|
|
123
|
+
value: codingRepoUrl,
|
|
124
|
+
},
|
|
125
|
+
]
|
|
126
|
+
})
|
|
127
|
+
|
|
112
128
|
const appid = md5(uuidv4(v4options));
|
|
113
129
|
|
|
114
130
|
let config = {
|
|
@@ -123,7 +139,7 @@ async function main() {
|
|
|
123
139
|
log(`\n初始化项目. \n`)
|
|
124
140
|
|
|
125
141
|
spinner.start()
|
|
126
|
-
await execa('git', ['clone',
|
|
142
|
+
await execa('git', ['clone', repoType, appName])
|
|
127
143
|
let appRootPath = '';
|
|
128
144
|
try {
|
|
129
145
|
if (tempType === 'taro') {
|
|
@@ -144,23 +160,86 @@ async function main() {
|
|
|
144
160
|
await execa('rm', ['-r', `${appName}/cli`])
|
|
145
161
|
await execa('rm', ['-rf', `${appName}/.git`])
|
|
146
162
|
} catch (err) {}
|
|
147
|
-
|
|
163
|
+
const __TEMP_PATH__ = path.join(appRootPath, '__TEMP__');
|
|
164
|
+
const pkg_path = path.join(appRootPath, './package.json');
|
|
165
|
+
const dgzJosn = path.join(`${appRootPath}`, project.dgz.json)
|
|
148
166
|
if (tempType === 'taro') {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
167
|
+
fse.closeSync(
|
|
168
|
+
path.join(__TEMP_PATH__, 'taro_src'),
|
|
169
|
+
path.join(appRootPath, './src')
|
|
170
|
+
)
|
|
171
|
+
fse.closeSync(
|
|
172
|
+
path.join(__TEMP_PATH__, 'taro.App.tsx'),
|
|
173
|
+
path.join(appRootPath, './App.tsx')
|
|
174
|
+
)
|
|
175
|
+
fse.closeSync(
|
|
176
|
+
path.join(__TEMP_PATH__, 'taro.index.js'),
|
|
177
|
+
path.join(appRootPath, './index.js')
|
|
178
|
+
)
|
|
179
|
+
fse.closeSync(
|
|
180
|
+
path.join(__TEMP_PATH__, 'taro.bable.config.js'),
|
|
181
|
+
path.join(appRootPath, './bable.config.js')
|
|
182
|
+
)
|
|
183
|
+
fse.closeSync(
|
|
184
|
+
path.join(__TEMP_PATH__, 'taro.project.dgz.json'),
|
|
185
|
+
path.join(appRootPath, './project.dgz.json')
|
|
186
|
+
)
|
|
187
|
+
const pkg_info = fse.readJSONSync(pkg_path)
|
|
188
|
+
pkg_info['scripts'] = {
|
|
189
|
+
...(pkg_info['scripts'] || {}),
|
|
190
|
+
"build:weapp": "taro build --type weapp",
|
|
191
|
+
"build:swan": "taro build --type swan",
|
|
192
|
+
"build:alipay": "taro build --type alipay",
|
|
193
|
+
"build:tt": "taro build --type tt",
|
|
194
|
+
"build:h5": "taro build --type h5",
|
|
195
|
+
"build:rn": "taro build --type rn",
|
|
196
|
+
"build:qq": "taro build --type qq",
|
|
197
|
+
"build:jd": "taro build --type jd",
|
|
198
|
+
"build:quickapp": "taro build --type quickapp",
|
|
199
|
+
"dev:weapp": "npm run build:weapp -- --watch",
|
|
200
|
+
"dev:swan": "npm run build:swan -- --watch",
|
|
201
|
+
"dev:alipay": "npm run build:alipay -- --watch",
|
|
202
|
+
"dev:tt": "npm run build:tt -- --watch",
|
|
203
|
+
"dev:h5": "npm run build:h5 -- --watch",
|
|
204
|
+
"dev:rn": "npm run build:rn -- --watch",
|
|
205
|
+
"dev:qq": "npm run build:qq -- --watch",
|
|
206
|
+
"dev:jd": "npm run build:jd -- --watch",
|
|
207
|
+
"dev:quickapp": "npm run build:quickapp -- --watch",
|
|
208
|
+
}
|
|
209
|
+
delete pkg_info['scripts']['web']
|
|
210
|
+
delete pkg_info['scripts']['web:dev']
|
|
211
|
+
fse.writeJSONSync(pkg_path, JSON.stringify(pkg_info, undefined, 2))
|
|
152
212
|
}
|
|
153
|
-
if (tempType === '
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
213
|
+
if (tempType === 'expo') {
|
|
214
|
+
fse.closeSync(
|
|
215
|
+
path.join(__TEMP_PATH__, 'expo_src'),
|
|
216
|
+
path.join(appRootPath, './src')
|
|
217
|
+
)
|
|
218
|
+
fse.closeSync(
|
|
219
|
+
path.join(__TEMP_PATH__, 'expo.App.tsx'),
|
|
220
|
+
path.join(appRootPath, './App.tsx')
|
|
221
|
+
)
|
|
222
|
+
fse.closeSync(
|
|
223
|
+
path.join(__TEMP_PATH__, 'expo.index.js'),
|
|
224
|
+
path.join(appRootPath, './index.js')
|
|
225
|
+
)
|
|
226
|
+
fse.closeSync(
|
|
227
|
+
path.join(__TEMP_PATH__, 'expo.bable.config.js'),
|
|
228
|
+
path.join(appRootPath, './bable.config.js')
|
|
229
|
+
)
|
|
230
|
+
fse.closeSync(
|
|
231
|
+
path.join(__TEMP_PATH__, 'expo.project.dgz.json'),
|
|
232
|
+
path.join(appRootPath, './project.dgz.json')
|
|
233
|
+
)
|
|
157
234
|
}
|
|
158
235
|
if (tempType === 'game-cocos') {
|
|
159
|
-
|
|
160
|
-
fs.writeFileSync(dgzJosn, JSON.stringify(config, undefined, 2))
|
|
161
|
-
console.log(dgzJosn)
|
|
236
|
+
|
|
162
237
|
}
|
|
163
238
|
|
|
239
|
+
fs.writeFileSync(dgzJosn, JSON.stringify(config, undefined, 2))
|
|
240
|
+
console.log(dgzJosn)
|
|
241
|
+
|
|
242
|
+
fse.removeSync(appRootPath)
|
|
164
243
|
|
|
165
244
|
spinner.text = ''
|
|
166
245
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htyf-mp/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "红糖云服app小程序模板-cli",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": "cli.js",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"cli-spinners": "^2.9.0",
|
|
26
26
|
"commander": "^11.0.0",
|
|
27
27
|
"execa": "^8.0.1",
|
|
28
|
+
"fs-extra": "^11.2.0",
|
|
28
29
|
"md5": "^2.3.0",
|
|
29
30
|
"ora": "^7.0.1",
|
|
30
31
|
"uuid": "^9.0.1"
|