@qse/edu-scripts 0.0.0-beta.0

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 (81) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +107 -0
  3. package/app.d.ts +73 -0
  4. package/babel.config.json +3 -0
  5. package/docs/.vitepress/config.ts +35 -0
  6. package/docs/changelog.md +1 -0
  7. package/docs/debug.md +17 -0
  8. package/docs/deploy.md +54 -0
  9. package/docs/faq.md +144 -0
  10. package/docs/feat.md +167 -0
  11. package/docs/grayscale.md +31 -0
  12. package/docs/index.md +15 -0
  13. package/docs/install.md +1 -0
  14. package/docs/mode.md +42 -0
  15. package/docs/override.md +193 -0
  16. package/docs/refactor-react-16.md +37 -0
  17. package/docs/refactor.md +67 -0
  18. package/docs/static.md +24 -0
  19. package/es/asset/dll/libcommon3-manifest.json +181 -0
  20. package/es/asset/template/edu-app-env.d.ts.tpl +20 -0
  21. package/es/asset/template/edu-scripts.override.js.tpl +7 -0
  22. package/es/asset/template/tailwind.config.js.tpl +11 -0
  23. package/es/asset/template/tsconfig.json.tpl +24 -0
  24. package/es/auto-refactor.js +153 -0
  25. package/es/build.js +58 -0
  26. package/es/cli.js +65 -0
  27. package/es/commit-dist.js +83 -0
  28. package/es/config/paths.js +39 -0
  29. package/es/config/plugins/mock-server/defineMock.d.ts +6 -0
  30. package/es/config/plugins/mock-server/defineMock.js +7 -0
  31. package/es/config/plugins/mock-server/index.js +122 -0
  32. package/es/config/plugins/postcss-safe-area.js +22 -0
  33. package/es/config/plugins/ws-utils-createSocketURL.js +98 -0
  34. package/es/config/webpackConfig.js +418 -0
  35. package/es/config/webpackDevServerConfig.js +73 -0
  36. package/es/deploy.js +148 -0
  37. package/es/generator.js +52 -0
  38. package/es/index.d.ts +2 -0
  39. package/es/index.js +7 -0
  40. package/es/start.js +36 -0
  41. package/es/utils/FileSizeReporter.js +107 -0
  42. package/es/utils/appConfig.js +35 -0
  43. package/es/utils/beforeStart.js +51 -0
  44. package/es/utils/changeDeployVersion.js +85 -0
  45. package/es/utils/defineConfig.d.ts +76 -0
  46. package/es/utils/defineConfig.js +7 -0
  47. package/es/utils/exec.js +10 -0
  48. package/es/utils/getConfig.js +23 -0
  49. package/es/utils/getOverride.js +28 -0
  50. package/eslint.config.mjs +3 -0
  51. package/jest.config.mjs +199 -0
  52. package/package.json +95 -0
  53. package/src/asset/dll/libcommon3-manifest.json +181 -0
  54. package/src/asset/template/edu-app-env.d.ts.tpl +20 -0
  55. package/src/asset/template/edu-scripts.override.js.tpl +7 -0
  56. package/src/asset/template/tailwind.config.js.tpl +11 -0
  57. package/src/asset/template/tsconfig.json.tpl +24 -0
  58. package/src/auto-refactor.js +170 -0
  59. package/src/build.js +64 -0
  60. package/src/cli.js +88 -0
  61. package/src/commit-dist.js +103 -0
  62. package/src/config/paths.js +38 -0
  63. package/src/config/plugins/mock-server/defineMock.ts +12 -0
  64. package/src/config/plugins/mock-server/index.js +150 -0
  65. package/src/config/plugins/postcss-safe-area.js +21 -0
  66. package/src/config/plugins/ws-utils-createSocketURL.js +140 -0
  67. package/src/config/webpackConfig.js +444 -0
  68. package/src/config/webpackDevServerConfig.js +83 -0
  69. package/src/deploy.js +182 -0
  70. package/src/generator.js +67 -0
  71. package/src/index.ts +2 -0
  72. package/src/start.js +37 -0
  73. package/src/utils/FileSizeReporter.js +148 -0
  74. package/src/utils/appConfig.js +36 -0
  75. package/src/utils/beforeStart.js +55 -0
  76. package/src/utils/changeDeployVersion.js +119 -0
  77. package/src/utils/defineConfig.ts +81 -0
  78. package/src/utils/exec.js +7 -0
  79. package/src/utils/getConfig.js +26 -0
  80. package/src/utils/getOverride.js +33 -0
  81. package/tsconfig.json +21 -0
package/es/index.js ADDED
@@ -0,0 +1,7 @@
1
+ // src/index.ts
2
+ import { defineConfig } from "./utils/defineConfig.js";
3
+ import { defineMock } from "./config/plugins/mock-server/defineMock.js";
4
+ export {
5
+ defineConfig,
6
+ defineMock
7
+ };
package/es/start.js ADDED
@@ -0,0 +1,36 @@
1
+ // src/start.js
2
+ import { rspack } from "@rspack/core";
3
+ import { RspackDevServer } from "@rspack/dev-server";
4
+ import getConfig from "./utils/getConfig.js";
5
+ import chalk from "chalk";
6
+ async function start(args) {
7
+ process.env.NODE_ENV = "development";
8
+ process.env.BABEL_ENV = "development";
9
+ process.env.BROWSERSLIST = "chrome >= 70";
10
+ process.env.WEBPACK_DEV_SERVER_BASE_PORT = "3000";
11
+ const basePort = process.env.WEBPACK_DEV_SERVER_BASE_PORT;
12
+ const port = await RspackDevServer.getFreePort(args.port || process.env.PORT);
13
+ if (!(args.port || process.env.PORT) && +port !== +basePort) {
14
+ console.log(chalk.bgYellow(`${basePort} 端口已被占用,现切换到 ${port} 端口运行`));
15
+ }
16
+ args.port = port;
17
+ process.env.PORT = port;
18
+ const compiler = rspack(getConfig(args));
19
+ const devServer = new RspackDevServer(compiler.options.devServer, compiler);
20
+ devServer.start();
21
+ [("SIGINT", "SIGTERM")].forEach(function(sig) {
22
+ process.on(sig, function() {
23
+ devServer.stop();
24
+ process.exit();
25
+ });
26
+ });
27
+ if (process.env.CI !== "true") {
28
+ process.stdin.on("end", function() {
29
+ devServer.stop();
30
+ process.exit();
31
+ });
32
+ }
33
+ }
34
+ export {
35
+ start as default
36
+ };
@@ -0,0 +1,107 @@
1
+ // src/utils/FileSizeReporter.js
2
+ import fs from "fs";
3
+ import path from "path";
4
+ import chalk from "chalk";
5
+ import filesize from "filesize";
6
+ import recursive from "recursive-readdir";
7
+ import stripAnsi from "strip-ansi";
8
+ import { gzipSizeSync } from "gzip-size";
9
+ function canReadAsset(asset) {
10
+ return /\.(js|css)$/.test(asset) && !/service-worker\.js/.test(asset) && !/precache-manifest\.[0-9a-f]+\.js/.test(asset);
11
+ }
12
+ function printFileSizesAfterBuild(webpackStats, previousSizeMap, buildFolder, maxBundleGzipSize, maxChunkGzipSize) {
13
+ var root = previousSizeMap.root;
14
+ var sizes = previousSizeMap.sizes;
15
+ var assets = (webpackStats.stats || [webpackStats]).map(
16
+ (stats) => stats.toJson({ all: false, assets: true }).assets.filter((asset) => canReadAsset(asset.name)).map((asset) => {
17
+ var fileContents = fs.readFileSync(path.join(root, asset.name));
18
+ var size = gzipSizeSync(fileContents);
19
+ var previousSize = sizes[removeFileNameHash(root, asset.name)];
20
+ var difference = getDifferenceLabel(size, previousSize);
21
+ return {
22
+ folder: path.join(path.basename(buildFolder), path.dirname(asset.name)),
23
+ name: path.basename(asset.name),
24
+ size,
25
+ sizeLabel: filesize(size) + (difference ? " (" + difference + ")" : "")
26
+ };
27
+ })
28
+ ).reduce((single, all) => all.concat(single), []);
29
+ if (assets.length === 0)
30
+ return;
31
+ console.log("\ngzip 后文件大小:\n");
32
+ assets.sort((a, b) => b.size - a.size);
33
+ var mainAssetIdx = assets.findIndex((asset) => /_\d+\.\d+\.\d+\./.test(asset.name));
34
+ assets.unshift(assets.splice(mainAssetIdx, 1)[0]);
35
+ var longestSizeLabelLength = Math.max.apply(
36
+ null,
37
+ assets.map((a) => stripAnsi(a.sizeLabel).length)
38
+ );
39
+ var suggestBundleSplitting = false;
40
+ assets.forEach((asset) => {
41
+ var sizeLabel = asset.sizeLabel;
42
+ var sizeLength = stripAnsi(sizeLabel).length;
43
+ if (sizeLength < longestSizeLabelLength) {
44
+ var rightPadding = " ".repeat(longestSizeLabelLength - sizeLength);
45
+ sizeLabel += rightPadding;
46
+ }
47
+ var isMainBundle = /_\d+\.\d+\.\d+\./.test(asset.name);
48
+ var maxRecommendedSize = isMainBundle ? maxBundleGzipSize : maxChunkGzipSize;
49
+ var isLarge = maxRecommendedSize && asset.size > maxRecommendedSize;
50
+ if (isLarge && path.extname(asset.name) === ".js") {
51
+ suggestBundleSplitting = true;
52
+ }
53
+ console.log(
54
+ " " + (isLarge ? chalk.yellow(sizeLabel) : sizeLabel) + " " + chalk.dim(asset.folder + path.sep) + chalk.cyan(asset.name)
55
+ );
56
+ if (isMainBundle) {
57
+ console.log("");
58
+ }
59
+ });
60
+ if (suggestBundleSplitting) {
61
+ console.log();
62
+ console.log(chalk.yellow("产物大小明显大于推荐的大小 (主文件 30k, chunk 1M, 黄色标注为偏大)"));
63
+ console.log(chalk.yellow("考虑下使用代码分割解决"));
64
+ console.log(chalk.yellow("也可以使用 npm run analyze 命令分析产物"));
65
+ }
66
+ console.log();
67
+ }
68
+ function removeFileNameHash(buildFolder, fileName) {
69
+ return fileName.replace(buildFolder, "").replace(/\\/g, "/").replace(/\/\d+\.\d+\.\d+\//, "/").replace(/\/?(.*)(\.[0-9a-f]+)(\.chunk)?(\.js|\.css)/, (match, p1, p2, p3, p4) => p1 + p4);
70
+ }
71
+ function getDifferenceLabel(currentSize, previousSize) {
72
+ var FIFTY_KILOBYTES = 1024 * 50;
73
+ var difference = currentSize - previousSize;
74
+ var fileSize = !Number.isNaN(difference) ? filesize(difference) : 0;
75
+ if (difference >= FIFTY_KILOBYTES) {
76
+ return chalk.red("+" + fileSize);
77
+ } else if (difference < FIFTY_KILOBYTES && difference > 0) {
78
+ return chalk.yellow("+" + fileSize);
79
+ } else if (difference < 0) {
80
+ return chalk.green(fileSize);
81
+ } else {
82
+ return "";
83
+ }
84
+ }
85
+ function measureFileSizesBeforeBuild(buildFolder) {
86
+ return new Promise((resolve) => {
87
+ recursive(buildFolder, (err, fileNames) => {
88
+ var sizes;
89
+ if (!err && fileNames) {
90
+ sizes = fileNames.filter(canReadAsset).reduce((memo, fileName) => {
91
+ var contents = fs.readFileSync(fileName);
92
+ var key = removeFileNameHash(buildFolder, fileName);
93
+ memo[key] = gzipSizeSync(contents);
94
+ return memo;
95
+ }, {});
96
+ }
97
+ resolve({
98
+ root: buildFolder,
99
+ sizes: sizes || {}
100
+ });
101
+ });
102
+ });
103
+ }
104
+ export {
105
+ measureFileSizesBeforeBuild,
106
+ printFileSizesAfterBuild
107
+ };
@@ -0,0 +1,35 @@
1
+ // src/utils/appConfig.js
2
+ import paths from "../config/paths.js";
3
+ import fs from "fs-extra";
4
+ var appPkg = fs.readJsonSync(paths.package);
5
+ var edu = appPkg.edu || {};
6
+ if (edu.single || edu.mainProject) {
7
+ if (edu.single) {
8
+ edu.mode = "single";
9
+ delete edu.single;
10
+ }
11
+ if (edu.mainProject) {
12
+ edu.mode = "main";
13
+ delete edu.mainProject;
14
+ }
15
+ fs.writeFileSync(paths.package, JSON.stringify(appPkg, null, 2), "utf-8");
16
+ }
17
+ var appConfig = {
18
+ /** @type {'main'|'single'} */
19
+ get mode() {
20
+ return edu.mode;
21
+ },
22
+ get mainProject() {
23
+ return this.mode === "main";
24
+ },
25
+ get single() {
26
+ return this.mode === "single";
27
+ },
28
+ get grayscale() {
29
+ return !!edu.grayscale;
30
+ }
31
+ };
32
+ var appConfig_default = appConfig;
33
+ export {
34
+ appConfig_default as default
35
+ };
@@ -0,0 +1,51 @@
1
+ // src/utils/beforeStart.js
2
+ import fs from "fs-extra";
3
+ import paths from "../config/paths.js";
4
+ import chalk from "chalk";
5
+ import semver from "semver";
6
+ import appConfig from "./appConfig.js";
7
+ import { fileURLToPath } from "node:url";
8
+ var pkg = fs.readJsonSync(fileURLToPath(import.meta.resolve("../../package.json")));
9
+ var appPkg = fs.readJsonSync(paths.package);
10
+ if (semver.valid(appPkg.version) === null) {
11
+ console.log(
12
+ chalk.red(`package.version 不符合 semver 规范 https://docs.npmjs.com/about-semantic-versioning`)
13
+ );
14
+ process.exit(1);
15
+ }
16
+ switch (appConfig.mode) {
17
+ case "main":
18
+ console.log(chalk.bgMagenta("正在使用教育主工程模式"));
19
+ break;
20
+ case "single":
21
+ console.log(chalk.bgMagenta("正在使用独立项目模式"));
22
+ break;
23
+ default:
24
+ console.log(chalk.bgMagenta("正在使用教育集成模式"));
25
+ break;
26
+ }
27
+ if (appConfig.grayscale) {
28
+ console.log(chalk.bgYellow("正在使用灰度测试模式"));
29
+ }
30
+ if (!(appConfig.single || appConfig.mainProject)) {
31
+ if (fs.existsSync(paths.static)) {
32
+ console.log(chalk.bgYellow("教育集成工程不能含有 public/static, 现已自动删除"));
33
+ try {
34
+ fs.rmSync(paths.static, { recursive: true });
35
+ } catch (e) {
36
+ }
37
+ }
38
+ }
39
+ if (!fs.existsSync(paths.public) && !process.argv.includes("auto-refactor")) {
40
+ console.log(chalk.red(`public 文件夹不存在,请先按文档改造项目`));
41
+ console.log(`文档: ${chalk.underline(pkg.homepage)}`);
42
+ console.log(`
43
+ 使用 ${chalk.green("npx edu-scripts auto-refactor")} 自动改造
44
+ `);
45
+ process.exit(0);
46
+ }
47
+ if (appPkg.browserslist) {
48
+ console.log(chalk.yellow("已删除 package.json 中 browserslist,该值由内部自动控制\n"));
49
+ delete appPkg.browserslist;
50
+ fs.writeFileSync(paths.package, JSON.stringify(appPkg, null, 2), "utf-8");
51
+ }
@@ -0,0 +1,85 @@
1
+ // src/utils/changeDeployVersion.js
2
+ import { parse, traverse, types as t, transformFromAstSync } from "@babel/core";
3
+ var TARGET_IDENTIFIER_NAME = "project_apiArr";
4
+ var MODULE_IDENTIFIER_NAME = "module";
5
+ function changeDeployVersion(code, pkg) {
6
+ const { name, version, grayscale } = pkg;
7
+ let ast;
8
+ try {
9
+ ast = parse(code);
10
+ } catch (error) {
11
+ throw new Error(`代码解析错误: ${error.message}`);
12
+ }
13
+ const keyName = grayscale ? "grayscale" : "main";
14
+ function findTargetDeclarator(ast2) {
15
+ let res;
16
+ traverse(ast2, {
17
+ VariableDeclarator(path) {
18
+ if (t.isIdentifier(path.node.id, { name: TARGET_IDENTIFIER_NAME }) && t.isArrayExpression(path.node.init)) {
19
+ res = path;
20
+ }
21
+ }
22
+ });
23
+ return res;
24
+ }
25
+ function findModuleObject(path) {
26
+ let res;
27
+ path.traverse({
28
+ ObjectExpression(path2) {
29
+ if (path2.node.properties.some(
30
+ (node) => t.isIdentifier(node.key, { name: MODULE_IDENTIFIER_NAME }) && t.isLiteral(node.value, { value: name })
31
+ )) {
32
+ res = path2;
33
+ }
34
+ }
35
+ });
36
+ return res;
37
+ }
38
+ function modifyModuleVersion(path) {
39
+ let hasModify = false;
40
+ path.traverse({
41
+ Property(path2) {
42
+ if (path2.node.key.name === keyName) {
43
+ path2.node.value.value = version;
44
+ hasModify = true;
45
+ }
46
+ }
47
+ });
48
+ if (!hasModify) {
49
+ path.node.properties.push(t.objectProperty(t.identifier(keyName), t.stringLiteral(version)));
50
+ }
51
+ }
52
+ function deleteModuleComments(path) {
53
+ path.traverse({
54
+ ObjectExpression(path2) {
55
+ delete path2.node.leadingComments;
56
+ }
57
+ });
58
+ }
59
+ function addModuleToTarget(path) {
60
+ const elements = path.node.init.elements;
61
+ elements.splice(
62
+ elements.length - 2,
63
+ 0,
64
+ t.objectExpression([
65
+ t.objectProperty(t.identifier(MODULE_IDENTIFIER_NAME), t.stringLiteral(name)),
66
+ t.objectProperty(t.identifier(keyName), t.stringLiteral(version))
67
+ ])
68
+ );
69
+ }
70
+ const targetPath = findTargetDeclarator(ast);
71
+ if (!targetPath)
72
+ throw new Error(`ver.js 不合规范,未找到参数 ${TARGET_IDENTIFIER_NAME}`);
73
+ const moduleObjPath = findModuleObject(targetPath);
74
+ if (moduleObjPath) {
75
+ modifyModuleVersion(moduleObjPath);
76
+ } else {
77
+ addModuleToTarget(targetPath);
78
+ }
79
+ deleteModuleComments(targetPath);
80
+ return transformFromAstSync(ast, void 0, { minified: true }).code;
81
+ }
82
+ var changeDeployVersion_default = changeDeployVersion;
83
+ export {
84
+ changeDeployVersion_default as default
85
+ };
@@ -0,0 +1,76 @@
1
+ import type { Chalk } from 'chalk';
2
+ import type { Compiler, Configuration } from '@rspack/core';
3
+ import type { Configuration as DevServerConfiguration } from '@rspack/dev-server';
4
+ type ProxyConfigArray = NonNullable<DevServerConfiguration['proxy']>;
5
+ export type BabelImportPlugin = {
6
+ libraryName: string;
7
+ libraryDirectory: string;
8
+ camel2DashComponentName?: boolean;
9
+ style?: boolean | 'css' | ((name: string) => string);
10
+ };
11
+ export type Config = {
12
+ webpack?: (config: Configuration) => Configuration | undefined;
13
+ devServer?: (config: DevServerConfiguration) => DevServerConfiguration | undefined;
14
+ /**
15
+ * webpack alias 配置,会与内置 alias 合并
16
+ *
17
+ * @default
18
+ * { '@': './src' }
19
+ */
20
+ alias?: Record<string, string>;
21
+ /**
22
+ * webpack externals 配置,会与内置 externals 合并
23
+ */
24
+ externals?: Record<string, string>;
25
+ /**
26
+ * terser pure_funcs,esbuild pure 配置,传 [] 可以不清空 console.log
27
+ * @default ['console.log']
28
+ */
29
+ pure_funcs?: string[];
30
+ /**
31
+ * 是否压缩代码
32
+ * @default true
33
+ */
34
+ minify?: boolean;
35
+ /** 自定义全局参数 */
36
+ define?: Record<string, any>;
37
+ /**
38
+ * context 填写的顺序很重要,前面的会优先匹配。可以重复定义 /api 来覆盖默认的配置
39
+ *
40
+ * proxy 会自动删除请求头 referer,避免某些后端校验失败的问题
41
+ * @see https://webpack.js.org/configuration/dev-server/#devserverproxy
42
+ * @default /api -> /qsxxwapdev/api
43
+ * @example { '/api': 'http://localhost:3000' }
44
+ * @example [{ context: ['/api'], target: 'http://localhost:3000' }]
45
+ */
46
+ proxy?: ProxyConfigArray | Record<string, string>;
47
+ extraPostCSSPlugins?: any[];
48
+ /**
49
+ * 开启 mock 功能,会自动加载 mock 文件夹下的文件
50
+ *
51
+ * 默认情况下自动判断根目录是否存在 mock 文件夹,如果存在则开启 mock 功能。
52
+ * 如果设置 false,会关闭 mock 功能
53
+ */
54
+ mock?: boolean;
55
+ /**
56
+ * 开发模式启动后只执行一次的函数,用来展示启动后的提示信息,或者自定义的逻辑
57
+ */
58
+ startup?: (params: {
59
+ /** 控制台输出内容 */
60
+ logger: ReturnType<Compiler['getInfrastructureLogger']>;
61
+ /** 字体颜色相关工具 */
62
+ chalk: Chalk;
63
+ /** webpack compiler 自定义的时候会用到 */
64
+ compiler: Compiler;
65
+ }) => void;
66
+ /**
67
+ * 是否开启装饰器语法支持 只支持 legacy 版本
68
+ * @see https://babeljs.io/docs/en/babel-plugin-proposal-decorators
69
+ * @default false
70
+ */
71
+ decorators?: boolean;
72
+ /** babel-plugin-import */
73
+ import?: BabelImportPlugin[];
74
+ };
75
+ export declare function defineConfig(config: Config): Config;
76
+ export {};
@@ -0,0 +1,7 @@
1
+ // src/utils/defineConfig.ts
2
+ function defineConfig(config) {
3
+ return config;
4
+ }
5
+ export {
6
+ defineConfig
7
+ };
@@ -0,0 +1,10 @@
1
+ // src/utils/exec.js
2
+ import cp from "child_process";
3
+ var exec = (cmd) => {
4
+ console.log(`> ${cmd}`);
5
+ return cp.execSync(cmd, { stdio: "inherit", encoding: "utf-8" });
6
+ };
7
+ var exec_default = exec;
8
+ export {
9
+ exec_default as default
10
+ };
@@ -0,0 +1,23 @@
1
+ // src/utils/getConfig.js
2
+ import getWebpackConfig from "../config/webpackConfig.js";
3
+ import getWebpackDevServerConfig from "../config/webpackDevServerConfig.js";
4
+ import getOverride from "./getOverride.js";
5
+ function getConfig(args) {
6
+ const override = getOverride();
7
+ let webpackConfig = getWebpackConfig(args, override);
8
+ if (override.webpack) {
9
+ webpackConfig = override.webpack(webpackConfig) || webpackConfig;
10
+ }
11
+ if (process.env.NODE_ENV === "development") {
12
+ let devServerConfig = getWebpackDevServerConfig(args, override);
13
+ if (override.devServer) {
14
+ devServerConfig = override.devServer(devServerConfig) || devServerConfig;
15
+ }
16
+ webpackConfig.devServer = devServerConfig;
17
+ }
18
+ return webpackConfig;
19
+ }
20
+ var getConfig_default = getConfig;
21
+ export {
22
+ getConfig_default as default
23
+ };
@@ -0,0 +1,28 @@
1
+ // src/utils/getOverride.js
2
+ import fs from "fs-extra";
3
+ import paths from "../config/paths.js";
4
+ import { createRequire } from "node:module";
5
+ var require2 = createRequire(import.meta.url);
6
+ var defaultOverride = {
7
+ minify: true,
8
+ proxy: [],
9
+ extraPostCSSPlugins: [],
10
+ import: [],
11
+ pure_funcs: ["console.log"]
12
+ };
13
+ var override = null;
14
+ function getOverride() {
15
+ if (override)
16
+ return override;
17
+ override = Object.assign({}, defaultOverride);
18
+ if (fs.existsSync(paths.override)) {
19
+ const userOverride = require2(paths.override);
20
+ if (typeof userOverride !== "object")
21
+ throw new Error("格式错误,请使用 npx edu g override 生成文件");
22
+ Object.assign(override, userOverride);
23
+ }
24
+ return override;
25
+ }
26
+ export {
27
+ getOverride as default
28
+ };
@@ -0,0 +1,3 @@
1
+ import config from 'eslint-config-qsb-react'
2
+
3
+ export default config
@@ -0,0 +1,199 @@
1
+ /*
2
+ * For a detailed explanation regarding each configuration property, visit:
3
+ * https://jestjs.io/docs/configuration
4
+ */
5
+
6
+ export default {
7
+ // All imported modules in your tests should be mocked automatically
8
+ // automock: false,
9
+
10
+ // Stop running tests after `n` failures
11
+ // bail: 0,
12
+
13
+ // The directory where Jest should store its cached dependency information
14
+ // cacheDirectory: "/private/var/folders/71/g8xbd8f97pzcxd6csv8wxw6h0000gn/T/jest_dx",
15
+
16
+ // Automatically clear mock calls, instances, contexts and results before every test
17
+ clearMocks: true,
18
+
19
+ // Enable ESM support for Node.js test environment
20
+ extensionsToTreatAsEsm: ['.ts'],
21
+ testEnvironment: 'node',
22
+
23
+ // Indicates whether the coverage information should be collected while executing the test
24
+ // collectCoverage: false,
25
+
26
+ // An array of glob patterns indicating a set of files for which coverage information should be collected
27
+ // collectCoverageFrom: undefined,
28
+
29
+ // The directory where Jest should output its coverage files
30
+ // coverageDirectory: undefined,
31
+
32
+ // An array of regexp pattern strings used to skip coverage collection
33
+ // coveragePathIgnorePatterns: [
34
+ // "/node_modules/"
35
+ // ],
36
+
37
+ // Indicates which provider should be used to instrument code for coverage
38
+ // coverageProvider: "babel",
39
+
40
+ // A list of reporter names that Jest uses when writing coverage reports
41
+ // coverageReporters: [
42
+ // "json",
43
+ // "text",
44
+ // "lcov",
45
+ // "clover"
46
+ // ],
47
+
48
+ // An object that configures minimum threshold enforcement for coverage results
49
+ // coverageThreshold: undefined,
50
+
51
+ // A path to a custom dependency extractor
52
+ // dependencyExtractor: undefined,
53
+
54
+ // Make calling deprecated APIs throw helpful error messages
55
+ // errorOnDeprecated: false,
56
+
57
+ // The default configuration for fake timers
58
+ // fakeTimers: {
59
+ // "enableGlobally": false
60
+ // },
61
+
62
+ // Force coverage collection from ignored files using an array of glob patterns
63
+ // forceCoverageMatch: [],
64
+
65
+ // A path to a module which exports an async function that is triggered once before all test suites
66
+ // globalSetup: undefined,
67
+
68
+ // A path to a module which exports an async function that is triggered once after all test suites
69
+ // globalTeardown: undefined,
70
+
71
+ // A set of global variables that need to be available in all test environments
72
+ // globals: {},
73
+
74
+ // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
75
+ // maxWorkers: "50%",
76
+
77
+ // An array of directory names to be searched recursively up from the requiring module's location
78
+ // moduleDirectories: [
79
+ // "node_modules"
80
+ // ],
81
+
82
+ // An array of file extensions your modules use
83
+ // moduleFileExtensions: [
84
+ // "js",
85
+ // "mjs",
86
+ // "cjs",
87
+ // "jsx",
88
+ // "ts",
89
+ // "tsx",
90
+ // "json",
91
+ // "node"
92
+ // ],
93
+
94
+ // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
95
+ // moduleNameMapper: {},
96
+
97
+ // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
98
+ // modulePathIgnorePatterns: [],
99
+
100
+ // Activates notifications for test results
101
+ // notify: false,
102
+
103
+ // An enum that specifies notification mode. Requires { notify: true }
104
+ // notifyMode: "failure-change",
105
+
106
+ // A preset that is used as a base for Jest's configuration
107
+ // preset: undefined,
108
+
109
+ // Run tests from one or more projects
110
+ // projects: undefined,
111
+
112
+ // Use this configuration option to add custom reporters to Jest
113
+ // reporters: undefined,
114
+
115
+ // Automatically reset mock state before every test
116
+ // resetMocks: false,
117
+
118
+ // Reset the module registry before running each individual test
119
+ // resetModules: false,
120
+
121
+ // A path to a custom resolver
122
+ // resolver: undefined,
123
+
124
+ // Automatically restore mock state and implementation before every test
125
+ // restoreMocks: false,
126
+
127
+ // The root directory that Jest should scan for tests and modules within
128
+ // rootDir: undefined,
129
+
130
+ // A list of paths to directories that Jest should use to search for files in
131
+ // roots: [
132
+ // "<rootDir>"
133
+ // ],
134
+
135
+ // Allows you to use a custom runner instead of Jest's default test runner
136
+ // runner: "jest-runner",
137
+
138
+ // The paths to modules that run some code to configure or set up the testing environment before each test
139
+ // setupFiles: [],
140
+
141
+ // A list of paths to modules that run some code to configure or set up the testing framework before each test
142
+ // setupFilesAfterEnv: [],
143
+
144
+ // The number of seconds after which a test is considered as slow and reported as such in the results.
145
+ // slowTestThreshold: 5,
146
+
147
+ // A list of paths to snapshot serializer modules Jest should use for snapshot testing
148
+ // snapshotSerializers: [],
149
+
150
+ // The test environment that will be used for testing
151
+ // testEnvironment: "jest-environment-node",
152
+
153
+ // Options that will be passed to the testEnvironment
154
+ // testEnvironmentOptions: {},
155
+
156
+ // Adds a location field to test results
157
+ // testLocationInResults: false,
158
+
159
+ // The glob patterns Jest uses to detect test files
160
+ // testMatch: [
161
+ // "**/__tests__/**/*.[jt]s?(x)",
162
+ // "**/?(*.)+(spec|test).[tj]s?(x)"
163
+ // ],
164
+
165
+ // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
166
+ // testPathIgnorePatterns: [
167
+ // "/node_modules/"
168
+ // ],
169
+
170
+ // The regexp pattern or array of patterns that Jest uses to detect test files
171
+ // testRegex: [],
172
+
173
+ // This option allows the use of a custom results processor
174
+ // testResultsProcessor: undefined,
175
+
176
+ // This option allows use of a custom test runner
177
+ // testRunner: "jest-circus/runner",
178
+
179
+ // A map from regular expressions to paths to transformers
180
+ // transform: undefined
181
+
182
+ // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
183
+ // transformIgnorePatterns: [
184
+ // "/node_modules/",
185
+ // "\\.pnp\\.[^\\/]+$"
186
+ // ],
187
+
188
+ // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
189
+ // unmockedModulePathPatterns: undefined,
190
+
191
+ // Indicates whether each individual test should be reported during the run
192
+ // verbose: undefined,
193
+
194
+ // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
195
+ // watchPathIgnorePatterns: [],
196
+
197
+ // Whether to use watchman for file crawling
198
+ // watchman: true,
199
+ }