@bedrock-core/builder 0.2.0 → 0.3.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/dist/src/run.js CHANGED
@@ -107,7 +107,7 @@ export async function runBuild({ configPath = 'config.json', profile = 'default'
107
107
  const require = createRequire(file);
108
108
  const modules = new Map();
109
109
  for (const step of plan.filter(step => step.kind === 'plugin')) {
110
- if (step.script !== undefined) {
110
+ if (step.module === undefined) {
111
111
  continue;
112
112
  }
113
113
  const local = step.module.startsWith('.') || path.isAbsolute(step.module);
@@ -220,6 +220,9 @@ export async function runBuild({ configPath = 'config.json', profile = 'default'
220
220
  get inputDirectories() {
221
221
  return Object.freeze([...inputDirectories]);
222
222
  },
223
+ get assetRegistryExclusions() {
224
+ return Object.freeze([...artifacts.values()].filter(artifact => artifact.assetRegistry === false).map(artifact => artifact.path));
225
+ },
223
226
  generatedImportsFor(pack) {
224
227
  if (!Object.hasOwn(stagedPacks, pack)) {
225
228
  throw new Error(`Generated imports reference an unknown pack: ${pack}`);
@@ -286,6 +289,9 @@ export async function runBuild({ configPath = 'config.json', profile = 'default'
286
289
  }
287
290
  const importAs = options?.importAs;
288
291
  const pack = options?.pack;
292
+ if (options?.assetRegistry !== undefined && typeof options.assetRegistry !== 'boolean') {
293
+ throw new TypeError(`Artifact assetRegistry must be a boolean: ${id}`);
294
+ }
289
295
  if (pack !== undefined && !Object.hasOwn(stagedPacks, pack)) {
290
296
  throw new Error(`Artifact references an unknown pack: ${pack}`);
291
297
  }
@@ -307,7 +313,7 @@ export async function runBuild({ configPath = 'config.json', profile = 'default'
307
313
  generatedImports.set(importAs, id);
308
314
  }
309
315
  }
310
- artifacts.set(id, Object.freeze({ id, path: location, owner, ...(importAs ? { importAs } : {}), ...(pack ? { pack } : {}) }));
316
+ artifacts.set(id, Object.freeze({ id, path: location, owner, ...(importAs ? { importAs } : {}), ...(pack ? { pack } : {}), ...(options?.assetRegistry === false ? { assetRegistry: false } : {}) }));
311
317
  },
312
318
  finalizeArtifact(id, finalize) {
313
319
  const artifact = artifacts.get(id);
@@ -381,7 +387,7 @@ export async function runBuild({ configPath = 'config.json', profile = 'default'
381
387
  logger.info?.(`@bedrock-core/builder: ${owner}`);
382
388
  }
383
389
  if (step.kind === 'plugin') {
384
- if (step.script === undefined) {
390
+ if (step.module !== undefined) {
385
391
  const plugin = await nativeImplementation(step);
386
392
  const invocations = nativePluginContexts(context, plugin, step, plugin.requirements === undefined ? [] : await currentPacks());
387
393
  const writes = sharedPackWrites(invocations, step.plugin);
@@ -433,10 +439,15 @@ export async function runBuild({ configPath = 'config.json', profile = 'default'
433
439
  }
434
440
  await validatePackManifests(stagedPacks);
435
441
  await inspectPacks(stagedPacks);
436
- const mode = config.bedrockCore.profiles[profile]?.validation ?? 'warn';
442
+ const profileSettings = config.bedrockCore.profiles[profile];
443
+ const mode = profileSettings?.validation ?? 'warn';
444
+ const creatorTools = profileSettings?.creatorToolsValidation;
437
445
  validation = await validatePackContent({
438
446
  packs: await Promise.all(Object.keys(stagedPacks).map(id => context.inspectPack(id))),
439
447
  mode,
448
+ projectRoot: project,
449
+ targetVersion: config.targetVersion,
450
+ creatorTools: creatorTools && creatorTools !== 'skip' ? { mode: creatorTools, projectRoot: project } : undefined,
440
451
  signal,
441
452
  async reuse(file, inputs, revision, validate) {
442
453
  const result = await cache.reuse(path.relative(staged, file).replaceAll('\\', '/'), {
@@ -449,15 +460,15 @@ export async function runBuild({ configPath = 'config.json', profile = 'default'
449
460
  return result.value;
450
461
  },
451
462
  });
452
- const checked = validation.files.filter(file => file.schema).length;
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`);
456
- const schemaIssues = new Set(validation.files.flatMap(file => file.schemaIssue ? [file.schemaIssue] : []));
457
- for (const issue of schemaIssues) {
458
- logger.warn?.(`@bedrock-core/builder: ${issue}`);
463
+ const checked = validation.files.filter(file => file.category).length;
464
+ logger.info?.(validation.typesVersion
465
+ ? `@bedrock-core/builder: checked ${checked} content documents against Bedrock types ${validation.typesVersion}; ${validation.files.length - checked} additional JSON documents checked for syntax`
466
+ : `@bedrock-core/builder: checked ${validation.files.length} JSON documents for syntax`);
467
+ if (validation.typesIssue) {
468
+ logger.warn?.(`@bedrock-core/builder: ${validation.typesIssue}`);
459
469
  }
460
- for (const { pack, file, pointer, message } of validation.files.flatMap(result => result.diagnostics)) {
470
+ const diagnostics = [...validation.files.flatMap(result => result.diagnostics), ...validation.creatorTools?.diagnostics ?? []];
471
+ for (const { pack, file, pointer, message } of diagnostics) {
461
472
  logger.warn?.(`@bedrock-core/builder: ${pack}/${file}${pointer}: ${message}`);
462
473
  }
463
474
  }
@@ -496,7 +507,7 @@ export async function runBuild({ configPath = 'config.json', profile = 'default'
496
507
  stages: stageResults,
497
508
  dependencies: [...dependencies],
498
509
  compilations: cache.results,
499
- artifacts: [...artifacts.values()].map(({ id, owner, importAs, pack }) => ({ id, owner, ...(importAs ? { importAs } : {}), ...(pack ? { pack } : {}) })),
510
+ artifacts: [...artifacts.values()].map(({ id, owner, importAs, pack, assetRegistry }) => ({ id, owner, ...(importAs ? { importAs } : {}), ...(pack ? { pack } : {}), ...(assetRegistry === false ? { assetRegistry } : {}) })),
500
511
  packs: publishedPacks.map(pack => ({ ...pack, path: outputPaths[pack.id] })),
501
512
  });
502
513
  trackLocations(result, dependencyLocations);
@@ -165,7 +165,9 @@ export async function stagingInputs(project, config, profile = 'default', config
165
165
  }
166
166
  }
167
167
  else {
168
- add(path.resolve(project, step.filterDir ?? '.', step.script), true);
168
+ if (step.script !== undefined) {
169
+ add(path.resolve(project, step.filterDir ?? '.', step.script), true);
170
+ }
169
171
  add(step.dataPath ?? 'data');
170
172
  }
171
173
  }
@@ -272,6 +274,12 @@ export async function stagingInputs(project, config, profile = 'default', config
272
274
  const resolution = resolverFor(directory).resolveModuleName(imported.text, directory).resolvedModule;
273
275
  if (resolution) {
274
276
  add(resolution.resolvedFileName);
277
+ // A typed asset resolves to e.g. heads.d.json.ts. Bundle its runtime file too.
278
+ const extension = path.extname(imported.text);
279
+ const suffix = '.d' + extension + '.ts';
280
+ if (extension && resolution.resolvedFileName.endsWith(suffix)) {
281
+ add(resolution.resolvedFileName.slice(0, -suffix.length) + extension);
282
+ }
275
283
  }
276
284
  }
277
285
  }
@@ -1,2 +1,2 @@
1
1
  export { validatePackContent, ContentValidationError } from '@bedrock-core/builder-validation';
2
- export type { ContentPack, ContentDiagnostic, ContentFileResult, ContentValidationMode, ContentValidationOptions, ContentValidationResult } from '@bedrock-core/builder-validation';
2
+ export type { ContentPack, ContentDiagnostic, ContentFileResult, ContentValidationMode, ContentValidationOptions, ContentValidationResult, CreatorToolsDiagnostic, CreatorToolsResult, CreatorToolsValidationOptions } from '@bedrock-core/builder-validation';
package/dist/src/watch.js CHANGED
@@ -187,10 +187,6 @@ export async function watchBuild(options) {
187
187
  }
188
188
  const roots = new Set(await exportRoots(config));
189
189
  exclusions = stagingExclusions(project, config, configPath);
190
- const generator = settings.stages?.generator;
191
- if (generator && typeof generator === 'object' && generator.types !== false && typeof generator.typesDir === 'string' && generator.typesDir) {
192
- roots.add(path.resolve(project, generator.typesDir));
193
- }
194
190
  // Retain former outputs as ignored paths after profile edits.
195
191
  outputRoots = new Set([...outputRoots, ...roots]);
196
192
  sourceRoots = await stagingInputs(project, config, profile, configPath, [...outputRoots], signal);
@@ -277,16 +273,11 @@ export async function watchBuild(options) {
277
273
  }
278
274
  try {
279
275
  const config = validateConfig(JSON.parse(await readFile(configPath, 'utf8')));
280
- const settings = config.bedrockCore.profiles[profile];
281
276
  exclusions = stagingExclusions(project, config, configPath);
282
277
  for (const directory of await exportRoots(config)) {
283
278
  outputRoots.add(directory);
284
279
  }
285
280
  sourceRoots = await stagingInputs(project, config, profile, configPath, [...outputRoots], signal);
286
- const generator = settings?.stages?.generator;
287
- if (generator && typeof generator === 'object' && generator.types !== false && typeof generator.typesDir === 'string' && generator.typesDir) {
288
- outputRoots.add(path.resolve(project, generator.typesDir));
289
- }
290
281
  }
291
282
  catch {
292
283
  // A malformed config stays observable so editing it can recover the build.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrock-core/builder",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "Build one or many Minecraft Bedrock packs from a JavaScript or TypeScript project",
6
6
  "exports": {
@@ -46,15 +46,15 @@
46
46
  }
47
47
  },
48
48
  "scripts": {
49
- "test": "node --test",
49
+ "test": "node --test test \"scripts/*.test.*\" \"packages/*/test/**/*.{js,mjs,cjs,ts,mts,cts}\"",
50
50
  "plan": "node bin/plan.ts",
51
- "build": "node bin/build.ts",
52
- "typecheck": "node node_modules/typescript-native/bin/tsc --noEmit",
51
+ "build": "yarn prepare:types && node bin/build.ts",
52
+ "typecheck": "yarn prepare:types && node node_modules/typescript-native/bin/tsc --noEmit && node node_modules/typescript-native/bin/tsc -p packages/bedrock-types/tsconfig.json --noEmit",
53
53
  "lint": "eslint . --max-warnings=0",
54
54
  "lint:fix": "eslint . --fix --max-warnings=0",
55
55
  "format": "eslint . --fix --max-warnings=0",
56
56
  "check": "yarn lint && yarn typecheck && yarn test",
57
- "watch": "node bin/watch.ts",
57
+ "watch": "yarn prepare:types && node bin/watch.ts",
58
58
  "migrate": "node bin/migrate.ts",
59
59
  "scaffold": "node packages/cli/src/index.ts",
60
60
  "test:cli": "yarn workspace @bedrock-core/cli test",
@@ -64,6 +64,10 @@
64
64
  "pack-release": "yarn prepare-release && node scripts/pack-release.ts",
65
65
  "test:packages": "node scripts/verify-packages.ts",
66
66
  "prepare:acceptance": "node scripts/prepare-acceptance.ts",
67
+ "registry": "node scripts/local-registry.mjs",
68
+ "local:publish": "node scripts/local-packages.mjs publish",
69
+ "local:check": "node scripts/local-packages.mjs check",
70
+ "test:local-packages": "node --test scripts/local-registry.test.mjs scripts/local-packages.test.mjs",
67
71
  "acceptance": "node scripts/acceptance.ts",
68
72
  "acceptance:native": "node scripts/acceptance.ts --native",
69
73
  "acceptance:api": "node scripts/api-acceptance.ts",
@@ -79,22 +83,26 @@
79
83
  "version:packages": "changeset version && node scripts/sync-cli-template.mjs --builder-only && yarn install --mode=update-lockfile",
80
84
  "tag-release": "node scripts/tag-release.ts",
81
85
  "test:release": "node --test scripts/publish-release.test.ts scripts/cli-artifact.test.mjs scripts/sync-cli-template.test.mjs scripts/release-versions.test.ts scripts/acceptance-archives.test.ts",
82
- "publish:ci": "yarn publish-release --scope \"$RELEASE_SCOPE\" && yarn tag-release --scope \"$RELEASE_SCOPE\""
86
+ "publish:ci": "yarn publish-release --scope \"$RELEASE_SCOPE\" && yarn tag-release --scope \"$RELEASE_SCOPE\"",
87
+ "prepare:types": "node packages/bedrock-types/src/build.ts",
88
+ "prepare:assets": "node packages/asset-maps/src/build.ts",
89
+ "setup": "yarn install && yarn prepare:types"
83
90
  },
84
91
  "engines": {
85
92
  "node": ">=26.13.0"
86
93
  },
87
94
  "dependencies": {
88
- "@bedrock-core/builder-bundler": "0.2.0",
89
- "@bedrock-core/builder-generator": "0.2.0",
95
+ "@bedrock-core/builder-bundler": "0.3.0",
96
+ "@bedrock-core/builder-generator": "0.3.0",
90
97
  "@bedrock-core/builder-guides": "0.2.0",
91
- "@bedrock-core/builder-i18n": "0.2.0",
98
+ "@bedrock-core/builder-i18n": "0.2.1",
92
99
  "@bedrock-core/builder-manifest": "0.2.0",
93
100
  "@bedrock-core/builder-plugin": "0.2.0",
94
- "@bedrock-core/builder-ui": "0.3.0",
95
- "@bedrock-core/builder-validation": "0.2.0",
101
+ "@bedrock-core/builder-ui": "0.4.0",
102
+ "@bedrock-core/builder-validation": "0.3.0",
96
103
  "@types/node": "25.9.9",
97
104
  "ajv": "8.17.1",
105
+ "import-meta-resolve": "^4.2.0",
98
106
  "typescript-native": "npm:typescript@7.1.0-beta"
99
107
  },
100
108
  "devDependencies": {
@@ -104,7 +112,8 @@
104
112
  "eslint": "10.5.0",
105
113
  "globals": "17.7.0",
106
114
  "typescript": "5.9.3",
107
- "typescript-eslint": "8.62.0"
115
+ "typescript-eslint": "8.62.0",
116
+ "verdaccio": "7.1.0"
108
117
  },
109
118
  "workspaces": [
110
119
  ".",
@@ -116,7 +125,9 @@
116
125
  "packages/validation",
117
126
  "packages/plugin",
118
127
  "packages/manifest",
119
- "packages/cli"
128
+ "packages/cli",
129
+ "packages/bedrock-types",
130
+ "packages/asset-maps"
120
131
  ],
121
132
  "packageManager": "yarn@4.16.0",
122
133
  "license": "MIT",
@@ -30,6 +30,11 @@
30
30
  "debug": {
31
31
  "type": "boolean"
32
32
  },
33
+ "vanillaAssets": {
34
+ "type": "boolean",
35
+ "default": false,
36
+ "description": "Include the checked shared vanilla asset catalog and generated atlas. Authored addon assets publish automatically regardless of this setting."
37
+ },
33
38
  "target": {
34
39
  "type": "string",
35
40
  "pattern": "\\S"
@@ -201,14 +201,19 @@
201
201
  {
202
202
  "type": "object",
203
203
  "additionalProperties": false,
204
- "required": [
205
- "script"
204
+ "oneOf": [
205
+ { "required": ["script"] },
206
+ { "required": ["nodeModule"] }
206
207
  ],
207
208
  "properties": {
208
209
  "script": {
209
210
  "$ref": "#/definitions/nonempty",
210
211
  "description": "Standalone Node entry point, relative to filterDir, using the Regolith BP/RP/data contract."
211
212
  },
213
+ "nodeModule": {
214
+ "$ref": "#/definitions/nonempty",
215
+ "description": "Installed Node package or exported subpath resolved from filterDir and executed in the BP/RP/data workspace."
216
+ },
212
217
  "filterDir": {
213
218
  "$ref": "#/definitions/nonempty",
214
219
  "description": "Script definition directory, relative to config.json. Defaults to the project root and sets FILTER_DIR."
@@ -425,7 +430,12 @@
425
430
  "validation": {
426
431
  "enum": ["strict", "warn", "skip"],
427
432
  "default": "warn",
428
- "description": "Content schema validation mode. JSON syntax and pack manifests are always checked."
433
+ "description": "Document type validation mode. JSON syntax and pack manifests are always checked."
434
+ },
435
+ "creatorToolsValidation": {
436
+ "enum": ["strict", "warn", "skip"],
437
+ "default": "skip",
438
+ "description": "Run the installed Mojang Creator Tools CLI on the final pack set. In strict mode, errors prevent export."
429
439
  },
430
440
  "api": {
431
441
  "description": "Portable addon API package output; defaults to dist/api when public addon exports are declared. Set false to disable.",
@@ -14,33 +14,6 @@
14
14
  "exclude": {
15
15
  "$ref": "#/$defs/patterns"
16
16
  },
17
- "types": {
18
- "type": "boolean",
19
- "default": true,
20
- "description": "Generate Minecraft schema declarations for editor completion."
21
- },
22
- "schemaVersion": {
23
- "type": "string",
24
- "pattern": "\\S",
25
- "default": "latest"
26
- },
27
- "typesDir": {
28
- "type": ["string", "null"],
29
- "description": "Project-relative declaration output directory; defaults to .bedrock-core/generated/mc."
30
- },
31
- "typePrefix": {
32
- "type": "string",
33
- "default": ""
34
- },
35
- "strict": {
36
- "type": "boolean",
37
- "default": false
38
- },
39
- "maxAgeHours": {
40
- "type": "number",
41
- "minimum": 0,
42
- "default": 24
43
- },
44
17
  "tsconfig": {
45
18
  "type": "string",
46
19
  "pattern": "\\S"
@@ -80,8 +53,17 @@
80
53
  "$defs": {
81
54
  "patterns": {
82
55
  "anyOf": [
83
- { "type": "string", "pattern": "\\S" },
84
- { "type": "array", "items": { "type": "string", "pattern": "\\S" } }
56
+ {
57
+ "type": "string",
58
+ "pattern": "\\S"
59
+ },
60
+ {
61
+ "type": "array",
62
+ "items": {
63
+ "type": "string",
64
+ "pattern": "\\S"
65
+ }
66
+ }
85
67
  ]
86
68
  }
87
69
  }
@@ -65,6 +65,21 @@
65
65
  "type": "string",
66
66
  "minLength": 1
67
67
  },
68
+ "base_game_version": {
69
+ "type": "string"
70
+ },
71
+ "pack_optimization_version": {
72
+ "type": "string"
73
+ },
74
+ "allow_random_seed": {
75
+ "type": "boolean"
76
+ },
77
+ "lock_template_options": {
78
+ "type": "boolean"
79
+ },
80
+ "platform_locked": {
81
+ "type": "boolean"
82
+ },
68
83
  "pack_scope": {
69
84
  "enum": [
70
85
  "world",
@@ -90,8 +105,14 @@
90
105
  "url": {
91
106
  "type": "string"
92
107
  },
108
+ "product_type": {
109
+ "type": "string"
110
+ },
93
111
  "generated_with": {
94
- "type": "object"
112
+ "type": "object",
113
+ "additionalProperties": {
114
+ "$ref": "#/definitions/stringList"
115
+ }
95
116
  }
96
117
  }
97
118
  },
@@ -121,6 +142,9 @@
121
142
  "type": "string",
122
143
  "minLength": 1
123
144
  },
145
+ "description": {
146
+ "type": "string"
147
+ },
124
148
  "language": {
125
149
  "const": "javascript"
126
150
  },
@@ -137,9 +161,31 @@
137
161
  "items": {
138
162
  "$ref": "#/definitions/dependency"
139
163
  }
164
+ },
165
+ "capabilities": {
166
+ "$ref": "#/definitions/stringList"
167
+ },
168
+ "has_education_metadata": {
169
+ "type": "boolean"
170
+ },
171
+ "subpacks": {
172
+ "type": "array",
173
+ "items": {
174
+ "type": "object",
175
+ "required": ["folder_name", "name", "memory_performance_tier"],
176
+ "properties": {
177
+ "folder_name": { "type": "string" },
178
+ "name": { "type": "string" },
179
+ "memory_performance_tier": { "type": "integer", "minimum": 0, "maximum": 5 }
180
+ }
181
+ }
140
182
  }
141
183
  },
142
184
  "definitions": {
185
+ "stringList": {
186
+ "type": "array",
187
+ "items": { "type": "string" }
188
+ },
143
189
  "namespace": {
144
190
  "type": "string",
145
191
  "pattern": "^[a-z0-9_]+$",
@@ -178,11 +224,16 @@
178
224
  "type": "string",
179
225
  "minLength": 1
180
226
  },
227
+ "optional": {
228
+ "type": "boolean"
229
+ },
181
230
  "version": {
182
231
  "type": "string",
183
232
  "minLength": 1
184
233
  }
185
234
  },
235
+ "if": { "required": ["optional"] },
236
+ "then": { "required": ["module_name"] },
186
237
  "oneOf": [
187
238
  {
188
239
  "required": [
@@ -4,16 +4,6 @@
4
4
  "type": "object",
5
5
  "additionalProperties": false,
6
6
  "properties": {
7
- "experimentalOre": {
8
- "type": "object",
9
- "additionalProperties": false,
10
- "description": "Asset preparation for Experimental_OreUI screens; ignored when the build has none.",
11
- "properties": {
12
- "clientRoot": { "type": "string", "pattern": "\\S", "description": "Windows Minecraft Content directory; defaults to a matching installed client." },
13
- "resourceRoots": { "type": "array", "items": { "type": "string", "pattern": "\\S" }, "description": "Fallback resource-pack roots after the selected RP, in priority order. Paths resolve from the project." },
14
- "dynamicTextures": { "type": "array", "uniqueItems": true, "items": { "type": "string", "pattern": "^textures/(?:[A-Za-z0-9_-]+/)*[A-Za-z0-9_-]+(?:\\.png)?$" }, "description": "Pack-local PNG textures available to live Ore images." }
15
- }
16
- },
17
7
  "debug": {
18
8
  "type": "boolean",
19
9
  "description": "Stage override for the profile debug setting."
@@ -1,3 +0,0 @@
1
- import type { FilterKind } from './types.ts';
2
- /** Recognize canonical wrapper files in an explicitly trusted checkout without executing them. */
3
- export declare function localFilterKind(script: string, directory: string): Promise<FilterKind | undefined>;
@@ -1,20 +0,0 @@
1
- import { realpath } from 'node:fs/promises';
2
- import path from 'node:path';
3
- import { stages } from '../plan.js';
4
- /** Recognize canonical wrapper files in an explicitly trusted checkout without executing them. */
5
- export async function localFilterKind(script, directory) {
6
- const canonical = await realpath(script);
7
- for (const stage of ['core', ...stages]) {
8
- try {
9
- const expected = await realpath(path.join(directory, stage, 'main.ts'));
10
- if (path.relative(expected, canonical) === '') {
11
- return stage;
12
- }
13
- }
14
- catch (error) {
15
- if (error.code !== 'ENOENT') {
16
- throw error;
17
- }
18
- }
19
- }
20
- }