@gct-paas/cli 0.0.1-dev.1 → 0.0.1-dev.10
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/LICENSE +21 -0
- package/dist/actions/gen-api/api-manage.cjs +46 -0
- package/dist/actions/gen-api/api-manage.d.ts +36 -0
- package/dist/actions/gen-api/gen-api.cjs +157 -0
- package/dist/actions/gen-api/gen-api.d.ts +58 -0
- package/dist/actions/gen-api/model-manage.cjs +127 -0
- package/dist/actions/gen-api/model-manage.d.ts +124 -0
- package/dist/actions/index.cjs +12 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/bin.cjs +5 -0
- package/dist/bin.d.ts +2 -0
- package/dist/commands/gen-api/gen-api.cjs +16 -0
- package/dist/commands/gen-api/gen-api.d.ts +44 -0
- package/dist/commands/index.cjs +23 -0
- package/dist/commands/index.d.ts +5 -0
- package/dist/core/handlebars/constant/index.cjs +8 -0
- package/dist/core/handlebars/constant/index.d.ts +2 -0
- package/dist/core/handlebars/handlebars-engine.cjs +134 -0
- package/dist/core/handlebars/handlebars-engine.d.ts +74 -0
- package/dist/core/handlebars/helpers/and/and.cjs +21 -0
- package/dist/core/handlebars/helpers/and/and.d.ts +13 -0
- package/dist/core/handlebars/helpers/camel-case/camel-case.cjs +20 -0
- package/dist/core/handlebars/helpers/camel-case/camel-case.d.ts +13 -0
- package/dist/core/handlebars/helpers/concat/concat.cjs +17 -0
- package/dist/core/handlebars/helpers/concat/concat.d.ts +13 -0
- package/dist/core/handlebars/helpers/eq/eq.cjs +19 -0
- package/dist/core/handlebars/helpers/eq/eq.d.ts +14 -0
- package/dist/core/handlebars/helpers/format-import/format-import.cjs +41 -0
- package/dist/core/handlebars/helpers/format-import/format-import.d.ts +13 -0
- package/dist/core/handlebars/helpers/format-import-item/format-import-item.cjs +37 -0
- package/dist/core/handlebars/helpers/format-import-item/format-import-item.d.ts +13 -0
- package/dist/core/handlebars/helpers/format-js-type/format-js-type.cjs +41 -0
- package/dist/core/handlebars/helpers/format-js-type/format-js-type.d.ts +14 -0
- package/dist/core/handlebars/helpers/gt/gt.cjs +19 -0
- package/dist/core/handlebars/helpers/gt/gt.d.ts +14 -0
- package/dist/core/handlebars/helpers/gte/gte.cjs +19 -0
- package/dist/core/handlebars/helpers/gte/gte.d.ts +14 -0
- package/dist/core/handlebars/helpers/helper-base.cjs +19 -0
- package/dist/core/handlebars/helpers/helper-base.d.ts +22 -0
- package/dist/core/handlebars/helpers/includes/includes.cjs +18 -0
- package/dist/core/handlebars/helpers/includes/includes.d.ts +13 -0
- package/dist/core/handlebars/helpers/index.cjs +52 -0
- package/dist/core/handlebars/helpers/index.d.ts +6 -0
- package/dist/core/handlebars/helpers/json/json.cjs +16 -0
- package/dist/core/handlebars/helpers/json/json.d.ts +13 -0
- package/dist/core/handlebars/helpers/lower-case/lower-case.cjs +19 -0
- package/dist/core/handlebars/helpers/lower-case/lower-case.d.ts +13 -0
- package/dist/core/handlebars/helpers/lt/lt.cjs +19 -0
- package/dist/core/handlebars/helpers/lt/lt.d.ts +14 -0
- package/dist/core/handlebars/helpers/lte/lte.cjs +19 -0
- package/dist/core/handlebars/helpers/lte/lte.d.ts +14 -0
- package/dist/core/handlebars/helpers/neq/neq.cjs +19 -0
- package/dist/core/handlebars/helpers/neq/neq.d.ts +14 -0
- package/dist/core/handlebars/helpers/not/not.cjs +21 -0
- package/dist/core/handlebars/helpers/not/not.d.ts +14 -0
- package/dist/core/handlebars/helpers/not-includes/not-includes.cjs +18 -0
- package/dist/core/handlebars/helpers/not-includes/not-includes.d.ts +13 -0
- package/dist/core/handlebars/helpers/or/or.cjs +23 -0
- package/dist/core/handlebars/helpers/or/or.d.ts +13 -0
- package/dist/core/handlebars/helpers/pascal-case/pascal-case.cjs +20 -0
- package/dist/core/handlebars/helpers/pascal-case/pascal-case.d.ts +13 -0
- package/dist/core/handlebars/helpers/snake-case/snake-case.cjs +20 -0
- package/dist/core/handlebars/helpers/snake-case/snake-case.d.ts +13 -0
- package/dist/core/handlebars/helpers/spinal-case/spinal-case.cjs +20 -0
- package/dist/core/handlebars/helpers/spinal-case/spinal-case.d.ts +13 -0
- package/dist/core/handlebars/helpers/upper-case/upper-case.cjs +19 -0
- package/dist/core/handlebars/helpers/upper-case/upper-case.d.ts +13 -0
- package/dist/core/handlebars/index.cjs +27 -0
- package/dist/core/handlebars/index.d.ts +2 -0
- package/dist/core/handlebars/utils/helper/helper.cjs +41 -0
- package/dist/core/handlebars/utils/helper/helper.d.ts +33 -0
- package/dist/core/handlebars/utils/index.cjs +20 -0
- package/dist/core/handlebars/utils/index.d.ts +17 -0
- package/dist/core/index.cjs +27 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/interface/index.cjs +1 -0
- package/dist/core/interface/index.d.ts +1 -0
- package/dist/index.cjs +47 -0
- package/dist/index.d.ts +2 -0
- package/dist/interface/i-command/i-command.cjs +1 -0
- package/dist/interface/i-command/i-command.d.ts +22 -0
- package/dist/interface/index.cjs +16 -0
- package/dist/utils/index.cjs +18 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/local-binaries/local-binaries.cjs +19 -0
- package/dist/utils/local-binaries/local-binaries.d.ts +3 -0
- package/es/actions/gen-api/api-manage.d.ts +36 -0
- package/es/actions/gen-api/api-manage.mjs +38 -0
- package/es/actions/gen-api/gen-api.d.ts +58 -0
- package/es/actions/gen-api/gen-api.mjs +164 -0
- package/es/actions/gen-api/model-manage.d.ts +124 -0
- package/es/actions/gen-api/model-manage.mjs +126 -0
- package/es/actions/index.d.ts +1 -0
- package/es/actions/index.mjs +1 -0
- package/es/bin.d.ts +2 -0
- package/es/commands/gen-api/gen-api.d.ts +44 -0
- package/es/commands/gen-api/gen-api.mjs +15 -0
- package/es/commands/index.d.ts +5 -0
- package/es/commands/index.mjs +16 -0
- package/es/core/handlebars/constant/index.d.ts +2 -0
- package/es/core/handlebars/constant/index.mjs +2 -0
- package/es/core/handlebars/handlebars-engine.d.ts +74 -0
- package/es/core/handlebars/handlebars-engine.mjs +122 -0
- package/es/core/handlebars/helpers/and/and.d.ts +13 -0
- package/es/core/handlebars/helpers/and/and.mjs +14 -0
- package/es/core/handlebars/helpers/camel-case/camel-case.d.ts +13 -0
- package/es/core/handlebars/helpers/camel-case/camel-case.mjs +13 -0
- package/es/core/handlebars/helpers/concat/concat.d.ts +13 -0
- package/es/core/handlebars/helpers/concat/concat.mjs +10 -0
- package/es/core/handlebars/helpers/eq/eq.d.ts +14 -0
- package/es/core/handlebars/helpers/eq/eq.mjs +12 -0
- package/es/core/handlebars/helpers/format-import/format-import.d.ts +13 -0
- package/es/core/handlebars/helpers/format-import/format-import.mjs +34 -0
- package/es/core/handlebars/helpers/format-import-item/format-import-item.d.ts +13 -0
- package/es/core/handlebars/helpers/format-import-item/format-import-item.mjs +30 -0
- package/es/core/handlebars/helpers/format-js-type/format-js-type.d.ts +14 -0
- package/es/core/handlebars/helpers/format-js-type/format-js-type.mjs +34 -0
- package/es/core/handlebars/helpers/gt/gt.d.ts +14 -0
- package/es/core/handlebars/helpers/gt/gt.mjs +12 -0
- package/es/core/handlebars/helpers/gte/gte.d.ts +14 -0
- package/es/core/handlebars/helpers/gte/gte.mjs +12 -0
- package/es/core/handlebars/helpers/helper-base.d.ts +22 -0
- package/es/core/handlebars/helpers/helper-base.mjs +11 -0
- package/es/core/handlebars/helpers/includes/includes.d.ts +13 -0
- package/es/core/handlebars/helpers/includes/includes.mjs +11 -0
- package/es/core/handlebars/helpers/index.d.ts +6 -0
- package/es/core/handlebars/helpers/index.mjs +46 -0
- package/es/core/handlebars/helpers/json/json.d.ts +13 -0
- package/es/core/handlebars/helpers/json/json.mjs +13 -0
- package/es/core/handlebars/helpers/lower-case/lower-case.d.ts +13 -0
- package/es/core/handlebars/helpers/lower-case/lower-case.mjs +12 -0
- package/es/core/handlebars/helpers/lt/lt.d.ts +14 -0
- package/es/core/handlebars/helpers/lt/lt.mjs +12 -0
- package/es/core/handlebars/helpers/lte/lte.d.ts +14 -0
- package/es/core/handlebars/helpers/lte/lte.mjs +12 -0
- package/es/core/handlebars/helpers/neq/neq.d.ts +14 -0
- package/es/core/handlebars/helpers/neq/neq.mjs +12 -0
- package/es/core/handlebars/helpers/not/not.d.ts +14 -0
- package/es/core/handlebars/helpers/not/not.mjs +12 -0
- package/es/core/handlebars/helpers/not-includes/not-includes.d.ts +13 -0
- package/es/core/handlebars/helpers/not-includes/not-includes.mjs +11 -0
- package/es/core/handlebars/helpers/or/or.d.ts +13 -0
- package/es/core/handlebars/helpers/or/or.mjs +16 -0
- package/es/core/handlebars/helpers/pascal-case/pascal-case.d.ts +13 -0
- package/es/core/handlebars/helpers/pascal-case/pascal-case.mjs +13 -0
- package/es/core/handlebars/helpers/snake-case/snake-case.d.ts +13 -0
- package/es/core/handlebars/helpers/snake-case/snake-case.mjs +13 -0
- package/es/core/handlebars/helpers/spinal-case/spinal-case.d.ts +13 -0
- package/es/core/handlebars/helpers/spinal-case/spinal-case.mjs +13 -0
- package/es/core/handlebars/helpers/upper-case/upper-case.d.ts +13 -0
- package/es/core/handlebars/helpers/upper-case/upper-case.mjs +12 -0
- package/es/core/handlebars/index.d.ts +2 -0
- package/es/core/handlebars/index.mjs +2 -0
- package/es/core/handlebars/utils/helper/helper.d.ts +33 -0
- package/es/core/handlebars/utils/helper/helper.mjs +54 -0
- package/es/core/handlebars/utils/index.d.ts +17 -0
- package/es/core/handlebars/utils/index.mjs +7 -0
- package/es/core/index.d.ts +2 -0
- package/es/core/index.mjs +2 -0
- package/es/core/interface/index.d.ts +1 -0
- package/es/core/interface/index.mjs +0 -0
- package/es/index.d.ts +2 -0
- package/es/interface/i-command/i-command.d.ts +22 -0
- package/es/interface/i-command/i-command.mjs +0 -0
- package/es/interface/index.d.ts +1 -0
- package/es/interface/index.mjs +1 -0
- package/es/types/index.d.ts +1 -0
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.mjs +4 -0
- package/es/utils/local-binaries/local-binaries.d.ts +3 -0
- package/es/utils/local-binaries/local-binaries.mjs +11 -0
- package/package.json +29 -47
- package/src/bin.ts +0 -5
- package/src/commands/index.ts +0 -16
- package/src/core/commitlint/commitlint-config/commitlint-config.ts +0 -37
- package/src/core/commitlint/index.ts +0 -1
- package/src/core/constants/index.ts +0 -8
- package/src/core/eslint/eslint-config/eslint-config.ts +0 -122
- package/src/core/eslint/index.ts +0 -1
- package/src/core/index.ts +0 -7
- package/src/core/prettier/index.ts +0 -1
- package/src/core/prettier/prettier-config/prettier-config.ts +0 -48
- package/src/core/rollup/index.ts +0 -2
- package/src/core/rollup/rollup-config/dev-config.ts +0 -135
- package/src/core/rollup/rollup-plugins/copy-file.ts +0 -57
- package/src/core/rollup/rollup-plugins/ignore-compiler-file.ts +0 -25
- package/src/core/rollup/rollup-plugins/index.ts +0 -2
- package/src/core/stylelint/index.ts +0 -1
- package/src/core/stylelint/stylelint-config/stylelint-config.ts +0 -28
- package/src/core/util/index.ts +0 -27
- package/src/core/util/watcher/watcher.ts +0 -129
- package/src/core/vite/index.ts +0 -1
- package/src/core/vite/vite-config/vite-config.ts +0 -59
- package/src/index.ts +0 -36
- package/src/interface/i-command/i-command.ts +0 -29
- package/src/utils/index.ts +0 -4
- package/src/utils/local-binaries/local-binaries.ts +0 -16
- /package/{src/interface/index.ts → dist/interface/index.d.ts} +0 -0
- /package/{src → dist}/types/index.d.ts +0 -0
- /package/{dist → es}/bin.mjs +0 -0
- /package/{dist → es}/index.mjs +0 -0
|
File without changes
|
package/es/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* 命令项
|
|
4
|
+
*
|
|
5
|
+
* @export
|
|
6
|
+
* @interface ICommand
|
|
7
|
+
*/
|
|
8
|
+
export interface ICommand {
|
|
9
|
+
/**
|
|
10
|
+
* 加载命令
|
|
11
|
+
*
|
|
12
|
+
* @param {Command} program
|
|
13
|
+
*/
|
|
14
|
+
load(program: Command): void;
|
|
15
|
+
/**
|
|
16
|
+
* 执行行为
|
|
17
|
+
*
|
|
18
|
+
* @param {...unknown[]} args
|
|
19
|
+
* @return {*} {(void | Promise<void>)}
|
|
20
|
+
*/
|
|
21
|
+
action(...args: unknown[]): void | Promise<void>;
|
|
22
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './i-command/i-command';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./i-command/i-command.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module 'eslint-plugin-import';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { localBinExists, loadLocalBinCommandLoader, } from './local-binaries/local-binaries';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { join, posix } from "path";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
const localBinPathSegments = [process.cwd(), "node_modules", "@nestjs", "cli"];
|
|
4
|
+
export function localBinExists() {
|
|
5
|
+
return fs.existsSync(join(...localBinPathSegments));
|
|
6
|
+
}
|
|
7
|
+
export function loadLocalBinCommandLoader() {
|
|
8
|
+
const path = posix.join(...localBinPathSegments, "commands");
|
|
9
|
+
const commandsFile = require(path);
|
|
10
|
+
return commandsFile.CommandLoader;
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gct-paas/cli",
|
|
3
|
-
"version": "0.0.1-dev.
|
|
3
|
+
"version": "0.0.1-dev.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "paas 平台核心包",
|
|
6
6
|
"bin": {
|
|
7
|
-
"gct-
|
|
7
|
+
"gct-paas": "es/bin.mjs"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/index.cjs",
|
|
10
|
+
"module": "es/index.mjs",
|
|
11
|
+
"types": "es/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./es/index.d.ts",
|
|
15
|
+
"import": "./es/index.mjs",
|
|
16
|
+
"require": "./dist/index.cjs"
|
|
17
|
+
}
|
|
8
18
|
},
|
|
9
|
-
"main": "dist/index.mjs",
|
|
10
|
-
"types": "dist/index.d.ts",
|
|
11
19
|
"files": [
|
|
12
|
-
"
|
|
20
|
+
"dist",
|
|
21
|
+
"es",
|
|
13
22
|
"CHANGELOG.md",
|
|
14
23
|
"README.md"
|
|
15
24
|
],
|
|
@@ -33,53 +42,26 @@
|
|
|
33
42
|
"publish:npm": "npm run build && npm publish --access public --registry=https://registry.npmjs.org/"
|
|
34
43
|
},
|
|
35
44
|
"dependencies": {
|
|
36
|
-
"@
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"@eslint/js": "^9.17.0",
|
|
41
|
-
"@rollup/plugin-babel": "^6.0.4",
|
|
42
|
-
"@rollup/plugin-commonjs": "^28.0.2",
|
|
43
|
-
"@rollup/plugin-eslint": "^9.0.5",
|
|
44
|
-
"@rollup/plugin-json": "^6.1.0",
|
|
45
|
-
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
46
|
-
"@vitejs/plugin-vue": "^5.2.1",
|
|
47
|
-
"@vitejs/plugin-vue-jsx": "^4.1.1",
|
|
48
|
-
"@vue/compiler-sfc": "^3.5.13",
|
|
49
|
-
"chokidar": "^4.0.3",
|
|
50
|
-
"commander": "^13.0.0",
|
|
51
|
-
"consola": "^3.3.3",
|
|
52
|
-
"copy-file": "^11.0.0",
|
|
53
|
-
"cpy": "^11.1.0",
|
|
54
|
-
"eslint": "^9.17.0",
|
|
55
|
-
"eslint-plugin-import": "^2.31.0",
|
|
56
|
-
"eslint-plugin-prettier": "^5.2.1",
|
|
57
|
-
"eslint-plugin-unused-imports": "^4.1.4",
|
|
58
|
-
"eslint-plugin-vue": "^9.32.0",
|
|
45
|
+
"@inquirer/prompts": "^7.3.1",
|
|
46
|
+
"commander": "^13.1.0",
|
|
47
|
+
"consola": "^3.4.0",
|
|
48
|
+
"core-js": "^3.40.0",
|
|
59
49
|
"fast-glob": "^3.3.3",
|
|
60
|
-
"fs-extra": "^11.
|
|
61
|
-
"
|
|
50
|
+
"fs-extra": "^11.3.0",
|
|
51
|
+
"got": "^14.4.6",
|
|
52
|
+
"handlebars": "^4.7.8",
|
|
53
|
+
"handlebars-helpers": "^0.10.0",
|
|
62
54
|
"lodash-es": "^4.17.21",
|
|
55
|
+
"ora": "^8.2.0",
|
|
63
56
|
"picocolors": "^1.1.1",
|
|
64
|
-
"
|
|
65
|
-
"rimraf": "^6.0.1",
|
|
66
|
-
"rollup": "^4.30.0",
|
|
67
|
-
"rollup-plugin-esbuild": "^6.1.1",
|
|
68
|
-
"stylelint": "^16.12.0",
|
|
69
|
-
"stylelint-config-standard": "^36.0.1",
|
|
70
|
-
"stylelint-config-standard-scss": "^14.0.0",
|
|
71
|
-
"typescript-eslint": "^8.19.0",
|
|
72
|
-
"vite-plugin-dts": "^4.4.0",
|
|
73
|
-
"vue-tsc": "^2.2.0"
|
|
57
|
+
"rimraf": "^6.0.1"
|
|
74
58
|
},
|
|
75
59
|
"devDependencies": {
|
|
76
|
-
"@commitlint/types": "^19.5.0",
|
|
77
|
-
"@types/babel__core": "^7.20.5",
|
|
78
|
-
"@types/babel__preset-env": "^7.9.7",
|
|
79
60
|
"@types/fs-extra": "^11.0.4",
|
|
80
61
|
"@types/lodash-es": "^4.17.12",
|
|
81
|
-
"@types/node": "^22.
|
|
82
|
-
"typescript": "^5.7.
|
|
83
|
-
"unbuild": "^3.
|
|
84
|
-
}
|
|
62
|
+
"@types/node": "^22.13.1",
|
|
63
|
+
"typescript": "^5.7.3",
|
|
64
|
+
"unbuild": "^3.3.1"
|
|
65
|
+
},
|
|
66
|
+
"gitHead": "6bdbbb867c581cc85c4fc75ada7560310194aac0"
|
|
85
67
|
}
|
package/src/bin.ts
DELETED
package/src/commands/index.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { consola } from 'consola';
|
|
2
|
-
import { Command } from 'commander';
|
|
3
|
-
|
|
4
|
-
export class CommandLoader {
|
|
5
|
-
public static load(program: Command): void {
|
|
6
|
-
this.handleInvalidCommand(program);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
private static handleInvalidCommand(program: Command) {
|
|
10
|
-
program.on('command:*', () => {
|
|
11
|
-
consola.error(`未支持的命令: `, program.args.join(' '));
|
|
12
|
-
consola.log(`请使用 --help 查看已支持的命令.\n`);
|
|
13
|
-
process.exit(1);
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { merge } from 'lodash-es';
|
|
2
|
-
import type { UserConfig } from '@commitlint/types';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 基于基础配置,定义 commitlint 配置
|
|
6
|
-
*
|
|
7
|
-
* @export
|
|
8
|
-
* @param {UserConfig} [config={}]
|
|
9
|
-
* @returns {*} {UserConfig}
|
|
10
|
-
*/
|
|
11
|
-
export function defineCommitlintConfig(config: UserConfig = {}): UserConfig {
|
|
12
|
-
return merge(
|
|
13
|
-
{
|
|
14
|
-
extends: ['@commitlint/config-conventional'],
|
|
15
|
-
rules: {
|
|
16
|
-
'type-enum': [
|
|
17
|
-
2,
|
|
18
|
-
'always',
|
|
19
|
-
[
|
|
20
|
-
'feat',
|
|
21
|
-
'fix',
|
|
22
|
-
'docs',
|
|
23
|
-
'style',
|
|
24
|
-
'refactor',
|
|
25
|
-
'test',
|
|
26
|
-
'perf',
|
|
27
|
-
'revert',
|
|
28
|
-
'build',
|
|
29
|
-
'chore',
|
|
30
|
-
'release',
|
|
31
|
-
],
|
|
32
|
-
],
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
config,
|
|
36
|
-
);
|
|
37
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { defineCommitlintConfig } from './commitlint-config/commitlint-config';
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import eslint from '@eslint/js';
|
|
2
|
-
import tsEslint, {
|
|
3
|
-
ConfigArray,
|
|
4
|
-
InfiniteDepthConfigWithExtends,
|
|
5
|
-
} from 'typescript-eslint';
|
|
6
|
-
import eslintPluginVue from 'eslint-plugin-vue';
|
|
7
|
-
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
8
|
-
import unusedImports from 'eslint-plugin-unused-imports';
|
|
9
|
-
import eslintPluginImport from 'eslint-plugin-import';
|
|
10
|
-
import globals from 'globals';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 基于基础规则,定义 eslint 配置
|
|
14
|
-
*
|
|
15
|
-
* @export
|
|
16
|
-
* @param {...InfiniteDepthConfigWithExtends[]} configs
|
|
17
|
-
* @returns {*} {ConfigArray}
|
|
18
|
-
*/
|
|
19
|
-
export function defineEslintConfig(
|
|
20
|
-
...configs: InfiniteDepthConfigWithExtends[]
|
|
21
|
-
): ConfigArray {
|
|
22
|
-
return tsEslint.config(
|
|
23
|
-
/** js推荐配置 */
|
|
24
|
-
eslint.configs.recommended,
|
|
25
|
-
/** ts推荐配置 */
|
|
26
|
-
tsEslint.configs.strict,
|
|
27
|
-
tsEslint.configs.stylistic,
|
|
28
|
-
/** vue推荐配置 */
|
|
29
|
-
eslintPluginVue.configs['flat/recommended'],
|
|
30
|
-
eslintPluginPrettierRecommended,
|
|
31
|
-
eslintPluginImport.flatConfigs.recommended,
|
|
32
|
-
eslintPluginImport.flatConfigs.warnings,
|
|
33
|
-
eslintPluginImport.flatConfigs.errors,
|
|
34
|
-
eslintPluginImport.flatConfigs.typescript,
|
|
35
|
-
{
|
|
36
|
-
ignores: [
|
|
37
|
-
'**/node_modules',
|
|
38
|
-
'lerna.json',
|
|
39
|
-
'package.json',
|
|
40
|
-
'tsconfig.json',
|
|
41
|
-
'pnpm-lock.yaml',
|
|
42
|
-
'pnpm-workspace.yaml',
|
|
43
|
-
'eslint.config.mjs',
|
|
44
|
-
'**/dist',
|
|
45
|
-
'**/out',
|
|
46
|
-
'**/es',
|
|
47
|
-
'**/lib',
|
|
48
|
-
],
|
|
49
|
-
files: ['**/*.ts', '**.*.tsx', '**/*.vue'],
|
|
50
|
-
plugins: {
|
|
51
|
-
'unused-imports': unusedImports,
|
|
52
|
-
},
|
|
53
|
-
languageOptions: {
|
|
54
|
-
globals: {
|
|
55
|
-
...globals.browser,
|
|
56
|
-
},
|
|
57
|
-
parserOptions: {
|
|
58
|
-
ecmaFeatures: {
|
|
59
|
-
// 全局严格模式
|
|
60
|
-
impliedStrict: true,
|
|
61
|
-
// 启用 jsx
|
|
62
|
-
jsx: true,
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
rules: {
|
|
67
|
-
// 基础配置覆盖
|
|
68
|
-
'no-console': 'off',
|
|
69
|
-
'no-debugger': 'off',
|
|
70
|
-
'no-undef': 'off',
|
|
71
|
-
'no-plusplus': [
|
|
72
|
-
'error',
|
|
73
|
-
{
|
|
74
|
-
allowForLoopAfterthoughts: true,
|
|
75
|
-
},
|
|
76
|
-
],
|
|
77
|
-
'no-underscore-dangle': 'off',
|
|
78
|
-
'no-restricted-syntax': 'off',
|
|
79
|
-
'no-continue': 'off',
|
|
80
|
-
'no-unused-vars': 'off',
|
|
81
|
-
'no-extraneous-class': 'off',
|
|
82
|
-
'no-param-reassign': 'off',
|
|
83
|
-
'no-useless-constructor': 'off',
|
|
84
|
-
'no-empty-function': 'off',
|
|
85
|
-
// unused-imports 配置覆盖
|
|
86
|
-
'unused-imports/no-unused-imports': 'error',
|
|
87
|
-
'consistent-return': 'off',
|
|
88
|
-
'func-names': 'off',
|
|
89
|
-
// import 配置覆盖
|
|
90
|
-
'import/no-unresolved': 'off',
|
|
91
|
-
'import/extensions': 'off',
|
|
92
|
-
'import/prefer-default-export': 'off',
|
|
93
|
-
// vue 配置覆盖
|
|
94
|
-
'vue/no-setup-props-destructure': 'off',
|
|
95
|
-
'vue/require-default-prop': 'off',
|
|
96
|
-
// typescript 配置覆盖
|
|
97
|
-
'@typescript-eslint/no-unused-vars': [
|
|
98
|
-
'error',
|
|
99
|
-
{
|
|
100
|
-
argsIgnorePattern: '^_',
|
|
101
|
-
},
|
|
102
|
-
],
|
|
103
|
-
'@typescript-eslint/no-inferrable-types': 'off',
|
|
104
|
-
'@typescript-eslint/no-explicit-any': ['error'],
|
|
105
|
-
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
|
106
|
-
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
107
|
-
'@typescript-eslint/no-extraneous-class': 'off',
|
|
108
|
-
// 其他配置覆盖
|
|
109
|
-
'class-methods-use-this': 'off',
|
|
110
|
-
'prefer-destructuring': 'off',
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
name: 'ts-vue-override',
|
|
115
|
-
files: ['**/*.vue'],
|
|
116
|
-
rules: {
|
|
117
|
-
'@typescript-eslint/no-unused-vars': 'off',
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
...configs,
|
|
121
|
-
);
|
|
122
|
-
}
|
package/src/core/eslint/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { defineEslintConfig } from './eslint-config/eslint-config';
|
package/src/core/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { definePrettierConfig } from './prettier-config/prettier-config';
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { merge } from 'lodash-es';
|
|
2
|
-
import { Options } from 'prettier';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 基于基础配置,定义 prettier 配置
|
|
6
|
-
*
|
|
7
|
-
* @description 提交信息规范,提交格式: type: description
|
|
8
|
-
* feat: 新功能(feature)
|
|
9
|
-
* fix: 修补bug
|
|
10
|
-
* docs: 文档(documentation)
|
|
11
|
-
* style: 格式(不影响代码运行的变动)
|
|
12
|
-
* refactor: 重构(即不是新增功能,也不是修改bug的代码变动)
|
|
13
|
-
* test: 增加测试,或测试变更
|
|
14
|
-
* perf : 性能优化
|
|
15
|
-
* revert: 撤销上一次的提交
|
|
16
|
-
* build: 构建工具或构建过程等的变动,如:关联包升级等
|
|
17
|
-
* chore: 其他修改(不在上述类型中的修改)
|
|
18
|
-
* release: 发布新版本
|
|
19
|
-
*
|
|
20
|
-
* @export
|
|
21
|
-
* @param {Options} config
|
|
22
|
-
* @returns {*} {Options}
|
|
23
|
-
*/
|
|
24
|
-
export function definePrettierConfig(config: Options = {}): Options {
|
|
25
|
-
return merge(
|
|
26
|
-
{
|
|
27
|
-
// 起始格式化间隔
|
|
28
|
-
tabWidth: 2,
|
|
29
|
-
// 使用单引号
|
|
30
|
-
singleQuote: true,
|
|
31
|
-
// jsx 中使用单引号
|
|
32
|
-
jsxSingleQuote: true,
|
|
33
|
-
// 对象中的 key 是否需要引号。as-needed: 只有在必须时才要
|
|
34
|
-
quoteProps: 'as-needed',
|
|
35
|
-
// 每行结尾是否需要分号
|
|
36
|
-
trailingComma: 'all',
|
|
37
|
-
// 括号中参数前后补充空格
|
|
38
|
-
bracketSpacing: true,
|
|
39
|
-
// 箭头函数,参数是否添加括号
|
|
40
|
-
arrowParens: 'avoid',
|
|
41
|
-
// jsx 元素最后末尾的 > ,换行放置
|
|
42
|
-
bracketSameLine: false,
|
|
43
|
-
// 设置换行符
|
|
44
|
-
endOfLine: 'lf',
|
|
45
|
-
},
|
|
46
|
-
config,
|
|
47
|
-
);
|
|
48
|
-
}
|
package/src/core/rollup/index.ts
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import { defineConfig, OutputOptions, RollupOptions } from 'rollup';
|
|
2
|
-
import { merge } from 'lodash-es';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import glob from 'fast-glob';
|
|
5
|
-
import { nodeResolve } from '@rollup/plugin-node-resolve';
|
|
6
|
-
import commonjs from '@rollup/plugin-commonjs';
|
|
7
|
-
import json from '@rollup/plugin-json';
|
|
8
|
-
import esbuild from 'rollup-plugin-esbuild';
|
|
9
|
-
import dts from 'vite-plugin-dts';
|
|
10
|
-
import vue from '@vitejs/plugin-vue';
|
|
11
|
-
import vueJsx from '@vitejs/plugin-vue-jsx';
|
|
12
|
-
import * as rf from 'rimraf';
|
|
13
|
-
import cpy from 'cpy';
|
|
14
|
-
import fs from 'fs-extra';
|
|
15
|
-
import { copyFile, ignoreCompilerFile } from '../rollup-plugins';
|
|
16
|
-
import { PROD_MODE } from '../../constants';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* 开发包基础编译配置
|
|
20
|
-
*
|
|
21
|
-
* @export
|
|
22
|
-
* @param {RollupOptions} [opts={}]
|
|
23
|
-
* @returns {*} {RollupOptions}
|
|
24
|
-
*/
|
|
25
|
-
export function defineRollupConfig(opts: RollupOptions = {}): RollupOptions {
|
|
26
|
-
// 监控 ctrl + c 停止进程,触发 exit 事件
|
|
27
|
-
process.on('SIGINT', () => {
|
|
28
|
-
process.exit();
|
|
29
|
-
});
|
|
30
|
-
// 当前脚本执行的工作目录
|
|
31
|
-
const cwd = process.cwd();
|
|
32
|
-
// 是否为生产编译模式
|
|
33
|
-
const isProd = process.env.NODE_ENV === PROD_MODE;
|
|
34
|
-
// 项目脚本目录
|
|
35
|
-
const rootDir = path.resolve(cwd, 'src');
|
|
36
|
-
// es模块输出目录
|
|
37
|
-
const outDir = path.resolve(cwd, 'es');
|
|
38
|
-
// commonjs 模块输出目录
|
|
39
|
-
// const libOutDir = path.resolve(cwd, 'lib');
|
|
40
|
-
// 静态资源目录
|
|
41
|
-
const assetsDir = path.resolve(cwd, 'public');
|
|
42
|
-
|
|
43
|
-
// 需要忽略编译,以及直接拷贝的文件
|
|
44
|
-
const externalCompileFileReg = /\.(vue|scss|css|less)+$/;
|
|
45
|
-
|
|
46
|
-
// 删除之前编译的文件
|
|
47
|
-
rf.sync(outDir);
|
|
48
|
-
|
|
49
|
-
const input = glob.sync('src/**/*.{ts,tsx}', {
|
|
50
|
-
cwd,
|
|
51
|
-
absolute: true,
|
|
52
|
-
onlyFiles: true,
|
|
53
|
-
ignore: ['**/*.test.ts', '**/*.test.tsx', '**/*.d.ts'],
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
if (isProd) {
|
|
57
|
-
if (fs.pathExistsSync(assetsDir)) {
|
|
58
|
-
cpy(assetsDir, outDir);
|
|
59
|
-
}
|
|
60
|
-
cpy(path.resolve(cwd, 'src/**/*.{vue,scss,css,less}'), outDir);
|
|
61
|
-
} else {
|
|
62
|
-
// 拷贝静态资源目录,和排除编译的文件
|
|
63
|
-
copyFile([
|
|
64
|
-
{
|
|
65
|
-
from: assetsDir,
|
|
66
|
-
to: outDir,
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
from: rootDir,
|
|
70
|
-
to: outDir,
|
|
71
|
-
opts: {
|
|
72
|
-
ignored: (file, stats) => {
|
|
73
|
-
if (stats && stats.isFile()) {
|
|
74
|
-
return !externalCompileFileReg.test(file);
|
|
75
|
-
}
|
|
76
|
-
return false;
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
]);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const output: OutputOptions[] = [
|
|
84
|
-
{
|
|
85
|
-
dir: outDir,
|
|
86
|
-
format: 'es',
|
|
87
|
-
sourcemap: false,
|
|
88
|
-
preserveModules: true,
|
|
89
|
-
preserveModulesRoot: rootDir,
|
|
90
|
-
entryFileNames: '[name].mjs',
|
|
91
|
-
},
|
|
92
|
-
];
|
|
93
|
-
|
|
94
|
-
// if (isProd) {
|
|
95
|
-
// output.push({
|
|
96
|
-
// dir: libOutDir,
|
|
97
|
-
// format: 'cjs',
|
|
98
|
-
// sourcemap: false,
|
|
99
|
-
// exports: 'named',
|
|
100
|
-
// preserveModules: true,
|
|
101
|
-
// preserveModulesRoot: rootDir,
|
|
102
|
-
// entryFileNames: '[name].cjs',
|
|
103
|
-
// });
|
|
104
|
-
// }
|
|
105
|
-
|
|
106
|
-
return merge(
|
|
107
|
-
defineConfig({
|
|
108
|
-
input,
|
|
109
|
-
treeshake: false,
|
|
110
|
-
external: ['vue'],
|
|
111
|
-
output,
|
|
112
|
-
plugins: [
|
|
113
|
-
ignoreCompilerFile(externalCompileFileReg),
|
|
114
|
-
json(),
|
|
115
|
-
nodeResolve({
|
|
116
|
-
extensions: ['.cjs', '.mjs', '.js', '.ts'],
|
|
117
|
-
}),
|
|
118
|
-
commonjs(),
|
|
119
|
-
esbuild({
|
|
120
|
-
logLevel: 'verbose',
|
|
121
|
-
sourceMap: false,
|
|
122
|
-
target: ['esnext'],
|
|
123
|
-
}),
|
|
124
|
-
vue({
|
|
125
|
-
isProduction: false,
|
|
126
|
-
}),
|
|
127
|
-
vueJsx({}),
|
|
128
|
-
dts({
|
|
129
|
-
outDir: [outDir],
|
|
130
|
-
}),
|
|
131
|
-
],
|
|
132
|
-
}),
|
|
133
|
-
opts,
|
|
134
|
-
);
|
|
135
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import * as chokidar from 'chokidar';
|
|
2
|
-
import { CopyWatch } from '../../util';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 文件拷贝插件配置参数
|
|
6
|
-
*
|
|
7
|
-
* @export
|
|
8
|
-
* @interface CopyFilePluginOptions
|
|
9
|
-
*/
|
|
10
|
-
export interface CopyFilePluginOptions {
|
|
11
|
-
/**
|
|
12
|
-
* 源文件
|
|
13
|
-
*
|
|
14
|
-
* @type {string}
|
|
15
|
-
* @memberof CopyFilePluginOptions
|
|
16
|
-
*/
|
|
17
|
-
from: string;
|
|
18
|
-
/**
|
|
19
|
-
* 目标文件
|
|
20
|
-
*
|
|
21
|
-
* @type {string}
|
|
22
|
-
* @memberof CopyFilePluginOptions
|
|
23
|
-
*/
|
|
24
|
-
to: string;
|
|
25
|
-
/**
|
|
26
|
-
* chokidar watch 配置
|
|
27
|
-
*
|
|
28
|
-
* @type {chokidar.ChokidarOptions}
|
|
29
|
-
*/
|
|
30
|
-
opts?: chokidar.ChokidarOptions;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* 文件拷贝插件,在开发模式下会监控文件变更,并自动拷贝文件
|
|
35
|
-
*
|
|
36
|
-
* @export
|
|
37
|
-
* @param {CopyFilePluginOptions[]} opts
|
|
38
|
-
* @return {*} {Plugin}
|
|
39
|
-
*/
|
|
40
|
-
export function copyFile(opts: CopyFilePluginOptions[]): void {
|
|
41
|
-
if (opts.length === 0) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const arr: CopyWatch[] = [];
|
|
45
|
-
opts.forEach(opt => {
|
|
46
|
-
arr.push(new CopyWatch(opt.from, opt.to, opt.opts));
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
process.on('exit', () => {
|
|
50
|
-
if (!opts.length) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
arr.forEach(item => {
|
|
54
|
-
item.unwatch();
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Plugin } from 'rollup';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 忽略编译的文件类型
|
|
5
|
-
*
|
|
6
|
-
* @export
|
|
7
|
-
* @returns {*} {Plugin}
|
|
8
|
-
*/
|
|
9
|
-
export function ignoreCompilerFile(extReg: RegExp): Plugin {
|
|
10
|
-
return {
|
|
11
|
-
name: 'gct:ignore-compiler-file',
|
|
12
|
-
resolveId(source) {
|
|
13
|
-
if (extReg.test(source)) {
|
|
14
|
-
return {
|
|
15
|
-
id: source,
|
|
16
|
-
external: true,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
return null;
|
|
20
|
-
},
|
|
21
|
-
load() {
|
|
22
|
-
return null;
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { defineStylelintConfig } from './stylelint-config/stylelint-config';
|