Przeglądaj źródła

feat: add sync command

zhangyuhan 3 lat temu
rodzic
commit
ad76898045

+ 1 - 1
package.json

@@ -4,7 +4,7 @@
   "description": "剑鱼内部脚手架",
   "author": "zhangyuhan @zhangyuhan@topnet.net.cn",
   "bin": {
-    "jianyu": "./bin/dev"
+    "jianyu": "./bin/run"
   },
   "homepage": "http://192.168.3.207:20080/zhangyuhan/jianyu-cli",
   "license": "MIT",

+ 0 - 23
src/commands/hello/index.ts

@@ -1,23 +0,0 @@
-import { Command, Flags } from '@oclif/core'
-
-export default class Hello extends Command {
-  static description = 'Say hello'
-
-  static examples = [
-    `$ oex hello friend --from oclif
-hello friend from oclif! (./src/commands/hello/index.ts)
-`,
-  ]
-
-  static flags = {
-    from: Flags.string({ char: 'f', description: 'Whom is saying hello', required: true }),
-  }
-
-  static args = [{ name: 'person', description: 'Person to say hello to', required: true }]
-
-  async run(): Promise<void> {
-    const { args, flags } = await this.parse(Hello)
-
-    this.log(`hello ${args.person} from ${flags.from}! (./src/commands/hello/index.ts)`)
-  }
-}

+ 0 - 19
src/commands/hello/world.ts

@@ -1,19 +0,0 @@
-import { Command } from '@oclif/core'
-
-export default class World extends Command {
-  static description = 'Say hello world'
-
-  static examples = [
-    `$ oex hello world
-hello world! (./src/commands/hello/world.ts)
-`,
-  ]
-
-  static flags = {}
-
-  static args = []
-
-  async run(): Promise<void> {
-    this.log('hello world! (./src/commands/hello/world.ts)')
-  }
-}

+ 22 - 0
src/commands/sync/index.ts

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