@terraforge/core 0.0.9 → 0.0.10
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/dist/index.js +83 -83
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -479,6 +479,89 @@ var dependentsOn = (resources, dependency) => {
|
|
|
479
479
|
}
|
|
480
480
|
return dependents;
|
|
481
481
|
};
|
|
482
|
+
var findDependencyPaths = (value, dependencyUrn, path = []) => {
|
|
483
|
+
const paths = [];
|
|
484
|
+
const visit = (current, currentPath) => {
|
|
485
|
+
if (current instanceof Output) {
|
|
486
|
+
for (const dep of current.dependencies) {
|
|
487
|
+
if (dep.urn === dependencyUrn) {
|
|
488
|
+
paths.push(currentPath);
|
|
489
|
+
return;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
if (Array.isArray(current)) {
|
|
495
|
+
current.forEach((item, index) => {
|
|
496
|
+
visit(item, [...currentPath, index]);
|
|
497
|
+
});
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
if (current && typeof current === "object") {
|
|
501
|
+
for (const [key, item] of Object.entries(current)) {
|
|
502
|
+
visit(item, [...currentPath, key]);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
visit(value, path);
|
|
507
|
+
return paths;
|
|
508
|
+
};
|
|
509
|
+
var cloneState = (value) => JSON.parse(JSON.stringify(value));
|
|
510
|
+
var removeAtPath = (target, path) => {
|
|
511
|
+
if (path.length === 0) return;
|
|
512
|
+
let parent = target;
|
|
513
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
514
|
+
if (parent == null) return;
|
|
515
|
+
parent = parent[path[i]];
|
|
516
|
+
}
|
|
517
|
+
const last = path[path.length - 1];
|
|
518
|
+
if (Array.isArray(parent) && typeof last === "number") {
|
|
519
|
+
if (last >= 0 && last < parent.length) {
|
|
520
|
+
parent.splice(last, 1);
|
|
521
|
+
}
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
if (parent && typeof parent === "object") {
|
|
525
|
+
delete parent[last];
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
var stripDependencyInputs = (input, metaInput, dependencyUrn) => {
|
|
529
|
+
const paths = findDependencyPaths(metaInput, dependencyUrn);
|
|
530
|
+
if (paths.length === 0) {
|
|
531
|
+
return input;
|
|
532
|
+
}
|
|
533
|
+
const detached = cloneState(input);
|
|
534
|
+
const sortedPaths = [...paths].sort((a, b) => {
|
|
535
|
+
if (a.length !== b.length) return b.length - a.length;
|
|
536
|
+
const aLast = a[a.length - 1];
|
|
537
|
+
const bLast = b[b.length - 1];
|
|
538
|
+
if (typeof aLast === "number" && typeof bLast === "number") {
|
|
539
|
+
return bLast - aLast;
|
|
540
|
+
}
|
|
541
|
+
return 0;
|
|
542
|
+
});
|
|
543
|
+
for (const path of sortedPaths) {
|
|
544
|
+
removeAtPath(detached, path);
|
|
545
|
+
}
|
|
546
|
+
return detached;
|
|
547
|
+
};
|
|
548
|
+
var allowsDependentReplace = (replaceOnChanges, dependencyPaths) => {
|
|
549
|
+
if (!replaceOnChanges || replaceOnChanges.length === 0) {
|
|
550
|
+
return false;
|
|
551
|
+
}
|
|
552
|
+
for (const path of dependencyPaths) {
|
|
553
|
+
const base = typeof path[0] === "string" ? path[0] : void 0;
|
|
554
|
+
if (!base) {
|
|
555
|
+
continue;
|
|
556
|
+
}
|
|
557
|
+
for (const replacePath of replaceOnChanges) {
|
|
558
|
+
if (replacePath === base || replacePath.startsWith(`${base}.`) || replacePath.startsWith(`${base}[`) || replacePath.startsWith(`${base}.*`)) {
|
|
559
|
+
return true;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
return false;
|
|
564
|
+
};
|
|
482
565
|
|
|
483
566
|
// src/workspace/error.ts
|
|
484
567
|
var ResourceError = class _ResourceError extends Error {
|
|
@@ -912,89 +995,6 @@ var updateResource = async (resource, appToken, priorInputState, priorOutputStat
|
|
|
912
995
|
|
|
913
996
|
// src/workspace/procedure/deploy-app.ts
|
|
914
997
|
var debug7 = createDebugger("Deploy App");
|
|
915
|
-
var findDependencyPaths = (value, dependencyUrn, path = []) => {
|
|
916
|
-
const paths = [];
|
|
917
|
-
const visit = (current, currentPath) => {
|
|
918
|
-
if (current instanceof Output) {
|
|
919
|
-
for (const dep of current.dependencies) {
|
|
920
|
-
if (dep.urn === dependencyUrn) {
|
|
921
|
-
paths.push(currentPath);
|
|
922
|
-
return;
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
return;
|
|
926
|
-
}
|
|
927
|
-
if (Array.isArray(current)) {
|
|
928
|
-
current.forEach((item, index) => {
|
|
929
|
-
visit(item, [...currentPath, index]);
|
|
930
|
-
});
|
|
931
|
-
return;
|
|
932
|
-
}
|
|
933
|
-
if (current && typeof current === "object") {
|
|
934
|
-
for (const [key, item] of Object.entries(current)) {
|
|
935
|
-
visit(item, [...currentPath, key]);
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
};
|
|
939
|
-
visit(value, path);
|
|
940
|
-
return paths;
|
|
941
|
-
};
|
|
942
|
-
var cloneState = (value) => JSON.parse(JSON.stringify(value));
|
|
943
|
-
var removeAtPath = (target, path) => {
|
|
944
|
-
if (path.length === 0) return;
|
|
945
|
-
let parent = target;
|
|
946
|
-
for (let i = 0; i < path.length - 1; i++) {
|
|
947
|
-
if (parent == null) return;
|
|
948
|
-
parent = parent[path[i]];
|
|
949
|
-
}
|
|
950
|
-
const last = path[path.length - 1];
|
|
951
|
-
if (Array.isArray(parent) && typeof last === "number") {
|
|
952
|
-
if (last >= 0 && last < parent.length) {
|
|
953
|
-
parent.splice(last, 1);
|
|
954
|
-
}
|
|
955
|
-
return;
|
|
956
|
-
}
|
|
957
|
-
if (parent && typeof parent === "object") {
|
|
958
|
-
delete parent[last];
|
|
959
|
-
}
|
|
960
|
-
};
|
|
961
|
-
var stripDependencyInputs = (input, metaInput, dependencyUrn) => {
|
|
962
|
-
const paths = findDependencyPaths(metaInput, dependencyUrn);
|
|
963
|
-
if (paths.length === 0) {
|
|
964
|
-
return input;
|
|
965
|
-
}
|
|
966
|
-
const detached = cloneState(input);
|
|
967
|
-
const sortedPaths = [...paths].sort((a, b) => {
|
|
968
|
-
if (a.length !== b.length) return b.length - a.length;
|
|
969
|
-
const aLast = a[a.length - 1];
|
|
970
|
-
const bLast = b[b.length - 1];
|
|
971
|
-
if (typeof aLast === "number" && typeof bLast === "number") {
|
|
972
|
-
return bLast - aLast;
|
|
973
|
-
}
|
|
974
|
-
return 0;
|
|
975
|
-
});
|
|
976
|
-
for (const path of sortedPaths) {
|
|
977
|
-
removeAtPath(detached, path);
|
|
978
|
-
}
|
|
979
|
-
return detached;
|
|
980
|
-
};
|
|
981
|
-
var allowsDependentReplace = (replaceOnChanges, dependencyPaths) => {
|
|
982
|
-
if (!replaceOnChanges || replaceOnChanges.length === 0) {
|
|
983
|
-
return false;
|
|
984
|
-
}
|
|
985
|
-
for (const path of dependencyPaths) {
|
|
986
|
-
const base = typeof path[0] === "string" ? path[0] : void 0;
|
|
987
|
-
if (!base) {
|
|
988
|
-
continue;
|
|
989
|
-
}
|
|
990
|
-
for (const replacePath of replaceOnChanges) {
|
|
991
|
-
if (replacePath === base || replacePath.startsWith(`${base}.`) || replacePath.startsWith(`${base}[`) || replacePath.startsWith(`${base}.*`)) {
|
|
992
|
-
return true;
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
return false;
|
|
997
|
-
};
|
|
998
998
|
var deployApp = async (app, opt) => {
|
|
999
999
|
debug7(app.name, "start");
|
|
1000
1000
|
const latestState = await opt.backend.state.get(app.urn);
|