@jira-deploy/core 1.0.15 → 1.0.16

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/tools/helpers.js CHANGED
@@ -1,4 +1,4 @@
1
- import {getDeployConfig, META_TEST_NODES, SERVERS, SERVER_MODULE_MAP} from '../constants/index.js';
1
+ import {getDeployConfig, META_TEST_NODES, SERVER_MODULE_MAP, SERVERS} from '../constants/index.js';
2
2
 
3
3
  export function ok(data) {
4
4
  return {content: [{type: 'text', text: JSON.stringify(data, null, 2)}]};
@@ -22,7 +22,7 @@ export function today() {
22
22
  * @param {boolean} [metaTest] - 是否為 meta test 模式(ibk/cwa 只回傳單一節點)
23
23
  * @returns {string[]} Server 列表
24
24
  */
25
- export function getServerList(systemCode, env, metaTest, module) {
25
+ export function getServerList(systemCode, env, metaTest = false, module) {
26
26
  const systemConfig = SERVERS[systemCode];
27
27
  if (!systemConfig) return [];
28
28
 
@@ -36,7 +36,12 @@ export function getServerList(systemCode, env, metaTest, module) {
36
36
 
37
37
  // 如果是嵌套結構 (EIB, EVT),依 SERVER_MODULE_MAP 選擇 was 或 web
38
38
  if (typeof envConfig === 'object' && !Array.isArray(envConfig)) {
39
- const serverKey = SERVER_MODULE_MAP[module];
39
+ const moduleNameMap = {
40
+ cust: 'web_cust',
41
+ agent: 'web_agnt',
42
+ }
43
+
44
+ const serverKey = systemCode === getDeployConfig().systemCodes.EIB ? SERVER_MODULE_MAP[moduleNameMap[module]] : SERVER_MODULE_MAP[module];
40
45
  if (serverKey && envConfig[serverKey]) return envConfig[serverKey];
41
46
  // fallback:無法判斷時回傳所有(避免空陣列)
42
47
  return Object.values(envConfig).flat();
@@ -45,10 +50,6 @@ export function getServerList(systemCode, env, metaTest, module) {
45
50
  return Array.isArray(envConfig) ? envConfig : [];
46
51
  }
47
52
 
48
- export function getClusterList(systemCode, env, module) {
49
- return getServerList(systemCode, env, false, module);
50
- }
51
-
52
53
  /**
53
54
  * 依 systemCode + module + versionName 組出 release 版本名稱。
54
55
  */
@@ -63,3 +64,23 @@ export function getModuleName(systemCode, module, versionName) {
63
64
  versionName
64
65
  );
65
66
  }
67
+
68
+ export function getPollIntervalMs() {
69
+ return parseInt(process.env.POLL_INTERVAL_MS ?? '30000');
70
+ }
71
+
72
+ export function getPollTimeoutMs() {
73
+ return parseInt(process.env.POLL_TIMEOUT_MS ?? '3600000');
74
+ }
75
+
76
+ export function isPassingResult(value) {
77
+ return ['pass', 'passed', 'success', 'succeeded', 'done'].includes(
78
+ String(value ?? '').trim().toLowerCase(),
79
+ );
80
+ }
81
+
82
+ export function isFailingResult(value) {
83
+ return ['fail', 'failed', 'failure', 'error'].includes(
84
+ String(value ?? '').trim().toLowerCase(),
85
+ );
86
+ }