@gct-paas/cli 0.0.1-dev.1 → 0.0.1-dev.4
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/bin.d.ts +2 -0
- package/dist/commands/index.d.ts +5 -0
- package/dist/commands/index.mjs +14 -0
- package/dist/core/commitlint/commitlint-config/commitlint-config.d.ts +9 -0
- package/dist/core/commitlint/commitlint-config/commitlint-config.mjs +28 -0
- package/dist/core/commitlint/index.mjs +1 -0
- package/dist/core/constants/index.d.ts +12 -0
- package/dist/core/constants/index.mjs +23 -0
- package/dist/core/eslint/eslint-config/eslint-config.d.ts +9 -0
- package/dist/core/eslint/eslint-config/eslint-config.mjs +109 -0
- package/dist/core/eslint/index.mjs +1 -0
- package/dist/core/index.mjs +7 -0
- package/dist/core/prettier/index.mjs +1 -0
- package/dist/core/prettier/prettier-config/prettier-config.d.ts +22 -0
- package/dist/core/prettier/prettier-config/prettier-config.mjs +26 -0
- package/dist/core/rollup/index.mjs +2 -0
- package/dist/core/rollup/rollup-config/dev-config.d.ts +9 -0
- package/dist/core/rollup/rollup-config/dev-config.mjs +98 -0
- package/dist/core/rollup/rollup-plugins/copy-file.d.ts +37 -0
- package/dist/core/rollup/rollup-plugins/copy-file.mjs +18 -0
- package/dist/core/rollup/rollup-plugins/ignore-compiler-file.d.ts +8 -0
- package/dist/core/rollup/rollup-plugins/ignore-compiler-file.mjs +17 -0
- package/dist/core/rollup/rollup-plugins/index.mjs +2 -0
- package/dist/core/stylelint/index.mjs +1 -0
- package/dist/core/stylelint/stylelint-config/stylelint-config.d.ts +9 -0
- package/dist/core/stylelint/stylelint-config/stylelint-config.mjs +21 -0
- package/{src/core/util/index.ts → dist/core/util/index.d.ts} +2 -8
- package/dist/core/util/index.mjs +7 -0
- package/dist/core/util/watcher/watcher.d.ts +61 -0
- package/{src/core/util/watcher/watcher.ts → dist/core/util/watcher/watcher.mjs} +33 -54
- package/dist/core/vite/index.d.ts +2 -0
- package/dist/core/vite/index.mjs +2 -0
- package/dist/core/vite/vite-config/vite-config.d.ts +9 -0
- package/dist/core/vite/vite-config/vite-config.mjs +68 -0
- package/dist/core/vite/vite-config/vite-dev-config.d.ts +9 -0
- package/dist/core/vite/vite-config/vite-dev-config.mjs +19 -0
- package/dist/index.d.ts +2 -0
- package/dist/interface/i-command/i-command.d.ts +28 -0
- package/dist/interface/i-command/i-command.mjs +0 -0
- package/dist/interface/index.mjs +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.mjs +4 -0
- package/dist/utils/local-binaries/local-binaries.d.ts +3 -0
- package/dist/utils/local-binaries/local-binaries.mjs +11 -0
- package/package.json +7 -3
- 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/constants/index.ts +0 -8
- package/src/core/eslint/eslint-config/eslint-config.ts +0 -122
- package/src/core/prettier/prettier-config/prettier-config.ts +0 -48
- 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/stylelint/stylelint-config/stylelint-config.ts +0 -28
- 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/core/commitlint/index.ts → dist/core/commitlint/index.d.ts} +0 -0
- /package/{src/core/eslint/index.ts → dist/core/eslint/index.d.ts} +0 -0
- /package/{src/core/index.ts → dist/core/index.d.ts} +0 -0
- /package/{src/core/prettier/index.ts → dist/core/prettier/index.d.ts} +0 -0
- /package/{src/core/rollup/index.ts → dist/core/rollup/index.d.ts} +0 -0
- /package/{src/core/rollup/rollup-plugins/index.ts → dist/core/rollup/rollup-plugins/index.d.ts} +0 -0
- /package/{src/core/stylelint/index.ts → dist/core/stylelint/index.d.ts} +0 -0
- /package/{src/interface/index.ts → dist/interface/index.d.ts} +0 -0
- /package/{src → dist}/types/index.d.ts +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 冠骋信息技术有限公司
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { consola } from "consola";
|
|
2
|
+
export class CommandLoader {
|
|
3
|
+
static load(program) {
|
|
4
|
+
this.handleInvalidCommand(program);
|
|
5
|
+
}
|
|
6
|
+
static handleInvalidCommand(program) {
|
|
7
|
+
program.on("command:*", () => {
|
|
8
|
+
consola.error(`\u672A\u652F\u6301\u7684\u547D\u4EE4: `, program.args.join(" "));
|
|
9
|
+
consola.log(`\u8BF7\u4F7F\u7528 --help \u67E5\u770B\u5DF2\u652F\u6301\u7684\u547D\u4EE4.
|
|
10
|
+
`);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { merge } from "lodash-es";
|
|
2
|
+
export function defineCommitlintConfig(config = {}) {
|
|
3
|
+
return merge(
|
|
4
|
+
{
|
|
5
|
+
extends: ["@commitlint/config-conventional"],
|
|
6
|
+
rules: {
|
|
7
|
+
"type-enum": [
|
|
8
|
+
2,
|
|
9
|
+
"always",
|
|
10
|
+
[
|
|
11
|
+
"feat",
|
|
12
|
+
"fix",
|
|
13
|
+
"docs",
|
|
14
|
+
"style",
|
|
15
|
+
"refactor",
|
|
16
|
+
"test",
|
|
17
|
+
"perf",
|
|
18
|
+
"revert",
|
|
19
|
+
"build",
|
|
20
|
+
"chore",
|
|
21
|
+
"release"
|
|
22
|
+
]
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
config
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defineCommitlintConfig } from "./commitlint-config/commitlint-config.mjs";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 开发模式标识,匹配环境变量中的 NODE_ENV
|
|
3
|
+
*/
|
|
4
|
+
export declare const DEV_MODE = "development";
|
|
5
|
+
/**
|
|
6
|
+
* 生产编译模式标识,匹配环境变量中的 NODE_ENV
|
|
7
|
+
*/
|
|
8
|
+
export declare const PROD_MODE = "production";
|
|
9
|
+
/**
|
|
10
|
+
* 默认需要忽略编译的外部依赖
|
|
11
|
+
*/
|
|
12
|
+
export declare const DEFAULT_EXTERNAL: string[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const DEV_MODE = "development";
|
|
2
|
+
export const PROD_MODE = "production";
|
|
3
|
+
export const DEFAULT_EXTERNAL = [
|
|
4
|
+
"vue",
|
|
5
|
+
"vue-router",
|
|
6
|
+
"vue-i18n",
|
|
7
|
+
"axios",
|
|
8
|
+
"dayjs",
|
|
9
|
+
"lodash-es",
|
|
10
|
+
"qs",
|
|
11
|
+
"pinia",
|
|
12
|
+
"vuedraggable",
|
|
13
|
+
"sortablejs",
|
|
14
|
+
"vue-grid-layout",
|
|
15
|
+
"vant",
|
|
16
|
+
"ant-design-vue",
|
|
17
|
+
"@gct-paas/core",
|
|
18
|
+
"@gct-paas/design",
|
|
19
|
+
"@gct-paas/design-mobile",
|
|
20
|
+
"@gct-paas/design-web",
|
|
21
|
+
"@gct-paas/mobile",
|
|
22
|
+
"@gct-paas/web"
|
|
23
|
+
];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ConfigArray, InfiniteDepthConfigWithExtends } from 'typescript-eslint';
|
|
2
|
+
/**
|
|
3
|
+
* 基于基础规则,定义 eslint 配置
|
|
4
|
+
*
|
|
5
|
+
* @export
|
|
6
|
+
* @param {...InfiniteDepthConfigWithExtends[]} configs
|
|
7
|
+
* @returns {*} {ConfigArray}
|
|
8
|
+
*/
|
|
9
|
+
export declare function defineEslintConfig(...configs: InfiniteDepthConfigWithExtends[]): ConfigArray;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import eslint from "@eslint/js";
|
|
2
|
+
import tsEslint from "typescript-eslint";
|
|
3
|
+
import eslintPluginVue from "eslint-plugin-vue";
|
|
4
|
+
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
|
|
5
|
+
import unusedImports from "eslint-plugin-unused-imports";
|
|
6
|
+
import eslintPluginImport from "eslint-plugin-import";
|
|
7
|
+
import globals from "globals";
|
|
8
|
+
export function defineEslintConfig(...configs) {
|
|
9
|
+
return tsEslint.config(
|
|
10
|
+
/** js推荐配置 */
|
|
11
|
+
eslint.configs.recommended,
|
|
12
|
+
/** ts推荐配置 */
|
|
13
|
+
tsEslint.configs.strict,
|
|
14
|
+
tsEslint.configs.stylistic,
|
|
15
|
+
/** vue推荐配置 */
|
|
16
|
+
eslintPluginVue.configs["flat/recommended"],
|
|
17
|
+
eslintPluginPrettierRecommended,
|
|
18
|
+
eslintPluginImport.flatConfigs.recommended,
|
|
19
|
+
eslintPluginImport.flatConfigs.warnings,
|
|
20
|
+
eslintPluginImport.flatConfigs.errors,
|
|
21
|
+
eslintPluginImport.flatConfigs.typescript,
|
|
22
|
+
{
|
|
23
|
+
ignores: [
|
|
24
|
+
"**/node_modules",
|
|
25
|
+
"lerna.json",
|
|
26
|
+
"package.json",
|
|
27
|
+
"tsconfig.json",
|
|
28
|
+
"pnpm-lock.yaml",
|
|
29
|
+
"pnpm-workspace.yaml",
|
|
30
|
+
"eslint.config.mjs",
|
|
31
|
+
"**/dist",
|
|
32
|
+
"**/out",
|
|
33
|
+
"**/es",
|
|
34
|
+
"**/lib"
|
|
35
|
+
],
|
|
36
|
+
files: ["**/*.ts", "**.*.tsx", "**/*.vue"],
|
|
37
|
+
plugins: {
|
|
38
|
+
"unused-imports": unusedImports
|
|
39
|
+
},
|
|
40
|
+
languageOptions: {
|
|
41
|
+
globals: {
|
|
42
|
+
...globals.browser
|
|
43
|
+
},
|
|
44
|
+
parserOptions: {
|
|
45
|
+
ecmaFeatures: {
|
|
46
|
+
// 全局严格模式
|
|
47
|
+
impliedStrict: true,
|
|
48
|
+
// 启用 jsx
|
|
49
|
+
jsx: true
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
rules: {
|
|
54
|
+
// 基础配置覆盖
|
|
55
|
+
"no-console": "off",
|
|
56
|
+
"no-debugger": "off",
|
|
57
|
+
"no-undef": "off",
|
|
58
|
+
"no-plusplus": [
|
|
59
|
+
"error",
|
|
60
|
+
{
|
|
61
|
+
allowForLoopAfterthoughts: true
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
"no-underscore-dangle": "off",
|
|
65
|
+
"no-restricted-syntax": "off",
|
|
66
|
+
"no-continue": "off",
|
|
67
|
+
"no-unused-vars": "off",
|
|
68
|
+
"no-extraneous-class": "off",
|
|
69
|
+
"no-param-reassign": "off",
|
|
70
|
+
"no-useless-constructor": "off",
|
|
71
|
+
"no-empty-function": "off",
|
|
72
|
+
// unused-imports 配置覆盖
|
|
73
|
+
"unused-imports/no-unused-imports": "error",
|
|
74
|
+
"consistent-return": "off",
|
|
75
|
+
"func-names": "off",
|
|
76
|
+
// import 配置覆盖
|
|
77
|
+
"import/no-unresolved": "off",
|
|
78
|
+
"import/extensions": "off",
|
|
79
|
+
"import/prefer-default-export": "off",
|
|
80
|
+
// vue 配置覆盖
|
|
81
|
+
"vue/no-setup-props-destructure": "off",
|
|
82
|
+
"vue/require-default-prop": "off",
|
|
83
|
+
// typescript 配置覆盖
|
|
84
|
+
"@typescript-eslint/no-unused-vars": [
|
|
85
|
+
"error",
|
|
86
|
+
{
|
|
87
|
+
argsIgnorePattern: "^_"
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"@typescript-eslint/no-inferrable-types": "off",
|
|
91
|
+
"@typescript-eslint/no-explicit-any": ["error"],
|
|
92
|
+
"@typescript-eslint/explicit-module-boundary-types": "error",
|
|
93
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
94
|
+
"@typescript-eslint/no-extraneous-class": "off",
|
|
95
|
+
// 其他配置覆盖
|
|
96
|
+
"class-methods-use-this": "off",
|
|
97
|
+
"prefer-destructuring": "off"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: "ts-vue-override",
|
|
102
|
+
files: ["**/*.vue"],
|
|
103
|
+
rules: {
|
|
104
|
+
"@typescript-eslint/no-unused-vars": "off"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
...configs
|
|
108
|
+
);
|
|
109
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defineEslintConfig } from "./eslint-config/eslint-config.mjs";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./commitlint/index.mjs";
|
|
2
|
+
export * from "./eslint/index.mjs";
|
|
3
|
+
export * from "./prettier/index.mjs";
|
|
4
|
+
export * from "./rollup/index.mjs";
|
|
5
|
+
export * from "./stylelint/index.mjs";
|
|
6
|
+
export * from "./util/index.mjs";
|
|
7
|
+
export * from "./vite/index.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { definePrettierConfig } from "./prettier-config/prettier-config.mjs";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Options } from 'prettier';
|
|
2
|
+
/**
|
|
3
|
+
* 基于基础配置,定义 prettier 配置
|
|
4
|
+
*
|
|
5
|
+
* @description 提交信息规范,提交格式: type: description
|
|
6
|
+
* feat: 新功能(feature)
|
|
7
|
+
* fix: 修补bug
|
|
8
|
+
* docs: 文档(documentation)
|
|
9
|
+
* style: 格式(不影响代码运行的变动)
|
|
10
|
+
* refactor: 重构(即不是新增功能,也不是修改bug的代码变动)
|
|
11
|
+
* test: 增加测试,或测试变更
|
|
12
|
+
* perf : 性能优化
|
|
13
|
+
* revert: 撤销上一次的提交
|
|
14
|
+
* build: 构建工具或构建过程等的变动,如:关联包升级等
|
|
15
|
+
* chore: 其他修改(不在上述类型中的修改)
|
|
16
|
+
* release: 发布新版本
|
|
17
|
+
*
|
|
18
|
+
* @export
|
|
19
|
+
* @param {Options} config
|
|
20
|
+
* @returns {*} {Options}
|
|
21
|
+
*/
|
|
22
|
+
export declare function definePrettierConfig(config?: Options): Options;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { merge } from "lodash-es";
|
|
2
|
+
export function definePrettierConfig(config = {}) {
|
|
3
|
+
return merge(
|
|
4
|
+
{
|
|
5
|
+
// 起始格式化间隔
|
|
6
|
+
tabWidth: 2,
|
|
7
|
+
// 使用单引号
|
|
8
|
+
singleQuote: true,
|
|
9
|
+
// jsx 中使用单引号
|
|
10
|
+
jsxSingleQuote: true,
|
|
11
|
+
// 对象中的 key 是否需要引号。as-needed: 只有在必须时才要
|
|
12
|
+
quoteProps: "as-needed",
|
|
13
|
+
// 每行结尾是否需要分号
|
|
14
|
+
trailingComma: "all",
|
|
15
|
+
// 括号中参数前后补充空格
|
|
16
|
+
bracketSpacing: true,
|
|
17
|
+
// 箭头函数,参数是否添加括号
|
|
18
|
+
arrowParens: "avoid",
|
|
19
|
+
// jsx 元素最后末尾的 > ,换行放置
|
|
20
|
+
bracketSameLine: false,
|
|
21
|
+
// 设置换行符
|
|
22
|
+
endOfLine: "lf"
|
|
23
|
+
},
|
|
24
|
+
config
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { defineConfig } 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/index.mjs";
|
|
16
|
+
import { DEFAULT_EXTERNAL, PROD_MODE } from "../../constants/index.mjs";
|
|
17
|
+
export function defineRollupConfig(opts = {}) {
|
|
18
|
+
process.on("SIGINT", () => {
|
|
19
|
+
process.exit();
|
|
20
|
+
});
|
|
21
|
+
const cwd = process.cwd();
|
|
22
|
+
const isProd = process.env.NODE_ENV === PROD_MODE;
|
|
23
|
+
const rootDir = path.resolve(cwd, "src");
|
|
24
|
+
const outDir = path.resolve(cwd, "es");
|
|
25
|
+
const assetsDir = path.resolve(cwd, "public");
|
|
26
|
+
const externalCompileFileReg = /\.(vue|scss|css|less)+$/;
|
|
27
|
+
rf.sync(outDir);
|
|
28
|
+
const input = glob.sync("src/**/*.{ts,tsx}", {
|
|
29
|
+
cwd,
|
|
30
|
+
absolute: true,
|
|
31
|
+
onlyFiles: true,
|
|
32
|
+
ignore: ["**/*.test.ts", "**/*.test.tsx", "**/*.d.ts"]
|
|
33
|
+
});
|
|
34
|
+
if (isProd) {
|
|
35
|
+
if (fs.pathExistsSync(assetsDir)) {
|
|
36
|
+
cpy(assetsDir, outDir);
|
|
37
|
+
}
|
|
38
|
+
cpy(path.resolve(cwd, "src/**/*.{vue,scss,css,less}"), outDir);
|
|
39
|
+
} else {
|
|
40
|
+
copyFile([
|
|
41
|
+
{
|
|
42
|
+
from: assetsDir,
|
|
43
|
+
to: outDir
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
from: rootDir,
|
|
47
|
+
to: outDir,
|
|
48
|
+
opts: {
|
|
49
|
+
ignored: (file, stats) => {
|
|
50
|
+
if (stats && stats.isFile()) {
|
|
51
|
+
return !externalCompileFileReg.test(file);
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
]);
|
|
58
|
+
}
|
|
59
|
+
const output = [
|
|
60
|
+
{
|
|
61
|
+
dir: outDir,
|
|
62
|
+
format: "es",
|
|
63
|
+
sourcemap: false,
|
|
64
|
+
preserveModules: true,
|
|
65
|
+
preserveModulesRoot: rootDir,
|
|
66
|
+
entryFileNames: "[name].mjs"
|
|
67
|
+
}
|
|
68
|
+
];
|
|
69
|
+
return merge(
|
|
70
|
+
defineConfig({
|
|
71
|
+
input,
|
|
72
|
+
treeshake: false,
|
|
73
|
+
external: DEFAULT_EXTERNAL,
|
|
74
|
+
output,
|
|
75
|
+
plugins: [
|
|
76
|
+
ignoreCompilerFile(externalCompileFileReg),
|
|
77
|
+
json(),
|
|
78
|
+
nodeResolve({
|
|
79
|
+
extensions: [".cjs", ".mjs", ".js", ".ts"]
|
|
80
|
+
}),
|
|
81
|
+
commonjs(),
|
|
82
|
+
esbuild({
|
|
83
|
+
logLevel: "verbose",
|
|
84
|
+
sourceMap: false,
|
|
85
|
+
target: ["esnext"]
|
|
86
|
+
}),
|
|
87
|
+
vue({
|
|
88
|
+
isProduction: false
|
|
89
|
+
}),
|
|
90
|
+
vueJsx({}),
|
|
91
|
+
dts({
|
|
92
|
+
outDir: [outDir]
|
|
93
|
+
})
|
|
94
|
+
]
|
|
95
|
+
}),
|
|
96
|
+
opts
|
|
97
|
+
);
|
|
98
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as chokidar from 'chokidar';
|
|
2
|
+
/**
|
|
3
|
+
* 文件拷贝插件配置参数
|
|
4
|
+
*
|
|
5
|
+
* @export
|
|
6
|
+
* @interface CopyFilePluginOptions
|
|
7
|
+
*/
|
|
8
|
+
export interface CopyFilePluginOptions {
|
|
9
|
+
/**
|
|
10
|
+
* 源文件
|
|
11
|
+
*
|
|
12
|
+
* @type {string}
|
|
13
|
+
* @memberof CopyFilePluginOptions
|
|
14
|
+
*/
|
|
15
|
+
from: string;
|
|
16
|
+
/**
|
|
17
|
+
* 目标文件
|
|
18
|
+
*
|
|
19
|
+
* @type {string}
|
|
20
|
+
* @memberof CopyFilePluginOptions
|
|
21
|
+
*/
|
|
22
|
+
to: string;
|
|
23
|
+
/**
|
|
24
|
+
* chokidar watch 配置
|
|
25
|
+
*
|
|
26
|
+
* @type {chokidar.ChokidarOptions}
|
|
27
|
+
*/
|
|
28
|
+
opts?: chokidar.ChokidarOptions;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 文件拷贝插件,在开发模式下会监控文件变更,并自动拷贝文件
|
|
32
|
+
*
|
|
33
|
+
* @export
|
|
34
|
+
* @param {CopyFilePluginOptions[]} opts
|
|
35
|
+
* @return {*} {Plugin}
|
|
36
|
+
*/
|
|
37
|
+
export declare function copyFile(opts: CopyFilePluginOptions[]): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CopyWatch } from "../../util/index.mjs";
|
|
2
|
+
export function copyFile(opts) {
|
|
3
|
+
if (opts.length === 0) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
const arr = [];
|
|
7
|
+
opts.forEach((opt) => {
|
|
8
|
+
arr.push(new CopyWatch(opt.from, opt.to, opt.opts));
|
|
9
|
+
});
|
|
10
|
+
process.on("exit", () => {
|
|
11
|
+
if (!opts.length) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
arr.forEach((item) => {
|
|
15
|
+
item.unwatch();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function ignoreCompilerFile(extReg) {
|
|
2
|
+
return {
|
|
3
|
+
name: "gct:ignore-compiler-file",
|
|
4
|
+
resolveId(source) {
|
|
5
|
+
if (extReg.test(source)) {
|
|
6
|
+
return {
|
|
7
|
+
id: source,
|
|
8
|
+
external: true
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
},
|
|
13
|
+
load() {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { defineStylelintConfig } from "./stylelint-config/stylelint-config.mjs";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { merge } from "lodash-es";
|
|
2
|
+
export function defineStylelintConfig(config = {}) {
|
|
3
|
+
return merge(
|
|
4
|
+
{
|
|
5
|
+
extends: ["stylelint-config-standard", "stylelint-config-standard-scss"],
|
|
6
|
+
rules: {
|
|
7
|
+
"annotation-no-unknown": null,
|
|
8
|
+
"color-no-invalid-hex": true,
|
|
9
|
+
"function-name-case": null,
|
|
10
|
+
// 强制样式方法名称小写或大写
|
|
11
|
+
"no-duplicate-selectors": null,
|
|
12
|
+
"selector-class-pattern": null,
|
|
13
|
+
"scss/dollar-variable-pattern": null,
|
|
14
|
+
"scss/at-function-pattern": null,
|
|
15
|
+
"scss/dollar-variable-empty-line-before": null
|
|
16
|
+
// 变量声明之间不可以有空白行
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
config
|
|
20
|
+
);
|
|
21
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { CopyWatch } from './watcher/watcher';
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* win 路径 \\ 转 linux 路径 /
|
|
5
4
|
*
|
|
@@ -9,10 +8,7 @@ export { CopyWatch } from './watcher/watcher';
|
|
|
9
8
|
* @param {string} pathStr
|
|
10
9
|
* @return {*} {string}
|
|
11
10
|
*/
|
|
12
|
-
export function winToUnixPath(pathStr: string): string
|
|
13
|
-
return pathStr.replace(/\\/g, '/');
|
|
14
|
-
}
|
|
15
|
-
|
|
11
|
+
export declare function winToUnixPath(pathStr: string): string;
|
|
16
12
|
/**
|
|
17
13
|
* linux 路径 / 转 win 路径 \\
|
|
18
14
|
*
|
|
@@ -22,6 +18,4 @@ export function winToUnixPath(pathStr: string): string {
|
|
|
22
18
|
* @param {string} pathStr
|
|
23
19
|
* @return {*} {string}
|
|
24
20
|
*/
|
|
25
|
-
export function unixToWinPath(pathStr: string): string
|
|
26
|
-
return pathStr.replace(/\//g, '\\');
|
|
27
|
-
}
|
|
21
|
+
export declare function unixToWinPath(pathStr: string): string;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as chokidar from 'chokidar';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import { EventName } from 'chokidar/handler';
|
|
4
|
+
/**
|
|
5
|
+
* 文件监控类
|
|
6
|
+
*
|
|
7
|
+
* @author chitanda
|
|
8
|
+
* @date 2022-05-24 14:05:22
|
|
9
|
+
* @export
|
|
10
|
+
* @class CopyWatch
|
|
11
|
+
*/
|
|
12
|
+
export declare class CopyWatch {
|
|
13
|
+
dir: string;
|
|
14
|
+
copyDir: string;
|
|
15
|
+
protected w: chokidar.FSWatcher;
|
|
16
|
+
/**
|
|
17
|
+
* Creates an instance of CopyWatch.
|
|
18
|
+
*
|
|
19
|
+
* @author chitanda
|
|
20
|
+
* @date 2022-05-24 14:05:28
|
|
21
|
+
* @param {string[]} dir 需要监控的目录
|
|
22
|
+
* @param {string} copyDir 需要拷贝到的目录
|
|
23
|
+
*/
|
|
24
|
+
constructor(dir: string, copyDir: string, opts?: chokidar.ChokidarOptions);
|
|
25
|
+
/**
|
|
26
|
+
* 初始化
|
|
27
|
+
*
|
|
28
|
+
* @author chitanda
|
|
29
|
+
* @date 2022-05-24 14:05:34
|
|
30
|
+
* @protected
|
|
31
|
+
*/
|
|
32
|
+
protected init(): void;
|
|
33
|
+
/**
|
|
34
|
+
* 文件监控变更
|
|
35
|
+
*
|
|
36
|
+
* @author chitanda
|
|
37
|
+
* @date 2022-05-24 14:05:18
|
|
38
|
+
* @protected
|
|
39
|
+
* @param {("add" | "addDir" | "change" | "unlink" | "unlinkDir")} eventName
|
|
40
|
+
* @param {string} pathStr
|
|
41
|
+
* @param {(fs.Stats)} [stats]
|
|
42
|
+
*/
|
|
43
|
+
protected watchAll(eventName: EventName, pathStr: string, stats?: fs.Stats): void;
|
|
44
|
+
/**
|
|
45
|
+
* 文件监控异常
|
|
46
|
+
*
|
|
47
|
+
* @author chitanda
|
|
48
|
+
* @date 2022-05-24 14:05:13
|
|
49
|
+
* @protected
|
|
50
|
+
* @param {string} path
|
|
51
|
+
* @param {(fs.Stats | undefined)} [stats]
|
|
52
|
+
*/
|
|
53
|
+
protected watchErr(err: unknown): void;
|
|
54
|
+
/**
|
|
55
|
+
* 停止监控
|
|
56
|
+
*
|
|
57
|
+
* @author chitanda
|
|
58
|
+
* @date 2022-05-24 14:05:06
|
|
59
|
+
*/
|
|
60
|
+
unwatch(): void;
|
|
61
|
+
}
|