@spica-devkit/testing 0.20.8 → 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 +166 -31
- package/index.js.map +1 -1
- package/index.mjs +166 -31
- package/index.mjs.map +1 -1
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -418,7 +418,7 @@ const REMOVE$1 = Symbol('remove node');
|
|
|
418
418
|
* and `Node` (alias, map, seq & scalar) targets. Of all these, only the most
|
|
419
419
|
* specific defined one will be used for each node.
|
|
420
420
|
*/
|
|
421
|
-
function visit$
|
|
421
|
+
function visit$2(node, visitor) {
|
|
422
422
|
const visitor_ = initVisitor(visitor);
|
|
423
423
|
if (isDocument(node)) {
|
|
424
424
|
const cd = visit_(null, node.contents, visitor_, Object.freeze([node]));
|
|
@@ -432,11 +432,11 @@ function visit$1(node, visitor) {
|
|
|
432
432
|
// namespace using `var`, but then complains about that because
|
|
433
433
|
// `unique symbol` must be `const`.
|
|
434
434
|
/** Terminate visit traversal completely */
|
|
435
|
-
visit$
|
|
435
|
+
visit$2.BREAK = BREAK$1;
|
|
436
436
|
/** Do not visit the children of the current node */
|
|
437
|
-
visit$
|
|
437
|
+
visit$2.SKIP = SKIP$1;
|
|
438
438
|
/** Remove the current node */
|
|
439
|
-
visit$
|
|
439
|
+
visit$2.REMOVE = REMOVE$1;
|
|
440
440
|
function visit_(key, node, visitor, path) {
|
|
441
441
|
const ctrl = callVisitor(key, node, visitor, path);
|
|
442
442
|
if (isNode(ctrl) || isPair(ctrl)) {
|
|
@@ -767,7 +767,7 @@ class Directives {
|
|
|
767
767
|
let tagNames;
|
|
768
768
|
if (doc && tagEntries.length > 0 && isNode(doc.contents)) {
|
|
769
769
|
const tags = {};
|
|
770
|
-
visit$
|
|
770
|
+
visit$2(doc.contents, (_key, node) => {
|
|
771
771
|
if (isNode(node) && node.tag)
|
|
772
772
|
tags[node.tag] = true;
|
|
773
773
|
});
|
|
@@ -802,7 +802,7 @@ function anchorIsValid(anchor) {
|
|
|
802
802
|
}
|
|
803
803
|
function anchorNames(root) {
|
|
804
804
|
const anchors = new Set();
|
|
805
|
-
visit$
|
|
805
|
+
visit$2(root, {
|
|
806
806
|
Value(_key, node) {
|
|
807
807
|
if (node.anchor)
|
|
808
808
|
anchors.add(node.anchor);
|
|
@@ -996,7 +996,7 @@ class Alias extends NodeBase {
|
|
|
996
996
|
}
|
|
997
997
|
else {
|
|
998
998
|
nodes = [];
|
|
999
|
-
visit$
|
|
999
|
+
visit$2(doc, {
|
|
1000
1000
|
Node: (_key, node) => {
|
|
1001
1001
|
if (isAlias(node) || hasAnchor(node))
|
|
1002
1002
|
nodes.push(node);
|
|
@@ -5793,7 +5793,7 @@ const REMOVE = Symbol('remove item');
|
|
|
5793
5793
|
* visitor is called on item entry, next visitors are called after handling
|
|
5794
5794
|
* a non-empty `key` and when exiting the item.
|
|
5795
5795
|
*/
|
|
5796
|
-
function visit(cst, visitor) {
|
|
5796
|
+
function visit$1(cst, visitor) {
|
|
5797
5797
|
if ('type' in cst && cst.type === 'document')
|
|
5798
5798
|
cst = { start: cst.start, value: cst.value };
|
|
5799
5799
|
_visit(Object.freeze([]), cst, visitor);
|
|
@@ -5802,13 +5802,13 @@ function visit(cst, visitor) {
|
|
|
5802
5802
|
// namespace using `var`, but then complains about that because
|
|
5803
5803
|
// `unique symbol` must be `const`.
|
|
5804
5804
|
/** Terminate visit traversal completely */
|
|
5805
|
-
visit.BREAK = BREAK;
|
|
5805
|
+
visit$1.BREAK = BREAK;
|
|
5806
5806
|
/** Do not visit the children of the current item */
|
|
5807
|
-
visit.SKIP = SKIP;
|
|
5807
|
+
visit$1.SKIP = SKIP;
|
|
5808
5808
|
/** Remove the current item */
|
|
5809
|
-
visit.REMOVE = REMOVE;
|
|
5809
|
+
visit$1.REMOVE = REMOVE;
|
|
5810
5810
|
/** Find the item at `path` from `cst` as the root */
|
|
5811
|
-
visit.itemAtPath = (cst, path) => {
|
|
5811
|
+
visit$1.itemAtPath = (cst, path) => {
|
|
5812
5812
|
let item = cst;
|
|
5813
5813
|
for (const [field, index] of path) {
|
|
5814
5814
|
const tok = item?.[field];
|
|
@@ -5825,8 +5825,8 @@ visit.itemAtPath = (cst, path) => {
|
|
|
5825
5825
|
*
|
|
5826
5826
|
* Throws an error if the collection is not found, which should never happen if the item itself exists.
|
|
5827
5827
|
*/
|
|
5828
|
-
visit.parentCollection = (cst, path) => {
|
|
5829
|
-
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));
|
|
5830
5830
|
const field = path[path.length - 1][0];
|
|
5831
5831
|
const coll = parent?.[field];
|
|
5832
5832
|
if (coll && 'items' in coll)
|
|
@@ -5965,7 +5965,7 @@ var cst = /*#__PURE__*/Object.freeze({
|
|
|
5965
5965
|
setScalarValue: setScalarValue,
|
|
5966
5966
|
stringify: stringify$1,
|
|
5967
5967
|
tokenType: tokenType,
|
|
5968
|
-
visit: visit
|
|
5968
|
+
visit: visit$1
|
|
5969
5969
|
});
|
|
5970
5970
|
|
|
5971
5971
|
/*
|
|
@@ -7805,7 +7805,7 @@ var YAML = /*#__PURE__*/Object.freeze({
|
|
|
7805
7805
|
parseAllDocuments: parseAllDocuments,
|
|
7806
7806
|
parseDocument: parseDocument,
|
|
7807
7807
|
stringify: stringify,
|
|
7808
|
-
visit: visit$
|
|
7808
|
+
visit: visit$2,
|
|
7809
7809
|
visitAsync: visitAsync
|
|
7810
7810
|
});
|
|
7811
7811
|
|
|
@@ -13006,6 +13006,126 @@ function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader
|
|
|
13006
13006
|
return ret.join('\n') + '\n';
|
|
13007
13007
|
}
|
|
13008
13008
|
|
|
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
|
+
|
|
13009
13129
|
async function buildPlan(modules, unlimitedHttp, rootDir, options = {}) {
|
|
13010
13130
|
const { detailed = false, detectRenames = true, reporter = silentReporter, concurrency = DEFAULT_CONCURRENCY, source } = options;
|
|
13011
13131
|
const http = limitConcurrency(unlimitedHttp, concurrency);
|
|
@@ -13119,7 +13239,9 @@ async function applyPlan(plan, unlimitedHttp, opts = {}) {
|
|
|
13119
13239
|
}
|
|
13120
13240
|
return { errors };
|
|
13121
13241
|
}
|
|
13122
|
-
function diffObjectFields(
|
|
13242
|
+
function diffObjectFields(rawLocal, rawRemote, ignoredFields, unorderedPaths = []) {
|
|
13243
|
+
const local = sortUnorderedArrays(rawLocal, unorderedPaths);
|
|
13244
|
+
const remote = sortUnorderedArrays(rawRemote, unorderedPaths);
|
|
13123
13245
|
const allKeys = new Set([...Object.keys(local), ...Object.keys(remote)]);
|
|
13124
13246
|
const changed = [];
|
|
13125
13247
|
for (const key of allKeys) {
|
|
@@ -13131,15 +13253,18 @@ function diffObjectFields(local, remote, ignoredFields) {
|
|
|
13131
13253
|
}
|
|
13132
13254
|
return changed;
|
|
13133
13255
|
}
|
|
13134
|
-
function diffSchemaFields(local, remote, ignoredFields) {
|
|
13135
|
-
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 });
|
|
13136
13261
|
}
|
|
13137
13262
|
function buildUnifiedDiff(oldContent, newContent, filename) {
|
|
13138
13263
|
return createTwoFilesPatch(`remote/${filename}`, `local/${filename}`, oldContent, newContent);
|
|
13139
13264
|
}
|
|
13140
|
-
function renderSchemaDetail(localData, remoteData, ignoredFields) {
|
|
13141
|
-
const localYaml =
|
|
13142
|
-
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));
|
|
13143
13268
|
return { schema: buildUnifiedDiff(remoteYaml, localYaml, "schema.yaml") };
|
|
13144
13269
|
}
|
|
13145
13270
|
function runAllAtOnce(tasks, label, onError, reporter) {
|
|
@@ -13174,12 +13299,14 @@ function formatError(e) {
|
|
|
13174
13299
|
return String(e);
|
|
13175
13300
|
}
|
|
13176
13301
|
|
|
13177
|
-
const IGNORED_FIELDS$3 = ["_id"];
|
|
13302
|
+
const IGNORED_FIELDS$3 = ["_id", "order"];
|
|
13303
|
+
const UNORDERED_PATHS$1 = ["required", "properties.**.required", "indexes"];
|
|
13178
13304
|
const bucketModule = {
|
|
13179
13305
|
name: "bucket",
|
|
13180
13306
|
displayName: "Bucket",
|
|
13181
13307
|
identityField: "title",
|
|
13182
13308
|
ignoredFields: IGNORED_FIELDS$3,
|
|
13309
|
+
unorderedPaths: UNORDERED_PATHS$1,
|
|
13183
13310
|
readLocal(rootDir, source) {
|
|
13184
13311
|
return readLocalSchemas(rootDir, "bucket", source);
|
|
13185
13312
|
},
|
|
@@ -13208,10 +13335,10 @@ const bucketModule = {
|
|
|
13208
13335
|
deleteLocalSchema(rootDir, "bucket", slug);
|
|
13209
13336
|
},
|
|
13210
13337
|
diffFields(local, remote) {
|
|
13211
|
-
return diffSchemaFields(local, remote, IGNORED_FIELDS$3);
|
|
13338
|
+
return diffSchemaFields(local, remote, IGNORED_FIELDS$3, UNORDERED_PATHS$1);
|
|
13212
13339
|
},
|
|
13213
13340
|
renderDetail(local, remote) {
|
|
13214
|
-
return renderSchemaDetail(local.data, remote.data, IGNORED_FIELDS$3);
|
|
13341
|
+
return renderSchemaDetail(local.data, remote.data, IGNORED_FIELDS$3, UNORDERED_PATHS$1);
|
|
13215
13342
|
},
|
|
13216
13343
|
summaryLine(resource) {
|
|
13217
13344
|
const propCount = Object.keys(resource.data.properties ?? {}).length;
|
|
@@ -15990,7 +16117,8 @@ function requireSemver () {
|
|
|
15990
16117
|
var semverExports = requireSemver();
|
|
15991
16118
|
var semver = /*@__PURE__*/getDefaultExportFromCjs(semverExports);
|
|
15992
16119
|
|
|
15993
|
-
const SCHEMA_IGNORED = ["_id", "env_vars", "secrets"];
|
|
16120
|
+
const SCHEMA_IGNORED = ["_id", "env_vars", "secrets", "order"];
|
|
16121
|
+
const SCHEMA_UNORDERED = ["triggers.*.options.authenticate"];
|
|
15994
16122
|
function indexFilename(language) {
|
|
15995
16123
|
return language === "typescript" ? "index.ts" : "index.mjs";
|
|
15996
16124
|
}
|
|
@@ -16047,6 +16175,7 @@ const functionModule = {
|
|
|
16047
16175
|
displayName: "Function",
|
|
16048
16176
|
identityField: "name",
|
|
16049
16177
|
ignoredFields: SCHEMA_IGNORED,
|
|
16178
|
+
unorderedPaths: SCHEMA_UNORDERED,
|
|
16050
16179
|
readSchema(rootDir, slug, source = diskSource) {
|
|
16051
16180
|
return readSourceYaml(source, path.join(rootDir, "function", slug, "schema.yaml"));
|
|
16052
16181
|
},
|
|
@@ -16198,7 +16327,7 @@ const functionModule = {
|
|
|
16198
16327
|
},
|
|
16199
16328
|
diffFields(local, remote) {
|
|
16200
16329
|
const changed = [];
|
|
16201
|
-
const schemaChanged = diffObjectFields(local.schema, remote.schema, SCHEMA_IGNORED);
|
|
16330
|
+
const schemaChanged = diffObjectFields(local.schema, remote.schema, SCHEMA_IGNORED, SCHEMA_UNORDERED);
|
|
16202
16331
|
if (schemaChanged.length)
|
|
16203
16332
|
changed.push("schema");
|
|
16204
16333
|
if (local.index !== remote.index)
|
|
@@ -16217,8 +16346,8 @@ const functionModule = {
|
|
|
16217
16346
|
},
|
|
16218
16347
|
renderDetail(local, remote) {
|
|
16219
16348
|
const result = {};
|
|
16220
|
-
const localSchemaYaml =
|
|
16221
|
-
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));
|
|
16222
16351
|
if (localSchemaYaml !== remoteSchemaYaml) {
|
|
16223
16352
|
result["schema"] = buildUnifiedDiff(remoteSchemaYaml, localSchemaYaml, "schema.yaml");
|
|
16224
16353
|
}
|
|
@@ -16327,11 +16456,17 @@ const functionModule = {
|
|
|
16327
16456
|
};
|
|
16328
16457
|
|
|
16329
16458
|
const IGNORED_FIELDS$1 = ["_id", "system"];
|
|
16459
|
+
const UNORDERED_PATHS = [
|
|
16460
|
+
"statement",
|
|
16461
|
+
"statement.*.resource.include",
|
|
16462
|
+
"statement.*.resource.exclude"
|
|
16463
|
+
];
|
|
16330
16464
|
const policyModule = {
|
|
16331
16465
|
name: "policy",
|
|
16332
16466
|
displayName: "Policy",
|
|
16333
16467
|
identityField: "name",
|
|
16334
16468
|
ignoredFields: IGNORED_FIELDS$1,
|
|
16469
|
+
unorderedPaths: UNORDERED_PATHS,
|
|
16335
16470
|
readLocal(rootDir, source) {
|
|
16336
16471
|
return readLocalSchemas(rootDir, "policy", source);
|
|
16337
16472
|
},
|
|
@@ -16364,10 +16499,10 @@ const policyModule = {
|
|
|
16364
16499
|
deleteLocalSchema(rootDir, "policy", slug);
|
|
16365
16500
|
},
|
|
16366
16501
|
diffFields(local, remote) {
|
|
16367
|
-
return diffSchemaFields(local, remote, IGNORED_FIELDS$1);
|
|
16502
|
+
return diffSchemaFields(local, remote, IGNORED_FIELDS$1, UNORDERED_PATHS);
|
|
16368
16503
|
},
|
|
16369
16504
|
renderDetail(local, remote) {
|
|
16370
|
-
return renderSchemaDetail(local.data, remote.data, IGNORED_FIELDS$1);
|
|
16505
|
+
return renderSchemaDetail(local.data, remote.data, IGNORED_FIELDS$1, UNORDERED_PATHS);
|
|
16371
16506
|
},
|
|
16372
16507
|
summaryLine(resource) {
|
|
16373
16508
|
const stmts = resource.data.statement?.length ?? 0;
|