@infly/libs 2.1.9 → 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/README.md +1 -1
- 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 +26 -2
- package/build/docker/target-release.js +20 -3
- 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
package/README.md
CHANGED
|
@@ -363,7 +363,7 @@ infly-libs docker:bundle --target demo --dry-run
|
|
|
363
363
|
|
|
364
364
|
`--platform` 是 `--target` 的兼容别名;`--config` 读取 JSON 文件,其顶层直接为 docker 配置。CLI 参数优先于项目配置;`--backend-dir` 仅覆盖名为 backend 的组件源码目录。
|
|
365
365
|
|
|
366
|
-
构建成功后逐组件输出完整提交版本、`组件=仓库:<12位提交版本>` 和 `组件_latest=仓库:latest` 机器行;每个组件的一次构建同时生成不可变提交标签与 `latest`,启用推送时先推送不可变标签,再更新 `latest`。全部构建结束后打印 `✅ 完成`
|
|
366
|
+
构建成功后逐组件输出完整提交版本、`组件=仓库:<12位提交版本>` 和 `组件_latest=仓库:latest` 机器行;每个组件的一次构建同时生成不可变提交标签与 `latest`,启用推送时先推送不可变标签,再更新 `latest`。全部构建结束后打印 `✅ 完成` 汇总块,明确区分“不可变提交版本”和“最新推送镜像(所选平台 registry 的 latest)”。可选 `--cicd-url`(支持等号和空格两种传参形式)在推送成功后于汇总块尾输出蓝色发布系统链接;“发布系统:”与中文 URL 分为两行,URL 独占一行,OSC 8 显式超链接使用百分号编码后的标准 URL 作为点击目标,确保支持该协议的终端可通过 Ctrl + 鼠标左键完整打开。不传时保持原输出。链接必须是合法 HTTP/HTTPS URL,不含用户名或密码。单组件推送成功且 `--cicd-url` 指向以 `/build` 结尾的 Jenkins 构建地址时,链接会预填“平台”与“镜像版本”参数(`平台 / 12位提交版本 / 北京时间`),打开构建页默认即为本次推送镜像;多组件推送或其他地址保持原链接。
|
|
367
367
|
|
|
368
368
|
`docker:bundle` 只生成本地脚本包,不自动部署;输出须是项目内尚不存在的独立子目录。包内包含 config.sh、Compose 覆盖文件和公共 shell 脚本。Jenkins 可直接传入部署项目 `package.json` 声明的精确版本或 caret 范围获取公共包;`docker:bundle` 会在执行时输出实际解析到的 `@infly/libs` 精确版本,供 Jenkins 日志追溯。镜像不需要 Infly 专用版本标签,因此独立项目使用普通 `docker build` 生成的镜像仍可部署。Jenkins 使用既有凭据,调用 `deploy.sh component=repository:commit` 传输并执行。包内仍保留 `promote-image.sh` 供既有 qc 晋升流程兼容使用;低频定制平台直接在本地推送不可变提交标签与 `latest`,Jenkins 不再调用晋升脚本。运行部署脚本会操作服务器,必须由开发者手动触发既定任务。
|
|
369
369
|
|
|
@@ -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
|
+
};
|