@gct-paas/cli 0.0.1-dev.7.2 → 0.0.1-dev.9

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 (125) hide show
  1. package/dist/commands/index.cjs +0 -6
  2. package/dist/index.cjs +1 -1
  3. package/es/commands/index.mjs +0 -6
  4. package/es/index.mjs +1 -1
  5. package/package.json +11 -53
  6. package/dist/commands/create-template/create-template.cjs +0 -37
  7. package/dist/commands/create-template/create-template.d.ts +0 -6
  8. package/dist/commands/update-template/update-template.cjs +0 -25
  9. package/dist/commands/update-template/update-template.d.ts +0 -6
  10. package/dist/commands/zip/zip.cjs +0 -16
  11. package/dist/commands/zip/zip.d.ts +0 -21
  12. package/dist/core/commitlint/commitlint-config/commitlint-config.cjs +0 -15
  13. package/dist/core/commitlint/commitlint-config/commitlint-config.d.ts +0 -9
  14. package/dist/core/commitlint/index.cjs +0 -12
  15. package/dist/core/commitlint/index.d.ts +0 -1
  16. package/dist/core/constants/index.cjs +0 -9
  17. package/dist/core/constants/index.d.ts +0 -12
  18. package/dist/core/eslint/eslint-config/eslint-config.cjs +0 -85
  19. package/dist/core/eslint/eslint-config/eslint-config.d.ts +0 -9
  20. package/dist/core/eslint/index.cjs +0 -12
  21. package/dist/core/eslint/index.d.ts +0 -1
  22. package/dist/core/index.cjs +0 -93
  23. package/dist/core/index.d.ts +0 -8
  24. package/dist/core/prettier/index.cjs +0 -12
  25. package/dist/core/prettier/index.d.ts +0 -1
  26. package/dist/core/prettier/prettier-config/prettier-config.cjs +0 -29
  27. package/dist/core/prettier/prettier-config/prettier-config.d.ts +0 -22
  28. package/dist/core/rollup/index.cjs +0 -27
  29. package/dist/core/rollup/index.d.ts +0 -2
  30. package/dist/core/rollup/rollup-config/dev-config.cjs +0 -93
  31. package/dist/core/rollup/rollup-config/dev-config.d.ts +0 -9
  32. package/dist/core/rollup/rollup-plugins/copy-file.cjs +0 -24
  33. package/dist/core/rollup/rollup-plugins/copy-file.d.ts +0 -37
  34. package/dist/core/rollup/rollup-plugins/ignore-compiler-file.cjs +0 -23
  35. package/dist/core/rollup/rollup-plugins/ignore-compiler-file.d.ts +0 -8
  36. package/dist/core/rollup/rollup-plugins/index.cjs +0 -19
  37. package/dist/core/rollup/rollup-plugins/index.d.ts +0 -2
  38. package/dist/core/stylelint/index.cjs +0 -12
  39. package/dist/core/stylelint/index.d.ts +0 -1
  40. package/dist/core/stylelint/stylelint-config/stylelint-config.cjs +0 -24
  41. package/dist/core/stylelint/stylelint-config/stylelint-config.d.ts +0 -9
  42. package/dist/core/template/actions/create-template.cjs +0 -53
  43. package/dist/core/template/actions/create-template.d.ts +0 -16
  44. package/dist/core/template/actions/update-template.cjs +0 -71
  45. package/dist/core/template/actions/update-template.d.ts +0 -18
  46. package/dist/core/template/actions/zip.cjs +0 -25
  47. package/dist/core/template/actions/zip.d.ts +0 -9
  48. package/dist/core/template/constant/index.cjs +0 -7
  49. package/dist/core/template/constant/index.d.ts +0 -1
  50. package/dist/core/template/index.cjs +0 -26
  51. package/dist/core/template/index.d.ts +0 -3
  52. package/dist/core/util/index.cjs +0 -20
  53. package/dist/core/util/index.d.ts +0 -17
  54. package/dist/core/util/watcher/watcher.cjs +0 -99
  55. package/dist/core/util/watcher/watcher.d.ts +0 -48
  56. package/dist/core/vite/index.cjs +0 -45
  57. package/dist/core/vite/index.d.ts +0 -4
  58. package/dist/core/vite/vite-config/vite-base-config.cjs +0 -47
  59. package/dist/core/vite/vite-config/vite-base-config.d.ts +0 -9
  60. package/dist/core/vite/vite-config/vite-config.cjs +0 -35
  61. package/dist/core/vite/vite-config/vite-config.d.ts +0 -9
  62. package/dist/core/vite/vite-config/vite-dev-config.cjs +0 -23
  63. package/dist/core/vite/vite-config/vite-dev-config.d.ts +0 -9
  64. package/dist/core/vite/vite-config/vite-plugin-config.cjs +0 -97
  65. package/dist/core/vite/vite-config/vite-plugin-config.d.ts +0 -25
  66. package/es/commands/create-template/create-template.d.ts +0 -6
  67. package/es/commands/create-template/create-template.mjs +0 -29
  68. package/es/commands/update-template/update-template.d.ts +0 -6
  69. package/es/commands/update-template/update-template.mjs +0 -17
  70. package/es/commands/zip/zip.d.ts +0 -21
  71. package/es/commands/zip/zip.mjs +0 -9
  72. package/es/core/commitlint/commitlint-config/commitlint-config.d.ts +0 -9
  73. package/es/core/commitlint/commitlint-config/commitlint-config.mjs +0 -28
  74. package/es/core/commitlint/index.d.ts +0 -1
  75. package/es/core/commitlint/index.mjs +0 -1
  76. package/es/core/constants/index.d.ts +0 -12
  77. package/es/core/constants/index.mjs +0 -24
  78. package/es/core/eslint/eslint-config/eslint-config.d.ts +0 -9
  79. package/es/core/eslint/eslint-config/eslint-config.mjs +0 -109
  80. package/es/core/eslint/index.d.ts +0 -1
  81. package/es/core/eslint/index.mjs +0 -1
  82. package/es/core/index.d.ts +0 -8
  83. package/es/core/index.mjs +0 -8
  84. package/es/core/prettier/index.d.ts +0 -1
  85. package/es/core/prettier/index.mjs +0 -1
  86. package/es/core/prettier/prettier-config/prettier-config.d.ts +0 -22
  87. package/es/core/prettier/prettier-config/prettier-config.mjs +0 -26
  88. package/es/core/rollup/index.d.ts +0 -2
  89. package/es/core/rollup/index.mjs +0 -2
  90. package/es/core/rollup/rollup-config/dev-config.d.ts +0 -9
  91. package/es/core/rollup/rollup-config/dev-config.mjs +0 -101
  92. package/es/core/rollup/rollup-plugins/copy-file.d.ts +0 -37
  93. package/es/core/rollup/rollup-plugins/copy-file.mjs +0 -18
  94. package/es/core/rollup/rollup-plugins/ignore-compiler-file.d.ts +0 -8
  95. package/es/core/rollup/rollup-plugins/ignore-compiler-file.mjs +0 -17
  96. package/es/core/rollup/rollup-plugins/index.d.ts +0 -2
  97. package/es/core/rollup/rollup-plugins/index.mjs +0 -2
  98. package/es/core/stylelint/index.d.ts +0 -1
  99. package/es/core/stylelint/index.mjs +0 -1
  100. package/es/core/stylelint/stylelint-config/stylelint-config.d.ts +0 -9
  101. package/es/core/stylelint/stylelint-config/stylelint-config.mjs +0 -21
  102. package/es/core/template/actions/create-template.d.ts +0 -16
  103. package/es/core/template/actions/create-template.mjs +0 -43
  104. package/es/core/template/actions/update-template.d.ts +0 -18
  105. package/es/core/template/actions/update-template.mjs +0 -61
  106. package/es/core/template/actions/zip.d.ts +0 -9
  107. package/es/core/template/actions/zip.mjs +0 -13
  108. package/es/core/template/constant/index.d.ts +0 -1
  109. package/es/core/template/constant/index.mjs +0 -1
  110. package/es/core/template/index.d.ts +0 -3
  111. package/es/core/template/index.mjs +0 -3
  112. package/es/core/util/index.d.ts +0 -17
  113. package/es/core/util/index.mjs +0 -7
  114. package/es/core/util/watcher/watcher.d.ts +0 -48
  115. package/es/core/util/watcher/watcher.mjs +0 -97
  116. package/es/core/vite/index.d.ts +0 -4
  117. package/es/core/vite/index.mjs +0 -8
  118. package/es/core/vite/vite-config/vite-base-config.d.ts +0 -9
  119. package/es/core/vite/vite-config/vite-base-config.mjs +0 -53
  120. package/es/core/vite/vite-config/vite-config.d.ts +0 -9
  121. package/es/core/vite/vite-config/vite-config.mjs +0 -31
  122. package/es/core/vite/vite-config/vite-dev-config.d.ts +0 -9
  123. package/es/core/vite/vite-config/vite-dev-config.mjs +0 -19
  124. package/es/core/vite/vite-config/vite-plugin-config.d.ts +0 -25
  125. package/es/core/vite/vite-config/vite-plugin-config.mjs +0 -97
@@ -1,93 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.defineRollupConfig = defineRollupConfig;
7
- var _rollup = require("rollup");
8
- var _lodashEs = require("lodash-es");
9
- var _path = _interopRequireDefault(require("path"));
10
- var _fastGlob = _interopRequireDefault(require("fast-glob"));
11
- var _pluginNodeResolve = require("@rollup/plugin-node-resolve");
12
- var _pluginCommonjs = _interopRequireDefault(require("@rollup/plugin-commonjs"));
13
- var _pluginJson = _interopRequireDefault(require("@rollup/plugin-json"));
14
- var _rollupPluginEsbuild = _interopRequireDefault(require("rollup-plugin-esbuild"));
15
- var _vitePluginDts = _interopRequireDefault(require("vite-plugin-dts"));
16
- var _pluginVue = _interopRequireDefault(require("@vitejs/plugin-vue"));
17
- var _pluginVueJsx = _interopRequireDefault(require("@vitejs/plugin-vue-jsx"));
18
- var rf = _interopRequireWildcard(require("rimraf"));
19
- var _cpy = _interopRequireDefault(require("cpy"));
20
- var _fsExtra = _interopRequireDefault(require("fs-extra"));
21
- var _rollupPlugins = require("../rollup-plugins/index.cjs");
22
- var _constants = require("../../constants/index.cjs");
23
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
24
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
25
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
26
- function defineRollupConfig(opts = {}) {
27
- process.on("SIGINT", () => {
28
- process.exit();
29
- });
30
- const cwd = process.cwd();
31
- const isProd = process.env.NODE_ENV === _constants.PROD_MODE;
32
- const rootDir = _path.default.resolve(cwd, "src");
33
- const outDir = _path.default.resolve(cwd, "es");
34
- const assetsDir = _path.default.resolve(cwd, "public");
35
- const externalCompileFileReg = /\.(vue|scss|css|less|d\.ts)+$/;
36
- rf.sync(outDir);
37
- const input = _fastGlob.default.sync("src/**/*.{ts,tsx}", {
38
- cwd,
39
- absolute: true,
40
- onlyFiles: true,
41
- ignore: ["**/*.test.ts", "**/*.test.tsx", "**/*.d.ts"]
42
- });
43
- if (isProd) {
44
- if (_fsExtra.default.pathExistsSync(assetsDir)) {
45
- (0, _cpy.default)(assetsDir, outDir);
46
- }
47
- (0, _cpy.default)(_path.default.resolve(cwd, "src/**/*.{vue,scss,css,less,d.ts}"), outDir);
48
- } else {
49
- (0, _rollupPlugins.copyFile)([{
50
- from: assetsDir,
51
- to: outDir
52
- }, {
53
- from: rootDir,
54
- to: outDir,
55
- opts: {
56
- ignored: (file, stats) => {
57
- if (stats && stats.isFile()) {
58
- return !externalCompileFileReg.test(file);
59
- }
60
- return false;
61
- }
62
- }
63
- }]);
64
- }
65
- const output = [{
66
- dir: outDir,
67
- format: "es",
68
- sourcemap: false,
69
- preserveModules: true,
70
- preserveModulesRoot: rootDir,
71
- entryFileNames: "[name].mjs"
72
- }];
73
- return (0, _lodashEs.merge)((0, _rollup.defineConfig)({
74
- input,
75
- treeshake: false,
76
- external: _constants.DEFAULT_EXTERNAL,
77
- output,
78
- plugins: [(0, _rollupPlugins.ignoreCompilerFile)(externalCompileFileReg), (0, _pluginJson.default)(), (0, _pluginVue.default)({
79
- isProduction: false
80
- }), (0, _pluginVueJsx.default)({}), (0, _pluginNodeResolve.nodeResolve)({
81
- extensions: [".cjs", ".mjs", ".js", ".ts"]
82
- }), (0, _pluginCommonjs.default)(), (0, _rollupPluginEsbuild.default)({
83
- logLevel: "verbose",
84
- sourceMap: false,
85
- target: ["esnext"],
86
- loaders: {
87
- ".vue": "ts"
88
- }
89
- }), (0, _vitePluginDts.default)({
90
- outDir: [outDir]
91
- })]
92
- }), opts);
93
- }
@@ -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,24 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.copyFile = copyFile;
7
- var _util = require("../../util/index.cjs");
8
- function copyFile(opts) {
9
- if (opts.length === 0) {
10
- return;
11
- }
12
- const arr = [];
13
- opts.forEach(opt => {
14
- arr.push(new _util.CopyWatch(opt.from, opt.to, opt.opts));
15
- });
16
- process.on("exit", () => {
17
- if (!opts.length) {
18
- return;
19
- }
20
- arr.forEach(item => {
21
- item.unwatch();
22
- });
23
- });
24
- }
@@ -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,23 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ignoreCompilerFile = ignoreCompilerFile;
7
- function ignoreCompilerFile(extReg) {
8
- return {
9
- name: "gct:ignore-compiler-file",
10
- resolveId(source) {
11
- if (extReg.test(source)) {
12
- return {
13
- id: source,
14
- external: true
15
- };
16
- }
17
- return null;
18
- },
19
- load() {
20
- return null;
21
- }
22
- };
23
- }
@@ -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,19 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "copyFile", {
7
- enumerable: true,
8
- get: function () {
9
- return _copyFile.copyFile;
10
- }
11
- });
12
- Object.defineProperty(exports, "ignoreCompilerFile", {
13
- enumerable: true,
14
- get: function () {
15
- return _ignoreCompilerFile.ignoreCompilerFile;
16
- }
17
- });
18
- var _copyFile = require("./copy-file.cjs");
19
- var _ignoreCompilerFile = require("./ignore-compiler-file.cjs");
@@ -1,2 +0,0 @@
1
- export { copyFile } from './copy-file';
2
- export { ignoreCompilerFile } from './ignore-compiler-file';
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "defineStylelintConfig", {
7
- enumerable: true,
8
- get: function () {
9
- return _stylelintConfig.defineStylelintConfig;
10
- }
11
- });
12
- var _stylelintConfig = require("./stylelint-config/stylelint-config.cjs");
@@ -1 +0,0 @@
1
- export { defineStylelintConfig } from './stylelint-config/stylelint-config';
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.defineStylelintConfig = defineStylelintConfig;
7
- var _lodashEs = require("lodash-es");
8
- function defineStylelintConfig(config = {}) {
9
- return (0, _lodashEs.merge)({
10
- extends: ["stylelint-config-standard", "stylelint-config-standard-scss"],
11
- rules: {
12
- "annotation-no-unknown": null,
13
- "color-no-invalid-hex": true,
14
- "function-name-case": null,
15
- // 强制样式方法名称小写或大写
16
- "no-duplicate-selectors": null,
17
- "selector-class-pattern": null,
18
- "scss/dollar-variable-pattern": null,
19
- "scss/at-function-pattern": null,
20
- "scss/dollar-variable-empty-line-before": null
21
- // 变量声明之间不可以有空白行
22
- }
23
- }, config);
24
- }
@@ -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,53 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.CreateTemplateAction = void 0;
7
- var _consola = _interopRequireDefault(require("consola"));
8
- var _fsExtra = _interopRequireDefault(require("fs-extra"));
9
- var path = _interopRequireWildcard(require("path"));
10
- var rf = _interopRequireWildcard(require("rimraf"));
11
- var _simpleGit = require("simple-git");
12
- var _cpy = _interopRequireDefault(require("cpy"));
13
- var _constant = require("../constant/index.cjs");
14
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
- class CreateTemplateAction {
18
- /**
19
- * 创建模板
20
- *
21
- * @param {string} cwd 创建模板的路径
22
- * @param {string} name 生成项目名称
23
- * @returns {*} {Promise<void>}
24
- */
25
- async run(cwd, name) {
26
- const gitOut = path.join(cwd, ".temp_paas");
27
- rf.rimrafSync(gitOut);
28
- const git = (0, _simpleGit.simpleGit)();
29
- try {
30
- await git.init();
31
- await git.clone(
32
- // 模板项目地址
33
- _constant.TEMPLATE_GIT, gitOut,
34
- // 克隆 publish 分支内容
35
- {
36
- "--branch": "publish"
37
- });
38
- rf.rimrafSync(path.resolve(gitOut, ".git"));
39
- await (0, _cpy.default)([path.join(gitOut, "**")], "./", {
40
- cwd
41
- });
42
- rf.rimrafSync(gitOut);
43
- const outPkg = path.resolve(cwd, "package.json");
44
- const pkg = JSON.parse(_fsExtra.default.readFileSync(outPkg, "utf-8"));
45
- pkg.name = name;
46
- _fsExtra.default.writeFileSync(outPkg, JSON.stringify(pkg, null, 2));
47
- } catch (error) {
48
- _consola.default.error(error);
49
- process.exit(1);
50
- }
51
- }
52
- }
53
- exports.CreateTemplateAction = CreateTemplateAction;
@@ -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,71 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.UpdateTemplateAction = void 0;
7
- var _consola = _interopRequireDefault(require("consola"));
8
- var _fsExtra = _interopRequireDefault(require("fs-extra"));
9
- var path = _interopRequireWildcard(require("path"));
10
- var rf = _interopRequireWildcard(require("rimraf"));
11
- var _cpy = _interopRequireDefault(require("cpy"));
12
- var _fastGlob = _interopRequireDefault(require("fast-glob"));
13
- var _simpleGit = require("simple-git");
14
- var _constant = require("../constant/index.cjs");
15
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
16
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
18
- class UpdateTemplateAction {
19
- async run(cwd, overwrite) {
20
- const gitOut = path.resolve(cwd, ".temp_paas");
21
- rf.rimrafSync(gitOut);
22
- const git = (0, _simpleGit.simpleGit)();
23
- try {
24
- await git.init();
25
- await git.clone(
26
- // 模板项目地址
27
- _constant.TEMPLATE_GIT, gitOut,
28
- // 克隆 publish 分支内容
29
- {
30
- "--branch": "publish"
31
- });
32
- rf.rimrafSync(path.resolve(gitOut, ".git"));
33
- if (overwrite) {
34
- await (0, _cpy.default)([path.join(gitOut, "**")], "./", {
35
- cwd
36
- });
37
- } else {
38
- const files = _fastGlob.default.sync([path.join(gitOut, "**")], {
39
- cwd,
40
- dot: true,
41
- ignore: ["**/.git/**", "**/node_modules/**"]
42
- });
43
- const all = files.map(file => {
44
- return this.updateFile(cwd, gitOut, file);
45
- });
46
- await Promise.all(all);
47
- }
48
- rf.rimrafSync(gitOut);
49
- } catch (error) {
50
- _consola.default.error(error);
51
- process.exit(1);
52
- }
53
- }
54
- /**
55
- * 增量更新文件,对比文件 hash 值进行更新
56
- *
57
- * @param {string} cwd 项目更目录
58
- * @param {string} temp 模板克隆临时目录
59
- * @param {string} filePath 克隆的文件路径
60
- * @returns {*} {Promise<void>}
61
- */
62
- async updateFile(cwd, temp, filePath) {
63
- const relativePath = filePath.replace(temp, "");
64
- const cwdFilePath = path.join(cwd, relativePath);
65
- if (!_fsExtra.default.existsSync(cwdFilePath)) {
66
- await (0, _cpy.default)(filePath, cwdFilePath);
67
- return;
68
- }
69
- }
70
- }
71
- exports.UpdateTemplateAction = UpdateTemplateAction;
@@ -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,25 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.ZipAction = void 0;
7
- var _archiver = _interopRequireDefault(require("archiver"));
8
- var _fsExtra = _interopRequireDefault(require("fs-extra"));
9
- var _path = _interopRequireDefault(require("path"));
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- class ZipAction {
12
- async run(cwd, folder = "dist", outFile = "dist.zip") {
13
- const file = _path.default.resolve(cwd, outFile);
14
- const output = _fsExtra.default.createWriteStream(file);
15
- const zip = (0, _archiver.default)("zip", {
16
- zlib: {
17
- level: 9
18
- }
19
- });
20
- zip.pipe(output);
21
- zip.directory(_path.default.resolve(cwd, folder), false);
22
- zip.finalize();
23
- }
24
- }
25
- exports.ZipAction = ZipAction;
@@ -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,7 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.TEMPLATE_GIT = void 0;
7
- const TEMPLATE_GIT = exports.TEMPLATE_GIT = "https://git.gct-china.com/paas/frontend/paas-comp-template.git";
@@ -1 +0,0 @@
1
- export declare const TEMPLATE_GIT = "https://git.gct-china.com/paas/frontend/paas-comp-template.git";
@@ -1,26 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "CreateTemplateAction", {
7
- enumerable: true,
8
- get: function () {
9
- return _createTemplate.CreateTemplateAction;
10
- }
11
- });
12
- Object.defineProperty(exports, "UpdateTemplateAction", {
13
- enumerable: true,
14
- get: function () {
15
- return _updateTemplate.UpdateTemplateAction;
16
- }
17
- });
18
- Object.defineProperty(exports, "ZipAction", {
19
- enumerable: true,
20
- get: function () {
21
- return _zip.ZipAction;
22
- }
23
- });
24
- var _createTemplate = require("./actions/create-template.cjs");
25
- var _updateTemplate = require("./actions/update-template.cjs");
26
- var _zip = require("./actions/zip.cjs");
@@ -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,20 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "CopyWatch", {
7
- enumerable: true,
8
- get: function () {
9
- return _watcher.CopyWatch;
10
- }
11
- });
12
- exports.unixToWinPath = unixToWinPath;
13
- exports.winToUnixPath = winToUnixPath;
14
- var _watcher = require("./watcher/watcher.cjs");
15
- function winToUnixPath(pathStr) {
16
- return pathStr.replace(/\\/g, "/");
17
- }
18
- function unixToWinPath(pathStr) {
19
- return pathStr.replace(/\//g, "\\");
20
- }
@@ -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,99 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.CopyWatch = void 0;
7
- var chokidar = _interopRequireWildcard(require("chokidar"));
8
- var _path = _interopRequireDefault(require("path"));
9
- var rimraf = _interopRequireWildcard(require("rimraf"));
10
- var _copyFile = require("copy-file");
11
- var _consola = _interopRequireDefault(require("consola"));
12
- var _picocolors = _interopRequireDefault(require("picocolors"));
13
- var _lodashEs = require("lodash-es");
14
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
16
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
17
- class CopyWatch {
18
- /**
19
- * Creates an instance of CopyWatch.
20
- *
21
- * @param {string[]} dir 需要监控的目录
22
- * @param {string} copyDir 需要拷贝到的目录
23
- */
24
- constructor(dir, copyDir, opts = {}) {
25
- this.dir = dir;
26
- this.copyDir = copyDir;
27
- this.w = chokidar.watch(this.dir, (0, _lodashEs.merge)({
28
- awaitWriteFinish: {
29
- stabilityThreshold: 300
30
- // 等待0.3秒防抖
31
- }
32
- }, opts));
33
- _consola.default.debug(`\u62F7\u8D1D\u76D1\u63A7\u6587\u4EF6\u5939: ${this.dir}`);
34
- this.init();
35
- }
36
- w;
37
- /**
38
- * 初始化
39
- *
40
- * @protected
41
- */
42
- init() {
43
- this.watchAll = this.watchAll.bind(this);
44
- this.watchErr = this.watchErr.bind(this);
45
- this.w.on("all", this.watchAll);
46
- this.w.on("error", this.watchErr);
47
- }
48
- /**
49
- * 文件监控变更
50
- *
51
- * @protected
52
- * @param {("add" | "addDir" | "change" | "unlink" | "unlinkDir")} eventName
53
- * @param {string} pathStr
54
- * @param {(fs.Stats)} [stats]
55
- */
56
- watchAll(eventName, pathStr, stats) {
57
- if (stats && stats.size <= 0) {
58
- return;
59
- }
60
- const cwd = process.cwd();
61
- const source = _path.default.resolve(cwd, pathStr);
62
- const target = _path.default.resolve(this.copyDir, _path.default.relative(this.dir, pathStr));
63
- switch (eventName) {
64
- case "add":
65
- case "change":
66
- _consola.default.info(`\u62F7\u8D1D\u6587\u4EF6: ${_picocolors.default.cyan(source)} => ${_picocolors.default.cyan(target)}`);
67
- (0, _copyFile.copyFileSync)(source, target);
68
- break;
69
- case "addDir":
70
- break;
71
- case "unlink":
72
- case "unlinkDir":
73
- _consola.default.info(`\u5220\u9664\u6587\u4EF6\u6216\u76EE\u5F55: ${target}`);
74
- rimraf.sync(target);
75
- break;
76
- default:
77
- }
78
- }
79
- /**
80
- * 文件监控异常
81
- *
82
- * @protected
83
- * @param {string} path
84
- * @param {(fs.Stats | undefined)} [stats]
85
- */
86
- watchErr(err) {
87
- _consola.default.error(`\u76D1\u63A7\u6587\u4EF6\u53D1\u751F\u9519\u8BEF: ${err}`);
88
- }
89
- /**
90
- * 停止监控
91
- */
92
- unwatch() {
93
- this.w.off("all", this.watchAll);
94
- this.w.off("error", this.watchErr);
95
- this.w.unwatch(this.dir);
96
- this.w.close();
97
- }
98
- }
99
- exports.CopyWatch = CopyWatch;