Skip to content

Conversation

@WHChen-Alex
Copy link
Contributor

@WHChen-Alex WHChen-Alex commented Sep 16, 2025

Closes CMDB_INSTANCE-3369

依赖检查

组件之间的依赖声明,是微服务组件架构下的重要信息,请确保其正确性。

请勾选以下两组选项其中之一:

  • 本次 MR 没有使用上游组件(例如框架、后台组件等)的较新版本提供的特性。

或者:

  • 本次 MR 使用了上游组件(例如框架、后台组件等)的较新版本提供的特性。
  • 在对应的文件中更新了该上游组件的依赖版本(或确认了当前声明的依赖版本已包含本次 MR 使用的新特性)。

提交信息检查

Git 提交信息将决定包的版本发布及自动生成的 CHANGELOG,请检查工作内容与提交信息是否相符,并在以下每组选项中都依次确认。

破坏性变更是针对于下游使用者而言,可以通过本次改动对下游使用者的影响来识别变更类型:

  • 下游使用者不做任何改动,仍可以正常工作时,那么它属于普通变更。
  • 反之,下游使用者不做改动就无法正常工作时,那么它属于破坏性变更。

例如,构件修改了一个属性名,小产品 Storyboard 中需要使用新属性名才能工作,那么它就是破坏性变更。
又例如,构件还没有任何下游使用者,那么它的任何变更都是普通变更。

破坏性变更:

  • ⚠️ 本次 MR 包含破坏性变更的提交,请继续确认以下所有选项:
  • 没有更好的兼容方案,必须做破坏性变更。
  • 使用了 feat 作为提交类型。
  • 标注了 BREAKING CHANGE: 你的变更说明
  • 同时更新了本仓库中所有下游使用者的调用。
  • 同时更新了本仓库中所有下游使用者对该子包的依赖为即将发布的 major 版本。
  • 同时为其它仓库的 Migrating 做好了准备,例如文档或批量改动的方法。
  • 手动验证过破坏性变更在 Migrate 后可以正常工作。
  • 破坏性变更所在的提交没有意外携带其它子包的改动。

新特性:

  • 本次 MR 包含新特性的提交,且该提交不带有破坏性变更,并使用了 feat 作为提交类型。
  • 给新特性添加了单元测试。
  • 手动验证过新特性可以正常工作。

问题修复:

  • 本次 MR 包含问题修复的提交,且该提交不带有新特性或破坏性变更,并使用了 fix 作为提交类型。
  • 给问题修复添加了单元测试。
  • 手动验证过问题修复得到解决。

杂项工作:

即所有对下游使用者无任何影响、且没有必要显示在 CHANGELOG 中的改动,例如修改注释、测试用例、开发文档等:

  • 本次 MR 包含杂项工作的提交,且该提交不带有问题修复、新特性或破坏性变更,并使用了 chore, docs, test 等作为提交类型。

Summary by CodeRabbit

  • 新功能
    • 新增全局变量 LANGUAGE,可在运行时获取当前界面语言。
  • 国际化
    • 现在仅启用并支持英文与中文两种语言。
    • 在中文环境下相关文案将正确显示为中文(例如 “WORLD” 将显示为 “世界”)。

@coderabbitai
Copy link

coderabbitai bot commented Sep 16, 2025

Walkthrough

在计算全局变量的实现中新增对“LANGUAGE”的处理逻辑,并在相关测试中引入 i18n 的 supportedLngs 配置、在评估前切换语言为 zh、更新翻译断言,以及新增验证 LANGUAGE 返回值为 zh 的用例。

Changes

Cohort / File(s) Summary of changes
i18n 测试更新
packages/runtime/src/internal/compute/evaluate.spec.ts
在 i18n.init 中新增 supportedLngs: ["en","zh"];每次评估前调用 i18n.changeLanguage("zh");将 WORLD 的期望从 "World" 改为 "世界";新增测试:评估全局 LANGUAGE 返回 "zh"。
通用全局变量扩展
packages/runtime/src/internal/compute/getGeneralGlobals.ts
在 getIndividualGlobal 的 switch 中新增 "LANGUAGE" 分支:collectCoverage 为真时返回 "zh",否则返回 i18n.language,若未定义则回退 "zh"。无其他分支或导出签名变更。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning PR 描述目前基本保留了仓库模板且没有填写复选项或提供具体变更说明,模板中关于依赖检查、破坏性变更/新特性/修复等核对项均未被标注,且未说明代码层面的关键改动(例如新增 LANGUAGE 常量、getGeneralGlobals 的 LANGUAGE 分支及 tests 中的 i18n 调整)是否影响下游或需更新依赖版本,因此描述被判定为不完整且不足以支持合并决策与发布流程。 请补充并勾选依赖检查项,明确是否使用了上游新特性并在必要时更新或确认依赖版本;在提交信息检查区域标明变更类型(如使用 feat)并确认已添加单元测试与完成手动验证;在 PR 描述中加入简短的变更说明,列出主要改动文件(例如 packages/runtime/...)及其行为变化,并说明是否存在破坏性变更或需要下游迁移的指引;完成后再次请求审阅以推进合并流程。
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed 标题 “feat(): 框架支持LANGUAGE常量” 简洁且直接反映了变更的核心目的:为框架增加对 LANGUAGE 常量的支持(对应 changeset 中在 getGeneralGlobals 添加 LANGUAGE 分支并调整相关测试)。标题可被团队快速识别为一次功能性新增,表达清晰没有偏离更改内容。
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch alex/supportLanguageV3

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (5)
packages/runtime/src/internal/compute/language.ts (2)

26-30: fromEntries 的键使用了 [[lng]],多包了一层数组

功能虽可工作(会被字符串化),但可读性与类型均不佳,应使用 [lng, value]

应用如下微调:

-    return Object.fromEntries(
-      lngs.map((lng) => [[lng], i18n.language === lng])
-    );
+    return Object.fromEntries(
+      lngs.map((lng) => [lng, i18n.language === lng])
+    );

31-33: 确认默认兜底语义:为何固定 zh: true

默认返回 { en: false, zh: true } 会在未配置任何语言时强行偏向中文。请确认这是否为产品约定;否则更自然的兜底是基于 i18n.languagefallbackLng 生成。

如需我改成基于 fallbackLng 的动态兜底,我可以直接给出改动版 diff。

packages/runtime/src/internal/compute/language.spec.ts (1)

55-68: 避免直接赋值 i18n.options(破坏内部不变量)

多处通过重写 i18n.options 来模拟场景,存在与类型定义不符及污染全局实例的风险。建议改为使用 i18n.init(...) 重新初始化或封装帮助函数重置配置。

可改为:

  • 记录原配置:const original = { ...i18n.options };
  • 测试内调用 i18n.init({ ...original, supportedLngs: 'en', resources: { ... } })
  • 用后还原:i18n.init(original)

Also applies to: 70-84, 125-131

packages/runtime/src/internal/compute/evaluate.ts (1)

507-510: 新增全局常量 LANGUAGE 的计算分支合理 ✅

按需计算并注入 getSupportedLanguages() 的结果,且不引入副作用。建议在文档中补充 LANGUAGE 的可用性说明。

packages/runtime/src/internal/compute/evaluate.spec.ts (1)

325-325: 新增对 <% LANGUAGE %> 的断言到位 ✅

覆盖了基础路径,建议后续追加一个“当前语言不在 supportedLngs 中返回全 false”的集成断言(与 language.spec 相呼应)。

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between fc95fd9 and c69dabc.

📒 Files selected for processing (4)
  • packages/runtime/src/internal/compute/evaluate.spec.ts (4 hunks)
  • packages/runtime/src/internal/compute/evaluate.ts (2 hunks)
  • packages/runtime/src/internal/compute/language.spec.ts (1 hunks)
  • packages/runtime/src/internal/compute/language.ts (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: CI
packages/runtime/src/internal/compute/language.ts

[error] 9-9: Command failed: tsc --emitDeclarationOnly --declaration --declarationDir dist/types --project tsconfig.build.json. TS2339: Property 'options' does not exist on type 'typeof import(/home/runner/work/next-core/next-core/node_modules/i18next/index)'.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: update (20.x)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (5)
packages/runtime/src/internal/compute/language.spec.ts (1)

48-51: 用例覆盖良好 ✅

包含对 cimode 过滤、空配置、仅 resources 推导与“当前语言不在列表”边界的断言,能有效保护回退与布尔映射逻辑。

Also applies to: 104-116, 148-162, 182-193

packages/runtime/src/internal/compute/evaluate.ts (1)

47-47: 引入 LANGUAGE 依赖的导入位置与扩展名一致 ✅

与项目现有相对导入风格保持一致(.js 扩展名),无循环依赖风险。

packages/runtime/src/internal/compute/evaluate.spec.ts (3)

85-86: 测试初始化补充 supportedLngs 合理 ✅

与 LANGUAGE 行为强相关,确保解析出的语言集合可预期。


259-260: 在每个用例前切换到 zh,避免语言状态串扰 ✅


297-298: Widget I18N 期望值改为“世界”与当前语言保持一致 ✅

Comment on lines 1 to 2
import i18n from "i18next";
import { getSupportedLanguages } from "./language";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

测试应与生产一致地复用同一 i18n 实例

生产代码应从 @next-core/i18n 获取实例,建议测试也改为相同来源,避免测试与运行时各用一套实例导致行为偏差。

应用如下 diff:

-import i18n from "i18next";
+import { i18n } from "@next-core/i18n";
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import i18n from "i18next";
import { getSupportedLanguages } from "./language";
import { i18n } from "@next-core/i18n";
import { getSupportedLanguages } from "./language";
🤖 Prompt for AI Agents
In packages/runtime/src/internal/compute/language.spec.ts lines 1-2, the test
imports a fresh i18n from "i18next" which creates a separate instance from
production; change the test to import the shared i18n instance from
"@next-core/i18n" so tests and runtime reuse the same i18n instance, update the
import statement accordingly and remove the direct "i18next" import.

@@ -0,0 +1,33 @@
import i18n from "i18next";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

修复 CI:错误的 i18n 导入导致 TS2339(options 不存在)

这里从 "i18next" 默认导入拿到的是模块类型而非实例,导致 i18n.options 报错。应统一与其余代码使用同一实例:@next-core/i18n

应用如下 diff:

-import i18n from "i18next";
+import { i18n } from "@next-core/i18n";
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import i18n from "i18next";
import { i18n } from "@next-core/i18n";
🤖 Prompt for AI Agents
In packages/runtime/src/internal/compute/language.ts around line 1, the file
currently imports the i18next module instead of the shared i18n instance which
causes TS2339 when accessing i18n.options; update the import to use the
project-wide instance by replacing `import i18n from "i18next";` with `import
i18n from "@next-core/i18n";` so the code uses the same initialized instance and
typings as the rest of the codebase.

Comment on lines 3 to 7
export interface SupportedLanguages {
en: boolean;
zh: boolean;
[key: string]: boolean;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

类型定义与实现不一致(会返回不含 zh 的对象)

SupportedLanguagesen/zh 标为必填,但实现当仅有单语言(如 "en")时会返回 { en: true }。建议改为通用映射类型,或将 en/zh 设为可选。

建议采用更简单的定义:

-export interface SupportedLanguages {
-  en: boolean;
-  zh: boolean;
-  [key: string]: boolean;
-}
+export type SupportedLanguages = Record<string, boolean>;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export interface SupportedLanguages {
en: boolean;
zh: boolean;
[key: string]: boolean;
}
export type SupportedLanguages = Record<string, boolean>;
🤖 Prompt for AI Agents
In packages/runtime/src/internal/compute/language.ts around lines 3 to 7, the
SupportedLanguages interface marks en and zh as required but the code can return
objects like { en: true } without zh; change the type to match runtime output by
replacing the interface with a general mapping (e.g., Record<string, boolean>)
or make en and zh optional (en?: boolean; zh?: boolean), and update any
callers/assignments to satisfy the new type so implementations that only include
a single language no longer violate the type.

Comment on lines 11 to 24
const s = opt.supportedLngs;
let lngs: string[] = [];
if (Array.isArray(s)) {
lngs = s.filter((lng) => lng !== "cimode");
}

if (typeof s === "string" && s) {
lngs = [s];
}

// fallback: 从 resources 中取 key
if (opt.resources && typeof opt.resources === "object") {
lngs = Object.keys(opt.resources);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

“resources 作为兜底”逻辑写成了“覆盖”——应仅在前面未取到时才回退

当前无条件用 resources 覆盖 supportedLngs,与注释“fallback”不符。

应用如下修正,并统一过滤 cimode

-  const s = opt.supportedLngs;
-  let lngs: string[] = [];
-  if (Array.isArray(s)) {
-    lngs = s.filter((lng) => lng !== "cimode");
-  }
-  if (typeof s === "string" && s) {
-    lngs = [s];
-  }
-  // fallback: 从 resources 中取 key
-  if (opt.resources && typeof opt.resources === "object") {
-    lngs = Object.keys(opt.resources);
-  }
+  const s = opt.supportedLngs as unknown;
+  let lngs: string[] = [];
+  if (Array.isArray(s)) {
+    lngs = s.filter((lng) => lng && lng !== "cimode");
+  } else if (typeof s === "string" && s) {
+    lngs = [s];
+  }
+  // fallback: 仅当未从 supportedLngs 获取到时,从 resources 中取 key
+  if (!lngs.length && opt.resources && typeof opt.resources === "object") {
+    lngs = Object.keys(opt.resources).filter((lng) => lng && lng !== "cimode");
+  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const s = opt.supportedLngs;
let lngs: string[] = [];
if (Array.isArray(s)) {
lngs = s.filter((lng) => lng !== "cimode");
}
if (typeof s === "string" && s) {
lngs = [s];
}
// fallback: 从 resources 中取 key
if (opt.resources && typeof opt.resources === "object") {
lngs = Object.keys(opt.resources);
}
const s = opt.supportedLngs as unknown;
let lngs: string[] = [];
if (Array.isArray(s)) {
lngs = s.filter((lng) => lng && lng !== "cimode");
} else if (typeof s === "string" && s) {
lngs = [s];
}
// fallback: 仅当未从 supportedLngs 获取到时,从 resources 中取 key
if (!lngs.length && opt.resources && typeof opt.resources === "object") {
lngs = Object.keys(opt.resources).filter((lng) => lng && lng !== "cimode");
}
🤖 Prompt for AI Agents
In packages/runtime/src/internal/compute/language.ts around lines 11 to 24, the
current code unconditionally overwrites supportedLngs with opt.resources
(contradicting the "fallback" comment); change the logic so resources are used
only if no languages were obtained from supportedLngs (array or string), and
always filter out "cimode" from the final list; i.e., compute lngs from
opt.supportedLngs when present (handle array and string cases), then if lngs is
empty and opt.resources is an object set lngs = Object.keys(opt.resources), and
finally apply a filter to remove "cimode".

Closes CMDB_INSTANCE-3369
@WHChen-Alex WHChen-Alex force-pushed the alex/supportLanguageV3 branch from c69dabc to ac0ed0d Compare September 16, 2025 07:32
@codecov
Copy link

codecov bot commented Sep 16, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.21%. Comparing base (fc95fd9) to head (ac0ed0d).
⚠️ Report is 2 commits behind head on v3.

Files with missing lines Patch % Lines
.../runtime/src/internal/compute/getGeneralGlobals.ts 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##               v3    #4783      +/-   ##
==========================================
- Coverage   95.22%   95.21%   -0.02%     
==========================================
  Files         210      210              
  Lines        9175     9176       +1     
  Branches     1768     1769       +1     
==========================================
  Hits         8737     8737              
  Misses        324      324              
- Partials      114      115       +1     
Files with missing lines Coverage Δ
.../runtime/src/internal/compute/getGeneralGlobals.ts 93.10% <0.00%> (-3.33%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cypress
Copy link

cypress bot commented Sep 16, 2025

next-core    Run #11662

Run Properties:  status check passed Passed #11662  •  git commit ad8ed34e51 ℹ️: Merge ac0ed0dfef1d0c01c5dfff87eb45896d17ed81ee into fc95fd9315605585d3047650df90...
Project next-core
Branch Review alex/supportLanguageV3
Run status status check passed Passed #11662
Run duration 00m 22s
Commit git commit ad8ed34e51 ℹ️: Merge ac0ed0dfef1d0c01c5dfff87eb45896d17ed81ee into fc95fd9315605585d3047650df90...
Committer Chén Wénháo
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 17
View all changes introduced in this branch ↗︎

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
packages/runtime/src/internal/compute/getGeneralGlobals.ts (2)

84-86: 语言值建议标准化,避免返回 en-US/zh-CN 造成下游判定失配

直接用 i18n.language 可能返回区域化代码或空串。建议优先 resolvedLanguage,再按 supportedLngs 抽取基语言,最后保持与现有默认一致的回退值。

-    case "LANGUAGE": {
-      return collectCoverage ? "zh" : i18n.language || "zh";
-    }
+    case "LANGUAGE": {
+      if (collectCoverage) return "zh";
+      const lang =
+        // i18next >=21 暴露 resolvedLanguage;旧版本没有则回退 language
+        (i18n as any).resolvedLanguage ?? i18n.language ?? "";
+      const supported = (i18n.options?.supportedLngs as string[] | undefined) ?? [];
+      const base = lang.split("-")[0] || "";
+      return supported.includes(lang)
+        ? lang
+        : supported.includes(base)
+        ? base
+        : lang || "zh";
+    }

84-86: 覆盖模式下 LANGUAGE=zh 与 I18N_TEXT(en) 的假实现不一致

collectCoverage 时 LANGUAGE 固定为 zh,但 fakeI18nTextdata.en,两者组合可能产生自相矛盾的断言。二选一以保持一致:

  • 方案 A(更动最小):覆盖模式改为返回 "en"。
-      return collectCoverage ? "zh" : i18n.language || "zh";
+      return collectCoverage ? "en" : i18n.language || "en";
  • 方案 B(保留 LANGUAGE=zh):调整 fakeI18nText 优先 zh 回退 en(此变更位于本段之外,仅示例)。
function fakeI18nText(data: Record<string, string>): string {
  return data?.zh ?? data?.en;
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between c69dabc and ac0ed0d.

📒 Files selected for processing (2)
  • packages/runtime/src/internal/compute/evaluate.spec.ts (4 hunks)
  • packages/runtime/src/internal/compute/getGeneralGlobals.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/runtime/src/internal/compute/evaluate.spec.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build (20.x)
  • GitHub Check: Analyze (javascript-typescript)

Comment on lines +84 to +86
case "LANGUAGE": {
return collectCoverage ? "zh" : i18n.language || "zh";
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 Analysis chain

同步公开契约:为新全局 LANGUAGE 补齐类型/文档/清单

新增全局需同步到:API 文档、d.ts/类型提示、表达式/DSL 提示、dll manifest/白名单、CHANGELOG。请确认并补齐。


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# 1) 搜索是否已有白名单/类型里显式列出全局名
rg -nP -C2 '\b(BASE_URL|I18N_TEXT|I18N|THEME|PERMISSIONS|console|location|LANGUAGE)\b' -S

# 2) 检查 d.ts 是否已包含 LANGUAGE
fd -t f -e d.ts | xargs rg -n 'LANGUAGE' -n || true

# 3) 文档与变更记录
rg -n 'LANGUAGE' docs CHANGELOG.md -S || true

# 4) 可能的 dll manifest/白名单文件
fd -i -t f 'manifest' | xargs rg -n 'LANGUAGE' -n || true

# 5) 用例覆盖
rg -n 'LANGUAGE' -g '!**/node_modules/**' -S

Length of output: 267155


补齐公开契约:为新全局 LANGUAGE 补齐类型/文档/清单

检查结果:LANGUAGE 已在 runtime 中新增并被单测使用,但未在类型/白名单/文档/CHANGELOG 中登记。
需要补齐的项(最小可交付):

  • 类型 / 白名单:将 LANGUAGE 加入 packages/types/src/manifest.ts(或仓库中负责表达式全局的类型/manifest)并新增/更新相关 .d.ts,保证 IDE 类型提示。
  • 表达式 / DSL 提示:更新表达式提示/文档生成逻辑(doc-helpers 或 docs 源)以暴露 LANGUAGE 给编辑器/DSL 用户。
  • dll manifest / 白名单:在 bricks/manifest 或项目的白名单文件中加入 LANGUAGE(以便打包/运行时允许)。
  • CHANGELOG:在 packages/runtime/CHANGELOG.md(或受影响包的 CHANGELOG)记录新增全局及兼容说明。

参考位置(便于快速修改):

  • 使用处:packages/runtime/src/internal/compute/getGeneralGlobals.ts — case "LANGUAGE"(行 84–86)
  • 单测:packages/runtime/src/internal/compute/evaluate.spec.ts — 测试 "<% LANGUAGE %>"(行 ~324)
    我可协助生成所需的 d.ts/manifest/文档补丁或 PR。

@weareoutman weareoutman merged commit 8a0456e into v3 Sep 16, 2025
7 of 8 checks passed
@weareoutman weareoutman deleted the alex/supportLanguageV3 branch September 16, 2025 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants