|
@@ -1,13 +1,12 @@
|
|
|
-import {Command, Flags} from '@oclif/core'
|
|
|
-import {Templates} from "../../global"
|
|
|
-import DownloadRemoteProjectTemplate, { FormatParams} from '@jianyu/dl-template'
|
|
|
+import { Command, Flags } from '@oclif/core'
|
|
|
+import DownloadRemoteProjectTemplate, { FormatParams } from '@jianyu/dl-template'
|
|
|
+import { Templates } from '../../global'
|
|
|
const path = require('path')
|
|
|
|
|
|
declare global {
|
|
|
var TEMPLATES: Templates
|
|
|
}
|
|
|
|
|
|
-
|
|
|
export default class Init extends Command {
|
|
|
static description = '初始化项目'
|
|
|
|
|
@@ -21,15 +20,15 @@ export default class Init extends Command {
|
|
|
from: Flags.string({ char: 'f', description: '指定拉取模版的名称', required: true }),
|
|
|
}
|
|
|
|
|
|
- static args = [{name: 'dir', description: '目录名,同时用于项目名', required: true}]
|
|
|
+ static args = [{ name: 'dir', description: '目录名,同时用于项目名', required: true }]
|
|
|
|
|
|
async run(): Promise<void> {
|
|
|
- const {args, flags} = await this.parse(Init)
|
|
|
+ const { args, flags } = await this.parse(Init)
|
|
|
const TemplateNames = Object.keys(TEMPLATES)
|
|
|
const canNext = TemplateNames.includes(flags.from)
|
|
|
|
|
|
if (!canNext) {
|
|
|
- this.error( `没有找到对应的模版配置, 可用的模版为 [${TemplateNames.join(',')}]`)
|
|
|
+ this.error(`没有找到对应的模版配置, 可用的模版为 [${TemplateNames.join(',')}]`)
|
|
|
}
|
|
|
|
|
|
const { repo, assets, title } = TEMPLATES[flags.from]
|
|
@@ -41,27 +40,29 @@ export default class Init extends Command {
|
|
|
getTransformLinks: (params: FormatParams) => {
|
|
|
let url = ''
|
|
|
switch (params.type) {
|
|
|
- case 'gitlab-jh': {
|
|
|
- url = `http://192.168.3.207:20080/${params.group}/${params.name}/-/archive/${params.checkout}/${params.name}-${params.checkout}.zip`
|
|
|
- if (params.path) {
|
|
|
- url += `?path=${params.path}`
|
|
|
- }
|
|
|
- break
|
|
|
+ case 'gitlab-jh': {
|
|
|
+ url = `http://192.168.3.207:20080/${params.group}/${params.name}/-/archive/${params.checkout}/${params.name}-${params.checkout}.zip`
|
|
|
+ if (params.path) {
|
|
|
+ url += `?path=${params.path}`
|
|
|
}
|
|
|
+
|
|
|
+ break
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
return url
|
|
|
- }
|
|
|
+ },
|
|
|
})
|
|
|
|
|
|
await dl.get({
|
|
|
repository: repo,
|
|
|
remoteFolder: assets,
|
|
|
- destinationFolder: destinationFolder
|
|
|
+ destinationFolder,
|
|
|
}).then(() => {
|
|
|
this.log(`🎉 初始化 ${flags.from} ${title}项目模版创建成功`)
|
|
|
- this.log(`👉 使用下面这些命令开始项目:`)
|
|
|
+ this.log('👉 使用下面这些命令开始项目:')
|
|
|
this.log(`$ cd ${args.dir}`)
|
|
|
- this.log(`$ yarn`)
|
|
|
+ this.log('$ yarn')
|
|
|
})
|
|
|
}
|
|
|
}
|