@hawkeyexl/manni 2.8.1 → 2.8.3
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 +1 -1
- package/dist/{chunk-FWB6LGBB.js → chunk-DGC4CCK3.js} +125 -41
- package/dist/chunk-DGC4CCK3.js.map +1 -0
- package/dist/{chunk-RLHN765L.js → chunk-KGI7B6DD.js} +219 -101
- package/dist/chunk-KGI7B6DD.js.map +1 -0
- package/dist/{chunk-IQO55BTU.js → chunk-KYTHN2VT.js} +2 -2
- package/dist/cli.js +3 -3
- package/dist/docmeta.js +2 -2
- package/dist/index.d.ts +81 -14
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-FWB6LGBB.js.map +0 -1
- package/dist/chunk-RLHN765L.js.map +0 -1
- /package/dist/{chunk-IQO55BTU.js.map → chunk-KYTHN2VT.js.map} +0 -0
|
@@ -8,7 +8,7 @@ var __export = (target, all) => {
|
|
|
8
8
|
// package.json
|
|
9
9
|
var package_default = {
|
|
10
10
|
name: "@hawkeyexl/manni",
|
|
11
|
-
version: "2.8.
|
|
11
|
+
version: "2.8.3",
|
|
12
12
|
description: "One command line for documentation that is meant to be checked. `manni meta` validates the presence and format of document metadata (Markdown frontmatter and more) against JSON Schema, built for CI. Formerly docmeta.",
|
|
13
13
|
type: "module",
|
|
14
14
|
bin: {
|
|
@@ -393,8 +393,8 @@ function isMember(collection, relPath) {
|
|
|
393
393
|
return !collection.exclude.some((glob) => matchesFileGlob(relPath, glob));
|
|
394
394
|
}
|
|
395
395
|
function normalizeEntry(entry) {
|
|
396
|
-
const
|
|
397
|
-
return
|
|
396
|
+
const posix5 = entry.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
397
|
+
return posix5.endsWith("/") ? posix5.slice(0, -1) : posix5;
|
|
398
398
|
}
|
|
399
399
|
function isGlob(entry) {
|
|
400
400
|
return picomatch2.scan(entry).isGlob;
|
|
@@ -5569,11 +5569,11 @@ function collectSchemaPins(config) {
|
|
|
5569
5569
|
}
|
|
5570
5570
|
function rebaseConfigSchemaRefs(config, configDir, cwd) {
|
|
5571
5571
|
if (resolve(configDir) === resolve(cwd)) return config;
|
|
5572
|
-
const
|
|
5573
|
-
const rebaseEntry = (entry) => typeof entry === "string" ?
|
|
5572
|
+
const rebase2 = (ref) => classifyRef(ref).kind === "file" && !isAbsolute(ref) ? resolve(configDir, ref) : ref;
|
|
5573
|
+
const rebaseEntry = (entry) => typeof entry === "string" ? rebase2(entry) : {
|
|
5574
5574
|
...entry,
|
|
5575
|
-
ref:
|
|
5576
|
-
...entry.source !== void 0 ? { source:
|
|
5575
|
+
ref: rebase2(entry.ref),
|
|
5576
|
+
...entry.source !== void 0 ? { source: rebase2(entry.source) } : {}
|
|
5577
5577
|
};
|
|
5578
5578
|
return {
|
|
5579
5579
|
...config,
|
|
@@ -5581,7 +5581,7 @@ function rebaseConfigSchemaRefs(config, configDir, cwd) {
|
|
|
5581
5581
|
...config.overrides ? {
|
|
5582
5582
|
overrides: config.overrides.map((o) => ({
|
|
5583
5583
|
...o,
|
|
5584
|
-
schemas: o.schemas.map(
|
|
5584
|
+
schemas: o.schemas.map(rebase2)
|
|
5585
5585
|
}))
|
|
5586
5586
|
} : {}
|
|
5587
5587
|
};
|
|
@@ -7012,12 +7012,12 @@ async function gitIgnored(paths, cwd) {
|
|
|
7012
7012
|
return answered > 0 ? { ignored, available: true } : unavailable();
|
|
7013
7013
|
}
|
|
7014
7014
|
function checkIgnore(paths, cwd) {
|
|
7015
|
-
return new Promise((
|
|
7015
|
+
return new Promise((settle2) => {
|
|
7016
7016
|
let done = false;
|
|
7017
7017
|
const finish2 = (answer) => {
|
|
7018
7018
|
if (done) return;
|
|
7019
7019
|
done = true;
|
|
7020
|
-
|
|
7020
|
+
settle2(answer);
|
|
7021
7021
|
};
|
|
7022
7022
|
let child;
|
|
7023
7023
|
try {
|
|
@@ -9323,12 +9323,12 @@ var MAX_OUTPUT_BYTES = 8 * 1024 * 1024;
|
|
|
9323
9323
|
var BinMissing = class extends Error {
|
|
9324
9324
|
};
|
|
9325
9325
|
function run(bin, args, opts) {
|
|
9326
|
-
return new Promise((
|
|
9326
|
+
return new Promise((settle2, reject) => {
|
|
9327
9327
|
let done = false;
|
|
9328
9328
|
const finish2 = (r) => {
|
|
9329
9329
|
if (done) return;
|
|
9330
9330
|
done = true;
|
|
9331
|
-
|
|
9331
|
+
settle2(r);
|
|
9332
9332
|
};
|
|
9333
9333
|
const fail2 = (err) => {
|
|
9334
9334
|
if (done) return;
|
|
@@ -11226,12 +11226,12 @@ function text(out) {
|
|
|
11226
11226
|
}
|
|
11227
11227
|
}
|
|
11228
11228
|
function runGit(args, cwd, stdin, maxBytes) {
|
|
11229
|
-
return new Promise((
|
|
11229
|
+
return new Promise((settle2, reject) => {
|
|
11230
11230
|
let done = false;
|
|
11231
11231
|
const finish2 = (out) => {
|
|
11232
11232
|
if (done) return;
|
|
11233
11233
|
done = true;
|
|
11234
|
-
|
|
11234
|
+
settle2(out);
|
|
11235
11235
|
};
|
|
11236
11236
|
const fail2 = (err) => {
|
|
11237
11237
|
if (done) return;
|
|
@@ -11769,6 +11769,20 @@ function spliceManifestValue(text2, options) {
|
|
|
11769
11769
|
);
|
|
11770
11770
|
return { text: out, line };
|
|
11771
11771
|
}
|
|
11772
|
+
function readManifestValue(text2, options) {
|
|
11773
|
+
const join11 = options.join ?? PATH_JOIN;
|
|
11774
|
+
const doc = parseDocument5(text2, { uniqueKeys: false });
|
|
11775
|
+
if (doc.errors.length > 0) return void 0;
|
|
11776
|
+
const root = doc.contents;
|
|
11777
|
+
if (!isMap5(root)) return void 0;
|
|
11778
|
+
const same = join11 === PATH_JOIN ? (a, b) => posix3.normalize(a) === posix3.normalize(b) : (a, b) => a === b;
|
|
11779
|
+
const pair = root.items.find((p) => same(keyString(p.key), options.entry));
|
|
11780
|
+
const held = pair?.value;
|
|
11781
|
+
if (!isMap5(held)) return void 0;
|
|
11782
|
+
const kv = held.items.find((p) => keyString(p.key) === options.key);
|
|
11783
|
+
const node = kv?.value;
|
|
11784
|
+
return isNode2(node) ? node.toJSON() : void 0;
|
|
11785
|
+
}
|
|
11772
11786
|
function removeManifestKey(text2, options) {
|
|
11773
11787
|
const { entry, key, file } = options;
|
|
11774
11788
|
const join11 = options.join ?? PATH_JOIN;
|
|
@@ -12349,17 +12363,17 @@ function bare(path) {
|
|
|
12349
12363
|
}
|
|
12350
12364
|
async function collectionPath(target, cwd, configDir) {
|
|
12351
12365
|
if (target === STDIN_TOKEN) return void 0;
|
|
12352
|
-
const
|
|
12353
|
-
const scanned = picomatch6.scan(
|
|
12366
|
+
const posix5 = target.replace(/\\/g, "/");
|
|
12367
|
+
const scanned = picomatch6.scan(posix5);
|
|
12354
12368
|
if (scanned.isGlob) {
|
|
12355
12369
|
const rel2 = toPosix3(relative11(configDir, resolve13(cwd, scanned.base === "" ? "." : scanned.base)));
|
|
12356
12370
|
if (isAbsolute7(rel2) || rel2 === ".." || rel2.startsWith("../")) return void 0;
|
|
12357
12371
|
return rel2 === "" ? scanned.glob : `${rel2}/${scanned.glob}`;
|
|
12358
12372
|
}
|
|
12359
|
-
const abs = resolve13(cwd,
|
|
12373
|
+
const abs = resolve13(cwd, posix5);
|
|
12360
12374
|
const rel = toPosix3(relative11(configDir, abs));
|
|
12361
12375
|
if (isAbsolute7(rel) || rel.startsWith("..")) return void 0;
|
|
12362
|
-
let directory =
|
|
12376
|
+
let directory = posix5.endsWith("/");
|
|
12363
12377
|
if (!directory) {
|
|
12364
12378
|
try {
|
|
12365
12379
|
directory = (await stat5(abs)).isDirectory();
|
|
@@ -17116,7 +17130,7 @@ function skipExpression(sql, from) {
|
|
|
17116
17130
|
}
|
|
17117
17131
|
|
|
17118
17132
|
// src/meta/commands/fill.ts
|
|
17119
|
-
import { readFile as
|
|
17133
|
+
import { readFile as readFile14 } from "node:fs/promises";
|
|
17120
17134
|
import { resolve as resolve19, extname as extname8, join as join10 } from "node:path";
|
|
17121
17135
|
import {
|
|
17122
17136
|
completeValidatedJSON,
|
|
@@ -17131,6 +17145,107 @@ import {
|
|
|
17131
17145
|
InferenceError
|
|
17132
17146
|
} from "@hawkeyexl/inference";
|
|
17133
17147
|
|
|
17148
|
+
// src/meta/core/manifest-writes.ts
|
|
17149
|
+
import { readFile as readFile13 } from "node:fs/promises";
|
|
17150
|
+
|
|
17151
|
+
// src/shared/manifest-cas.ts
|
|
17152
|
+
import { posix as posix4 } from "node:path";
|
|
17153
|
+
var COMMIT_ATTEMPTS = 5;
|
|
17154
|
+
function conflictRefusal(file) {
|
|
17155
|
+
return `${file} changed under the command while it was being written. Nothing was written to it. Re-run the command.`;
|
|
17156
|
+
}
|
|
17157
|
+
function heldManifest(path, file, before) {
|
|
17158
|
+
return { path, file, before, text: before, ops: [], bases: /* @__PURE__ */ new Map() };
|
|
17159
|
+
}
|
|
17160
|
+
function encodeValue(value) {
|
|
17161
|
+
return value === void 0 ? "absent" : JSON.stringify(value);
|
|
17162
|
+
}
|
|
17163
|
+
function baseKey(at2) {
|
|
17164
|
+
const entry = at2.join === "path" ? posix4.normalize(at2.entry) : at2.entry;
|
|
17165
|
+
return `${entry}\0${at2.key}`;
|
|
17166
|
+
}
|
|
17167
|
+
function rebaseable(held, op, codec) {
|
|
17168
|
+
const at2 = baseKey(op);
|
|
17169
|
+
if (held.bases.has(at2)) return;
|
|
17170
|
+
held.bases.set(at2, {
|
|
17171
|
+
entry: op.entry,
|
|
17172
|
+
key: op.key,
|
|
17173
|
+
join: op.join,
|
|
17174
|
+
value: encodeValue(codec.read(held.before, op))
|
|
17175
|
+
});
|
|
17176
|
+
}
|
|
17177
|
+
function rebase(held, current, codec) {
|
|
17178
|
+
for (const base of held.bases.values()) {
|
|
17179
|
+
if (encodeValue(codec.read(current, base)) !== base.value) return void 0;
|
|
17180
|
+
}
|
|
17181
|
+
let text2 = current;
|
|
17182
|
+
for (const op of held.ops) text2 = codec.apply(text2, op);
|
|
17183
|
+
return text2;
|
|
17184
|
+
}
|
|
17185
|
+
function rebaseline(held) {
|
|
17186
|
+
held.before = held.text;
|
|
17187
|
+
held.ops = [];
|
|
17188
|
+
held.bases.clear();
|
|
17189
|
+
}
|
|
17190
|
+
async function settle(held, io) {
|
|
17191
|
+
for (let attempt = 1; attempt <= COMMIT_ATTEMPTS; attempt++) {
|
|
17192
|
+
let current;
|
|
17193
|
+
try {
|
|
17194
|
+
current = await io.read(held.path);
|
|
17195
|
+
} catch (error) {
|
|
17196
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
17197
|
+
throw io.toError(`Manifest ${held.file} could not be read: ${reason}`);
|
|
17198
|
+
}
|
|
17199
|
+
if (current === held.before) {
|
|
17200
|
+
await io.write(held.path, held.text);
|
|
17201
|
+
return;
|
|
17202
|
+
}
|
|
17203
|
+
const replayed = rebase(held, current, io.codec);
|
|
17204
|
+
if (replayed === void 0) throw io.toError(conflictRefusal(held.file));
|
|
17205
|
+
held.before = current;
|
|
17206
|
+
held.text = replayed;
|
|
17207
|
+
}
|
|
17208
|
+
throw io.toError(conflictRefusal(held.file));
|
|
17209
|
+
}
|
|
17210
|
+
|
|
17211
|
+
// src/meta/core/manifest-writes.ts
|
|
17212
|
+
var manifestCodec = {
|
|
17213
|
+
apply(text2, op) {
|
|
17214
|
+
const where = { entry: op.entry, key: op.key, join: op.join, file: op.file };
|
|
17215
|
+
return op.kind === "remove" ? removeManifestKey(text2, where).text : spliceManifestValue(text2, { ...where, value: op.value }).text;
|
|
17216
|
+
},
|
|
17217
|
+
read(text2, at2) {
|
|
17218
|
+
return readManifestValue(text2, at2);
|
|
17219
|
+
}
|
|
17220
|
+
};
|
|
17221
|
+
function applyManifestOp(text2, op) {
|
|
17222
|
+
return manifestCodec.apply(text2, op);
|
|
17223
|
+
}
|
|
17224
|
+
async function holdManifestFile(path, file) {
|
|
17225
|
+
let before;
|
|
17226
|
+
try {
|
|
17227
|
+
before = await readFile13(path, "utf8");
|
|
17228
|
+
} catch (err) {
|
|
17229
|
+
throw new DocmetaError(`Manifest ${file} could not be read: ${errorMessage(err)}`);
|
|
17230
|
+
}
|
|
17231
|
+
return heldManifest(path, file, before);
|
|
17232
|
+
}
|
|
17233
|
+
function recordManifestOp(held, op) {
|
|
17234
|
+
rebaseable(held, op, manifestCodec);
|
|
17235
|
+
held.ops.push(op);
|
|
17236
|
+
}
|
|
17237
|
+
async function settleManifest(held, io = {}) {
|
|
17238
|
+
if (held.text === held.before) return false;
|
|
17239
|
+
await settle(held, {
|
|
17240
|
+
codec: manifestCodec,
|
|
17241
|
+
write: io.write ?? writeFileAtomic,
|
|
17242
|
+
read: io.read ?? ((at2) => readFile13(at2, "utf8")),
|
|
17243
|
+
toError: (message) => new DocmetaError(message)
|
|
17244
|
+
});
|
|
17245
|
+
rebaseline(held);
|
|
17246
|
+
return true;
|
|
17247
|
+
}
|
|
17248
|
+
|
|
17134
17249
|
// src/meta/commands/fill-prompt.ts
|
|
17135
17250
|
var FILL_PROMPT_VERSION = 4;
|
|
17136
17251
|
var DEFAULT_CHUNK_CHARS = 12e3;
|
|
@@ -17430,28 +17545,34 @@ async function runFill(opts) {
|
|
|
17430
17545
|
});
|
|
17431
17546
|
const heldManifests = /* @__PURE__ */ new Map();
|
|
17432
17547
|
const holding = /* @__PURE__ */ new Map();
|
|
17433
|
-
const saveManifest = (
|
|
17434
|
-
|
|
17435
|
-
const
|
|
17436
|
-
|
|
17437
|
-
|
|
17438
|
-
|
|
17548
|
+
const saveManifest = (h, ops) => {
|
|
17549
|
+
h.saving = h.saving.then(async () => {
|
|
17550
|
+
for (const op of ops) {
|
|
17551
|
+
const after = applyManifestOp(h.held.text, op);
|
|
17552
|
+
if (after === h.held.text) continue;
|
|
17553
|
+
recordManifestOp(h.held, op);
|
|
17554
|
+
h.held.text = after;
|
|
17555
|
+
}
|
|
17556
|
+
if (!dryRun) await settleManifest(h.held);
|
|
17439
17557
|
});
|
|
17440
|
-
return
|
|
17558
|
+
return h.saving;
|
|
17559
|
+
};
|
|
17560
|
+
const restorePage = async (label, before) => {
|
|
17561
|
+
try {
|
|
17562
|
+
await writeFileAtomic(resolve19(base, label), before);
|
|
17563
|
+
return `${label} was restored.`;
|
|
17564
|
+
} catch (err) {
|
|
17565
|
+
return `${label} could not be restored: ${errorMessage(err)}. Restore it from version control.`;
|
|
17566
|
+
}
|
|
17441
17567
|
};
|
|
17442
17568
|
const holdManifest = (home) => {
|
|
17443
17569
|
let held = holding.get(home.absPath);
|
|
17444
17570
|
if (held === void 0) {
|
|
17445
|
-
held =
|
|
17446
|
-
(
|
|
17447
|
-
|
|
17448
|
-
|
|
17449
|
-
|
|
17450
|
-
},
|
|
17451
|
-
(err) => {
|
|
17452
|
-
throw new DocmetaError(`Manifest ${home.file} could not be read: ${errorMessage(err)}`);
|
|
17453
|
-
}
|
|
17454
|
-
);
|
|
17571
|
+
held = holdManifestFile(home.absPath, home.file).then((m) => {
|
|
17572
|
+
const h = { held: m, saving: Promise.resolve() };
|
|
17573
|
+
heldManifests.set(home.absPath, h);
|
|
17574
|
+
return h;
|
|
17575
|
+
});
|
|
17455
17576
|
holding.set(home.absPath, held);
|
|
17456
17577
|
}
|
|
17457
17578
|
return held;
|
|
@@ -17953,52 +18074,54 @@ async function runFill(opts) {
|
|
|
17953
18074
|
metaProvenance = { written: false, skipReason: "unwritable" };
|
|
17954
18075
|
}
|
|
17955
18076
|
const helds = await Promise.all(entryWrites.map((w) => holdManifest(w.home)));
|
|
17956
|
-
const
|
|
17957
|
-
|
|
17958
|
-
|
|
17959
|
-
|
|
17960
|
-
|
|
17961
|
-
|
|
17962
|
-
|
|
17963
|
-
|
|
17964
|
-
|
|
17965
|
-
|
|
17966
|
-
|
|
17967
|
-
|
|
17968
|
-
|
|
17969
|
-
|
|
17970
|
-
|
|
17971
|
-
|
|
17972
|
-
}
|
|
17973
|
-
return texts;
|
|
17974
|
-
};
|
|
18077
|
+
const ops = [];
|
|
18078
|
+
for (const [i, w] of entryWrites.entries()) {
|
|
18079
|
+
const at2 = helds[i];
|
|
18080
|
+
if (at2 === void 0) continue;
|
|
18081
|
+
ops.push({
|
|
18082
|
+
at: at2,
|
|
18083
|
+
op: {
|
|
18084
|
+
kind: "splice",
|
|
18085
|
+
entry: w.home.entry,
|
|
18086
|
+
key: w.key,
|
|
18087
|
+
value: w.value,
|
|
18088
|
+
join: w.home.join,
|
|
18089
|
+
file: w.home.file
|
|
18090
|
+
}
|
|
18091
|
+
});
|
|
18092
|
+
}
|
|
17975
18093
|
let manifestChanged = false;
|
|
17976
18094
|
try {
|
|
17977
|
-
|
|
18095
|
+
const texts = /* @__PURE__ */ new Map();
|
|
18096
|
+
for (const { at: at2, op } of ops) {
|
|
18097
|
+
texts.set(at2.held.path, applyManifestOp(texts.get(at2.held.path) ?? at2.held.text, op));
|
|
18098
|
+
}
|
|
18099
|
+
manifestChanged = [...texts].some(([path, text2]) => heldManifests.get(path)?.held.text !== text2);
|
|
17978
18100
|
} catch (err) {
|
|
17979
18101
|
if (!(err instanceof DocmetaError)) throw err;
|
|
17980
18102
|
return errorResult(label, extractor.name, err.message, schemaSet, fields);
|
|
17981
18103
|
}
|
|
17982
18104
|
const changed = next !== content || manifestChanged;
|
|
17983
|
-
|
|
18105
|
+
const pageWritten = next !== content && !dryRun && label !== "<stdin>";
|
|
18106
|
+
if (pageWritten) {
|
|
17984
18107
|
await writeFileAtomic(resolve19(base, label), next);
|
|
17985
18108
|
}
|
|
17986
18109
|
if (manifestChanged) {
|
|
17987
|
-
|
|
18110
|
+
const perManifest = /* @__PURE__ */ new Map();
|
|
18111
|
+
for (const { at: at2, op } of ops) {
|
|
18112
|
+
const list2 = perManifest.get(at2);
|
|
18113
|
+
if (list2 === void 0) perManifest.set(at2, [op]);
|
|
18114
|
+
else list2.push(op);
|
|
18115
|
+
}
|
|
18116
|
+
const saves = [...perManifest].map(([at2, list2]) => saveManifest(at2, list2));
|
|
17988
18117
|
try {
|
|
17989
|
-
|
|
18118
|
+
await Promise.all(saves);
|
|
17990
18119
|
} catch (err) {
|
|
17991
|
-
if (!
|
|
17992
|
-
|
|
17993
|
-
|
|
17994
|
-
|
|
17995
|
-
for (const [path, text2] of texts) {
|
|
17996
|
-
const held = heldManifests.get(path);
|
|
17997
|
-
if (held === void 0 || held.text === text2) continue;
|
|
17998
|
-
held.text = text2;
|
|
17999
|
-
if (!dryRun) saves.push(saveManifest(held));
|
|
18120
|
+
if (!pageWritten) throw err;
|
|
18121
|
+
const note = await restorePage(label, content);
|
|
18122
|
+
if (err instanceof DocmetaError) throw new DocmetaError(`${err.message} ${note}`);
|
|
18123
|
+
throw err;
|
|
18000
18124
|
}
|
|
18001
|
-
await Promise.all(saves);
|
|
18002
18125
|
}
|
|
18003
18126
|
return {
|
|
18004
18127
|
file: label,
|
|
@@ -18013,7 +18136,7 @@ async function runFill(opts) {
|
|
|
18013
18136
|
const prepareAll = async () => ({
|
|
18014
18137
|
stdin: usingStdin ? await prepareOne("<stdin>", opts.stdinContent ?? "", forcedExtractor?.extensions[0] ?? "") : void 0,
|
|
18015
18138
|
files: await mapConcurrent(files, concurrency, async (file) => {
|
|
18016
|
-
const content = await
|
|
18139
|
+
const content = await readFile14(resolve19(base, file), "utf8");
|
|
18017
18140
|
return prepareOne(file, content, extname8(file));
|
|
18018
18141
|
})
|
|
18019
18142
|
});
|
|
@@ -18037,7 +18160,7 @@ async function runFill(opts) {
|
|
|
18037
18160
|
const results = [];
|
|
18038
18161
|
if (prepared.stdin !== void 0) results.push(await finish2(prepared.stdin));
|
|
18039
18162
|
results.push(...await mapConcurrent(prepared.files, concurrency, finish2));
|
|
18040
|
-
await Promise.all([...heldManifests.values()].map((
|
|
18163
|
+
await Promise.all([...heldManifests.values()].map((h) => h.saving));
|
|
18041
18164
|
if (flagged.length > 0) {
|
|
18042
18165
|
const landed = flagged.filter((w) => {
|
|
18043
18166
|
const r = results.find((x) => x.file === w.label);
|
|
@@ -18442,7 +18565,7 @@ async function mapConcurrent(items2, limit, fn) {
|
|
|
18442
18565
|
}
|
|
18443
18566
|
|
|
18444
18567
|
// src/meta/commands/derive.ts
|
|
18445
|
-
import { readFile as
|
|
18568
|
+
import { readFile as readFile15 } from "node:fs/promises";
|
|
18446
18569
|
import { extname as extname9, relative as relative14, resolve as resolve20, sep as sep10 } from "node:path";
|
|
18447
18570
|
var GENERATED_BY_ENV = "MANNI_GENERATED_BY";
|
|
18448
18571
|
var SOURCE_HINT = "narrow --sources or --fields";
|
|
@@ -18588,7 +18711,7 @@ async function runDerive(opts) {
|
|
|
18588
18711
|
});
|
|
18589
18712
|
continue;
|
|
18590
18713
|
}
|
|
18591
|
-
const content = await
|
|
18714
|
+
const content = await readFile15(absPath, "utf8");
|
|
18592
18715
|
const elements = resolveElements(label, config, membersFor(label));
|
|
18593
18716
|
try {
|
|
18594
18717
|
loaded2.set(label, {
|
|
@@ -18809,24 +18932,13 @@ async function runDerive(opts) {
|
|
|
18809
18932
|
const holdManifest = async (manifest) => {
|
|
18810
18933
|
const already = heldManifests.get(manifest.absPath);
|
|
18811
18934
|
if (already !== void 0) return already;
|
|
18812
|
-
|
|
18813
|
-
try {
|
|
18814
|
-
before = await readFile14(manifest.absPath, "utf8");
|
|
18815
|
-
} catch (err) {
|
|
18816
|
-
throw new DocmetaError(`Manifest ${manifest.file} could not be read: ${errorMessage(err)}`);
|
|
18817
|
-
}
|
|
18818
|
-
const held = { path: manifest.absPath, written: before, text: before };
|
|
18935
|
+
const held = await holdManifestFile(manifest.absPath, manifest.file);
|
|
18819
18936
|
heldManifests.set(manifest.absPath, held);
|
|
18820
18937
|
return held;
|
|
18821
18938
|
};
|
|
18822
18939
|
const results = [];
|
|
18823
18940
|
const saveManifests = async () => {
|
|
18824
|
-
for (const held of heldManifests.values())
|
|
18825
|
-
if (held.text !== held.written) {
|
|
18826
|
-
await writeFileAtomic(held.path, held.text);
|
|
18827
|
-
held.written = held.text;
|
|
18828
|
-
}
|
|
18829
|
-
}
|
|
18941
|
+
for (const held of heldManifests.values()) await settleManifest(held);
|
|
18830
18942
|
};
|
|
18831
18943
|
let settled = false;
|
|
18832
18944
|
try {
|
|
@@ -18903,12 +19015,15 @@ async function runDerive(opts) {
|
|
|
18903
19015
|
}
|
|
18904
19016
|
let changed = false;
|
|
18905
19017
|
const staged = /* @__PURE__ */ new Map();
|
|
18906
|
-
const
|
|
19018
|
+
const stagedOps = [];
|
|
19019
|
+
const stage = async (manifest, op) => {
|
|
18907
19020
|
const held = await holdManifest(manifest);
|
|
18908
19021
|
const before = staged.get(held.path) ?? held.text;
|
|
18909
|
-
const after =
|
|
19022
|
+
const after = applyManifestOp(before, op);
|
|
18910
19023
|
staged.set(held.path, after);
|
|
18911
|
-
|
|
19024
|
+
if (after === before) return false;
|
|
19025
|
+
stagedOps.push({ held, op });
|
|
19026
|
+
return true;
|
|
18912
19027
|
};
|
|
18913
19028
|
const manifestWritten = [];
|
|
18914
19029
|
const entryWritten = [];
|
|
@@ -18917,7 +19032,7 @@ async function runDerive(opts) {
|
|
|
18917
19032
|
const plan = toManifest.judged.plan;
|
|
18918
19033
|
const edited = await stage(
|
|
18919
19034
|
place.manifest,
|
|
18920
|
-
|
|
19035
|
+
plan.length === 0 ? { ...where, kind: "remove" } : { ...where, kind: "splice", value: plan }
|
|
18921
19036
|
);
|
|
18922
19037
|
if (edited) {
|
|
18923
19038
|
changed = true;
|
|
@@ -18927,16 +19042,14 @@ async function runDerive(opts) {
|
|
|
18927
19042
|
try {
|
|
18928
19043
|
for (const { f, home, entry } of toEntries) {
|
|
18929
19044
|
const value = isMarked(f.field) ? await sealField(f.field, f.derived, marks.marked) : f.derived;
|
|
18930
|
-
const edited = await stage(
|
|
18931
|
-
|
|
18932
|
-
|
|
18933
|
-
|
|
18934
|
-
|
|
18935
|
-
|
|
18936
|
-
|
|
18937
|
-
|
|
18938
|
-
}).text
|
|
18939
|
-
);
|
|
19045
|
+
const edited = await stage(home, {
|
|
19046
|
+
kind: "splice",
|
|
19047
|
+
entry,
|
|
19048
|
+
key: f.field,
|
|
19049
|
+
value,
|
|
19050
|
+
join: home.join,
|
|
19051
|
+
file: home.file
|
|
19052
|
+
});
|
|
18940
19053
|
if (edited) {
|
|
18941
19054
|
changed = true;
|
|
18942
19055
|
manifestWritten.push(f);
|
|
@@ -18999,6 +19112,7 @@ async function runDerive(opts) {
|
|
|
18999
19112
|
}
|
|
19000
19113
|
}
|
|
19001
19114
|
}
|
|
19115
|
+
for (const { held, op } of stagedOps) recordManifestOp(held, op);
|
|
19002
19116
|
for (const [path, text2] of staged) {
|
|
19003
19117
|
const held = heldManifests.get(path);
|
|
19004
19118
|
if (held !== void 0) held.text = text2;
|
|
@@ -19881,6 +19995,7 @@ export {
|
|
|
19881
19995
|
orphanJoins,
|
|
19882
19996
|
orphanError,
|
|
19883
19997
|
spliceManifestValue,
|
|
19998
|
+
readManifestValue,
|
|
19884
19999
|
removeManifestKey,
|
|
19885
20000
|
LOCATION_KEYWORD,
|
|
19886
20001
|
LOCATION_EXTERNAL_SCHEMA,
|
|
@@ -19929,6 +20044,9 @@ export {
|
|
|
19929
20044
|
runVendorSchema,
|
|
19930
20045
|
runInferSchema,
|
|
19931
20046
|
runQuery,
|
|
20047
|
+
heldManifest,
|
|
20048
|
+
rebaseable,
|
|
20049
|
+
settle,
|
|
19932
20050
|
runFill,
|
|
19933
20051
|
runDerive,
|
|
19934
20052
|
deriveFailed,
|
|
@@ -19947,4 +20065,4 @@ export {
|
|
|
19947
20065
|
renderQuery,
|
|
19948
20066
|
renderQueryCsv
|
|
19949
20067
|
};
|
|
19950
|
-
//# sourceMappingURL=chunk-
|
|
20068
|
+
//# sourceMappingURL=chunk-KGI7B6DD.js.map
|