@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 CHANGED
@@ -439,7 +439,7 @@ const REMOVE$1 = Symbol('remove node');
439
439
  * and `Node` (alias, map, seq & scalar) targets. Of all these, only the most
440
440
  * specific defined one will be used for each node.
441
441
  */
442
- function visit$1(node, visitor) {
442
+ function visit$2(node, visitor) {
443
443
  const visitor_ = initVisitor(visitor);
444
444
  if (isDocument(node)) {
445
445
  const cd = visit_(null, node.contents, visitor_, Object.freeze([node]));
@@ -453,11 +453,11 @@ function visit$1(node, visitor) {
453
453
  // namespace using `var`, but then complains about that because
454
454
  // `unique symbol` must be `const`.
455
455
  /** Terminate visit traversal completely */
456
- visit$1.BREAK = BREAK$1;
456
+ visit$2.BREAK = BREAK$1;
457
457
  /** Do not visit the children of the current node */
458
- visit$1.SKIP = SKIP$1;
458
+ visit$2.SKIP = SKIP$1;
459
459
  /** Remove the current node */
460
- visit$1.REMOVE = REMOVE$1;
460
+ visit$2.REMOVE = REMOVE$1;
461
461
  function visit_(key, node, visitor, path) {
462
462
  const ctrl = callVisitor(key, node, visitor, path);
463
463
  if (isNode(ctrl) || isPair(ctrl)) {
@@ -788,7 +788,7 @@ class Directives {
788
788
  let tagNames;
789
789
  if (doc && tagEntries.length > 0 && isNode(doc.contents)) {
790
790
  const tags = {};
791
- visit$1(doc.contents, (_key, node) => {
791
+ visit$2(doc.contents, (_key, node) => {
792
792
  if (isNode(node) && node.tag)
793
793
  tags[node.tag] = true;
794
794
  });
@@ -823,7 +823,7 @@ function anchorIsValid(anchor) {
823
823
  }
824
824
  function anchorNames(root) {
825
825
  const anchors = new Set();
826
- visit$1(root, {
826
+ visit$2(root, {
827
827
  Value(_key, node) {
828
828
  if (node.anchor)
829
829
  anchors.add(node.anchor);
@@ -1017,7 +1017,7 @@ class Alias extends NodeBase {
1017
1017
  }
1018
1018
  else {
1019
1019
  nodes = [];
1020
- visit$1(doc, {
1020
+ visit$2(doc, {
1021
1021
  Node: (_key, node) => {
1022
1022
  if (isAlias(node) || hasAnchor(node))
1023
1023
  nodes.push(node);
@@ -5814,7 +5814,7 @@ const REMOVE = Symbol('remove item');
5814
5814
  * visitor is called on item entry, next visitors are called after handling
5815
5815
  * a non-empty `key` and when exiting the item.
5816
5816
  */
5817
- function visit(cst, visitor) {
5817
+ function visit$1(cst, visitor) {
5818
5818
  if ('type' in cst && cst.type === 'document')
5819
5819
  cst = { start: cst.start, value: cst.value };
5820
5820
  _visit(Object.freeze([]), cst, visitor);
@@ -5823,13 +5823,13 @@ function visit(cst, visitor) {
5823
5823
  // namespace using `var`, but then complains about that because
5824
5824
  // `unique symbol` must be `const`.
5825
5825
  /** Terminate visit traversal completely */
5826
- visit.BREAK = BREAK;
5826
+ visit$1.BREAK = BREAK;
5827
5827
  /** Do not visit the children of the current item */
5828
- visit.SKIP = SKIP;
5828
+ visit$1.SKIP = SKIP;
5829
5829
  /** Remove the current item */
5830
- visit.REMOVE = REMOVE;
5830
+ visit$1.REMOVE = REMOVE;
5831
5831
  /** Find the item at `path` from `cst` as the root */
5832
- visit.itemAtPath = (cst, path) => {
5832
+ visit$1.itemAtPath = (cst, path) => {
5833
5833
  let item = cst;
5834
5834
  for (const [field, index] of path) {
5835
5835
  const tok = item?.[field];
@@ -5846,8 +5846,8 @@ visit.itemAtPath = (cst, path) => {
5846
5846
  *
5847
5847
  * Throws an error if the collection is not found, which should never happen if the item itself exists.
5848
5848
  */
5849
- visit.parentCollection = (cst, path) => {
5850
- 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));
5851
5851
  const field = path[path.length - 1][0];
5852
5852
  const coll = parent?.[field];
5853
5853
  if (coll && 'items' in coll)
@@ -5986,7 +5986,7 @@ var cst = /*#__PURE__*/Object.freeze({
5986
5986
  setScalarValue: setScalarValue,
5987
5987
  stringify: stringify$1,
5988
5988
  tokenType: tokenType,
5989
- visit: visit
5989
+ visit: visit$1
5990
5990
  });
5991
5991
 
5992
5992
  /*
@@ -7826,7 +7826,7 @@ var YAML = /*#__PURE__*/Object.freeze({
7826
7826
  parseAllDocuments: parseAllDocuments,
7827
7827
  parseDocument: parseDocument,
7828
7828
  stringify: stringify,
7829
- visit: visit$1,
7829
+ visit: visit$2,
7830
7830
  visitAsync: visitAsync
7831
7831
  });
7832
7832
 
@@ -13027,6 +13027,126 @@ function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader
13027
13027
  return ret.join('\n') + '\n';
13028
13028
  }
13029
13029
 
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
+
13030
13150
  async function buildPlan(modules, unlimitedHttp, rootDir, options = {}) {
13031
13151
  const { detailed = false, detectRenames = true, reporter = silentReporter, concurrency = DEFAULT_CONCURRENCY, source } = options;
13032
13152
  const http = limitConcurrency(unlimitedHttp, concurrency);
@@ -13140,7 +13260,9 @@ async function applyPlan(plan, unlimitedHttp, opts = {}) {
13140
13260
  }
13141
13261
  return { errors };
13142
13262
  }
13143
- function diffObjectFields(local, remote, ignoredFields) {
13263
+ function diffObjectFields(rawLocal, rawRemote, ignoredFields, unorderedPaths = []) {
13264
+ const local = sortUnorderedArrays(rawLocal, unorderedPaths);
13265
+ const remote = sortUnorderedArrays(rawRemote, unorderedPaths);
13144
13266
  const allKeys = new Set([...Object.keys(local), ...Object.keys(remote)]);
13145
13267
  const changed = [];
13146
13268
  for (const key of allKeys) {
@@ -13152,15 +13274,18 @@ function diffObjectFields(local, remote, ignoredFields) {
13152
13274
  }
13153
13275
  return changed;
13154
13276
  }
13155
- function diffSchemaFields(local, remote, ignoredFields) {
13156
- 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 });
13157
13282
  }
13158
13283
  function buildUnifiedDiff(oldContent, newContent, filename) {
13159
13284
  return createTwoFilesPatch(`remote/${filename}`, `local/${filename}`, oldContent, newContent);
13160
13285
  }
13161
- function renderSchemaDetail(localData, remoteData, ignoredFields) {
13162
- const localYaml = YAML.stringify(omit(localData, ignoredFields));
13163
- const remoteYaml = YAML.stringify(omit(remoteData, ignoredFields));
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));
13164
13289
  return { schema: buildUnifiedDiff(remoteYaml, localYaml, "schema.yaml") };
13165
13290
  }
13166
13291
  function runAllAtOnce(tasks, label, onError, reporter) {
@@ -13195,12 +13320,14 @@ function formatError(e) {
13195
13320
  return String(e);
13196
13321
  }
13197
13322
 
13198
- const IGNORED_FIELDS$3 = ["_id"];
13323
+ const IGNORED_FIELDS$3 = ["_id", "order"];
13324
+ const UNORDERED_PATHS$1 = ["required", "properties.**.required", "indexes"];
13199
13325
  const bucketModule = {
13200
13326
  name: "bucket",
13201
13327
  displayName: "Bucket",
13202
13328
  identityField: "title",
13203
13329
  ignoredFields: IGNORED_FIELDS$3,
13330
+ unorderedPaths: UNORDERED_PATHS$1,
13204
13331
  readLocal(rootDir, source) {
13205
13332
  return readLocalSchemas(rootDir, "bucket", source);
13206
13333
  },
@@ -13229,10 +13356,10 @@ const bucketModule = {
13229
13356
  deleteLocalSchema(rootDir, "bucket", slug);
13230
13357
  },
13231
13358
  diffFields(local, remote) {
13232
- return diffSchemaFields(local, remote, IGNORED_FIELDS$3);
13359
+ return diffSchemaFields(local, remote, IGNORED_FIELDS$3, UNORDERED_PATHS$1);
13233
13360
  },
13234
13361
  renderDetail(local, remote) {
13235
- return renderSchemaDetail(local.data, remote.data, IGNORED_FIELDS$3);
13362
+ return renderSchemaDetail(local.data, remote.data, IGNORED_FIELDS$3, UNORDERED_PATHS$1);
13236
13363
  },
13237
13364
  summaryLine(resource) {
13238
13365
  const propCount = Object.keys(resource.data.properties ?? {}).length;
@@ -16011,7 +16138,8 @@ function requireSemver () {
16011
16138
  var semverExports = requireSemver();
16012
16139
  var semver = /*@__PURE__*/getDefaultExportFromCjs(semverExports);
16013
16140
 
16014
- const SCHEMA_IGNORED = ["_id", "env_vars", "secrets"];
16141
+ const SCHEMA_IGNORED = ["_id", "env_vars", "secrets", "order"];
16142
+ const SCHEMA_UNORDERED = ["triggers.*.options.authenticate"];
16015
16143
  function indexFilename(language) {
16016
16144
  return language === "typescript" ? "index.ts" : "index.mjs";
16017
16145
  }
@@ -16068,6 +16196,7 @@ const functionModule = {
16068
16196
  displayName: "Function",
16069
16197
  identityField: "name",
16070
16198
  ignoredFields: SCHEMA_IGNORED,
16199
+ unorderedPaths: SCHEMA_UNORDERED,
16071
16200
  readSchema(rootDir, slug, source = diskSource) {
16072
16201
  return readSourceYaml(source, path.join(rootDir, "function", slug, "schema.yaml"));
16073
16202
  },
@@ -16219,7 +16348,7 @@ const functionModule = {
16219
16348
  },
16220
16349
  diffFields(local, remote) {
16221
16350
  const changed = [];
16222
- const schemaChanged = diffObjectFields(local.schema, remote.schema, SCHEMA_IGNORED);
16351
+ const schemaChanged = diffObjectFields(local.schema, remote.schema, SCHEMA_IGNORED, SCHEMA_UNORDERED);
16223
16352
  if (schemaChanged.length)
16224
16353
  changed.push("schema");
16225
16354
  if (local.index !== remote.index)
@@ -16238,8 +16367,8 @@ const functionModule = {
16238
16367
  },
16239
16368
  renderDetail(local, remote) {
16240
16369
  const result = {};
16241
- const localSchemaYaml = YAML.stringify(omit(local.data.schema, SCHEMA_IGNORED));
16242
- const remoteSchemaYaml = YAML.stringify(omit(remote.data.schema, SCHEMA_IGNORED));
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));
16243
16372
  if (localSchemaYaml !== remoteSchemaYaml) {
16244
16373
  result["schema"] = buildUnifiedDiff(remoteSchemaYaml, localSchemaYaml, "schema.yaml");
16245
16374
  }
@@ -16348,11 +16477,17 @@ const functionModule = {
16348
16477
  };
16349
16478
 
16350
16479
  const IGNORED_FIELDS$1 = ["_id", "system"];
16480
+ const UNORDERED_PATHS = [
16481
+ "statement",
16482
+ "statement.*.resource.include",
16483
+ "statement.*.resource.exclude"
16484
+ ];
16351
16485
  const policyModule = {
16352
16486
  name: "policy",
16353
16487
  displayName: "Policy",
16354
16488
  identityField: "name",
16355
16489
  ignoredFields: IGNORED_FIELDS$1,
16490
+ unorderedPaths: UNORDERED_PATHS,
16356
16491
  readLocal(rootDir, source) {
16357
16492
  return readLocalSchemas(rootDir, "policy", source);
16358
16493
  },
@@ -16385,10 +16520,10 @@ const policyModule = {
16385
16520
  deleteLocalSchema(rootDir, "policy", slug);
16386
16521
  },
16387
16522
  diffFields(local, remote) {
16388
- return diffSchemaFields(local, remote, IGNORED_FIELDS$1);
16523
+ return diffSchemaFields(local, remote, IGNORED_FIELDS$1, UNORDERED_PATHS);
16389
16524
  },
16390
16525
  renderDetail(local, remote) {
16391
- return renderSchemaDetail(local.data, remote.data, IGNORED_FIELDS$1);
16526
+ return renderSchemaDetail(local.data, remote.data, IGNORED_FIELDS$1, UNORDERED_PATHS);
16392
16527
  },
16393
16528
  summaryLine(resource) {
16394
16529
  const stmts = resource.data.statement?.length ?? 0;