@htyf-mp/cli 0.0.11 → 0.1.1
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 +33 -25
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -28,7 +28,7 @@ const codingRepoUrl = 'https://e.coding.net/dagouzhi/hongtangyun_mobile/htyf-mp.
|
|
|
28
28
|
|
|
29
29
|
const taroTempPath = 'mini-apps-template';
|
|
30
30
|
const expoTempPath = 'mini-apps-template';
|
|
31
|
-
const gameTempPath = 'mini-game-template
|
|
31
|
+
const gameTempPath = 'mini-game-template';
|
|
32
32
|
|
|
33
33
|
const isYarnInstalled = () => {
|
|
34
34
|
try {
|
|
@@ -146,46 +146,52 @@ async function main() {
|
|
|
146
146
|
const game_path = path.join('./', `${appName}`, `${gameTempPath}`)
|
|
147
147
|
const cli_path = path.join('./', `${appName}`, `cli`)
|
|
148
148
|
const git_path = path.join('./', `${appName}`, `.git`)
|
|
149
|
+
const docs_path = path.join('./', `${appName}`, `docs`)
|
|
150
|
+
const README_path = path.join('./', `${appName}`, `README.md`)
|
|
149
151
|
try {
|
|
150
152
|
if (tempType === 'taro') {
|
|
151
153
|
appRootPath = taro_path
|
|
152
|
-
|
|
153
|
-
await execa('rm', ['-r', `${game_path}`])
|
|
154
|
+
fse.removeSync(game_path)
|
|
154
155
|
}
|
|
155
156
|
if (tempType === 'expo') {
|
|
156
157
|
appRootPath = expo_path
|
|
157
|
-
|
|
158
|
-
await execa('rm', ['-r', `${game_path}`])
|
|
158
|
+
fse.removeSync(game_path)
|
|
159
159
|
}
|
|
160
160
|
if (tempType === 'game-cocos') {
|
|
161
161
|
appRootPath = game_path
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
fse.removeSync(taro_path)
|
|
163
|
+
fse.removeSync(expo_path)
|
|
164
164
|
}
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
fse.removeSync(cli_path)
|
|
166
|
+
fse.removeSync(git_path)
|
|
167
|
+
fse.removeSync(docs_path)
|
|
168
|
+
fse.removeSync(README_path)
|
|
167
169
|
} catch (err) {}
|
|
168
170
|
const __TEMP_PATH__ = path.join(appRootPath, '__TEMP__');
|
|
169
171
|
const pkg_path = path.join(appRootPath, './package.json');
|
|
170
172
|
const dgzJosn = path.join(`${appRootPath}`, 'project.dgz.json')
|
|
173
|
+
console.log(' ')
|
|
174
|
+
console.log(tempType)
|
|
175
|
+
console.log(__TEMP_PATH__)
|
|
176
|
+
console.log(' ')
|
|
171
177
|
if (tempType === 'taro') {
|
|
172
|
-
fse.
|
|
178
|
+
fse.copySync(
|
|
173
179
|
path.join(__TEMP_PATH__, 'taro_src'),
|
|
174
180
|
path.join(appRootPath, './src')
|
|
175
181
|
)
|
|
176
|
-
fse.
|
|
182
|
+
fse.copySync(
|
|
177
183
|
path.join(__TEMP_PATH__, 'taro.App.tsx'),
|
|
178
184
|
path.join(appRootPath, './App.tsx')
|
|
179
185
|
)
|
|
180
|
-
fse.
|
|
186
|
+
fse.copySync(
|
|
181
187
|
path.join(__TEMP_PATH__, 'taro.index.js'),
|
|
182
188
|
path.join(appRootPath, './index.js')
|
|
183
189
|
)
|
|
184
|
-
fse.
|
|
185
|
-
path.join(__TEMP_PATH__, 'taro.
|
|
186
|
-
path.join(appRootPath, './
|
|
190
|
+
fse.copySync(
|
|
191
|
+
path.join(__TEMP_PATH__, 'taro.babel.config.js'),
|
|
192
|
+
path.join(appRootPath, './babel.config.js')
|
|
187
193
|
)
|
|
188
|
-
fse.
|
|
194
|
+
fse.copySync(
|
|
189
195
|
path.join(__TEMP_PATH__, 'taro.project.dgz.json'),
|
|
190
196
|
path.join(appRootPath, './project.dgz.json')
|
|
191
197
|
)
|
|
@@ -213,26 +219,28 @@ async function main() {
|
|
|
213
219
|
}
|
|
214
220
|
delete pkg_info['scripts']['web']
|
|
215
221
|
delete pkg_info['scripts']['web:dev']
|
|
216
|
-
fse.writeJSONSync(pkg_path,
|
|
222
|
+
fse.writeJSONSync(pkg_path, pkg_info, {
|
|
223
|
+
spaces: 2
|
|
224
|
+
})
|
|
217
225
|
}
|
|
218
226
|
if (tempType === 'expo') {
|
|
219
|
-
fse.
|
|
227
|
+
fse.copySync(
|
|
220
228
|
path.join(__TEMP_PATH__, 'expo_src'),
|
|
221
229
|
path.join(appRootPath, './src')
|
|
222
230
|
)
|
|
223
|
-
fse.
|
|
231
|
+
fse.copySync(
|
|
224
232
|
path.join(__TEMP_PATH__, 'expo.App.tsx'),
|
|
225
233
|
path.join(appRootPath, './App.tsx')
|
|
226
234
|
)
|
|
227
|
-
fse.
|
|
235
|
+
fse.copySync(
|
|
228
236
|
path.join(__TEMP_PATH__, 'expo.index.js'),
|
|
229
237
|
path.join(appRootPath, './index.js')
|
|
230
238
|
)
|
|
231
|
-
fse.
|
|
232
|
-
path.join(__TEMP_PATH__, 'expo.
|
|
233
|
-
path.join(appRootPath, './
|
|
239
|
+
fse.copySync(
|
|
240
|
+
path.join(__TEMP_PATH__, 'expo.babel.config.js'),
|
|
241
|
+
path.join(appRootPath, './babel.config.js')
|
|
234
242
|
)
|
|
235
|
-
fse.
|
|
243
|
+
fse.copySync(
|
|
236
244
|
path.join(__TEMP_PATH__, 'expo.project.dgz.json'),
|
|
237
245
|
path.join(appRootPath, './project.dgz.json')
|
|
238
246
|
)
|
|
@@ -244,7 +252,7 @@ async function main() {
|
|
|
244
252
|
fs.writeFileSync(dgzJosn, JSON.stringify(config, undefined, 2))
|
|
245
253
|
console.log(dgzJosn)
|
|
246
254
|
|
|
247
|
-
fse.removeSync(
|
|
255
|
+
fse.removeSync(__TEMP_PATH__)
|
|
248
256
|
|
|
249
257
|
spinner.text = ''
|
|
250
258
|
|