@gct-paas/cli 0.0.1-dev.7.1 → 0.0.1-dev.8

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.
Files changed (83) hide show
  1. package/dist/bin.cjs +5 -0
  2. package/dist/commands/index.cjs +21 -0
  3. package/dist/index.cjs +47 -0
  4. package/dist/interface/i-command/i-command.cjs +1 -0
  5. package/dist/interface/index.cjs +16 -0
  6. package/dist/utils/index.cjs +18 -0
  7. package/dist/utils/local-binaries/local-binaries.cjs +19 -0
  8. package/es/bin.d.ts +2 -0
  9. package/es/commands/index.d.ts +5 -0
  10. package/{dist → es}/commands/index.mjs +0 -6
  11. package/es/index.d.ts +2 -0
  12. package/{dist → es}/index.mjs +1 -1
  13. package/es/interface/i-command/i-command.d.ts +22 -0
  14. package/es/interface/index.d.ts +1 -0
  15. package/es/types/index.d.ts +1 -0
  16. package/es/utils/index.d.ts +1 -0
  17. package/es/utils/local-binaries/local-binaries.d.ts +3 -0
  18. package/package.json +20 -54
  19. package/dist/commands/create-template/create-template.d.ts +0 -6
  20. package/dist/commands/create-template/create-template.mjs +0 -29
  21. package/dist/commands/update-template/update-template.d.ts +0 -6
  22. package/dist/commands/update-template/update-template.mjs +0 -17
  23. package/dist/commands/zip/zip.d.ts +0 -21
  24. package/dist/commands/zip/zip.mjs +0 -9
  25. package/dist/core/commitlint/commitlint-config/commitlint-config.d.ts +0 -9
  26. package/dist/core/commitlint/commitlint-config/commitlint-config.mjs +0 -28
  27. package/dist/core/commitlint/index.d.ts +0 -1
  28. package/dist/core/commitlint/index.mjs +0 -1
  29. package/dist/core/constants/index.d.ts +0 -12
  30. package/dist/core/constants/index.mjs +0 -24
  31. package/dist/core/eslint/eslint-config/eslint-config.d.ts +0 -9
  32. package/dist/core/eslint/eslint-config/eslint-config.mjs +0 -109
  33. package/dist/core/eslint/index.d.ts +0 -1
  34. package/dist/core/eslint/index.mjs +0 -1
  35. package/dist/core/index.d.ts +0 -8
  36. package/dist/core/index.mjs +0 -8
  37. package/dist/core/prettier/index.d.ts +0 -1
  38. package/dist/core/prettier/index.mjs +0 -1
  39. package/dist/core/prettier/prettier-config/prettier-config.d.ts +0 -22
  40. package/dist/core/prettier/prettier-config/prettier-config.mjs +0 -26
  41. package/dist/core/rollup/index.d.ts +0 -2
  42. package/dist/core/rollup/index.mjs +0 -2
  43. package/dist/core/rollup/rollup-config/dev-config.d.ts +0 -9
  44. package/dist/core/rollup/rollup-config/dev-config.mjs +0 -101
  45. package/dist/core/rollup/rollup-plugins/copy-file.d.ts +0 -37
  46. package/dist/core/rollup/rollup-plugins/copy-file.mjs +0 -18
  47. package/dist/core/rollup/rollup-plugins/ignore-compiler-file.d.ts +0 -8
  48. package/dist/core/rollup/rollup-plugins/ignore-compiler-file.mjs +0 -17
  49. package/dist/core/rollup/rollup-plugins/index.d.ts +0 -2
  50. package/dist/core/rollup/rollup-plugins/index.mjs +0 -2
  51. package/dist/core/stylelint/index.d.ts +0 -1
  52. package/dist/core/stylelint/index.mjs +0 -1
  53. package/dist/core/stylelint/stylelint-config/stylelint-config.d.ts +0 -9
  54. package/dist/core/stylelint/stylelint-config/stylelint-config.mjs +0 -21
  55. package/dist/core/template/actions/create-template.d.ts +0 -16
  56. package/dist/core/template/actions/create-template.mjs +0 -43
  57. package/dist/core/template/actions/update-template.d.ts +0 -18
  58. package/dist/core/template/actions/update-template.mjs +0 -61
  59. package/dist/core/template/actions/zip.d.ts +0 -9
  60. package/dist/core/template/actions/zip.mjs +0 -13
  61. package/dist/core/template/constant/index.d.ts +0 -1
  62. package/dist/core/template/constant/index.mjs +0 -1
  63. package/dist/core/template/index.d.ts +0 -3
  64. package/dist/core/template/index.mjs +0 -3
  65. package/dist/core/util/index.d.ts +0 -17
  66. package/dist/core/util/index.mjs +0 -7
  67. package/dist/core/util/watcher/watcher.d.ts +0 -48
  68. package/dist/core/util/watcher/watcher.mjs +0 -97
  69. package/dist/core/vite/index.d.ts +0 -4
  70. package/dist/core/vite/index.mjs +0 -8
  71. package/dist/core/vite/vite-config/vite-base-config.d.ts +0 -9
  72. package/dist/core/vite/vite-config/vite-base-config.mjs +0 -53
  73. package/dist/core/vite/vite-config/vite-config.d.ts +0 -9
  74. package/dist/core/vite/vite-config/vite-config.mjs +0 -31
  75. package/dist/core/vite/vite-config/vite-dev-config.d.ts +0 -9
  76. package/dist/core/vite/vite-config/vite-dev-config.mjs +0 -19
  77. package/dist/core/vite/vite-config/vite-plugin-config.d.ts +0 -25
  78. package/dist/core/vite/vite-config/vite-plugin-config.mjs +0 -97
  79. /package/{dist → es}/bin.mjs +0 -0
  80. /package/{dist → es}/interface/i-command/i-command.mjs +0 -0
  81. /package/{dist → es}/interface/index.mjs +0 -0
  82. /package/{dist → es}/utils/index.mjs +0 -0
  83. /package/{dist → es}/utils/local-binaries/local-binaries.mjs +0 -0
@@ -1,22 +0,0 @@
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;
@@ -1,26 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- export { defineRollupConfig } from './rollup-config/dev-config';
2
- export * from './rollup-plugins';
@@ -1,2 +0,0 @@
1
- export { defineRollupConfig } from "./rollup-config/dev-config.mjs";
2
- export * from "./rollup-plugins/index.mjs";
@@ -1,9 +0,0 @@
1
- import { RollupOptions } from 'rollup';
2
- /**
3
- * 开发包基础编译配置
4
- *
5
- * @export
6
- * @param {RollupOptions} [opts={}]
7
- * @returns {*} {RollupOptions}
8
- */
9
- export declare function defineRollupConfig(opts?: RollupOptions): RollupOptions;
@@ -1,101 +0,0 @@
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|d\.ts)+$/;
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,d.ts}"), 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
- vue({
79
- isProduction: false
80
- }),
81
- vueJsx({}),
82
- nodeResolve({
83
- extensions: [".cjs", ".mjs", ".js", ".ts"]
84
- }),
85
- commonjs(),
86
- esbuild({
87
- logLevel: "verbose",
88
- sourceMap: false,
89
- target: ["esnext"],
90
- loaders: {
91
- ".vue": "ts"
92
- }
93
- }),
94
- dts({
95
- outDir: [outDir]
96
- })
97
- ]
98
- }),
99
- opts
100
- );
101
- }
@@ -1,37 +0,0 @@
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;
@@ -1,18 +0,0 @@
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
- }
@@ -1,8 +0,0 @@
1
- import { Plugin } from 'rollup';
2
- /**
3
- * 忽略编译的文件类型
4
- *
5
- * @export
6
- * @returns {*} {Plugin}
7
- */
8
- export declare function ignoreCompilerFile(extReg: RegExp): Plugin;
@@ -1,17 +0,0 @@
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
- }
@@ -1,2 +0,0 @@
1
- export { copyFile } from './copy-file';
2
- export { ignoreCompilerFile } from './ignore-compiler-file';
@@ -1,2 +0,0 @@
1
- export { copyFile } from "./copy-file.mjs";
2
- export { ignoreCompilerFile } from "./ignore-compiler-file.mjs";
@@ -1 +0,0 @@
1
- export { defineStylelintConfig } from './stylelint-config/stylelint-config';
@@ -1 +0,0 @@
1
- export { defineStylelintConfig } from "./stylelint-config/stylelint-config.mjs";
@@ -1,9 +0,0 @@
1
- import { Config } from 'stylelint';
2
- /**
3
- * 基于基础规则,定义 stylelint 配置
4
- *
5
- * @export
6
- * @param {Config} config
7
- * @returns {*} {Config}
8
- */
9
- export declare function defineStylelintConfig(config?: Config): Config;
@@ -1,21 +0,0 @@
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,16 +0,0 @@
1
- /**
2
- * 创建模板行为
3
- *
4
- * @export
5
- * @class CreateTemplateAction
6
- */
7
- export declare class CreateTemplateAction {
8
- /**
9
- * 创建模板
10
- *
11
- * @param {string} cwd 创建模板的路径
12
- * @param {string} name 生成项目名称
13
- * @returns {*} {Promise<void>}
14
- */
15
- run(cwd: string, name: string): Promise<void>;
16
- }
@@ -1,43 +0,0 @@
1
- import consola from "consola";
2
- import fse from "fs-extra";
3
- import * as path from "path";
4
- import * as rf from "rimraf";
5
- import { simpleGit } from "simple-git";
6
- import cpy from "cpy";
7
- import { TEMPLATE_GIT } from "../constant/index.mjs";
8
- export class CreateTemplateAction {
9
- /**
10
- * 创建模板
11
- *
12
- * @param {string} cwd 创建模板的路径
13
- * @param {string} name 生成项目名称
14
- * @returns {*} {Promise<void>}
15
- */
16
- async run(cwd, name) {
17
- const gitOut = path.join(cwd, ".temp_paas");
18
- rf.rimrafSync(gitOut);
19
- const git = simpleGit();
20
- try {
21
- await git.init();
22
- await git.clone(
23
- // 模板项目地址
24
- TEMPLATE_GIT,
25
- gitOut,
26
- // 克隆 publish 分支内容
27
- { "--branch": "publish" }
28
- );
29
- rf.rimrafSync(path.resolve(gitOut, ".git"));
30
- await cpy([path.join(gitOut, "**")], "./", {
31
- cwd
32
- });
33
- rf.rimrafSync(gitOut);
34
- const outPkg = path.resolve(cwd, "package.json");
35
- const pkg = JSON.parse(fse.readFileSync(outPkg, "utf-8"));
36
- pkg.name = name;
37
- fse.writeFileSync(outPkg, JSON.stringify(pkg, null, 2));
38
- } catch (error) {
39
- consola.error(error);
40
- process.exit(1);
41
- }
42
- }
43
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * 已经出初始化过的插件进行增量更新
3
- *
4
- * @export
5
- * @class UpdateTemplateAction
6
- */
7
- export declare class UpdateTemplateAction {
8
- run(cwd: string, overwrite: boolean): Promise<void>;
9
- /**
10
- * 增量更新文件,对比文件 hash 值进行更新
11
- *
12
- * @param {string} cwd 项目更目录
13
- * @param {string} temp 模板克隆临时目录
14
- * @param {string} filePath 克隆的文件路径
15
- * @returns {*} {Promise<void>}
16
- */
17
- updateFile(cwd: string, temp: string, filePath: string): Promise<void>;
18
- }
@@ -1,61 +0,0 @@
1
- import consola from "consola";
2
- import fse from "fs-extra";
3
- import * as path from "path";
4
- import * as rf from "rimraf";
5
- import cpy from "cpy";
6
- import global from "fast-glob";
7
- import { simpleGit } from "simple-git";
8
- import { TEMPLATE_GIT } from "../constant/index.mjs";
9
- export class UpdateTemplateAction {
10
- async run(cwd, overwrite) {
11
- const gitOut = path.resolve(cwd, ".temp_paas");
12
- rf.rimrafSync(gitOut);
13
- const git = simpleGit();
14
- try {
15
- await git.init();
16
- await git.clone(
17
- // 模板项目地址
18
- TEMPLATE_GIT,
19
- gitOut,
20
- // 克隆 publish 分支内容
21
- { "--branch": "publish" }
22
- );
23
- rf.rimrafSync(path.resolve(gitOut, ".git"));
24
- if (overwrite) {
25
- await cpy([path.join(gitOut, "**")], "./", {
26
- cwd
27
- });
28
- } else {
29
- const files = global.sync([path.join(gitOut, "**")], {
30
- cwd,
31
- dot: true,
32
- ignore: ["**/.git/**", "**/node_modules/**"]
33
- });
34
- const all = files.map((file) => {
35
- return this.updateFile(cwd, gitOut, file);
36
- });
37
- await Promise.all(all);
38
- }
39
- rf.rimrafSync(gitOut);
40
- } catch (error) {
41
- consola.error(error);
42
- process.exit(1);
43
- }
44
- }
45
- /**
46
- * 增量更新文件,对比文件 hash 值进行更新
47
- *
48
- * @param {string} cwd 项目更目录
49
- * @param {string} temp 模板克隆临时目录
50
- * @param {string} filePath 克隆的文件路径
51
- * @returns {*} {Promise<void>}
52
- */
53
- async updateFile(cwd, temp, filePath) {
54
- const relativePath = filePath.replace(temp, "");
55
- const cwdFilePath = path.join(cwd, relativePath);
56
- if (!fse.existsSync(cwdFilePath)) {
57
- await cpy(filePath, cwdFilePath);
58
- return;
59
- }
60
- }
61
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * 压缩文件夹
3
- *
4
- * @export
5
- * @class ZipAction
6
- */
7
- export declare class ZipAction {
8
- run(cwd: string, folder?: string, outFile?: string): Promise<void>;
9
- }
@@ -1,13 +0,0 @@
1
- import archiver from "archiver";
2
- import fse from "fs-extra";
3
- import path from "path";
4
- export class ZipAction {
5
- async run(cwd, folder = "dist", outFile = "dist.zip") {
6
- const file = path.resolve(cwd, outFile);
7
- const output = fse.createWriteStream(file);
8
- const zip = archiver("zip", { zlib: { level: 9 } });
9
- zip.pipe(output);
10
- zip.directory(path.resolve(cwd, folder), false);
11
- zip.finalize();
12
- }
13
- }
@@ -1 +0,0 @@
1
- export declare const TEMPLATE_GIT = "https://git.gct-china.com/paas/frontend/paas-comp-template.git";
@@ -1 +0,0 @@
1
- export const TEMPLATE_GIT = "https://git.gct-china.com/paas/frontend/paas-comp-template.git";
@@ -1,3 +0,0 @@
1
- export { CreateTemplateAction } from './actions/create-template';
2
- export { UpdateTemplateAction } from './actions/update-template';
3
- export { ZipAction } from './actions/zip';
@@ -1,3 +0,0 @@
1
- export { CreateTemplateAction } from "./actions/create-template.mjs";
2
- export { UpdateTemplateAction } from "./actions/update-template.mjs";
3
- export { ZipAction } from "./actions/zip.mjs";
@@ -1,17 +0,0 @@
1
- export { CopyWatch } from './watcher/watcher';
2
- /**
3
- * win 路径 \\ 转 linux 路径 /
4
- *
5
- * @export
6
- * @param {string} pathStr
7
- * @return {*} {string}
8
- */
9
- export declare function winToUnixPath(pathStr: string): string;
10
- /**
11
- * linux 路径 / 转 win 路径 \\
12
- *
13
- * @export
14
- * @param {string} pathStr
15
- * @return {*} {string}
16
- */
17
- export declare function unixToWinPath(pathStr: string): string;
@@ -1,7 +0,0 @@
1
- export { CopyWatch } from "./watcher/watcher.mjs";
2
- export function winToUnixPath(pathStr) {
3
- return pathStr.replace(/\\/g, "/");
4
- }
5
- export function unixToWinPath(pathStr) {
6
- return pathStr.replace(/\//g, "\\");
7
- }
@@ -1,48 +0,0 @@
1
- import * as chokidar from 'chokidar';
2
- import fs from 'fs-extra';
3
- import { EventName } from 'chokidar/handler';
4
- /**
5
- * 文件监控类
6
- *
7
- * @export
8
- * @class CopyWatch
9
- */
10
- export declare class CopyWatch {
11
- dir: string;
12
- copyDir: string;
13
- protected w: chokidar.FSWatcher;
14
- /**
15
- * Creates an instance of CopyWatch.
16
- *
17
- * @param {string[]} dir 需要监控的目录
18
- * @param {string} copyDir 需要拷贝到的目录
19
- */
20
- constructor(dir: string, copyDir: string, opts?: chokidar.ChokidarOptions);
21
- /**
22
- * 初始化
23
- *
24
- * @protected
25
- */
26
- protected init(): void;
27
- /**
28
- * 文件监控变更
29
- *
30
- * @protected
31
- * @param {("add" | "addDir" | "change" | "unlink" | "unlinkDir")} eventName
32
- * @param {string} pathStr
33
- * @param {(fs.Stats)} [stats]
34
- */
35
- protected watchAll(eventName: EventName, pathStr: string, stats?: fs.Stats): void;
36
- /**
37
- * 文件监控异常
38
- *
39
- * @protected
40
- * @param {string} path
41
- * @param {(fs.Stats | undefined)} [stats]
42
- */
43
- protected watchErr(err: unknown): void;
44
- /**
45
- * 停止监控
46
- */
47
- unwatch(): void;
48
- }
@@ -1,97 +0,0 @@
1
- import * as chokidar from "chokidar";
2
- import path from "path";
3
- import * as rimraf from "rimraf";
4
- import { copyFileSync } from "copy-file";
5
- import consola from "consola";
6
- import colors from "picocolors";
7
- import { merge } from "lodash-es";
8
- export class CopyWatch {
9
- /**
10
- * Creates an instance of CopyWatch.
11
- *
12
- * @param {string[]} dir 需要监控的目录
13
- * @param {string} copyDir 需要拷贝到的目录
14
- */
15
- constructor(dir, copyDir, opts = {}) {
16
- this.dir = dir;
17
- this.copyDir = copyDir;
18
- this.w = chokidar.watch(
19
- this.dir,
20
- merge(
21
- {
22
- awaitWriteFinish: {
23
- stabilityThreshold: 300
24
- // 等待0.3秒防抖
25
- }
26
- },
27
- opts
28
- )
29
- );
30
- consola.debug(`\u62F7\u8D1D\u76D1\u63A7\u6587\u4EF6\u5939: ${this.dir}`);
31
- this.init();
32
- }
33
- w;
34
- /**
35
- * 初始化
36
- *
37
- * @protected
38
- */
39
- init() {
40
- this.watchAll = this.watchAll.bind(this);
41
- this.watchErr = this.watchErr.bind(this);
42
- this.w.on("all", this.watchAll);
43
- this.w.on("error", this.watchErr);
44
- }
45
- /**
46
- * 文件监控变更
47
- *
48
- * @protected
49
- * @param {("add" | "addDir" | "change" | "unlink" | "unlinkDir")} eventName
50
- * @param {string} pathStr
51
- * @param {(fs.Stats)} [stats]
52
- */
53
- watchAll(eventName, pathStr, stats) {
54
- if (stats && stats.size <= 0) {
55
- return;
56
- }
57
- const cwd = process.cwd();
58
- const source = path.resolve(cwd, pathStr);
59
- const target = path.resolve(this.copyDir, path.relative(this.dir, pathStr));
60
- switch (eventName) {
61
- case "add":
62
- case "change":
63
- consola.info(
64
- `\u62F7\u8D1D\u6587\u4EF6: ${colors.cyan(source)} => ${colors.cyan(target)}`
65
- );
66
- copyFileSync(source, target);
67
- break;
68
- case "addDir":
69
- break;
70
- case "unlink":
71
- case "unlinkDir":
72
- consola.info(`\u5220\u9664\u6587\u4EF6\u6216\u76EE\u5F55: ${target}`);
73
- rimraf.sync(target);
74
- break;
75
- default:
76
- }
77
- }
78
- /**
79
- * 文件监控异常
80
- *
81
- * @protected
82
- * @param {string} path
83
- * @param {(fs.Stats | undefined)} [stats]
84
- */
85
- watchErr(err) {
86
- consola.error(`\u76D1\u63A7\u6587\u4EF6\u53D1\u751F\u9519\u8BEF: ${err}`);
87
- }
88
- /**
89
- * 停止监控
90
- */
91
- unwatch() {
92
- this.w.off("all", this.watchAll);
93
- this.w.off("error", this.watchErr);
94
- this.w.unwatch(this.dir);
95
- this.w.close();
96
- }
97
- }
@@ -1,4 +0,0 @@
1
- export { defineViteBaseConfig } from './vite-config/vite-base-config';
2
- export { defineViteConfig } from './vite-config/vite-config';
3
- export { defineDevViteConfig } from './vite-config/vite-dev-config';
4
- export { defineDesignPluginViteConfig, defineMobilePluginViteConfig, defineWebPluginViteConfig, } from './vite-config/vite-plugin-config';
@@ -1,8 +0,0 @@
1
- export { defineViteBaseConfig } from "./vite-config/vite-base-config.mjs";
2
- export { defineViteConfig } from "./vite-config/vite-config.mjs";
3
- export { defineDevViteConfig } from "./vite-config/vite-dev-config.mjs";
4
- export {
5
- defineDesignPluginViteConfig,
6
- defineMobilePluginViteConfig,
7
- defineWebPluginViteConfig
8
- } from "./vite-config/vite-plugin-config.mjs";