@infly/libs 2.2.0 → 2.2.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
@@ -131,7 +131,7 @@ infly-libs build:docker --local --health-check --health-timeout=60
131
131
  infly-libs release:docker --local --health-check --health-timeout=60
132
132
  ```
133
133
 
134
- `checks` 中的名称必须对应应用已有的 pnpm script;任一检查、覆盖率文件验证、Sonar Quality Gate 或镜像健康门禁失败,命令都会退出且不会推送镜像。`sonar` 默认为 `true`;设为 `false` 时由 CI 单独负责扫描和 Quality Gate。本地启用 Sonar 时必须通过当前进程环境或应用根目录下被 Git 忽略的 `.env.production.local` 提供 `SONAR_TOKEN`,并确保 `sonar-scanner` CLI 可执行;当前进程环境变量的优先级更高。`release:docker` 会拒绝含未提交文件的应用工作树,固定使用 12 位应用 commit 作为镜像标签,并把完整 commit 写入 OCI revision label;普通 `build:docker` 的原有版本来源保持不变。应用差异保留在应用配置,通用编排由 `infly-libs` 维护。
134
+ `checks` 中的名称必须对应应用已有的 pnpm script;任一检查、覆盖率文件验证、Sonar Quality Gate 或镜像健康门禁失败,命令都会退出且不会推送镜像。`sonar` 默认为 `true`;设为 `false` 时由 CI 单独负责扫描和 Quality Gate。本地启用 Sonar 时必须通过当前进程环境或应用根目录下被 Git 忽略的 `.env.production.local` 提供 `SONAR_TOKEN`,并确保 `sonar-scanner` CLI 可执行;当前进程环境变量的优先级更高。`release:docker` 会拒绝含未提交文件的应用工作树,固定使用完整 40 位应用 commit 作为镜像标签及 OCI revision/version;普通 `build:docker` 未显式传版本时同样使用完整 commit。应用差异保留在应用配置,通用编排由 `infly-libs` 维护。
135
135
 
136
136
  受控紧急构建可使用 `--emergency` 跳过 `checks`、覆盖率文件校验和 Sonar,但必须提供 8~200 个字符且无控制字符的 `--emergency-reason`,并同时启用 `--standalone --commit-only --health-check`。紧急模式仍执行工作树干净检查、commit/revision 解析、镜像构建、健康检查和推送;缺少任一保护参数会在调用 Docker 前失败。
137
137
 
@@ -237,12 +237,12 @@ const components = await selectOptions("请选择构建范围", [
237
237
  infly-libs docker:compose --target yhqy --bump patch
238
238
  ```
239
239
 
240
- 默认从当前目录 `package.json` 的 `infly.docker.targets` 读取目标,并以该 package 所在目录解析 Compose 相对路径;省略 `--target` 时在 TTY 中交互选择。`--config` 外部 JS 配置和原有 `--project-dir` + `--file` 直传方式继续兼容。
240
+ 默认从当前目录 `package.json` 的 `infly.docker` 读取目标;该对象可用 `config` 指向项目内 JSON、YAML、JS 配置文件,package 中的少量同名字段作为 override 合并。Compose 与配置路径均以 package 所在项目目录解析;省略 `--target` 时在 TTY 中交互选择。`--config` 外部配置和原有 `--project-dir` + `--file` 直传方式继续兼容。
241
241
 
242
242
  参数约束:
243
243
 
244
244
  - `--target`:选择 `infly.docker.targets` 或外部配置中的目标;非交互环境必须显式传入。
245
- - `--config`:可选的外部 JS 配置文件,使用 `targets.<name>.file` 结构。
245
+ - `--config`:可选的外部 JSON、YAML 或 JS 配置文件,使用 `targets.<name>` 结构。
246
246
  - `--project-dir` + `--file`:不使用 target 配置时的兼容直传方式,Compose 文件不能越出 `project-dir`。
247
247
  - `--bump none|patch`:`none` 保持 Compose 中的镜像版本不变,`patch` 将补丁版本递增;两种模式都要求 Compose 中恰好有一个 `x.y.z` 镜像 tag。
248
248
  - `--push`:显式推送;未传时只执行 `docker compose config` 和 `build`。
@@ -258,7 +258,37 @@ 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` 构建、验证后先推送不可变 `<12位提交版本>`,再更新 `latest`;`--dry-run` 只解析配置,不联网、不运行 Git/Docker、不创建目录。
261
+ `infly-libs docker:release` 先单选 target,再多选该 target 的 components。构建在执行命令的机器进行。默认不推送;`--push` 构建、验证后先推送不可变 `<完整40位提交版本>`,再更新 `latest`;`--dry-run` 只解析配置,不联网、不运行 Git/Docker、不创建目录。
262
+
263
+ 当 Docker 配置较大时,推荐在 `package.json` 只保留配置入口和真正需要被 Jenkins 直接读取的部署差异:
264
+
265
+ ```json
266
+ {
267
+ "infly": {
268
+ "docker": {
269
+ "config": "deploy/docker-platforms.yaml",
270
+ "targets": {
271
+ "demo": {
272
+ "deployment": { "server": "example.com" }
273
+ }
274
+ }
275
+ }
276
+ }
277
+ }
278
+ ```
279
+
280
+ 外部 YAML 可以定义完整的 `targetPresets` 和 `targets`。组件还可通过 `compose.file`、`compose.service` 直接复用 Compose 中的 `image`、`build.context`、`dockerfile`、`target` 与 `build.args`,避免在 `infly.docker` 重复 Docker 编排:
281
+
282
+ ```yaml
283
+ targets:
284
+ demo:
285
+ components:
286
+ frontend:
287
+ compose:
288
+ file: deploy/compose/docker-compose.frontend.demo.yaml
289
+ service: frontend
290
+ expectedRef: origin/master
291
+ ```
262
292
 
263
293
  ```json
264
294
  {
@@ -279,6 +309,10 @@ Windows 本地构建连接 `dockerDesktopLinuxEngine` 失败时,入口尝试
279
309
  "backend": {
280
310
  "dockerfile": "Dockerfile",
281
311
  "context": ".",
312
+ "source": {
313
+ "directory": ["../../services/api", "../api"],
314
+ "url": "https://example.com/api.git"
315
+ },
282
316
  "imageEnv": "API_IMAGE",
283
317
  "services": ["api", "worker"]
284
318
  }
@@ -318,8 +352,6 @@ Windows 本地构建连接 `dockerDesktopLinuxEngine` 失败时,入口尝试
318
352
  "backend": {
319
353
  "repository": "registry.example.com/demo/api",
320
354
  "source": {
321
- "directory": "../api",
322
- "url": "https://example.com/api.git",
323
355
  "branch": "release/demo"
324
356
  }
325
357
  }
@@ -342,10 +374,13 @@ Windows 本地构建连接 `dockerDesktopLinuxEngine` 失败时,入口尝试
342
374
  ```
343
375
 
344
376
  - `files`:从组件源码仓复制到独立临时上下文,仅发送指定产物;配置后 `dockerfile` 相对临时上下文。未配置时 `context`、`dockerfile` 相对组件源码仓。
377
+ - `config`:`infly.docker` 中的外部配置路径,支持 JSON、YAML、JS;外部配置为基础,package 中的同名对象递归覆盖。循环引用和未知格式会直接失败。
378
+ - `compose`:组件构建配置来源,必须指定 `file` 和 `service`。工具从 Compose 服务读取镜像仓库、上下文、Dockerfile、stage 与构建参数;组件显式字段仍可覆盖解析结果。
379
+ - `target` / `buildArgs`:分别映射到 `docker buildx build --target` 和 `--build-arg`;使用 `compose` 时通常无需重复填写。
345
380
  - `requiredFiles`:构建前必须存在的源码仓相对路径,例如前端产物的 `index.html`;缺失时停止构建。
346
- - `source`:可选独立源码仓;从项目目录解析 `directory`,fetch 后使用指定分支的临时 detached worktree,不切换当前开发分支。缺少源码仓时明确说明未执行构建或推送,打印编号化的 clone、fetch 和重跑步骤,全部构建停止,CLI 返回 2。
381
+ - `source`:可选独立源码仓;`directory` 支持单个路径或按优先级排列的候选路径数组,路径均从项目目录解析,采用第一个包含 `.git` 的目录。fetch 后使用指定分支的临时 detached worktree,不切换当前开发分支。交互终端找不到候选仓库时会列出已检查路径、展示路径示例并等待手动输入;取消或非交互环境仍明确说明未执行构建或推送,打印编号化的 clone、fetch 和重跑步骤,全部构建停止,CLI 返回 2。
347
382
  - `targetPresets` 与 `targets.*.extends`:可选的具名公共目标配置。preset 可以继续 `extends` 另一个 preset;目标只继承显式指定的 preset,未声明 `extends` 的历史目标不受影响。同名普通对象递归合并;数组、字符串、数字、布尔值和 `null` 由下层整项替换,不按数组下标混合。未知 preset 或循环继承直接失败。本地构建、Compose 发布和部署包生成共用同一解析规则。
348
- - `releaseScripts`:可选的组件重跑脚本映射。源码仓缺失时优先提示 `pnpm run <脚本> -- --platform ...`;脚本名只允许字母、数字、冒号、点、下划线和连字符。未配置时提示通用 `pnpm exec infly-libs docker:release` 命令。
383
+ - `releaseScripts`:可选的组件重跑脚本覆盖。默认从项目 scripts 自动识别严格匹配 `release:<组件>:docker` 的脚本,例如 `release:backend:docker`;源码仓缺失时提示 `pnpm run <脚本> -- --platform ...`。只有脚本名称不遵循约定时才需要显式配置;无匹配时提示通用 `pnpm exec infly-libs docker:release` 命令。
349
384
  - 无 `source` 时构建当前项目,要求干净工作树且 HEAD 等于 `expectedRef`。有 `source` 时校验临时工作树对应的 origin 分支。
350
385
  - `check`:可选镜像内校验,使用 `entrypoint`、`args` 数组及 `addHosts` 数组;失败不推送。配置命令具有代码执行权限,应与源码一样评审,不能来自不可信输入。
351
386
  - `deployment`:仅用于部署包生成;`ready=false` 会阻止生成。可设置 `lockName`,默认 `.infly-release.lock`。服务归属和 imageEnv 必须唯一。
@@ -356,15 +391,18 @@ Windows 本地构建连接 `dockerDesktopLinuxEngine` 失败时,入口尝试
356
391
  ```bash
357
392
  infly-libs docker:release --target demo --components frontend,backend --push
358
393
  infly-libs docker:release --platform demo --components backend --backend-dir ../api --no-push
359
- infly-libs docker:release --project-dir ./deployment --config docker.json --target demo --components frontend --dry-run
394
+ infly-libs docker:release --project-dir ./deployment --config docker.yaml --target demo --components frontend --dry-run
395
+ infly-libs docker:config --project-dir ./deployment
360
396
  infly-libs docker:bundle --target demo --output .infly-deploy-123
361
397
  infly-libs docker:bundle --target demo --dry-run
362
398
  ```
363
399
 
364
- `--platform` 是 `--target` 的兼容别名;`--config` 读取 JSON 文件,其顶层直接为 docker 配置。CLI 参数优先于项目配置;`--backend-dir` 仅覆盖名为 backend 的组件源码目录。
400
+ `--platform` 是 `--target` 的兼容别名;`--config` 读取 JSON、YAML 或 JS 文件,其顶层直接为 docker 配置。`docker:config` 输出合并和继承后的单行 JSON,便于不安装 YAML 插件的 Jenkins 使用。CLI 参数优先于项目配置;`--backend-dir` 仅覆盖名为 backend 的组件源码目录,并覆盖整个 `source.directory` 候选数组。
365
401
 
366
- 构建成功后逐组件输出完整提交版本、`组件=仓库:<12位提交版本>` 和 `组件_latest=仓库:latest` 机器行;每个组件的一次构建同时生成不可变提交标签与 `latest`,启用推送时先推送不可变标签,再更新 `latest`。全部构建结束后打印 `✅ 完成` 汇总块,明确区分“不可变提交版本”和“最新推送镜像(所选平台 registry 的 latest)”。可选 `--cicd-url`(支持等号和空格两种传参形式)在推送成功后于汇总块尾输出蓝色发布系统链接;“发布系统:”与中文 URL 分为两行,URL 独占一行,OSC 8 显式超链接使用百分号编码后的标准 URL 作为点击目标,确保支持该协议的终端可通过 Ctrl + 鼠标左键完整打开。不传时保持原输出。链接必须是合法 HTTP/HTTPS URL,不含用户名或密码。单组件推送成功且 `--cicd-url` 指向以 `/build` 结尾的 Jenkins 构建地址时,链接会预填“平台”与“镜像版本”参数(`平台 / 12位提交版本 / 北京时间`),打开构建页默认即为本次推送镜像;多组件推送或其他地址保持原链接。
402
+ 构建成功后逐组件输出完整提交版本、`组件=仓库:<完整40位提交版本>` 和 `组件_latest=仓库:latest` 机器行;每个组件的一次构建同时生成不可变提交标签与 `latest`,启用推送时先推送不可变标签,再更新 `latest`。全部构建结束后打印 `✅ 完成` 汇总块,明确区分“不可变提交版本”和“最新推送镜像(所选平台 registry 的 latest)”。可选 `--cicd-url`(支持等号和空格两种传参形式)只在目标配置 `deployment.ready=true` 时于汇总块尾输出蓝色发布系统链接;未开放部署的平台只提示镜像已推送,不展示可能造成误解的部署入口。“发布系统:”与中文 URL 分为两行,URL 独占一行,OSC 8 显式超链接使用百分号编码后的标准 URL 作为点击目标,确保支持该协议的终端可通过 Ctrl + 鼠标左键完整打开。不传时保持原输出。链接必须是合法 HTTP/HTTPS URL,不含用户名或密码。单组件推送成功且 `--cicd-url` 指向以 `/build` 结尾的 Jenkins 构建地址时,链接会预填“平台”与“镜像版本”参数(`平台 / 完整40位提交版本 / 北京时间`),打开构建页默认即为本次推送镜像;多组件推送或其他地址保持原链接。
367
403
 
368
404
  `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
405
 
406
+ `docker:release` 不是强制构建入口。独立源码仓可以直接使用 Dockerfile 或 Compose 构建,但若镜像要进入这里生成的部署流程,必须自行保证仓库名、不可变完整 40 位提交标签以及 `org.opencontainers.image.revision`、`org.opencontainers.image.version`、`com.infly.platform` 标签与目标配置一致;公共发布入口只是自动化这些校验和映射。部署侧仅为既有镜像保留旧 12 位标签兼容,新构建不再生成 12 位标签。
407
+
370
408
  远端发布持锁后读取全部组件镜像基线,保存 .release-history;配置 `runtimeEnv` 时先从服务器总环境文件按白名单原子生成应用专用文件,再仅更新传入组件的服务(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 };
package/bin/cli.js CHANGED
@@ -103,6 +103,16 @@ function parseProjectArgs(argv) {
103
103
  async function main(argv = process.argv.slice(2)) {
104
104
  const command = argv[0];
105
105
  const commandMap = {
106
+ "docker:config": () => {
107
+ const { parseReleaseArgs } = require("../build/docker/target-release");
108
+ const options = parseReleaseArgs(argv.slice(1));
109
+ const config = require("../build/docker/config-loader").loadDockerConfig({
110
+ projectDir: options.projectDir,
111
+ configPath: options.config,
112
+ });
113
+ console.log(JSON.stringify(config));
114
+ return config;
115
+ },
106
116
  "docker:bundle": () => {
107
117
  const { parseReleaseArgs } = require("../build/docker/target-release");
108
118
  const result = require("../build/docker/deployment-bundle").createDeploymentBundle(parseReleaseArgs(argv.slice(1)));
@@ -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
+ };