@bedrock-core/builder 0.1.2 → 0.2.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.
Files changed (46) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/bin/api-library.d.ts +1 -0
  3. package/dist/bin/api-library.js +10 -0
  4. package/dist/bin/audit-paths.d.ts +1 -0
  5. package/dist/bin/audit-paths.js +44 -0
  6. package/dist/bin/build.js +1 -1
  7. package/dist/bin/builder.js +13 -2
  8. package/dist/bin/migrate.js +2 -6
  9. package/dist/bin/plan.js +2 -2
  10. package/dist/bin/watch.js +1 -1
  11. package/dist/package.json +11 -10
  12. package/dist/schemas/config.schema.json +28 -8
  13. package/dist/schemas/guides.schema.json +0 -5
  14. package/dist/schemas/i18n.schema.json +0 -5
  15. package/dist/schemas/pack-manifest.schema.json +243 -0
  16. package/dist/schemas/ui-compiler.schema.json +0 -5
  17. package/dist/src/config.d.ts +7 -3
  18. package/dist/src/config.js +3 -0
  19. package/dist/src/contract.d.ts +2 -0
  20. package/dist/src/export.d.ts +7 -5
  21. package/dist/src/export.js +274 -47
  22. package/dist/src/migrate.js +13 -10
  23. package/dist/src/migration/exports.js +1 -1
  24. package/dist/src/migration/filters.js +3 -2
  25. package/dist/src/migration/local-filter.js +1 -1
  26. package/dist/src/migration/project.js +17 -8
  27. package/dist/src/migration/types.d.ts +0 -2
  28. package/dist/src/path-audit.d.ts +29 -0
  29. package/dist/src/path-audit.js +110 -0
  30. package/dist/src/plan.js +2 -2
  31. package/dist/src/plugin-routing.js +1 -1
  32. package/dist/src/plugins.js +10 -1
  33. package/dist/src/project.d.ts +1 -3
  34. package/dist/src/project.js +1 -12
  35. package/dist/src/regolith.js +2 -2
  36. package/dist/src/run.js +67 -30
  37. package/dist/src/staging.d.ts +4 -0
  38. package/dist/src/staging.js +297 -0
  39. package/dist/src/validation.d.ts +1 -1
  40. package/dist/src/watch.js +48 -20
  41. package/package.json +24 -14
  42. package/schemas/config.schema.json +28 -8
  43. package/schemas/guides.schema.json +0 -5
  44. package/schemas/i18n.schema.json +0 -5
  45. package/schemas/pack-manifest.schema.json +243 -0
  46. package/schemas/ui-compiler.schema.json +0 -5
@@ -0,0 +1,110 @@
1
+ import { lstat, readdir } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ const containers = new Set(['behavior_packs', 'resource_packs']);
4
+ // Creator Tools 0.20.0 strips these pack folder names from its path budget.
5
+ const packAliases = new Set(['bp', 'rp', 'behavior pack', 'resource pack', 'behavior_pack', 'resource_pack', 'skin_pack', 'world', 'world_template']);
6
+ const assetFiles = new Map([
7
+ ['textures', /\.(png|tga|jpe?g)$/i],
8
+ ['sounds', /\.(ogg|wav|fsb)$/i],
9
+ ['functions', /\.mcfunction$/i],
10
+ ['loot_tables', /\.json$/i],
11
+ ['trading', /\.json$/i],
12
+ ]);
13
+ const maxDepth = 8;
14
+ async function hasManifest(directory) {
15
+ try {
16
+ return (await lstat(path.join(directory, 'manifest.json'))).isFile();
17
+ }
18
+ catch (error) {
19
+ if (error.code === 'ENOENT') {
20
+ return false;
21
+ }
22
+ throw error;
23
+ }
24
+ }
25
+ async function packRoots(root) {
26
+ if (!(await lstat(root)).isDirectory()) {
27
+ throw new Error(`Path audit requires a pack or unpacked add-on directory: ${root}`);
28
+ }
29
+ if (await hasManifest(root)) {
30
+ return [{ directory: root, relative: '.', prefix: '' }];
31
+ }
32
+ const packs = [];
33
+ for (const container of await readdir(root, { withFileTypes: true })) {
34
+ if (!containers.has(container.name.toLowerCase())) {
35
+ continue;
36
+ }
37
+ const directory = path.join(root, container.name);
38
+ if (!container.isDirectory()) {
39
+ throw new Error(`Path audit requires a real pack container directory: ${directory}`);
40
+ }
41
+ for (const entry of await readdir(directory, { withFileTypes: true })) {
42
+ const pack = path.join(directory, entry.name);
43
+ if (entry.isSymbolicLink()) {
44
+ throw new Error(`Path audit cannot follow a link: ${pack}`);
45
+ }
46
+ if (entry.isDirectory() && await hasManifest(pack)) {
47
+ packs.push({
48
+ directory: pack,
49
+ relative: path.posix.join(container.name, entry.name),
50
+ prefix: packAliases.has(entry.name.toLowerCase()) ? '' : entry.name,
51
+ });
52
+ }
53
+ }
54
+ }
55
+ if (!packs.length) {
56
+ throw new Error(`No pack manifests found at ${root} or under its behavior_packs and resource_packs directories`);
57
+ }
58
+ return packs.sort((a, b) => a.relative.localeCompare(b.relative));
59
+ }
60
+ async function packFiles(directory, files = [], prefix = '') {
61
+ for (const entry of await readdir(directory, { withFileTypes: true })) {
62
+ const relative = path.posix.join(prefix, entry.name);
63
+ const file = path.join(directory, entry.name);
64
+ if (entry.isSymbolicLink()) {
65
+ throw new Error(`Path audit cannot follow a link: ${file}`);
66
+ }
67
+ if (entry.isDirectory()) {
68
+ await packFiles(file, files, relative);
69
+ }
70
+ else if (entry.isFile()) {
71
+ files.push(relative);
72
+ }
73
+ }
74
+ return files;
75
+ }
76
+ /** Audit the file names of an existing pack or unpacked add-on. */
77
+ export async function auditPackPaths(directory, { maxLength, folders }) {
78
+ const packs = [];
79
+ for (const pack of await packRoots(path.resolve(directory))) {
80
+ const files = (await packFiles(pack.directory)).sort();
81
+ const findings = [];
82
+ let longest = { path: '', length: 0 };
83
+ for (const file of files) {
84
+ const measured = path.posix.join(pack.prefix, file);
85
+ const length = measured.length;
86
+ const depth = measured.split('/').length - 1;
87
+ const segments = file.split('/');
88
+ const category = segments[0];
89
+ if (length > longest.length) {
90
+ longest = { path: measured, length };
91
+ }
92
+ if (length > maxLength) {
93
+ findings.push({ rule: 'path-length', path: measured, message: `Path length ${length} exceeds the ${maxLength}-character budget` });
94
+ }
95
+ if (depth > maxDepth) {
96
+ findings.push({ rule: 'path-depth', path: measured, message: `Directory depth ${depth} exceeds the ${maxDepth}-level budget` });
97
+ }
98
+ if (!assetFiles.get(category)?.test(file)) {
99
+ continue;
100
+ }
101
+ const [, creator, name] = segments;
102
+ if (segments.length < 4 || (folders && (creator !== folders.creator || (name !== folders.pack && name !== 'common')))) {
103
+ const expected = folders ? `${folders.creator}/${folders.pack}/` : '<creator>/<pack>/';
104
+ findings.push({ rule: 'asset-folder', path: measured, message: `Cooperative add-ons should place these assets under ${category}/${expected}` });
105
+ }
106
+ }
107
+ packs.push({ path: pack.relative, files: files.length, longest, findings });
108
+ }
109
+ return { limits: { length: maxLength, depth: maxDepth }, packs };
110
+ }
package/dist/src/plan.js CHANGED
@@ -1,5 +1,5 @@
1
- import { builtinPlugins } from "./builtins.js";
2
- import { validatePluginDefinition } from "./config.js";
1
+ import { builtinPlugins } from './builtins.js';
2
+ import { validatePluginDefinition } from './config.js';
3
3
  /** Ordered built-in boundaries; automatic input detection happens during execution. */
4
4
  export const stages = Object.freeze(Object.keys(builtinPlugins));
5
5
  const record = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
@@ -1,7 +1,7 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { readdir, readFile } from 'node:fs/promises';
3
3
  import path from 'node:path';
4
- import { resolvePluginPacks } from "./plugin-packs.js";
4
+ import { resolvePluginPacks } from './plugin-packs.js';
5
5
  /** Preserve live host services while exposing one declared invocation's pack paths. */
6
6
  export function packContext(context, packs, owner, linkedPacks = Object.freeze({}), owners = packs.map(pack => pack.id), routing) {
7
7
  return Object.freeze({
@@ -1,5 +1,14 @@
1
- var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx, extraExtensions, ignoreCase) {
2
2
  if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ if (extraExtensions) {
4
+ for (var extension in extraExtensions) {
5
+ var suffix = path.slice(-extension.length);
6
+ if (suffix === extension || ignoreCase && suffix.toLowerCase() === extension.toLowerCase()) {
7
+ var output = extraExtensions[extension];
8
+ return output === extension ? path : path.slice(0, -extension.length) + output;
9
+ }
10
+ }
11
+ }
3
12
  return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
13
  return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
14
  });
@@ -1,6 +1,4 @@
1
- import type { ProjectMetadata, BuildContext } from '@bedrock-core/builder-plugin';
1
+ import type { ProjectMetadata } from '@bedrock-core/builder-plugin';
2
2
  import type { ProjectConfig } from './config.ts';
3
3
  /** Resolve shared display and package metadata without importing project code. */
4
4
  export declare function resolveProject(config: ProjectConfig, root: string, dependency?: (file: string) => void): Promise<ProjectMetadata>;
5
- /** Emit shared project metadata and literal editor declarations. */
6
- export declare function generateProject(context: BuildContext, project: ProjectMetadata): Promise<void>;
@@ -1,4 +1,4 @@
1
- import { mkdir, readFile, writeFile } from 'node:fs/promises';
1
+ import { readFile } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { isManifestVersion } from '@bedrock-core/builder-manifest';
4
4
  /** Resolve shared display and package metadata without importing project code. */
@@ -49,7 +49,6 @@ export async function resolveProject(config, root, dependency = () => { }) {
49
49
  }
50
50
  const url = [pkg.homepage, pkg.url].find((value) => typeof value === 'string' && !!value.trim());
51
51
  return Object.freeze({
52
- namespace: config.namespace,
53
52
  name: config.name,
54
53
  description: config.description ?? '',
55
54
  authors: Object.freeze(config.authors.map(author => typeof author === 'string' ? author : author.name)),
@@ -60,13 +59,3 @@ export async function resolveProject(config, root, dependency = () => { }) {
60
59
  ...(url ? { url: url.trim() } : {}),
61
60
  });
62
61
  }
63
- /** Emit shared project metadata and literal editor declarations. */
64
- export async function generateProject(context, project) {
65
- const value = JSON.stringify(project);
66
- const file = path.join(context.generatedDir, 'project.js');
67
- const declarations = path.join(context.projectRoot, '.bedrock-core/generated/project.d.ts');
68
- await writeFile(file, `export const project = ${value};\n`);
69
- await mkdir(path.dirname(declarations), { recursive: true });
70
- await writeFile(declarations, `declare module '@bedrock-core/generated/project' {\n export const project: ${value};\n}\n`);
71
- await context.registerArtifact('project:metadata', file, { importAs: '@bedrock-core/generated/project' });
72
- }
@@ -3,7 +3,7 @@ import { createHash, randomUUID } from 'node:crypto';
3
3
  import { cp, lstat, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm } from 'node:fs/promises';
4
4
  import path from 'node:path';
5
5
  import { createInterface } from 'node:readline';
6
- import { withSourceWrites } from "./source-writes.js";
6
+ import { withSourceWrites } from './source-writes.js';
7
7
  const sessions = new WeakMap();
8
8
  const roles = ['BP', 'RP'];
9
9
  function contains(root, file) {
@@ -245,7 +245,7 @@ export async function publishNodeData(context, publish) {
245
245
  for (const session of selected) {
246
246
  const source = session.dataSource;
247
247
  const parts = path.relative(context.projectRoot, source).split(path.sep);
248
- const roots = [...Object.values(context.allPacks ?? context.packs).map(directory => path.join(context.projectRoot, path.relative(context.stagedRoot, directory))), ...Object.values(context.outputPaths)];
248
+ const roots = [...Object.values(context.allPacks ?? context.packs).map(directory => path.join(context.projectRoot, path.relative(context.stagedRoot, directory))), ...Object.values(context.outputPaths), ...(context.apiOutput ? [context.apiOutput] : [])];
249
249
  if (!contains(context.projectRoot, source) || source === context.projectRoot
250
250
  || parts.some(part => ['.git', 'node_modules', '.bedrock-core'].includes(part) || part.includes('.builder-'))
251
251
  || roots.some(root => contains(root, source) || contains(source, root))) {
package/dist/src/run.js CHANGED
@@ -3,21 +3,21 @@ import { tmpdir } from 'node:os';
3
3
  import path from 'node:path';
4
4
  import { createRequire } from 'node:module';
5
5
  import { pathToFileURL } from 'node:url';
6
- import { validateConfig } from "./config.js";
7
- import { isStagingExcluded, stagingExclusions } from "./staging.js";
8
- import { planBuild } from "./plan.js";
9
- import { resolveProject, generateProject } from "./project.js";
10
- import { runNodeFilter, publishNodeData } from "./regolith.js";
11
- import { builtinPlugins } from "./builtins.js";
12
- import { loadPlugin, executePlugin } from "./plugins.js";
13
- import { nativePluginContexts, sharedPackWrites } from "./plugin-routing.js";
14
- import { inspectPacks } from "./packs.js";
6
+ import { validateConfig } from './config.js';
7
+ import { isStagingExcluded, isStagingInput, stagingExclusions, stagingInputs } from './staging.js';
8
+ import { planBuild } from './plan.js';
9
+ import { resolveProject } from './project.js';
10
+ import { runNodeFilter, publishNodeData } from './regolith.js';
11
+ import { builtinPlugins } from './builtins.js';
12
+ import { loadPlugin, executePlugin } from './plugins.js';
13
+ import { nativePluginContexts, sharedPackWrites } from './plugin-routing.js';
14
+ import { inspectPacks } from './packs.js';
15
15
  import { describePack, resolvePackGraph } from '@bedrock-core/builder-plugin';
16
- import { resolveManifest, resolveProjectManifests } from '@bedrock-core/builder-manifest';
17
- import { validatePackManifests } from "./manifest.js";
18
- import { resolveExportPaths, withExportPaths } from "./export.js";
16
+ import { resolveManifest, resolveProjectManifests, hasApiExports } from '@bedrock-core/builder-manifest';
17
+ import { finalizePackManifests, prepareAddonArtwork, validatePackManifests } from './manifest.js';
18
+ import { resolveExportPaths, resolveApiPackagePath, withExportPaths } from './export.js';
19
19
  import { createHash } from 'node:crypto';
20
- import { createFileCache, trackLocations } from "./file-cache.js";
20
+ import { createFileCache, trackLocations } from './file-cache.js';
21
21
  import { validatePackContent } from '@bedrock-core/builder-validation';
22
22
  const inside = (root, file) => {
23
23
  const relative = path.relative(root, file);
@@ -67,12 +67,20 @@ export async function runBuild({ configPath = 'config.json', profile = 'default'
67
67
  throw new Error('Profile needs export destinations for its packs to execute a build');
68
68
  }
69
69
  const outputPaths = Object.freeze(resolveExportPaths(project, config.packs, exportConfig));
70
+ const packageFile = path.join(project, 'package.json');
71
+ const packageMetadata = await exists(packageFile) ? JSON.parse(await readFile(packageFile, 'utf8')) : undefined;
72
+ const hasPublicApi = hasApiExports(packageMetadata);
73
+ const apiSelection = config.bedrockCore.profiles[profile]?.api;
74
+ const apiOutput = hasPublicApi && apiSelection !== false
75
+ ? resolveApiPackagePath(project, config.packs, outputPaths, apiSelection ?? 'dist/api')
76
+ : undefined;
70
77
  const outputs = Object.values(config.bedrockCore.profiles).flatMap((settings) => {
71
78
  if (!settings.export) {
72
79
  return [];
73
80
  }
74
81
  try {
75
- return Object.values(resolveExportPaths(project, config.packs, settings.export));
82
+ const paths = resolveExportPaths(project, config.packs, settings.export);
83
+ return [...Object.values(paths), ...(hasPublicApi && settings.api !== false ? [resolveApiPackagePath(project, config.packs, paths, settings.api ?? 'dist/api')] : [])];
76
84
  }
77
85
  catch {
78
86
  return [];
@@ -113,26 +121,23 @@ export async function runBuild({ configPath = 'config.json', profile = 'default'
113
121
  const ignored = new Set(['.git', 'node_modules', '.bedrock-core']);
114
122
  const normalized = (file) => process.platform === 'win32' ? file.toLowerCase() : file;
115
123
  const isOutput = (file) => outputs.some(output => path.relative(output, file) === '' || normalized(file).startsWith(`${normalized(output)}.builder-`));
116
- // Reject symlinks before copying or publishing, including export parent directories.
117
- async function inspect(directory, skipIgnored = true) {
124
+ const sources = await stagingInputs(project, config, profile, file, outputs, signal);
125
+ async function inspect(directory) {
118
126
  for (const entry of await readdir(directory, { withFileTypes: true })) {
119
127
  const source = path.join(directory, entry.name);
120
- if (skipIgnored && (isOutput(source) || ignored.has(entry.name) || isStagingExcluded(source, exclusions))) {
121
- continue;
122
- }
123
128
  if (entry.isSymbolicLink()) {
124
129
  throw new Error(`Symlinks are unsupported in staged sources: ${source}`);
125
130
  }
126
131
  if (entry.isDirectory()) {
127
- await inspect(source, skipIgnored);
132
+ await inspect(source);
128
133
  }
129
134
  }
130
135
  }
131
- await inspect(project);
132
136
  return withExportPaths(outputPaths, async (publish) => {
133
137
  let workspace;
134
- const dependencies = new Set([file, ...metadataInputs, ...modules.values()]);
138
+ const dependencies = new Set([file, ...sources, ...metadataInputs, ...modules.values(), ...(hasPublicApi ? [packageFile] : [])]);
135
139
  const artifacts = new Map();
140
+ const artifactFinalizers = new Map();
136
141
  const generatedImports = new Map();
137
142
  const packImports = new Map();
138
143
  const exportExclusions = new Set();
@@ -146,7 +151,7 @@ export async function runBuild({ configPath = 'config.json', profile = 'default'
146
151
  const staged = path.join(workspace, 'project');
147
152
  await cp(project, staged, {
148
153
  recursive: true,
149
- filter: source => !isOutput(source) && !ignored.has(path.basename(source)) && !isStagingExcluded(source, exclusions),
154
+ filter: source => isStagingInput(source, sources) && !isOutput(source) && !ignored.has(path.basename(source)) && !isStagingExcluded(source, exclusions),
150
155
  });
151
156
  const generated = path.join(workspace, 'generated');
152
157
  await mkdir(generated);
@@ -175,7 +180,7 @@ export async function runBuild({ configPath = 'config.json', profile = 'default'
175
180
  dependencies.add(path.join(project, path.relative(staged, input)));
176
181
  }
177
182
  }
178
- const resolved = resolveProjectManifests(manifests, metadata);
183
+ const resolved = resolveProjectManifests(manifests, metadata, { dependencyRoot: project, registerDependency: input => dependencies.add(input) });
179
184
  return withDestinations(resolvePackGraph(Object.entries(stagedPacks).map(([id, directory]) => describePack(id, directory, resolved[id]))));
180
185
  }
181
186
  let owner = 'prepare';
@@ -205,7 +210,6 @@ export async function runBuild({ configPath = 'config.json', profile = 'default'
205
210
  });
206
211
  const context = Object.freeze({
207
212
  projectRoot: project,
208
- namespace: metadata.namespace,
209
213
  project: metadata,
210
214
  stagedRoot: staged,
211
215
  generatedDir: generated,
@@ -242,6 +246,7 @@ export async function runBuild({ configPath = 'config.json', profile = 'default'
242
246
  const copy = Object.freeze({
243
247
  ...extension,
244
248
  ...(extension.packs ? { packs: Object.freeze([...extension.packs]) } : {}),
249
+ ...(extension.moduleNames ? { moduleNames: Object.freeze([...extension.moduleNames]) } : {}),
245
250
  ...(extension.inputs ? { inputs: Object.freeze([...extension.inputs]) } : {}),
246
251
  ...(extension.plugins ? { plugins: Object.freeze([...extension.plugins]) } : {}),
247
252
  ...(extension.resolveFromProject ? { resolveFromProject: Object.freeze([...extension.resolveFromProject]) } : {}),
@@ -252,6 +257,7 @@ export async function runBuild({ configPath = 'config.json', profile = 'default'
252
257
  allPacks: Object.freeze(stagedPacks),
253
258
  inspectPacks: currentPacks,
254
259
  outputPaths,
260
+ ...(apiOutput ? { apiOutput } : {}),
255
261
  profile,
256
262
  logger,
257
263
  signal,
@@ -303,6 +309,16 @@ export async function runBuild({ configPath = 'config.json', profile = 'default'
303
309
  }
304
310
  artifacts.set(id, Object.freeze({ id, path: location, owner, ...(importAs ? { importAs } : {}), ...(pack ? { pack } : {}) }));
305
311
  },
312
+ finalizeArtifact(id, finalize) {
313
+ const artifact = artifacts.get(id);
314
+ if (!artifact || artifact.owner !== owner) {
315
+ throw new Error(`Artifact finalization requires an artifact owned by this invocation: ${id}`);
316
+ }
317
+ if (typeof finalize !== 'function' || artifactFinalizers.has(id)) {
318
+ throw new Error(`Artifact needs one finalizer function: ${id}`);
319
+ }
320
+ artifactFinalizers.set(id, finalize);
321
+ },
306
322
  artifact(id) {
307
323
  const artifact = artifacts.get(id);
308
324
  if (!artifact) {
@@ -326,7 +342,6 @@ export async function runBuild({ configPath = 'config.json', profile = 'default'
326
342
  url.searchParams.set('build', path.basename(workspace));
327
343
  return loadPlugin(url.href, step.plugin);
328
344
  }
329
- await generateProject(context, metadata);
330
345
  for (const [index, step] of plan.entries()) {
331
346
  check(signal);
332
347
  owner = step.kind === 'plugin' ? `${step.plugin}:${index}` : step.stage;
@@ -407,10 +422,21 @@ export async function runBuild({ configPath = 'config.json', profile = 'default'
407
422
  }
408
423
  }
409
424
  }
425
+ await finalizePackManifests(stagedPacks);
426
+ for (const [id, finalize] of artifactFinalizers) {
427
+ check(signal);
428
+ await finalize(artifacts.get(id));
429
+ const file = await realpath(artifacts.get(id).path);
430
+ if (!inside(workspace, file) || !(await stat(file)).isFile()) {
431
+ throw new Error(`Invalid finalized artifact: ${id}`);
432
+ }
433
+ }
410
434
  await validatePackManifests(stagedPacks);
411
435
  await inspectPacks(stagedPacks);
436
+ const mode = config.bedrockCore.profiles[profile]?.validation ?? 'warn';
412
437
  validation = await validatePackContent({
413
438
  packs: await Promise.all(Object.keys(stagedPacks).map(id => context.inspectPack(id))),
439
+ mode,
414
440
  signal,
415
441
  async reuse(file, inputs, revision, validate) {
416
442
  const result = await cache.reuse(path.relative(staged, file).replaceAll('\\', '/'), {
@@ -424,21 +450,31 @@ export async function runBuild({ configPath = 'config.json', profile = 'default'
424
450
  },
425
451
  });
426
452
  const checked = validation.files.filter(file => file.schema).length;
427
- logger.info?.(`@bedrock-core/builder: validated ${checked} content documents against Mojang schemas ${validation.schemaVersion}; ${validation.files.length - checked} additional JSON documents checked for syntax`);
453
+ logger.info?.(mode === 'skip'
454
+ ? `@bedrock-core/builder: checked ${validation.files.length} JSON documents for syntax; content schema validation skipped`
455
+ : `@bedrock-core/builder: ${mode === 'warn' ? 'checked' : 'validated'} ${checked} content documents against Mojang schemas ${validation.schemaVersion}; ${validation.files.length - checked} additional JSON documents checked for syntax`);
428
456
  const schemaIssues = new Set(validation.files.flatMap(file => file.schemaIssue ? [file.schemaIssue] : []));
429
457
  for (const issue of schemaIssues) {
430
458
  logger.warn?.(`@bedrock-core/builder: ${issue}`);
431
459
  }
460
+ for (const { pack, file, pointer, message } of validation.files.flatMap(result => result.diagnostics)) {
461
+ logger.warn?.(`@bedrock-core/builder: ${pack}/${file}${pointer}: ${message}`);
462
+ }
432
463
  }
433
464
  else if (step.stage === 'export') {
434
465
  publishedPacks = [...withDestinations(await inspectPacks(stagedPacks))];
435
- await inspect(staged, false);
466
+ await inspect(staged);
436
467
  check(signal);
437
- await publishNodeData(context, () => publish(stagedPacks, signal));
468
+ const apiPackage = artifacts.get('api:package');
469
+ await publishNodeData(context, () => publish(stagedPacks, signal, apiPackage ? path.dirname(apiPackage.path) : undefined));
438
470
  }
439
471
  else if (step.stage !== 'prepare') {
440
472
  const plugin = await implementation(step.stage);
441
473
  const outcome = await executePlugin(plugin, context, step.settings ?? {}, step.mode);
474
+ if (step.stage === 'manifest') {
475
+ const ui = config.bedrockCore.profiles[profile]?.stages?.['ui-compiler'];
476
+ await prepareAddonArtwork(context, typeof ui === 'object' ? ui : {});
477
+ }
442
478
  stageResults.push({ stage: step.stage, ...outcome });
443
479
  logger.info?.(`@bedrock-core/builder: ${step.stage} ${outcome.status}${outcome.reason ? ` (${outcome.reason})` : ''}`);
444
480
  }
@@ -455,6 +491,7 @@ export async function runBuild({ configPath = 'config.json', profile = 'default'
455
491
  const result = Object.freeze({
456
492
  validation: validation,
457
493
  outputPaths,
494
+ ...(artifacts.has('api:package') ? { apiOutput } : {}),
458
495
  profile,
459
496
  stages: stageResults,
460
497
  dependencies: [...dependencies],
@@ -471,5 +508,5 @@ export async function runBuild({ configPath = 'config.json', profile = 'default'
471
508
  await rm(workspace, { recursive: true, force: true });
472
509
  }
473
510
  }
474
- });
511
+ }, apiOutput);
475
512
  }
@@ -2,3 +2,7 @@ import type { ProjectConfig } from './config.ts';
2
2
  /** Literal project paths omitted from staging and project watches. */
3
3
  export declare function stagingExclusions(project: string, config: ProjectConfig, configPath?: string): string[];
4
4
  export declare const isStagingExcluded: (file: string, exclusions: readonly string[]) => boolean;
5
+ /** A selected source or one of its ancestors needed to preserve project-relative paths. */
6
+ export declare const isStagingInput: (file: string, inputs: readonly string[]) => boolean;
7
+ /** Discover authored inputs without entering unrelated project directories or executing code. */
8
+ export declare function stagingInputs(project: string, config: ProjectConfig, profile?: string, configPath?: string, outputs?: readonly string[], signal?: AbortSignal): Promise<string[]>;