@infly/libs 2.0.43 → 2.0.45

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 (67) hide show
  1. package/README.md +104 -67
  2. package/{module → adapters/vue2/module}/Permission.js +2 -2
  3. package/{module → adapters/vue2/module}/REST.js +32 -20
  4. package/{module → adapters/vue2/module}/TokenService.js +10 -1
  5. package/adapters/vue2/module/file-export.js +18 -0
  6. package/adapters/vue2/postinstall.js +46 -0
  7. package/adapters/vue2/project-preview.js +152 -0
  8. package/adapters/vue2/script-config.js +26 -0
  9. package/adapters/vue2/store/index.js +1 -0
  10. package/{store → adapters/vue2/store}/modules/user.js +1 -1
  11. package/adapters/vue2/vite/index.js +95 -0
  12. package/adapters/vue2/vite/jest.config.js +11 -0
  13. package/{build → adapters/vue2}/webpack5/webpack.base.js +26 -79
  14. package/bin/cli.js +71 -71
  15. package/build/build-dist/index.js +863 -863
  16. package/build/build-dist/script-management.js +5 -5
  17. package/{script/build → build/build-utils}/command.js +13 -4
  18. package/{script/build → build/build-utils}/deps.js +1 -1
  19. package/{script/build → build/build-utils}/git.js +6 -4
  20. package/{script/build → build/build-utils}/preview.js +4 -1
  21. package/{script/webhook/webhook.js → build/build-utils/webhook-single.js} +7 -2
  22. package/{script/build → build/build-utils}/webhook.js +3 -2
  23. package/build/docker/compose-command.js +74 -74
  24. package/build/docker/compose-release.js +91 -91
  25. package/compat/init.js +9 -0
  26. package/index.js +8 -20
  27. package/module/Uts.js +77 -7265
  28. package/module/cjs/{request-url-rules.cjs → request-url-rules.js} +6 -0
  29. package/module/cjs/rest-error-rules.js +33 -0
  30. package/package.json +124 -92
  31. package/script/git-automation/git-clone.js +3 -4
  32. package/script/git-automation/git-configure.js +29 -0
  33. package/script/git-automation/index.js +0 -14
  34. package/script/git-automation/submodule-status.js +113 -0
  35. package/script/git-automation/submodule-utils.js +18 -0
  36. package/script/index.js +1 -26
  37. package/tools/auto-export.js +1 -2
  38. package/tools/concurrency.js +30 -0
  39. package/tools/progress.js +63 -0
  40. package/tools/project-command.js +198 -194
  41. package/tools/project-preview.js +1 -148
  42. package/tools/select-option.js +60 -60
  43. package/tools/workspace-config.js +145 -0
  44. package/.prettierrc +0 -5
  45. package/build/build-dist/script-management.test.js +0 -16
  46. package/build/docker/compose-command.test.js +0 -148
  47. package/build/docker/compose-release.test.js +0 -101
  48. package/build/docker/docker-build-push.test.js +0 -124
  49. package/build/webpack5/remove-legacy-assets-plugin.js +0 -84
  50. package/build/webpack5/webpack.base.test.js +0 -59
  51. package/lib/index.js +0 -6
  52. package/lib/server/connect.js +0 -3011
  53. package/lib/server/serve-static.js +0 -4848
  54. package/module/cjs/deep-merge.cjs +0 -38
  55. package/script/pts/cloud-scenes.mjs +0 -65
  56. package/script/pts/cloud.js +0 -151
  57. package/script/pts/generate-cloud-params.mjs +0 -210
  58. package/script/pts/generate-cloud-params.test.mjs +0 -67
  59. package/store/index.js +0 -0
  60. package/tools/file-export.js +0 -165
  61. package/tools/project-command.test.js +0 -267
  62. package/tools/select-option.test.js +0 -52
  63. package/webpack.config.js +0 -38
  64. /package/{module → adapters/vue2/module}/Router.js +0 -0
  65. /package/{build → adapters/vue2}/webpack5/inline-runtime-plugin.js +0 -0
  66. /package/{script/build → build/build-utils}/env.js +0 -0
  67. /package/module/cjs/{page-config.cjs → page-config.js} +0 -0
@@ -0,0 +1,11 @@
1
+ module.exports = {
2
+ moduleFileExtensions: ["js", "json", "vue"],
3
+ moduleNameMapper: {
4
+ "^@/(.*)$": "<rootDir>/src/$1",
5
+ },
6
+ testEnvironment: "jsdom",
7
+ transform: {
8
+ "^.+\\.js$": "babel-jest",
9
+ ".*\\.(vue)$": "@vue/vue2-jest",
10
+ },
11
+ };
@@ -2,8 +2,6 @@
2
2
 
3
3
  const path = require("path");
4
4
  const InlineRuntimePlugin = require("./inline-runtime-plugin");
5
- const RemoveLegacyAssetsPlugin = require("./remove-legacy-assets-plugin");
6
-
7
5
  // 环境变量与常量配置
8
6
  const ENV = {
9
7
  IS_PROD: ["production", "staging"].includes(process.env.NODE_ENV),
@@ -11,13 +9,6 @@ const ENV = {
11
9
  IS_DEV: process.env.ENV === "development"
12
10
  };
13
11
 
14
- // 强制禁用 modern mode(staging 环境)
15
- if (ENV.IS_STAGING) {
16
- process.env.VUE_CLI_MODERN_MODE = "false";
17
- process.env.VUE_CLI_MODERN_BUILD = "false";
18
- console.log("\n\x1b[36m⚡ Building for STAGING with Modern Bundle only (仅现代浏览器)...\x1b[0m");
19
- }
20
-
21
12
  /**
22
13
  * 解析项目路径(兼容monorepo)
23
14
  * @param {string} dir 相对路径
@@ -94,7 +85,7 @@ function configureWebpack(extraConfig = {}) {
94
85
  },
95
86
  fallback: createNodePolyfills(),
96
87
  // 优化模块解析
97
- extensions: [".js", ".vue", ".json", ".jsx"],
88
+ extensions: [".js", ".vue", ".json", ".jsx", ".ts", ".tsx"],
98
89
  modules: ["node_modules"]
99
90
  },
100
91
  target: ["web", "es5"],
@@ -151,76 +142,32 @@ function chainWebpack(config, options = {}) {
151
142
  });
152
143
  }
153
144
 
154
- // 强制禁用 modern mode(staging 环境)
155
- if (ENV.IS_STAGING) {
156
- // 删除 @vue/cli-service 的 modern mode 相关插件
157
- config.plugins.delete("modern-mode-plugin");
158
-
159
- // 强制修改 HTML 插件配置
160
- config.plugin("html").tap((args) => {
161
- args[0] = args[0] || {};
162
-
163
- // 彻底禁用 modern mode
164
- args[0].modern = false;
165
- args[0].modulePreload = false;
166
- args[0].scriptLoading = "defer";
167
-
168
- // 删除所有 modern/legacy 相关的钩子和回调
169
- delete args[0].modernBuild;
170
- delete args[0].legacyBuild;
171
- delete args[0].modernManifest;
172
- delete args[0].legacyManifest;
173
-
174
- // 关键:重写 templateParameters 来阻止 modern mode 注入
175
- const originalTemplateParameters = args[0].templateParameters || {};
176
- args[0].templateParameters = (compilation, assets, assetTags, options) => {
177
- const params =
178
- typeof originalTemplateParameters === "function"
179
- ? originalTemplateParameters(compilation, assets, assetTags, options)
180
- : originalTemplateParameters;
181
-
182
- // 移除 modern/legacy 相关的参数
183
- if (params) {
184
- delete params.modernBuild;
185
- delete params.legacyBuild;
186
- delete params.modernManifest;
187
- delete params.legacyManifest;
188
- }
189
-
190
- return params;
191
- };
192
-
193
- return args;
194
- });
195
-
196
- // 添加自定义插件来处理 legacy 文件问题
197
- config.plugin("remove-legacy-assets").use(RemoveLegacyAssetsPlugin);
198
-
199
- // Babel 配置:只转译现代浏览器
200
- config.module
201
- .rule("js")
202
- .use("babel-loader")
203
- .tap((options) => ({
204
- ...options,
205
- presets: [
206
- [
207
- "@babel/preset-env",
208
- {
209
- targets: {
210
- esmodules: true,
211
- chrome: "60",
212
- firefox: "60",
213
- safari: "11",
214
- edge: "79"
215
- },
216
- modules: false
217
- }
218
- ]
145
+ // Babel 配置:只转译现代浏览器 + TypeScript(支持 @infly/ts-libs)
146
+ config.module
147
+ .rule("js")
148
+ .test(/\.(js|ts)x?$/)
149
+ .use("babel-loader")
150
+ .tap((options) => ({
151
+ ...options,
152
+ presets: [
153
+ [
154
+ "@babel/preset-env",
155
+ {
156
+ targets: {
157
+ esmodules: true,
158
+ chrome: "60",
159
+ firefox: "60",
160
+ safari: "11",
161
+ edge: "79"
162
+ },
163
+ modules: false
164
+ }
219
165
  ],
220
- cacheDirectory: true,
221
- cacheCompression: false
222
- }));
223
- }
166
+ "@babel/preset-typescript"
167
+ ],
168
+ cacheDirectory: true,
169
+ cacheCompression: false
170
+ }));
224
171
 
225
172
  // 注册 runtime 内联插件
226
173
  config.plugin("inline-runtime").use(InlineRuntimePlugin);
package/bin/cli.js CHANGED
@@ -5,73 +5,73 @@ function loadBuildDist() {
5
5
  }
6
6
 
7
7
  function loadPreview() {
8
- return require("../tools/project-preview");
8
+ return require("../adapters/vue2/project-preview");
9
9
  }
10
10
 
11
- function parseArgs(argv) {
12
- const options = { env: "prod", local: false, dryRun: false };
13
- const valueOptions = {
14
- "--env": "env",
15
- "--cicd-url": "cicdUrl",
16
- "--project-dir": "projectDir",
17
- "--file": "file",
11
+ function parseArgs(argv) {
12
+ const options = { env: "prod", local: false, dryRun: false };
13
+ const valueOptions = {
14
+ "--env": "env",
15
+ "--cicd-url": "cicdUrl",
16
+ "--project-dir": "projectDir",
17
+ "--file": "file",
18
18
  "--bump": "bump",
19
19
  "--config": "config",
20
- "--target": "target",
21
- };
22
-
23
- let i = 0;
24
- while (i < argv.length) {
25
- const arg = argv[i];
26
- const equalsIndex = arg.indexOf("=");
27
- if (equalsIndex > 0) {
28
- const flag = arg.slice(0, equalsIndex);
29
- const key = valueOptions[flag];
30
- if (key) {
31
- const value = arg.slice(equalsIndex + 1);
32
- if (!value) throw new Error(`${flag} requires a value.`);
33
- options[key] = value;
34
- i++;
35
- continue;
36
- }
37
- }
38
-
39
- if (arg === "--local") {
40
- options.local = true;
41
- i++;
42
- continue;
43
- }
44
- if (arg === "--dry-run") {
45
- options.dryRun = true;
46
- i++;
47
- continue;
48
- }
49
- if (arg === "--push") {
50
- options.push = true;
51
- i++;
52
- continue;
53
- }
54
-
55
- const key = valueOptions[arg];
56
- if (key) {
57
- const value = argv[i + 1];
58
- if (!value || value.startsWith("--")) throw new Error(`${arg} requires a value.`);
59
- options[key] = value;
60
- i += 2;
61
- continue;
62
- }
63
-
64
- i++;
65
- }
66
- return options;
20
+ "--target": "target",
21
+ };
22
+
23
+ let i = 0;
24
+ while (i < argv.length) {
25
+ const arg = argv[i];
26
+ const equalsIndex = arg.indexOf("=");
27
+ if (equalsIndex > 0) {
28
+ const flag = arg.slice(0, equalsIndex);
29
+ const key = valueOptions[flag];
30
+ if (key) {
31
+ const value = arg.slice(equalsIndex + 1);
32
+ if (!value) throw new Error(`${flag} requires a value.`);
33
+ options[key] = value;
34
+ i++;
35
+ continue;
36
+ }
37
+ }
38
+
39
+ if (arg === "--local") {
40
+ options.local = true;
41
+ i++;
42
+ continue;
43
+ }
44
+ if (arg === "--dry-run") {
45
+ options.dryRun = true;
46
+ i++;
47
+ continue;
48
+ }
49
+ if (arg === "--push") {
50
+ options.push = true;
51
+ i++;
52
+ continue;
53
+ }
54
+
55
+ const key = valueOptions[arg];
56
+ if (key) {
57
+ const value = argv[i + 1];
58
+ if (!value || value.startsWith("--")) throw new Error(`${arg} requires a value.`);
59
+ options[key] = value;
60
+ i += 2;
61
+ continue;
62
+ }
63
+
64
+ i++;
65
+ }
66
+ return options;
67
+ }
68
+ function parseProjectArgs(argv) {
69
+ const options = parseArgs(argv);
70
+ const hasExplicitEnv = argv.some((arg) => arg === "--env" || arg.startsWith("--env="));
71
+ delete options.local;
72
+ if (!hasExplicitEnv) delete options.env;
73
+ return options;
67
74
  }
68
- function parseProjectArgs(argv) {
69
- const options = parseArgs(argv);
70
- const hasExplicitEnv = argv.some((arg) => arg === "--env" || arg.startsWith("--env="));
71
- delete options.local;
72
- if (!hasExplicitEnv) delete options.env;
73
- return options;
74
- }
75
75
  async function main(argv = process.argv.slice(2)) {
76
76
  const command = argv[0];
77
77
  const commandMap = {
@@ -89,15 +89,15 @@ async function main(argv = process.argv.slice(2)) {
89
89
  "build:docker": () => {
90
90
  const opts = parseArgs(argv.slice(1));
91
91
  return require("../build/docker/docker-build-push").dockerBuildPush(opts);
92
- },
93
- "docker:compose": () => {
94
- const opts = parseArgs(argv.slice(1));
95
- return require("../build/docker/compose-command").runComposeCommand(opts);
96
- },
97
- project: () => {
98
- const action = argv[1] && !argv[1].startsWith("--") ? argv[1] : undefined;
99
- const opts = parseProjectArgs(argv.slice(action ? 2 : 1));
100
- return require("../tools/project-command").runProjectCommand({ ...opts, action });
92
+ },
93
+ "docker:compose": () => {
94
+ const opts = parseArgs(argv.slice(1));
95
+ return require("../build/docker/compose-command").runComposeCommand(opts);
96
+ },
97
+ project: () => {
98
+ const action = argv[1] && !argv[1].startsWith("--") ? argv[1] : undefined;
99
+ const opts = parseProjectArgs(argv.slice(action ? 2 : 1));
100
+ return require("../tools/project-command").runProjectCommand({ ...opts, action });
101
101
  },
102
102
  };
103
103