@realnation/content-config 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -0
- package/package.json +36 -0
- package/src/index.d.ts +41 -0
- package/src/index.mjs +2 -0
- package/src/labels.mjs +43 -0
- package/src/validate.d.ts +30 -0
- package/src/validate.mjs +59 -0
- package/src/vite-plugin.mjs +74 -0
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @realnation/content-config
|
|
2
|
+
|
|
3
|
+
qiksense 模块「内容配置」的机器可读说明(ClickUp 任务 8,方案 B,2026-09-29 定)。
|
|
4
|
+
|
|
5
|
+
模块每次构建时,这个 vite 插件读取模块的 `src/content-config.ts`,用其中的字段说明校验默认请求体,
|
|
6
|
+
不通过就让构建失败;通过就在 `remoteEntry.js` 同一目录生成 `content-config.json`,随配置端产物一起发布
|
|
7
|
+
(`deploy.mjs` 把 `dist` 整个搬进 `qik-sense-partner-remotes/<模块>/<vN>/`,发布流程不变)。
|
|
8
|
+
|
|
9
|
+
AI 与团队建活动 skill 的读法:先从模块目录接口 `GET /partner/projects/modulecontents` 拿到模块的
|
|
10
|
+
`partnerRemote.remoteEntry`,把末尾的 `remoteEntry.js`(连同 `?v=` 之类的查询串)换成 `content-config.json` 去取。
|
|
11
|
+
同一目录重新发布时说明跟着代码一起换;换了新目录(vN)的版本取新目录里的那份。
|
|
12
|
+
|
|
13
|
+
## 模块里怎么接
|
|
14
|
+
|
|
15
|
+
1. 装包:`npm install -D @realnation/content-config`
|
|
16
|
+
2. `vite.config.ts` 里加插件:
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import contentConfig from '@realnation/content-config';
|
|
20
|
+
// plugins: [ ..., contentConfig(), federation({ ... }) ]
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
3. 写 `src/content-config.ts`,默认导出三样:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import type { ContentConfigSpec } from '@realnation/content-config';
|
|
27
|
+
import { createEmptyDetail, LIMITS } from './types/config';
|
|
28
|
+
|
|
29
|
+
export default {
|
|
30
|
+
endpoint: 'common', // POST /partner/contents/<endpoint>/config/{projectId}
|
|
31
|
+
defaultBody: () => ({ configId: 0, detail: createEmptyDetail() }), // 配置页新建时提交的完整请求体
|
|
32
|
+
schema: { type: 'object', properties: { /* ... */ } }
|
|
33
|
+
} satisfies ContentConfigSpec;
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## 写字段说明的规矩
|
|
37
|
+
|
|
38
|
+
- **默认值与范围引用代码里的同一份常量**(默认值函数、LIMITS、枚举表),不照抄数字;改代码说明自动跟上。
|
|
39
|
+
- **配置页不动**(PF 2026-09-29)。`x-label` 写配置页上显示的名字,一个字段在页上分几层时用「 · 」连起来
|
|
40
|
+
(如 `Game Sounds · Grab`);**构建时每一段都要在模块 `src/` 的源码里原样找得到**,配置页改了名字而说明没跟上,
|
|
41
|
+
构建就报错。页上没有单独名字的字段(如随图片读回的宽高)不写 `x-label`。
|
|
42
|
+
- `description` 用英文写,给 AI 看:写清单位、取值的含义、空值与 0 代表什么;能用配置页上的提示就用它,不必一字不差。
|
|
43
|
+
- **请求体按服务器格式写**:配置端内部与存库格式不同的(如 Personality Test 题目内部叫 questions、存时叫 details),
|
|
44
|
+
写转换后的。
|
|
45
|
+
- **空串会被存成 null**:后端全局有 `ConvertEmptyStringsToNull`(qik-sense-api `app/Http/Kernel.php`),
|
|
46
|
+
允许空串的字段写 `type: ['string', 'null']`,并在说明里写清空串或 null 的含义。
|
|
47
|
+
- `detail` 写 `additionalProperties: false` 并把默认值里的每个键都列进 `required`,默认值多出或少了字段构建就会报。
|
|
48
|
+
- 只支持这些关键字:type、properties、required、additionalProperties、items、minItems、maxItems、enum、const、
|
|
49
|
+
minimum、maximum、minLength、maxLength、pattern、anyOf、format,另加 $schema、title、description、x-label。
|
|
50
|
+
用到别的会被当成问题报出来。
|
|
51
|
+
|
|
52
|
+
## 其他用法
|
|
53
|
+
|
|
54
|
+
- `import { validate } from '@realnation/content-config/validate'`:返回问题清单,空数组 = 通过(skill 读到说明后用它校验要提交的请求体)。
|
|
55
|
+
- `buildContentConfig(root, entry)`:不经 vite,直接读出并校验,返回要写进 `content-config.json` 的内容。
|
|
56
|
+
|
|
57
|
+
## 发版
|
|
58
|
+
|
|
59
|
+
`npm publish`(在本目录;账号要两步验证,由 PF 在自己的终端里发)。改了产物格式就把 `FORMAT` 加一,并同步改读取方。
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@realnation/content-config",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "qiksense 模块内容配置的机器可读说明:构建时导出 content-config.json,并用字段说明校验默认请求体",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./src/index.d.ts",
|
|
9
|
+
"import": "./src/index.mjs"
|
|
10
|
+
},
|
|
11
|
+
"./validate": {
|
|
12
|
+
"types": "./src/validate.d.ts",
|
|
13
|
+
"import": "./src/validate.mjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"src",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"test": "node --test \"test/*.test.mjs\""
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"esbuild": ">=0.19"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"vite": ">=5"
|
|
28
|
+
},
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"license": "UNLICENSED"
|
|
36
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import type { JsonSchema } from './validate';
|
|
3
|
+
|
|
4
|
+
export type { JsonSchema } from './validate';
|
|
5
|
+
export { validate, SUPPORTED_KEYWORDS } from './validate';
|
|
6
|
+
|
|
7
|
+
/** 模块 src/content-config.ts 默认导出的形状 */
|
|
8
|
+
export interface ContentConfigSpec<Body = unknown> {
|
|
9
|
+
/** POST /partner/contents/<endpoint>/config/{projectId} 里的 <endpoint>,如 common、form、quiz */
|
|
10
|
+
endpoint: string;
|
|
11
|
+
/** 配置页新建内容配置时提交的完整请求体(服务器格式);可以是返回它的函数 */
|
|
12
|
+
defaultBody: Body | (() => Body | Promise<Body>);
|
|
13
|
+
/** 请求体的字段说明 */
|
|
14
|
+
schema: JsonSchema;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** 构建产物 content-config.json 的形状 */
|
|
18
|
+
export interface ContentConfigFile<Body = unknown> {
|
|
19
|
+
format: 1;
|
|
20
|
+
endpoint: string;
|
|
21
|
+
defaultBody: Body;
|
|
22
|
+
schema: JsonSchema;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ContentConfigPluginOptions {
|
|
26
|
+
/** 说明文件,默认 src/content-config.ts */
|
|
27
|
+
entry?: string;
|
|
28
|
+
/** 产物位置,默认 assets/content-config.json(与 remoteEntry.js 同一目录) */
|
|
29
|
+
fileName?: string;
|
|
30
|
+
/** 在哪些目录的源码里核对 x-label,默认 ['src'];传 [] 不核对 */
|
|
31
|
+
labelDirs?: string[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export declare const FORMAT: 1;
|
|
35
|
+
export declare function loadSpec(root: string, entry: string): Promise<ContentConfigSpec>;
|
|
36
|
+
export declare function buildContentConfig(root: string, entry?: string, options?: { labelDirs?: string[] }): Promise<ContentConfigFile>;
|
|
37
|
+
/** 字段说明里所有的 x-label 与它们的位置 */
|
|
38
|
+
export declare function collectLabels(schema: JsonSchema, path?: string): Array<{ path: string; label: string }>;
|
|
39
|
+
/** 每个 x-label 按「 · 」拆开后,每一段都要在源码里原样出现过;返回找不到的清单 */
|
|
40
|
+
export declare function checkLabels(schema: JsonSchema, root: string, options?: { dirs?: string[]; exclude?: string[] }): string[];
|
|
41
|
+
export default function contentConfig(options?: ContentConfigPluginOptions): Plugin;
|
package/src/index.mjs
ADDED
package/src/labels.mjs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// 核对字段名:配置页不动,说明自己写 x-label(PF 2026-09-29)。为防配置页改了名字说明没跟上,
|
|
2
|
+
// 每个 x-label 按「 · 」拆开后,每一段都要在模块源码里原样出现过(说明文件本身不算)。
|
|
3
|
+
|
|
4
|
+
import { readdirSync, readFileSync, statSync } from 'node:fs'
|
|
5
|
+
import { extname, join, resolve } from 'node:path'
|
|
6
|
+
|
|
7
|
+
const SOURCE_EXTENSIONS = new Set(['.vue', '.ts', '.tsx', '.js', '.jsx', '.mjs'])
|
|
8
|
+
|
|
9
|
+
// 字段说明里所有的 x-label,连同它在说明里的位置
|
|
10
|
+
export function collectLabels(schema, path = '$') {
|
|
11
|
+
const found = []
|
|
12
|
+
if (!schema || typeof schema !== 'object') return found
|
|
13
|
+
if (typeof schema['x-label'] === 'string') found.push({ path, label: schema['x-label'] })
|
|
14
|
+
for (const [key, sub] of Object.entries(schema.properties ?? {})) found.push(...collectLabels(sub, `${path}.${key}`))
|
|
15
|
+
if (schema.items) found.push(...collectLabels(schema.items, `${path}[]`))
|
|
16
|
+
for (const sub of schema.anyOf ?? []) found.push(...collectLabels(sub, path))
|
|
17
|
+
return found
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function* sourceFiles(dir) {
|
|
21
|
+
for (const name of readdirSync(dir)) {
|
|
22
|
+
const p = join(dir, name)
|
|
23
|
+
if (statSync(p).isDirectory()) yield* sourceFiles(p)
|
|
24
|
+
else if (SOURCE_EXTENSIONS.has(extname(name))) yield p
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function checkLabels(schema, root, { dirs = ['src'], exclude = [] } = {}) {
|
|
29
|
+
const excluded = new Set(exclude.map((f) => resolve(root, f)))
|
|
30
|
+
let text = ''
|
|
31
|
+
for (const dir of dirs) {
|
|
32
|
+
for (const file of sourceFiles(resolve(root, dir))) {
|
|
33
|
+
if (!excluded.has(resolve(file))) text += readFileSync(file, 'utf8') + '\n'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const problems = []
|
|
37
|
+
for (const { path, label } of collectLabels(schema)) {
|
|
38
|
+
for (const part of label.split(' · ')) {
|
|
39
|
+
if (!text.includes(part)) problems.push(`${path}:x-label「${label}」里的「${part}」在配置页源码里找不到`)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return problems
|
|
43
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** 字段说明:JSON Schema 2020-12 里本包支持的那部分关键字 */
|
|
2
|
+
export interface JsonSchema {
|
|
3
|
+
$schema?: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
/** 给人和 AI 看的说明,用英文写 */
|
|
6
|
+
description?: string;
|
|
7
|
+
/** 配置页上这个字段显示的名字 */
|
|
8
|
+
'x-label'?: string;
|
|
9
|
+
type?: 'object' | 'array' | 'string' | 'number' | 'integer' | 'boolean' | 'null' | ReadonlyArray<'object' | 'array' | 'string' | 'number' | 'integer' | 'boolean' | 'null'>;
|
|
10
|
+
properties?: Record<string, JsonSchema>;
|
|
11
|
+
required?: ReadonlyArray<string>;
|
|
12
|
+
additionalProperties?: boolean;
|
|
13
|
+
items?: JsonSchema;
|
|
14
|
+
minItems?: number;
|
|
15
|
+
maxItems?: number;
|
|
16
|
+
enum?: ReadonlyArray<unknown>;
|
|
17
|
+
const?: unknown;
|
|
18
|
+
minimum?: number;
|
|
19
|
+
maximum?: number;
|
|
20
|
+
minLength?: number;
|
|
21
|
+
maxLength?: number;
|
|
22
|
+
pattern?: string;
|
|
23
|
+
anyOf?: ReadonlyArray<JsonSchema>;
|
|
24
|
+
format?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export declare const SUPPORTED_KEYWORDS: ReadonlySet<string>;
|
|
28
|
+
|
|
29
|
+
/** 返回问题清单,空数组 = 通过 */
|
|
30
|
+
export declare function validate(schema: JsonSchema, value: unknown, path?: string): string[];
|
package/src/validate.mjs
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// 用字段说明(JSON Schema 2020-12 的一个子集)校验一份值,返回问题清单,空数组 = 通过。
|
|
2
|
+
// 只支持字段说明里用得到的关键字;用到别的会直接列为问题,免得写了却没校验。
|
|
3
|
+
// 构建插件与团队建活动 skill 共用这一份,两边的判断不会不一样。
|
|
4
|
+
|
|
5
|
+
export const SUPPORTED_KEYWORDS = new Set([
|
|
6
|
+
'$schema', 'title', 'description', 'x-label', 'type', 'properties', 'required', 'additionalProperties',
|
|
7
|
+
'items', 'minItems', 'maxItems', 'enum', 'const', 'minimum', 'maximum', 'minLength', 'maxLength', 'pattern',
|
|
8
|
+
'anyOf', 'format'
|
|
9
|
+
])
|
|
10
|
+
|
|
11
|
+
const typeOf = (v) => (v === null ? 'null' : Array.isArray(v) ? 'array' : Number.isInteger(v) ? 'integer' : typeof v)
|
|
12
|
+
const matchesType = (v, t) => t === typeOf(v) || (t === 'number' && typeof v === 'number' && Number.isFinite(v))
|
|
13
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b)
|
|
14
|
+
|
|
15
|
+
export function validate(schema, value, path = '$') {
|
|
16
|
+
const errors = []
|
|
17
|
+
for (const key of Object.keys(schema)) {
|
|
18
|
+
if (!SUPPORTED_KEYWORDS.has(key)) errors.push(`${path}:字段说明用了不支持的关键字 ${key}`)
|
|
19
|
+
}
|
|
20
|
+
if (schema.anyOf && !schema.anyOf.some((s) => validate(s, value, path).length === 0)) {
|
|
21
|
+
errors.push(`${path}:${JSON.stringify(value)} 不符合 anyOf 里的任何一种`)
|
|
22
|
+
}
|
|
23
|
+
if (schema.type) {
|
|
24
|
+
const types = Array.isArray(schema.type) ? schema.type : [schema.type]
|
|
25
|
+
if (!types.some((t) => matchesType(value, t))) {
|
|
26
|
+
errors.push(`${path}:应为 ${types.join(' 或 ')},实为 ${typeOf(value)}`)
|
|
27
|
+
return errors
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if ('const' in schema && !same(value, schema.const)) errors.push(`${path}:应为 ${JSON.stringify(schema.const)}`)
|
|
31
|
+
if (schema.enum && !schema.enum.some((e) => same(e, value))) {
|
|
32
|
+
errors.push(`${path}:${JSON.stringify(value)} 不在可选值 ${JSON.stringify(schema.enum)} 里`)
|
|
33
|
+
}
|
|
34
|
+
if (typeof value === 'number') {
|
|
35
|
+
if (schema.minimum !== undefined && value < schema.minimum) errors.push(`${path}:${value} 小于下限 ${schema.minimum}`)
|
|
36
|
+
if (schema.maximum !== undefined && value > schema.maximum) errors.push(`${path}:${value} 大于上限 ${schema.maximum}`)
|
|
37
|
+
}
|
|
38
|
+
if (typeof value === 'string') {
|
|
39
|
+
if (schema.minLength !== undefined && value.length < schema.minLength) errors.push(`${path}:长度 ${value.length} 小于 ${schema.minLength}`)
|
|
40
|
+
if (schema.maxLength !== undefined && value.length > schema.maxLength) errors.push(`${path}:长度 ${value.length} 大于 ${schema.maxLength}`)
|
|
41
|
+
if (schema.pattern && !new RegExp(schema.pattern).test(value)) errors.push(`${path}:${JSON.stringify(value)} 不符合 ${schema.pattern}`)
|
|
42
|
+
}
|
|
43
|
+
if (Array.isArray(value)) {
|
|
44
|
+
if (schema.minItems !== undefined && value.length < schema.minItems) errors.push(`${path}:${value.length} 项,少于 ${schema.minItems}`)
|
|
45
|
+
if (schema.maxItems !== undefined && value.length > schema.maxItems) errors.push(`${path}:${value.length} 项,多于 ${schema.maxItems}`)
|
|
46
|
+
if (schema.items) value.forEach((item, i) => errors.push(...validate(schema.items, item, `${path}[${i}]`)))
|
|
47
|
+
}
|
|
48
|
+
if (typeOf(value) === 'object') {
|
|
49
|
+
const props = schema.properties ?? {}
|
|
50
|
+
for (const key of schema.required ?? []) {
|
|
51
|
+
if (!(key in value)) errors.push(`${path}:缺少必填字段 ${key}`)
|
|
52
|
+
}
|
|
53
|
+
for (const [key, v] of Object.entries(value)) {
|
|
54
|
+
if (props[key]) errors.push(...validate(props[key], v, `${path}.${key}`))
|
|
55
|
+
else if (schema.additionalProperties === false) errors.push(`${path}.${key}:字段说明里没有这个字段`)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return errors
|
|
59
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// vite 插件:构建时加载模块的 src/content-config.ts,用它的字段说明校验默认请求体,
|
|
2
|
+
// 不通过就让构建失败;通过就在 remoteEntry.js 同一目录生成 content-config.json,随配置端产物发布。
|
|
3
|
+
// 模块每次构建都跑(本机 npm run build、deploy.mjs 发 UAT 与正式),所以说明永远跟着当时的代码。
|
|
4
|
+
|
|
5
|
+
import { build } from 'esbuild'
|
|
6
|
+
import { mkdirSync, rmSync, writeFileSync } from 'node:fs'
|
|
7
|
+
import { join, resolve } from 'node:path'
|
|
8
|
+
import { pathToFileURL } from 'node:url'
|
|
9
|
+
import { validate } from './validate.mjs'
|
|
10
|
+
import { checkLabels } from './labels.mjs'
|
|
11
|
+
|
|
12
|
+
export { checkLabels, collectLabels } from './labels.mjs'
|
|
13
|
+
|
|
14
|
+
export const FORMAT = 1
|
|
15
|
+
|
|
16
|
+
// 用 esbuild 把 content-config.ts 连同它引用的模块代码打成一个 ESM 文件再加载:TS、相对引用与 @/ 别名都能处理;
|
|
17
|
+
// node_modules 里的包不打进去,加载时照常从模块仓解析(所以临时文件放在模块仓的 node_modules 下)
|
|
18
|
+
export async function loadSpec(root, entry) {
|
|
19
|
+
const dir = join(root, 'node_modules', '.content-config')
|
|
20
|
+
mkdirSync(dir, { recursive: true })
|
|
21
|
+
const out = join(dir, `spec-${process.pid}-${Date.now()}.mjs`)
|
|
22
|
+
const result = await build({
|
|
23
|
+
entryPoints: [resolve(root, entry)],
|
|
24
|
+
bundle: true,
|
|
25
|
+
format: 'esm',
|
|
26
|
+
platform: 'node',
|
|
27
|
+
packages: 'external',
|
|
28
|
+
write: false,
|
|
29
|
+
logLevel: 'silent',
|
|
30
|
+
alias: { '@': resolve(root, 'src') }
|
|
31
|
+
})
|
|
32
|
+
writeFileSync(out, result.outputFiles[0].text)
|
|
33
|
+
try {
|
|
34
|
+
const mod = await import(pathToFileURL(out).href)
|
|
35
|
+
return mod.default
|
|
36
|
+
} finally {
|
|
37
|
+
rmSync(out, { force: true })
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 读出说明并校验,返回要写进 content-config.json 的内容;不合规时抛错,错误信息逐条列出
|
|
42
|
+
export async function buildContentConfig(root, entry = 'src/content-config.ts', { labelDirs = ['src'] } = {}) {
|
|
43
|
+
const spec = await loadSpec(root, entry)
|
|
44
|
+
if (!spec || typeof spec.endpoint !== 'string' || !spec.endpoint || !spec.schema || spec.defaultBody === undefined) {
|
|
45
|
+
throw new Error(`content-config:${entry} 要默认导出 { endpoint, defaultBody, schema }`)
|
|
46
|
+
}
|
|
47
|
+
const defaultBody = typeof spec.defaultBody === 'function' ? await spec.defaultBody() : spec.defaultBody
|
|
48
|
+
const errors = validate(spec.schema, defaultBody)
|
|
49
|
+
if (labelDirs.length) errors.push(...checkLabels(spec.schema, root, { dirs: labelDirs, exclude: [entry] }))
|
|
50
|
+
if (errors.length) {
|
|
51
|
+
throw new Error(`content-config:字段说明没通过检查(${errors.length} 处)\n ${errors.join('\n ')}`)
|
|
52
|
+
}
|
|
53
|
+
return { format: FORMAT, endpoint: spec.endpoint, defaultBody, schema: spec.schema }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default function contentConfig({ entry = 'src/content-config.ts', fileName = 'assets/content-config.json', labelDirs = ['src'] } = {}) {
|
|
57
|
+
let root = process.cwd()
|
|
58
|
+
return {
|
|
59
|
+
name: 'realnation-content-config',
|
|
60
|
+
apply: 'build',
|
|
61
|
+
configResolved(config) {
|
|
62
|
+
root = config.root
|
|
63
|
+
},
|
|
64
|
+
async generateBundle() {
|
|
65
|
+
let doc
|
|
66
|
+
try {
|
|
67
|
+
doc = await buildContentConfig(root, entry, { labelDirs })
|
|
68
|
+
} catch (e) {
|
|
69
|
+
this.error(e.message)
|
|
70
|
+
}
|
|
71
|
+
this.emitFile({ type: 'asset', fileName, source: JSON.stringify(doc, null, 2) + '\n' })
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|