@blue-labs/repository-generator 4.0.2-rc.0 → 4.1.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/README.md +2 -1
- package/dist/bin/blue-repo-generator.js +1 -1
- package/dist/bin/blue-repo-generator.mjs +1 -1
- package/dist/generateRepository-B7eem2l_.mjs +969 -0
- package/dist/generateRepository-DUT9zf8k.js +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/lib/core/blueIds.d.ts +4 -2
- package/dist/lib/core/blueIds.d.ts.map +1 -1
- package/dist/lib/core/contractValidation.d.ts.map +1 -1
- package/dist/lib/core/graph.d.ts +3 -0
- package/dist/lib/core/graph.d.ts.map +1 -1
- package/dist/lib/generateRepository.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/generateRepository-BiRDvOfc.mjs +0 -706
- package/dist/generateRepository-DDbll3Cz.js +0 -1
|
@@ -0,0 +1,969 @@
|
|
|
1
|
+
import * as D from "path";
|
|
2
|
+
import k from "path";
|
|
3
|
+
import A from "fs";
|
|
4
|
+
import { Properties as G, yamlBlueParse as q, MergingProcessors as B, Blue as j, createNodeProvider as H, BlueNode as X, BlueIdCalculator as Z } from "@blue-labs/language";
|
|
5
|
+
import { OBJECT_CONTRACTS as Q, RESERVED_ATTRIBUTES_POINTER_SEGMENTS as ee, validateAttributesAddedPointer as te, parsePointer as ne, OBJECT_SCHEMA as T, validateStableDoesNotDependOnDev as re } from "@blue-labs/repository-contract";
|
|
6
|
+
import oe from "fast-json-patch";
|
|
7
|
+
import se from "js-yaml";
|
|
8
|
+
const V = /* @__PURE__ */ new Set([...G.CORE_TYPES]), x = G.CORE_TYPE_NAME_TO_BLUE_ID_MAP, O = "Blue Repository", m = {
|
|
9
|
+
Dev: "dev",
|
|
10
|
+
Stable: "stable"
|
|
11
|
+
}, ie = /* @__PURE__ */ new Set([
|
|
12
|
+
".git",
|
|
13
|
+
".github",
|
|
14
|
+
".husky",
|
|
15
|
+
"node_modules",
|
|
16
|
+
".nx",
|
|
17
|
+
".vscode",
|
|
18
|
+
".idea"
|
|
19
|
+
]);
|
|
20
|
+
function ae(e) {
|
|
21
|
+
const r = A.readdirSync(e, { withFileTypes: !0 }), n = /* @__PURE__ */ new Map();
|
|
22
|
+
for (const t of r) {
|
|
23
|
+
if (!t.isDirectory() || ie.has(t.name))
|
|
24
|
+
continue;
|
|
25
|
+
const o = k.join(e, t.name), s = W(o);
|
|
26
|
+
if (s.length !== 0)
|
|
27
|
+
for (const a of s) {
|
|
28
|
+
const c = a.endsWith(".dev.blue") ? m.Dev : m.Stable, i = ce(a), f = ue(i, a), u = `${t.name}/${f}`, l = n.get(u);
|
|
29
|
+
if (l)
|
|
30
|
+
throw l.status !== c ? new Error(
|
|
31
|
+
`Type ${u} has both stable and dev definitions (${l.filePath} and ${a}).`
|
|
32
|
+
) : new Error(
|
|
33
|
+
`Type ${u} is defined multiple times (${l.filePath} and ${a}).`
|
|
34
|
+
);
|
|
35
|
+
const y = fe(i, a);
|
|
36
|
+
n.set(u, {
|
|
37
|
+
packageName: t.name,
|
|
38
|
+
typeName: f,
|
|
39
|
+
status: c,
|
|
40
|
+
content: i,
|
|
41
|
+
filePath: a,
|
|
42
|
+
references: y
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return n;
|
|
47
|
+
}
|
|
48
|
+
function ce(e) {
|
|
49
|
+
const r = A.readFileSync(e, "utf8"), n = q(r);
|
|
50
|
+
if (!C(n))
|
|
51
|
+
throw new Error(`Type file ${e} must contain a YAML object.`);
|
|
52
|
+
return n;
|
|
53
|
+
}
|
|
54
|
+
function ue(e, r) {
|
|
55
|
+
if (!C(e) || typeof e.name != "string")
|
|
56
|
+
throw new Error(`Type file ${r} is missing required "name" field.`);
|
|
57
|
+
return e.name;
|
|
58
|
+
}
|
|
59
|
+
function W(e) {
|
|
60
|
+
const r = A.readdirSync(e, { withFileTypes: !0 }), n = [];
|
|
61
|
+
for (const t of r) {
|
|
62
|
+
if (t.isDirectory()) {
|
|
63
|
+
n.push(...W(k.join(e, t.name)));
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
(t.name.endsWith(".blue") || t.name.endsWith(".dev.blue")) && n.push(k.join(e, t.name));
|
|
67
|
+
}
|
|
68
|
+
return n;
|
|
69
|
+
}
|
|
70
|
+
function fe(e, r) {
|
|
71
|
+
const n = /* @__PURE__ */ new Set(), t = (o) => {
|
|
72
|
+
if (Array.isArray(o)) {
|
|
73
|
+
o.forEach((a) => t(a));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (!C(o))
|
|
77
|
+
return;
|
|
78
|
+
const s = (a) => {
|
|
79
|
+
if (typeof a == "string" && !V.has(a)) {
|
|
80
|
+
if (!a.includes("/"))
|
|
81
|
+
throw new Error(
|
|
82
|
+
`Invalid type reference "${a}" in ${r}. Use <Package>/<Type> for non-primitive references.`
|
|
83
|
+
);
|
|
84
|
+
n.add(a);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
s(o.type), s(o.itemType), s(o.keyType), s(o.valueType), Object.values(o).forEach((a) => t(a));
|
|
88
|
+
};
|
|
89
|
+
return t(e), n;
|
|
90
|
+
}
|
|
91
|
+
function C(e) {
|
|
92
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
93
|
+
}
|
|
94
|
+
function le(e) {
|
|
95
|
+
const r = /* @__PURE__ */ new Map();
|
|
96
|
+
for (const [n, t] of e) {
|
|
97
|
+
const o = /* @__PURE__ */ new Set();
|
|
98
|
+
for (const s of t.references) {
|
|
99
|
+
if (!e.has(s))
|
|
100
|
+
throw new Error(
|
|
101
|
+
`Type ${n} references unknown alias ${s}. Ensure the target type exists.`
|
|
102
|
+
);
|
|
103
|
+
o.add(s);
|
|
104
|
+
}
|
|
105
|
+
r.set(n, o);
|
|
106
|
+
}
|
|
107
|
+
return r;
|
|
108
|
+
}
|
|
109
|
+
function de(e) {
|
|
110
|
+
const r = [], n = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), o = [], s = /* @__PURE__ */ new Set();
|
|
111
|
+
let a = 0;
|
|
112
|
+
const c = (i) => {
|
|
113
|
+
n.set(i, a), t.set(i, a), a += 1, o.push(i), s.add(i);
|
|
114
|
+
for (const u of e.get(i) ?? []) {
|
|
115
|
+
if (!n.has(u)) {
|
|
116
|
+
c(u), t.set(
|
|
117
|
+
i,
|
|
118
|
+
Math.min(
|
|
119
|
+
t.get(i) ?? 0,
|
|
120
|
+
t.get(u) ?? 0
|
|
121
|
+
)
|
|
122
|
+
);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
s.has(u) && t.set(
|
|
126
|
+
i,
|
|
127
|
+
Math.min(t.get(i) ?? 0, n.get(u) ?? 0)
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
if (t.get(i) !== n.get(i))
|
|
131
|
+
return;
|
|
132
|
+
const f = [];
|
|
133
|
+
for (; o.length > 0; ) {
|
|
134
|
+
const u = o.pop();
|
|
135
|
+
if (!u || (s.delete(u), f.push(u), u === i))
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
r.push(f.sort((u, l) => u.localeCompare(l)));
|
|
139
|
+
};
|
|
140
|
+
for (const i of e.keys())
|
|
141
|
+
n.has(i) || c(i);
|
|
142
|
+
return r;
|
|
143
|
+
}
|
|
144
|
+
function pe(e) {
|
|
145
|
+
const r = de(e), n = /* @__PURE__ */ new Map();
|
|
146
|
+
r.forEach((c, i) => {
|
|
147
|
+
c.forEach((f) => n.set(f, i));
|
|
148
|
+
});
|
|
149
|
+
const t = /* @__PURE__ */ new Map();
|
|
150
|
+
r.forEach(
|
|
151
|
+
(c, i) => t.set(i, /* @__PURE__ */ new Set())
|
|
152
|
+
);
|
|
153
|
+
for (const [c, i] of e) {
|
|
154
|
+
const f = n.get(c);
|
|
155
|
+
if (f !== void 0)
|
|
156
|
+
for (const u of i) {
|
|
157
|
+
const l = n.get(u);
|
|
158
|
+
l !== void 0 && l !== f && t.get(f)?.add(l);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const o = [], s = /* @__PURE__ */ new Set(), a = (c) => {
|
|
162
|
+
if (!s.has(c)) {
|
|
163
|
+
s.add(c);
|
|
164
|
+
for (const i of t.get(c) ?? [])
|
|
165
|
+
a(i);
|
|
166
|
+
o.push(c);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
for (const c of t.keys())
|
|
170
|
+
a(c);
|
|
171
|
+
return o.map((c) => r[c] ?? []);
|
|
172
|
+
}
|
|
173
|
+
function ye(e, r) {
|
|
174
|
+
const n = /* @__PURE__ */ new Map(), t = (o, s = /* @__PURE__ */ new Set()) => {
|
|
175
|
+
if (n.has(o))
|
|
176
|
+
return n.get(o) ?? !1;
|
|
177
|
+
if (s.has(o))
|
|
178
|
+
return !1;
|
|
179
|
+
s.add(o);
|
|
180
|
+
const a = e.get(o) || /* @__PURE__ */ new Set();
|
|
181
|
+
for (const c of a) {
|
|
182
|
+
const i = r.get(c);
|
|
183
|
+
if (i && (i.status === m.Dev || t(c, s)))
|
|
184
|
+
return s.delete(o), n.set(o, !0), !0;
|
|
185
|
+
}
|
|
186
|
+
return s.delete(o), n.set(o, !1), !1;
|
|
187
|
+
};
|
|
188
|
+
for (const [o, s] of r)
|
|
189
|
+
if (s.status === m.Stable && t(o))
|
|
190
|
+
throw new Error(
|
|
191
|
+
`Stable type ${o} depends on a dev type. Stable types may only depend on other stable types.`
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
function I(e) {
|
|
195
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
196
|
+
}
|
|
197
|
+
function h(e) {
|
|
198
|
+
return I(e) ? Object.getPrototypeOf(e) === Object.prototype : !1;
|
|
199
|
+
}
|
|
200
|
+
function S(e) {
|
|
201
|
+
if (Array.isArray(e))
|
|
202
|
+
return e.map((r) => S(r));
|
|
203
|
+
if (h(e)) {
|
|
204
|
+
const r = {};
|
|
205
|
+
for (const [n, t] of Object.entries(e))
|
|
206
|
+
r[n] = S(t);
|
|
207
|
+
return r;
|
|
208
|
+
}
|
|
209
|
+
return e;
|
|
210
|
+
}
|
|
211
|
+
function P(e) {
|
|
212
|
+
return e.map((r) => ({
|
|
213
|
+
repositoryVersionIndex: r.repositoryVersionIndex,
|
|
214
|
+
typeBlueId: r.typeBlueId,
|
|
215
|
+
attributesAdded: [...r.attributesAdded]
|
|
216
|
+
}));
|
|
217
|
+
}
|
|
218
|
+
const ge = /^\$\{([\s\S]*)\}$/;
|
|
219
|
+
class me {
|
|
220
|
+
process(r, n) {
|
|
221
|
+
const t = n.getValue();
|
|
222
|
+
if (U(t)) {
|
|
223
|
+
const o = n.clone();
|
|
224
|
+
return o.setValue(t), o.setProperties(void 0), o.setItems(void 0), o.setType(void 0), o;
|
|
225
|
+
}
|
|
226
|
+
return r;
|
|
227
|
+
}
|
|
228
|
+
postProcess(r, n) {
|
|
229
|
+
const t = n.getValue();
|
|
230
|
+
if (U(t) && r.getValue() !== t) {
|
|
231
|
+
const o = r.clone();
|
|
232
|
+
return o.setValue(t), o;
|
|
233
|
+
}
|
|
234
|
+
return r;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
function U(e) {
|
|
238
|
+
return typeof e != "string" || !ge.test(e) ? !1 : e.indexOf("${") === e.lastIndexOf("${");
|
|
239
|
+
}
|
|
240
|
+
function he() {
|
|
241
|
+
return new B.SequentialMergingProcessor([
|
|
242
|
+
new B.ValuePropagator(),
|
|
243
|
+
new me(),
|
|
244
|
+
new B.TypeAssigner(),
|
|
245
|
+
new B.ListProcessor(),
|
|
246
|
+
new B.DictionaryProcessor(),
|
|
247
|
+
new B.MetadataPropagator(),
|
|
248
|
+
new B.BasicTypesVerifier()
|
|
249
|
+
]);
|
|
250
|
+
}
|
|
251
|
+
const Y = "00000000000000000000000000000000000000000000";
|
|
252
|
+
function we(e, r, n, t) {
|
|
253
|
+
const o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), c = new j(), i = H((l) => be(l) ? [new X().setReferenceBlueId(l)] : Ie(a, l).map(
|
|
254
|
+
(y) => c.jsonValueToNode(y)
|
|
255
|
+
)), u = { blue: new j({
|
|
256
|
+
nodeProvider: i,
|
|
257
|
+
mergingProcessor: he()
|
|
258
|
+
}), contentByBlueId: a };
|
|
259
|
+
for (const l of e) {
|
|
260
|
+
if (Ee(l, n)) {
|
|
261
|
+
ve({
|
|
262
|
+
component: l,
|
|
263
|
+
discovered: r,
|
|
264
|
+
previousTypes: t,
|
|
265
|
+
aliasToBlueId: o,
|
|
266
|
+
aliasToStorageContent: s,
|
|
267
|
+
context: u
|
|
268
|
+
});
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
const y = l[0];
|
|
272
|
+
if (!y)
|
|
273
|
+
continue;
|
|
274
|
+
const g = r.get(y);
|
|
275
|
+
g && Be({
|
|
276
|
+
alias: y,
|
|
277
|
+
type: g,
|
|
278
|
+
previousTypes: t,
|
|
279
|
+
aliasToBlueId: o,
|
|
280
|
+
aliasToStorageContent: s,
|
|
281
|
+
context: u
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
return { aliasToBlueId: o, aliasToStorageContent: s };
|
|
285
|
+
}
|
|
286
|
+
function Ie(e, r) {
|
|
287
|
+
const n = J(r);
|
|
288
|
+
if (n === void 0)
|
|
289
|
+
return [];
|
|
290
|
+
const t = e.get(n.baseBlueId);
|
|
291
|
+
if (t === void 0)
|
|
292
|
+
return [];
|
|
293
|
+
if (n.index === void 0)
|
|
294
|
+
return Array.isArray(t) ? t : [t];
|
|
295
|
+
if (!Array.isArray(t))
|
|
296
|
+
return n.index === 0 ? [t] : [];
|
|
297
|
+
const o = t[n.index];
|
|
298
|
+
return o === void 0 ? [] : [o];
|
|
299
|
+
}
|
|
300
|
+
function J(e) {
|
|
301
|
+
const r = e.indexOf("#");
|
|
302
|
+
if (r === -1)
|
|
303
|
+
return { baseBlueId: e };
|
|
304
|
+
const n = e.slice(0, r), t = e.slice(r + 1), o = Number(t);
|
|
305
|
+
if (!(!Number.isInteger(o) || o < 0))
|
|
306
|
+
return { baseBlueId: n, index: o };
|
|
307
|
+
}
|
|
308
|
+
function be(e) {
|
|
309
|
+
return e === Y || /^this#\d+$/.test(e);
|
|
310
|
+
}
|
|
311
|
+
function $(e, r, n = !1, t = !1) {
|
|
312
|
+
if (Array.isArray(e))
|
|
313
|
+
return e.map(
|
|
314
|
+
(s) => $(
|
|
315
|
+
s,
|
|
316
|
+
r,
|
|
317
|
+
n,
|
|
318
|
+
t
|
|
319
|
+
)
|
|
320
|
+
);
|
|
321
|
+
if (!I(e))
|
|
322
|
+
return e;
|
|
323
|
+
const o = {};
|
|
324
|
+
for (const [s, a] of Object.entries(e)) {
|
|
325
|
+
const c = t || s === Q;
|
|
326
|
+
if ((s === "type" || s === "itemType" || s === "keyType" || s === "valueType") && typeof a == "string" && !(n && c)) {
|
|
327
|
+
if (V.has(a)) {
|
|
328
|
+
const i = x[a];
|
|
329
|
+
if (!i)
|
|
330
|
+
throw new Error(`Missing primitive BlueId for ${a}.`);
|
|
331
|
+
o[s] = { blueId: i };
|
|
332
|
+
} else {
|
|
333
|
+
const i = a, f = r(i);
|
|
334
|
+
if (!f)
|
|
335
|
+
throw new Error(`Missing BlueId for alias ${i}.`);
|
|
336
|
+
o[s] = { blueId: f };
|
|
337
|
+
}
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
o[s] = $(
|
|
341
|
+
a,
|
|
342
|
+
r,
|
|
343
|
+
n,
|
|
344
|
+
c
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
return o;
|
|
348
|
+
}
|
|
349
|
+
function Be({
|
|
350
|
+
alias: e,
|
|
351
|
+
type: r,
|
|
352
|
+
previousTypes: n,
|
|
353
|
+
aliasToBlueId: t,
|
|
354
|
+
aliasToStorageContent: o,
|
|
355
|
+
context: s
|
|
356
|
+
}) {
|
|
357
|
+
const { node: a, storageContent: c } = N(
|
|
358
|
+
r,
|
|
359
|
+
(g) => t.get(g),
|
|
360
|
+
s.blue
|
|
361
|
+
), i = V.has(r.typeName), f = i ? Pe(r.typeName) : s.blue.calculateBlueIdSync(a), u = K(
|
|
362
|
+
n,
|
|
363
|
+
r,
|
|
364
|
+
c
|
|
365
|
+
), l = u?.blueId ?? f, y = u?.content ?? c;
|
|
366
|
+
t.set(e, l), o.set(e, y), i || s.contentByBlueId.set(l, y), s.blue.registerBlueIds({ [e]: l });
|
|
367
|
+
}
|
|
368
|
+
function ve({
|
|
369
|
+
component: e,
|
|
370
|
+
discovered: r,
|
|
371
|
+
previousTypes: n,
|
|
372
|
+
aliasToBlueId: t,
|
|
373
|
+
aliasToStorageContent: o,
|
|
374
|
+
context: s
|
|
375
|
+
}) {
|
|
376
|
+
const a = new Set(e), c = /* @__PURE__ */ new Map();
|
|
377
|
+
e.forEach((d, p) => c.set(d, p));
|
|
378
|
+
const i = e.map((d) => {
|
|
379
|
+
const p = M(r, d), { node: b } = N(
|
|
380
|
+
p,
|
|
381
|
+
(w) => a.has(w) ? Y : t.get(w),
|
|
382
|
+
s.blue
|
|
383
|
+
);
|
|
384
|
+
return {
|
|
385
|
+
alias: d,
|
|
386
|
+
preliminaryBlueId: s.blue.calculateBlueIdSync(b)
|
|
387
|
+
};
|
|
388
|
+
});
|
|
389
|
+
Te(i), i.sort(ke);
|
|
390
|
+
const f = /* @__PURE__ */ new Map();
|
|
391
|
+
i.forEach(({ alias: d }, p) => {
|
|
392
|
+
f.set(d, p);
|
|
393
|
+
});
|
|
394
|
+
const u = /* @__PURE__ */ new Map();
|
|
395
|
+
for (const d of e) {
|
|
396
|
+
const p = M(r, d), b = N(
|
|
397
|
+
p,
|
|
398
|
+
(w) => {
|
|
399
|
+
if (!a.has(w))
|
|
400
|
+
return t.get(w);
|
|
401
|
+
const _ = f.get(w);
|
|
402
|
+
if (_ === void 0)
|
|
403
|
+
throw new Error(`Failed to resolve cyclic reference ${w}.`);
|
|
404
|
+
return `this#${_}`;
|
|
405
|
+
},
|
|
406
|
+
s.blue
|
|
407
|
+
);
|
|
408
|
+
u.set(d, b);
|
|
409
|
+
}
|
|
410
|
+
const l = Ae(
|
|
411
|
+
e,
|
|
412
|
+
r,
|
|
413
|
+
n,
|
|
414
|
+
u
|
|
415
|
+
);
|
|
416
|
+
if (l) {
|
|
417
|
+
for (const d of e) {
|
|
418
|
+
const p = l.get(d);
|
|
419
|
+
if (!p)
|
|
420
|
+
throw new Error(`Failed to preserve cyclic BlueId for type ${d}.`);
|
|
421
|
+
t.set(d, p.blueId), o.set(d, p.content), s.blue.registerBlueIds({ [d]: p.blueId });
|
|
422
|
+
}
|
|
423
|
+
Se(s.contentByBlueId, l);
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
const y = i.map(({ alias: d }) => {
|
|
427
|
+
const p = u.get(d);
|
|
428
|
+
if (!p)
|
|
429
|
+
throw new Error(`Failed to build cyclic content for type ${d}.`);
|
|
430
|
+
return p.node;
|
|
431
|
+
}), g = i.map(({ alias: d }) => {
|
|
432
|
+
const p = u.get(d);
|
|
433
|
+
if (!p)
|
|
434
|
+
throw new Error(`Failed to build cyclic content for type ${d}.`);
|
|
435
|
+
return p.storageContent;
|
|
436
|
+
}), E = s.blue.calculateBlueIdSync(y);
|
|
437
|
+
s.contentByBlueId.set(E, g), i.forEach(({ alias: d }, p) => {
|
|
438
|
+
const b = u.get(d);
|
|
439
|
+
if (!b)
|
|
440
|
+
throw new Error(`Failed to build cyclic content for type ${d}.`);
|
|
441
|
+
const w = `${E}#${p}`;
|
|
442
|
+
t.set(d, w), o.set(d, b.storageContent), s.blue.registerBlueIds({ [d]: w });
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
function Ee(e, r) {
|
|
446
|
+
if (e.length > 1)
|
|
447
|
+
return !0;
|
|
448
|
+
const n = e[0];
|
|
449
|
+
return n ? r.get(n)?.has(n) ?? !1 : !1;
|
|
450
|
+
}
|
|
451
|
+
function N(e, r, n) {
|
|
452
|
+
const t = $(
|
|
453
|
+
S(e.content),
|
|
454
|
+
r
|
|
455
|
+
), o = n.jsonValueToNode(t);
|
|
456
|
+
return {
|
|
457
|
+
node: o,
|
|
458
|
+
storageContent: n.nodeToJson(o, "official")
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
function M(e, r) {
|
|
462
|
+
const n = e.get(r);
|
|
463
|
+
if (!n)
|
|
464
|
+
throw new Error(`Unknown type alias ${r}.`);
|
|
465
|
+
return n;
|
|
466
|
+
}
|
|
467
|
+
function Ae(e, r, n, t) {
|
|
468
|
+
const o = /* @__PURE__ */ new Map();
|
|
469
|
+
for (const s of e) {
|
|
470
|
+
const a = M(r, s), c = t.get(s);
|
|
471
|
+
if (!c)
|
|
472
|
+
throw new Error(`Failed to build cyclic content for type ${s}.`);
|
|
473
|
+
const i = K(
|
|
474
|
+
n,
|
|
475
|
+
a,
|
|
476
|
+
c.storageContent
|
|
477
|
+
);
|
|
478
|
+
if (!i)
|
|
479
|
+
return null;
|
|
480
|
+
o.set(s, i);
|
|
481
|
+
}
|
|
482
|
+
return o;
|
|
483
|
+
}
|
|
484
|
+
function K(e, r, n) {
|
|
485
|
+
const t = e.get(r.packageName)?.get(r.typeName), o = t?.versions?.at(-1)?.typeBlueId;
|
|
486
|
+
return !o || !t || !h(t.content) || !R(t.content, n) ? null : {
|
|
487
|
+
blueId: o,
|
|
488
|
+
content: S(t.content)
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
function Se(e, r) {
|
|
492
|
+
const n = /* @__PURE__ */ new Map();
|
|
493
|
+
for (const { blueId: t, content: o } of r.values()) {
|
|
494
|
+
const s = J(t);
|
|
495
|
+
if (!s || s.index === void 0) {
|
|
496
|
+
e.set(t, o);
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
const a = n.get(s.baseBlueId) ?? [];
|
|
500
|
+
a.push({ index: s.index, content: o }), n.set(s.baseBlueId, a);
|
|
501
|
+
}
|
|
502
|
+
for (const [t, o] of n) {
|
|
503
|
+
const a = [...o].sort((c, i) => c.index - i.index).map((c, i) => {
|
|
504
|
+
if (c.index !== i)
|
|
505
|
+
throw new Error(
|
|
506
|
+
`Cyclic repository content for ${t} is missing index ${i}.`
|
|
507
|
+
);
|
|
508
|
+
return c.content;
|
|
509
|
+
});
|
|
510
|
+
e.set(t, a);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
function Te(e) {
|
|
514
|
+
const r = /* @__PURE__ */ new Map();
|
|
515
|
+
for (const n of e) {
|
|
516
|
+
const t = r.get(n.preliminaryBlueId);
|
|
517
|
+
if (t)
|
|
518
|
+
throw new Error(
|
|
519
|
+
`Direct cyclic type set has ambiguous canonical ordering: ${t} and ${n.alias} share preliminary BlueId '${n.preliminaryBlueId}'.`
|
|
520
|
+
);
|
|
521
|
+
r.set(n.preliminaryBlueId, n.alias);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
function ke(e, r) {
|
|
525
|
+
return e.preliminaryBlueId < r.preliminaryBlueId ? -1 : e.preliminaryBlueId > r.preliminaryBlueId ? 1 : 0;
|
|
526
|
+
}
|
|
527
|
+
function R(e, r) {
|
|
528
|
+
if (e === r)
|
|
529
|
+
return !0;
|
|
530
|
+
if (Array.isArray(e) || Array.isArray(r))
|
|
531
|
+
return !Array.isArray(e) || !Array.isArray(r) || e.length !== r.length ? !1 : e.every((n, t) => R(n, r[t]));
|
|
532
|
+
if (h(e) || h(r)) {
|
|
533
|
+
if (!h(e) || !h(r))
|
|
534
|
+
return !1;
|
|
535
|
+
const n = Object.keys(e).sort(), t = Object.keys(r).sort();
|
|
536
|
+
return n.length !== t.length ? !1 : n.every(
|
|
537
|
+
(o, s) => o === t[s] && R(e[o], r[o])
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
return !1;
|
|
541
|
+
}
|
|
542
|
+
function Pe(e) {
|
|
543
|
+
const r = x[e];
|
|
544
|
+
if (!r)
|
|
545
|
+
throw new Error(`Missing primitive BlueId for ${e}.`);
|
|
546
|
+
return r;
|
|
547
|
+
}
|
|
548
|
+
const F = new Set(Object.values(x)), $e = /* @__PURE__ */ new Set([
|
|
549
|
+
"type",
|
|
550
|
+
"itemType",
|
|
551
|
+
"valueType",
|
|
552
|
+
"keyType"
|
|
553
|
+
]), Ne = /* @__PURE__ */ new Set(["name", "description"]), v = {
|
|
554
|
+
Unchanged: "unchanged",
|
|
555
|
+
NonBreaking: "non-breaking",
|
|
556
|
+
Breaking: "breaking"
|
|
557
|
+
};
|
|
558
|
+
function Me(e, r, n, t, o) {
|
|
559
|
+
const s = oe.compare(
|
|
560
|
+
e,
|
|
561
|
+
r
|
|
562
|
+
);
|
|
563
|
+
if (s.length === 0)
|
|
564
|
+
return { status: v.Unchanged, attributesAdded: [] };
|
|
565
|
+
const a = [];
|
|
566
|
+
let c = !1;
|
|
567
|
+
for (const i of s) {
|
|
568
|
+
if (Oe(i, e, o)) {
|
|
569
|
+
c = !0;
|
|
570
|
+
continue;
|
|
571
|
+
}
|
|
572
|
+
if (i.op !== "add")
|
|
573
|
+
return { status: v.Breaking, attributesAdded: [] };
|
|
574
|
+
if (!Ve(i))
|
|
575
|
+
return { status: v.Breaking, attributesAdded: [] };
|
|
576
|
+
a.push(i.path);
|
|
577
|
+
}
|
|
578
|
+
return a.length === 0 && !c ? {
|
|
579
|
+
status: v.Breaking,
|
|
580
|
+
attributesAdded: []
|
|
581
|
+
} : (a.length > 0 && Re(a, n, t), { status: v.NonBreaking, attributesAdded: a });
|
|
582
|
+
}
|
|
583
|
+
function Re(e, r, n) {
|
|
584
|
+
for (const t of e)
|
|
585
|
+
try {
|
|
586
|
+
te(t);
|
|
587
|
+
} catch (o) {
|
|
588
|
+
throw new Error(
|
|
589
|
+
`Invalid attribute pointer "${t}" for ${r}/${n}: ${o.message}`
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
function Ve(e) {
|
|
594
|
+
if (e.op !== "add")
|
|
595
|
+
return !1;
|
|
596
|
+
const r = z(e.path);
|
|
597
|
+
if (r.length === 0)
|
|
598
|
+
return !1;
|
|
599
|
+
const n = r.at(-1);
|
|
600
|
+
return n && /^\d+$/.test(n) || n && $e.has(n) || r.some(
|
|
601
|
+
(t) => ee.has(t)
|
|
602
|
+
) ? !1 : I(e.value) ? !xe(e.value) : n ? Ne.has(n) : !1;
|
|
603
|
+
}
|
|
604
|
+
function z(e) {
|
|
605
|
+
try {
|
|
606
|
+
return ne(e);
|
|
607
|
+
} catch {
|
|
608
|
+
return [];
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
function xe(e) {
|
|
612
|
+
const r = [e];
|
|
613
|
+
for (; r.length; ) {
|
|
614
|
+
const n = r.pop();
|
|
615
|
+
if (n) {
|
|
616
|
+
if (Object.prototype.hasOwnProperty.call(n, "value") || Object.prototype.hasOwnProperty.call(n, "items"))
|
|
617
|
+
return !0;
|
|
618
|
+
if (Object.prototype.hasOwnProperty.call(n, T)) {
|
|
619
|
+
const t = n[T];
|
|
620
|
+
if (I(t) && t.required === !0)
|
|
621
|
+
return !0;
|
|
622
|
+
}
|
|
623
|
+
for (const [t, o] of Object.entries(n))
|
|
624
|
+
t !== T && I(o) && r.push(o);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
return !1;
|
|
628
|
+
}
|
|
629
|
+
function Oe(e, r, n) {
|
|
630
|
+
if (e.op !== "replace" || typeof e.path != "string")
|
|
631
|
+
return !1;
|
|
632
|
+
const t = z(e.path);
|
|
633
|
+
if (t.length < 2)
|
|
634
|
+
return !1;
|
|
635
|
+
const o = t.at(-1), s = t.at(-2);
|
|
636
|
+
if (!(o === "blueId" && s !== void 0 && (s === "type" || s === "itemType" || s === "keyType" || s === "valueType")))
|
|
637
|
+
return !1;
|
|
638
|
+
const a = Ce(r, t), c = typeof a == "string" ? a : I(a) && typeof a.blueId == "string" ? a.blueId : null, i = typeof e.value == "string" ? e.value : I(e.value) && typeof e.value.blueId == "string" ? e.value.blueId : null;
|
|
639
|
+
if (c && F.has(c) || i && F.has(i) || !c || !i)
|
|
640
|
+
return !1;
|
|
641
|
+
const f = n.get(c), u = n.get(i);
|
|
642
|
+
if (!f || !u)
|
|
643
|
+
return !1;
|
|
644
|
+
for (const l of f)
|
|
645
|
+
if (u.has(l))
|
|
646
|
+
return !0;
|
|
647
|
+
return !1;
|
|
648
|
+
}
|
|
649
|
+
function Ce(e, r) {
|
|
650
|
+
let n = e;
|
|
651
|
+
for (const t of r)
|
|
652
|
+
if (Array.isArray(n)) {
|
|
653
|
+
const o = Number(t);
|
|
654
|
+
if (Number.isNaN(o) || o < 0 || o >= n.length)
|
|
655
|
+
return;
|
|
656
|
+
n = n[o];
|
|
657
|
+
} else if (I(n))
|
|
658
|
+
n = n[t];
|
|
659
|
+
else
|
|
660
|
+
return;
|
|
661
|
+
return n;
|
|
662
|
+
}
|
|
663
|
+
function _e(e) {
|
|
664
|
+
const r = /* @__PURE__ */ new Map();
|
|
665
|
+
if (!e)
|
|
666
|
+
return r;
|
|
667
|
+
for (const n of e.packages || []) {
|
|
668
|
+
if (typeof n.name != "string")
|
|
669
|
+
continue;
|
|
670
|
+
const t = /* @__PURE__ */ new Map();
|
|
671
|
+
for (const o of n.types || []) {
|
|
672
|
+
const s = o.content, a = h(s) && typeof s.name == "string" ? s.name : void 0;
|
|
673
|
+
a && t.set(a, o);
|
|
674
|
+
}
|
|
675
|
+
r.set(n.name, t);
|
|
676
|
+
}
|
|
677
|
+
return r;
|
|
678
|
+
}
|
|
679
|
+
function De(e, r) {
|
|
680
|
+
for (const [n, t] of r)
|
|
681
|
+
for (const [o, s] of t) {
|
|
682
|
+
const a = `${n}/${o}`;
|
|
683
|
+
if (!e.has(a) && s.status === m.Stable)
|
|
684
|
+
throw new Error(
|
|
685
|
+
`Stable type ${a} was removed. Breaking changes require a new logical type name.`
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
function je({
|
|
690
|
+
discovered: e,
|
|
691
|
+
previousTypes: r,
|
|
692
|
+
aliasToBlueId: n,
|
|
693
|
+
aliasToStorageContent: t,
|
|
694
|
+
nextRepoVersionIndex: o
|
|
695
|
+
}) {
|
|
696
|
+
const s = /* @__PURE__ */ new Map(), a = Ue(r, n);
|
|
697
|
+
for (const [c, i] of e) {
|
|
698
|
+
const f = n.get(c);
|
|
699
|
+
if (!f)
|
|
700
|
+
throw new Error(`Failed to compute BlueId for type ${c}.`);
|
|
701
|
+
const u = r.get(i.packageName)?.get(i.typeName) ?? null;
|
|
702
|
+
if (u && u.status === m.Stable && i.status === m.Dev)
|
|
703
|
+
throw new Error(
|
|
704
|
+
`Type ${c} was stable previously and cannot be downgraded to dev. Use a new logical name instead.`
|
|
705
|
+
);
|
|
706
|
+
const l = t.get(c) ?? i.content, y = i.status === m.Dev ? Fe({ blueId: f, nextRepoVersionIndex: o, previousType: u }) : !u || u.status === m.Dev ? Le({ blueId: f, nextRepoVersionIndex: o }) : Ge({
|
|
707
|
+
alias: c,
|
|
708
|
+
blueId: f,
|
|
709
|
+
nextRepoVersionIndex: o,
|
|
710
|
+
previousType: u,
|
|
711
|
+
currentContent: l,
|
|
712
|
+
packageName: i.packageName,
|
|
713
|
+
typeName: i.typeName,
|
|
714
|
+
blueIdAliases: a
|
|
715
|
+
});
|
|
716
|
+
y.content = l, y.status = i.status;
|
|
717
|
+
const g = s.get(i.packageName) ?? [];
|
|
718
|
+
g.push(y), s.set(i.packageName, g);
|
|
719
|
+
}
|
|
720
|
+
return s;
|
|
721
|
+
}
|
|
722
|
+
function Ue(e, r) {
|
|
723
|
+
const n = /* @__PURE__ */ new Map(), t = (o, s) => {
|
|
724
|
+
const a = n.get(o);
|
|
725
|
+
if (a) {
|
|
726
|
+
a.add(s);
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
n.set(o, /* @__PURE__ */ new Set([s]));
|
|
730
|
+
};
|
|
731
|
+
for (const [o, s] of e)
|
|
732
|
+
for (const [a, c] of s) {
|
|
733
|
+
const i = `${o}/${a}`;
|
|
734
|
+
for (const f of c.versions ?? [])
|
|
735
|
+
typeof f.typeBlueId == "string" && t(f.typeBlueId, i);
|
|
736
|
+
}
|
|
737
|
+
for (const [o, s] of r)
|
|
738
|
+
t(s, o);
|
|
739
|
+
return n;
|
|
740
|
+
}
|
|
741
|
+
function Fe({
|
|
742
|
+
blueId: e,
|
|
743
|
+
nextRepoVersionIndex: r,
|
|
744
|
+
previousType: n
|
|
745
|
+
}) {
|
|
746
|
+
const t = n && n.status === m.Dev ? n : null, o = t?.versions?.length === 1 ? t.versions[0] : null, s = o && o.typeBlueId === e;
|
|
747
|
+
return {
|
|
748
|
+
status: m.Dev,
|
|
749
|
+
content: {},
|
|
750
|
+
versions: s && t?.versions ? P(t.versions) : [
|
|
751
|
+
{
|
|
752
|
+
repositoryVersionIndex: r,
|
|
753
|
+
typeBlueId: e,
|
|
754
|
+
attributesAdded: []
|
|
755
|
+
}
|
|
756
|
+
]
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
function Le({
|
|
760
|
+
blueId: e,
|
|
761
|
+
nextRepoVersionIndex: r
|
|
762
|
+
}) {
|
|
763
|
+
return {
|
|
764
|
+
status: m.Stable,
|
|
765
|
+
content: {},
|
|
766
|
+
versions: [
|
|
767
|
+
{
|
|
768
|
+
repositoryVersionIndex: r,
|
|
769
|
+
typeBlueId: e,
|
|
770
|
+
attributesAdded: []
|
|
771
|
+
}
|
|
772
|
+
]
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
function Ge({
|
|
776
|
+
alias: e,
|
|
777
|
+
blueId: r,
|
|
778
|
+
nextRepoVersionIndex: n,
|
|
779
|
+
previousType: t,
|
|
780
|
+
currentContent: o,
|
|
781
|
+
packageName: s,
|
|
782
|
+
typeName: a,
|
|
783
|
+
blueIdAliases: c
|
|
784
|
+
}) {
|
|
785
|
+
if (!h(t.content))
|
|
786
|
+
throw new Error(
|
|
787
|
+
`Type ${e} has non-object content; cannot compute diff for stable versioning.`
|
|
788
|
+
);
|
|
789
|
+
const i = Me(
|
|
790
|
+
t.content,
|
|
791
|
+
o,
|
|
792
|
+
s,
|
|
793
|
+
a,
|
|
794
|
+
c
|
|
795
|
+
);
|
|
796
|
+
if (i.status === v.Unchanged) {
|
|
797
|
+
const f = P(t.versions || []), u = f.at(-1);
|
|
798
|
+
if (u && u.typeBlueId !== r)
|
|
799
|
+
throw new Error(
|
|
800
|
+
`Type ${e} content is unchanged but BlueId differs from previous metadata.`
|
|
801
|
+
);
|
|
802
|
+
return {
|
|
803
|
+
status: m.Stable,
|
|
804
|
+
content: {},
|
|
805
|
+
versions: f
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
if (i.status === v.NonBreaking)
|
|
809
|
+
return {
|
|
810
|
+
status: m.Stable,
|
|
811
|
+
content: {},
|
|
812
|
+
versions: [
|
|
813
|
+
...P(t.versions || []),
|
|
814
|
+
{
|
|
815
|
+
repositoryVersionIndex: n,
|
|
816
|
+
typeBlueId: r,
|
|
817
|
+
attributesAdded: i.attributesAdded
|
|
818
|
+
}
|
|
819
|
+
]
|
|
820
|
+
};
|
|
821
|
+
throw new Error(
|
|
822
|
+
`Breaking change detected in stable type ${e}. Introduce a new type name for breaking changes.`
|
|
823
|
+
);
|
|
824
|
+
}
|
|
825
|
+
function qe(e) {
|
|
826
|
+
return Array.from(e.entries()).map(([r, n]) => ({
|
|
827
|
+
name: r,
|
|
828
|
+
types: n.map((t) => ({
|
|
829
|
+
...t,
|
|
830
|
+
versions: [...t.versions].sort(
|
|
831
|
+
(o, s) => o.repositoryVersionIndex - s.repositoryVersionIndex
|
|
832
|
+
)
|
|
833
|
+
})).sort((t, o) => {
|
|
834
|
+
const s = h(t.content) && typeof t.content.name == "string" ? t.content.name : "", a = h(o.content) && typeof o.content.name == "string" ? o.content.name : "";
|
|
835
|
+
return s.localeCompare(a);
|
|
836
|
+
})
|
|
837
|
+
})).sort((r, n) => r.name.localeCompare(n.name));
|
|
838
|
+
}
|
|
839
|
+
function L(e) {
|
|
840
|
+
return Z.INSTANCE.calculateSync(
|
|
841
|
+
e
|
|
842
|
+
);
|
|
843
|
+
}
|
|
844
|
+
function We(e, r, n) {
|
|
845
|
+
const t = r?.repositoryVersions.at(-1), o = !t || t !== n, s = r?.repositoryVersions ? [...r.repositoryVersions] : [];
|
|
846
|
+
return o && s.push(n), { document: {
|
|
847
|
+
name: O,
|
|
848
|
+
packages: e,
|
|
849
|
+
repositoryVersions: s
|
|
850
|
+
}, changed: o };
|
|
851
|
+
}
|
|
852
|
+
function Ye(e, r, n) {
|
|
853
|
+
const t = {
|
|
854
|
+
name: O,
|
|
855
|
+
repositoryVersions: r,
|
|
856
|
+
packages: Je(e, n)
|
|
857
|
+
};
|
|
858
|
+
re(t);
|
|
859
|
+
}
|
|
860
|
+
function Je(e, r) {
|
|
861
|
+
const n = {};
|
|
862
|
+
for (const t of e) {
|
|
863
|
+
const o = Ke(t.name, r), s = {}, a = {};
|
|
864
|
+
for (const c of t.types) {
|
|
865
|
+
const i = c.versions?.[c.versions.length - 1]?.typeBlueId;
|
|
866
|
+
if (!i)
|
|
867
|
+
throw new Error(
|
|
868
|
+
`Type ${t.name} is missing a current BlueId in versions.`
|
|
869
|
+
);
|
|
870
|
+
const f = ze(c);
|
|
871
|
+
s[i] = {
|
|
872
|
+
status: c.status,
|
|
873
|
+
name: f,
|
|
874
|
+
versions: c.versions ?? []
|
|
875
|
+
}, a[i] = c.content;
|
|
876
|
+
}
|
|
877
|
+
n[t.name] = {
|
|
878
|
+
name: t.name,
|
|
879
|
+
aliases: o,
|
|
880
|
+
typesMeta: s,
|
|
881
|
+
contents: a,
|
|
882
|
+
schemas: {}
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
return n;
|
|
886
|
+
}
|
|
887
|
+
function Ke(e, r) {
|
|
888
|
+
const n = {}, t = `${e}/`;
|
|
889
|
+
return r.forEach((o, s) => {
|
|
890
|
+
s.startsWith(t) && (n[s] = o);
|
|
891
|
+
}), n;
|
|
892
|
+
}
|
|
893
|
+
function ze(e) {
|
|
894
|
+
const r = h(e.content) && typeof e.content.name == "string" ? e.content.name : null;
|
|
895
|
+
if (!r)
|
|
896
|
+
throw new Error('Type content is missing required "name" field.');
|
|
897
|
+
return r;
|
|
898
|
+
}
|
|
899
|
+
function He(e) {
|
|
900
|
+
if (!A.existsSync(e))
|
|
901
|
+
return { previous: null };
|
|
902
|
+
const r = A.readFileSync(e, "utf8"), n = q(r);
|
|
903
|
+
if (!n || !I(n))
|
|
904
|
+
throw new Error("Existing BlueRepository.blue is not a valid object.");
|
|
905
|
+
const t = n, o = t.packages, s = t.repositoryVersions, a = Array.isArray(o) && o.every(
|
|
906
|
+
(l) => I(l) && typeof l.name == "string" && Array.isArray(l.types)
|
|
907
|
+
), c = Array.isArray(s) && s.every((l) => typeof l == "string");
|
|
908
|
+
if (!a || !c)
|
|
909
|
+
throw new Error(
|
|
910
|
+
"Invalid BlueRepository.blue structure: expected { packages: BluePackage[], repositoryVersions: string[] }"
|
|
911
|
+
);
|
|
912
|
+
const i = o, f = s, u = {
|
|
913
|
+
name: typeof t.name == "string" ? t.name : O,
|
|
914
|
+
packages: i,
|
|
915
|
+
repositoryVersions: f
|
|
916
|
+
};
|
|
917
|
+
return { existingYaml: r, previous: u };
|
|
918
|
+
}
|
|
919
|
+
function Xe(e) {
|
|
920
|
+
return se.dump(e, { lineWidth: -1 });
|
|
921
|
+
}
|
|
922
|
+
function st(e) {
|
|
923
|
+
const r = D.resolve(e.repoRoot), n = D.resolve(e.blueRepositoryPath), { existingYaml: t, previous: o } = He(n), s = ae(r), a = _e(o);
|
|
924
|
+
De(s, a);
|
|
925
|
+
const c = le(s), i = pe(c);
|
|
926
|
+
ye(c, s);
|
|
927
|
+
const { aliasToBlueId: f, aliasToStorageContent: u } = we(
|
|
928
|
+
i,
|
|
929
|
+
s,
|
|
930
|
+
c,
|
|
931
|
+
a
|
|
932
|
+
), l = o ? o.repositoryVersions.length : 0, y = je({
|
|
933
|
+
discovered: s,
|
|
934
|
+
previousTypes: a,
|
|
935
|
+
aliasToBlueId: f,
|
|
936
|
+
aliasToStorageContent: u,
|
|
937
|
+
nextRepoVersionIndex: l
|
|
938
|
+
}), g = qe(y), E = o && Ze(o.packages, g) ? o.repositoryVersions.at(-1) ?? L(g) : L(g), { document: d, changed: p } = We(
|
|
939
|
+
g,
|
|
940
|
+
o,
|
|
941
|
+
E
|
|
942
|
+
);
|
|
943
|
+
Ye(
|
|
944
|
+
d.packages,
|
|
945
|
+
d.repositoryVersions,
|
|
946
|
+
f
|
|
947
|
+
);
|
|
948
|
+
const b = Xe(d);
|
|
949
|
+
if (o && !p && t && t !== b)
|
|
950
|
+
throw new Error(
|
|
951
|
+
"BlueRepository.blue content differs from regenerated output while RepoBlueId is unchanged. Please revert manual edits or rerun in write mode."
|
|
952
|
+
);
|
|
953
|
+
return e.verbose && console.info(
|
|
954
|
+
`[repository-generator] RepoBlueId: ${E} (${p ? "changed" : "unchanged"})`
|
|
955
|
+
), {
|
|
956
|
+
document: d,
|
|
957
|
+
currentRepoBlueId: E,
|
|
958
|
+
previousRepoBlueId: o?.repositoryVersions.at(-1),
|
|
959
|
+
changed: p || !t,
|
|
960
|
+
yaml: b,
|
|
961
|
+
existingYaml: t
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
function Ze(e, r) {
|
|
965
|
+
return JSON.stringify(e) === JSON.stringify(r);
|
|
966
|
+
}
|
|
967
|
+
export {
|
|
968
|
+
st as g
|
|
969
|
+
};
|