@cobre-npm/portal-widgets

中文文档
0.49.0发布于 2026/11/10TypeScriptES Module近 30 天下载 4022

Embeddable Vue 3 widgets for Cobre's portal, published to npm and consumed by the portal shell and by any other host app. vue and vue-i18n are external — the host provides them.

原始使用文档
文档目录5 节
  1. Scripts
  2. Testing
  3. The coverage floor ratchets
  4. Where this gate is enforced
  5. Architecture

@cobre-npm/portal-widgets

Embeddable Vue 3 widgets for Cobre's portal, published to npm and consumed by the portal shell and by any other host app. vue and vue-i18n are external — the host provides them.

Scripts

ScriptWhat it does
pnpm devVite dev harness (src/main.ts)
pnpm buildBuild the publishable library into dist/ + emit types into dist/types/
pnpm testThe whole gate: the suite, coverage against the floor, and the ratchet
pnpm lintLint & auto-fix with ESLint

Testing

pnpm test runs three things in order, and any one of them going red fails the build:

  1. The suite — Vitest over src/**/*.{test,spec}.ts.
  2. Coverage — enforced against the thresholds in coverage-floor.json.
  3. The ratchet — scripts/check-invariants.mjs, which compares the floor against the base ref.

src/repo-invariants.test.ts guards the shape of the gate rather than its numbers: that the thresholds are read from coverage-floor.json and not inlined, that all four metrics are declared, that no whole widget directory gets excluded to shrink the denominator, and that the test script still invokes a real runner with no --passWithNoTests. Without it the gate can be defeated without touching a number the ratchet watches.

The lane covers src/**/*.ts minus tests, type-only modules, enums, locales, mocks, constants, barrels and the dev entry. The .vue components are deliberately not in the denominator: unlike ds-v3 this package has no story lane, so there is no binary render gate to pair a percentage with, and folding the untested components into one number would measure the absence of a render lane rather than the logic (ADR-0008).

The coverage floor ratchets

coverage-floor.json is a floor, not a target. It holds what the repo measured the day the gate was switched on (2026-09-17), not 95%, because there is no retroactive backfill — a gate nobody can adopt on day one is a gate nobody turns on.

It may only rise. scripts/check-invariants.mjs fails when any number in it drops below the value on the base ref, when a metric is removed altogether, or when the base ref does not resolve — a ratchet that silently did not run is indistinguishable from one that passed, which is the defect this whole gate exists to remove. Lowering the floor in the same commit that breaks it is exactly what the ratchet exists to prevent.

When you add tests and coverage rises, raise the floor in the same PR. That is the whole mechanism.

Outside CI the ratchet is a no-op unless you give it a base ref:

node scripts/check-invariants.mjs --base origin/trunk

Where this gate is enforced

The pipeline is not in this repo. It lives in Cobre-Colombia/circleci-library at pipes/npm/config-frontend-libraries.yml, whose build_unit job runs eval "CI=true ${TEST_CMD:-npm test}".

This package has no .env file in that repo's config/frontend-libraries-project-overrides/, so build_unit falls through to its default npm test — and that default is the gate. The absence is deliberate rather than an oversight: the pipe needs no override for this step to run, and an override here could only weaken the command the package already defines for itself.

If one is ever added, it must not carry a TEST_CMD of the vitest ... --passWithNoTests shape. That is exactly what neutralised util-ds: the step ran, reported success, and could never fail.

CI=true is also what switches the ratchet on: without it check-invariants.mjs has no base ref and exits 0.

Architecture

See CLAUDE.md for the widget layout, the export surface, the localization pattern and the code style rules.

版本与发布记录

@cobre-npm/portal-widgets 共发布 83 个版本,首次发布于 2026/02/12;过去 12 个月发布了 83 个版本。

版本发布日期距今
0.49.0latest2026/11/10今天
0.48.02026/11/063 天前
0.46.02026/11/064 天前
0.45.02026/11/045 天前
0.44.62026/11/036 天前
0.44.52026/10/3011 天前

关于 @cobre-npm/portal-widgets 的常见问题

@cobre-npm/portal-widgets 是什么?

Embeddable Vue 3 widgets for Cobre's portal, published to npm and consumed by the portal shell and by any other host app. vue and vue-i18n are external — the host provides them.

如何安装 @cobre-npm/portal-widgets?

在项目目录运行 npm install @cobre-npm/portal-widgets,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:vue(^3.5.0)、vue-i18n(>=11.0.0)、bootstrap(^5.3.8)、vue-collapsed(^1.1.0)、@cobre-npm/ds-v3(>=0.169.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cobre-npm/portal-widgets 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cobre-npm/portal-widgets 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cobre-npm/portal-widgets 可以商用吗?

@cobre-npm/portal-widgets 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@cobre-npm/portal-widgets 的下载量有多少?

根据 npm 官方下载统计,@cobre-npm/portal-widgets 在 2026/10/10 – 2026/11/08 这 30 天内被下载 4,022 次,日均约 134 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cobre-npm/portal-widgets 还在维护吗?

最新版本 0.49.0 发布于 2026/11/10(今天);至今共发布 83 个版本,其中过去 12 个月发布了 83 个;首次发布于 2026/02/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。