@tapestry-mud/cli 0.9.0 → 0.12.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/CLAUDE.md +42 -0
- package/bin/tapestry.js +18 -5
- package/package.json +6 -3
- package/specs/README.md +59 -0
- package/specs/changes/2026-06-20-pack-esm-build.md +28 -0
- package/specs/engine-management.md +140 -0
- package/specs/harvest.md +169 -0
- package/specs/lint.config.json +1 -0
- package/specs/pack-lifecycle.md +206 -0
- package/specs/registry-auth.md +127 -0
- package/specs/validate.md +70 -0
- package/src/commands/harvest.js +12 -2
- package/src/commands/pack.js +3 -0
- package/src/commands/publish.js +2 -0
- package/src/commands/types.js +15 -0
- package/src/lib/pack-manifest.js +4 -0
- package/src/lib/registry-sink.js +117 -0
- package/src/lib/render-core.js +67 -0
- package/src/lib/ts-build.js +22 -0
- package/types/tapestry-engine.d.ts +630 -0
- package/validation-ledger.md +29 -0
package/src/lib/render-core.js
CHANGED
|
@@ -6,6 +6,44 @@ const { readYaml, writeYaml } = require('../util/yaml');
|
|
|
6
6
|
const { ensureContentGlobs } = require('./pack-manifest');
|
|
7
7
|
const { packNamespace } = require('./pack-resolve');
|
|
8
8
|
|
|
9
|
+
// Recursively collect files matching a name predicate under a directory.
|
|
10
|
+
// Returns absolute paths.
|
|
11
|
+
function collectFiles(dir, predicate, results = []) {
|
|
12
|
+
if (!fs.existsSync(dir)) {
|
|
13
|
+
return results;
|
|
14
|
+
}
|
|
15
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
16
|
+
if (entry.isDirectory()) {
|
|
17
|
+
collectFiles(path.join(dir, entry.name), predicate, results);
|
|
18
|
+
} else if (predicate(entry.name)) {
|
|
19
|
+
results.push(path.join(dir, entry.name));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return results;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Copy oracle side-car yaml files from the area source root into the area dest root,
|
|
26
|
+
// preserving relative paths and applying the divergence guard.
|
|
27
|
+
function copyOracleSideCars(areaSrcRoot, areaDestRoot, force) {
|
|
28
|
+
const oracleFiles = collectFiles(areaSrcRoot, (name) => {
|
|
29
|
+
return name === 'places-oracle.yaml' || name.endsWith('-oracle-table.yaml');
|
|
30
|
+
});
|
|
31
|
+
for (const src of oracleFiles) {
|
|
32
|
+
const rel = path.relative(areaSrcRoot, src);
|
|
33
|
+
const dest = path.join(areaDestRoot, rel);
|
|
34
|
+
const incoming = readYaml(src);
|
|
35
|
+
if (fs.existsSync(dest) && !force) {
|
|
36
|
+
const existing = readYaml(dest);
|
|
37
|
+
if (JSON.stringify(existing) !== JSON.stringify(incoming)) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
`Pack file ${dest} diverges from the side-car. Review the diff and re-run with --force to overwrite.`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
43
|
+
writeYaml(dest, incoming);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
9
47
|
// Fold one area's authored side-cars into a target pack directory. Setup-independent:
|
|
10
48
|
// it does not know whether targetDir is a real repo or a temp build dir.
|
|
11
49
|
// Returns { written, files }. Throws if there is nothing to render or a pack file diverges.
|
|
@@ -49,6 +87,35 @@ function renderArea(targetDir, { gameRoot, area, force = false }) {
|
|
|
49
87
|
written++;
|
|
50
88
|
}
|
|
51
89
|
|
|
90
|
+
// Copy oracle table side-cars: places-oracle.yaml at the area root,
|
|
91
|
+
// and any *-oracle-table.yaml files in subdirectories (mobs/, items/, etc.).
|
|
92
|
+
const areaSrcRoot = path.join(gameRoot, 'data', 'areas', area);
|
|
93
|
+
const areaDestRoot = path.join(targetDir, 'areas', area);
|
|
94
|
+
copyOracleSideCars(areaSrcRoot, areaDestRoot, force);
|
|
95
|
+
|
|
96
|
+
// Copy minted mob and item instance files (including their *-oracle-table.yaml).
|
|
97
|
+
for (const sub of ['mobs', 'items']) {
|
|
98
|
+
const srcDir = path.join(gameRoot, 'data', 'areas', area, sub);
|
|
99
|
+
if (fs.existsSync(srcDir)) {
|
|
100
|
+
const subFiles = fs.readdirSync(srcDir).filter((f) => f.endsWith('.yaml'));
|
|
101
|
+
const destDir = path.join(targetDir, 'areas', area, sub);
|
|
102
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
103
|
+
for (const file of subFiles) {
|
|
104
|
+
const src = path.join(srcDir, file);
|
|
105
|
+
const dest = path.join(destDir, file);
|
|
106
|
+
const incoming = readYaml(src);
|
|
107
|
+
if (fs.existsSync(dest) && !force) {
|
|
108
|
+
const existing = readYaml(dest);
|
|
109
|
+
if (JSON.stringify(existing) !== JSON.stringify(incoming)) {
|
|
110
|
+
throw new Error(
|
|
111
|
+
`Pack file ${dest} diverges from the side-car. Review the diff and re-run with --force to overwrite.`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
writeYaml(dest, incoming);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
52
119
|
ensureContentGlobs(targetDir);
|
|
53
120
|
reconcileDependencies(targetDir, area);
|
|
54
121
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const { spawnSync } = require('child_process');
|
|
5
|
+
|
|
6
|
+
// Compiles an ESM pack's TypeScript (scripts/**/*.ts -> dist/scripts/**/*.js) using the
|
|
7
|
+
// bundled tsc and the pack's tsconfig.json. No-op for legacy packs (raw .js, no build).
|
|
8
|
+
function buildTypeScript(cwd, manifest) {
|
|
9
|
+
const format = manifest && manifest.content && manifest.content.scripts_format;
|
|
10
|
+
if (format !== 'esm') {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const tsc = require.resolve('typescript/bin/tsc');
|
|
14
|
+
const tsconfig = path.join(cwd, 'tsconfig.json');
|
|
15
|
+
console.log('Compiling TypeScript (tsc)...');
|
|
16
|
+
const res = spawnSync(process.execPath, [tsc, '-p', tsconfig], { cwd, stdio: 'inherit' });
|
|
17
|
+
if (res.status !== 0) {
|
|
18
|
+
throw new Error('TypeScript compile failed');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = { buildTypeScript };
|