@spica-devkit/testing 0.20.7 → 0.20.9
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/index.js +276 -73
- package/index.js.map +1 -1
- package/index.mjs +276 -73
- package/index.mjs.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -281,6 +281,85 @@ var ChangeKind;
|
|
|
281
281
|
})(ChangeKind || (ChangeKind = {}));
|
|
282
282
|
const DEFAULT_CONCURRENCY = 10;
|
|
283
283
|
|
|
284
|
+
const REQUEST_METHODS = ["get", "delete", "head", "post", "patch", "put"];
|
|
285
|
+
const limitedClients = new WeakMap();
|
|
286
|
+
function limitConcurrency(http, limit = DEFAULT_CONCURRENCY, signal) {
|
|
287
|
+
const existing = limitedClients.get(http);
|
|
288
|
+
if (existing && !signal)
|
|
289
|
+
return http;
|
|
290
|
+
const { semaphore, target } = existing ?? {
|
|
291
|
+
semaphore: new Semaphore(normalizeLimit(limit)),
|
|
292
|
+
target: http
|
|
293
|
+
};
|
|
294
|
+
const limited = { ...target };
|
|
295
|
+
for (const method of REQUEST_METHODS) {
|
|
296
|
+
limited[method] = (...args) => semaphore.run(() => {
|
|
297
|
+
if (signal?.aborted)
|
|
298
|
+
throw signal.reason;
|
|
299
|
+
return target[method](...args);
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
limitedClients.set(limited, { semaphore, target });
|
|
303
|
+
return limited;
|
|
304
|
+
}
|
|
305
|
+
async function mapWithConcurrency(items, limit, fn) {
|
|
306
|
+
const results = new Array(items.length);
|
|
307
|
+
let next = 0;
|
|
308
|
+
let failure;
|
|
309
|
+
const worker = async () => {
|
|
310
|
+
while (!failure && next < items.length) {
|
|
311
|
+
const index = next++;
|
|
312
|
+
try {
|
|
313
|
+
results[index] = await fn(items[index], index);
|
|
314
|
+
}
|
|
315
|
+
catch (error) {
|
|
316
|
+
if (!failure)
|
|
317
|
+
failure = { error };
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
const workerCount = Math.min(normalizeLimit(limit), items.length);
|
|
322
|
+
await Promise.all(Array.from({ length: workerCount }, worker));
|
|
323
|
+
if (failure)
|
|
324
|
+
throw failure.error;
|
|
325
|
+
return results;
|
|
326
|
+
}
|
|
327
|
+
function normalizeLimit(limit) {
|
|
328
|
+
return Number.isFinite(limit) ? Math.max(1, Math.floor(limit)) : DEFAULT_CONCURRENCY;
|
|
329
|
+
}
|
|
330
|
+
class Semaphore {
|
|
331
|
+
constructor(limit) {
|
|
332
|
+
this.limit = limit;
|
|
333
|
+
this.active = 0;
|
|
334
|
+
this.waiting = [];
|
|
335
|
+
}
|
|
336
|
+
async run(task) {
|
|
337
|
+
await this.acquire();
|
|
338
|
+
try {
|
|
339
|
+
return await task();
|
|
340
|
+
}
|
|
341
|
+
finally {
|
|
342
|
+
this.release();
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
acquire() {
|
|
346
|
+
if (this.active < this.limit) {
|
|
347
|
+
this.active++;
|
|
348
|
+
return Promise.resolve();
|
|
349
|
+
}
|
|
350
|
+
return new Promise(resolve => this.waiting.push(resolve));
|
|
351
|
+
}
|
|
352
|
+
release() {
|
|
353
|
+
const next = this.waiting.shift();
|
|
354
|
+
if (next) {
|
|
355
|
+
next();
|
|
356
|
+
}
|
|
357
|
+
else {
|
|
358
|
+
this.active--;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
284
363
|
const noopProgress = {
|
|
285
364
|
update() { },
|
|
286
365
|
succeed() { },
|
|
@@ -360,7 +439,7 @@ const REMOVE$1 = Symbol('remove node');
|
|
|
360
439
|
* and `Node` (alias, map, seq & scalar) targets. Of all these, only the most
|
|
361
440
|
* specific defined one will be used for each node.
|
|
362
441
|
*/
|
|
363
|
-
function visit$
|
|
442
|
+
function visit$2(node, visitor) {
|
|
364
443
|
const visitor_ = initVisitor(visitor);
|
|
365
444
|
if (isDocument(node)) {
|
|
366
445
|
const cd = visit_(null, node.contents, visitor_, Object.freeze([node]));
|
|
@@ -374,11 +453,11 @@ function visit$1(node, visitor) {
|
|
|
374
453
|
// namespace using `var`, but then complains about that because
|
|
375
454
|
// `unique symbol` must be `const`.
|
|
376
455
|
/** Terminate visit traversal completely */
|
|
377
|
-
visit$
|
|
456
|
+
visit$2.BREAK = BREAK$1;
|
|
378
457
|
/** Do not visit the children of the current node */
|
|
379
|
-
visit$
|
|
458
|
+
visit$2.SKIP = SKIP$1;
|
|
380
459
|
/** Remove the current node */
|
|
381
|
-
visit$
|
|
460
|
+
visit$2.REMOVE = REMOVE$1;
|
|
382
461
|
function visit_(key, node, visitor, path) {
|
|
383
462
|
const ctrl = callVisitor(key, node, visitor, path);
|
|
384
463
|
if (isNode(ctrl) || isPair(ctrl)) {
|
|
@@ -709,7 +788,7 @@ class Directives {
|
|
|
709
788
|
let tagNames;
|
|
710
789
|
if (doc && tagEntries.length > 0 && isNode(doc.contents)) {
|
|
711
790
|
const tags = {};
|
|
712
|
-
visit$
|
|
791
|
+
visit$2(doc.contents, (_key, node) => {
|
|
713
792
|
if (isNode(node) && node.tag)
|
|
714
793
|
tags[node.tag] = true;
|
|
715
794
|
});
|
|
@@ -744,7 +823,7 @@ function anchorIsValid(anchor) {
|
|
|
744
823
|
}
|
|
745
824
|
function anchorNames(root) {
|
|
746
825
|
const anchors = new Set();
|
|
747
|
-
visit$
|
|
826
|
+
visit$2(root, {
|
|
748
827
|
Value(_key, node) {
|
|
749
828
|
if (node.anchor)
|
|
750
829
|
anchors.add(node.anchor);
|
|
@@ -938,7 +1017,7 @@ class Alias extends NodeBase {
|
|
|
938
1017
|
}
|
|
939
1018
|
else {
|
|
940
1019
|
nodes = [];
|
|
941
|
-
visit$
|
|
1020
|
+
visit$2(doc, {
|
|
942
1021
|
Node: (_key, node) => {
|
|
943
1022
|
if (isAlias(node) || hasAnchor(node))
|
|
944
1023
|
nodes.push(node);
|
|
@@ -5735,7 +5814,7 @@ const REMOVE = Symbol('remove item');
|
|
|
5735
5814
|
* visitor is called on item entry, next visitors are called after handling
|
|
5736
5815
|
* a non-empty `key` and when exiting the item.
|
|
5737
5816
|
*/
|
|
5738
|
-
function visit(cst, visitor) {
|
|
5817
|
+
function visit$1(cst, visitor) {
|
|
5739
5818
|
if ('type' in cst && cst.type === 'document')
|
|
5740
5819
|
cst = { start: cst.start, value: cst.value };
|
|
5741
5820
|
_visit(Object.freeze([]), cst, visitor);
|
|
@@ -5744,13 +5823,13 @@ function visit(cst, visitor) {
|
|
|
5744
5823
|
// namespace using `var`, but then complains about that because
|
|
5745
5824
|
// `unique symbol` must be `const`.
|
|
5746
5825
|
/** Terminate visit traversal completely */
|
|
5747
|
-
visit.BREAK = BREAK;
|
|
5826
|
+
visit$1.BREAK = BREAK;
|
|
5748
5827
|
/** Do not visit the children of the current item */
|
|
5749
|
-
visit.SKIP = SKIP;
|
|
5828
|
+
visit$1.SKIP = SKIP;
|
|
5750
5829
|
/** Remove the current item */
|
|
5751
|
-
visit.REMOVE = REMOVE;
|
|
5830
|
+
visit$1.REMOVE = REMOVE;
|
|
5752
5831
|
/** Find the item at `path` from `cst` as the root */
|
|
5753
|
-
visit.itemAtPath = (cst, path) => {
|
|
5832
|
+
visit$1.itemAtPath = (cst, path) => {
|
|
5754
5833
|
let item = cst;
|
|
5755
5834
|
for (const [field, index] of path) {
|
|
5756
5835
|
const tok = item?.[field];
|
|
@@ -5767,8 +5846,8 @@ visit.itemAtPath = (cst, path) => {
|
|
|
5767
5846
|
*
|
|
5768
5847
|
* Throws an error if the collection is not found, which should never happen if the item itself exists.
|
|
5769
5848
|
*/
|
|
5770
|
-
visit.parentCollection = (cst, path) => {
|
|
5771
|
-
const parent = visit.itemAtPath(cst, path.slice(0, -1));
|
|
5849
|
+
visit$1.parentCollection = (cst, path) => {
|
|
5850
|
+
const parent = visit$1.itemAtPath(cst, path.slice(0, -1));
|
|
5772
5851
|
const field = path[path.length - 1][0];
|
|
5773
5852
|
const coll = parent?.[field];
|
|
5774
5853
|
if (coll && 'items' in coll)
|
|
@@ -5907,7 +5986,7 @@ var cst = /*#__PURE__*/Object.freeze({
|
|
|
5907
5986
|
setScalarValue: setScalarValue,
|
|
5908
5987
|
stringify: stringify$1,
|
|
5909
5988
|
tokenType: tokenType,
|
|
5910
|
-
visit: visit
|
|
5989
|
+
visit: visit$1
|
|
5911
5990
|
});
|
|
5912
5991
|
|
|
5913
5992
|
/*
|
|
@@ -7747,7 +7826,7 @@ var YAML = /*#__PURE__*/Object.freeze({
|
|
|
7747
7826
|
parseAllDocuments: parseAllDocuments,
|
|
7748
7827
|
parseDocument: parseDocument,
|
|
7749
7828
|
stringify: stringify,
|
|
7750
|
-
visit: visit$
|
|
7829
|
+
visit: visit$2,
|
|
7751
7830
|
visitAsync: visitAsync
|
|
7752
7831
|
});
|
|
7753
7832
|
|
|
@@ -12948,13 +13027,134 @@ function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader
|
|
|
12948
13027
|
return ret.join('\n') + '\n';
|
|
12949
13028
|
}
|
|
12950
13029
|
|
|
12951
|
-
|
|
13030
|
+
var isPlainObject_1;
|
|
13031
|
+
var hasRequiredIsPlainObject;
|
|
13032
|
+
|
|
13033
|
+
function requireIsPlainObject () {
|
|
13034
|
+
if (hasRequiredIsPlainObject) return isPlainObject_1;
|
|
13035
|
+
hasRequiredIsPlainObject = 1;
|
|
13036
|
+
var baseGetTag = require_baseGetTag(),
|
|
13037
|
+
getPrototype = require_getPrototype(),
|
|
13038
|
+
isObjectLike = requireIsObjectLike();
|
|
13039
|
+
|
|
13040
|
+
/** `Object#toString` result references. */
|
|
13041
|
+
var objectTag = '[object Object]';
|
|
13042
|
+
|
|
13043
|
+
/** Used for built-in method references. */
|
|
13044
|
+
var funcProto = Function.prototype,
|
|
13045
|
+
objectProto = Object.prototype;
|
|
13046
|
+
|
|
13047
|
+
/** Used to resolve the decompiled source of functions. */
|
|
13048
|
+
var funcToString = funcProto.toString;
|
|
13049
|
+
|
|
13050
|
+
/** Used to check objects for own properties. */
|
|
13051
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
13052
|
+
|
|
13053
|
+
/** Used to infer the `Object` constructor. */
|
|
13054
|
+
var objectCtorString = funcToString.call(Object);
|
|
13055
|
+
|
|
13056
|
+
/**
|
|
13057
|
+
* Checks if `value` is a plain object, that is, an object created by the
|
|
13058
|
+
* `Object` constructor or one with a `[[Prototype]]` of `null`.
|
|
13059
|
+
*
|
|
13060
|
+
* @static
|
|
13061
|
+
* @memberOf _
|
|
13062
|
+
* @since 0.8.0
|
|
13063
|
+
* @category Lang
|
|
13064
|
+
* @param {*} value The value to check.
|
|
13065
|
+
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
|
|
13066
|
+
* @example
|
|
13067
|
+
*
|
|
13068
|
+
* function Foo() {
|
|
13069
|
+
* this.a = 1;
|
|
13070
|
+
* }
|
|
13071
|
+
*
|
|
13072
|
+
* _.isPlainObject(new Foo);
|
|
13073
|
+
* // => false
|
|
13074
|
+
*
|
|
13075
|
+
* _.isPlainObject([1, 2, 3]);
|
|
13076
|
+
* // => false
|
|
13077
|
+
*
|
|
13078
|
+
* _.isPlainObject({ 'x': 0, 'y': 0 });
|
|
13079
|
+
* // => true
|
|
13080
|
+
*
|
|
13081
|
+
* _.isPlainObject(Object.create(null));
|
|
13082
|
+
* // => true
|
|
13083
|
+
*/
|
|
13084
|
+
function isPlainObject(value) {
|
|
13085
|
+
if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
|
|
13086
|
+
return false;
|
|
13087
|
+
}
|
|
13088
|
+
var proto = getPrototype(value);
|
|
13089
|
+
if (proto === null) {
|
|
13090
|
+
return true;
|
|
13091
|
+
}
|
|
13092
|
+
var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
|
|
13093
|
+
return typeof Ctor == 'function' && Ctor instanceof Ctor &&
|
|
13094
|
+
funcToString.call(Ctor) == objectCtorString;
|
|
13095
|
+
}
|
|
13096
|
+
|
|
13097
|
+
isPlainObject_1 = isPlainObject;
|
|
13098
|
+
return isPlainObject_1;
|
|
13099
|
+
}
|
|
13100
|
+
|
|
13101
|
+
var isPlainObjectExports = requireIsPlainObject();
|
|
13102
|
+
var isPlainObject = /*@__PURE__*/getDefaultExportFromCjs(isPlainObjectExports);
|
|
13103
|
+
|
|
13104
|
+
function sortUnorderedArrays(data, paths = []) {
|
|
13105
|
+
if (!paths.length)
|
|
13106
|
+
return data;
|
|
13107
|
+
return visit(data, [], paths.map(p => p.split(".")));
|
|
13108
|
+
}
|
|
13109
|
+
function visit(node, path, patterns) {
|
|
13110
|
+
let visited = node;
|
|
13111
|
+
if (Array.isArray(node)) {
|
|
13112
|
+
visited = node.map((item, i) => visit(item, [...path, String(i)], patterns));
|
|
13113
|
+
}
|
|
13114
|
+
else if (isPlainObject(node)) {
|
|
13115
|
+
visited = Object.fromEntries(Object.entries(node).map(([k, v]) => [
|
|
13116
|
+
k,
|
|
13117
|
+
visit(v, [...path, k], patterns)
|
|
13118
|
+
]));
|
|
13119
|
+
}
|
|
13120
|
+
if (Array.isArray(visited) && patterns.some(p => matches(p, path))) {
|
|
13121
|
+
return visited
|
|
13122
|
+
.map(item => ({ item, key: canonical(item) }))
|
|
13123
|
+
.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0))
|
|
13124
|
+
.map(({ item }) => item);
|
|
13125
|
+
}
|
|
13126
|
+
return visited;
|
|
13127
|
+
}
|
|
13128
|
+
function matches(pattern, path) {
|
|
13129
|
+
if (!pattern.length)
|
|
13130
|
+
return !path.length;
|
|
13131
|
+
const [head, ...rest] = pattern;
|
|
13132
|
+
if (head === "**") {
|
|
13133
|
+
return matches(rest, path) || (path.length > 0 && matches(pattern, path.slice(1)));
|
|
13134
|
+
}
|
|
13135
|
+
return path.length > 0 && (head === "*" || head === path[0]) && matches(rest, path.slice(1));
|
|
13136
|
+
}
|
|
13137
|
+
function canonical(value) {
|
|
13138
|
+
if (Array.isArray(value))
|
|
13139
|
+
return `[${value.map(canonical).join(",")}]`;
|
|
13140
|
+
if (isPlainObject(value)) {
|
|
13141
|
+
const obj = value;
|
|
13142
|
+
const entries = Object.keys(obj)
|
|
13143
|
+
.sort()
|
|
13144
|
+
.map(k => `${JSON.stringify(k)}:${canonical(obj[k])}`);
|
|
13145
|
+
return `{${entries.join(",")}}`;
|
|
13146
|
+
}
|
|
13147
|
+
return JSON.stringify(value) ?? "undefined";
|
|
13148
|
+
}
|
|
13149
|
+
|
|
13150
|
+
async function buildPlan(modules, unlimitedHttp, rootDir, options = {}) {
|
|
12952
13151
|
const { detailed = false, detectRenames = true, reporter = silentReporter, concurrency = DEFAULT_CONCURRENCY, source } = options;
|
|
13152
|
+
const http = limitConcurrency(unlimitedHttp, concurrency);
|
|
12953
13153
|
const modulePlans = [];
|
|
12954
13154
|
for (const mod of modules) {
|
|
12955
13155
|
const [locals, remotes] = await Promise.all([
|
|
12956
13156
|
reporter.task(`Reading local ${mod.displayName} files`, () => mod.readLocal(rootDir, source)),
|
|
12957
|
-
reporter.task(`Fetching remote ${mod.displayName}`, () => mod.readRemote(http
|
|
13157
|
+
reporter.task(`Fetching remote ${mod.displayName}`, () => mod.readRemote(http))
|
|
12958
13158
|
]);
|
|
12959
13159
|
const localBySlug = new Map(locals.map(l => [l.slug, l]));
|
|
12960
13160
|
const remoteBySlug = new Map(remotes.map(r => [r.slug, r]));
|
|
@@ -13033,33 +13233,36 @@ async function buildPlan(modules, http, rootDir, options = {}) {
|
|
|
13033
13233
|
}
|
|
13034
13234
|
return { modules: modulePlans };
|
|
13035
13235
|
}
|
|
13036
|
-
async function applyPlan(plan,
|
|
13236
|
+
async function applyPlan(plan, unlimitedHttp, opts = {}) {
|
|
13037
13237
|
const concurrency = opts.concurrency ?? DEFAULT_CONCURRENCY;
|
|
13038
13238
|
const reporter = opts.reporter ?? silentReporter;
|
|
13039
13239
|
const errors = [];
|
|
13240
|
+
const abortController = new AbortController();
|
|
13241
|
+
const http = limitConcurrency(unlimitedHttp, concurrency, abortController.signal);
|
|
13242
|
+
let abortError;
|
|
13040
13243
|
const handleErr = (label, e) => {
|
|
13041
|
-
|
|
13042
|
-
|
|
13043
|
-
|
|
13044
|
-
|
|
13244
|
+
if (abortError)
|
|
13245
|
+
throw abortError;
|
|
13246
|
+
const full = `${label}: ${formatError(e)}`;
|
|
13247
|
+
if (opts.abortOnError) {
|
|
13248
|
+
abortError = new Error(full);
|
|
13249
|
+
abortController.abort(abortError);
|
|
13250
|
+
throw abortError;
|
|
13251
|
+
}
|
|
13045
13252
|
reporter.warn(full);
|
|
13046
13253
|
errors.push(full);
|
|
13047
13254
|
};
|
|
13048
13255
|
for (const mp of plan.modules) {
|
|
13049
13256
|
const { module: mod, creates, updates, deletes } = mp;
|
|
13050
|
-
|
|
13051
|
-
|
|
13052
|
-
}
|
|
13053
|
-
if (updates.length) {
|
|
13054
|
-
await runConcurrently(updates.map(e => ({ slug: e.slug, run: () => mod.update(http, e.local, e.remote.id) })), concurrency, `Updating ${mod.displayName}`, handleErr, reporter);
|
|
13055
|
-
}
|
|
13056
|
-
if (creates.length) {
|
|
13057
|
-
await runConcurrently(creates.map(e => ({ slug: e.slug, run: () => mod.create(http, e.local) })), concurrency, `Creating ${mod.displayName}`, handleErr, reporter);
|
|
13058
|
-
}
|
|
13257
|
+
await runAllAtOnce(deletes.map(e => ({ slug: e.slug, run: () => mod.delete(http, e.remote.id) })), `Deleting ${mod.displayName}`, handleErr, reporter);
|
|
13258
|
+
await runAllAtOnce(updates.map(e => ({ slug: e.slug, run: () => mod.update(http, e.local, e.remote.id) })), `Updating ${mod.displayName}`, handleErr, reporter);
|
|
13259
|
+
await runAllAtOnce(creates.map(e => ({ slug: e.slug, run: () => mod.create(http, e.local) })), `Creating ${mod.displayName}`, handleErr, reporter);
|
|
13059
13260
|
}
|
|
13060
13261
|
return { errors };
|
|
13061
13262
|
}
|
|
13062
|
-
function diffObjectFields(
|
|
13263
|
+
function diffObjectFields(rawLocal, rawRemote, ignoredFields, unorderedPaths = []) {
|
|
13264
|
+
const local = sortUnorderedArrays(rawLocal, unorderedPaths);
|
|
13265
|
+
const remote = sortUnorderedArrays(rawRemote, unorderedPaths);
|
|
13063
13266
|
const allKeys = new Set([...Object.keys(local), ...Object.keys(remote)]);
|
|
13064
13267
|
const changed = [];
|
|
13065
13268
|
for (const key of allKeys) {
|
|
@@ -13071,17 +13274,23 @@ function diffObjectFields(local, remote, ignoredFields) {
|
|
|
13071
13274
|
}
|
|
13072
13275
|
return changed;
|
|
13073
13276
|
}
|
|
13074
|
-
function diffSchemaFields(local, remote, ignoredFields) {
|
|
13075
|
-
return diffObjectFields(local, remote, ignoredFields);
|
|
13277
|
+
function diffSchemaFields(local, remote, ignoredFields, unorderedPaths = []) {
|
|
13278
|
+
return diffObjectFields(local, remote, ignoredFields, unorderedPaths);
|
|
13279
|
+
}
|
|
13280
|
+
function stringifyForDiff(data) {
|
|
13281
|
+
return YAML.stringify(data, { sortMapEntries: true });
|
|
13076
13282
|
}
|
|
13077
13283
|
function buildUnifiedDiff(oldContent, newContent, filename) {
|
|
13078
13284
|
return createTwoFilesPatch(`remote/${filename}`, `local/${filename}`, oldContent, newContent);
|
|
13079
13285
|
}
|
|
13080
|
-
function renderSchemaDetail(localData, remoteData, ignoredFields) {
|
|
13081
|
-
const localYaml =
|
|
13082
|
-
const remoteYaml =
|
|
13286
|
+
function renderSchemaDetail(localData, remoteData, ignoredFields, unorderedPaths = []) {
|
|
13287
|
+
const localYaml = stringifyForDiff(sortUnorderedArrays(omit(localData, ignoredFields), unorderedPaths));
|
|
13288
|
+
const remoteYaml = stringifyForDiff(sortUnorderedArrays(omit(remoteData, ignoredFields), unorderedPaths));
|
|
13083
13289
|
return { schema: buildUnifiedDiff(remoteYaml, localYaml, "schema.yaml") };
|
|
13084
13290
|
}
|
|
13291
|
+
function runAllAtOnce(tasks, label, onError, reporter) {
|
|
13292
|
+
return runConcurrently(tasks, tasks.length, label, onError, reporter);
|
|
13293
|
+
}
|
|
13085
13294
|
async function runConcurrently(tasks, concurrency, label, onError, reporter) {
|
|
13086
13295
|
if (!tasks.length)
|
|
13087
13296
|
return;
|
|
@@ -13089,21 +13298,13 @@ async function runConcurrently(tasks, concurrency, label, onError, reporter) {
|
|
|
13089
13298
|
let done = 0;
|
|
13090
13299
|
const progress = reporter.progress(label, total);
|
|
13091
13300
|
try {
|
|
13092
|
-
|
|
13093
|
-
|
|
13094
|
-
|
|
13095
|
-
|
|
13096
|
-
|
|
13097
|
-
|
|
13098
|
-
|
|
13099
|
-
.catch((e) => onError(`${label}: ${task.slug}`, e))
|
|
13100
|
-
.finally(() => {
|
|
13101
|
-
done++;
|
|
13102
|
-
progress.update(task.slug, done, total);
|
|
13103
|
-
})));
|
|
13104
|
-
batch = [];
|
|
13105
|
-
}
|
|
13106
|
-
}
|
|
13301
|
+
await mapWithConcurrency(tasks, concurrency, task => task
|
|
13302
|
+
.run()
|
|
13303
|
+
.catch((e) => onError(`${label}: ${task.slug}`, e))
|
|
13304
|
+
.finally(() => {
|
|
13305
|
+
done++;
|
|
13306
|
+
progress.update(task.slug, done, total);
|
|
13307
|
+
}));
|
|
13107
13308
|
progress.succeed();
|
|
13108
13309
|
}
|
|
13109
13310
|
catch (e) {
|
|
@@ -13119,12 +13320,14 @@ function formatError(e) {
|
|
|
13119
13320
|
return String(e);
|
|
13120
13321
|
}
|
|
13121
13322
|
|
|
13122
|
-
const IGNORED_FIELDS$3 = ["_id"];
|
|
13323
|
+
const IGNORED_FIELDS$3 = ["_id", "order"];
|
|
13324
|
+
const UNORDERED_PATHS$1 = ["required", "properties.**.required", "indexes"];
|
|
13123
13325
|
const bucketModule = {
|
|
13124
13326
|
name: "bucket",
|
|
13125
13327
|
displayName: "Bucket",
|
|
13126
13328
|
identityField: "title",
|
|
13127
13329
|
ignoredFields: IGNORED_FIELDS$3,
|
|
13330
|
+
unorderedPaths: UNORDERED_PATHS$1,
|
|
13128
13331
|
readLocal(rootDir, source) {
|
|
13129
13332
|
return readLocalSchemas(rootDir, "bucket", source);
|
|
13130
13333
|
},
|
|
@@ -13153,10 +13356,10 @@ const bucketModule = {
|
|
|
13153
13356
|
deleteLocalSchema(rootDir, "bucket", slug);
|
|
13154
13357
|
},
|
|
13155
13358
|
diffFields(local, remote) {
|
|
13156
|
-
return diffSchemaFields(local, remote, IGNORED_FIELDS$3);
|
|
13359
|
+
return diffSchemaFields(local, remote, IGNORED_FIELDS$3, UNORDERED_PATHS$1);
|
|
13157
13360
|
},
|
|
13158
13361
|
renderDetail(local, remote) {
|
|
13159
|
-
return renderSchemaDetail(local.data, remote.data, IGNORED_FIELDS$3);
|
|
13362
|
+
return renderSchemaDetail(local.data, remote.data, IGNORED_FIELDS$3, UNORDERED_PATHS$1);
|
|
13160
13363
|
},
|
|
13161
13364
|
summaryLine(resource) {
|
|
13162
13365
|
const propCount = Object.keys(resource.data.properties ?? {}).length;
|
|
@@ -15935,7 +16138,8 @@ function requireSemver () {
|
|
|
15935
16138
|
var semverExports = requireSemver();
|
|
15936
16139
|
var semver = /*@__PURE__*/getDefaultExportFromCjs(semverExports);
|
|
15937
16140
|
|
|
15938
|
-
const SCHEMA_IGNORED = ["_id", "env_vars", "secrets"];
|
|
16141
|
+
const SCHEMA_IGNORED = ["_id", "env_vars", "secrets", "order"];
|
|
16142
|
+
const SCHEMA_UNORDERED = ["triggers.*.options.authenticate"];
|
|
15939
16143
|
function indexFilename(language) {
|
|
15940
16144
|
return language === "typescript" ? "index.ts" : "index.mjs";
|
|
15941
16145
|
}
|
|
@@ -15960,14 +16164,6 @@ function normalizeSchema(schema) {
|
|
|
15960
16164
|
}
|
|
15961
16165
|
return normalized;
|
|
15962
16166
|
}
|
|
15963
|
-
async function mapInBatches(items, size, fn) {
|
|
15964
|
-
const limit = Math.max(1, size);
|
|
15965
|
-
const results = [];
|
|
15966
|
-
for (let i = 0; i < items.length; i += limit) {
|
|
15967
|
-
results.push(...(await Promise.all(items.slice(i, i + limit).map(fn))));
|
|
15968
|
-
}
|
|
15969
|
-
return results;
|
|
15970
|
-
}
|
|
15971
16167
|
function isNotFoundError(error) {
|
|
15972
16168
|
if (!error || typeof error !== "object")
|
|
15973
16169
|
return false;
|
|
@@ -16000,6 +16196,7 @@ const functionModule = {
|
|
|
16000
16196
|
displayName: "Function",
|
|
16001
16197
|
identityField: "name",
|
|
16002
16198
|
ignoredFields: SCHEMA_IGNORED,
|
|
16199
|
+
unorderedPaths: SCHEMA_UNORDERED,
|
|
16003
16200
|
readSchema(rootDir, slug, source = diskSource) {
|
|
16004
16201
|
return readSourceYaml(source, path.join(rootDir, "function", slug, "schema.yaml"));
|
|
16005
16202
|
},
|
|
@@ -16031,10 +16228,10 @@ const functionModule = {
|
|
|
16031
16228
|
}
|
|
16032
16229
|
return results;
|
|
16033
16230
|
},
|
|
16034
|
-
async readRemote(http
|
|
16231
|
+
async readRemote(http) {
|
|
16035
16232
|
const res = await http.get("function");
|
|
16036
16233
|
const fns = unwrapList(res);
|
|
16037
|
-
return
|
|
16234
|
+
return Promise.all(fns.map(async (fn) => {
|
|
16038
16235
|
const id = fn._id;
|
|
16039
16236
|
const [indexRes, depsRes] = await Promise.all([
|
|
16040
16237
|
http.get(`function/${id}/index`).catch(emptyIfMissing({ index: "" })),
|
|
@@ -16057,7 +16254,7 @@ const functionModule = {
|
|
|
16057
16254
|
dependencies
|
|
16058
16255
|
}
|
|
16059
16256
|
};
|
|
16060
|
-
});
|
|
16257
|
+
}));
|
|
16061
16258
|
},
|
|
16062
16259
|
async create(http, local) {
|
|
16063
16260
|
const id = await this.createSchema(http, local.data.schema);
|
|
@@ -16151,7 +16348,7 @@ const functionModule = {
|
|
|
16151
16348
|
},
|
|
16152
16349
|
diffFields(local, remote) {
|
|
16153
16350
|
const changed = [];
|
|
16154
|
-
const schemaChanged = diffObjectFields(local.schema, remote.schema, SCHEMA_IGNORED);
|
|
16351
|
+
const schemaChanged = diffObjectFields(local.schema, remote.schema, SCHEMA_IGNORED, SCHEMA_UNORDERED);
|
|
16155
16352
|
if (schemaChanged.length)
|
|
16156
16353
|
changed.push("schema");
|
|
16157
16354
|
if (local.index !== remote.index)
|
|
@@ -16170,8 +16367,8 @@ const functionModule = {
|
|
|
16170
16367
|
},
|
|
16171
16368
|
renderDetail(local, remote) {
|
|
16172
16369
|
const result = {};
|
|
16173
|
-
const localSchemaYaml =
|
|
16174
|
-
const remoteSchemaYaml =
|
|
16370
|
+
const localSchemaYaml = stringifyForDiff(sortUnorderedArrays(omit(local.data.schema, SCHEMA_IGNORED), SCHEMA_UNORDERED));
|
|
16371
|
+
const remoteSchemaYaml = stringifyForDiff(sortUnorderedArrays(omit(remote.data.schema, SCHEMA_IGNORED), SCHEMA_UNORDERED));
|
|
16175
16372
|
if (localSchemaYaml !== remoteSchemaYaml) {
|
|
16176
16373
|
result["schema"] = buildUnifiedDiff(remoteSchemaYaml, localSchemaYaml, "schema.yaml");
|
|
16177
16374
|
}
|
|
@@ -16280,11 +16477,17 @@ const functionModule = {
|
|
|
16280
16477
|
};
|
|
16281
16478
|
|
|
16282
16479
|
const IGNORED_FIELDS$1 = ["_id", "system"];
|
|
16480
|
+
const UNORDERED_PATHS = [
|
|
16481
|
+
"statement",
|
|
16482
|
+
"statement.*.resource.include",
|
|
16483
|
+
"statement.*.resource.exclude"
|
|
16484
|
+
];
|
|
16283
16485
|
const policyModule = {
|
|
16284
16486
|
name: "policy",
|
|
16285
16487
|
displayName: "Policy",
|
|
16286
16488
|
identityField: "name",
|
|
16287
16489
|
ignoredFields: IGNORED_FIELDS$1,
|
|
16490
|
+
unorderedPaths: UNORDERED_PATHS,
|
|
16288
16491
|
readLocal(rootDir, source) {
|
|
16289
16492
|
return readLocalSchemas(rootDir, "policy", source);
|
|
16290
16493
|
},
|
|
@@ -16317,10 +16520,10 @@ const policyModule = {
|
|
|
16317
16520
|
deleteLocalSchema(rootDir, "policy", slug);
|
|
16318
16521
|
},
|
|
16319
16522
|
diffFields(local, remote) {
|
|
16320
|
-
return diffSchemaFields(local, remote, IGNORED_FIELDS$1);
|
|
16523
|
+
return diffSchemaFields(local, remote, IGNORED_FIELDS$1, UNORDERED_PATHS);
|
|
16321
16524
|
},
|
|
16322
16525
|
renderDetail(local, remote) {
|
|
16323
|
-
return renderSchemaDetail(local.data, remote.data, IGNORED_FIELDS$1);
|
|
16526
|
+
return renderSchemaDetail(local.data, remote.data, IGNORED_FIELDS$1, UNORDERED_PATHS);
|
|
16324
16527
|
},
|
|
16325
16528
|
summaryLine(resource) {
|
|
16326
16529
|
const stmts = resource.data.statement?.length ?? 0;
|