@infly/libs 2.1.1 → 2.1.3
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 +3 -3
- 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-command.js +73 -73
- package/build/docker/compose-release.js +79 -79
- package/build/docker/deployment/promote-image.sh +4 -6
- package/build/docker/target-release.js +15 -13
- package/build/project-files.js +47 -47
- package/cli/select-option.js +51 -51
- package/core/async/concurrency.js +29 -29
- package/package.json +1 -1
- package/script/git-automation/submodule-utils.js +16 -16
- package/workspace/config.js +144 -144
package/README.md
CHANGED
|
@@ -258,7 +258,7 @@ Windows 本地构建连接 `dockerDesktopLinuxEngine` 失败时,入口尝试
|
|
|
258
258
|
|
|
259
259
|
维护归属:公共构建工具;以 `bin/cli.js`、`build/docker/target-release.js` 和 `deployment-bundle.js` 为实现契约。新增配置字段时同步此节及测试。
|
|
260
260
|
|
|
261
|
-
`infly-libs docker:release` 先单选 target,再多选该 target 的 components。构建在执行命令的机器进行。默认不推送;`--push`
|
|
261
|
+
`infly-libs docker:release` 先单选 target,再多选该 target 的 components。构建在执行命令的机器进行。默认不推送;`--push` 构建、验证后先推送不可变 `<12位提交版本>`,再更新 `latest`;`--dry-run` 只解析配置,不联网、不运行 Git/Docker、不创建目录。
|
|
262
262
|
|
|
263
263
|
```json
|
|
264
264
|
{
|
|
@@ -337,8 +337,8 @@ infly-libs docker:bundle --target demo --dry-run
|
|
|
337
337
|
|
|
338
338
|
`--platform` 是 `--target` 的兼容别名;`--config` 读取 JSON 文件,其顶层直接为 docker 配置。CLI 参数优先于项目配置;`--backend-dir` 仅覆盖名为 backend 的组件源码目录。
|
|
339
339
|
|
|
340
|
-
|
|
340
|
+
构建成功后逐组件输出完整提交版本、`组件=仓库:<12位提交版本>` 和 `组件_latest=仓库:latest` 机器行;每个组件的一次构建同时生成不可变提交标签与 `latest`,启用推送时先推送不可变标签,再更新 `latest`。全部构建结束后打印 `✅ 完成` 汇总块,明确区分“不可变提交版本”和“最新构建镜像”。可选 `--cicd-url`(支持等号和空格两种传参形式)在推送成功后于汇总块尾输出蓝色发布系统链接;不传时保持原输出。链接必须是合法 HTTP/HTTPS URL,不含用户名或密码。
|
|
341
341
|
|
|
342
|
-
`docker:bundle` 只生成本地脚本包,不自动部署;输出须是项目内尚不存在的独立子目录。包内包含 config.sh、Compose 覆盖文件和公共 shell 脚本。Jenkins 固定公共包版本后生成,使用既有凭据,调用 `deploy.sh component=repository:commit`
|
|
342
|
+
`docker:bundle` 只生成本地脚本包,不自动部署;输出须是项目内尚不存在的独立子目录。包内包含 config.sh、Compose 覆盖文件和公共 shell 脚本。Jenkins 固定公共包版本后生成,使用既有凭据,调用 `deploy.sh component=repository:commit` 传输并执行。包内仍保留 `promote-image.sh` 供既有 qc 晋升流程兼容使用;低频定制平台直接在本地推送不可变提交标签与 `latest`,Jenkins 不再调用晋升脚本。运行部署脚本会操作服务器,必须由开发者手动触发既定任务。
|
|
343
343
|
|
|
344
344
|
远端发布持锁后读取全部组件镜像基线,保存 .release-history,仅更新传入组件的服务(up -d --no-deps)。失败恢复镜像环境文件及选中服务;回滚验证失败明确报错。不创建/修改数据库,不更新未配置的基础设施。服务器不需要 npm/Node,仍需 Bash、Docker Compose 和 curl。
|
|
@@ -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
|
+
};
|