import fs from 'node:fs/promises'; import path from 'node:path'; import { resolveRules } from '../src/rules.mjs'; import { atomic, digest } from '../src/store.mjs'; const configFile = process.argv[2]; const config = JSON.parse(await fs.readFile(configFile, 'utf8')); const packPath = path.resolve('lib/detail-generator/knowledge/enterprise-20261013.json'); const bytes = await fs.readFile(packPath, 'utf8'), pack = JSON.parse(bytes); const profile = pack.brands.find(b => b.name === '顾家'); if (!profile) throw Error('现有顾家导入快照不存在'); const catalog = { brands: [{ id: 'local-import-gujia', name: '顾家', profile, revision: pack.version, source: 'repository-import:enterprise-20261013.json (draft)' }], shops: [{ id: 'QA-A店', brandId: 'local-import-gujia', platform: 'local-qa', revision: 'qa-1', source: 'explicit-qa-fixture', rules: ['A店书桌规则口令:晨雾-2168'] }, { id: 'QA-B店', brandId: 'local-import-gujia', platform: 'local-qa', revision: 'qa-1', source: 'explicit-qa-fixture', rules: ['B店餐椅规则口令:海盐-7391'] }], categories: [{ id: 'QA-书桌', revision: 'qa-1', source: 'explicit-qa-fixture', rules: ['没有承重或检测报告时不编造相应参数'] }, { id: 'QA-餐椅', revision: 'qa-1', source: 'explicit-qa-fixture', rules: ['不能把另一产品的尺寸与材质用于当前餐椅'] }], bindings: [{ id: 'QA-A-desk', shopId: 'QA-A店', categoryId: 'QA-书桌', revision: 'qa-1', source: 'explicit-qa-fixture', state: 'ready', rules: [] }, { id: 'QA-B-chair', shopId: 'QA-B店', categoryId: 'QA-餐椅', revision: 'qa-1', source: 'explicit-qa-fixture', state: 'ready', rules: [] }], }; config.canvasBinding = resolveRules({ brandId: 'local-import-gujia', shopId: 'QA-A店', categoryId: 'QA-书桌' }, catalog); config.otherBinding = resolveRules({ brandId: 'local-import-gujia', shopId: 'QA-B店', categoryId: 'QA-餐椅' }, catalog); await atomic(configFile, config); await atomic(path.join(config.output, 'rule-source-manifest.json'), { brandSource: packPath, importedVersion: pack.version, hash: digest(bytes), status: profile.status, shopsAndCategories: 'explicit-local-qa-fixtures', productionCatalog: 'GET currently unavailable; no automatic fallback or deployment performed' }); console.log('Selected the existing local enterprise import explicitly; shop/category rules are labelled QA fixtures.');