@gct-paas/cli 0.0.1-dev.7.1 → 0.0.1-dev.7.2
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/dist/bin.cjs +5 -0
- package/dist/commands/create-template/create-template.cjs +37 -0
- package/dist/commands/index.cjs +27 -0
- package/dist/commands/update-template/update-template.cjs +25 -0
- package/dist/commands/zip/zip.cjs +16 -0
- package/dist/core/commitlint/commitlint-config/commitlint-config.cjs +15 -0
- package/dist/core/commitlint/index.cjs +12 -0
- package/dist/core/constants/index.cjs +9 -0
- package/dist/core/eslint/eslint-config/eslint-config.cjs +85 -0
- package/dist/core/eslint/index.cjs +12 -0
- package/dist/core/index.cjs +93 -0
- package/dist/core/prettier/index.cjs +12 -0
- package/dist/core/prettier/prettier-config/prettier-config.cjs +29 -0
- package/dist/core/rollup/index.cjs +27 -0
- package/dist/core/rollup/rollup-config/dev-config.cjs +93 -0
- package/dist/core/rollup/rollup-plugins/copy-file.cjs +24 -0
- package/dist/core/rollup/rollup-plugins/ignore-compiler-file.cjs +23 -0
- package/dist/core/rollup/rollup-plugins/index.cjs +19 -0
- package/dist/core/stylelint/index.cjs +12 -0
- package/dist/core/stylelint/stylelint-config/stylelint-config.cjs +24 -0
- package/dist/core/template/actions/create-template.cjs +53 -0
- package/dist/core/template/actions/update-template.cjs +71 -0
- package/dist/core/template/actions/zip.cjs +25 -0
- package/dist/core/template/constant/index.cjs +7 -0
- package/dist/core/template/index.cjs +26 -0
- package/dist/core/util/index.cjs +20 -0
- package/dist/core/util/watcher/watcher.cjs +99 -0
- package/dist/core/vite/index.cjs +45 -0
- package/dist/core/vite/vite-config/vite-base-config.cjs +47 -0
- package/dist/core/vite/vite-config/vite-config.cjs +35 -0
- package/dist/core/vite/vite-config/vite-dev-config.cjs +23 -0
- package/dist/core/vite/vite-config/vite-plugin-config.cjs +97 -0
- package/dist/index.cjs +47 -0
- package/dist/interface/i-command/i-command.cjs +1 -0
- package/dist/interface/index.cjs +16 -0
- package/dist/utils/index.cjs +18 -0
- package/dist/utils/local-binaries/local-binaries.cjs +19 -0
- package/es/bin.d.ts +2 -0
- package/es/commands/create-template/create-template.d.ts +6 -0
- package/es/commands/index.d.ts +5 -0
- package/es/commands/update-template/update-template.d.ts +6 -0
- package/es/commands/zip/zip.d.ts +21 -0
- package/es/core/commitlint/commitlint-config/commitlint-config.d.ts +9 -0
- package/es/core/commitlint/index.d.ts +1 -0
- package/es/core/constants/index.d.ts +12 -0
- package/es/core/eslint/eslint-config/eslint-config.d.ts +9 -0
- package/es/core/eslint/index.d.ts +1 -0
- package/es/core/index.d.ts +8 -0
- package/es/core/prettier/index.d.ts +1 -0
- package/es/core/prettier/prettier-config/prettier-config.d.ts +22 -0
- package/es/core/rollup/index.d.ts +2 -0
- package/es/core/rollup/rollup-config/dev-config.d.ts +9 -0
- package/es/core/rollup/rollup-plugins/copy-file.d.ts +37 -0
- package/es/core/rollup/rollup-plugins/ignore-compiler-file.d.ts +8 -0
- package/es/core/rollup/rollup-plugins/index.d.ts +2 -0
- package/es/core/stylelint/index.d.ts +1 -0
- package/es/core/stylelint/stylelint-config/stylelint-config.d.ts +9 -0
- package/es/core/template/actions/create-template.d.ts +16 -0
- package/es/core/template/actions/update-template.d.ts +18 -0
- package/es/core/template/actions/zip.d.ts +9 -0
- package/es/core/template/constant/index.d.ts +1 -0
- package/es/core/template/index.d.ts +3 -0
- package/es/core/util/index.d.ts +17 -0
- package/es/core/util/watcher/watcher.d.ts +48 -0
- package/es/core/vite/index.d.ts +4 -0
- package/es/core/vite/vite-config/vite-base-config.d.ts +9 -0
- package/es/core/vite/vite-config/vite-config.d.ts +9 -0
- package/es/core/vite/vite-config/vite-dev-config.d.ts +9 -0
- package/es/core/vite/vite-config/vite-plugin-config.d.ts +25 -0
- package/es/index.d.ts +2 -0
- package/es/interface/i-command/i-command.d.ts +22 -0
- package/es/interface/index.d.ts +1 -0
- package/es/types/index.d.ts +1 -0
- package/es/utils/index.d.ts +1 -0
- package/es/utils/local-binaries/local-binaries.d.ts +3 -0
- package/package.json +12 -3
- /package/{dist → es}/bin.mjs +0 -0
- /package/{dist → es}/commands/create-template/create-template.mjs +0 -0
- /package/{dist → es}/commands/index.mjs +0 -0
- /package/{dist → es}/commands/update-template/update-template.mjs +0 -0
- /package/{dist → es}/commands/zip/zip.mjs +0 -0
- /package/{dist → es}/core/commitlint/commitlint-config/commitlint-config.mjs +0 -0
- /package/{dist → es}/core/commitlint/index.mjs +0 -0
- /package/{dist → es}/core/constants/index.mjs +0 -0
- /package/{dist → es}/core/eslint/eslint-config/eslint-config.mjs +0 -0
- /package/{dist → es}/core/eslint/index.mjs +0 -0
- /package/{dist → es}/core/index.mjs +0 -0
- /package/{dist → es}/core/prettier/index.mjs +0 -0
- /package/{dist → es}/core/prettier/prettier-config/prettier-config.mjs +0 -0
- /package/{dist → es}/core/rollup/index.mjs +0 -0
- /package/{dist → es}/core/rollup/rollup-config/dev-config.mjs +0 -0
- /package/{dist → es}/core/rollup/rollup-plugins/copy-file.mjs +0 -0
- /package/{dist → es}/core/rollup/rollup-plugins/ignore-compiler-file.mjs +0 -0
- /package/{dist → es}/core/rollup/rollup-plugins/index.mjs +0 -0
- /package/{dist → es}/core/stylelint/index.mjs +0 -0
- /package/{dist → es}/core/stylelint/stylelint-config/stylelint-config.mjs +0 -0
- /package/{dist → es}/core/template/actions/create-template.mjs +0 -0
- /package/{dist → es}/core/template/actions/update-template.mjs +0 -0
- /package/{dist → es}/core/template/actions/zip.mjs +0 -0
- /package/{dist → es}/core/template/constant/index.mjs +0 -0
- /package/{dist → es}/core/template/index.mjs +0 -0
- /package/{dist → es}/core/util/index.mjs +0 -0
- /package/{dist → es}/core/util/watcher/watcher.mjs +0 -0
- /package/{dist → es}/core/vite/index.mjs +0 -0
- /package/{dist → es}/core/vite/vite-config/vite-base-config.mjs +0 -0
- /package/{dist → es}/core/vite/vite-config/vite-config.mjs +0 -0
- /package/{dist → es}/core/vite/vite-config/vite-dev-config.mjs +0 -0
- /package/{dist → es}/core/vite/vite-config/vite-plugin-config.mjs +0 -0
- /package/{dist → es}/index.mjs +0 -0
- /package/{dist → es}/interface/i-command/i-command.mjs +0 -0
- /package/{dist → es}/interface/index.mjs +0 -0
- /package/{dist → es}/utils/index.mjs +0 -0
- /package/{dist → es}/utils/local-binaries/local-binaries.mjs +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
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;
|
|
@@ -0,0 +1,71 @@
|
|
|
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;
|
|
@@ -0,0 +1,25 @@
|
|
|
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;
|
|
@@ -0,0 +1,26 @@
|
|
|
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");
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
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;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "defineDesignPluginViteConfig", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _vitePluginConfig.defineDesignPluginViteConfig;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "defineDevViteConfig", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _viteDevConfig.defineDevViteConfig;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "defineMobilePluginViteConfig", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _vitePluginConfig.defineMobilePluginViteConfig;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "defineViteBaseConfig", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _viteBaseConfig.defineViteBaseConfig;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "defineViteConfig", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _viteConfig.defineViteConfig;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "defineWebPluginViteConfig", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _vitePluginConfig.defineWebPluginViteConfig;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
var _viteBaseConfig = require("./vite-config/vite-base-config.cjs");
|
|
43
|
+
var _viteConfig = require("./vite-config/vite-config.cjs");
|
|
44
|
+
var _viteDevConfig = require("./vite-config/vite-dev-config.cjs");
|
|
45
|
+
var _vitePluginConfig = require("./vite-config/vite-plugin-config.cjs");
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defineViteBaseConfig = defineViteBaseConfig;
|
|
7
|
+
var _vite = require("vite");
|
|
8
|
+
var _pluginVue = _interopRequireDefault(require("@vitejs/plugin-vue"));
|
|
9
|
+
var _pluginVueJsx = _interopRequireDefault(require("@vitejs/plugin-vue-jsx"));
|
|
10
|
+
var _pluginBabel = require("@rollup/plugin-babel");
|
|
11
|
+
var _pluginJson = _interopRequireDefault(require("@rollup/plugin-json"));
|
|
12
|
+
var _path = _interopRequireDefault(require("path"));
|
|
13
|
+
var _constants = require("../../constants/index.cjs");
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
+
function defineViteBaseConfig(opts = {}) {
|
|
16
|
+
const cwd = process.cwd();
|
|
17
|
+
const outDir = _path.default.resolve(cwd, "dist");
|
|
18
|
+
return (0, _vite.mergeConfig)((0, _vite.defineConfig)({
|
|
19
|
+
css: {
|
|
20
|
+
preprocessorOptions: {
|
|
21
|
+
scss: {
|
|
22
|
+
additionalData: `@use "@gct-paas/scss/style/global.scss" as *;`
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
build: {
|
|
27
|
+
outDir,
|
|
28
|
+
rollupOptions: {
|
|
29
|
+
external: _constants.DEFAULT_EXTERNAL
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
plugins: [(0, _pluginJson.default)(), (0, _pluginVue.default)(), (0, _pluginVueJsx.default)(), (0, _pluginBabel.babel)({
|
|
33
|
+
babelHelpers: "bundled",
|
|
34
|
+
presets: [["@babel/preset-env", {
|
|
35
|
+
useBuiltIns: "usage",
|
|
36
|
+
corejs: 3,
|
|
37
|
+
bugfixes: true,
|
|
38
|
+
targets: {
|
|
39
|
+
chrome: "85",
|
|
40
|
+
edge: "85",
|
|
41
|
+
firefox: "79",
|
|
42
|
+
safari: "14.1"
|
|
43
|
+
}
|
|
44
|
+
}]]
|
|
45
|
+
})]
|
|
46
|
+
}), opts);
|
|
47
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defineViteConfig = defineViteConfig;
|
|
7
|
+
var _vite = require("vite");
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var rf = _interopRequireWildcard(require("rimraf"));
|
|
10
|
+
var _viteBaseConfig = require("./vite-base-config.cjs");
|
|
11
|
+
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); }
|
|
12
|
+
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; }
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
function defineViteConfig(opts = {}) {
|
|
15
|
+
const cwd = process.cwd();
|
|
16
|
+
const outDir = _path.default.resolve(cwd, "dist");
|
|
17
|
+
rf.sync(outDir);
|
|
18
|
+
return (0, _vite.mergeConfig)((0, _viteBaseConfig.defineViteBaseConfig)((0, _vite.defineConfig)({
|
|
19
|
+
build: {
|
|
20
|
+
lib: {
|
|
21
|
+
entry: _path.default.resolve(cwd, "src/index.ts"),
|
|
22
|
+
formats: ["system", "cjs"],
|
|
23
|
+
fileName(format) {
|
|
24
|
+
if (format === "system" || format === "systemjs") {
|
|
25
|
+
return `[name].system.min.js`;
|
|
26
|
+
}
|
|
27
|
+
if (format === "cjs" || format === "commonjs") {
|
|
28
|
+
return `[name].min.cjs`;
|
|
29
|
+
}
|
|
30
|
+
return `[name].${format}.min.js`;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
})), opts);
|
|
35
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defineDevViteConfig = defineDevViteConfig;
|
|
7
|
+
var _vite = require("vite");
|
|
8
|
+
var _pluginVue = _interopRequireDefault(require("@vitejs/plugin-vue"));
|
|
9
|
+
var _pluginVueJsx = _interopRequireDefault(require("@vitejs/plugin-vue-jsx"));
|
|
10
|
+
var _pluginJson = _interopRequireDefault(require("@rollup/plugin-json"));
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
function defineDevViteConfig(opts = {}) {
|
|
13
|
+
return (0, _vite.mergeConfig)((0, _vite.defineConfig)({
|
|
14
|
+
css: {
|
|
15
|
+
preprocessorOptions: {
|
|
16
|
+
scss: {
|
|
17
|
+
additionalData: `@use "@gct-paas/scss/style/global.scss" as *;`
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
plugins: [(0, _pluginJson.default)(), (0, _pluginVue.default)(), (0, _pluginVueJsx.default)()]
|
|
22
|
+
}), opts);
|
|
23
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.defineDesignPluginViteConfig = defineDesignPluginViteConfig;
|
|
7
|
+
exports.defineMobilePluginViteConfig = defineMobilePluginViteConfig;
|
|
8
|
+
exports.defineWebPluginViteConfig = defineWebPluginViteConfig;
|
|
9
|
+
var _vite = require("vite");
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
var _viteBaseConfig = require("./vite-base-config.cjs");
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const formats = ["system", "cjs"];
|
|
14
|
+
function formatFileName(format) {
|
|
15
|
+
if (format === "system" || format === "systemjs") {
|
|
16
|
+
return `[name].system.min.js`;
|
|
17
|
+
}
|
|
18
|
+
if (format === "cjs" || format === "commonjs") {
|
|
19
|
+
return `[name].min.cjs`;
|
|
20
|
+
}
|
|
21
|
+
return `[name].${format}.min.js`;
|
|
22
|
+
}
|
|
23
|
+
function assetFileNames(assetInfo, name) {
|
|
24
|
+
if (assetInfo.names.length > 0 && assetInfo.names[0].endsWith(".css")) {
|
|
25
|
+
return name + ".min.css";
|
|
26
|
+
}
|
|
27
|
+
return assetInfo.names[0];
|
|
28
|
+
}
|
|
29
|
+
function defineDesignPluginViteConfig(opts = {}) {
|
|
30
|
+
const cwd = process.cwd();
|
|
31
|
+
const designEntry = _path.default.resolve(cwd, "src/index.ts");
|
|
32
|
+
return (0, _vite.mergeConfig)((0, _viteBaseConfig.defineViteBaseConfig)({
|
|
33
|
+
build: {
|
|
34
|
+
emptyOutDir: false,
|
|
35
|
+
rollupOptions: {
|
|
36
|
+
output: {
|
|
37
|
+
assetFileNames: assetInfo => {
|
|
38
|
+
return assetFileNames(assetInfo, "design");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
lib: {
|
|
43
|
+
entry: {
|
|
44
|
+
design: designEntry
|
|
45
|
+
},
|
|
46
|
+
formats,
|
|
47
|
+
fileName: formatFileName
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}), opts);
|
|
51
|
+
}
|
|
52
|
+
function defineMobilePluginViteConfig(opts = {}) {
|
|
53
|
+
const cwd = process.cwd();
|
|
54
|
+
const mobileEntry = _path.default.resolve(cwd, "src/index.ts");
|
|
55
|
+
return (0, _vite.mergeConfig)((0, _viteBaseConfig.defineViteBaseConfig)({
|
|
56
|
+
build: {
|
|
57
|
+
emptyOutDir: false,
|
|
58
|
+
rollupOptions: {
|
|
59
|
+
output: {
|
|
60
|
+
assetFileNames: assetInfo => {
|
|
61
|
+
return assetFileNames(assetInfo, "mobile");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
lib: {
|
|
66
|
+
entry: {
|
|
67
|
+
mobile: mobileEntry
|
|
68
|
+
},
|
|
69
|
+
formats,
|
|
70
|
+
fileName: formatFileName
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}), opts);
|
|
74
|
+
}
|
|
75
|
+
function defineWebPluginViteConfig(opts = {}) {
|
|
76
|
+
const cwd = process.cwd();
|
|
77
|
+
const webEntry = _path.default.resolve(cwd, "src/index.ts");
|
|
78
|
+
return (0, _vite.mergeConfig)((0, _viteBaseConfig.defineViteBaseConfig)({
|
|
79
|
+
build: {
|
|
80
|
+
emptyOutDir: false,
|
|
81
|
+
rollupOptions: {
|
|
82
|
+
output: {
|
|
83
|
+
assetFileNames: assetInfo => {
|
|
84
|
+
return assetFileNames(assetInfo, "web");
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
lib: {
|
|
89
|
+
entry: {
|
|
90
|
+
web: webEntry
|
|
91
|
+
},
|
|
92
|
+
formats,
|
|
93
|
+
fileName: formatFileName
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}), opts);
|
|
97
|
+
}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
bootstrap: true
|
|
8
|
+
};
|
|
9
|
+
exports.bootstrap = bootstrap;
|
|
10
|
+
var _commander = require("commander");
|
|
11
|
+
var _commands = require("./commands/index.cjs");
|
|
12
|
+
var _utils = require("./utils/index.cjs");
|
|
13
|
+
var _package = _interopRequireDefault(require("../package.json"));
|
|
14
|
+
var _core = require("./core/index.cjs");
|
|
15
|
+
Object.keys(_core).forEach(function (key) {
|
|
16
|
+
if (key === "default" || key === "__esModule") return;
|
|
17
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
18
|
+
if (key in exports && exports[key] === _core[key]) return;
|
|
19
|
+
Object.defineProperty(exports, key, {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _core[key];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
27
|
+
async function bootstrap() {
|
|
28
|
+
process.on("SIGINT", () => {
|
|
29
|
+
process.exit();
|
|
30
|
+
});
|
|
31
|
+
_commander.program.version(_package.default.version, "-v, --version", "\u67E5\u770B\u5F53\u524D\u7248\u672C").usage("<command> [options]").helpOption("-h, --help", "\u83B7\u53D6\u5E2E\u52A9\u4FE1\u606F").configureOutput({
|
|
32
|
+
// Visibly override write routines as example!
|
|
33
|
+
writeErr: str => process.stdout.write(`[ERR] ${str}`),
|
|
34
|
+
// Highlight errors in color.
|
|
35
|
+
outputError: (str, write) => write(`\x1B[31m${str}\x1B[0m`)
|
|
36
|
+
});
|
|
37
|
+
if ((0, _utils.localBinExists)()) {
|
|
38
|
+
const localCommandLoader = (0, _utils.loadLocalBinCommandLoader)();
|
|
39
|
+
localCommandLoader.load(_commander.program);
|
|
40
|
+
} else {
|
|
41
|
+
_commands.CommandLoader.load(_commander.program);
|
|
42
|
+
}
|
|
43
|
+
_commander.program.parse(process.argv);
|
|
44
|
+
if (!process.argv.slice(2).length) {
|
|
45
|
+
_commander.program.outputHelp();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _iCommand = require("./i-command/i-command.cjs");
|
|
7
|
+
Object.keys(_iCommand).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _iCommand[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _iCommand[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "loadLocalBinCommandLoader", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _localBinaries.loadLocalBinCommandLoader;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "localBinExists", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _localBinaries.localBinExists;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _localBinaries = require("./local-binaries/local-binaries.cjs");
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.loadLocalBinCommandLoader = loadLocalBinCommandLoader;
|
|
7
|
+
exports.localBinExists = localBinExists;
|
|
8
|
+
var _path = require("path");
|
|
9
|
+
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
const localBinPathSegments = [process.cwd(), "node_modules", "@nestjs", "cli"];
|
|
12
|
+
function localBinExists() {
|
|
13
|
+
return _fsExtra.default.existsSync((0, _path.join)(...localBinPathSegments));
|
|
14
|
+
}
|
|
15
|
+
function loadLocalBinCommandLoader() {
|
|
16
|
+
const path = _path.posix.join(...localBinPathSegments, "commands");
|
|
17
|
+
const commandsFile = require(path);
|
|
18
|
+
return commandsFile.CommandLoader;
|
|
19
|
+
}
|
package/es/bin.d.ts
ADDED