@nocobase/cli 2.2.0-beta.3 → 2.2.0-beta.5

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.
@@ -23,6 +23,7 @@ import { runPromptCatalogWebUI } from "../lib/prompt-web-ui.js";
23
23
  import { validateApiBaseUrl, validateEnvKey } from "../lib/prompt-validators.js";
24
24
  import { installNocoBaseSkills, isNpmRegistryUnavailable } from '../lib/skills-manager.js';
25
25
  import { omitKeys, pickKeys } from "../lib/object-utils.js";
26
+ import { ENV_CONFIG_SCHEMA_VERSION } from '../lib/env-config.js';
26
27
  import { printInfo, printStage, printVerbose, printWarning } from '../lib/ui.js';
27
28
  import Download from "./download.js";
28
29
  import EnvAdd from "./env/add.js";
@@ -1036,6 +1037,7 @@ Prompt modes:
1036
1037
  results.appKey = appKey;
1037
1038
  results.timeZone = timeZone;
1038
1039
  await upsertEnv(envName, {
1040
+ schemaVersion: ENV_CONFIG_SCHEMA_VERSION,
1039
1041
  ...(source === 'docker'
1040
1042
  ? { kind: 'docker' }
1041
1043
  : source || appPath || appRootPath
@@ -12,6 +12,7 @@ import { resolveAppPublicPath } from './app-public-path.js';
12
12
  import { resolveCliHomeDir, resolveConfiguredEnvPath, resolveEnvRelativePath } from './cli-home.js';
13
13
  import { normalizeCliLocale } from './cli-locale.js';
14
14
  import { inferConfiguredAppPathFromLegacyConfig, resolveConfiguredAppPath, resolveConfiguredSourcePath, resolveConfiguredStoragePath, } from './env-paths.js';
15
+ import { ENV_CONFIG_SCHEMA_VERSION, normalizeEnvConfigSchemaVersion } from './env-config.js';
15
16
  import { cleanupCurrentSessionAfterEnvRemoval, resolveEffectiveCurrentEnv, setSessionCurrentEnv, } from './session-store.js';
16
17
  function normalizeStoredEnvKind(value) {
17
18
  const kind = String(value ?? '').trim();
@@ -76,11 +77,13 @@ function normalizeEnvConfigEntry(entry) {
76
77
  if (!entry) {
77
78
  return entry;
78
79
  }
79
- const { kind: _kind, apiBaseUrl: _apiBaseUrl, baseUrl: _baseUrl, apibaseUrl: _legacyApiBaseUrl, ...rest } = entry;
80
+ const { kind: _kind, apiBaseUrl: _apiBaseUrl, baseUrl: _baseUrl, apibaseUrl: _legacyApiBaseUrl, schemaVersion: _schemaVersion, ...rest } = entry;
80
81
  const normalizedKind = resolveEnvKind(entry);
81
82
  const apiBaseUrl = readEnvApiBaseUrl(entry);
83
+ const schemaVersion = normalizeEnvConfigSchemaVersion(entry.schemaVersion);
82
84
  return {
83
85
  ...rest,
86
+ ...(schemaVersion ? { schemaVersion } : {}),
84
87
  ...(normalizedKind ? { kind: normalizedKind } : {}),
85
88
  ...(apiBaseUrl !== undefined ? { apiBaseUrl } : {}),
86
89
  ...(normalizeOptionalString(entry.appPublicPath) ? { appPublicPath: resolveAppPublicPath(entry.appPublicPath) } : {}),
@@ -366,7 +369,13 @@ function areAuthConfigsEquivalent(left, right) {
366
369
  async function writeEnv(envName, updater, options = {}) {
367
370
  const config = await loadExactAuthConfig(options);
368
371
  const previous = config.envs[envName];
369
- config.envs[envName] = updater(previous);
372
+ const next = updater(previous);
373
+ config.envs[envName] = {
374
+ ...next,
375
+ schemaVersion: normalizeEnvConfigSchemaVersion(next.schemaVersion) ??
376
+ normalizeEnvConfigSchemaVersion(previous?.schemaVersion) ??
377
+ ENV_CONFIG_SCHEMA_VERSION,
378
+ };
370
379
  await saveAuthConfig(config, options);
371
380
  }
372
381
  function normalizeConfiguredAuthType(value) {
@@ -377,18 +386,19 @@ export function resolveConfiguredAuthType(config) {
377
386
  }
378
387
  export async function upsertEnv(envName, config, options = {}) {
379
388
  await writeEnv(envName, (previous) => {
380
- const { apiBaseUrl: _apiBaseUrl, baseUrl: _baseUrl, apibaseUrl: _legacyApiBaseUrl, accessToken, authType, authUsername, ...rest } = config;
389
+ const { apiBaseUrl: _apiBaseUrl, baseUrl: _baseUrl, apibaseUrl: _legacyApiBaseUrl, accessToken, authType, authUsername, schemaVersion, ...rest } = config;
381
390
  const nextApiBaseUrl = readEnvApiBaseUrl(config);
382
391
  const previousApiBaseUrl = readEnvApiBaseUrl(previous);
383
392
  const baseUrlChanged = previousApiBaseUrl !== nextApiBaseUrl;
384
393
  const previousAuthType = resolveConfiguredAuthType(previous);
385
394
  const requestedAuthType = normalizeConfiguredAuthType(authType);
386
- const nextAuthType = requestedAuthType ?? (accessToken ? 'token' : previousAuthType);
395
+ const nextAccessToken = normalizeOptionalString(accessToken);
396
+ const nextAuthType = requestedAuthType ?? (nextAccessToken ? 'token' : previousAuthType);
387
397
  const nextAuthUsername = nextAuthType === 'basic' ? normalizeOptionalString(authUsername) ?? previous?.authUsername : undefined;
388
- const nextAuth = accessToken
398
+ const nextAuth = nextAccessToken
389
399
  ? {
390
400
  type: 'token',
391
- accessToken,
401
+ accessToken: nextAccessToken,
392
402
  }
393
403
  : nextAuthType === 'oauth' && !baseUrlChanged && previous?.auth?.type === 'oauth'
394
404
  ? previous.auth
@@ -396,6 +406,9 @@ export async function upsertEnv(envName, config, options = {}) {
396
406
  const authChanged = !areAuthConfigsEquivalent(previous?.auth, nextAuth);
397
407
  const authTypeChanged = previousAuthType !== nextAuthType;
398
408
  const authUsernameChanged = previous?.authUsername !== nextAuthUsername;
409
+ const nextSchemaVersion = normalizeEnvConfigSchemaVersion(schemaVersion) ??
410
+ normalizeEnvConfigSchemaVersion(previous?.schemaVersion) ??
411
+ ENV_CONFIG_SCHEMA_VERSION;
399
412
  return {
400
413
  ...previous,
401
414
  apiBaseUrl: nextApiBaseUrl,
@@ -403,6 +416,7 @@ export async function upsertEnv(envName, config, options = {}) {
403
416
  authUsername: nextAuthUsername,
404
417
  auth: nextAuth,
405
418
  ...rest,
419
+ schemaVersion: nextSchemaVersion,
406
420
  runtime: baseUrlChanged || authChanged || authTypeChanged || authUsernameChanged ? undefined : previous?.runtime,
407
421
  };
408
422
  }, options);
@@ -46,6 +46,7 @@ const BOOLEAN_ENV_CONFIG_KEYS = [
46
46
  'buildDts',
47
47
  'dbUnderscored',
48
48
  ];
49
+ export const ENV_CONFIG_SCHEMA_VERSION = 1;
49
50
  function trimConfigValue(value) {
50
51
  const text = String(value ?? '').trim();
51
52
  return text || undefined;
@@ -53,6 +54,9 @@ function trimConfigValue(value) {
53
54
  function resolveSetupState(value) {
54
55
  return value === 'prepared' || value === 'installed' ? value : undefined;
55
56
  }
57
+ export function normalizeEnvConfigSchemaVersion(value) {
58
+ return typeof value === 'number' && Number.isInteger(value) && value > 0 ? value : undefined;
59
+ }
56
60
  function resolveEnvKind(input) {
57
61
  const source = trimConfigValue(input.source);
58
62
  const appPath = trimConfigValue(input.appPath);
@@ -67,6 +71,7 @@ function resolveEnvKind(input) {
67
71
  }
68
72
  export function buildStoredEnvConfig(input) {
69
73
  const envConfig = {
74
+ schemaVersion: normalizeEnvConfigSchemaVersion(input.schemaVersion) ?? ENV_CONFIG_SCHEMA_VERSION,
70
75
  kind: resolveEnvKind(input),
71
76
  apiBaseUrl: trimConfigValue(input.apiBaseUrl) ?? '',
72
77
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/cli",
3
- "version": "2.2.0-beta.3",
3
+ "version": "2.2.0-beta.5",
4
4
  "description": "NocoBase Command Line Tool",
5
5
  "type": "module",
6
6
  "main": "dist/generated/command-registry.js",
@@ -143,5 +143,5 @@
143
143
  "type": "git",
144
144
  "url": "git+https://github.com/nocobase/nocobase.git"
145
145
  },
146
- "gitHead": "7b16bb2cfd427c110c6671252138cd85155723c5"
146
+ "gitHead": "81eab2cfa9d3d989e99ba0c914807b38db55f023"
147
147
  }