@77-zhike/app-sdk 0.2.0-d7b1.2 → 0.2.0-d7b1.3
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/package.json +1 -1
- package/src/cli/index.js +1 -0
- package/src/config.js +11 -7
package/package.json
CHANGED
package/src/cli/index.js
CHANGED
package/src/config.js
CHANGED
|
@@ -3,6 +3,9 @@ import { readFileSync } from "node:fs";
|
|
|
3
3
|
import { ZhikeCliError } from "./errors.js";
|
|
4
4
|
|
|
5
5
|
export const CLI_CLIENT_ID = "zhike-cli";
|
|
6
|
+
export const DEFAULT_DEVELOPER_API_URL = "https://build-clm.77hub.com";
|
|
7
|
+
export const DEFAULT_DEVELOPER_CONSOLE_URL = "https://build-clm.77hub.com";
|
|
8
|
+
export const DEFAULT_WORKSPACE_APP_URL = "https://app-clm.77hub.com";
|
|
6
9
|
const metadata = JSON.parse(
|
|
7
10
|
readFileSync(new URL("../package.json", import.meta.url), "utf8"),
|
|
8
11
|
);
|
|
@@ -38,26 +41,27 @@ export function normalizeOrigin(value, fieldName) {
|
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
export function loadCliConfig(environment = process.env) {
|
|
41
|
-
const
|
|
42
|
-
(name) => typeof environment[name]
|
|
44
|
+
const provided = CLI_ORIGIN_VARIABLES.filter(
|
|
45
|
+
(name) => typeof environment[name] === "string" && environment[name].trim(),
|
|
43
46
|
);
|
|
44
|
-
if (
|
|
47
|
+
if (provided.length > 0 && provided.length < CLI_ORIGIN_VARIABLES.length) {
|
|
48
|
+
const missing = CLI_ORIGIN_VARIABLES.filter((name) => !provided.includes(name));
|
|
45
49
|
throw new ZhikeCliError(
|
|
46
50
|
"zhike_environment_required",
|
|
47
|
-
|
|
51
|
+
`覆盖平台环境时必须同时提供:${missing.join(", ")}`,
|
|
48
52
|
);
|
|
49
53
|
}
|
|
50
54
|
return {
|
|
51
55
|
apiBaseUrl: normalizeOrigin(
|
|
52
|
-
environment.ZHIKE_DEVELOPER_API_URL,
|
|
56
|
+
environment.ZHIKE_DEVELOPER_API_URL || DEFAULT_DEVELOPER_API_URL,
|
|
53
57
|
"ZHIKE_DEVELOPER_API_URL",
|
|
54
58
|
),
|
|
55
59
|
consoleBaseUrl: normalizeOrigin(
|
|
56
|
-
environment.ZHIKE_DEVELOPER_CONSOLE_URL,
|
|
60
|
+
environment.ZHIKE_DEVELOPER_CONSOLE_URL || DEFAULT_DEVELOPER_CONSOLE_URL,
|
|
57
61
|
"ZHIKE_DEVELOPER_CONSOLE_URL",
|
|
58
62
|
),
|
|
59
63
|
workspaceBaseUrl: normalizeOrigin(
|
|
60
|
-
environment.ZHIKE_WORKSPACE_APP_URL,
|
|
64
|
+
environment.ZHIKE_WORKSPACE_APP_URL || DEFAULT_WORKSPACE_APP_URL,
|
|
61
65
|
"ZHIKE_WORKSPACE_APP_URL",
|
|
62
66
|
),
|
|
63
67
|
};
|