@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@77-zhike/app-sdk",
3
- "version": "0.2.0-d7b1.2",
3
+ "version": "0.2.0-d7b1.3",
4
4
  "description": "\u667a\u5ba2 Integration App \u4e00\u671f SDK \u4e0e\u672c\u5730 Toolchain",
5
5
  "type": "module",
6
6
  "engines": {
package/src/cli/index.js CHANGED
@@ -100,6 +100,7 @@ export async function runCli(
100
100
  fetchImpl,
101
101
  openBrowser,
102
102
  onProgress,
103
+ allowBrowserAuthorization: true,
103
104
  });
104
105
  output.write(
105
106
  `Developer CLI 登录成功(${_formatElapsed(startedAt)}),正在创建 App 和本地项目...\n`,
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 missing = CLI_ORIGIN_VARIABLES.filter(
42
- (name) => typeof environment[name] !== "string" || !environment[name].trim(),
44
+ const provided = CLI_ORIGIN_VARIABLES.filter(
45
+ (name) => typeof environment[name] === "string" && environment[name].trim(),
43
46
  );
44
- if (missing.length) {
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
- `缺少 CLI 环境变量:${missing.join(", ")}`,
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
  };