@wzyjs/cli 0.0.16 → 0.0.18

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.
@@ -40,7 +40,7 @@ exports.default = (cli) => {
40
40
  // 写 midway.config.js 到 dist 目录
41
41
  (0, utils_2.writeConfig)(outDir, productionConfig);
42
42
  // 写 package.json 到 dist 目录
43
- fs.cpSync((0, path_1.join)(root, 'package.json'), (0, path_1.join)(outDir, 'package.json'));
43
+ // fs.cpSync(join(root, 'package.json'), join(outDir, 'package.json'))
44
44
  consola.info('正在打包后端代码...', root);
45
45
  const rdBuild = await (0, utils_1.executePromise)((0, utils_2.buildServer)(root, outDir));
46
46
  // 删除 midway.config.js
@@ -0,0 +1,3 @@
1
+ import { CAC } from 'cac';
2
+ declare const _default: (cli: CAC) => void;
3
+ export default _default;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const script_1 = tslib_1.__importDefault(require("./script"));
5
+ exports.default = (cli) => {
6
+ cli.command('m', 'cli工具')
7
+ .option('--commit', '[boolean] 是否在合并前提交代码')
8
+ .action(script_1.default);
9
+ };
@@ -0,0 +1,4 @@
1
+ declare const _default: (options: {
2
+ commit: boolean;
3
+ }) => Promise<void>;
4
+ export default _default;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const { exec } = require('child_process');
4
+ // 获取最新的msg
5
+ async function getLatestCommitMsg() {
6
+ return execGitCommand(`git log -1 --pretty=%B`);
7
+ }
8
+ function getContinuousCommitCount() {
9
+ return new Promise((resolve, reject) => {
10
+ exec(`git log --oneline --format=%s`, (err, stdout) => {
11
+ if (err) {
12
+ reject(err);
13
+ return;
14
+ }
15
+ const messages = stdout.split('\n');
16
+ const msg = messages[0];
17
+ let count = 0;
18
+ for (const item of messages) {
19
+ if (item !== msg) {
20
+ break;
21
+ }
22
+ count++;
23
+ }
24
+ resolve(count);
25
+ });
26
+ });
27
+ }
28
+ function execGitCommand(command) {
29
+ return new Promise((resolve, reject) => {
30
+ exec(command, (err, stdout) => {
31
+ if (err) {
32
+ reject(err);
33
+ return;
34
+ }
35
+ resolve(stdout);
36
+ });
37
+ });
38
+ }
39
+ exports.default = async (options) => {
40
+ if (options.commit) {
41
+ await execGitCommand(`git commit -a -m "${(await getLatestCommitMsg()).trim()}"`);
42
+ }
43
+ const count = await getContinuousCommitCount();
44
+ const command = `GIT_EDITOR=true GIT_SEQUENCE_EDITOR="sed -i -e '2,\\$s/^pick/squash/'" git rebase -i HEAD~${count}`;
45
+ console.log(666, await execGitCommand(command));
46
+ };
package/dist/index.js CHANGED
@@ -6,11 +6,13 @@ const dev_1 = tslib_1.__importDefault(require("./commands/dev"));
6
6
  const build_1 = tslib_1.__importDefault(require("./commands/build"));
7
7
  const start_1 = tslib_1.__importDefault(require("./commands/start"));
8
8
  const create_1 = tslib_1.__importDefault(require("./commands/create"));
9
+ const merge_1 = tslib_1.__importDefault(require("./commands/merge"));
9
10
  const cli = (0, cac_1.default)();
10
11
  (0, dev_1.default)(cli);
11
12
  (0, build_1.default)(cli);
12
13
  (0, start_1.default)(cli);
13
14
  (0, create_1.default)(cli);
15
+ (0, merge_1.default)(cli);
14
16
  cli.help();
15
17
  cli.version('0.0.1');
16
18
  cli.parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wzyjs/cli",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "description",
5
5
  "author": "wzy",
6
6
  "license": "ISC",
@@ -9,6 +9,7 @@
9
9
  "build": "tsc"
10
10
  },
11
11
  "files": [
12
+ "bin",
12
13
  "dist"
13
14
  ],
14
15
  "bin": {
@@ -20,7 +21,7 @@
20
21
  "@midwayjs/command-core": "^1.3.14",
21
22
  "@midwayjs/hooks": "^3.0.1",
22
23
  "@umijs/plugins": "^4.0.28",
23
- "@wzyjs/utils": "^0.0.16",
24
+ "@wzyjs/utils": "^0.0.18",
24
25
  "cac": "^6.7.14",
25
26
  "consola": "^2.15.3",
26
27
  "fs-extra": "^10.1.0",
@@ -42,5 +43,5 @@
42
43
  "type": "git",
43
44
  "url": "https://gitee.com/wang-zhenyu/app.git"
44
45
  },
45
- "gitHead": "06ef413d0febd5cf016833ca123e1ac31f52f3cc"
46
+ "gitHead": "7ebb80ef50a4df3d262a1da82d7967e628698b10"
46
47
  }