@aurelienbbn/conformance-alchemy

中文文档
0.1.1发布于 2026/10/14MITTypeScriptES Module构建来源已验证近 30 天下载 1915

Structural conformance checks for Alchemy v2 projects: state, CI, previews, pinning. Packaged as a Vitest suite.

原始使用文档
文档目录10 节
  1. One file, four tests
  2. Checks
  3. alchemy-pinned-exact
  4. alchemy-state-gitignored
  5. ci-uses-remote-state
  6. preview-cleanup
  7. Options
  8. Sources
  9. Registered contract inventory
  10. Credited concepts

@aurelienbbn/conformance-alchemy

npm downloads CI license node

4 checks that catch Alchemy v2 setups that deploy fine once and then lose track of your infrastructure: state committed to git, CI deploys on local state, PR previews nobody destroys, and a floating beta version.

 alchemy.run.ts ────┐
 .gitignore + git ──┼─▶ alchemyChecks (4) ─▶ report { passed | incomplete | failed }   Vitest or plain function
 .github/workflows ─┤
 package.json(s) ───┘

[!WARNING] Release candidate, checked against [email protected], one known consumer. Alchemy's CLI and state API still move between betas; alchemy plan stays authoritative for what a deploy will do.

One file, four tests

// conformance.test.ts
import { alchemyConformance } from "@aurelienbbn/conformance-alchemy/vitest";

alchemyConformance({ root: process.cwd() });

Errors fail; warnings print. Missing evidence (no workflows directory, a package script run from a directory set at run time) shows as a skipped test, never a pass. vitest is an optional peer; Node ^22.19.0 || ^24.11.0.

import { runAlchemyConformanceReport } from "@aurelienbbn/conformance-alchemy";

const report = await runAlchemyConformanceReport({ root: process.cwd() }); // { status, checks[], findings[] }
EvaluationCauseVitestReport status
evaluatedran to completion; can still hold errors✅ / ❌passed/failed
skippedlisted in skipChecks⏭️incomplete
unsupportedno workflows, a script or directory it cannot resolve, an unrecognized state:⏭️incomplete
failedno stack file, no alchemy dependency, invalid YAML/JSON/TypeScript, a throw❌failed

Findings carry check, severity, message, path, a docs URL, and evaluation when evidence is missing.

Checks

CheckFails when
alchemy-pinned-exacta workspace package.json (or the pnpm catalog it points to) gives alchemy a range on a pre-1.0 or prerelease line
alchemy-state-gitignoreda directory holding a stack file has no committed rule ignoring .alchemy/, or .alchemy/ files are already tracked
ci-uses-remote-statea workflow step runs alchemy deploy or destroy against a stack whose state: is localState() or inMemoryState()
preview-cleanupa workflow deploys a pr-* stage with no alchemy destroy of a pr-* stage on pull_request closed; a destroy can hit prod
What each check catches, and its limits

alchemy-pinned-exact

"alchemy": "^2.0.0-beta.79"  // ❌ the next lockfile refresh can pull a breaking beta
"alchemy": "catalog:"        // ❌ when pnpm-workspace.yaml has `alchemy: ~2.0.0-beta.79`
"alchemy": "2.0.0-beta.79"   // ✅ also through `catalog:` / `catalog:<name>` resolving to it

Betas break without a major bump: 2.0.0-beta.78 made every non-interactive alchemy deploy under bun crash in the CLI renderer (alchemy#1689). Reads dependencies, devDependencies, and optionalDependencies of the root manifest and every member of pnpm-workspace.yaml packages or package.json workspaces. A range whose lower bound is a stable 1.0+ release stays silent. workspace:, file:, link:, and git specs → ⚠️ unsupported. A catalog: with no matching entry → ❌ failed. The lockfile is not read.

alchemy-state-gitignored

# apps/api/alchemy.run.ts
dist/            # ❌ apps/api/.alchemy/ is not ignored
.alchemy/        # ✅ root or apps/api/.gitignore; `.alchemy`, `.alchemy/*`, `**/.alchemy` work too

localState() writes .alchemy/state/<stack>/<stage>/*.json, resource outputs included, under the CLI's working directory. The probe is <stack dir>/.alchemy/state/. Inside a git work tree it asks git check-ignore --no-index, so every rule git applies counts, then rejects matches from .git/info/exclude or a global excludes file: teammates don't share them. git ls-files also fails state that is already committed. Without git (not a work tree, no git binary), it reads the .gitignore files from root down to the stack directory with git's pattern rules; files above root are not read. A --config stack run from another directory writes .alchemy/ there, which this check does not follow.

ci-uses-remote-state

state: localState(),                                          // ❌ with any CI `alchemy deploy`/`destroy` of this stack
state: Cloudflare.state(),                                    // ✅ also AWS.state(), postgresState()
state: process.env.CI ? Cloudflare.state() : localState(),    // ⚠️ warns: confirm CI takes the remote branch

A CI runner discards .alchemy/state with the job: the next deploy starts from empty state and collides with live resources, and a destroy plans nothing and leaks them. Finds alchemy <command> in every run: step: bare, npx/bunx/pnpx, pnpm [exec|dlx], yarn [dlx], bun [x|run], npm exec, with cd <dir> &&, working-directory and defaults.run. Package scripts (pnpm ship, npm run ship, bun run ship, yarn ship) are read from the nearest package.json and followed two levels deep, with forwarded arguments appended (bun run deploy --stage pr-1; npm only after --). Package selection resolves -C/--dir/--prefix/--cwd, -w/--workspace, -ws, -r, yarn workspace <name>, and --filter/-F by name or path glob. Anything else that runs a script is reported as unsupported, never dropped: a directory from ${{ matrix.* }} or $VAR, --filter graph selectors (pkg..., !pkg, {dir}), yarn workspaces foreach, a third nested script, an unreadable package.json. deploy --dry-run counts as a plan. The stack file is <cwd>/<--config or positional or alchemy.run.ts>, parsed with oxc: state: in Stack(...), Alchemy.Stack(...), or Stack.make(...), store constructors recognized only through their alchemy, alchemy/State, alchemy/Cloudflare, alchemy/AWS imports, top-level consts followed. A workflow with no Alchemy command passes: there is nothing to lose.

preview-cleanup

- run: alchemy deploy --stage pr-${{ github.event.number }} # ❌ alone: every closed PR leaves resources running
# ✅ plus, in a workflow on `pull_request: types: [closed]`:
- run: alchemy destroy --stage pr-${{ github.event.number }}
- run: alchemy destroy --stage prod # ❌ never destroy production from CI

The stage is --stage, else ALCHEMY_STAGE, with ${{ env.X }}, $X, ${X} substituted from workflow, job, and step env (twice, so a job value reading the workflow env resolves). A stage containing pr- is a preview, which covers the shared STAGE: ${{ ... format('pr-{0}', ...) || 'prod' }} pattern of the Alchemy CI guide. The destroy must target the same stack file, unless either side's directory is dynamic. A destroy whose stage is literally prod / production fails; one whose expression contains either word fails unless a step of the same job, up to the destroy, runs exit 1 and names either production (the guide's deny check) or pr- (an allow-list like case "$STAGE" in pr-*) ;; *) exit 1;; esac); the guard's condition is not evaluated. An unresolved script in a closed workflow turns a missing cleanup into ⚠️ unsupported, since that script may be the destroy. A branch literally named prod reaching github.ref_name is invisible to this literal check.

Options

OptionDefaultUsed by
rootrequired: the repository rootall
skipChecks[] (unknown ids throw)all
stackFiles["**/alchemy.run.ts"], no node_modulesalchemy-state-gitignored
workflowsDir.github/workflowsci-uses-remote-state, preview-cleanup

Not checked, owned elsewhere: whether a deploy succeeds (alchemy plan), provider credentials in CI (alchemy provider check-env), CI=true for Cloudflare.state(), stages set via $GITHUB_ENV, reusable workflows and composite actions, CI systems other than GitHub Actions.

Sources

Independent implementations of Alchemy's State Store, CI, and Stages guides and the deploy / destroy references, reviewed 2026-09-25 against [email protected] source (State/LocalState.ts, Stack.ts, Cli/commands/flags.ts), and of alchemy#1689. Source carries greppable @attribution tags.

Registered contract inventory

Generated from package exports by pnpm catalog. Rule-specific options and limitations are described above and in the source tests.

Rule/checkTrigger or review scope
alchemy-pinned-exactEvery workspace package.json pins alchemy to an exact version (pnpm catalogs resolved) while Alchemy is pre-1.0 or a prerelease.
alchemy-state-gitignoredEvery directory holding a stack file ignores .alchemy/ in a committed .gitignore.
ci-uses-remote-stateEvery CI alchemy deploy or destroy targets a stack with a remote state store, not localState().
preview-cleanupEvery CI deploy to a pr-* stage has a matching alchemy destroy on pull_request closed, and no destroy can target prod.

Credited concepts

版本与发布记录

@aurelienbbn/conformance-alchemy 共发布 2 个版本,首次发布于 2026/09/28;过去 12 个月发布了 2 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.1latest2026/10/1424 天前
0.1.02026/09/281 个月前

关于 @aurelienbbn/conformance-alchemy 的常见问题

@aurelienbbn/conformance-alchemy 是什么?

Structural conformance checks for Alchemy v2 projects: state, CI, previews, pinning. Packaged as a Vitest suite.

如何安装 @aurelienbbn/conformance-alchemy?

在项目目录运行 npm install @aurelienbbn/conformance-alchemy,或使用 pnpm add / yarn add / bun add。

@aurelienbbn/conformance-alchemy 支持 TypeScript 吗?

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

@aurelienbbn/conformance-alchemy 支持 ESM 还是 CommonJS?

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

@aurelienbbn/conformance-alchemy 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^22.19.0 || ^24.11.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@aurelienbbn/conformance-alchemy 可以商用吗?

@aurelienbbn/conformance-alchemy 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@aurelienbbn/conformance-alchemy 的下载量有多少?

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

@aurelienbbn/conformance-alchemy 还在维护吗?

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