@credibledata/cred-cli 0.1.0

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.
Files changed (170) hide show
  1. package/.eslintrc +33 -0
  2. package/.github/workflows/build.yml +23 -0
  3. package/.mocharc.json +10 -0
  4. package/.prettierignore +1 -0
  5. package/.prettierrc +4 -0
  6. package/README.md +40 -0
  7. package/bun.lock +1259 -0
  8. package/dist/client/api.js +7022 -0
  9. package/dist/client/api.js.map +1 -0
  10. package/dist/client/base.js +69 -0
  11. package/dist/client/base.js.map +1 -0
  12. package/dist/client/common.js +162 -0
  13. package/dist/client/common.js.map +1 -0
  14. package/dist/client/configuration.js +44 -0
  15. package/dist/client/configuration.js.map +1 -0
  16. package/dist/client/index.js +32 -0
  17. package/dist/client/index.js.map +1 -0
  18. package/dist/clientconfiguration.js +163 -0
  19. package/dist/clientconfiguration.js.map +1 -0
  20. package/dist/clientconfiguration.spec.js +92 -0
  21. package/dist/clientconfiguration.spec.js.map +1 -0
  22. package/dist/commands/add.js +61 -0
  23. package/dist/commands/add.js.map +1 -0
  24. package/dist/commands/connection/createconnections.js +62 -0
  25. package/dist/commands/connection/createconnections.js.map +1 -0
  26. package/dist/commands/connection/deleteconnection.js +52 -0
  27. package/dist/commands/connection/deleteconnection.js.map +1 -0
  28. package/dist/commands/connection/listconnections.js +44 -0
  29. package/dist/commands/connection/listconnections.js.map +1 -0
  30. package/dist/commands/get.js +28 -0
  31. package/dist/commands/get.js.map +1 -0
  32. package/dist/commands/group/addmember.js +73 -0
  33. package/dist/commands/group/addmember.js.map +1 -0
  34. package/dist/commands/group/creategroup.js +55 -0
  35. package/dist/commands/group/creategroup.js.map +1 -0
  36. package/dist/commands/group/deletegroup.js +48 -0
  37. package/dist/commands/group/deletegroup.js.map +1 -0
  38. package/dist/commands/group/getgroup.js +50 -0
  39. package/dist/commands/group/getgroup.js.map +1 -0
  40. package/dist/commands/group/listgroups.js +56 -0
  41. package/dist/commands/group/listgroups.js.map +1 -0
  42. package/dist/commands/group/removemember.js +68 -0
  43. package/dist/commands/group/removemember.js.map +1 -0
  44. package/dist/commands/groupaccesstoken/createToken.js +49 -0
  45. package/dist/commands/groupaccesstoken/createToken.js.map +1 -0
  46. package/dist/commands/groupaccesstoken/deleteToken.js +24 -0
  47. package/dist/commands/groupaccesstoken/deleteToken.js.map +1 -0
  48. package/dist/commands/groupaccesstoken/groupContainer.js +71 -0
  49. package/dist/commands/groupaccesstoken/groupContainer.js.map +1 -0
  50. package/dist/commands/groupaccesstoken/listTokens.js +25 -0
  51. package/dist/commands/groupaccesstoken/listTokens.js.map +1 -0
  52. package/dist/commands/list.js +68 -0
  53. package/dist/commands/list.js.map +1 -0
  54. package/dist/commands/misc/login.js +166 -0
  55. package/dist/commands/misc/login.js.map +1 -0
  56. package/dist/commands/misc/login.spec.js +138 -0
  57. package/dist/commands/misc/login.spec.js.map +1 -0
  58. package/dist/commands/misc/logout.js +11 -0
  59. package/dist/commands/misc/logout.js.map +1 -0
  60. package/dist/commands/misc/set-access-token.js +27 -0
  61. package/dist/commands/misc/set-access-token.js.map +1 -0
  62. package/dist/commands/package/deletepackage.js +54 -0
  63. package/dist/commands/package/deletepackage.js.map +1 -0
  64. package/dist/commands/package/listpackages.js +52 -0
  65. package/dist/commands/package/listpackages.js.map +1 -0
  66. package/dist/commands/package/publish.js +134 -0
  67. package/dist/commands/package/publish.js.map +1 -0
  68. package/dist/commands/package/updatepackage.js +75 -0
  69. package/dist/commands/package/updatepackage.js.map +1 -0
  70. package/dist/commands/package/updatepackage.spec.js +139 -0
  71. package/dist/commands/package/updatepackage.spec.js.map +1 -0
  72. package/dist/commands/project/createproject.js +65 -0
  73. package/dist/commands/project/createproject.js.map +1 -0
  74. package/dist/commands/project/deleteproject.js +49 -0
  75. package/dist/commands/project/deleteproject.js.map +1 -0
  76. package/dist/commands/project/getproject.js +44 -0
  77. package/dist/commands/project/getproject.js.map +1 -0
  78. package/dist/commands/project/listprojects.js +46 -0
  79. package/dist/commands/project/listprojects.js.map +1 -0
  80. package/dist/commands/project/setproject.js +26 -0
  81. package/dist/commands/project/setproject.js.map +1 -0
  82. package/dist/commands/rm.js +68 -0
  83. package/dist/commands/rm.js.map +1 -0
  84. package/dist/commands/set.js +17 -0
  85. package/dist/commands/set.js.map +1 -0
  86. package/dist/commands/update.js +29 -0
  87. package/dist/commands/update.js.map +1 -0
  88. package/dist/commands/version/archive-unarchive-version.js +79 -0
  89. package/dist/commands/version/archive-unarchive-version.js.map +1 -0
  90. package/dist/commands/version/archive-unarchive-version.spec.js +244 -0
  91. package/dist/commands/version/archive-unarchive-version.spec.js.map +1 -0
  92. package/dist/commands/version/listversions.js +46 -0
  93. package/dist/commands/version/listversions.js.map +1 -0
  94. package/dist/common/UserGroupId.js +112 -0
  95. package/dist/common/UserGroupId.js.map +1 -0
  96. package/dist/constants.js +54 -0
  97. package/dist/constants.js.map +1 -0
  98. package/dist/index.js +137 -0
  99. package/dist/index.js.map +1 -0
  100. package/dist/logger.js +77 -0
  101. package/dist/logger.js.map +1 -0
  102. package/dist/polyfills/file.polyfill.js +6 -0
  103. package/dist/polyfills/file.polyfill.js.map +1 -0
  104. package/dist/utils.js +51 -0
  105. package/dist/utils.js.map +1 -0
  106. package/dist/validator.js +53 -0
  107. package/dist/validator.js.map +1 -0
  108. package/dist/validator.spec.js +41 -0
  109. package/dist/validator.spec.js.map +1 -0
  110. package/docker/Dockerfile.ci +10 -0
  111. package/docker-compose.yml +18 -0
  112. package/mocha.setup.ts +4 -0
  113. package/openapitools.json +7 -0
  114. package/package.json +67 -0
  115. package/src/client/.openapi-generator/FILES +8 -0
  116. package/src/client/.openapi-generator/VERSION +1 -0
  117. package/src/client/.openapi-generator-ignore +23 -0
  118. package/src/client/api.ts +8408 -0
  119. package/src/client/base.ts +86 -0
  120. package/src/client/common.ts +150 -0
  121. package/src/client/configuration.ts +110 -0
  122. package/src/client/git_push.sh +57 -0
  123. package/src/client/index.ts +18 -0
  124. package/src/clientconfiguration.spec.ts +116 -0
  125. package/src/clientconfiguration.ts +204 -0
  126. package/src/commands/add.ts +106 -0
  127. package/src/commands/connection/createconnections.ts +67 -0
  128. package/src/commands/connection/deleteconnection.ts +57 -0
  129. package/src/commands/connection/listconnections.ts +39 -0
  130. package/src/commands/get.ts +31 -0
  131. package/src/commands/group/addmember.ts +83 -0
  132. package/src/commands/group/creategroup.ts +54 -0
  133. package/src/commands/group/deletegroup.ts +45 -0
  134. package/src/commands/group/getgroup.ts +47 -0
  135. package/src/commands/group/listgroups.ts +45 -0
  136. package/src/commands/group/removemember.ts +74 -0
  137. package/src/commands/groupaccesstoken/createToken.ts +68 -0
  138. package/src/commands/groupaccesstoken/deleteToken.ts +24 -0
  139. package/src/commands/groupaccesstoken/groupContainer.ts +83 -0
  140. package/src/commands/groupaccesstoken/listTokens.ts +24 -0
  141. package/src/commands/list.ts +90 -0
  142. package/src/commands/misc/login.spec.ts +128 -0
  143. package/src/commands/misc/login.ts +142 -0
  144. package/src/commands/misc/logout.ts +9 -0
  145. package/src/commands/misc/set-access-token.ts +32 -0
  146. package/src/commands/package/deletepackage.ts +58 -0
  147. package/src/commands/package/listpackages.ts +44 -0
  148. package/src/commands/package/publish.ts +179 -0
  149. package/src/commands/package/updatepackage.spec.ts +221 -0
  150. package/src/commands/package/updatepackage.ts +95 -0
  151. package/src/commands/project/createproject.ts +59 -0
  152. package/src/commands/project/deleteproject.ts +48 -0
  153. package/src/commands/project/getproject.ts +43 -0
  154. package/src/commands/project/listprojects.ts +36 -0
  155. package/src/commands/project/setproject.ts +14 -0
  156. package/src/commands/rm.ts +106 -0
  157. package/src/commands/set.ts +16 -0
  158. package/src/commands/update.ts +41 -0
  159. package/src/commands/version/archive-unarchive-version.spec.ts +456 -0
  160. package/src/commands/version/archive-unarchive-version.ts +111 -0
  161. package/src/commands/version/listversions.ts +45 -0
  162. package/src/common/UserGroupId.ts +137 -0
  163. package/src/constants.ts +70 -0
  164. package/src/index.ts +183 -0
  165. package/src/logger.ts +86 -0
  166. package/src/polyfills/file.polyfill.ts +5 -0
  167. package/src/utils.ts +34 -0
  168. package/src/validator.spec.ts +51 -0
  169. package/src/validator.ts +44 -0
  170. package/tsconfig.json +20 -0
@@ -0,0 +1,95 @@
1
+ import { Package, PackagesApi } from "../../client/api";
2
+ import { Configuration } from "../../client/configuration";
3
+ import { ClientConfiguration } from "../../clientconfiguration";
4
+ import { logger } from "../../logger";
5
+ import { getConfirmation, printOutError } from "../../utils";
6
+
7
+ const packagesApi = new PackagesApi(new Configuration());
8
+
9
+ type NewParams = {
10
+ latestVersion?: string;
11
+ replicationCount?: number;
12
+ description?: string;
13
+ };
14
+ export async function updatePackage(
15
+ packageServer: string,
16
+ packageName: string,
17
+ newParams: NewParams,
18
+ debug: boolean,
19
+ autoConfirm: boolean,
20
+ ) {
21
+ const clientConfig = new ClientConfiguration();
22
+ const organizationName = clientConfig.getOrganization();
23
+ const projectName = clientConfig.getProject();
24
+
25
+ if (!clientConfig.doesConfigExists()) {
26
+ logger.error("Please, make sure that you are logged in");
27
+ return;
28
+ }
29
+
30
+ if (!projectName) {
31
+ logger.error("Please, make sure to set a project");
32
+ return;
33
+ }
34
+
35
+ if (!packageName) {
36
+ logger.error("Please provide a package name");
37
+ return;
38
+ }
39
+
40
+ logger.info(
41
+ `Setting replication count for package ${packageName} to ${newParams.replicationCount}`,
42
+ );
43
+
44
+ try {
45
+ if (!autoConfirm) {
46
+ const confirmation = await getConfirmation(
47
+ `Are you sure you that want to update the replication count for package ${packageName} to ${newParams.replicationCount}?`,
48
+ );
49
+ if (!confirmation) {
50
+ logger.info("Operation cancelled.");
51
+ return;
52
+ }
53
+ }
54
+ const packageUpdate: Package = {
55
+ replicationCount: newParams.replicationCount || undefined,
56
+ latestVersion: newParams.latestVersion || undefined,
57
+ description: newParams.description || undefined,
58
+ };
59
+ const pathParts = packageName
60
+ .split("/")
61
+ .filter((part) => part.length > 0);
62
+ if (pathParts.length !== 1) {
63
+ logger.error("Invalid package path. Expected format: /<packageName>");
64
+ return;
65
+ }
66
+
67
+ packageName = pathParts[0];
68
+
69
+ const response = await packagesApi.updatePackage(
70
+ organizationName,
71
+ projectName,
72
+ packageName,
73
+ packageUpdate,
74
+ {
75
+ baseURL: packageServer,
76
+ headers: clientConfig.getHeaders(),
77
+ },
78
+ );
79
+
80
+ if (response.status === 200) {
81
+ logger.info(
82
+ `Successfully set replication count for package ${packageName} to ${newParams.replicationCount}`,
83
+ );
84
+ } else {
85
+ logger.error(
86
+ `Failed to set replication count. Status: ${response.status}`,
87
+ );
88
+ }
89
+ } catch (e) {
90
+ logger.error(
91
+ `Failed to set replication count for package ${packageName}`,
92
+ );
93
+ printOutError(e, debug);
94
+ }
95
+ }
@@ -0,0 +1,59 @@
1
+ import fs from "fs";
2
+ import { Project, ProjectsApi } from "../../client/api";
3
+ import { Configuration } from "../../client/configuration";
4
+ import { ClientConfiguration } from "../../clientconfiguration";
5
+ import { logger } from "../../logger";
6
+ import { getConfirmation, printOutError } from "../../utils";
7
+
8
+ const projectsApi = new ProjectsApi(new Configuration());
9
+
10
+ export async function createProject(
11
+ controlPlane: string,
12
+ projectName: string,
13
+ readmeFile: string,
14
+ debug: boolean,
15
+ autoConfirm: boolean,
16
+ ) {
17
+ const clientConfig = new ClientConfiguration();
18
+
19
+ if (!clientConfig.doesConfigExists()) {
20
+ logger.error("Please, make sure that you are logged in");
21
+ return;
22
+ }
23
+ if (!autoConfirm) {
24
+ const confirmation = await getConfirmation(
25
+ `Are you sure you that want to create a project named ${projectName}?`,
26
+ );
27
+ if (!confirmation) {
28
+ logger.info("Operation cancelled.");
29
+ return;
30
+ }
31
+ }
32
+ logger.info("Creating project " + projectName);
33
+
34
+ let readmeContents = "";
35
+ if (readmeFile) {
36
+ readmeContents = fs.readFileSync(readmeFile).toString();
37
+ }
38
+
39
+ try {
40
+ const project: Project = { name: projectName, readme: readmeContents };
41
+ await projectsApi
42
+ .createProject(clientConfig.getOrganization(), project, {
43
+ baseURL: controlPlane,
44
+ headers: {
45
+ Authorization: clientConfig.getAuthenticationHeader(),
46
+ },
47
+ })
48
+ .then((response) => {
49
+ const jsonString = JSON.stringify(response.data, null, 2);
50
+ console.log(jsonString);
51
+ // Make the new project the default project.
52
+ clientConfig.setProject(projectName);
53
+ });
54
+ logger.info("Project created successfully");
55
+ } catch (e) {
56
+ logger.error("Failed to create project");
57
+ printOutError(e, debug);
58
+ }
59
+ }
@@ -0,0 +1,48 @@
1
+ import { ProjectsApi } from "../../client/api";
2
+ import { Configuration } from "../../client/configuration";
3
+ import { ClientConfiguration } from "../../clientconfiguration";
4
+ import { logger } from "../../logger";
5
+ import { getConfirmation, printOutError } from "../../utils";
6
+
7
+ const projectsApi = new ProjectsApi(new Configuration());
8
+
9
+ export async function deleteProject(
10
+ controlPlane: string,
11
+ projectName: string,
12
+ debug: boolean,
13
+ autoConfirm: boolean,
14
+ ) {
15
+ const clientConfig = new ClientConfiguration();
16
+
17
+ if (!clientConfig.doesConfigExists()) {
18
+ logger.error("Please, make sure that you are logged in");
19
+ return;
20
+ }
21
+ if (!autoConfirm) {
22
+ const confirmation = await getConfirmation(
23
+ `Are you sure you that want to delete the ${projectName} project? This action cannot be undone.`,
24
+ );
25
+ if (!confirmation) {
26
+ logger.info("Operation cancelled.");
27
+ return;
28
+ }
29
+ }
30
+ logger.info("Deleting project " + projectName);
31
+
32
+ try {
33
+ await projectsApi.deleteProject(
34
+ clientConfig.getOrganization(),
35
+ projectName,
36
+ {
37
+ baseURL: controlPlane,
38
+ headers: {
39
+ Authorization: clientConfig.getAuthenticationHeader(),
40
+ },
41
+ },
42
+ );
43
+ logger.info("Project deleted successfully");
44
+ } catch (e) {
45
+ logger.error("Failed to delete project");
46
+ printOutError(e, debug);
47
+ }
48
+ }
@@ -0,0 +1,43 @@
1
+ import { ProjectsApi } from "../../client/api";
2
+ import { Configuration } from "../../client/configuration";
3
+ import { ClientConfiguration } from "../../clientconfiguration";
4
+ import { logger } from "../../logger";
5
+ import { prettifyJson, printOutError } from "../../utils";
6
+
7
+ const projectsApi = new ProjectsApi(new Configuration());
8
+
9
+ export async function getProject(
10
+ controlPlane: string,
11
+ projectName: string,
12
+ debug: boolean,
13
+ ) {
14
+ const clientConfig = new ClientConfiguration();
15
+ const organizationName = clientConfig.getOrganization();
16
+
17
+ if (!clientConfig.doesConfigExists()) {
18
+ logger.error("Please, make sure that you are logged in");
19
+ return;
20
+ }
21
+
22
+ if (!projectName) {
23
+ logger.error("Please, make sure to provide a project name");
24
+ return;
25
+ }
26
+
27
+ try {
28
+ const response = await projectsApi.getProject(
29
+ organizationName,
30
+ projectName,
31
+ false,
32
+ {
33
+ baseURL: controlPlane,
34
+ headers: clientConfig.getHeaders(),
35
+ },
36
+ );
37
+
38
+ console.log(prettifyJson(response.data));
39
+ } catch (e) {
40
+ logger.error("Failed to get project");
41
+ printOutError(e, debug);
42
+ }
43
+ }
@@ -0,0 +1,36 @@
1
+ import { ProjectsApi } from "../../client/api";
2
+ import { Configuration } from "../../client/configuration";
3
+ import { ClientConfiguration } from "../../clientconfiguration";
4
+ import { logger } from "../../logger";
5
+ import { prettifyJson, printOutError } from "../../utils";
6
+
7
+ const projectsApi = new ProjectsApi(new Configuration());
8
+
9
+ export async function listProjects(controlPlane: string, debug: boolean) {
10
+ const clientConfig = new ClientConfiguration();
11
+
12
+ if (!clientConfig.doesConfigExists()) {
13
+ logger.error("Please, make sure that you are logged in");
14
+ return [];
15
+ }
16
+
17
+ try {
18
+ const response = await projectsApi.listProjects(
19
+ clientConfig.getOrganization(),
20
+ {
21
+ baseURL: controlPlane,
22
+ headers: clientConfig.getHeaders(),
23
+ },
24
+ );
25
+
26
+ return response.data;
27
+ } catch (e) {
28
+ logger.error("Failed to list projects");
29
+ printOutError(e, debug);
30
+ return [];
31
+ }
32
+ }
33
+
34
+ export async function printOutProjects(controlPlane: string, debug: boolean) {
35
+ console.log(prettifyJson(await listProjects(controlPlane, debug)));
36
+ }
@@ -0,0 +1,14 @@
1
+ import { ClientConfiguration } from "../../clientconfiguration";
2
+ import { logger } from "../../logger";
3
+
4
+ export async function setProject(projectName: string) {
5
+ console.log("Setting project " + projectName);
6
+ const clientConfig = new ClientConfiguration();
7
+
8
+ if (!clientConfig.doesConfigExists()) {
9
+ logger.error("Please, make sure that you are logged in");
10
+ return;
11
+ }
12
+
13
+ clientConfig.setProject(projectName);
14
+ }
@@ -0,0 +1,106 @@
1
+ import { Command } from "commander";
2
+ import { controlPlanesByEnv, Environment } from "../constants";
3
+ import { deleteConnection } from "./connection/deleteconnection";
4
+ import { deleteGroup } from "./group/deletegroup";
5
+ import { removeMember } from "./group/removemember";
6
+ import { deleteGroupAccessToken } from "./groupaccesstoken/deleteToken";
7
+ import { deletePackage } from "./package/deletepackage";
8
+ import { deleteProject } from "./project/deleteproject";
9
+
10
+ export const registerRmCommands = (cli: Command, environment: Environment) => {
11
+ const rm = cli
12
+ .command("rm")
13
+ .description("Remove a resource")
14
+ .argument("<resource>", "The resource to remove");
15
+
16
+ rm.command("package")
17
+ .description("Delete a package.")
18
+ .argument("<packageName>", "The name of the package to delete.")
19
+ .option("--debug")
20
+ .option("-y, --yes", "Skip confirmation.")
21
+ .action((packageName, options) => {
22
+ deletePackage(
23
+ controlPlanesByEnv[environment],
24
+ packageName,
25
+ options.debug,
26
+ options.yes,
27
+ );
28
+ });
29
+
30
+ rm.command("project")
31
+ .description("Delete a project.")
32
+ .argument("<projectName>", "The name of the project to delete.")
33
+ .option("--debug")
34
+ .option("-y, --yes", "Skip confirmation.")
35
+ .action((projectName, options) => {
36
+ deleteProject(
37
+ controlPlanesByEnv[environment],
38
+ projectName,
39
+ options.debug,
40
+ options.yes,
41
+ );
42
+ });
43
+
44
+ rm.command("connection")
45
+ .description("Delete a connection.")
46
+ .argument("<connectionName>", "The name of the connection to delete.")
47
+ .option("--debug")
48
+ .option("-y, --yes", "Skip confirmation.")
49
+ .action((connectionName, options) => {
50
+ deleteConnection(
51
+ controlPlanesByEnv[environment],
52
+ connectionName,
53
+ options.debug,
54
+ options.yes,
55
+ );
56
+ });
57
+
58
+ rm.command("group")
59
+ .description("Delete a group.")
60
+ .argument("<groupName>", "The name of the group to delete")
61
+ .option("--debug")
62
+ .option("-y, --yes", "Skip confirmation.")
63
+ .action((groupName, options) => {
64
+ deleteGroup(
65
+ controlPlanesByEnv[environment],
66
+ groupName,
67
+ options.debug || false,
68
+ );
69
+ });
70
+
71
+ rm.command("member")
72
+ .description("Remove a member from a group.")
73
+ .argument("<groupName>", "The name of the group")
74
+ .argument("<memberType>", "The type of member (user or group)")
75
+ .argument("<memberName>", "The name of the member")
76
+ .option("--debug")
77
+ .action((groupName, memberType, memberName, options) => {
78
+ removeMember(
79
+ controlPlanesByEnv[environment],
80
+ groupName,
81
+ memberType,
82
+ memberName,
83
+ options.debug || false,
84
+ );
85
+ });
86
+
87
+
88
+ rm.command("group-access-token")
89
+ .description("Delete an access token from a group.")
90
+ .argument(
91
+ "<groupName>",
92
+ "The name of the group",
93
+ )
94
+ .argument("<tokenName>", "The name of the token to delete")
95
+ .option("--debug")
96
+ .option("-y, --yes", "Skip confirmation.")
97
+ .action((groupName, tokenName, options) => {
98
+ deleteGroupAccessToken(
99
+ controlPlanesByEnv[environment],
100
+ groupName,
101
+ tokenName,
102
+ options.debug || false,
103
+ );
104
+ });
105
+
106
+ };
@@ -0,0 +1,16 @@
1
+ import { Command } from "commander";
2
+ import { setProject } from "./project/setproject";
3
+
4
+ export const registerSetCommands = (cli: Command) => {
5
+ const set = cli
6
+ .command("set")
7
+ .description("Set a resource")
8
+ .argument("<resource>", "The resource to set");
9
+
10
+ set.command("project")
11
+ .description("Set the default project.")
12
+ .argument("<projectName>", "The name of the project to set.")
13
+ .action(setProject);
14
+
15
+ // TODO: It would be nice to `cred set org` and avoid logging again when switching orgs.
16
+ };
@@ -0,0 +1,41 @@
1
+ import { Command } from "commander";
2
+ import { controlPlanesByEnv, Environment } from "../constants";
3
+ import { updatePackage } from "./package/updatepackage";
4
+
5
+ export const registerUpdateCommands = (
6
+ cli: Command,
7
+ environment: Environment,
8
+ ) => {
9
+ const update = cli
10
+ .command("update")
11
+ .description("Update a resource")
12
+ .argument("<resource>", "The resource to update");
13
+
14
+ update
15
+ .command("package")
16
+ .description("Update a package.")
17
+ .argument("<packageName>", "The name of the package to update.")
18
+ .option(
19
+ "--replication <replicationCount>",
20
+ "The new replication count (must be at least 1).",
21
+ parseInt,
22
+ )
23
+ .option("--version <latestVersion>", "The new latest version.")
24
+ .option("--desc, --description <description>", "The new description.")
25
+ .option("--debug")
26
+ .option("-y, --yes", "Skip confirmation.")
27
+ .action((packageName, options) => {
28
+ updatePackage(
29
+ controlPlanesByEnv[environment],
30
+ packageName,
31
+ {
32
+ replicationCount: options.replication,
33
+ latestVersion: options.version,
34
+ description: options.description,
35
+ },
36
+ options.debug,
37
+ options.yes,
38
+ );
39
+ });
40
+
41
+ };