@spica-devkit/sync 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
|
@@ -173,7 +173,7 @@ const REMOVE$1 = Symbol('remove node');
|
|
|
173
173
|
* and `Node` (alias, map, seq & scalar) targets. Of all these, only the most
|
|
174
174
|
* specific defined one will be used for each node.
|
|
175
175
|
*/
|
|
176
|
-
function visit$
|
|
176
|
+
function visit$2(node, visitor) {
|
|
177
177
|
const visitor_ = initVisitor(visitor);
|
|
178
178
|
if (isDocument(node)) {
|
|
179
179
|
const cd = visit_(null, node.contents, visitor_, Object.freeze([node]));
|
|
@@ -187,11 +187,11 @@ function visit$1(node, visitor) {
|
|
|
187
187
|
// namespace using `var`, but then complains about that because
|
|
188
188
|
// `unique symbol` must be `const`.
|
|
189
189
|
/** Terminate visit traversal completely */
|
|
190
|
-
visit$
|
|
190
|
+
visit$2.BREAK = BREAK$1;
|
|
191
191
|
/** Do not visit the children of the current node */
|
|
192
|
-
visit$
|
|
192
|
+
visit$2.SKIP = SKIP$1;
|
|
193
193
|
/** Remove the current node */
|
|
194
|
-
visit$
|
|
194
|
+
visit$2.REMOVE = REMOVE$1;
|
|
195
195
|
function visit_(key, node, visitor, path) {
|
|
196
196
|
const ctrl = callVisitor(key, node, visitor, path);
|
|
197
197
|
if (isNode(ctrl) || isPair(ctrl)) {
|
|
@@ -522,7 +522,7 @@ class Directives {
|
|
|
522
522
|
let tagNames;
|
|
523
523
|
if (doc && tagEntries.length > 0 && isNode(doc.contents)) {
|
|
524
524
|
const tags = {};
|
|
525
|
-
visit$
|
|
525
|
+
visit$2(doc.contents, (_key, node) => {
|
|
526
526
|
if (isNode(node) && node.tag)
|
|
527
527
|
tags[node.tag] = true;
|
|
528
528
|
});
|
|
@@ -557,7 +557,7 @@ function anchorIsValid(anchor) {
|
|
|
557
557
|
}
|
|
558
558
|
function anchorNames(root) {
|
|
559
559
|
const anchors = new Set();
|
|
560
|
-
visit$
|
|
560
|
+
visit$2(root, {
|
|
561
561
|
Value(_key, node) {
|
|
562
562
|
if (node.anchor)
|
|
563
563
|
anchors.add(node.anchor);
|
|
@@ -751,7 +751,7 @@ class Alias extends NodeBase {
|
|
|
751
751
|
}
|
|
752
752
|
else {
|
|
753
753
|
nodes = [];
|
|
754
|
-
visit$
|
|
754
|
+
visit$2(doc, {
|
|
755
755
|
Node: (_key, node) => {
|
|
756
756
|
if (isAlias(node) || hasAnchor(node))
|
|
757
757
|
nodes.push(node);
|
|
@@ -5548,7 +5548,7 @@ const REMOVE = Symbol('remove item');
|
|
|
5548
5548
|
* visitor is called on item entry, next visitors are called after handling
|
|
5549
5549
|
* a non-empty `key` and when exiting the item.
|
|
5550
5550
|
*/
|
|
5551
|
-
function visit(cst, visitor) {
|
|
5551
|
+
function visit$1(cst, visitor) {
|
|
5552
5552
|
if ('type' in cst && cst.type === 'document')
|
|
5553
5553
|
cst = { start: cst.start, value: cst.value };
|
|
5554
5554
|
_visit(Object.freeze([]), cst, visitor);
|
|
@@ -5557,13 +5557,13 @@ function visit(cst, visitor) {
|
|
|
5557
5557
|
// namespace using `var`, but then complains about that because
|
|
5558
5558
|
// `unique symbol` must be `const`.
|
|
5559
5559
|
/** Terminate visit traversal completely */
|
|
5560
|
-
visit.BREAK = BREAK;
|
|
5560
|
+
visit$1.BREAK = BREAK;
|
|
5561
5561
|
/** Do not visit the children of the current item */
|
|
5562
|
-
visit.SKIP = SKIP;
|
|
5562
|
+
visit$1.SKIP = SKIP;
|
|
5563
5563
|
/** Remove the current item */
|
|
5564
|
-
visit.REMOVE = REMOVE;
|
|
5564
|
+
visit$1.REMOVE = REMOVE;
|
|
5565
5565
|
/** Find the item at `path` from `cst` as the root */
|
|
5566
|
-
visit.itemAtPath = (cst, path) => {
|
|
5566
|
+
visit$1.itemAtPath = (cst, path) => {
|
|
5567
5567
|
let item = cst;
|
|
5568
5568
|
for (const [field, index] of path) {
|
|
5569
5569
|
const tok = item?.[field];
|
|
@@ -5580,8 +5580,8 @@ visit.itemAtPath = (cst, path) => {
|
|
|
5580
5580
|
*
|
|
5581
5581
|
* Throws an error if the collection is not found, which should never happen if the item itself exists.
|
|
5582
5582
|
*/
|
|
5583
|
-
visit.parentCollection = (cst, path) => {
|
|
5584
|
-
const parent = visit.itemAtPath(cst, path.slice(0, -1));
|
|
5583
|
+
visit$1.parentCollection = (cst, path) => {
|
|
5584
|
+
const parent = visit$1.itemAtPath(cst, path.slice(0, -1));
|
|
5585
5585
|
const field = path[path.length - 1][0];
|
|
5586
5586
|
const coll = parent?.[field];
|
|
5587
5587
|
if (coll && 'items' in coll)
|
|
@@ -5720,7 +5720,7 @@ var cst = /*#__PURE__*/Object.freeze({
|
|
|
5720
5720
|
setScalarValue: setScalarValue,
|
|
5721
5721
|
stringify: stringify$1,
|
|
5722
5722
|
tokenType: tokenType,
|
|
5723
|
-
visit: visit
|
|
5723
|
+
visit: visit$1
|
|
5724
5724
|
});
|
|
5725
5725
|
|
|
5726
5726
|
/*
|
|
@@ -7560,7 +7560,7 @@ var YAML = /*#__PURE__*/Object.freeze({
|
|
|
7560
7560
|
parseAllDocuments: parseAllDocuments,
|
|
7561
7561
|
parseDocument: parseDocument,
|
|
7562
7562
|
stringify: stringify,
|
|
7563
|
-
visit: visit$
|
|
7563
|
+
visit: visit$2,
|
|
7564
7564
|
visitAsync: visitAsync
|
|
7565
7565
|
});
|
|
7566
7566
|
|
|
@@ -12793,6 +12793,126 @@ function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader
|
|
|
12793
12793
|
return ret.join('\n') + '\n';
|
|
12794
12794
|
}
|
|
12795
12795
|
|
|
12796
|
+
var isPlainObject_1;
|
|
12797
|
+
var hasRequiredIsPlainObject;
|
|
12798
|
+
|
|
12799
|
+
function requireIsPlainObject () {
|
|
12800
|
+
if (hasRequiredIsPlainObject) return isPlainObject_1;
|
|
12801
|
+
hasRequiredIsPlainObject = 1;
|
|
12802
|
+
var baseGetTag = require_baseGetTag(),
|
|
12803
|
+
getPrototype = require_getPrototype(),
|
|
12804
|
+
isObjectLike = requireIsObjectLike();
|
|
12805
|
+
|
|
12806
|
+
/** `Object#toString` result references. */
|
|
12807
|
+
var objectTag = '[object Object]';
|
|
12808
|
+
|
|
12809
|
+
/** Used for built-in method references. */
|
|
12810
|
+
var funcProto = Function.prototype,
|
|
12811
|
+
objectProto = Object.prototype;
|
|
12812
|
+
|
|
12813
|
+
/** Used to resolve the decompiled source of functions. */
|
|
12814
|
+
var funcToString = funcProto.toString;
|
|
12815
|
+
|
|
12816
|
+
/** Used to check objects for own properties. */
|
|
12817
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
12818
|
+
|
|
12819
|
+
/** Used to infer the `Object` constructor. */
|
|
12820
|
+
var objectCtorString = funcToString.call(Object);
|
|
12821
|
+
|
|
12822
|
+
/**
|
|
12823
|
+
* Checks if `value` is a plain object, that is, an object created by the
|
|
12824
|
+
* `Object` constructor or one with a `[[Prototype]]` of `null`.
|
|
12825
|
+
*
|
|
12826
|
+
* @static
|
|
12827
|
+
* @memberOf _
|
|
12828
|
+
* @since 0.8.0
|
|
12829
|
+
* @category Lang
|
|
12830
|
+
* @param {*} value The value to check.
|
|
12831
|
+
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
|
|
12832
|
+
* @example
|
|
12833
|
+
*
|
|
12834
|
+
* function Foo() {
|
|
12835
|
+
* this.a = 1;
|
|
12836
|
+
* }
|
|
12837
|
+
*
|
|
12838
|
+
* _.isPlainObject(new Foo);
|
|
12839
|
+
* // => false
|
|
12840
|
+
*
|
|
12841
|
+
* _.isPlainObject([1, 2, 3]);
|
|
12842
|
+
* // => false
|
|
12843
|
+
*
|
|
12844
|
+
* _.isPlainObject({ 'x': 0, 'y': 0 });
|
|
12845
|
+
* // => true
|
|
12846
|
+
*
|
|
12847
|
+
* _.isPlainObject(Object.create(null));
|
|
12848
|
+
* // => true
|
|
12849
|
+
*/
|
|
12850
|
+
function isPlainObject(value) {
|
|
12851
|
+
if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
|
|
12852
|
+
return false;
|
|
12853
|
+
}
|
|
12854
|
+
var proto = getPrototype(value);
|
|
12855
|
+
if (proto === null) {
|
|
12856
|
+
return true;
|
|
12857
|
+
}
|
|
12858
|
+
var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
|
|
12859
|
+
return typeof Ctor == 'function' && Ctor instanceof Ctor &&
|
|
12860
|
+
funcToString.call(Ctor) == objectCtorString;
|
|
12861
|
+
}
|
|
12862
|
+
|
|
12863
|
+
isPlainObject_1 = isPlainObject;
|
|
12864
|
+
return isPlainObject_1;
|
|
12865
|
+
}
|
|
12866
|
+
|
|
12867
|
+
var isPlainObjectExports = requireIsPlainObject();
|
|
12868
|
+
var isPlainObject = /*@__PURE__*/getDefaultExportFromCjs(isPlainObjectExports);
|
|
12869
|
+
|
|
12870
|
+
function sortUnorderedArrays(data, paths = []) {
|
|
12871
|
+
if (!paths.length)
|
|
12872
|
+
return data;
|
|
12873
|
+
return visit(data, [], paths.map(p => p.split(".")));
|
|
12874
|
+
}
|
|
12875
|
+
function visit(node, path, patterns) {
|
|
12876
|
+
let visited = node;
|
|
12877
|
+
if (Array.isArray(node)) {
|
|
12878
|
+
visited = node.map((item, i) => visit(item, [...path, String(i)], patterns));
|
|
12879
|
+
}
|
|
12880
|
+
else if (isPlainObject(node)) {
|
|
12881
|
+
visited = Object.fromEntries(Object.entries(node).map(([k, v]) => [
|
|
12882
|
+
k,
|
|
12883
|
+
visit(v, [...path, k], patterns)
|
|
12884
|
+
]));
|
|
12885
|
+
}
|
|
12886
|
+
if (Array.isArray(visited) && patterns.some(p => matches(p, path))) {
|
|
12887
|
+
return visited
|
|
12888
|
+
.map(item => ({ item, key: canonical(item) }))
|
|
12889
|
+
.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0))
|
|
12890
|
+
.map(({ item }) => item);
|
|
12891
|
+
}
|
|
12892
|
+
return visited;
|
|
12893
|
+
}
|
|
12894
|
+
function matches(pattern, path) {
|
|
12895
|
+
if (!pattern.length)
|
|
12896
|
+
return !path.length;
|
|
12897
|
+
const [head, ...rest] = pattern;
|
|
12898
|
+
if (head === "**") {
|
|
12899
|
+
return matches(rest, path) || (path.length > 0 && matches(pattern, path.slice(1)));
|
|
12900
|
+
}
|
|
12901
|
+
return path.length > 0 && (head === "*" || head === path[0]) && matches(rest, path.slice(1));
|
|
12902
|
+
}
|
|
12903
|
+
function canonical(value) {
|
|
12904
|
+
if (Array.isArray(value))
|
|
12905
|
+
return `[${value.map(canonical).join(",")}]`;
|
|
12906
|
+
if (isPlainObject(value)) {
|
|
12907
|
+
const obj = value;
|
|
12908
|
+
const entries = Object.keys(obj)
|
|
12909
|
+
.sort()
|
|
12910
|
+
.map(k => `${JSON.stringify(k)}:${canonical(obj[k])}`);
|
|
12911
|
+
return `{${entries.join(",")}}`;
|
|
12912
|
+
}
|
|
12913
|
+
return JSON.stringify(value) ?? "undefined";
|
|
12914
|
+
}
|
|
12915
|
+
|
|
12796
12916
|
async function buildPlan(modules, unlimitedHttp, rootDir, options = {}) {
|
|
12797
12917
|
const { detailed = false, detectRenames = true, reporter = silentReporter, concurrency = DEFAULT_CONCURRENCY, source } = options;
|
|
12798
12918
|
const http = limitConcurrency(unlimitedHttp, concurrency);
|
|
@@ -12906,7 +13026,9 @@ async function applyPlan(plan, unlimitedHttp, opts = {}) {
|
|
|
12906
13026
|
}
|
|
12907
13027
|
return { errors };
|
|
12908
13028
|
}
|
|
12909
|
-
function diffObjectFields(
|
|
13029
|
+
function diffObjectFields(rawLocal, rawRemote, ignoredFields, unorderedPaths = []) {
|
|
13030
|
+
const local = sortUnorderedArrays(rawLocal, unorderedPaths);
|
|
13031
|
+
const remote = sortUnorderedArrays(rawRemote, unorderedPaths);
|
|
12910
13032
|
const allKeys = new Set([...Object.keys(local), ...Object.keys(remote)]);
|
|
12911
13033
|
const changed = [];
|
|
12912
13034
|
for (const key of allKeys) {
|
|
@@ -12918,15 +13040,18 @@ function diffObjectFields(local, remote, ignoredFields) {
|
|
|
12918
13040
|
}
|
|
12919
13041
|
return changed;
|
|
12920
13042
|
}
|
|
12921
|
-
function diffSchemaFields(local, remote, ignoredFields) {
|
|
12922
|
-
return diffObjectFields(local, remote, ignoredFields);
|
|
13043
|
+
function diffSchemaFields(local, remote, ignoredFields, unorderedPaths = []) {
|
|
13044
|
+
return diffObjectFields(local, remote, ignoredFields, unorderedPaths);
|
|
13045
|
+
}
|
|
13046
|
+
function stringifyForDiff(data) {
|
|
13047
|
+
return YAML.stringify(data, { sortMapEntries: true });
|
|
12923
13048
|
}
|
|
12924
13049
|
function buildUnifiedDiff(oldContent, newContent, filename) {
|
|
12925
13050
|
return createTwoFilesPatch(`remote/${filename}`, `local/${filename}`, oldContent, newContent);
|
|
12926
13051
|
}
|
|
12927
|
-
function renderSchemaDetail(localData, remoteData, ignoredFields) {
|
|
12928
|
-
const localYaml =
|
|
12929
|
-
const remoteYaml =
|
|
13052
|
+
function renderSchemaDetail(localData, remoteData, ignoredFields, unorderedPaths = []) {
|
|
13053
|
+
const localYaml = stringifyForDiff(sortUnorderedArrays(omit(localData, ignoredFields), unorderedPaths));
|
|
13054
|
+
const remoteYaml = stringifyForDiff(sortUnorderedArrays(omit(remoteData, ignoredFields), unorderedPaths));
|
|
12930
13055
|
return { schema: buildUnifiedDiff(remoteYaml, localYaml, "schema.yaml") };
|
|
12931
13056
|
}
|
|
12932
13057
|
function runAllAtOnce(tasks, label, onError, reporter) {
|
|
@@ -12961,12 +13086,14 @@ function formatError(e) {
|
|
|
12961
13086
|
return String(e);
|
|
12962
13087
|
}
|
|
12963
13088
|
|
|
12964
|
-
const IGNORED_FIELDS$3 = ["_id"];
|
|
13089
|
+
const IGNORED_FIELDS$3 = ["_id", "order"];
|
|
13090
|
+
const UNORDERED_PATHS$1 = ["required", "properties.**.required", "indexes"];
|
|
12965
13091
|
const bucketModule = {
|
|
12966
13092
|
name: "bucket",
|
|
12967
13093
|
displayName: "Bucket",
|
|
12968
13094
|
identityField: "title",
|
|
12969
13095
|
ignoredFields: IGNORED_FIELDS$3,
|
|
13096
|
+
unorderedPaths: UNORDERED_PATHS$1,
|
|
12970
13097
|
readLocal(rootDir, source) {
|
|
12971
13098
|
return readLocalSchemas(rootDir, "bucket", source);
|
|
12972
13099
|
},
|
|
@@ -12995,10 +13122,10 @@ const bucketModule = {
|
|
|
12995
13122
|
deleteLocalSchema(rootDir, "bucket", slug);
|
|
12996
13123
|
},
|
|
12997
13124
|
diffFields(local, remote) {
|
|
12998
|
-
return diffSchemaFields(local, remote, IGNORED_FIELDS$3);
|
|
13125
|
+
return diffSchemaFields(local, remote, IGNORED_FIELDS$3, UNORDERED_PATHS$1);
|
|
12999
13126
|
},
|
|
13000
13127
|
renderDetail(local, remote) {
|
|
13001
|
-
return renderSchemaDetail(local.data, remote.data, IGNORED_FIELDS$3);
|
|
13128
|
+
return renderSchemaDetail(local.data, remote.data, IGNORED_FIELDS$3, UNORDERED_PATHS$1);
|
|
13002
13129
|
},
|
|
13003
13130
|
summaryLine(resource) {
|
|
13004
13131
|
const propCount = Object.keys(resource.data.properties ?? {}).length;
|
|
@@ -15777,7 +15904,8 @@ function requireSemver () {
|
|
|
15777
15904
|
var semverExports = requireSemver();
|
|
15778
15905
|
var semver = /*@__PURE__*/getDefaultExportFromCjs(semverExports);
|
|
15779
15906
|
|
|
15780
|
-
const SCHEMA_IGNORED = ["_id", "env_vars", "secrets"];
|
|
15907
|
+
const SCHEMA_IGNORED = ["_id", "env_vars", "secrets", "order"];
|
|
15908
|
+
const SCHEMA_UNORDERED = ["triggers.*.options.authenticate"];
|
|
15781
15909
|
function indexFilename(language) {
|
|
15782
15910
|
return language === "typescript" ? "index.ts" : "index.mjs";
|
|
15783
15911
|
}
|
|
@@ -15834,6 +15962,7 @@ const functionModule = {
|
|
|
15834
15962
|
displayName: "Function",
|
|
15835
15963
|
identityField: "name",
|
|
15836
15964
|
ignoredFields: SCHEMA_IGNORED,
|
|
15965
|
+
unorderedPaths: SCHEMA_UNORDERED,
|
|
15837
15966
|
readSchema(rootDir, slug, source = diskSource) {
|
|
15838
15967
|
return readSourceYaml(source, path.join(rootDir, "function", slug, "schema.yaml"));
|
|
15839
15968
|
},
|
|
@@ -15985,7 +16114,7 @@ const functionModule = {
|
|
|
15985
16114
|
},
|
|
15986
16115
|
diffFields(local, remote) {
|
|
15987
16116
|
const changed = [];
|
|
15988
|
-
const schemaChanged = diffObjectFields(local.schema, remote.schema, SCHEMA_IGNORED);
|
|
16117
|
+
const schemaChanged = diffObjectFields(local.schema, remote.schema, SCHEMA_IGNORED, SCHEMA_UNORDERED);
|
|
15989
16118
|
if (schemaChanged.length)
|
|
15990
16119
|
changed.push("schema");
|
|
15991
16120
|
if (local.index !== remote.index)
|
|
@@ -16004,8 +16133,8 @@ const functionModule = {
|
|
|
16004
16133
|
},
|
|
16005
16134
|
renderDetail(local, remote) {
|
|
16006
16135
|
const result = {};
|
|
16007
|
-
const localSchemaYaml =
|
|
16008
|
-
const remoteSchemaYaml =
|
|
16136
|
+
const localSchemaYaml = stringifyForDiff(sortUnorderedArrays(omit(local.data.schema, SCHEMA_IGNORED), SCHEMA_UNORDERED));
|
|
16137
|
+
const remoteSchemaYaml = stringifyForDiff(sortUnorderedArrays(omit(remote.data.schema, SCHEMA_IGNORED), SCHEMA_UNORDERED));
|
|
16009
16138
|
if (localSchemaYaml !== remoteSchemaYaml) {
|
|
16010
16139
|
result["schema"] = buildUnifiedDiff(remoteSchemaYaml, localSchemaYaml, "schema.yaml");
|
|
16011
16140
|
}
|
|
@@ -16114,11 +16243,17 @@ const functionModule = {
|
|
|
16114
16243
|
};
|
|
16115
16244
|
|
|
16116
16245
|
const IGNORED_FIELDS$1 = ["_id", "system"];
|
|
16246
|
+
const UNORDERED_PATHS = [
|
|
16247
|
+
"statement",
|
|
16248
|
+
"statement.*.resource.include",
|
|
16249
|
+
"statement.*.resource.exclude"
|
|
16250
|
+
];
|
|
16117
16251
|
const policyModule = {
|
|
16118
16252
|
name: "policy",
|
|
16119
16253
|
displayName: "Policy",
|
|
16120
16254
|
identityField: "name",
|
|
16121
16255
|
ignoredFields: IGNORED_FIELDS$1,
|
|
16256
|
+
unorderedPaths: UNORDERED_PATHS,
|
|
16122
16257
|
readLocal(rootDir, source) {
|
|
16123
16258
|
return readLocalSchemas(rootDir, "policy", source);
|
|
16124
16259
|
},
|
|
@@ -16151,10 +16286,10 @@ const policyModule = {
|
|
|
16151
16286
|
deleteLocalSchema(rootDir, "policy", slug);
|
|
16152
16287
|
},
|
|
16153
16288
|
diffFields(local, remote) {
|
|
16154
|
-
return diffSchemaFields(local, remote, IGNORED_FIELDS$1);
|
|
16289
|
+
return diffSchemaFields(local, remote, IGNORED_FIELDS$1, UNORDERED_PATHS);
|
|
16155
16290
|
},
|
|
16156
16291
|
renderDetail(local, remote) {
|
|
16157
|
-
return renderSchemaDetail(local.data, remote.data, IGNORED_FIELDS$1);
|
|
16292
|
+
return renderSchemaDetail(local.data, remote.data, IGNORED_FIELDS$1, UNORDERED_PATHS);
|
|
16158
16293
|
},
|
|
16159
16294
|
summaryLine(resource) {
|
|
16160
16295
|
const stmts = resource.data.statement?.length ?? 0;
|