@infly/libs 2.2.0 → 2.2.1
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/adapters/webpack/auto-export.js +52 -52
- package/build/build-utils/command.js +57 -57
- package/build/build-utils/git.js +254 -254
- package/build/build-utils/preview.js +78 -78
- package/build/build-utils/webhook-single.js +136 -136
- package/build/docker/compose-release.js +79 -79
- package/build/docker/docker-build-push.js +8 -2
- package/build/docker/target-release.js +2 -1
- package/build/project-files.js +47 -47
- package/core/async/concurrency.js +29 -29
- package/package.json +1 -1
- package/script/git-automation/index.js +703 -703
- package/script/git-automation/submodule-utils.js +16 -16
- package/workspace/config.js +144 -144
|
@@ -1,56 +1,56 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Webpack require.context 适配器。
|
|
3
|
-
* 自动导出目录下所有文件
|
|
4
|
-
* @param {Function} requireContext - require.context 返回的函数
|
|
5
|
-
* @returns {Object} 导出对象,key 为文件名(不含扩展名),value 为模块内容
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* // 在 components/Dialog/index.js 中使用
|
|
3
|
+
* 自动导出目录下所有文件
|
|
4
|
+
* @param {Function} requireContext - require.context 返回的函数
|
|
5
|
+
* @returns {Object} 导出对象,key 为文件名(不含扩展名),value 为模块内容
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // 在 components/Dialog/index.js 中使用
|
|
9
9
|
* import { autoExportFiles } from '@infly/libs/adapters/webpack/auto-export';
|
|
10
|
-
* const components = autoExportFiles(require.context('./', false, /\.vue$/));
|
|
11
|
-
* Object.keys(components).forEach(name => {
|
|
12
|
-
* module.exports[name] = components[name];
|
|
13
|
-
* });
|
|
14
|
-
*
|
|
15
|
-
* // 或者直接一行
|
|
16
|
-
* Object.assign(module.exports, autoExportFiles(require.context('./', false, /\.vue$/)));
|
|
17
|
-
*/
|
|
18
|
-
function autoExportFiles(requireContext) {
|
|
19
|
-
if (!requireContext || typeof requireContext !== 'function') {
|
|
20
|
-
console.error('autoExportFiles: requireContext 必须是 require.context 返回的函数');
|
|
21
|
-
return {};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const exports = {};
|
|
25
|
-
|
|
26
|
-
requireContext.keys().forEach(fileName => {
|
|
27
|
-
// 跳过 index 文件自身
|
|
28
|
-
if (fileName.includes('index')) return;
|
|
29
|
-
|
|
30
|
-
const componentConfig = requireContext(fileName);
|
|
31
|
-
const componentName = fileName
|
|
32
|
-
.replace(/^\.\//, '') // 移除 './'
|
|
33
|
-
.replace(/\.\w+$/, ''); // 移除扩展名
|
|
34
|
-
|
|
35
|
-
exports[componentName] = componentConfig.default || componentConfig;
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
return exports;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* 简化版:直接挂载到 module.exports
|
|
43
|
-
* @param {Function} requireContext - require.context 返回的函数
|
|
44
|
-
* @param {Object} targetExports - 目标导出对象(通常是 module.exports)
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* // 在 components/Dialog/index.js 中使用
|
|
10
|
+
* const components = autoExportFiles(require.context('./', false, /\.vue$/));
|
|
11
|
+
* Object.keys(components).forEach(name => {
|
|
12
|
+
* module.exports[name] = components[name];
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* // 或者直接一行
|
|
16
|
+
* Object.assign(module.exports, autoExportFiles(require.context('./', false, /\.vue$/)));
|
|
17
|
+
*/
|
|
18
|
+
function autoExportFiles(requireContext) {
|
|
19
|
+
if (!requireContext || typeof requireContext !== 'function') {
|
|
20
|
+
console.error('autoExportFiles: requireContext 必须是 require.context 返回的函数');
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const exports = {};
|
|
25
|
+
|
|
26
|
+
requireContext.keys().forEach(fileName => {
|
|
27
|
+
// 跳过 index 文件自身
|
|
28
|
+
if (fileName.includes('index')) return;
|
|
29
|
+
|
|
30
|
+
const componentConfig = requireContext(fileName);
|
|
31
|
+
const componentName = fileName
|
|
32
|
+
.replace(/^\.\//, '') // 移除 './'
|
|
33
|
+
.replace(/\.\w+$/, ''); // 移除扩展名
|
|
34
|
+
|
|
35
|
+
exports[componentName] = componentConfig.default || componentConfig;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return exports;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 简化版:直接挂载到 module.exports
|
|
43
|
+
* @param {Function} requireContext - require.context 返回的函数
|
|
44
|
+
* @param {Object} targetExports - 目标导出对象(通常是 module.exports)
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* // 在 components/Dialog/index.js 中使用
|
|
48
48
|
* import { autoExportToModule } from '@infly/libs/adapters/webpack/auto-export';
|
|
49
|
-
* autoExportToModule(require.context('./', false, /\.vue$/), module.exports);
|
|
50
|
-
*/
|
|
51
|
-
function autoExportToModule(requireContext, targetExports) {
|
|
52
|
-
const files = autoExportFiles(requireContext);
|
|
53
|
-
Object.assign(targetExports, files);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export { autoExportFiles, autoExportToModule };
|
|
49
|
+
* autoExportToModule(require.context('./', false, /\.vue$/), module.exports);
|
|
50
|
+
*/
|
|
51
|
+
function autoExportToModule(requireContext, targetExports) {
|
|
52
|
+
const files = autoExportFiles(requireContext);
|
|
53
|
+
Object.assign(targetExports, files);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { autoExportFiles, autoExportToModule };
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
const { spawn } = require("child_process");
|
|
2
|
-
|
|
3
|
-
function run(command, args, options = {}) {
|
|
4
|
-
return new Promise((resolve, reject) => {
|
|
5
|
-
const useShell = options.shell !== undefined ? options.shell : process.platform === "win32";
|
|
6
|
-
// Avoid DEP0190: when shell=true, pass command+args as single string
|
|
7
|
-
const [cmd, cmdArgs] = useShell
|
|
8
|
-
? [[command, ...args].join(" "), []]
|
|
9
|
-
: [command, args];
|
|
10
|
-
const child = spawn(cmd, cmdArgs, {
|
|
11
|
-
cwd: options.cwd || process.cwd(),
|
|
12
|
-
env: {
|
|
13
|
-
...process.env,
|
|
14
|
-
...(options.env || {})
|
|
15
|
-
},
|
|
16
|
-
stdio: options.stdio || "inherit",
|
|
17
|
-
shell: useShell
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
child.on("close", (code) => {
|
|
21
|
-
if (code === 0) {
|
|
22
|
-
resolve();
|
|
23
|
-
} else {
|
|
24
|
-
reject(new Error(`${command} ${args.join(" ")} failed with exit code ${code}`));
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
child.on("error", reject);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function spawnBackground(command, args, options = {}) {
|
|
33
|
-
const useShell = options.shell !== undefined ? options.shell : process.platform === "win32";
|
|
34
|
-
const [cmd, cmdArgs] = useShell
|
|
35
|
-
? [[command, ...args].join(" "), []]
|
|
36
|
-
: [command, args];
|
|
37
|
-
const child = spawn(cmd, cmdArgs, {
|
|
38
|
-
cwd: options.cwd || process.cwd(),
|
|
39
|
-
env: {
|
|
40
|
-
...process.env,
|
|
41
|
-
...(options.env || {})
|
|
42
|
-
},
|
|
43
|
-
stdio: options.stdio || "inherit",
|
|
44
|
-
shell: useShell
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
child.on("error", (error) => {
|
|
48
|
-
console.error(error.message);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
return child;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
module.exports = {
|
|
55
|
-
run,
|
|
56
|
-
spawnBackground
|
|
57
|
-
};
|
|
1
|
+
const { spawn } = require("child_process");
|
|
2
|
+
|
|
3
|
+
function run(command, args, options = {}) {
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
const useShell = options.shell !== undefined ? options.shell : process.platform === "win32";
|
|
6
|
+
// Avoid DEP0190: when shell=true, pass command+args as single string
|
|
7
|
+
const [cmd, cmdArgs] = useShell
|
|
8
|
+
? [[command, ...args].join(" "), []]
|
|
9
|
+
: [command, args];
|
|
10
|
+
const child = spawn(cmd, cmdArgs, {
|
|
11
|
+
cwd: options.cwd || process.cwd(),
|
|
12
|
+
env: {
|
|
13
|
+
...process.env,
|
|
14
|
+
...(options.env || {})
|
|
15
|
+
},
|
|
16
|
+
stdio: options.stdio || "inherit",
|
|
17
|
+
shell: useShell
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
child.on("close", (code) => {
|
|
21
|
+
if (code === 0) {
|
|
22
|
+
resolve();
|
|
23
|
+
} else {
|
|
24
|
+
reject(new Error(`${command} ${args.join(" ")} failed with exit code ${code}`));
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
child.on("error", reject);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function spawnBackground(command, args, options = {}) {
|
|
33
|
+
const useShell = options.shell !== undefined ? options.shell : process.platform === "win32";
|
|
34
|
+
const [cmd, cmdArgs] = useShell
|
|
35
|
+
? [[command, ...args].join(" "), []]
|
|
36
|
+
: [command, args];
|
|
37
|
+
const child = spawn(cmd, cmdArgs, {
|
|
38
|
+
cwd: options.cwd || process.cwd(),
|
|
39
|
+
env: {
|
|
40
|
+
...process.env,
|
|
41
|
+
...(options.env || {})
|
|
42
|
+
},
|
|
43
|
+
stdio: options.stdio || "inherit",
|
|
44
|
+
shell: useShell
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
child.on("error", (error) => {
|
|
48
|
+
console.error(error.message);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return child;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
module.exports = {
|
|
55
|
+
run,
|
|
56
|
+
spawnBackground
|
|
57
|
+
};
|