@gravity-rail/cli 0.36.1 → 0.36.2
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/gr.js +69 -24
- package/dist/gr.js.map +1 -1
- package/dist/lib.js +53 -13
- package/dist/lib.js.map +1 -1
- package/package.json +1 -1
package/dist/lib.js
CHANGED
|
@@ -4021,13 +4021,41 @@ function renderImportPlan(projection) {
|
|
|
4021
4021
|
return lines.join("\n") + "\n";
|
|
4022
4022
|
}
|
|
4023
4023
|
|
|
4024
|
+
// src/lib/workspace-sync/progress.ts
|
|
4025
|
+
async function withTransferProgress(stage, workspaceUuid, operation, options = {}) {
|
|
4026
|
+
const started = performance.now();
|
|
4027
|
+
const elapsed = () => Math.floor((performance.now() - started) / 1e3);
|
|
4028
|
+
const label = `${workspaceUuid}: ${stage}`;
|
|
4029
|
+
stderr(`${label} started`);
|
|
4030
|
+
const timer = setInterval(() => {
|
|
4031
|
+
stderr(`${label} waiting (${elapsed()}s elapsed)`);
|
|
4032
|
+
}, 3e4);
|
|
4033
|
+
timer.unref();
|
|
4034
|
+
try {
|
|
4035
|
+
const result2 = await operation();
|
|
4036
|
+
stderr(`${label} completed (${elapsed()}s elapsed)`);
|
|
4037
|
+
return result2;
|
|
4038
|
+
} catch (error) {
|
|
4039
|
+
if (options.reportFailure !== false) {
|
|
4040
|
+
stderr(`${label} failed (${elapsed()}s elapsed)`);
|
|
4041
|
+
}
|
|
4042
|
+
throw error;
|
|
4043
|
+
} finally {
|
|
4044
|
+
clearInterval(timer);
|
|
4045
|
+
}
|
|
4046
|
+
}
|
|
4047
|
+
|
|
4024
4048
|
// src/domains/workspaces.ts
|
|
4025
4049
|
function archiveBlob(zip) {
|
|
4026
4050
|
return new Blob([new Uint8Array(zip)]);
|
|
4027
4051
|
}
|
|
4028
4052
|
var REAPPLY_EXPORT_EXCLUDE = "channels";
|
|
4029
4053
|
async function exportTemplateArchive(client, templateUuid) {
|
|
4030
|
-
return
|
|
4054
|
+
return withTransferProgress(
|
|
4055
|
+
"template archive",
|
|
4056
|
+
templateUuid,
|
|
4057
|
+
() => client.exportWorkspaceZip(templateUuid, void 0, void 0, REAPPLY_EXPORT_EXCLUDE)
|
|
4058
|
+
);
|
|
4031
4059
|
}
|
|
4032
4060
|
async function readBindingsFile(filePath, targets) {
|
|
4033
4061
|
if (!filePath) return {};
|
|
@@ -4109,10 +4137,14 @@ async function reapplyOneTarget(ctx, client, options) {
|
|
|
4109
4137
|
const { targetUuid, bindings, planOnly, autoConfirm } = options;
|
|
4110
4138
|
let projection;
|
|
4111
4139
|
try {
|
|
4112
|
-
const preview = await
|
|
4140
|
+
const preview = await withTransferProgress(
|
|
4141
|
+
"target preview",
|
|
4113
4142
|
targetUuid,
|
|
4114
|
-
archiveBlob(options.archive),
|
|
4115
|
-
|
|
4143
|
+
() => client.previewWorkspaceImportZip(targetUuid, archiveBlob(options.archive), {
|
|
4144
|
+
intent: "template_reapply",
|
|
4145
|
+
bindings
|
|
4146
|
+
}),
|
|
4147
|
+
{ reportFailure: false }
|
|
4116
4148
|
);
|
|
4117
4149
|
projection = projectImportPlan(preview);
|
|
4118
4150
|
} catch (err) {
|
|
@@ -4154,11 +4186,16 @@ ${renderImportPlan(projection)}`);
|
|
|
4154
4186
|
return { target: targetUuid, status: "skipped", code: "not_confirmed", plan: projection };
|
|
4155
4187
|
}
|
|
4156
4188
|
try {
|
|
4157
|
-
const applied = await
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4189
|
+
const applied = await withTransferProgress(
|
|
4190
|
+
"target apply",
|
|
4191
|
+
targetUuid,
|
|
4192
|
+
() => client.importWorkspaceZip(targetUuid, archiveBlob(options.archive), {
|
|
4193
|
+
intent: "template_reapply",
|
|
4194
|
+
expectedPlanFingerprint: projection.planFingerprint,
|
|
4195
|
+
bindings
|
|
4196
|
+
}),
|
|
4197
|
+
{ reportFailure: false }
|
|
4198
|
+
);
|
|
4162
4199
|
if (applied.status === "noop") {
|
|
4163
4200
|
return {
|
|
4164
4201
|
target: targetUuid,
|
|
@@ -4651,10 +4688,12 @@ Provisioning started. Watch it come up with:
|
|
|
4651
4688
|
const templateUuid = requireArg(hctx, "template");
|
|
4652
4689
|
const client = ctx.apiClient;
|
|
4653
4690
|
const archive = await exportTemplateArchive(client, templateUuid);
|
|
4654
|
-
const preview = await
|
|
4691
|
+
const preview = await withTransferProgress(
|
|
4692
|
+
"target preview",
|
|
4655
4693
|
hctx.workspace,
|
|
4656
|
-
archiveBlob(archive),
|
|
4657
|
-
|
|
4694
|
+
() => client.previewWorkspaceImportZip(hctx.workspace, archiveBlob(archive), {
|
|
4695
|
+
intent: "template_reapply"
|
|
4696
|
+
})
|
|
4658
4697
|
);
|
|
4659
4698
|
const projection = projectImportPlan(preview);
|
|
4660
4699
|
emitReport(ctx, renderImportPlan(projection), projection);
|
|
@@ -10259,7 +10298,8 @@ var NO_UUID_LOOKUP = /* @__PURE__ */ new Set([
|
|
|
10259
10298
|
"purchase",
|
|
10260
10299
|
"import",
|
|
10261
10300
|
"invoice",
|
|
10262
|
-
"workspace_config"
|
|
10301
|
+
"workspace_config",
|
|
10302
|
+
"data_record"
|
|
10263
10303
|
]);
|
|
10264
10304
|
var HYDRATORS = {
|
|
10265
10305
|
workspace: async ({ client }, ref) => (await client.getWorkspace(ref.uuid)).name,
|