@infly/libs 2.1.0 → 2.1.2

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 CHANGED
@@ -252,6 +252,10 @@ infly-libs docker:compose --target yhqy --bump patch
252
252
 
253
253
  ## 配置驱动的 Docker 构建与部署
254
254
 
255
+ 兼容目标:仅配置 `file` 的历史目标仍显示在同一平台列表,范围仅提供前端,沿用 Compose 中的镜像标签并固定 `bump=none`;配置 `components` 的目标使用 qc 镜像流程,两者不混用标签。历史目标的镜像不能交给要求 qc/commit 的定制平台 Jenkins 任务。
256
+
257
+ Windows 本地构建连接 `dockerDesktopLinuxEngine` 失败时,入口尝试启动默认安装路径的 Docker Desktop,每两秒检测一次,最多等待 120 秒。CI、Jenkins、显式 DOCKER_HOST 和 dry-run 不启动软件;不切换 Docker context,不重启远程服务。软件安装在其他路径时请手动启动后重试。
258
+
255
259
  维护归属:公共构建工具;以 `bin/cli.js`、`build/docker/target-release.js` 和 `deployment-bundle.js` 为实现契约。新增配置字段时同步此节及测试。
256
260
 
257
261
  `infly-libs docker:release` 先单选 target,再多选该 target 的 components。构建在执行命令的机器进行。默认不推送;`--push` 构建、验证后推送 `qc-<12位commit>`;`--dry-run` 只解析配置,不联网、不运行 Git/Docker、不创建目录。
@@ -259,8 +263,8 @@ infly-libs docker:compose --target yhqy --bump patch
259
263
  ```json
260
264
  {
261
265
  "scripts": {
262
- "docker:build": "infly-libs docker:release --no-push",
263
- "docker:release": "infly-libs docker:release --push"
266
+ "build:prod:docker": "infly-libs docker:release --no-push",
267
+ "release:prod:docker": "infly-libs docker:release --push"
264
268
  },
265
269
  "infly": {
266
270
  "docker": {
@@ -333,6 +337,8 @@ infly-libs docker:bundle --target demo --dry-run
333
337
 
334
338
  `--platform` 是 `--target` 的兼容别名;`--config` 读取 JSON 文件,其顶层直接为 docker 配置。CLI 参数优先于项目配置;`--backend-dir` 仅覆盖名为 backend 的组件源码目录。
335
339
 
336
- `docker:bundle` 只生成本地脚本包,不自动部署;输出须是项目内尚不存在的独立子目录。包内包含 config.sh、Compose 覆盖文件和公共 shell 脚本。Jenkins 固定公共包版本后生成,使用既有凭据及人工确认,调用 `deploy.sh component=repository:commit` 传输并执行;`promote-image.sh` 接受组件名、qc 镜像、正式镜像和完整 commit。运行部署脚本会操作服务器,必须由开发者手动触发既定任务。
340
+ 构建成功后逐组件输出 `frontend_commit=<40位commit>`、`frontend=仓库:qc-<12位commit>` 机器行;全部构建结束后打印与 `build:docker` 一致的汇总块(`✅ 完成`、可用标签并标注 `commit 精确版本`、发布参数区,方便复制到定制化 Jenkins 发布 Job)。可选 `--cicd-url`(支持等号和空格两种传参形式)在推送成功后于汇总块尾输出蓝色发布系统链接;不传时保持原输出。链接必须是合法 HTTP/HTTPS URL,不含用户名或密码。
341
+
342
+ `docker:bundle` 只生成本地脚本包,不自动部署;输出须是项目内尚不存在的独立子目录。包内包含 config.sh、Compose 覆盖文件和公共 shell 脚本。Jenkins 固定公共包版本后生成,使用既有凭据,调用 `deploy.sh component=repository:commit` 传输并执行;`promote-image.sh` 接受组件名、qc 镜像、正式镜像和完整 commit,拉取经过 revision 校验的单平台 qc 镜像,再以 `docker tag` 和 `docker push` 创建正式标签,并复核正式镜像 revision。运行部署脚本会操作服务器,必须由开发者手动触发既定任务。
337
343
 
338
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
+ };