@htyf-mp/cli 0.0.6 → 0.0.7
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 +77 -13
- 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';
|
|
@@ -24,8 +25,8 @@ const green = chalk.green
|
|
|
24
25
|
|
|
25
26
|
const repoUrl = 'https://github.com/htyf-mp-community/htyf-mp.git'
|
|
26
27
|
|
|
27
|
-
const taroTempPath = 'mini-apps-template
|
|
28
|
-
const expoTempPath = 'mini-apps-template
|
|
28
|
+
const taroTempPath = 'mini-apps-template';
|
|
29
|
+
const expoTempPath = 'mini-apps-template';
|
|
29
30
|
const gameTempPath = 'mini-game-template-cocos';
|
|
30
31
|
|
|
31
32
|
const isYarnInstalled = () => {
|
|
@@ -144,23 +145,86 @@ async function main() {
|
|
|
144
145
|
await execa('rm', ['-r', `${appName}/cli`])
|
|
145
146
|
await execa('rm', ['-rf', `${appName}/.git`])
|
|
146
147
|
} catch (err) {}
|
|
147
|
-
|
|
148
|
+
const __TEMP_PATH__ = path.join(appRootPath, '__TEMP__');
|
|
149
|
+
const pkg_path = path.join(appRootPath, './package.json');
|
|
150
|
+
const dgzJosn = path.join(`${appRootPath}`, project.dgz.json)
|
|
148
151
|
if (tempType === 'taro') {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
+
fse.closeSync(
|
|
153
|
+
path.join(__TEMP_PATH__, 'taro_src'),
|
|
154
|
+
path.join(appRootPath, './src')
|
|
155
|
+
)
|
|
156
|
+
fse.closeSync(
|
|
157
|
+
path.join(__TEMP_PATH__, 'taro.App.tsx'),
|
|
158
|
+
path.join(appRootPath, './App.tsx')
|
|
159
|
+
)
|
|
160
|
+
fse.closeSync(
|
|
161
|
+
path.join(__TEMP_PATH__, 'taro.index.js'),
|
|
162
|
+
path.join(appRootPath, './index.js')
|
|
163
|
+
)
|
|
164
|
+
fse.closeSync(
|
|
165
|
+
path.join(__TEMP_PATH__, 'taro.bable.config.js'),
|
|
166
|
+
path.join(appRootPath, './bable.config.js')
|
|
167
|
+
)
|
|
168
|
+
fse.closeSync(
|
|
169
|
+
path.join(__TEMP_PATH__, 'taro.project.dgz.json'),
|
|
170
|
+
path.join(appRootPath, './project.dgz.json')
|
|
171
|
+
)
|
|
172
|
+
const pkg_info = fse.readJSONSync(pkg_path)
|
|
173
|
+
pkg_info['scripts'] = {
|
|
174
|
+
...(pkg_info['scripts'] || {}),
|
|
175
|
+
"build:weapp": "taro build --type weapp",
|
|
176
|
+
"build:swan": "taro build --type swan",
|
|
177
|
+
"build:alipay": "taro build --type alipay",
|
|
178
|
+
"build:tt": "taro build --type tt",
|
|
179
|
+
"build:h5": "taro build --type h5",
|
|
180
|
+
"build:rn": "taro build --type rn",
|
|
181
|
+
"build:qq": "taro build --type qq",
|
|
182
|
+
"build:jd": "taro build --type jd",
|
|
183
|
+
"build:quickapp": "taro build --type quickapp",
|
|
184
|
+
"dev:weapp": "npm run build:weapp -- --watch",
|
|
185
|
+
"dev:swan": "npm run build:swan -- --watch",
|
|
186
|
+
"dev:alipay": "npm run build:alipay -- --watch",
|
|
187
|
+
"dev:tt": "npm run build:tt -- --watch",
|
|
188
|
+
"dev:h5": "npm run build:h5 -- --watch",
|
|
189
|
+
"dev:rn": "npm run build:rn -- --watch",
|
|
190
|
+
"dev:qq": "npm run build:qq -- --watch",
|
|
191
|
+
"dev:jd": "npm run build:jd -- --watch",
|
|
192
|
+
"dev:quickapp": "npm run build:quickapp -- --watch",
|
|
193
|
+
}
|
|
194
|
+
delete pkg_info['scripts']['web']
|
|
195
|
+
delete pkg_info['scripts']['web:dev']
|
|
196
|
+
fse.writeJSONSync(pkg_path, JSON.stringify(pkg_info, undefined, 2))
|
|
152
197
|
}
|
|
153
|
-
if (tempType === '
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
198
|
+
if (tempType === 'expo') {
|
|
199
|
+
fse.closeSync(
|
|
200
|
+
path.join(__TEMP_PATH__, 'expo_src'),
|
|
201
|
+
path.join(appRootPath, './src')
|
|
202
|
+
)
|
|
203
|
+
fse.closeSync(
|
|
204
|
+
path.join(__TEMP_PATH__, 'expo.App.tsx'),
|
|
205
|
+
path.join(appRootPath, './App.tsx')
|
|
206
|
+
)
|
|
207
|
+
fse.closeSync(
|
|
208
|
+
path.join(__TEMP_PATH__, 'expo.index.js'),
|
|
209
|
+
path.join(appRootPath, './index.js')
|
|
210
|
+
)
|
|
211
|
+
fse.closeSync(
|
|
212
|
+
path.join(__TEMP_PATH__, 'expo.bable.config.js'),
|
|
213
|
+
path.join(appRootPath, './bable.config.js')
|
|
214
|
+
)
|
|
215
|
+
fse.closeSync(
|
|
216
|
+
path.join(__TEMP_PATH__, 'expo.project.dgz.json'),
|
|
217
|
+
path.join(appRootPath, './project.dgz.json')
|
|
218
|
+
)
|
|
157
219
|
}
|
|
158
220
|
if (tempType === 'game-cocos') {
|
|
159
|
-
|
|
160
|
-
fs.writeFileSync(dgzJosn, JSON.stringify(config, undefined, 2))
|
|
161
|
-
console.log(dgzJosn)
|
|
221
|
+
|
|
162
222
|
}
|
|
163
223
|
|
|
224
|
+
fs.writeFileSync(dgzJosn, JSON.stringify(config, undefined, 2))
|
|
225
|
+
console.log(dgzJosn)
|
|
226
|
+
|
|
227
|
+
fse.removeSync(appRootPath)
|
|
164
228
|
|
|
165
229
|
spinner.text = ''
|
|
166
230
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htyf-mp/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
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"
|