@heroiclands/package-build 8.1.0 → 10.0.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 (122) hide show
  1. package/CHANGELOG.md +748 -0
  2. package/CONTENT.md +273 -13
  3. package/bin/content-build.mjs +479 -123
  4. package/bin/package-build.mjs +27 -69
  5. package/bin/report.mjs +1 -2
  6. package/bundle.mjs +2 -10
  7. package/config.mjs +31 -106
  8. package/container.mjs +13 -57
  9. package/content-config.mjs +300 -188
  10. package/coverage.mjs +14 -55
  11. package/deploy.mjs +4 -13
  12. package/docs/content-format.md +1418 -0
  13. package/e2e.mjs +16 -55
  14. package/engine/address-charset.mjs +62 -0
  15. package/engine/address-diff.mjs +1 -4
  16. package/engine/alias-index.mjs +153 -0
  17. package/engine/base-compiler.mjs +203 -31
  18. package/engine/code-fences.mjs +4 -13
  19. package/engine/compendiums.mjs +13 -37
  20. package/engine/content-address.mjs +6 -10
  21. package/engine/content-format-check.mjs +570 -0
  22. package/engine/content-format.mjs +253 -0
  23. package/engine/content-links.mjs +144 -99
  24. package/engine/content-lint.mjs +12 -16
  25. package/engine/content-slug.mjs +2 -6
  26. package/engine/content-tables.mjs +26 -79
  27. package/engine/diagnostics.mjs +37 -15
  28. package/engine/document-subtypes.mjs +440 -0
  29. package/engine/field-reference.mjs +6 -20
  30. package/engine/field-spec.mjs +49 -45
  31. package/engine/foreign-catalog.mjs +7 -22
  32. package/engine/foreign-manifests.mjs +1 -4
  33. package/engine/frontmatter-lint.mjs +347 -43
  34. package/engine/frontmatter.mjs +3 -8
  35. package/engine/generate.mjs +36 -20
  36. package/engine/helpers.mjs +54 -81
  37. package/engine/homepage.mjs +4 -15
  38. package/engine/ids.mjs +21 -12
  39. package/engine/index.mjs +15 -0
  40. package/engine/item-registry.mjs +72 -9
  41. package/engine/journals.mjs +4 -14
  42. package/engine/kb-manifest.mjs +41 -24
  43. package/engine/macros.mjs +2 -10
  44. package/engine/manifest-emit.mjs +6 -17
  45. package/engine/map-notes.mjs +53 -87
  46. package/engine/note-claims.mjs +383 -0
  47. package/engine/note-package.mjs +1 -4
  48. package/engine/note-vocabulary.mjs +678 -0
  49. package/engine/pack-config.mjs +56 -60
  50. package/engine/pack-router.mjs +18 -8
  51. package/engine/prose-config.mjs +20 -4
  52. package/engine/prose-lint.mjs +61 -17
  53. package/engine/region-events.mjs +1 -3
  54. package/engine/retired-fields.mjs +117 -3
  55. package/engine/scene-levels.mjs +8 -22
  56. package/engine/scenes.mjs +31 -47
  57. package/engine/schema-check.mjs +348 -7
  58. package/engine/schema-extract.mjs +11 -39
  59. package/engine/site-build.mjs +13 -38
  60. package/engine/site-index.mjs +40 -35
  61. package/engine/system-block.mjs +513 -0
  62. package/engine/web-wikilinks.mjs +115 -92
  63. package/engine/wikilink-syntax.mjs +30 -0
  64. package/engine/wikilinks.mjs +147 -183
  65. package/index.mjs +1 -5
  66. package/lang.mjs +1 -3
  67. package/manifest.mjs +10 -37
  68. package/markdownlint-config.mjs +1 -5
  69. package/package.json +6 -2
  70. package/sohl/actors.mjs +251 -68
  71. package/sohl/being-info.mjs +3 -6
  72. package/sohl/document-subtypes.mjs +82 -0
  73. package/sohl/index.mjs +4 -6
  74. package/sohl/item-builders.mjs +1 -3
  75. package/sohl/item-fields.mjs +16 -34
  76. package/sohl/items.mjs +111 -17
  77. package/sohl/kb-passes.mjs +29 -39
  78. package/sohl/note-schemas.mjs +11 -7
  79. package/sohl/skill-base.mjs +7 -23
  80. package/stage.mjs +3 -13
  81. package/templates.mjs +4 -15
  82. package/types/bundle.d.mts +1 -1
  83. package/types/container.d.mts +2 -2
  84. package/types/content-config.d.mts +48 -4
  85. package/types/coverage.d.mts +1 -1
  86. package/types/e2e.d.mts +4 -4
  87. package/types/engine/address-charset.d.mts +45 -0
  88. package/types/engine/alias-index.d.mts +122 -0
  89. package/types/engine/base-compiler.d.mts +132 -4
  90. package/types/engine/content-address.d.mts +2 -2
  91. package/types/engine/content-format-check.d.mts +163 -0
  92. package/types/engine/content-format.d.mts +101 -0
  93. package/types/engine/content-links.d.mts +16 -1
  94. package/types/engine/content-lint.d.mts +6 -0
  95. package/types/engine/diagnostics.d.mts +29 -0
  96. package/types/engine/document-subtypes.d.mts +233 -0
  97. package/types/engine/field-spec.d.mts +76 -23
  98. package/types/engine/frontmatter-lint.d.mts +47 -2
  99. package/types/engine/generate.d.mts +15 -2
  100. package/types/engine/helpers.d.mts +22 -14
  101. package/types/engine/ids.d.mts +10 -0
  102. package/types/engine/index.d.mts +5 -0
  103. package/types/engine/item-registry.d.mts +21 -2
  104. package/types/engine/kb-manifest.d.mts +35 -8
  105. package/types/engine/map-notes.d.mts +21 -11
  106. package/types/engine/note-claims.d.mts +113 -0
  107. package/types/engine/note-vocabulary.d.mts +251 -0
  108. package/types/engine/pack-config.d.mts +4 -3
  109. package/types/engine/pack-router.d.mts +4 -4
  110. package/types/engine/prose-lint.d.mts +6 -2
  111. package/types/engine/retired-fields.d.mts +73 -2
  112. package/types/engine/schema-check.d.mts +182 -0
  113. package/types/engine/schema-extract.d.mts +1 -1
  114. package/types/engine/site-index.d.mts +1 -1
  115. package/types/engine/system-block.d.mts +281 -0
  116. package/types/engine/web-wikilinks.d.mts +23 -12
  117. package/types/engine/wikilink-syntax.d.mts +29 -0
  118. package/types/manifest.d.mts +1 -1
  119. package/types/sohl/actors.d.mts +62 -6
  120. package/types/sohl/document-subtypes.d.mts +14 -0
  121. package/types/sohl/index.d.mts +1 -0
  122. package/types/sohl/items.d.mts +21 -0
package/container.mjs CHANGED
@@ -155,10 +155,7 @@ export function containerName(packageId, stage, base = null) {
155
155
  * @returns {number} The host port.
156
156
  * @throws {Error} When the stage has no port from any source.
157
157
  */
158
- export function resolveStagePort(
159
- stage,
160
- { env = process.env, stages = {} } = {},
161
- ) {
158
+ export function resolveStagePort(stage, { env = process.env, stages = {} } = {}) {
162
159
  const fromEnv = env[`FOUNDRYVTT_${stage.toUpperCase()}_PORT`]?.trim();
163
160
  const port =
164
161
  fromEnv ? Number(fromEnv)
@@ -205,12 +202,7 @@ const EXACT_BUILD = /^\d+\.\d+$/;
205
202
  */
206
203
  export function resolveFoundryVersion(
207
204
  stage,
208
- {
209
- env = process.env,
210
- stages = {},
211
- compatibilityMinimum = null,
212
- e2eStage = "test",
213
- } = {},
205
+ { env = process.env, stages = {}, compatibilityMinimum = null, e2eStage = "test" } = {},
214
206
  ) {
215
207
  const fromEnv = env[`FOUNDRYVTT_${stage.toUpperCase()}_VERSION`]?.trim();
216
208
  if (fromEnv) return fromEnv;
@@ -267,9 +259,7 @@ export function resolveWorld(stage, { env = process.env, stages = {} } = {}) {
267
259
  const fromEnv = env[`FOUNDRYVTT_${stage.toUpperCase()}_WORLD`];
268
260
  if (fromEnv !== undefined) return fromEnv.trim();
269
261
  const declared = stages[stage]?.world;
270
- return declared === undefined || declared === null ?
271
- null
272
- : String(declared);
262
+ return declared === undefined || declared === null ? null : String(declared);
273
263
  }
274
264
 
275
265
  /**
@@ -387,12 +377,7 @@ export function dockerRunArgs({
387
377
  `${dataRoot}:/data`,
388
378
  ];
389
379
  if (cacheDir) {
390
- args.push(
391
- "--volume",
392
- `${cacheDir}:${CACHE_MOUNT}`,
393
- "-e",
394
- `CONTAINER_CACHE=${CACHE_MOUNT}`,
395
- );
380
+ args.push("--volume", `${cacheDir}:${CACHE_MOUNT}`, "-e", `CONTAINER_CACHE=${CACHE_MOUNT}`);
396
381
  }
397
382
  for (const [key, value] of passthroughEnv(env)) {
398
383
  args.push("-e", `${key}=${value}`);
@@ -414,10 +399,7 @@ export function dockerRunArgs({
414
399
  export function runDocker(args) {
415
400
  const result = spawnSync("docker", args, { stdio: "inherit" });
416
401
  if (result.error) {
417
- if (
418
- /** @type {NodeJS.ErrnoException} */ (result.error).code ===
419
- "ENOENT"
420
- ) {
402
+ if (/** @type {NodeJS.ErrnoException} */ (result.error).code === "ENOENT") {
421
403
  throw new Error(
422
404
  "docker was not found on PATH. Install Docker and make sure " +
423
405
  "the `docker` CLI is available.",
@@ -464,13 +446,7 @@ export function containerExists(name, runningOnly = false) {
464
446
  * @returns {string[]} The container names.
465
447
  */
466
448
  export function runningFoundryContainers(except = "") {
467
- return captureDocker([
468
- "ps",
469
- "--filter",
470
- "name=-foundry-",
471
- "--format",
472
- "{{.Names}}",
473
- ])
449
+ return captureDocker(["ps", "--filter", "name=-foundry-", "--format", "{{.Names}}"])
474
450
  .split("\n")
475
451
  .filter((name) => name && name !== except);
476
452
  }
@@ -559,26 +535,18 @@ export function resolveContainer({ stage, config, env = process.env }) {
559
535
  * @param {(message: string) => void} [opts.log] - Progress reporting.
560
536
  * @returns {number} The exit status.
561
537
  */
562
- export function startContainer(
563
- container,
564
- { dataRoot, env = process.env, log = () => {} },
565
- ) {
538
+ export function startContainer(container, { dataRoot, env = process.env, log = () => {} }) {
566
539
  if (containerExists(container.name)) {
567
540
  // Nothing is running against this data root — we are about to start it
568
541
  // — so any lock present was left by a previous crash.
569
- if (!containerExists(container.name, true))
570
- clearStaleLock(dataRoot, log);
571
- log(
572
- `Starting existing container '${container.name}' → ${container.url}`,
573
- );
542
+ if (!containerExists(container.name, true)) clearStaleLock(dataRoot, log);
543
+ log(`Starting existing container '${container.name}' → ${container.url}`);
574
544
  return runDocker(["start", container.name]);
575
545
  }
576
546
 
577
547
  clearStaleLock(dataRoot, log);
578
548
  if (container.cacheDir && !fs.existsSync(container.cacheDir)) {
579
- throw new Error(
580
- `FOUNDRYVTT_CACHE directory does not exist: ${container.cacheDir}.`,
581
- );
549
+ throw new Error(`FOUNDRYVTT_CACHE directory does not exist: ${container.cacheDir}.`);
582
550
  }
583
551
  log(
584
552
  `Creating container '${container.name}' from ${container.image}\n` +
@@ -634,13 +602,7 @@ export function removeContainer(name, log = () => {}) {
634
602
  * @returns {number} The exit status.
635
603
  * @throws {Error} On an unknown action, or a stage with no usable data root.
636
604
  */
637
- export function containerAction({
638
- action,
639
- stage,
640
- config,
641
- env = process.env,
642
- log = () => {},
643
- }) {
605
+ export function containerAction({ action, stage, config, env = process.env, log = () => {} }) {
644
606
  if (!CONTAINER_ACTIONS.includes(action)) {
645
607
  throw new Error(
646
608
  `Invalid container action '${action}'. Valid actions are: ` +
@@ -677,12 +639,7 @@ export function containerAction({
677
639
  removeContainer(container.name, log);
678
640
  return 0;
679
641
  case "status":
680
- return runDocker([
681
- "ps",
682
- "-a",
683
- "--filter",
684
- `name=^${container.name}$`,
685
- ]);
642
+ return runDocker(["ps", "-a", "--filter", `name=^${container.name}$`]);
686
643
  case "logs":
687
644
  return runDocker(["logs", "-f", container.name]);
688
645
  default:
@@ -702,8 +659,7 @@ function requireDataRoot(stage, env) {
702
659
  const dataRoot = resolveDataRoot(stage, { env });
703
660
  if (!fs.existsSync(dataRoot)) {
704
661
  throw new Error(
705
- `Data directory does not exist: ${dataRoot} (from ` +
706
- `${dataEnvVar(stage)}).`,
662
+ `Data directory does not exist: ${dataRoot} (from ` + `${dataEnvVar(stage)}).`,
707
663
  );
708
664
  }
709
665
  return dataRoot;