@trayai/tray-sync-cli 1.0.10 → 1.0.11
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/commands/api/api.js
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Command, InvalidArgumentError } from "commander";
|
|
2
|
+
import { rollbackProject } from "../../api/resources/project.js";
|
|
3
|
+
import { isUuid } from "../../lib/uuid.js";
|
|
4
|
+
import { parseVersionNumber } from "../../lib/versionNumber.js";
|
|
5
|
+
import { OutputFormats } from "../../lib/outputFormat.js";
|
|
6
|
+
import { printProjectRollbackResult } from "../../views/api/project.v2.js";
|
|
7
|
+
import { printConfirmationJson } from "../../views/api/shared.js";
|
|
8
|
+
import { addCommonApiOptions, apiClientFor, realDeps, runApiAction, } from "./shared.js";
|
|
9
|
+
function parseProjectId(value) {
|
|
10
|
+
if (!isUuid(value)) {
|
|
11
|
+
throw new InvalidArgumentError("project id must be a UUID");
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
export async function runProjectRollback(deps, options) {
|
|
16
|
+
const client = apiClientFor(deps, options);
|
|
17
|
+
await rollbackProject(client, options.projectId, options.versionNumber);
|
|
18
|
+
if (options.format === OutputFormats.JSON) {
|
|
19
|
+
printConfirmationJson(deps.stdout, {
|
|
20
|
+
projectId: options.projectId,
|
|
21
|
+
versionNumber: options.versionNumber,
|
|
22
|
+
rolledBack: true,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
printProjectRollbackResult(deps.stdout, options.projectId, options.versionNumber);
|
|
27
|
+
}
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
export const projectCommand = new Command("project").description("Manage projects");
|
|
31
|
+
const versionCommand = new Command("version").description("Manage project versions");
|
|
32
|
+
projectCommand.addCommand(versionCommand);
|
|
33
|
+
addCommonApiOptions(versionCommand
|
|
34
|
+
.command("rollback")
|
|
35
|
+
.description("Roll back a project to a specific version")
|
|
36
|
+
.argument("<project-id>", "Tray project UUID", parseProjectId)
|
|
37
|
+
.requiredOption("--version-number <major.minor>", "target version number", parseVersionNumber)).action(async (projectId, opts) => {
|
|
38
|
+
const deps = realDeps();
|
|
39
|
+
await runApiAction(deps, () => runProjectRollback(deps, {
|
|
40
|
+
projectId,
|
|
41
|
+
versionNumber: opts.versionNumber,
|
|
42
|
+
region: opts.region,
|
|
43
|
+
token: opts.token,
|
|
44
|
+
format: opts.format,
|
|
45
|
+
}));
|
|
46
|
+
});
|
|
47
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import ansis from "ansis";
|
|
2
|
+
import { SUCCESS_ICON } from "../icons.js";
|
|
3
|
+
export function printProjectRollbackResult(stdout, projectId, versionNumber) {
|
|
4
|
+
stdout(`${SUCCESS_ICON} Project ${ansis.bold(projectId)} rolled back to version ${ansis.bold(versionNumber)}.`);
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=project.v2.js.map
|
package/package.json
CHANGED