@gct-paas/cli 0.0.1-dev.5 → 0.0.1-dev.7

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 (34) hide show
  1. package/dist/commands/create-template/create-template.d.ts +6 -0
  2. package/dist/commands/create-template/create-template.mjs +29 -0
  3. package/dist/commands/index.mjs +6 -0
  4. package/dist/commands/update-template/update-template.d.ts +6 -0
  5. package/dist/commands/update-template/update-template.mjs +17 -0
  6. package/dist/commands/zip/zip.d.ts +21 -0
  7. package/dist/commands/zip/zip.mjs +9 -0
  8. package/dist/core/constants/index.mjs +2 -1
  9. package/dist/core/eslint/eslint-config/eslint-config.mjs +1 -1
  10. package/dist/core/index.d.ts +1 -0
  11. package/dist/core/index.mjs +1 -0
  12. package/dist/core/rollup/rollup-config/dev-config.mjs +10 -7
  13. package/dist/core/template/actions/create-template.d.ts +16 -0
  14. package/dist/core/template/actions/create-template.mjs +43 -0
  15. package/dist/core/template/actions/update-template.d.ts +18 -0
  16. package/dist/core/template/actions/update-template.mjs +61 -0
  17. package/dist/core/template/actions/zip.d.ts +9 -0
  18. package/dist/core/template/actions/zip.mjs +13 -0
  19. package/dist/core/template/constant/index.d.ts +1 -0
  20. package/dist/core/template/constant/index.mjs +1 -0
  21. package/dist/core/template/index.d.ts +3 -0
  22. package/dist/core/template/index.mjs +3 -0
  23. package/dist/core/util/index.d.ts +0 -4
  24. package/dist/core/util/watcher/watcher.d.ts +0 -13
  25. package/dist/core/util/watcher/watcher.mjs +0 -11
  26. package/dist/core/vite/index.d.ts +2 -0
  27. package/dist/core/vite/index.mjs +6 -0
  28. package/dist/core/vite/vite-config/vite-base-config.d.ts +9 -0
  29. package/dist/core/vite/vite-config/vite-base-config.mjs +53 -0
  30. package/dist/core/vite/vite-config/vite-config.mjs +17 -54
  31. package/dist/core/vite/vite-config/vite-plugin-config.d.ts +25 -0
  32. package/dist/core/vite/vite-config/vite-plugin-config.mjs +97 -0
  33. package/dist/interface/i-command/i-command.d.ts +0 -6
  34. package/package.json +13 -4
@@ -0,0 +1,6 @@
1
+ import { Command } from 'commander';
2
+ import { ICommand } from '../../interface';
3
+ export declare class CreateTemplateCommand implements ICommand {
4
+ load(program: Command): void;
5
+ action(): Promise<void>;
6
+ }
@@ -0,0 +1,29 @@
1
+ import fse from "fs-extra";
2
+ import ora from "ora";
3
+ import { confirm, input } from "@inquirer/prompts";
4
+ import { CreateTemplateAction } from "../../core/index.mjs";
5
+ export class CreateTemplateCommand {
6
+ load(program) {
7
+ program.command("create-template").description("\u57FA\u4E8E\u6A21\u677F\u521B\u5EFA paas \u5E73\u53F0\u63D2\u4EF6").action(this.action.bind(this));
8
+ }
9
+ async action() {
10
+ const cwd = process.cwd();
11
+ const child = fse.readdirSync(cwd);
12
+ if (child.length > 0) {
13
+ const bol = await confirm({
14
+ message: "\u5F53\u524D\u76EE\u5F55\u4E0D\u4E3A\u7A7A\uFF0C\u7EE7\u7EED\u5C06\u53EF\u80FD\u8986\u76D6\u5DF2\u6709\u6587\u4EF6\uFF0C\u662F\u5426\u7EE7\u7EED\u521B\u5EFA\uFF1F",
15
+ default: false
16
+ });
17
+ if (bol === false) {
18
+ process.exit();
19
+ }
20
+ }
21
+ const name = await input({
22
+ message: "\u8BF7\u8F93\u5165\u63D2\u4EF6\u540D\u79F0",
23
+ default: "gct-plugin"
24
+ });
25
+ const spinner = ora("\u521D\u59CB\u5316\u63D2\u4EF6").start();
26
+ await new CreateTemplateAction().run(process.cwd(), name);
27
+ spinner.succeed("\u521D\u59CB\u5316\u5B8C\u6210");
28
+ }
29
+ }
@@ -1,6 +1,12 @@
1
1
  import { consola } from "consola";
2
+ import { CreateTemplateCommand } from "./create-template/create-template.mjs";
3
+ import { UpdateTemplateCommand } from "./update-template/update-template.mjs";
4
+ import { ZipCommand } from "./zip/zip.mjs";
2
5
  export class CommandLoader {
3
6
  static load(program) {
7
+ new CreateTemplateCommand().load(program);
8
+ new UpdateTemplateCommand().load(program);
9
+ new ZipCommand().load(program);
4
10
  this.handleInvalidCommand(program);
5
11
  }
6
12
  static handleInvalidCommand(program) {
@@ -0,0 +1,6 @@
1
+ import { Command } from 'commander';
2
+ import { ICommand } from '../../interface';
3
+ export declare class UpdateTemplateCommand implements ICommand {
4
+ load(program: Command): void;
5
+ action(): Promise<void>;
6
+ }
@@ -0,0 +1,17 @@
1
+ import ora from "ora";
2
+ import { confirm } from "@inquirer/prompts";
3
+ import { UpdateTemplateAction } from "../../core/index.mjs";
4
+ export class UpdateTemplateCommand {
5
+ load(program) {
6
+ program.command("update-template").description("paas \u5E73\u53F0\u63D2\u4EF6\u589E\u91CF\u66F4\u65B0").action(this.action.bind(this));
7
+ }
8
+ async action() {
9
+ const overwrite = await confirm({
10
+ message: "\u66F4\u65B0\u65F6\u9009\u62E9\u4E0D\u8986\u76D6\uFF0C\u53EF\u4FDD\u7559\u5DF2\u4FEE\u6539\u7684\u6587\u4EF6\u800C\u4E0D\u88AB\u65B0\u7248\u672C\u66FF\u6362\u3002\u662F\u5426\u8986\u76D6\u66F4\u65B0\uFF1F",
11
+ default: false
12
+ });
13
+ const spinner = ora("\u589E\u91CF\u66F4\u65B0\u63D2\u4EF6").start();
14
+ await new UpdateTemplateAction().run(process.cwd(), overwrite);
15
+ spinner.succeed("\u66F4\u65B0\u5B8C\u6210");
16
+ }
17
+ }
@@ -0,0 +1,21 @@
1
+ import { Command } from 'commander';
2
+ import { ICommand } from '../../interface';
3
+ interface ZipCommandParams {
4
+ /**
5
+ * 待压缩目录
6
+ *
7
+ * @type {string}
8
+ */
9
+ folder: string;
10
+ /**
11
+ * 输出文件名
12
+ *
13
+ * @type {string}
14
+ */
15
+ output: string;
16
+ }
17
+ export declare class ZipCommand implements ICommand {
18
+ load(program: Command): void;
19
+ action(args: ZipCommandParams): Promise<void>;
20
+ }
21
+ export {};
@@ -0,0 +1,9 @@
1
+ import { ZipAction } from "../../core/index.mjs";
2
+ export class ZipCommand {
3
+ load(program) {
4
+ program.command("zip").description("zip \u538B\u7F29\u76EE\u5F55").option("--folder <folder-path>", "\u5F85\u538B\u7F29\u76EE\u5F55").option("--output <output-file>", "\u8F93\u51FA\u6587\u4EF6\u540D").action(this.action.bind(this));
5
+ }
6
+ async action(args) {
7
+ new ZipAction().run(process.cwd(), args.folder, args.output);
8
+ }
9
+ }
@@ -19,5 +19,6 @@ export const DEFAULT_EXTERNAL = [
19
19
  "@gct-paas/design-mobile",
20
20
  "@gct-paas/design-web",
21
21
  "@gct-paas/mobile",
22
- "@gct-paas/web"
22
+ "@gct-paas/web",
23
+ "systemjs"
23
24
  ];
@@ -89,7 +89,7 @@ export function defineEslintConfig(...configs) {
89
89
  ],
90
90
  "@typescript-eslint/no-inferrable-types": "off",
91
91
  "@typescript-eslint/no-explicit-any": ["error"],
92
- "@typescript-eslint/explicit-module-boundary-types": "error",
92
+ "@typescript-eslint/explicit-module-boundary-types": "off",
93
93
  "@typescript-eslint/no-non-null-assertion": "off",
94
94
  "@typescript-eslint/no-extraneous-class": "off",
95
95
  // 其他配置覆盖
@@ -3,5 +3,6 @@ export * from './eslint';
3
3
  export * from './prettier';
4
4
  export * from './rollup';
5
5
  export * from './stylelint';
6
+ export * from './template';
6
7
  export * from './util';
7
8
  export * from './vite';
@@ -3,5 +3,6 @@ export * from "./eslint/index.mjs";
3
3
  export * from "./prettier/index.mjs";
4
4
  export * from "./rollup/index.mjs";
5
5
  export * from "./stylelint/index.mjs";
6
+ export * from "./template/index.mjs";
6
7
  export * from "./util/index.mjs";
7
8
  export * from "./vite/index.mjs";
@@ -23,7 +23,7 @@ export function defineRollupConfig(opts = {}) {
23
23
  const rootDir = path.resolve(cwd, "src");
24
24
  const outDir = path.resolve(cwd, "es");
25
25
  const assetsDir = path.resolve(cwd, "public");
26
- const externalCompileFileReg = /\.(vue|scss|css|less)+$/;
26
+ const externalCompileFileReg = /\.(vue|scss|css|less|d\.ts)+$/;
27
27
  rf.sync(outDir);
28
28
  const input = glob.sync("src/**/*.{ts,tsx}", {
29
29
  cwd,
@@ -35,7 +35,7 @@ export function defineRollupConfig(opts = {}) {
35
35
  if (fs.pathExistsSync(assetsDir)) {
36
36
  cpy(assetsDir, outDir);
37
37
  }
38
- cpy(path.resolve(cwd, "src/**/*.{vue,scss,css,less}"), outDir);
38
+ cpy(path.resolve(cwd, "src/**/*.{vue,scss,css,less,d.ts}"), outDir);
39
39
  } else {
40
40
  copyFile([
41
41
  {
@@ -75,6 +75,10 @@ export function defineRollupConfig(opts = {}) {
75
75
  plugins: [
76
76
  ignoreCompilerFile(externalCompileFileReg),
77
77
  json(),
78
+ vue({
79
+ isProduction: false
80
+ }),
81
+ vueJsx({}),
78
82
  nodeResolve({
79
83
  extensions: [".cjs", ".mjs", ".js", ".ts"]
80
84
  }),
@@ -82,12 +86,11 @@ export function defineRollupConfig(opts = {}) {
82
86
  esbuild({
83
87
  logLevel: "verbose",
84
88
  sourceMap: false,
85
- target: ["esnext"]
86
- }),
87
- vue({
88
- isProduction: false
89
+ target: ["esnext"],
90
+ loaders: {
91
+ ".vue": "ts"
92
+ }
89
93
  }),
90
- vueJsx({}),
91
94
  dts({
92
95
  outDir: [outDir]
93
96
  })
@@ -0,0 +1,16 @@
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
+ }
@@ -0,0 +1,43 @@
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
+ }
@@ -0,0 +1,18 @@
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
+ }
@@ -0,0 +1,61 @@
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
+ }
@@ -0,0 +1,9 @@
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
+ }
@@ -0,0 +1,13 @@
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
+ }
@@ -0,0 +1 @@
1
+ export declare const TEMPLATE_GIT = "https://git.gct-china.com/paas/frontend/paas-comp-template.git";
@@ -0,0 +1 @@
1
+ export const TEMPLATE_GIT = "https://git.gct-china.com/paas/frontend/paas-comp-template.git";
@@ -0,0 +1,3 @@
1
+ export { CreateTemplateAction } from './actions/create-template';
2
+ export { UpdateTemplateAction } from './actions/update-template';
3
+ export { ZipAction } from './actions/zip';
@@ -0,0 +1,3 @@
1
+ export { CreateTemplateAction } from "./actions/create-template.mjs";
2
+ export { UpdateTemplateAction } from "./actions/update-template.mjs";
3
+ export { ZipAction } from "./actions/zip.mjs";
@@ -2,8 +2,6 @@ export { CopyWatch } from './watcher/watcher';
2
2
  /**
3
3
  * win 路径 \\ 转 linux 路径 /
4
4
  *
5
- * @author chitanda
6
- * @date 2022-01-19 09:01:23
7
5
  * @export
8
6
  * @param {string} pathStr
9
7
  * @return {*} {string}
@@ -12,8 +10,6 @@ export declare function winToUnixPath(pathStr: string): string;
12
10
  /**
13
11
  * linux 路径 / 转 win 路径 \\
14
12
  *
15
- * @author chitanda
16
- * @date 2022-01-19 10:01:34
17
13
  * @export
18
14
  * @param {string} pathStr
19
15
  * @return {*} {string}
@@ -4,8 +4,6 @@ import { EventName } from 'chokidar/handler';
4
4
  /**
5
5
  * 文件监控类
6
6
  *
7
- * @author chitanda
8
- * @date 2022-05-24 14:05:22
9
7
  * @export
10
8
  * @class CopyWatch
11
9
  */
@@ -16,8 +14,6 @@ export declare class CopyWatch {
16
14
  /**
17
15
  * Creates an instance of CopyWatch.
18
16
  *
19
- * @author chitanda
20
- * @date 2022-05-24 14:05:28
21
17
  * @param {string[]} dir 需要监控的目录
22
18
  * @param {string} copyDir 需要拷贝到的目录
23
19
  */
@@ -25,16 +21,12 @@ export declare class CopyWatch {
25
21
  /**
26
22
  * 初始化
27
23
  *
28
- * @author chitanda
29
- * @date 2022-05-24 14:05:34
30
24
  * @protected
31
25
  */
32
26
  protected init(): void;
33
27
  /**
34
28
  * 文件监控变更
35
29
  *
36
- * @author chitanda
37
- * @date 2022-05-24 14:05:18
38
30
  * @protected
39
31
  * @param {("add" | "addDir" | "change" | "unlink" | "unlinkDir")} eventName
40
32
  * @param {string} pathStr
@@ -44,8 +36,6 @@ export declare class CopyWatch {
44
36
  /**
45
37
  * 文件监控异常
46
38
  *
47
- * @author chitanda
48
- * @date 2022-05-24 14:05:13
49
39
  * @protected
50
40
  * @param {string} path
51
41
  * @param {(fs.Stats | undefined)} [stats]
@@ -53,9 +43,6 @@ export declare class CopyWatch {
53
43
  protected watchErr(err: unknown): void;
54
44
  /**
55
45
  * 停止监控
56
- *
57
- * @author chitanda
58
- * @date 2022-05-24 14:05:06
59
46
  */
60
47
  unwatch(): void;
61
48
  }
@@ -9,8 +9,6 @@ export class CopyWatch {
9
9
  /**
10
10
  * Creates an instance of CopyWatch.
11
11
  *
12
- * @author chitanda
13
- * @date 2022-05-24 14:05:28
14
12
  * @param {string[]} dir 需要监控的目录
15
13
  * @param {string} copyDir 需要拷贝到的目录
16
14
  */
@@ -36,8 +34,6 @@ export class CopyWatch {
36
34
  /**
37
35
  * 初始化
38
36
  *
39
- * @author chitanda
40
- * @date 2022-05-24 14:05:34
41
37
  * @protected
42
38
  */
43
39
  init() {
@@ -49,8 +45,6 @@ export class CopyWatch {
49
45
  /**
50
46
  * 文件监控变更
51
47
  *
52
- * @author chitanda
53
- * @date 2022-05-24 14:05:18
54
48
  * @protected
55
49
  * @param {("add" | "addDir" | "change" | "unlink" | "unlinkDir")} eventName
56
50
  * @param {string} pathStr
@@ -84,8 +78,6 @@ export class CopyWatch {
84
78
  /**
85
79
  * 文件监控异常
86
80
  *
87
- * @author chitanda
88
- * @date 2022-05-24 14:05:13
89
81
  * @protected
90
82
  * @param {string} path
91
83
  * @param {(fs.Stats | undefined)} [stats]
@@ -95,9 +87,6 @@ export class CopyWatch {
95
87
  }
96
88
  /**
97
89
  * 停止监控
98
- *
99
- * @author chitanda
100
- * @date 2022-05-24 14:05:06
101
90
  */
102
91
  unwatch() {
103
92
  this.w.off("all", this.watchAll);
@@ -1,2 +1,4 @@
1
+ export { defineViteBaseConfig } from './vite-config/vite-base-config';
1
2
  export { defineViteConfig } from './vite-config/vite-config';
2
3
  export { defineDevViteConfig } from './vite-config/vite-dev-config';
4
+ export { defineDesignPluginViteConfig, defineMobilePluginViteConfig, defineWebPluginViteConfig, } from './vite-config/vite-plugin-config';
@@ -1,2 +1,8 @@
1
+ export { defineViteBaseConfig } from "./vite-config/vite-base-config.mjs";
1
2
  export { defineViteConfig } from "./vite-config/vite-config.mjs";
2
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";
@@ -0,0 +1,9 @@
1
+ import { UserConfig } from 'vite';
2
+ /**
3
+ * 构建 vite 通用配置,基于此配置构建其他 vite 配置
4
+ *
5
+ * @export
6
+ * @param {UserConfig} [opts={}]
7
+ * @returns {*} {UserConfig}
8
+ */
9
+ export declare function defineViteBaseConfig(opts?: UserConfig): UserConfig;
@@ -0,0 +1,53 @@
1
+ import { defineConfig, mergeConfig } from "vite";
2
+ import vue from "@vitejs/plugin-vue";
3
+ import vueJsx from "@vitejs/plugin-vue-jsx";
4
+ import { babel } from "@rollup/plugin-babel";
5
+ import json from "@rollup/plugin-json";
6
+ import path from "path";
7
+ import { DEFAULT_EXTERNAL } from "../../constants/index.mjs";
8
+ export function defineViteBaseConfig(opts = {}) {
9
+ const cwd = process.cwd();
10
+ const outDir = path.resolve(cwd, "dist");
11
+ return mergeConfig(
12
+ defineConfig({
13
+ css: {
14
+ preprocessorOptions: {
15
+ scss: {
16
+ additionalData: `@use "@gct-paas/scss/style/global.scss" as *;`
17
+ }
18
+ }
19
+ },
20
+ build: {
21
+ outDir,
22
+ rollupOptions: {
23
+ external: DEFAULT_EXTERNAL
24
+ }
25
+ },
26
+ plugins: [
27
+ json(),
28
+ vue(),
29
+ vueJsx(),
30
+ babel({
31
+ babelHelpers: "bundled",
32
+ presets: [
33
+ [
34
+ "@babel/preset-env",
35
+ {
36
+ useBuiltIns: "usage",
37
+ corejs: 3,
38
+ bugfixes: true,
39
+ targets: {
40
+ chrome: "85",
41
+ edge: "85",
42
+ firefox: "79",
43
+ safari: "14.1"
44
+ }
45
+ }
46
+ ]
47
+ ]
48
+ })
49
+ ]
50
+ }),
51
+ opts
52
+ );
53
+ }
@@ -1,68 +1,31 @@
1
1
  import { defineConfig, mergeConfig } from "vite";
2
- import vue from "@vitejs/plugin-vue";
3
- import vueJsx from "@vitejs/plugin-vue-jsx";
4
- import { babel } from "@rollup/plugin-babel";
5
- import json from "@rollup/plugin-json";
6
2
  import path from "path";
7
3
  import * as rf from "rimraf";
8
- import { DEFAULT_EXTERNAL } from "../../constants/index.mjs";
4
+ import { defineViteBaseConfig } from "./vite-base-config.mjs";
9
5
  export function defineViteConfig(opts = {}) {
10
6
  const cwd = process.cwd();
11
7
  const outDir = path.resolve(cwd, "dist");
12
8
  rf.sync(outDir);
13
9
  return mergeConfig(
14
- defineConfig({
15
- css: {
16
- preprocessorOptions: {
17
- scss: {
18
- additionalData: `@use "@gct-paas/scss/style/global.scss" as *;`
19
- }
20
- }
21
- },
22
- build: {
23
- outDir,
24
- rollupOptions: {
25
- external: DEFAULT_EXTERNAL
26
- },
27
- lib: {
28
- entry: path.resolve(cwd, "src/index.ts"),
29
- formats: ["system", "cjs"],
30
- fileName(format) {
31
- if (format === "system" || format === "systemjs") {
32
- return `[name].system.min.js`;
33
- }
34
- if (format === "cjs" || format === "commonjs") {
35
- return `[name].min.cjs`;
10
+ defineViteBaseConfig(
11
+ defineConfig({
12
+ build: {
13
+ lib: {
14
+ entry: path.resolve(cwd, "src/index.ts"),
15
+ formats: ["system", "cjs"],
16
+ fileName(format) {
17
+ if (format === "system" || format === "systemjs") {
18
+ return `[name].system.min.js`;
19
+ }
20
+ if (format === "cjs" || format === "commonjs") {
21
+ return `[name].min.cjs`;
22
+ }
23
+ return `[name].${format}.min.js`;
36
24
  }
37
- return `[name].${format}.min.js`;
38
25
  }
39
26
  }
40
- },
41
- plugins: [
42
- json(),
43
- vue(),
44
- vueJsx(),
45
- babel({
46
- babelHelpers: "bundled",
47
- presets: [
48
- [
49
- "@babel/preset-env",
50
- {
51
- useBuiltIns: "usage",
52
- corejs: 3,
53
- bugfixes: true,
54
- targets: {
55
- chrome: "85",
56
- edge: "85",
57
- firefox: "79",
58
- safari: "14.1"
59
- }
60
- }
61
- ]
62
- ]
63
- })
64
- ]
65
- }),
27
+ })
28
+ ),
66
29
  opts
67
30
  );
68
31
  }
@@ -0,0 +1,25 @@
1
+ import { UserConfig } from 'vite';
2
+ /**
3
+ * 设计端构建配置
4
+ *
5
+ * @export
6
+ * @param {UserConfig} [opts={}]
7
+ * @returns {*} {UserConfig}
8
+ */
9
+ export declare function defineDesignPluginViteConfig(opts?: UserConfig): UserConfig;
10
+ /**
11
+ * 移动端插件构建配置
12
+ *
13
+ * @export
14
+ * @param {UserConfig} [opts={}]
15
+ * @returns {*} {UserConfig}
16
+ */
17
+ export declare function defineMobilePluginViteConfig(opts?: UserConfig): UserConfig;
18
+ /**
19
+ * 网页端插件构建配置
20
+ *
21
+ * @export
22
+ * @param {UserConfig} [opts={}]
23
+ * @returns {*} {UserConfig}
24
+ */
25
+ export declare function defineWebPluginViteConfig(opts?: UserConfig): UserConfig;
@@ -0,0 +1,97 @@
1
+ import { mergeConfig } from "vite";
2
+ import path from "path";
3
+ import { defineViteBaseConfig } from "./vite-base-config.mjs";
4
+ const formats = ["system", "cjs"];
5
+ function formatFileName(format) {
6
+ if (format === "system" || format === "systemjs") {
7
+ return `[name].system.min.js`;
8
+ }
9
+ if (format === "cjs" || format === "commonjs") {
10
+ return `[name].min.cjs`;
11
+ }
12
+ return `[name].${format}.min.js`;
13
+ }
14
+ function assetFileNames(assetInfo, name) {
15
+ if (assetInfo.names.length > 0 && assetInfo.names[0].endsWith(".css")) {
16
+ return name + ".min.css";
17
+ }
18
+ return assetInfo.names[0];
19
+ }
20
+ export function defineDesignPluginViteConfig(opts = {}) {
21
+ const cwd = process.cwd();
22
+ const designEntry = path.resolve(cwd, "src/index.ts");
23
+ return mergeConfig(
24
+ defineViteBaseConfig({
25
+ build: {
26
+ emptyOutDir: false,
27
+ rollupOptions: {
28
+ output: {
29
+ assetFileNames: (assetInfo) => {
30
+ return assetFileNames(assetInfo, "design");
31
+ }
32
+ }
33
+ },
34
+ lib: {
35
+ entry: {
36
+ design: designEntry
37
+ },
38
+ formats,
39
+ fileName: formatFileName
40
+ }
41
+ }
42
+ }),
43
+ opts
44
+ );
45
+ }
46
+ export function defineMobilePluginViteConfig(opts = {}) {
47
+ const cwd = process.cwd();
48
+ const mobileEntry = path.resolve(cwd, "src/index.ts");
49
+ return mergeConfig(
50
+ defineViteBaseConfig({
51
+ build: {
52
+ emptyOutDir: false,
53
+ rollupOptions: {
54
+ output: {
55
+ assetFileNames: (assetInfo) => {
56
+ return assetFileNames(assetInfo, "mobile");
57
+ }
58
+ }
59
+ },
60
+ lib: {
61
+ entry: {
62
+ mobile: mobileEntry
63
+ },
64
+ formats,
65
+ fileName: formatFileName
66
+ }
67
+ }
68
+ }),
69
+ opts
70
+ );
71
+ }
72
+ export function defineWebPluginViteConfig(opts = {}) {
73
+ const cwd = process.cwd();
74
+ const webEntry = path.resolve(cwd, "src/index.ts");
75
+ return mergeConfig(
76
+ defineViteBaseConfig({
77
+ build: {
78
+ emptyOutDir: false,
79
+ rollupOptions: {
80
+ output: {
81
+ assetFileNames: (assetInfo) => {
82
+ return assetFileNames(assetInfo, "web");
83
+ }
84
+ }
85
+ },
86
+ lib: {
87
+ entry: {
88
+ web: webEntry
89
+ },
90
+ formats,
91
+ fileName: formatFileName
92
+ }
93
+ }
94
+ }),
95
+ opts
96
+ );
97
+ }
@@ -2,8 +2,6 @@ import { Command } from 'commander';
2
2
  /**
3
3
  * 命令项
4
4
  *
5
- * @author chitanda
6
- * @date 2021-12-18 15:12:13
7
5
  * @export
8
6
  * @interface ICommand
9
7
  */
@@ -11,16 +9,12 @@ export interface ICommand {
11
9
  /**
12
10
  * 加载命令
13
11
  *
14
- * @author chitanda
15
- * @date 2021-12-18 15:12:22
16
12
  * @param {Command} program
17
13
  */
18
14
  load(program: Command): void;
19
15
  /**
20
16
  * 执行行为
21
17
  *
22
- * @author chitanda
23
- * @date 2021-12-21 16:12:22
24
18
  * @param {...unknown[]} args
25
19
  * @return {*} {(void | Promise<void>)}
26
20
  */
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@gct-paas/cli",
3
- "version": "0.0.1-dev.5",
3
+ "version": "0.0.1-dev.7",
4
4
  "type": "module",
5
5
  "description": "paas 平台核心包",
6
6
  "bin": {
7
- "gct-build": "dist/bin.mjs"
7
+ "gct-paas": "dist/bin.mjs"
8
8
  },
9
9
  "main": "dist/index.mjs",
10
10
  "types": "dist/index.d.ts",
@@ -38,21 +38,26 @@
38
38
  "@commitlint/cli": "^19.6.1",
39
39
  "@commitlint/config-conventional": "^19.6.0",
40
40
  "@eslint/js": "^9.17.0",
41
- "@gct-paas/scss": "workspace:*",
41
+ "@gct-paas/scss": "*",
42
+ "@inquirer/prompts": "^7.3.1",
42
43
  "@rollup/plugin-babel": "^6.0.4",
43
44
  "@rollup/plugin-commonjs": "^28.0.2",
44
45
  "@rollup/plugin-eslint": "^9.0.5",
45
46
  "@rollup/plugin-json": "^6.1.0",
46
47
  "@rollup/plugin-node-resolve": "^16.0.0",
48
+ "@rollup/plugin-typescript": "^12.1.2",
47
49
  "@vitejs/plugin-vue": "^5.2.1",
48
50
  "@vitejs/plugin-vue-jsx": "^4.1.1",
49
51
  "@vue/compiler-sfc": "^3.5.13",
52
+ "archiver": "^7.0.1",
50
53
  "chokidar": "^4.0.3",
51
54
  "commander": "^13.0.0",
52
55
  "consola": "^3.3.3",
53
56
  "copy-file": "^11.0.0",
54
57
  "core-js": "^3.40.0",
55
58
  "cpy": "^11.1.0",
59
+ "crypto": "^1.0.1",
60
+ "esbuild": "^0.24.2",
56
61
  "eslint": "^9.17.0",
57
62
  "eslint-config-prettier": "^9.1.0",
58
63
  "eslint-plugin-import": "^2.31.0",
@@ -63,20 +68,24 @@
63
68
  "fs-extra": "^11.2.0",
64
69
  "globals": "^15.14.0",
65
70
  "lodash-es": "^4.17.21",
71
+ "ora": "^8.2.0",
66
72
  "picocolors": "^1.1.1",
67
73
  "prettier": "^3.4.2",
68
74
  "rimraf": "^6.0.1",
69
75
  "rollup": "^4.30.0",
70
76
  "rollup-plugin-esbuild": "^6.1.1",
77
+ "simple-git": "^3.27.0",
71
78
  "stylelint": "^16.12.0",
72
79
  "stylelint-config-standard": "^36.0.1",
73
80
  "stylelint-config-standard-scss": "^14.0.0",
74
81
  "typescript-eslint": "^8.19.0",
82
+ "vite": "^6.0.7",
75
83
  "vite-plugin-dts": "^4.4.0",
76
84
  "vue-tsc": "^2.2.0"
77
85
  },
78
86
  "devDependencies": {
79
87
  "@commitlint/types": "^19.5.0",
88
+ "@types/archiver": "^6.0.3",
80
89
  "@types/babel__core": "^7.20.5",
81
90
  "@types/babel__preset-env": "^7.9.7",
82
91
  "@types/fs-extra": "^11.0.4",
@@ -85,5 +94,5 @@
85
94
  "typescript": "^5.7.2",
86
95
  "unbuild": "^3.2.0"
87
96
  },
88
- "gitHead": "2466aa73804b93fcc773880a05d57eb914bf26fb"
97
+ "gitHead": "b467be0657258b6b09979789977bcb3f141bdb9c"
89
98
  }