@terraforge/core 0.0.32 → 0.0.35
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.mjs +24 -12
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -985,6 +985,10 @@ const deployApp = async (app, opt) => {
|
|
|
985
985
|
else {
|
|
986
986
|
const inputChanged = !compareState(nodeState.input, input);
|
|
987
987
|
const hasDrift = !!nodeState.drifted;
|
|
988
|
+
console.log("DEPLOY_NODE", meta$1.urn);
|
|
989
|
+
console.log("STATE_NODE", nodeState);
|
|
990
|
+
console.log("INPUT_CHANGED", inputChanged);
|
|
991
|
+
console.log("HAS_DRIFT", hasDrift);
|
|
988
992
|
if (!inputChanged && !hasDrift) Object.assign(nodeState, partialNewResourceState);
|
|
989
993
|
else {
|
|
990
994
|
let newResourceState;
|
|
@@ -1119,27 +1123,26 @@ const hydrate = async (app, opt) => {
|
|
|
1119
1123
|
|
|
1120
1124
|
//#endregion
|
|
1121
1125
|
//#region src/workspace/procedure/refresh.ts
|
|
1122
|
-
const
|
|
1123
|
-
return JSON.parse(JSON.stringify(value));
|
|
1124
|
-
};
|
|
1125
|
-
const createDeleteOperation = (urn, stackState) => {
|
|
1126
|
+
const createDeleteOperation = (urn, stackState, onCommit) => {
|
|
1126
1127
|
return {
|
|
1127
1128
|
urn,
|
|
1128
1129
|
operation: "delete",
|
|
1129
1130
|
commit() {
|
|
1130
1131
|
delete stackState.nodes[urn];
|
|
1132
|
+
onCommit();
|
|
1131
1133
|
}
|
|
1132
1134
|
};
|
|
1133
1135
|
};
|
|
1134
|
-
const createUpdateOperation = (urn, state, before, after, nodeState) => {
|
|
1136
|
+
const createUpdateOperation = (urn, state, before, after, nodeState, onCommit) => {
|
|
1135
1137
|
return {
|
|
1136
1138
|
urn,
|
|
1137
1139
|
operation: "update",
|
|
1138
|
-
before:
|
|
1139
|
-
after:
|
|
1140
|
+
before: structuredClone(before),
|
|
1141
|
+
after: structuredClone(after),
|
|
1140
1142
|
commit() {
|
|
1141
1143
|
nodeState.output = state;
|
|
1142
1144
|
nodeState.drifted = true;
|
|
1145
|
+
onCommit();
|
|
1143
1146
|
}
|
|
1144
1147
|
};
|
|
1145
1148
|
};
|
|
@@ -1150,6 +1153,7 @@ const refresh = async (app, opt) => {
|
|
|
1150
1153
|
if (opt.filters && opt.filters.length > 0) filteredStacks = Object.values(appState?.stacks ?? {}).filter((stackState) => {
|
|
1151
1154
|
return opt.filters.includes(stackState.name);
|
|
1152
1155
|
});
|
|
1156
|
+
let committed = 0;
|
|
1153
1157
|
if (appState && filteredStacks.length > 0) {
|
|
1154
1158
|
const filteredOperations = (await Promise.all(filteredStacks.map((stackState) => {
|
|
1155
1159
|
return Promise.all(Object.entries(stackState.nodes).map(([_urn, nodeState]) => {
|
|
@@ -1161,9 +1165,13 @@ const refresh = async (app, opt) => {
|
|
|
1161
1165
|
type: nodeState.type,
|
|
1162
1166
|
state: nodeState.output
|
|
1163
1167
|
});
|
|
1164
|
-
if (!result) return createDeleteOperation(urn, stackState)
|
|
1168
|
+
if (!result) return createDeleteOperation(urn, stackState, () => {
|
|
1169
|
+
committed++;
|
|
1170
|
+
});
|
|
1165
1171
|
if (compareState(result.state, nodeState.output)) return;
|
|
1166
|
-
return createUpdateOperation(urn, result.state, nodeState.input, result.state, nodeState)
|
|
1172
|
+
return createUpdateOperation(urn, result.state, nodeState.input, result.state, nodeState, () => {
|
|
1173
|
+
committed++;
|
|
1174
|
+
});
|
|
1167
1175
|
}
|
|
1168
1176
|
if (!provider.refreshResource) return;
|
|
1169
1177
|
const refreshed = await provider.refreshResource({
|
|
@@ -1172,8 +1180,12 @@ const refresh = async (app, opt) => {
|
|
|
1172
1180
|
priorOutputState: nodeState.output
|
|
1173
1181
|
});
|
|
1174
1182
|
if (!refreshed || refreshed.kind === "unchanged") return;
|
|
1175
|
-
if (refreshed.kind === "deleted") return createDeleteOperation(urn, stackState)
|
|
1176
|
-
|
|
1183
|
+
if (refreshed.kind === "deleted") return createDeleteOperation(urn, stackState, () => {
|
|
1184
|
+
committed++;
|
|
1185
|
+
});
|
|
1186
|
+
return createUpdateOperation(urn, refreshed.state, nodeState.input, refreshed.inputState, nodeState, () => {
|
|
1187
|
+
committed++;
|
|
1188
|
+
});
|
|
1177
1189
|
});
|
|
1178
1190
|
}));
|
|
1179
1191
|
}))).flat().filter((op) => !!op);
|
|
@@ -1181,7 +1193,7 @@ const refresh = async (app, opt) => {
|
|
|
1181
1193
|
return {
|
|
1182
1194
|
operations: filteredOperations,
|
|
1183
1195
|
async commit() {
|
|
1184
|
-
await opt.backend.state.update(app.urn, appState);
|
|
1196
|
+
if (committed > 0) await opt.backend.state.update(app.urn, appState);
|
|
1185
1197
|
}
|
|
1186
1198
|
};
|
|
1187
1199
|
}
|