瀏覽代碼

style: code lint

zhangyuhan 3 年之前
父節點
當前提交
d363b0ccf5
共有 4 個文件被更改,包括 22 次插入21 次删除
  1. 7 7
      src/commands/create/index.ts
  2. 9 8
      src/commands/init/index.ts
  3. 4 4
      src/commands/sync/index.ts
  4. 2 2
      src/template.ts

+ 7 - 7
src/commands/create/index.ts

@@ -1,13 +1,13 @@
 import { Command } from '@oclif/core'
-import { TEMPLATES, TemplateNames } from "../../template";
+import { TEMPLATES, TemplateNames } from '../../template'
 import * as inquirer from 'inquirer'
-import Init from "../init";
+import Init from '../init'
 
 export default class Create extends Command {
   static description = '创建项目-命令行交互式'
 
   static examples = [
-    `$ jianyu create`
+    '$ jianyu create',
   ]
 
   async run(): Promise<void> {
@@ -18,7 +18,7 @@ export default class Create extends Command {
         type: 'input',
         name: 'name',
         default: 'new-project',
-        message: '输入项目名称(同时用于目录名)'
+        message: '输入项目名称(同时用于目录名)',
       },
       {
         type: 'list',
@@ -26,10 +26,10 @@ export default class Create extends Command {
         default: TemplateNames[0],
         choices: TemplateNames.map(v => ({
           name: `${v}  ${TEMPLATES[v].title}`,
-          value: v
+          value: v,
         })),
-        message: '选择项目模板'
-      }
+        message: '选择项目模板',
+      },
     ])
 
     await Init.run(['-f', config.template, config.name])

+ 9 - 8
src/commands/init/index.ts

@@ -1,5 +1,5 @@
 import { Command, Flags } from '@oclif/core'
-import { TEMPLATES, TemplateNames } from "../../template";
+import { TEMPLATES, TemplateNames } from '../../template'
 import DownloadRemoteProjectTemplate, { FormatParams } from '@jianyu/dl-template'
 const path = require('path')
 
@@ -36,15 +36,16 @@ 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
       },
     })

+ 4 - 4
src/commands/sync/index.ts

@@ -1,11 +1,11 @@
 import { Command } from '@oclif/core'
-import { execSync } from "child_process";
+import { execSync } from 'node:child_process'
 
 export default class Sync extends Command {
   static description = '同步到物料平台(内网注册表)'
 
   static examples = [
-    `$ jianyu sync`,
+    '$ jianyu sync',
   ]
 
   async run(): Promise<void> {
@@ -14,9 +14,9 @@ export default class Sync extends Command {
 
     try {
       execSync('npm publish --registry http://192.168.3.207:4873/')
-    } catch (e) {
+    } catch (error) {
       // @ts-ignore
-      this.error(e)
+      this.error(error)
     }
   }
 }

+ 2 - 2
src/template.ts

@@ -1,4 +1,4 @@
-import * as path from 'path'
+import * as path from 'node:path'
 
 export interface RepoTemplate {
   title: string
@@ -16,5 +16,5 @@ const TemplateNames = Object.keys(TEMPLATES)
 
 export {
   TEMPLATES,
-  TemplateNames
+  TemplateNames,
 }