Compare commits

..
3 Commits
Author SHA1 Message Date
que01 c2bd956b07 docs: 更新项目状态与交付证据
CI / API integration (push) Has been cancelled
CI / Taro builds (acheng-campus-food) (push) Has been cancelled
CI / Taro builds (atelier-solopreneur) (push) Has been cancelled
CI / Taro builds (linjing-editorial) (push) Has been cancelled
CI / Browser regression (push) Has been cancelled
CI / Static checks (push) Has been cancelled
CI / Production build (push) Has been cancelled
2026-10-21 10:22:44 +08:00
que01 b101d169c9 fix: 前置发布构建的 Node 版本门禁 2026-10-21 10:22:44 +08:00
que01 ab17f80607 fix: 修正品牌创建与页面方案交互 2026-10-21 10:22:44 +08:00
7 changed files with 412 additions and 20 deletions

No files matched your search

+66 -17
View File
@@ -1,26 +1,68 @@
# Project Status
最后更新:2026-10-20
最后更新:2026-10-21
## 当前阶段
系统已从“餐饮试点小程序”演进为多模板个人品牌平台。当前分支完成了统一模板契约收口、模板完成证据门禁、管理员登录态撤销和 release 版本一致性修复。
系统已从“餐饮试点小程序”演进为多模板个人品牌平台。当前已完成统一模板契约收口、模板完成证据门禁、品牌与页面方案拆分、管理员登录态撤销和 release 版本一致性修复。
ADR 0033 已落地:
- “表达方式”已从 Admin 源码移除。
- “业务类型”和“页面方案”是两个独立概念。
- 新增“创建品牌”和“页面方案”页面。
- 创建品牌不会自动导入示例内容。
- `linjing-editorial` 只兼容 `doors`,不再兼容 `personal`。
## 当前能力
- NestJS + Fastify API、Prisma PostgreSQL、全局 DTO 校验、统一错误响应和 `requestId`。
- 多品牌 Admin、品牌 membership、角色边界、品牌切换和品牌隔离。
- 创建品牌时按业务类型筛选兼容的页面方案;不兼容组合无法提交。
- 模板包发现、确定性打包、导入、校验、发布、预览、安装、升级和回滚。
- 三套已交付模板:
- `acheng-campus-food@1.0.3`
- `atelier-solopreneur@1.3.2`
- `linjing-editorial@1.0.7`
- 三套已交付模板及其业务类型:
- `acheng-campus-food@1.0.3`:`food`
- `atelier-solopreneur@1.3.2`:`personal`
- `linjing-editorial@1.0.7`:`doors`
- Taro Runtime、Admin 组件预览、真实 manifest 驱动编辑、草稿/发布隔离。
- 发布备注为可选字段;空备注不会写入数据库,也不影响发布、回滚和公开内容。
- 依赖 override 的运行时兼容性通过 `miniprogram-ci` / Jimp / image-size / uuid smoke test 守卫。
- 小程序构建、上传任务状态机、attempt lease 和失败记录。
- Admin/Customer token version:修改 admin 密码或调用 logout 后旧 token 立即失效;无 membership 的账号不会自动获得 owner 权限。
- `visualPresentation` 已进入唯一 `template.json` 契约,旧手写 visual manifest 优先路径已删除。
## 生产状态
当前生产 release:
```text
20261021013244-6df4e1d72b6a
```
生产健康检查:
```text
api=online
pm2-autostart=enabled
admin=active
database=running
backups=7
/admin/ 200
/template-preview/ 200
/api/health 200
/media/seed/food-package-02.jpg 200
```
生产数据库已应用全部 48 个 Prisma migration,schema 为 up to date。
三个生产品牌的当前发布快照:
| 品牌 | 业务类型 | 页面方案 | 发布版本 |
| ---------------- | ---------- | --------------------------- | ------------ |
| `atelier-studio` | `personal` | `atelier-solopreneur@1.3.2` | `v2 current` |
| `default-brand` | `food` | `acheng-campus-food@1.0.3` | `v2 current` |
| `linjing-doors` | `doors` | `linjing-editorial@1.0.7` | `v3 current` |
## 完成证据
`.codex-tasks/template-audit-execution/raw/completion-evidence.json` 登记四类证据:
@@ -38,6 +80,15 @@ completionStatus=complete
unresolvedIssues=0
```
Admin 浏览器回归新增 `apps/taro/test/browser/brand-creation-and-page-scheme.spec.ts`,覆盖:
- 创建品牌时按业务类型筛选页面方案。
- `personal` 不出现林境页面方案。
- 切换业务类型后清除不兼容的页面方案选择,提交按钮禁用。
- 创建失败时保留用户输入并显示错误。
- 页面方案切换和升级提交正确版本、校验和与冲突保留参数。
- 操作成功后刷新工作区、页面方案选项和升级预览查询。
## 已验证门禁
- `pnpm check`
@@ -46,13 +97,19 @@ unresolvedIssues=0
- `pnpm --filter @personal-brand/api test:integration`
- `miniprogram-ci` override 兼容 smoke test
- `pnpm test:api-client`
- `pnpm test:deploy`
- `pnpm --filter @personal-brand/admin typecheck`
- `pnpm --filter @personal-brand/admin lint`
- `pnpm --filter @personal-brand/admin test`
- `pnpm --filter @personal-brand/admin build`
- `pnpm build`
- `pnpm template:doctor`
- Playwright:
- `brand-creation-and-page-scheme.spec.ts`
- `template-preview-media.spec.ts`
- `admin-editor.spec.ts`
本机数据库已应用全部 46 个 Prisma migration,`prisma migrate status` 为 up to date。
发布脚本的 Node 版本门禁已提前到所有构建之前。Node 22 下执行 `pnpm deploy:release` 会立即失败,并给出 Node.js 24 要求提示,不再先执行一轮无用构建。
## 安全审计
@@ -61,17 +118,9 @@ unresolvedIssues=0
- 剩余 8 条为 `miniprogram-ci@2.1.31` 无修复版本的上游 advisory,已在 `pnpm.auditConfig.ignoreGhsas` 和 `docs/security-audit.md` 中显式登记风险、控制措施与跟进条件。
- Taro 官方 peer 仍声明 Vite 4;当前使用 Vite 6.4.3,H5 与 Weapp 实际构建均通过,peer warning 记录在安全审计文档。
## 本机数据状态
- 本机数据库 schema 已 up to date。
- 当前三个新版本已通过模板导入服务导入并发布:
- `acheng-campus-food@1.0.3`
- `atelier-solopreneur@1.3.2`
- `linjing-editorial@1.0.7`
- 既有品牌安装仍锁定各自原版本,需通过 Admin 的显式升级流程升级,不在本任务中静默变更。
## 未决事项
- 生产发布仍需按 `docs/deployment.md` 配置真实环境变量并执行部署后健康检查。
- 本次源码新增的 Admin 浏览器回归、页面方案查询缓存修复和 Node 门禁修复尚未部署到生产;部署后需更新本节的生产 release 和验证结果。
- `miniprogram-ci` 上游发布修复版本后,需要移除对应的 audit ignore、风险登记和本地 patch。
- Gitea SSH 直连仍受 OCI 安全列表限制;当前本机通过 `oracle_arm` ProxyCommand 转发访问,不阻塞业务。
- CI 已加入 audit 和三套模板矩阵构建;后续可继续拆分更细粒度的 smoke/visual matrix。
@@ -28,6 +28,7 @@ export function CreateBrandPage() {
const navigate = useNavigate();
const [form] = Form.useForm<CreateBrandInput>();
const businessType = Form.useWatch("businessType", form);
const selectedSchemeId = Form.useWatch("templatePackageVersionId", form);
const options = useQuery({
queryKey: ["admin-brand-creation-options"],
queryFn: () => client.getAdminBrandCreationOptions(),
@@ -190,7 +191,10 @@ export function CreateBrandPage() {
htmlType="submit"
size="large"
loading={create.isPending}
disabled={!businessType || schemes.length === 0}
disabled={
!businessType ||
!schemes.some((scheme) => scheme.templatePackageVersionId === selectedSchemeId)
}
>
创建并进入品牌
</Button>
@@ -43,6 +43,7 @@ export function PageSchemePage() {
const refresh = () => {
for (const queryKey of [
"page-scheme-workspace",
"admin-page-scheme-options",
"page-scheme-upgrade-preview",
"admin-workspace",
"admin-preview-workspace",
@@ -0,0 +1,315 @@
import { test, expect, type Page, type Route } from "@playwright/test";
const adminOrigin = process.env.ADMIN_URL || "http://localhost:3005";
const businesses = [
{ key: "personal", name: "个人品牌", description: "适合独立创作者与个人工作室" },
{ key: "doors", name: "门作品牌", description: "适合门作、木作与建筑空间业务" },
{ key: "food", name: "餐饮品牌", description: "适合餐饮与本地生活业务" },
];
const pageSchemes = [
{
templatePackageVersionId: "atelier-v132",
name: "独立创作者画册",
description: "个人品牌页面方案",
version: "1.3.2",
supportedBusinessTypes: ["personal"],
isLatestForPackage: true,
},
{
templatePackageVersionId: "linjing-v107",
name: "林境建筑画册",
description: "门作品牌页面方案",
version: "1.0.7",
supportedBusinessTypes: ["doors"],
isLatestForPackage: false,
},
{
templatePackageVersionId: "linjing-v108",
name: "林境建筑画册",
description: "门作品牌页面方案",
version: "1.0.8",
supportedBusinessTypes: ["doors"],
isLatestForPackage: true,
},
{
templatePackageVersionId: "food-v103",
name: "阿成校园餐饮",
description: "餐饮品牌页面方案",
version: "1.0.3",
supportedBusinessTypes: ["food"],
isLatestForPackage: true,
},
];
const currentBrand = {
id: "brand-current",
name: "独立工坊",
slug: "atelier-studio",
templateKey: "personal",
};
const memberships = [{ id: "membership-current", role: "owner", brand: currentBrand }];
interface ApiMockOptions {
createStatus?: number;
onCreate?: (body: Record<string, unknown>) => void;
onSelectVersion?: (body: Record<string, unknown>) => void;
onUpgrade?: (body: Record<string, unknown>) => void;
}
async function mockAdminApi(page: Page, options: ApiMockOptions = {}) {
let createStatus = options.createStatus ?? 200;
let currentVersion = "1.0.7";
let currentPackageVersionId = "linjing-v107";
await page.route("**/api/**", async (route: Route) => {
const request = route.request();
const url = new URL(request.url());
const path = url.pathname.replace(/^\/api/, "");
const method = request.method();
if (path === "/admin/session/current") {
return route.fulfill({
json: {
authenticated: true,
displayName: "品牌负责人",
role: "owner",
mustChangePassword: false,
platformTemplateRole: "none",
},
});
}
if (path === "/admin/config/brand") return route.fulfill({ json: currentBrand });
if (path === "/admin/brands" && method === "GET") return route.fulfill({ json: memberships });
if (path === "/admin/brands/creation-options") {
return route.fulfill({ json: { businesses, pageSchemes } });
}
if (path === "/admin/brands" && method === "POST") {
const body = JSON.parse(request.postData() ?? "{}") as Record<string, unknown>;
options.onCreate?.(body);
if (createStatus !== 200) {
return route.fulfill({
status: createStatus,
json: {
error: { code: "BRAND_SLUG_TAKEN", message: "小程序地址标识已被使用" },
requestId: "browser-create-error",
},
});
}
return route.fulfill({
json: {
role: "owner",
brand: {
id: "brand-created",
name: body.name,
slug: body.slug,
templateKey: body.businessType,
},
},
});
}
if (path === "/admin/workspace/template/options") {
return route.fulfill({
json: {
business: businesses[1],
pageSchemes: pageSchemes.filter((scheme) =>
scheme.supportedBusinessTypes.includes("doors"),
),
},
});
}
if (path === "/admin/workspace/template/preview") {
return route.fulfill({
json: {
templateKey: "doors",
currentVersion: "1.0.7",
latestVersion: "1.0.8",
canUpgrade: true,
canRollback: false,
currentPackageVersionId: "linjing-v107",
currentContentChecksum: "current-checksum",
targetPackageVersionId: "linjing-v108",
targetContentChecksum: "target-checksum",
changes: {
brandFields: { available: false, reason: "不适用" },
templateBindings: { added: [], changed: [], removed: [] },
pages: { added: [], changed: [], removed: [] },
modules: {
available: true,
source: "platform_visual_manifest",
packageUpgradeChangesRenderer: false,
pages: [],
},
assets: {
slots: { added: [], changed: [], removed: [] },
files: { available: false, reason: "不适用" },
},
capabilities: { added: [], removed: [] },
renderer: {
available: true,
source: "platform_visual_manifest",
packageUpgradeChangesRenderer: false,
pages: [],
},
package: {
currentContentChecksum: "current-checksum",
targetContentChecksum: "target-checksum",
runtimeContract: { current: null, target: null },
},
},
conflicts: [{ key: "hero.title", binding: "brand.name", reason: "自定义标题" }],
},
});
}
if (path === "/admin/workspace/template/select-version" && method === "POST") {
options.onSelectVersion?.(JSON.parse(request.postData() ?? "{}") as Record<string, unknown>);
currentVersion = "1.0.8";
currentPackageVersionId = "linjing-v108";
return route.fulfill({ json: { selected: true } });
}
if (path === "/admin/workspace/template/upgrade" && method === "POST") {
options.onUpgrade?.(JSON.parse(request.postData() ?? "{}") as Record<string, unknown>);
currentVersion = "1.0.8";
currentPackageVersionId = "linjing-v108";
return route.fulfill({ json: { upgraded: true } });
}
if (path === "/admin/workspace") {
return route.fulfill({
json: {
brand: currentBrand,
installations: [
{
templateVersion: currentVersion,
templatePackageVersionId: currentPackageVersionId,
templateKey: "doors",
},
],
templateContent: { displayName: "林境建筑画册" },
offerings: [],
forms: [],
},
});
}
if (path === "/admin/releases/readiness") {
return route.fulfill({ json: { ready: true, checks: [] } });
}
if (
path === "/admin/config/trust-content" ||
path === "/admin/workspace/offerings" ||
path === "/admin/workspace/submissions"
) {
return route.fulfill({ json: [] });
}
return route.fulfill({ json: {} });
});
return {
failCreate: () => {
createStatus = 400;
},
};
}
test("创建品牌成功后进入新品牌工作区", async ({ page }) => {
await page.setViewportSize({ width: 1440, height: 1000 });
let createdBody: Record<string, unknown> | undefined;
await mockAdminApi(page, { onCreate: (body) => (createdBody = body) });
await page.goto(`${adminOrigin}/admin/brands/new`);
await page.getByText("个人品牌", { exact: true }).click();
await page.getByText(/最新版 1\.3\.2/).click();
await page.getByLabel("品牌名称").fill("新的独立品牌");
await page.getByLabel("小程序地址标识").fill("new-atelier");
await page.getByRole("button", { name: "创建并进入品牌" }).click();
await expect
.poll(() => createdBody)
.toEqual({
name: "新的独立品牌",
slug: "new-atelier",
businessType: "personal",
templatePackageVersionId: "atelier-v132",
});
await page.waitForURL("**/admin/overview");
await expect(page.getByRole("heading", { name: "品牌概览" })).toBeVisible();
});
test("创建品牌按业务类型过滤页面方案,失败后保留输入", async ({ page }) => {
await page.setViewportSize({ width: 1440, height: 1000 });
let createdBody: Record<string, unknown> | undefined;
const api = await mockAdminApi(page, { onCreate: (body) => (createdBody = body) });
await page.goto(`${adminOrigin}/admin/brands/new`);
await expect(page.getByRole("heading", { name: "创建品牌" })).toBeVisible();
await expect(page.getByText("先选择业务类型")).toBeVisible();
await page.getByText("个人品牌", { exact: true }).click();
await expect(page.getByText("独立创作者画册")).toBeVisible();
await expect(page.getByText("林境建筑画册")).toBeHidden();
await page.getByText("门作品牌", { exact: true }).click();
await expect(page.getByText("林境建筑画册").first()).toBeVisible();
await expect(page.getByText("独立创作者画册")).toBeHidden();
await page.getByText(/最新版 1\.0\.8/).click();
await page.getByText("个人品牌", { exact: true }).click();
await expect(page.getByRole("button", { name: "创建并进入品牌" })).toBeDisabled();
await page.getByText(/最新版 1\.3\.2/).click();
await page.getByLabel("品牌名称").fill("测试独立品牌");
await page.getByLabel("小程序地址标识").fill("test-atelier");
api.failCreate();
await page.getByRole("button", { name: "创建并进入品牌" }).click();
await expect(page.locator(".admin-error-note")).toContainText("小程序地址标识已被使用");
await expect(page.getByLabel("品牌名称")).toHaveValue("测试独立品牌");
await expect(page.getByLabel("小程序地址标识")).toHaveValue("test-atelier");
expect(createdBody).toEqual({
name: "测试独立品牌",
slug: "test-atelier",
businessType: "personal",
templatePackageVersionId: "atelier-v132",
});
});
test("页面方案切换和升级提交正确契约,并刷新查询缓存", async ({ page }) => {
await page.setViewportSize({ width: 1440, height: 1000 });
let selectBody: Record<string, unknown> | undefined;
let upgradeBody: Record<string, unknown> | undefined;
await mockAdminApi(page, {
onSelectVersion: (body) => (selectBody = body),
onUpgrade: (body) => (upgradeBody = body),
});
await page.goto(`${adminOrigin}/admin/page-scheme`);
await expect(page.getByRole("heading", { name: "页面方案" })).toBeVisible();
await expect(page.getByText("门作品牌", { exact: true })).toBeVisible();
await expect(page.getByText("正在使用版本 1.0.7")).toBeVisible();
await expect(page.getByText("独立创作者画册")).toBeHidden();
await expect(page.getByRole("button", { name: "恢复上一版配置" })).toBeDisabled();
await page.getByRole("button", { name: "切换到此版本" }).click();
await page.getByRole("button", { name: "确认切换" }).click();
await expect.poll(() => selectBody).toBeTruthy();
expect(selectBody).toEqual({
templatePackageVersionId: "linjing-v108",
expectedCurrentPackageVersionId: "linjing-v107",
confirm: true,
});
await expect(page.getByText("页面方案版本已切换")).toBeVisible();
await expect(page.getByText("正在使用版本 1.0.8")).toBeVisible();
await page.getByRole("button", { name: "升级到 1.0.8" }).click();
await expect(page.getByText("将升级到版本 1.0.8,并全部保留 1 项现有内容。")).toBeVisible();
await page.getByRole("button", { name: "确认升级" }).click();
await expect.poll(() => upgradeBody).toBeTruthy();
expect(upgradeBody).toMatchObject({
templatePackageVersionId: "linjing-v108",
expectedContentChecksum: "target-checksum",
expectedCurrentVersion: "1.0.7",
expectedCurrentPackageVersionId: "linjing-v107",
confirm: true,
preservedBindings: [{ key: "hero.title", binding: "brand.name", action: "preserve" }],
});
await expect(page.getByText("页面方案已升级,现有内容已全部保留")).toBeVisible();
});
+9
View File
@@ -0,0 +1,9 @@
export function nodeMajor(version = process.versions.node) {
return Number(String(version).replace(/^v/, "").split(".")[0]);
}
export function assertSupportedNode(version = process.versions.node) {
if (nodeMajor(version) !== 24) {
throw new Error(`Node.js 24 is required to build the release (current: ${version})`);
}
}
+14
View File
@@ -0,0 +1,14 @@
import assert from "node:assert/strict";
import { test } from "node:test";
import { assertSupportedNode, nodeMajor } from "./node-version.mjs";
test("接受 Node 24 及 v 前缀版本号", () => {
assert.doesNotThrow(() => assertSupportedNode("24.16.0"));
assert.doesNotThrow(() => assertSupportedNode("v24.16.0"));
assert.equal(nodeMajor("v24.16.0"), 24);
});
test("拒绝非 Node 24 并给出可操作错误", () => {
assert.throws(() => assertSupportedNode("22.22.2"), /Node\.js 24 is required/);
assert.throws(() => assertSupportedNode("25.0.0"), /current: 25\.0\.0/);
});
+2 -2
View File
@@ -7,6 +7,7 @@ import { spawnSync } from "node:child_process";
import { createRequire } from "node:module";
import { checkPackage } from "./check-package.mjs";
import { verifyRuntimePreflight } from "./runtime-preflight.mjs";
import { assertSupportedNode } from "./node-version.mjs";
const require = createRequire(import.meta.url);
const { findLeaks, loadConfig } = require("../../apps/taro/config/mask-taro.cjs");
@@ -174,8 +175,6 @@ async function buildTemplateCatalog() {
}
async function main() {
if (Number(process.versions.node.split(".")[0]) !== 24)
throw new Error("Node.js 24 is required to build the release");
if (!/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,100}$/.test(version))
throw new Error("Invalid release version");
const adminDist = path.join(root, "apps/admin/dist");
@@ -260,6 +259,7 @@ async function main() {
console.log("checksum: " + path.relative(root, archive + ".sha256"));
}
assertSupportedNode();
run("pnpm", ["build:admin:preview"]);
assertNoStackFingerprint("apps/admin/dist");
run("pnpm", ["--filter", "@personal-brand/config", "build"]);