@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.mjs
CHANGED
|
@@ -260,6 +260,85 @@ var ChangeKind;
|
|
|
260
260
|
})(ChangeKind || (ChangeKind = {}));
|
|
261
261
|
const DEFAULT_CONCURRENCY = 10;
|
|
262
262
|
|
|
263
|
+
const REQUEST_METHODS = ["get", "delete", "head", "post", "patch", "put"];
|
|
264
|
+
const limitedClients = new WeakMap();
|
|
265
|
+
function limitConcurrency(http, limit = DEFAULT_CONCURRENCY, signal) {
|
|
266
|
+
const existing = limitedClients.get(http);
|
|
267
|
+
if (existing && !signal)
|
|
268
|
+
return http;
|
|
269
|
+
const { semaphore, target } = existing ?? {
|
|
270
|
+
semaphore: new Semaphore(normalizeLimit(limit)),
|
|
271
|
+
target: http
|
|
272
|
+
};
|
|
273
|
+
const limited = { ...target };
|
|
274
|
+
for (const method of REQUEST_METHODS) {
|
|
275
|
+
limited[method] = (...args) => semaphore.run(() => {
|
|
276
|
+
if (signal?.aborted)
|
|
277
|
+
throw signal.reason;
|
|
278
|
+
return target[method](...args);
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
limitedClients.set(limited, { semaphore, target });
|
|
282
|
+
return limited;
|
|
283
|
+
}
|
|
284
|
+
async function mapWithConcurrency(items, limit, fn) {
|
|
285
|
+
const results = new Array(items.length);
|
|
286
|
+
let next = 0;
|
|
287
|
+
let failure;
|
|
288
|
+
const worker = async () => {
|
|
289
|
+
while (!failure && next < items.length) {
|
|
290
|
+
const index = next++;
|
|
291
|
+
try {
|
|
292
|
+
results[index] = await fn(items[index], index);
|
|
293
|
+
}
|
|
294
|
+
catch (error) {
|
|
295
|
+
if (!failure)
|
|
296
|
+
failure = { error };
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
const workerCount = Math.min(normalizeLimit(limit), items.length);
|
|
301
|
+
await Promise.all(Array.from({ length: workerCount }, worker));
|
|
302
|
+
if (failure)
|
|
303
|
+
throw failure.error;
|
|
304
|
+
return results;
|
|
305
|
+
}
|
|
306
|
+
function normalizeLimit(limit) {
|
|
307
|
+
return Number.isFinite(limit) ? Math.max(1, Math.floor(limit)) : DEFAULT_CONCURRENCY;
|
|
308
|
+
}
|
|
309
|
+
class Semaphore {
|
|
310
|
+
constructor(limit) {
|
|
311
|
+
this.limit = limit;
|
|
312
|
+
this.active = 0;
|
|
313
|
+
this.waiting = [];
|
|
314
|
+
}
|
|
315
|
+
async run(task) {
|
|
316
|
+
await this.acquire();
|
|
317
|
+
try {
|
|
318
|
+
return await task();
|
|
319
|
+
}
|
|
320
|
+
finally {
|
|
321
|
+
this.release();
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
acquire() {
|
|
325
|
+
if (this.active < this.limit) {
|
|
326
|
+
this.active++;
|
|
327
|
+
return Promise.resolve();
|
|
328
|
+
}
|
|
329
|
+
return new Promise(resolve => this.waiting.push(resolve));
|
|
330
|
+
}
|
|
331
|
+
release() {
|
|
332
|
+
const next = this.waiting.shift();
|
|
333
|
+
if (next) {
|
|
334
|
+
next();
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
this.active--;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
263
342
|
const noopProgress = {
|
|
264
343
|
update() { },
|
|
265
344
|
succeed() { },
|
|
@@ -339,7 +418,7 @@ const REMOVE$1 = Symbol('remove node');
|
|
|
339
418
|
* and `Node` (alias, map, seq & scalar) targets. Of all these, only the most
|
|
340
419
|
* specific defined one will be used for each node.
|
|
341
420
|
*/
|
|
342
|
-
function visit$
|
|
421
|
+
function visit$2(node, visitor) {
|
|
343
422
|
const visitor_ = initVisitor(visitor);
|
|
344
423
|
if (isDocument(node)) {
|
|
345
424
|
const cd = visit_(null, node.contents, visitor_, Object.freeze([node]));
|
|
@@ -353,11 +432,11 @@ function visit$1(node, visitor) {
|
|
|
353
432
|
// namespace using `var`, but then complains about that because
|
|
354
433
|
// `unique symbol` must be `const`.
|
|
355
434
|
/** Terminate visit traversal completely */
|
|
356
|
-
visit$
|
|
435
|
+
visit$2.BREAK = BREAK$1;
|
|
357
436
|
/** Do not visit the children of the current node */
|
|
358
|
-
visit$
|
|
437
|
+
visit$2.SKIP = SKIP$1;
|
|
359
438
|
/** Remove the current node */
|
|
360
|
-
visit$
|
|
439
|
+
visit$2.REMOVE = REMOVE$1;
|
|
361
440
|
function visit_(key, node, visitor, path) {
|
|
362
441
|
const ctrl = callVisitor(key, node, visitor, path);
|
|
363
442
|
if (isNode(ctrl) || isPair(ctrl)) {
|
|
@@ -688,7 +767,7 @@ class Directives {
|
|
|
688
767
|
let tagNames;
|
|
689
768
|
if (doc && tagEntries.length > 0 && isNode(doc.contents)) {
|
|
690
769
|
const tags = {};
|
|
691
|
-
visit$
|
|
770
|
+
visit$2(doc.contents, (_key, node) => {
|
|
692
771
|
if (isNode(node) && node.tag)
|
|
693
772
|
tags[node.tag] = true;
|
|
694
773
|
});
|
|
@@ -723,7 +802,7 @@ function anchorIsValid(anchor) {
|
|
|
723
802
|
}
|
|
724
803
|
function anchorNames(root) {
|
|
725
804
|
const anchors = new Set();
|
|
726
|
-
visit$
|
|
805
|
+
visit$2(root, {
|
|
727
806
|
Value(_key, node) {
|
|
728
807
|
if (node.anchor)
|
|
729
808
|
anchors.add(node.anchor);
|
|
@@ -917,7 +996,7 @@ class Alias extends NodeBase {
|
|
|
917
996
|
}
|
|
918
997
|
else {
|
|
919
998
|
nodes = [];
|
|
920
|
-
visit$
|
|
999
|
+
visit$2(doc, {
|
|
921
1000
|
Node: (_key, node) => {
|
|
922
1001
|
if (isAlias(node) || hasAnchor(node))
|
|
923
1002
|
nodes.push(node);
|
|
@@ -5714,7 +5793,7 @@ const REMOVE = Symbol('remove item');
|
|
|
5714
5793
|
* visitor is called on item entry, next visitors are called after handling
|
|
5715
5794
|
* a non-empty `key` and when exiting the item.
|
|
5716
5795
|
*/
|
|
5717
|
-
function visit(cst, visitor) {
|
|
5796
|
+
function visit$1(cst, visitor) {
|
|
5718
5797
|
if ('type' in cst && cst.type === 'document')
|
|
5719
5798
|
cst = { start: cst.start, value: cst.value };
|
|
5720
5799
|
_visit(Object.freeze([]), cst, visitor);
|
|
@@ -5723,13 +5802,13 @@ function visit(cst, visitor) {
|
|
|
5723
5802
|
// namespace using `var`, but then complains about that because
|
|
5724
5803
|
// `unique symbol` must be `const`.
|
|
5725
5804
|
/** Terminate visit traversal completely */
|
|
5726
|
-
visit.BREAK = BREAK;
|
|
5805
|
+
visit$1.BREAK = BREAK;
|
|
5727
5806
|
/** Do not visit the children of the current item */
|
|
5728
|
-
visit.SKIP = SKIP;
|
|
5807
|
+
visit$1.SKIP = SKIP;
|
|
5729
5808
|
/** Remove the current item */
|
|
5730
|
-
visit.REMOVE = REMOVE;
|
|
5809
|
+
visit$1.REMOVE = REMOVE;
|
|
5731
5810
|
/** Find the item at `path` from `cst` as the root */
|
|
5732
|
-
visit.itemAtPath = (cst, path) => {
|
|
5811
|
+
visit$1.itemAtPath = (cst, path) => {
|
|
5733
5812
|
let item = cst;
|
|
5734
5813
|
for (const [field, index] of path) {
|
|
5735
5814
|
const tok = item?.[field];
|
|
@@ -5746,8 +5825,8 @@ visit.itemAtPath = (cst, path) => {
|
|
|
5746
5825
|
*
|
|
5747
5826
|
* Throws an error if the collection is not found, which should never happen if the item itself exists.
|
|
5748
5827
|
*/
|
|
5749
|
-
visit.parentCollection = (cst, path) => {
|
|
5750
|
-
const parent = visit.itemAtPath(cst, path.slice(0, -1));
|
|
5828
|
+
visit$1.parentCollection = (cst, path) => {
|
|
5829
|
+
const parent = visit$1.itemAtPath(cst, path.slice(0, -1));
|
|
5751
5830
|
const field = path[path.length - 1][0];
|
|
5752
5831
|
const coll = parent?.[field];
|
|
5753
5832
|
if (coll && 'items' in coll)
|
|
@@ -5886,7 +5965,7 @@ var cst = /*#__PURE__*/Object.freeze({
|
|
|
5886
5965
|
setScalarValue: setScalarValue,
|
|
5887
5966
|
stringify: stringify$1,
|
|
5888
5967
|
tokenType: tokenType,
|
|
5889
|
-
visit: visit
|
|
5968
|
+
visit: visit$1
|
|
5890
5969
|
});
|
|
5891
5970
|
|
|
5892
5971
|
/*
|
|
@@ -7726,7 +7805,7 @@ var YAML = /*#__PURE__*/Object.freeze({
|
|
|
7726
7805
|
parseAllDocuments: parseAllDocuments,
|
|
7727
7806
|
parseDocument: parseDocument,
|
|
7728
7807
|
stringify: stringify,
|
|
7729
|
-
visit: visit$
|
|
7808
|
+
visit: visit$2,
|
|
7730
7809
|
visitAsync: visitAsync
|
|
7731
7810
|
});
|
|
7732
7811
|
|
|
@@ -12927,13 +13006,134 @@ function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader
|
|
|
12927
13006
|
return ret.join('\n') + '\n';
|
|
12928
13007
|
}
|
|
12929
13008
|
|
|
12930
|
-
|
|
13009
|
+
var isPlainObject_1;
|
|
13010
|
+
var hasRequiredIsPlainObject;
|
|
13011
|
+
|
|
13012
|
+
function requireIsPlainObject () {
|
|
13013
|
+
if (hasRequiredIsPlainObject) return isPlainObject_1;
|
|
13014
|
+
hasRequiredIsPlainObject = 1;
|
|
13015
|
+
var baseGetTag = require_baseGetTag(),
|
|
13016
|
+
getPrototype = require_getPrototype(),
|
|
13017
|
+
isObjectLike = requireIsObjectLike();
|
|
13018
|
+
|
|
13019
|
+
/** `Object#toString` result references. */
|
|
13020
|
+
var objectTag = '[object Object]';
|
|
13021
|
+
|
|
13022
|
+
/** Used for built-in method references. */
|
|
13023
|
+
var funcProto = Function.prototype,
|
|
13024
|
+
objectProto = Object.prototype;
|
|
13025
|
+
|
|
13026
|
+
/** Used to resolve the decompiled source of functions. */
|
|
13027
|
+
var funcToString = funcProto.toString;
|
|
13028
|
+
|
|
13029
|
+
/** Used to check objects for own properties. */
|
|
13030
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
13031
|
+
|
|
13032
|
+
/** Used to infer the `Object` constructor. */
|
|
13033
|
+
var objectCtorString = funcToString.call(Object);
|
|
13034
|
+
|
|
13035
|
+
/**
|
|
13036
|
+
* Checks if `value` is a plain object, that is, an object created by the
|
|
13037
|
+
* `Object` constructor or one with a `[[Prototype]]` of `null`.
|
|
13038
|
+
*
|
|
13039
|
+
* @static
|
|
13040
|
+
* @memberOf _
|
|
13041
|
+
* @since 0.8.0
|
|
13042
|
+
* @category Lang
|
|
13043
|
+
* @param {*} value The value to check.
|
|
13044
|
+
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
|
|
13045
|
+
* @example
|
|
13046
|
+
*
|
|
13047
|
+
* function Foo() {
|
|
13048
|
+
* this.a = 1;
|
|
13049
|
+
* }
|
|
13050
|
+
*
|
|
13051
|
+
* _.isPlainObject(new Foo);
|
|
13052
|
+
* // => false
|
|
13053
|
+
*
|
|
13054
|
+
* _.isPlainObject([1, 2, 3]);
|
|
13055
|
+
* // => false
|
|
13056
|
+
*
|
|
13057
|
+
* _.isPlainObject({ 'x': 0, 'y': 0 });
|
|
13058
|
+
* // => true
|
|
13059
|
+
*
|
|
13060
|
+
* _.isPlainObject(Object.create(null));
|
|
13061
|
+
* // => true
|
|
13062
|
+
*/
|
|
13063
|
+
function isPlainObject(value) {
|
|
13064
|
+
if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
|
|
13065
|
+
return false;
|
|
13066
|
+
}
|
|
13067
|
+
var proto = getPrototype(value);
|
|
13068
|
+
if (proto === null) {
|
|
13069
|
+
return true;
|
|
13070
|
+
}
|
|
13071
|
+
var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
|
|
13072
|
+
return typeof Ctor == 'function' && Ctor instanceof Ctor &&
|
|
13073
|
+
funcToString.call(Ctor) == objectCtorString;
|
|
13074
|
+
}
|
|
13075
|
+
|
|
13076
|
+
isPlainObject_1 = isPlainObject;
|
|
13077
|
+
return isPlainObject_1;
|
|
13078
|
+
}
|
|
13079
|
+
|
|
13080
|
+
var isPlainObjectExports = requireIsPlainObject();
|
|
13081
|
+
var isPlainObject = /*@__PURE__*/getDefaultExportFromCjs(isPlainObjectExports);
|
|
13082
|
+
|
|
13083
|
+
function sortUnorderedArrays(data, paths = []) {
|
|
13084
|
+
if (!paths.length)
|
|
13085
|
+
return data;
|
|
13086
|
+
return visit(data, [], paths.map(p => p.split(".")));
|
|
13087
|
+
}
|
|
13088
|
+
function visit(node, path, patterns) {
|
|
13089
|
+
let visited = node;
|
|
13090
|
+
if (Array.isArray(node)) {
|
|
13091
|
+
visited = node.map((item, i) => visit(item, [...path, String(i)], patterns));
|
|
13092
|
+
}
|
|
13093
|
+
else if (isPlainObject(node)) {
|
|
13094
|
+
visited = Object.fromEntries(Object.entries(node).map(([k, v]) => [
|
|
13095
|
+
k,
|
|
13096
|
+
visit(v, [...path, k], patterns)
|
|
13097
|
+
]));
|
|
13098
|
+
}
|
|
13099
|
+
if (Array.isArray(visited) && patterns.some(p => matches(p, path))) {
|
|
13100
|
+
return visited
|
|
13101
|
+
.map(item => ({ item, key: canonical(item) }))
|
|
13102
|
+
.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0))
|
|
13103
|
+
.map(({ item }) => item);
|
|
13104
|
+
}
|
|
13105
|
+
return visited;
|
|
13106
|
+
}
|
|
13107
|
+
function matches(pattern, path) {
|
|
13108
|
+
if (!pattern.length)
|
|
13109
|
+
return !path.length;
|
|
13110
|
+
const [head, ...rest] = pattern;
|
|
13111
|
+
if (head === "**") {
|
|
13112
|
+
return matches(rest, path) || (path.length > 0 && matches(pattern, path.slice(1)));
|
|
13113
|
+
}
|
|
13114
|
+
return path.length > 0 && (head === "*" || head === path[0]) && matches(rest, path.slice(1));
|
|
13115
|
+
}
|
|
13116
|
+
function canonical(value) {
|
|
13117
|
+
if (Array.isArray(value))
|
|
13118
|
+
return `[${value.map(canonical).join(",")}]`;
|
|
13119
|
+
if (isPlainObject(value)) {
|
|
13120
|
+
const obj = value;
|
|
13121
|
+
const entries = Object.keys(obj)
|
|
13122
|
+
.sort()
|
|
13123
|
+
.map(k => `${JSON.stringify(k)}:${canonical(obj[k])}`);
|
|
13124
|
+
return `{${entries.join(",")}}`;
|
|
13125
|
+
}
|
|
13126
|
+
return JSON.stringify(value) ?? "undefined";
|
|
13127
|
+
}
|
|
13128
|
+
|
|
13129
|
+
async function buildPlan(modules, unlimitedHttp, rootDir, options = {}) {
|
|
12931
13130
|
const { detailed = false, detectRenames = true, reporter = silentReporter, concurrency = DEFAULT_CONCURRENCY, source } = options;
|
|
13131
|
+
const http = limitConcurrency(unlimitedHttp, concurrency);
|
|
12932
13132
|
const modulePlans = [];
|
|
12933
13133
|
for (const mod of modules) {
|
|
12934
13134
|
const [locals, remotes] = await Promise.all([
|
|
12935
13135
|
reporter.task(`Reading local ${mod.displayName} files`, () => mod.readLocal(rootDir, source)),
|
|
12936
|
-
reporter.task(`Fetching remote ${mod.displayName}`, () => mod.readRemote(http
|
|
13136
|
+
reporter.task(`Fetching remote ${mod.displayName}`, () => mod.readRemote(http))
|
|
12937
13137
|
]);
|
|
12938
13138
|
const localBySlug = new Map(locals.map(l => [l.slug, l]));
|
|
12939
13139
|
const remoteBySlug = new Map(remotes.map(r => [r.slug, r]));
|
|
@@ -13012,33 +13212,36 @@ async function buildPlan(modules, http, rootDir, options = {}) {
|
|
|
13012
13212
|
}
|
|
13013
13213
|
return { modules: modulePlans };
|
|
13014
13214
|
}
|
|
13015
|
-
async function applyPlan(plan,
|
|
13215
|
+
async function applyPlan(plan, unlimitedHttp, opts = {}) {
|
|
13016
13216
|
const concurrency = opts.concurrency ?? DEFAULT_CONCURRENCY;
|
|
13017
13217
|
const reporter = opts.reporter ?? silentReporter;
|
|
13018
13218
|
const errors = [];
|
|
13219
|
+
const abortController = new AbortController();
|
|
13220
|
+
const http = limitConcurrency(unlimitedHttp, concurrency, abortController.signal);
|
|
13221
|
+
let abortError;
|
|
13019
13222
|
const handleErr = (label, e) => {
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
|
|
13023
|
-
|
|
13223
|
+
if (abortError)
|
|
13224
|
+
throw abortError;
|
|
13225
|
+
const full = `${label}: ${formatError(e)}`;
|
|
13226
|
+
if (opts.abortOnError) {
|
|
13227
|
+
abortError = new Error(full);
|
|
13228
|
+
abortController.abort(abortError);
|
|
13229
|
+
throw abortError;
|
|
13230
|
+
}
|
|
13024
13231
|
reporter.warn(full);
|
|
13025
13232
|
errors.push(full);
|
|
13026
13233
|
};
|
|
13027
13234
|
for (const mp of plan.modules) {
|
|
13028
13235
|
const { module: mod, creates, updates, deletes } = mp;
|
|
13029
|
-
|
|
13030
|
-
|
|
13031
|
-
}
|
|
13032
|
-
if (updates.length) {
|
|
13033
|
-
await runConcurrently(updates.map(e => ({ slug: e.slug, run: () => mod.update(http, e.local, e.remote.id) })), concurrency, `Updating ${mod.displayName}`, handleErr, reporter);
|
|
13034
|
-
}
|
|
13035
|
-
if (creates.length) {
|
|
13036
|
-
await runConcurrently(creates.map(e => ({ slug: e.slug, run: () => mod.create(http, e.local) })), concurrency, `Creating ${mod.displayName}`, handleErr, reporter);
|
|
13037
|
-
}
|
|
13236
|
+
await runAllAtOnce(deletes.map(e => ({ slug: e.slug, run: () => mod.delete(http, e.remote.id) })), `Deleting ${mod.displayName}`, handleErr, reporter);
|
|
13237
|
+
await runAllAtOnce(updates.map(e => ({ slug: e.slug, run: () => mod.update(http, e.local, e.remote.id) })), `Updating ${mod.displayName}`, handleErr, reporter);
|
|
13238
|
+
await runAllAtOnce(creates.map(e => ({ slug: e.slug, run: () => mod.create(http, e.local) })), `Creating ${mod.displayName}`, handleErr, reporter);
|
|
13038
13239
|
}
|
|
13039
13240
|
return { errors };
|
|
13040
13241
|
}
|
|
13041
|
-
function diffObjectFields(
|
|
13242
|
+
function diffObjectFields(rawLocal, rawRemote, ignoredFields, unorderedPaths = []) {
|
|
13243
|
+
const local = sortUnorderedArrays(rawLocal, unorderedPaths);
|
|
13244
|
+
const remote = sortUnorderedArrays(rawRemote, unorderedPaths);
|
|
13042
13245
|
const allKeys = new Set([...Object.keys(local), ...Object.keys(remote)]);
|
|
13043
13246
|
const changed = [];
|
|
13044
13247
|
for (const key of allKeys) {
|
|
@@ -13050,17 +13253,23 @@ function diffObjectFields(local, remote, ignoredFields) {
|
|
|
13050
13253
|
}
|
|
13051
13254
|
return changed;
|
|
13052
13255
|
}
|
|
13053
|
-
function diffSchemaFields(local, remote, ignoredFields) {
|
|
13054
|
-
return diffObjectFields(local, remote, ignoredFields);
|
|
13256
|
+
function diffSchemaFields(local, remote, ignoredFields, unorderedPaths = []) {
|
|
13257
|
+
return diffObjectFields(local, remote, ignoredFields, unorderedPaths);
|
|
13258
|
+
}
|
|
13259
|
+
function stringifyForDiff(data) {
|
|
13260
|
+
return YAML.stringify(data, { sortMapEntries: true });
|
|
13055
13261
|
}
|
|
13056
13262
|
function buildUnifiedDiff(oldContent, newContent, filename) {
|
|
13057
13263
|
return createTwoFilesPatch(`remote/${filename}`, `local/${filename}`, oldContent, newContent);
|
|
13058
13264
|
}
|
|
13059
|
-
function renderSchemaDetail(localData, remoteData, ignoredFields) {
|
|
13060
|
-
const localYaml =
|
|
13061
|
-
const remoteYaml =
|
|
13265
|
+
function renderSchemaDetail(localData, remoteData, ignoredFields, unorderedPaths = []) {
|
|
13266
|
+
const localYaml = stringifyForDiff(sortUnorderedArrays(omit(localData, ignoredFields), unorderedPaths));
|
|
13267
|
+
const remoteYaml = stringifyForDiff(sortUnorderedArrays(omit(remoteData, ignoredFields), unorderedPaths));
|
|
13062
13268
|
return { schema: buildUnifiedDiff(remoteYaml, localYaml, "schema.yaml") };
|
|
13063
13269
|
}
|
|
13270
|
+
function runAllAtOnce(tasks, label, onError, reporter) {
|
|
13271
|
+
return runConcurrently(tasks, tasks.length, label, onError, reporter);
|
|
13272
|
+
}
|
|
13064
13273
|
async function runConcurrently(tasks, concurrency, label, onError, reporter) {
|
|
13065
13274
|
if (!tasks.length)
|
|
13066
13275
|
return;
|
|
@@ -13068,21 +13277,13 @@ async function runConcurrently(tasks, concurrency, label, onError, reporter) {
|
|
|
13068
13277
|
let done = 0;
|
|
13069
13278
|
const progress = reporter.progress(label, total);
|
|
13070
13279
|
try {
|
|
13071
|
-
|
|
13072
|
-
|
|
13073
|
-
|
|
13074
|
-
|
|
13075
|
-
|
|
13076
|
-
|
|
13077
|
-
|
|
13078
|
-
.catch((e) => onError(`${label}: ${task.slug}`, e))
|
|
13079
|
-
.finally(() => {
|
|
13080
|
-
done++;
|
|
13081
|
-
progress.update(task.slug, done, total);
|
|
13082
|
-
})));
|
|
13083
|
-
batch = [];
|
|
13084
|
-
}
|
|
13085
|
-
}
|
|
13280
|
+
await mapWithConcurrency(tasks, concurrency, task => task
|
|
13281
|
+
.run()
|
|
13282
|
+
.catch((e) => onError(`${label}: ${task.slug}`, e))
|
|
13283
|
+
.finally(() => {
|
|
13284
|
+
done++;
|
|
13285
|
+
progress.update(task.slug, done, total);
|
|
13286
|
+
}));
|
|
13086
13287
|
progress.succeed();
|
|
13087
13288
|
}
|
|
13088
13289
|
catch (e) {
|
|
@@ -13098,12 +13299,14 @@ function formatError(e) {
|
|
|
13098
13299
|
return String(e);
|
|
13099
13300
|
}
|
|
13100
13301
|
|
|
13101
|
-
const IGNORED_FIELDS$3 = ["_id"];
|
|
13302
|
+
const IGNORED_FIELDS$3 = ["_id", "order"];
|
|
13303
|
+
const UNORDERED_PATHS$1 = ["required", "properties.**.required", "indexes"];
|
|
13102
13304
|
const bucketModule = {
|
|
13103
13305
|
name: "bucket",
|
|
13104
13306
|
displayName: "Bucket",
|
|
13105
13307
|
identityField: "title",
|
|
13106
13308
|
ignoredFields: IGNORED_FIELDS$3,
|
|
13309
|
+
unorderedPaths: UNORDERED_PATHS$1,
|
|
13107
13310
|
readLocal(rootDir, source) {
|
|
13108
13311
|
return readLocalSchemas(rootDir, "bucket", source);
|
|
13109
13312
|
},
|
|
@@ -13132,10 +13335,10 @@ const bucketModule = {
|
|
|
13132
13335
|
deleteLocalSchema(rootDir, "bucket", slug);
|
|
13133
13336
|
},
|
|
13134
13337
|
diffFields(local, remote) {
|
|
13135
|
-
return diffSchemaFields(local, remote, IGNORED_FIELDS$3);
|
|
13338
|
+
return diffSchemaFields(local, remote, IGNORED_FIELDS$3, UNORDERED_PATHS$1);
|
|
13136
13339
|
},
|
|
13137
13340
|
renderDetail(local, remote) {
|
|
13138
|
-
return renderSchemaDetail(local.data, remote.data, IGNORED_FIELDS$3);
|
|
13341
|
+
return renderSchemaDetail(local.data, remote.data, IGNORED_FIELDS$3, UNORDERED_PATHS$1);
|
|
13139
13342
|
},
|
|
13140
13343
|
summaryLine(resource) {
|
|
13141
13344
|
const propCount = Object.keys(resource.data.properties ?? {}).length;
|
|
@@ -15914,7 +16117,8 @@ function requireSemver () {
|
|
|
15914
16117
|
var semverExports = requireSemver();
|
|
15915
16118
|
var semver = /*@__PURE__*/getDefaultExportFromCjs(semverExports);
|
|
15916
16119
|
|
|
15917
|
-
const SCHEMA_IGNORED = ["_id", "env_vars", "secrets"];
|
|
16120
|
+
const SCHEMA_IGNORED = ["_id", "env_vars", "secrets", "order"];
|
|
16121
|
+
const SCHEMA_UNORDERED = ["triggers.*.options.authenticate"];
|
|
15918
16122
|
function indexFilename(language) {
|
|
15919
16123
|
return language === "typescript" ? "index.ts" : "index.mjs";
|
|
15920
16124
|
}
|
|
@@ -15939,14 +16143,6 @@ function normalizeSchema(schema) {
|
|
|
15939
16143
|
}
|
|
15940
16144
|
return normalized;
|
|
15941
16145
|
}
|
|
15942
|
-
async function mapInBatches(items, size, fn) {
|
|
15943
|
-
const limit = Math.max(1, size);
|
|
15944
|
-
const results = [];
|
|
15945
|
-
for (let i = 0; i < items.length; i += limit) {
|
|
15946
|
-
results.push(...(await Promise.all(items.slice(i, i + limit).map(fn))));
|
|
15947
|
-
}
|
|
15948
|
-
return results;
|
|
15949
|
-
}
|
|
15950
16146
|
function isNotFoundError(error) {
|
|
15951
16147
|
if (!error || typeof error !== "object")
|
|
15952
16148
|
return false;
|
|
@@ -15979,6 +16175,7 @@ const functionModule = {
|
|
|
15979
16175
|
displayName: "Function",
|
|
15980
16176
|
identityField: "name",
|
|
15981
16177
|
ignoredFields: SCHEMA_IGNORED,
|
|
16178
|
+
unorderedPaths: SCHEMA_UNORDERED,
|
|
15982
16179
|
readSchema(rootDir, slug, source = diskSource) {
|
|
15983
16180
|
return readSourceYaml(source, path.join(rootDir, "function", slug, "schema.yaml"));
|
|
15984
16181
|
},
|
|
@@ -16010,10 +16207,10 @@ const functionModule = {
|
|
|
16010
16207
|
}
|
|
16011
16208
|
return results;
|
|
16012
16209
|
},
|
|
16013
|
-
async readRemote(http
|
|
16210
|
+
async readRemote(http) {
|
|
16014
16211
|
const res = await http.get("function");
|
|
16015
16212
|
const fns = unwrapList(res);
|
|
16016
|
-
return
|
|
16213
|
+
return Promise.all(fns.map(async (fn) => {
|
|
16017
16214
|
const id = fn._id;
|
|
16018
16215
|
const [indexRes, depsRes] = await Promise.all([
|
|
16019
16216
|
http.get(`function/${id}/index`).catch(emptyIfMissing({ index: "" })),
|
|
@@ -16036,7 +16233,7 @@ const functionModule = {
|
|
|
16036
16233
|
dependencies
|
|
16037
16234
|
}
|
|
16038
16235
|
};
|
|
16039
|
-
});
|
|
16236
|
+
}));
|
|
16040
16237
|
},
|
|
16041
16238
|
async create(http, local) {
|
|
16042
16239
|
const id = await this.createSchema(http, local.data.schema);
|
|
@@ -16130,7 +16327,7 @@ const functionModule = {
|
|
|
16130
16327
|
},
|
|
16131
16328
|
diffFields(local, remote) {
|
|
16132
16329
|
const changed = [];
|
|
16133
|
-
const schemaChanged = diffObjectFields(local.schema, remote.schema, SCHEMA_IGNORED);
|
|
16330
|
+
const schemaChanged = diffObjectFields(local.schema, remote.schema, SCHEMA_IGNORED, SCHEMA_UNORDERED);
|
|
16134
16331
|
if (schemaChanged.length)
|
|
16135
16332
|
changed.push("schema");
|
|
16136
16333
|
if (local.index !== remote.index)
|
|
@@ -16149,8 +16346,8 @@ const functionModule = {
|
|
|
16149
16346
|
},
|
|
16150
16347
|
renderDetail(local, remote) {
|
|
16151
16348
|
const result = {};
|
|
16152
|
-
const localSchemaYaml =
|
|
16153
|
-
const remoteSchemaYaml =
|
|
16349
|
+
const localSchemaYaml = stringifyForDiff(sortUnorderedArrays(omit(local.data.schema, SCHEMA_IGNORED), SCHEMA_UNORDERED));
|
|
16350
|
+
const remoteSchemaYaml = stringifyForDiff(sortUnorderedArrays(omit(remote.data.schema, SCHEMA_IGNORED), SCHEMA_UNORDERED));
|
|
16154
16351
|
if (localSchemaYaml !== remoteSchemaYaml) {
|
|
16155
16352
|
result["schema"] = buildUnifiedDiff(remoteSchemaYaml, localSchemaYaml, "schema.yaml");
|
|
16156
16353
|
}
|
|
@@ -16259,11 +16456,17 @@ const functionModule = {
|
|
|
16259
16456
|
};
|
|
16260
16457
|
|
|
16261
16458
|
const IGNORED_FIELDS$1 = ["_id", "system"];
|
|
16459
|
+
const UNORDERED_PATHS = [
|
|
16460
|
+
"statement",
|
|
16461
|
+
"statement.*.resource.include",
|
|
16462
|
+
"statement.*.resource.exclude"
|
|
16463
|
+
];
|
|
16262
16464
|
const policyModule = {
|
|
16263
16465
|
name: "policy",
|
|
16264
16466
|
displayName: "Policy",
|
|
16265
16467
|
identityField: "name",
|
|
16266
16468
|
ignoredFields: IGNORED_FIELDS$1,
|
|
16469
|
+
unorderedPaths: UNORDERED_PATHS,
|
|
16267
16470
|
readLocal(rootDir, source) {
|
|
16268
16471
|
return readLocalSchemas(rootDir, "policy", source);
|
|
16269
16472
|
},
|
|
@@ -16296,10 +16499,10 @@ const policyModule = {
|
|
|
16296
16499
|
deleteLocalSchema(rootDir, "policy", slug);
|
|
16297
16500
|
},
|
|
16298
16501
|
diffFields(local, remote) {
|
|
16299
|
-
return diffSchemaFields(local, remote, IGNORED_FIELDS$1);
|
|
16502
|
+
return diffSchemaFields(local, remote, IGNORED_FIELDS$1, UNORDERED_PATHS);
|
|
16300
16503
|
},
|
|
16301
16504
|
renderDetail(local, remote) {
|
|
16302
|
-
return renderSchemaDetail(local.data, remote.data, IGNORED_FIELDS$1);
|
|
16505
|
+
return renderSchemaDetail(local.data, remote.data, IGNORED_FIELDS$1, UNORDERED_PATHS);
|
|
16303
16506
|
},
|
|
16304
16507
|
summaryLine(resource) {
|
|
16305
16508
|
const stmts = resource.data.statement?.length ?? 0;
|