@dreamor/atlas-cli 0.7.9 → 0.7.10
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/dist/adapters/atlas/commands/actual/index.js +3 -5
- package/dist/adapters/atlas/commands/baseline/index.js +2 -5
- package/dist/adapters/atlas/commands/compare/index.js +2 -4
- package/dist/adapters/atlas/util/env.js +27 -0
- package/dist/adapters/atlas/util/version.js +1 -1
- package/package.json +1 -1
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { createClient } from '../../http/client.js';
|
|
2
2
|
import { isJsonMode, jsonOk, log } from '../../util/output.js';
|
|
3
3
|
import { enforceOutputLimit } from '../../util/output-limit.js';
|
|
4
|
-
import {
|
|
4
|
+
import { SessionExpiredError } from '../../util/errors.js';
|
|
5
5
|
import { expandMonths } from '../../util/months.js';
|
|
6
6
|
import { resolveSecureExportPath, secureWriteFile } from '../../util/secure-fs.js';
|
|
7
7
|
import { annotateWithMonth, aggregateByAxis, filterByStaff, } from './_logic.js';
|
|
8
|
+
import { resolveProjectId } from '../../util/env.js';
|
|
8
9
|
function getProjectId(opts) {
|
|
9
|
-
|
|
10
|
-
if (!pid)
|
|
11
|
-
throw new ConfigError('请指定 --project-id 或设置 BANMA_PROJECT_ID 环境变量');
|
|
12
|
-
return pid;
|
|
10
|
+
return resolveProjectId(opts.projectId);
|
|
13
11
|
}
|
|
14
12
|
async function fetchActual(pid, month) {
|
|
15
13
|
const client = createClient();
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { createClient } from '../../http/client.js';
|
|
2
2
|
import { isJsonMode, jsonOk, log } from '../../util/output.js';
|
|
3
3
|
import { enforceOutputLimit } from '../../util/output-limit.js';
|
|
4
|
-
import { ConfigError } from '../../util/errors.js';
|
|
5
4
|
import { expandMonths } from '../../util/months.js';
|
|
6
5
|
import { monthTsToKey } from '../../util/time.js';
|
|
7
6
|
import { resolveSecureExportPath, secureWriteFile } from '../../util/secure-fs.js';
|
|
7
|
+
import { resolveProjectId } from '../../util/env.js';
|
|
8
8
|
function getProjectId(opts) {
|
|
9
|
-
|
|
10
|
-
if (!pid)
|
|
11
|
-
throw new ConfigError('请指定 --project-id 或设置 BANMA_PROJECT_ID 环境变量');
|
|
12
|
-
return pid;
|
|
9
|
+
return resolveProjectId(opts.projectId);
|
|
13
10
|
}
|
|
14
11
|
/**
|
|
15
12
|
* 月基线 API 返回 data 为数组,每项含 linePlanMonthDetailList
|
|
@@ -4,11 +4,9 @@ import { ConfigError, SessionExpiredError } from '../../util/errors.js';
|
|
|
4
4
|
import { expandMonths } from '../../util/months.js';
|
|
5
5
|
import { monthTsToKey } from '../../util/time.js';
|
|
6
6
|
import { groupByAxis, mergeBaselineActual, } from './_logic.js';
|
|
7
|
+
import { resolveProjectId } from '../../util/env.js';
|
|
7
8
|
function getProjectId(opts) {
|
|
8
|
-
|
|
9
|
-
if (!pid)
|
|
10
|
-
throw new ConfigError('请指定 --project-id 或设置 BANMA_PROJECT_ID 环境变量');
|
|
11
|
-
return pid;
|
|
9
|
+
return resolveProjectId(opts.projectId);
|
|
12
10
|
}
|
|
13
11
|
export async function compareCmd(opts) {
|
|
14
12
|
const pid = getProjectId(opts);
|
|
@@ -1,7 +1,34 @@
|
|
|
1
|
+
import { readFileSync, existsSync } from 'fs';
|
|
2
|
+
import { getLinkFile } from './paths.js';
|
|
3
|
+
import { ConfigError } from './errors.js';
|
|
1
4
|
/** 获取 BANMA_PROJECT_ID 环境变量 */
|
|
2
5
|
export function getBanmaProjectId() {
|
|
3
6
|
return process.env.BANMA_PROJECT_ID;
|
|
4
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* 解析项目 ID,优先级:
|
|
10
|
+
* 1. 命令行 --project-id 参数
|
|
11
|
+
* 2. BANMA_PROJECT_ID 环境变量
|
|
12
|
+
* 3. ~/.atlas/link.json(atlas link 绑定的项目)
|
|
13
|
+
*/
|
|
14
|
+
export function resolveProjectId(cliProjectId) {
|
|
15
|
+
if (cliProjectId)
|
|
16
|
+
return cliProjectId;
|
|
17
|
+
if (process.env.BANMA_PROJECT_ID)
|
|
18
|
+
return process.env.BANMA_PROJECT_ID;
|
|
19
|
+
try {
|
|
20
|
+
const linkFile = getLinkFile();
|
|
21
|
+
if (existsSync(linkFile)) {
|
|
22
|
+
const link = JSON.parse(readFileSync(linkFile, 'utf-8'));
|
|
23
|
+
if (link.projectId)
|
|
24
|
+
return link.projectId;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
// ignore
|
|
29
|
+
}
|
|
30
|
+
throw new ConfigError('请指定 --project-id、设置 BANMA_PROJECT_ID、或先用 atlas link <project> 绑定项目');
|
|
31
|
+
}
|
|
5
32
|
/** 是否禁用自动升级 */
|
|
6
33
|
export function isUpdateDisabled() {
|
|
7
34
|
return process.env.ATLAS_DISABLE_UPDATE === '1';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const ATLAS_VERSION = '0.7.
|
|
1
|
+
export const ATLAS_VERSION = '0.7.10';
|