@soybeanjs/cli 0.3.1 → 0.4.0

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/README.md CHANGED
@@ -20,16 +20,16 @@ pnpm soy -h
20
20
 
21
21
  ## 命令介绍
22
22
 
23
- | 命令 | 作用 |
24
- | ----------------- | --------------------------------------------- |
25
- | help | 查看全部命令用法 |
26
- | git-commit | 生成符合 Angular 规范的 git 提交信息 |
27
- | git-commit-verify | 校验 git 的提交信息是否符合 Angular 规范 |
28
- | cleanup | 清空依赖和构建产物 |
29
- | cleanup-deep | 清空依赖和构建产物(包含 深层级) |
30
- | init-git-hooks | 初始化 simple-gi t-hooks 钩子 |
31
- | update-pkg | 升级依赖 |
32
- | prettier-format | prettier 格式化 |
23
+ | 命令 | 作用 |
24
+ | ----------------- | ---------------------------------------- |
25
+ | help | 查看全部命令用法 |
26
+ | git-commit | 生成符合 Angular 规范的 git 提交信息 |
27
+ | git-commit-verify | 校验 git 的提交信息是否符合 Angular 规范 |
28
+ | cleanup | 清空依赖和构建产物 |
29
+ | cleanup-deep | 清空依赖和构建产物(包含 深层级) |
30
+ | init-git-hooks | 初始化 simple-gi t-hooks 钩子 |
31
+ | update-pkg | 升级依赖 |
32
+ | prettier-format | prettier 格式化 |
33
33
 
34
34
  ### prettier-format
35
35
 
@@ -50,4 +50,5 @@ pnpm soy -h
50
50
  - package-lock.json
51
51
  - pnpm-lock.yaml
52
52
  - yarn.lock
53
+ - .github
53
54
  - **snapshots**
package/dist/index.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- const commander = require('commander');
5
- const kolorist = require('kolorist');
4
+ const cac = require('cac');
6
5
  const enquirer = require('enquirer');
7
6
  const execa = require('execa');
8
7
  const actualFS = require('fs');
8
+ const kolorist = require('kolorist');
9
9
  const rimraf = require('rimraf');
10
10
  const path$1 = require('path');
11
11
  const url = require('url');
@@ -28,95 +28,14 @@ function _interopNamespaceCompat(e) {
28
28
  return n;
29
29
  }
30
30
 
31
+ const cac__default = /*#__PURE__*/_interopDefaultCompat(cac);
31
32
  const enquirer__default = /*#__PURE__*/_interopDefaultCompat(enquirer);
32
33
  const actualFS__namespace = /*#__PURE__*/_interopNamespaceCompat(actualFS);
33
34
  const EE__default = /*#__PURE__*/_interopDefaultCompat(EE);
34
35
  const Stream__default = /*#__PURE__*/_interopDefaultCompat(Stream);
35
36
  const stringdecoder__default = /*#__PURE__*/_interopDefaultCompat(stringdecoder);
36
37
 
37
- const name = "@soybeanjs/cli";
38
- const version = "0.3.1";
39
- const description = "SoybeanJS's command line tools";
40
- const author = {
41
- name: "Soybean",
42
- email: "honghuangdc@gmail.com",
43
- url: "https://github.com/honghuangdc"
44
- };
45
- const license = "MIT";
46
- const homepage = "https://github.com/honghuangdc/soybean-cli";
47
- const repository = {
48
- url: "https://github.com/honghuangdc/soybean-cli.git"
49
- };
50
- const bugs = {
51
- url: "https://github.com/honghuangdc/soybean-cli/issues"
52
- };
53
- const publishConfig = {
54
- registry: "https://registry.npmjs.org/"
55
- };
56
- const bin = {
57
- soybean: "dist/index.mjs",
58
- soy: "dist/index.mjs"
59
- };
60
- const files = [
61
- "dist"
62
- ];
63
- const scripts = {
64
- build: "pnpm typecheck && unbuild",
65
- lint: "eslint . --fix",
66
- format: "soy prettier-format",
67
- commit: "soy git-commit",
68
- cleanup: "soy cleanup",
69
- "update-pkg": "soy update-pkg",
70
- "update-version": "bumpp --commit --push --tag",
71
- "publish-pkg": "pnpm -r publish --access public",
72
- typecheck: "tsc --noEmit",
73
- release: "pnpm update-version && pnpm build && pnpm publish-pkg"
74
- };
75
- const dependencies = {
76
- commander: "10.0.1",
77
- enquirer: "2.3.6",
78
- execa: "7.1.1",
79
- kolorist: "1.8.0",
80
- minimist: "1.2.8",
81
- "npm-check-updates": "16.10.12",
82
- rimraf: "5.0.1"
83
- };
84
- const devDependencies = {
85
- "@soybeanjs/cli": "link:",
86
- "@types/node": "20.2.5",
87
- bumpp: "9.1.0",
88
- eslint: "8.41.0",
89
- "eslint-config-soybeanjs": "0.4.7",
90
- "lint-staged": "13.2.2",
91
- "simple-git-hooks": "2.8.1",
92
- tsx: "3.12.7",
93
- typescript: "5.0.4",
94
- unbuild: "1.2.1"
95
- };
96
- const pkg = {
97
- name: name,
98
- version: version,
99
- description: description,
100
- author: author,
101
- license: license,
102
- homepage: homepage,
103
- repository: repository,
104
- bugs: bugs,
105
- publishConfig: publishConfig,
106
- bin: bin,
107
- files: files,
108
- scripts: scripts,
109
- dependencies: dependencies,
110
- devDependencies: devDependencies,
111
- "simple-git-hooks": {
112
- "commit-msg": "pnpm soy git-commit-verify",
113
- "pre-commit": "pnpm typecheck && pnpm lint-staged"
114
- },
115
- "lint-staged": {
116
- "*.{js,mjs,jsx,ts,mts,tsx,json,vue,svelte,astro}": "eslint . --fix",
117
- "*.!{js,mjs,jsx,ts,mts,tsx,json,vue,svelte,astro}": "format"
118
- }
119
- };
38
+ const version = "0.4.0";
120
39
 
121
40
  const gitCommitTypes = [
122
41
  { value: "init", title: "init: \u9879\u76EE\u521D\u59CB\u5316" },
@@ -7542,23 +7461,56 @@ function prettierFormat() {
7542
7461
  });
7543
7462
  }
7544
7463
 
7545
- commander.program.command("git-commit").description("\u751F\u6210\u7B26\u5408 Angular \u89C4\u8303\u7684 git commit").action(() => {
7546
- gitCommit();
7547
- });
7548
- commander.program.command("git-commit-verify").description("\u6821\u9A8Cgit\u7684commit\u662F\u5426\u7B26\u5408 Angular \u89C4\u8303").action(() => {
7549
- gitCommitVerify();
7550
- });
7551
- commander.program.command("cleanup").description("\u6E05\u7A7A\u4F9D\u8D56\u548C\u6784\u5EFA\u4EA7\u7269").action(() => {
7552
- cleanup();
7553
- });
7554
- commander.program.command("init-git-hooks").description("\u521D\u59CB\u5316simple-git-hooks\u94A9\u5B50").action(() => {
7555
- initSimpleGitHooks();
7556
- });
7557
- commander.program.command("update-pkg").description("\u5347\u7EA7\u4F9D\u8D56").action(() => {
7558
- updatePkg();
7559
- });
7560
- commander.program.command("prettier-format").description("prettier\u683C\u5F0F\u5316").action(() => {
7561
- prettierFormat();
7464
+ async function eslintPretter() {
7465
+ await execa.execa("npx", ["eslint", ".", "--fix"], {
7466
+ stdio: "inherit"
7467
+ });
7468
+ await execa.execa("npx", ["soy", "prettier-format"], {
7469
+ stdio: "inherit"
7470
+ });
7471
+ }
7472
+
7473
+ function lintStaged() {
7474
+ execa.execa("npx", ["lint-staged", "--config", "@soybeanjs/cli/lint-staged"], { stdio: "inherit" });
7475
+ }
7476
+
7477
+ const cli = cac__default("soybean");
7478
+ cli.version(version).help();
7479
+ const commands = {
7480
+ "git-commit": {
7481
+ desc: "\u751F\u6210\u7B26\u5408 Angular \u89C4\u8303\u7684 git commit",
7482
+ action: gitCommit
7483
+ },
7484
+ "git-commit-verify": {
7485
+ desc: "\u6821\u9A8Cgit\u7684commit\u662F\u5426\u7B26\u5408 Angular \u89C4\u8303",
7486
+ action: gitCommitVerify
7487
+ },
7488
+ cleanup: {
7489
+ desc: "\u6E05\u7A7A\u4F9D\u8D56\u548C\u6784\u5EFA\u4EA7\u7269",
7490
+ action: cleanup
7491
+ },
7492
+ "init-git-hooks": {
7493
+ desc: "\u521D\u59CB\u5316simple-git-hooks\u94A9\u5B50",
7494
+ action: initSimpleGitHooks
7495
+ },
7496
+ "update-pkg": {
7497
+ desc: "\u5347\u7EA7\u4F9D\u8D56",
7498
+ action: updatePkg
7499
+ },
7500
+ "prettier-format": {
7501
+ desc: "prettier\u683C\u5F0F\u5316",
7502
+ action: prettierFormat
7503
+ },
7504
+ "eslint-prettier": {
7505
+ desc: "eslint\u548Cprettier\u683C\u5F0F\u5316",
7506
+ action: eslintPretter
7507
+ },
7508
+ "lint-staged": {
7509
+ desc: "\u6267\u884Clint-staged",
7510
+ action: lintStaged
7511
+ }
7512
+ };
7513
+ Object.entries(commands).forEach(([command, { desc, action }]) => {
7514
+ cli.command(command, desc).action(action);
7562
7515
  });
7563
- commander.program.version(pkg.version).description(kolorist.blue("soybean alias soy\n\nhttps://github.com/soybeanjs/cli"));
7564
- commander.program.parse(process.argv);
7516
+ cli.parse();
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { program } from 'commander';
3
- import { bgRed, red, green, blue } from 'kolorist';
2
+ import cac from 'cac';
4
3
  import enquirer from 'enquirer';
5
4
  import { execa } from 'execa';
6
5
  import * as actualFS from 'fs';
7
6
  import { readFileSync, realpathSync as realpathSync$1, lstatSync, readdir, readdirSync, readlinkSync, existsSync } from 'fs';
7
+ import { bgRed, red, green } from 'kolorist';
8
8
  import { rimraf } from 'rimraf';
9
9
  import { win32, posix } from 'path';
10
10
  import { fileURLToPath } from 'url';
@@ -13,89 +13,7 @@ import EE from 'events';
13
13
  import Stream from 'stream';
14
14
  import stringdecoder from 'string_decoder';
15
15
 
16
- const name = "@soybeanjs/cli";
17
- const version = "0.3.1";
18
- const description = "SoybeanJS's command line tools";
19
- const author = {
20
- name: "Soybean",
21
- email: "honghuangdc@gmail.com",
22
- url: "https://github.com/honghuangdc"
23
- };
24
- const license = "MIT";
25
- const homepage = "https://github.com/honghuangdc/soybean-cli";
26
- const repository = {
27
- url: "https://github.com/honghuangdc/soybean-cli.git"
28
- };
29
- const bugs = {
30
- url: "https://github.com/honghuangdc/soybean-cli/issues"
31
- };
32
- const publishConfig = {
33
- registry: "https://registry.npmjs.org/"
34
- };
35
- const bin = {
36
- soybean: "dist/index.mjs",
37
- soy: "dist/index.mjs"
38
- };
39
- const files = [
40
- "dist"
41
- ];
42
- const scripts = {
43
- build: "pnpm typecheck && unbuild",
44
- lint: "eslint . --fix",
45
- format: "soy prettier-format",
46
- commit: "soy git-commit",
47
- cleanup: "soy cleanup",
48
- "update-pkg": "soy update-pkg",
49
- "update-version": "bumpp --commit --push --tag",
50
- "publish-pkg": "pnpm -r publish --access public",
51
- typecheck: "tsc --noEmit",
52
- release: "pnpm update-version && pnpm build && pnpm publish-pkg"
53
- };
54
- const dependencies = {
55
- commander: "10.0.1",
56
- enquirer: "2.3.6",
57
- execa: "7.1.1",
58
- kolorist: "1.8.0",
59
- minimist: "1.2.8",
60
- "npm-check-updates": "16.10.12",
61
- rimraf: "5.0.1"
62
- };
63
- const devDependencies = {
64
- "@soybeanjs/cli": "link:",
65
- "@types/node": "20.2.5",
66
- bumpp: "9.1.0",
67
- eslint: "8.41.0",
68
- "eslint-config-soybeanjs": "0.4.7",
69
- "lint-staged": "13.2.2",
70
- "simple-git-hooks": "2.8.1",
71
- tsx: "3.12.7",
72
- typescript: "5.0.4",
73
- unbuild: "1.2.1"
74
- };
75
- const pkg = {
76
- name: name,
77
- version: version,
78
- description: description,
79
- author: author,
80
- license: license,
81
- homepage: homepage,
82
- repository: repository,
83
- bugs: bugs,
84
- publishConfig: publishConfig,
85
- bin: bin,
86
- files: files,
87
- scripts: scripts,
88
- dependencies: dependencies,
89
- devDependencies: devDependencies,
90
- "simple-git-hooks": {
91
- "commit-msg": "pnpm soy git-commit-verify",
92
- "pre-commit": "pnpm typecheck && pnpm lint-staged"
93
- },
94
- "lint-staged": {
95
- "*.{js,mjs,jsx,ts,mts,tsx,json,vue,svelte,astro}": "eslint . --fix",
96
- "*.!{js,mjs,jsx,ts,mts,tsx,json,vue,svelte,astro}": "format"
97
- }
98
- };
16
+ const version = "0.4.0";
99
17
 
100
18
  const gitCommitTypes = [
101
19
  { value: "init", title: "init: \u9879\u76EE\u521D\u59CB\u5316" },
@@ -7521,23 +7439,56 @@ function prettierFormat() {
7521
7439
  });
7522
7440
  }
7523
7441
 
7524
- program.command("git-commit").description("\u751F\u6210\u7B26\u5408 Angular \u89C4\u8303\u7684 git commit").action(() => {
7525
- gitCommit();
7526
- });
7527
- program.command("git-commit-verify").description("\u6821\u9A8Cgit\u7684commit\u662F\u5426\u7B26\u5408 Angular \u89C4\u8303").action(() => {
7528
- gitCommitVerify();
7529
- });
7530
- program.command("cleanup").description("\u6E05\u7A7A\u4F9D\u8D56\u548C\u6784\u5EFA\u4EA7\u7269").action(() => {
7531
- cleanup();
7532
- });
7533
- program.command("init-git-hooks").description("\u521D\u59CB\u5316simple-git-hooks\u94A9\u5B50").action(() => {
7534
- initSimpleGitHooks();
7535
- });
7536
- program.command("update-pkg").description("\u5347\u7EA7\u4F9D\u8D56").action(() => {
7537
- updatePkg();
7538
- });
7539
- program.command("prettier-format").description("prettier\u683C\u5F0F\u5316").action(() => {
7540
- prettierFormat();
7442
+ async function eslintPretter() {
7443
+ await execa("npx", ["eslint", ".", "--fix"], {
7444
+ stdio: "inherit"
7445
+ });
7446
+ await execa("npx", ["soy", "prettier-format"], {
7447
+ stdio: "inherit"
7448
+ });
7449
+ }
7450
+
7451
+ function lintStaged() {
7452
+ execa("npx", ["lint-staged", "--config", "@soybeanjs/cli/lint-staged"], { stdio: "inherit" });
7453
+ }
7454
+
7455
+ const cli = cac("soybean");
7456
+ cli.version(version).help();
7457
+ const commands = {
7458
+ "git-commit": {
7459
+ desc: "\u751F\u6210\u7B26\u5408 Angular \u89C4\u8303\u7684 git commit",
7460
+ action: gitCommit
7461
+ },
7462
+ "git-commit-verify": {
7463
+ desc: "\u6821\u9A8Cgit\u7684commit\u662F\u5426\u7B26\u5408 Angular \u89C4\u8303",
7464
+ action: gitCommitVerify
7465
+ },
7466
+ cleanup: {
7467
+ desc: "\u6E05\u7A7A\u4F9D\u8D56\u548C\u6784\u5EFA\u4EA7\u7269",
7468
+ action: cleanup
7469
+ },
7470
+ "init-git-hooks": {
7471
+ desc: "\u521D\u59CB\u5316simple-git-hooks\u94A9\u5B50",
7472
+ action: initSimpleGitHooks
7473
+ },
7474
+ "update-pkg": {
7475
+ desc: "\u5347\u7EA7\u4F9D\u8D56",
7476
+ action: updatePkg
7477
+ },
7478
+ "prettier-format": {
7479
+ desc: "prettier\u683C\u5F0F\u5316",
7480
+ action: prettierFormat
7481
+ },
7482
+ "eslint-prettier": {
7483
+ desc: "eslint\u548Cprettier\u683C\u5F0F\u5316",
7484
+ action: eslintPretter
7485
+ },
7486
+ "lint-staged": {
7487
+ desc: "\u6267\u884Clint-staged",
7488
+ action: lintStaged
7489
+ }
7490
+ };
7491
+ Object.entries(commands).forEach(([command, { desc, action }]) => {
7492
+ cli.command(command, desc).action(action);
7541
7493
  });
7542
- program.version(pkg.version).description(blue("soybean alias soy\n\nhttps://github.com/soybeanjs/cli"));
7543
- program.parse(process.argv);
7494
+ cli.parse();
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ const config = {
4
+ "*": "soy eslint-prettier"
5
+ };
6
+
7
+ module.exports = config;
@@ -0,0 +1,5 @@
1
+ const config = {
2
+ "*": "soy eslint-prettier"
3
+ };
4
+
5
+ export { config as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soybeanjs/cli",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "SoybeanJS's command line tools",
5
5
  "author": {
6
6
  "name": "Soybean",
@@ -8,16 +8,22 @@
8
8
  "url": "https://github.com/honghuangdc"
9
9
  },
10
10
  "license": "MIT",
11
- "homepage": "https://github.com/honghuangdc/soybean-cli",
11
+ "homepage": "https://github.com/soybeanjs/soybean-cli",
12
12
  "repository": {
13
- "url": "https://github.com/honghuangdc/soybean-cli.git"
13
+ "url": "https://github.com/soybeanjs/soybean-cli.git"
14
14
  },
15
15
  "bugs": {
16
- "url": "https://github.com/honghuangdc/soybean-cli/issues"
16
+ "url": "https://github.com/soybeanjs/soybean-cli/issues"
17
17
  },
18
18
  "publishConfig": {
19
19
  "registry": "https://registry.npmjs.org/"
20
20
  },
21
+ "exports": {
22
+ "./lint-staged": {
23
+ "import": "./dist/lint-staged.config.mjs",
24
+ "require": "./dist/lint-staged.config.cjs"
25
+ }
26
+ },
21
27
  "bin": {
22
28
  "soybean": "dist/index.mjs",
23
29
  "soy": "dist/index.mjs"
@@ -26,10 +32,11 @@
26
32
  "dist"
27
33
  ],
28
34
  "dependencies": {
29
- "commander": "10.0.1",
35
+ "cac": "^6.7.14",
30
36
  "enquirer": "2.3.6",
31
37
  "execa": "7.1.1",
32
38
  "kolorist": "1.8.0",
39
+ "lint-staged": "13.2.2",
33
40
  "minimist": "1.2.8",
34
41
  "npm-check-updates": "16.10.12",
35
42
  "rimraf": "5.0.1"
@@ -40,7 +47,6 @@
40
47
  "bumpp": "9.1.0",
41
48
  "eslint": "8.41.0",
42
49
  "eslint-config-soybeanjs": "0.4.7",
43
- "lint-staged": "13.2.2",
44
50
  "simple-git-hooks": "2.8.1",
45
51
  "tsx": "3.12.7",
46
52
  "typescript": "5.0.4",
@@ -48,11 +54,7 @@
48
54
  },
49
55
  "simple-git-hooks": {
50
56
  "commit-msg": "pnpm soy git-commit-verify",
51
- "pre-commit": "pnpm typecheck && pnpm lint-staged"
52
- },
53
- "lint-staged": {
54
- "*.{js,mjs,jsx,ts,mts,tsx,json,vue,svelte,astro}": "eslint . --fix",
55
- "*.!{js,mjs,jsx,ts,mts,tsx,json,vue,svelte,astro}": "format"
57
+ "pre-commit": "pnpm typecheck && pnpm soy lint-staged"
56
58
  },
57
59
  "scripts": {
58
60
  "build": "pnpm typecheck && unbuild",