@infly/libs 2.1.1 → 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
@@ -339,6 +339,6 @@ infly-libs docker:bundle --target demo --dry-run
339
339
 
340
340
  构建成功后逐组件输出 `frontend_commit=<40位commit>`、`frontend=仓库:qc-<12位commit>` 机器行;全部构建结束后打印与 `build:docker` 一致的汇总块(`✅ 完成`、可用标签并标注 `commit 精确版本`、发布参数区,方便复制到定制化 Jenkins 发布 Job)。可选 `--cicd-url`(支持等号和空格两种传参形式)在推送成功后于汇总块尾输出蓝色发布系统链接;不传时保持原输出。链接必须是合法 HTTP/HTTPS URL,不含用户名或密码。
341
341
 
342
- `docker:bundle` 只生成本地脚本包,不自动部署;输出须是项目内尚不存在的独立子目录。包内包含 config.sh、Compose 覆盖文件和公共 shell 脚本。Jenkins 固定公共包版本后生成,使用既有凭据,调用 `deploy.sh component=repository:commit` 传输并执行;`promote-image.sh` 接受组件名、qc 镜像、正式镜像和完整 commit,使用 `docker buildx imagetools create` 在注册表内复制多平台 OCI index 晋升正式标签(多平台镜像不能用 pull/tag/push),并要求参数与镜像 revision 一致。运行部署脚本会操作服务器,必须由开发者手动触发既定任务。
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。运行部署脚本会操作服务器,必须由开发者手动触发既定任务。
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
+ };