@zuplo/cli 1.125.0 → 1.126.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.
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="aaafa692-9a45-5551-b265-0a92f13b3846")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="927377a1-a35e-545f-b1f3-b6bb33de78a5")}catch(e){}}();
3
3
  import { captureEvent } from "../common/analytics/lib.js";
4
4
  import { configure } from "../common/middleware/user-configuration.js";
5
5
  import { identify } from "../common/middleware/user-identification.js";
@@ -28,6 +28,10 @@ export default {
28
28
  .option("wait", {
29
29
  type: "boolean",
30
30
  describe: "Should the CLI wait until the zup is deleted",
31
+ })
32
+ .option("self-hosted-endpoint", {
33
+ type: "string",
34
+ describe: "The endpoint of your self-hosted service to deploy to",
31
35
  })
32
36
  .boolean("wait")
33
37
  .demandOption(["api-key", "url"])
@@ -42,4 +46,4 @@ export default {
42
46
  },
43
47
  };
44
48
  //# sourceMappingURL=delete.js.map
45
- //# debugId=aaafa692-9a45-5551-b265-0a92f13b3846
49
+ //# debugId=927377a1-a35e-545f-b1f3-b6bb33de78a5
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="340e4aed-225d-5578-a3af-822eb8c7f33b")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="71a10983-ca0c-521e-8b72-1c13c38ccb75")}catch(e){}}();
3
3
  import { captureEvent } from "../common/analytics/lib.js";
4
4
  import { configure } from "../common/middleware/user-configuration.js";
5
5
  import { identify } from "../common/middleware/user-identification.js";
@@ -37,6 +37,10 @@ export default {
37
37
  .option("environment", {
38
38
  type: "string",
39
39
  describe: "The value to use for environment name, instead of the current branch name",
40
+ })
41
+ .option("self-hosted-endpoint", {
42
+ type: "string",
43
+ describe: "The endpoint of your self-hosted service to deploy to"
40
44
  })
41
45
  .demandOption(["api-key"])
42
46
  .boolean("verify-remote")
@@ -51,4 +55,4 @@ export default {
51
55
  },
52
56
  };
53
57
  //# sourceMappingURL=deploy.js.map
54
- //# debugId=340e4aed-225d-5578-a3af-822eb8c7f33b
58
+ //# debugId=71a10983-ca0c-521e-8b72-1c13c38ccb75
package/dist/cmds/list.js CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1365eaa2-6dd2-520c-9675-2c2c00576f66")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="144bdbb4-d5bd-5341-8fa5-90647d62ceda")}catch(e){}}();
3
3
  import { captureEvent } from "../common/analytics/lib.js";
4
4
  import { configure } from "../common/middleware/user-configuration.js";
5
5
  import { identify } from "../common/middleware/user-identification.js";
@@ -20,6 +20,10 @@ export default {
20
20
  .option("project", {
21
21
  type: "string",
22
22
  describe: "The project name",
23
+ })
24
+ .option("self-hosted-endpoint", {
25
+ type: "string",
26
+ describe: "The endpoint of your self-hosted service to deploy to",
23
27
  })
24
28
  .demandOption(["api-key"])
25
29
  .middleware([setBlocking, configure, identify])
@@ -33,4 +37,4 @@ export default {
33
37
  },
34
38
  };
35
39
  //# sourceMappingURL=list.js.map
36
- //# debugId=1365eaa2-6dd2-520c-9675-2c2c00576f66
40
+ //# debugId=144bdbb4-d5bd-5341-8fa5-90647d62ceda
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4daebd3e-ec9e-5f97-947a-e83332c8499e")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d26c033c-d06e-597b-b81e-6be1685fe906")}catch(e){}}();
3
3
  export const ZUPLO_PREFERRED_JSON_FILE = "zuplo.jsonc";
4
4
  export const ZUPLO_FALLBACK_JSON_FILE = "zuplo.json";
5
5
  export const ZUPLO_CLI_XDG_FOLDER_NAME = "zup";
@@ -7,6 +7,8 @@ export const ZUPLO_AUTH_FILE_NAME = "auth.json";
7
7
  export const ZUPLO_VERSION_CHECK_FILE = "version.json";
8
8
  export const ZUPLO_SYSTEM_ENV_VAR = ".env.zuplo";
9
9
  export const DEPLOYER_METADATA_FILE = "deployer.json";
10
+ export const MAX_HASH_LENGTH = 7;
11
+ export const MAX_PRETTY_BRANCH_NAME = 10;
10
12
  export const ZUPLO_USER_ID_ARGV_KEY = "zuplo-user-id";
11
13
  export const TEST_IN_FOLDER = "tests";
12
14
  export const TEST_OUT_FOLDER = ".zuplo/__tests__";
@@ -14,4 +16,4 @@ export const SENTRY_DSN = "https://28220fd3185a1281daff09ade2114dca@o1036703.ing
14
16
  export const MAX_WAIT_PENDING_TIME_MS = 1000;
15
17
  export const POST_HOG_CAPTURE_KEY = "phc_LDSwSTOvIjiDDZql2g54Q7xEXoQ0EN9RMYb3STbdz1V";
16
18
  //# sourceMappingURL=constants.js.map
17
- //# debugId=4daebd3e-ec9e-5f97-947a-e83332c8499e
19
+ //# debugId=d26c033c-d06e-597b-b81e-6be1685fe906
@@ -0,0 +1,5 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b24fac48-2d44-5d0f-a34d-c45c7d2170a4")}catch(e){}}();
3
+ export {};
4
+ //# sourceMappingURL=types.js.map
5
+ //# debugId=b24fac48-2d44-5d0f-a34d-c45c7d2170a4
@@ -0,0 +1,14 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="93a448e8-d837-510e-bfcd-d02f063a75a0")}catch(e){}}();
3
+ export function normalizeUrl(url) {
4
+ let normalizedUrl = url;
5
+ if (!url.startsWith("http://") && !url.startsWith("https://")) {
6
+ normalizedUrl = `https://${url}`;
7
+ }
8
+ if (normalizedUrl.endsWith("/")) {
9
+ normalizedUrl = normalizedUrl.slice(0, -1);
10
+ }
11
+ return normalizedUrl;
12
+ }
13
+ //# sourceMappingURL=urls.js.map
14
+ //# debugId=93a448e8-d837-510e-bfcd-d02f063a75a0
@@ -1,30 +1,23 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e605d017-6ce7-5c84-9e5f-81d70ada98c0")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="644ba9e3-7f97-54dc-9902-564b509428ec")}catch(e){}}();
3
+ import { normalize } from "path";
3
4
  import { logger } from "../common/logger.js";
4
5
  import { printCriticalFailureToConsoleAndExit, printResultToConsoleAndExitGracefully, } from "../common/output.js";
5
6
  import settings from "../common/settings.js";
6
7
  import { pingDeployment } from "./poll-deployment.js";
7
8
  export async function deleteZup(argv) {
9
+ if (argv["self-hosted-endpoint"]) {
10
+ const args = argv;
11
+ await deleteFromSelfHosted(args);
12
+ }
13
+ else {
14
+ await deleteFromSaas(argv);
15
+ }
16
+ }
17
+ async function deleteFromSaas(argv) {
8
18
  let deploymentName;
9
19
  try {
10
- let url = argv.url;
11
- if (!/^(http:\/\/|https:\/\/)/i.test(argv.url)) {
12
- url = "https://" + url;
13
- }
14
- const parsedUrl = new URL(url);
15
- if (parsedUrl.username || parsedUrl.password) {
16
- logger.error(`Extra username and/or password was included in the URL.`);
17
- await printCriticalFailureToConsoleAndExit(`Error: Extraneous username and/or password in the URL. Only include the hostname.`);
18
- }
19
- if (parsedUrl.pathname !== "/") {
20
- logger.error(`Extra pathname was included in the URL: ${parsedUrl.pathname}`);
21
- await printCriticalFailureToConsoleAndExit(`Error: Extraneous pathname in URL: ${parsedUrl.pathname}. Only include the hostname.`);
22
- }
23
- if (parsedUrl.search !== "") {
24
- logger.error(`Extra search params were included in the URL: ${parsedUrl.search}`);
25
- await printCriticalFailureToConsoleAndExit(`Error: Extraneous search params in URL: ${parsedUrl.search}. Only include the hostname.`);
26
- }
27
- deploymentName = parsedUrl.hostname.split(".")[0];
20
+ deploymentName = await checkUrl(argv, deploymentName);
28
21
  }
29
22
  catch (err) {
30
23
  logger.error(err, "Failed to parse the URL");
@@ -60,5 +53,50 @@ export async function deleteZup(argv) {
60
53
  await printCriticalFailureToConsoleAndExit("Error: Failed to enqueue the deletion request. Try again later.");
61
54
  }
62
55
  }
56
+ async function deleteFromSelfHosted(argv) {
57
+ let deploymentName;
58
+ try {
59
+ deploymentName = await checkUrl(argv, deploymentName);
60
+ }
61
+ catch (err) {
62
+ logger.error(err, "Failed to parse the URL");
63
+ await printCriticalFailureToConsoleAndExit(`Error: Failed to parse the URL: ${argv.url}. Ensure you have entered a valid URL.`);
64
+ }
65
+ const endpoint = normalize(argv["self-hosted-endpoint"]);
66
+ const deleteResponse = await fetch(`${endpoint}/v1/deployments/${deploymentName}`, {
67
+ method: "DELETE",
68
+ headers: {
69
+ Authorization: `Bearer ${argv["api-key"]}`,
70
+ },
71
+ });
72
+ if (deleteResponse.ok) {
73
+ await printResultToConsoleAndExitGracefully(`Enqueued deletion of ${argv.url}`);
74
+ }
75
+ else {
76
+ logger.error(JSON.stringify(await deleteResponse.json(), null, 2), "Failed to upload to self-hosted build endpoint");
77
+ await printCriticalFailureToConsoleAndExit("Error: Failed to enqueue the deletion request. Try again later.");
78
+ }
79
+ }
80
+ async function checkUrl(argv, deploymentName) {
81
+ let url = argv.url;
82
+ if (!/^(http:\/\/|https:\/\/)/i.test(argv.url)) {
83
+ url = "https://" + url;
84
+ }
85
+ const parsedUrl = new URL(url);
86
+ if (parsedUrl.username || parsedUrl.password) {
87
+ logger.error(`Extra username and/or password was included in the URL.`);
88
+ await printCriticalFailureToConsoleAndExit(`Error: Extraneous username and/or password in the URL. Only include the hostname.`);
89
+ }
90
+ if (parsedUrl.pathname !== "/") {
91
+ logger.error(`Extra pathname was included in the URL: ${parsedUrl.pathname}`);
92
+ await printCriticalFailureToConsoleAndExit(`Error: Extraneous pathname in URL: ${parsedUrl.pathname}. Only include the hostname.`);
93
+ }
94
+ if (parsedUrl.search !== "") {
95
+ logger.error(`Extra search params were included in the URL: ${parsedUrl.search}`);
96
+ await printCriticalFailureToConsoleAndExit(`Error: Extraneous search params in URL: ${parsedUrl.search}. Only include the hostname.`);
97
+ }
98
+ deploymentName = parsedUrl.hostname.split(".")[0];
99
+ return deploymentName;
100
+ }
63
101
  //# sourceMappingURL=handler.js.map
64
- //# debugId=e605d017-6ce7-5c84-9e5f-81d70ada98c0
102
+ //# debugId=644ba9e3-7f97-54dc-9902-564b509428ec
@@ -1,13 +1,25 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ce3166fa-f448-54d8-834e-5b6b0999d341")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="cb40a32c-281e-5053-b199-7372a7cf977b")}catch(e){}}();
3
+ import { readFileSync } from "node:fs";
3
4
  import { parse } from "node:path";
5
+ import { MAX_PRETTY_BRANCH_NAME as MAX_PRETTY_BRANCH_LENGTH } from "../common/constants.js";
4
6
  import { logger } from "../common/logger.js";
5
7
  import { printCriticalFailureToConsoleAndExit, printDiagnosticsToConsole, printResultToConsoleAndExitGracefully, } from "../common/output.js";
6
8
  import settings from "../common/settings.js";
9
+ import { normalizeUrl } from "../common/utils/urls.js";
7
10
  import { ARCHIVE_EXTENSION, archive } from "./archive.js";
8
11
  import { upload } from "./file-upload.js";
9
- import { pollDeployment } from "./poll-deployment.js";
12
+ import { pollBuild, pollDeployment } from "./poll-deployment.js";
10
13
  export async function deploy(argv) {
14
+ if (argv["self-hosted-endpoint"]) {
15
+ const args = argv;
16
+ await deployToSelfHosted(args);
17
+ }
18
+ else {
19
+ await deployToSaas(argv);
20
+ }
21
+ }
22
+ async function deployToSaas(argv) {
11
23
  const archiveMetadata = await archive(argv);
12
24
  logger.debug(`Tarball created locally at ${archiveMetadata}`);
13
25
  const { account, project } = argv;
@@ -53,5 +65,56 @@ export async function deploy(argv) {
53
65
  await printCriticalFailureToConsoleAndExit("Error: Failed to determine where to upload your files. Try again later.");
54
66
  }
55
67
  }
68
+ async function deployToSelfHosted(argv) {
69
+ let endpoint = normalizeUrl(argv["self-hosted-endpoint"]);
70
+ const archiveMetadata = await archive(argv);
71
+ logger.debug(`Tarball created locally at ${archiveMetadata}`);
72
+ const { project } = argv;
73
+ const form = new FormData();
74
+ const deploymentName = `${project}-${getPrettyBranch(archiveMetadata.metadata.branch)}`;
75
+ form.set("file", new Blob([readFileSync(archiveMetadata.tarball)], {
76
+ type: "application/gzip",
77
+ }));
78
+ form.set("projectName", project);
79
+ form.set("deploymentName", deploymentName);
80
+ const uploadUrlResponse = await fetch(`${endpoint}/v1/deployments/build`, {
81
+ method: "POST",
82
+ headers: {
83
+ Authorization: `Bearer ${argv["api-key"]}`,
84
+ },
85
+ body: form,
86
+ });
87
+ if (uploadUrlResponse.ok) {
88
+ const { buildName } = await uploadUrlResponse.json();
89
+ const buildResult = await pollBuild(argv, endpoint, buildName);
90
+ if (buildResult.conditionType === "Complete") {
91
+ const deploymentResponse = await fetch(`${endpoint}/v1/deployments/${deploymentName}`, {
92
+ method: "GET",
93
+ headers: {
94
+ Authorization: `Bearer ${argv["api-key"]}`,
95
+ },
96
+ });
97
+ const deploymentJSON = await deploymentResponse.json();
98
+ await printResultToConsoleAndExitGracefully(`Deployed to ${deploymentJSON.deploymentUrl}`);
99
+ }
100
+ else {
101
+ await printCriticalFailureToConsoleAndExit(`Failed to deploy the current environment. Here's the diagnostics: ${JSON.stringify(buildResult)}`);
102
+ }
103
+ }
104
+ else {
105
+ logger.error(JSON.stringify(await uploadUrlResponse.json(), null, 2), "Failed to upload to self-hosted build endpoint");
106
+ await printCriticalFailureToConsoleAndExit("Error: Failed to upload to self-hosted build endpoint");
107
+ }
108
+ }
109
+ export const getPrettyBranch = (branch) => {
110
+ return (branch
111
+ .normalize("NFD")
112
+ .replace(/[\u0300-\u036f]/g, "")
113
+ .replace(/([^\w]+|\s+)/g, "-")
114
+ .replace(/\-\-+/g, "-")
115
+ .replace(/(^-+|-+$)/, "")
116
+ .toLowerCase()
117
+ .substring(0, MAX_PRETTY_BRANCH_LENGTH));
118
+ };
56
119
  //# sourceMappingURL=handler.js.map
57
- //# debugId=ce3166fa-f448-54d8-834e-5b6b0999d341
120
+ //# debugId=cb40a32c-281e-5053-b199-7372a7cf977b
@@ -1,7 +1,7 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3c3c35a5-25eb-5ed0-b613-ff502349f0f9")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ec7f237c-120f-50d6-88bf-a372ec1074b0")}catch(e){}}();
3
3
  import { logger } from "../common/logger.js";
4
- import { printDiagnosticsToConsole, textOrJson } from "../common/output.js";
4
+ import { printCriticalFailureToConsoleAndExit, printDiagnosticsToConsole, textOrJson, } from "../common/output.js";
5
5
  import settings from "../common/settings.js";
6
6
  function wait(duration = settings.POLL_INTERVAL) {
7
7
  return new Promise((resolve) => setTimeout(resolve, duration));
@@ -62,5 +62,50 @@ export async function pollDeployment(argv, fileId, account, project) {
62
62
  }
63
63
  return {};
64
64
  }
65
+ export async function pollBuild(argv, endpoint, buildName) {
66
+ const MAX_RETRY_ATTEMPTS_FOR_SERVER_UPDATES = 5;
67
+ let CURRENT_RETRY_ATTEMPTS_FOR_SERVER_UPDATES = 0;
68
+ for (let pollRetry = 0; pollRetry < settings.MAX_POLL_RETRIES; pollRetry++) {
69
+ printDiagnosticsToConsole(`Polling for deployment status... (${pollRetry}/${settings.MAX_POLL_RETRIES})`);
70
+ const response = await fetch(`${endpoint}/v1/deployments/build/${buildName}`, {
71
+ method: "GET",
72
+ headers: {
73
+ Authorization: `Bearer ${argv["api-key"]}`,
74
+ },
75
+ });
76
+ if (response.ok) {
77
+ const { conditionType, status, reason, message } = await response.json();
78
+ switch (conditionType) {
79
+ case "Complete":
80
+ case "Failed":
81
+ return {
82
+ conditionType,
83
+ status,
84
+ reason,
85
+ message,
86
+ };
87
+ default:
88
+ await wait();
89
+ continue;
90
+ }
91
+ }
92
+ else if (response.status === 404) {
93
+ await wait();
94
+ continue;
95
+ }
96
+ else if (response.status === 500 &&
97
+ CURRENT_RETRY_ATTEMPTS_FOR_SERVER_UPDATES <
98
+ MAX_RETRY_ATTEMPTS_FOR_SERVER_UPDATES) {
99
+ CURRENT_RETRY_ATTEMPTS_FOR_SERVER_UPDATES++;
100
+ await wait();
101
+ continue;
102
+ }
103
+ else {
104
+ logger.error(JSON.stringify(await response.json(), null, 2), "Failed to upload to self-hosted build endpoint");
105
+ await printCriticalFailureToConsoleAndExit("Error: Failed to upload to self-hosted build endpoint");
106
+ }
107
+ }
108
+ return {};
109
+ }
65
110
  //# sourceMappingURL=poll-deployment.js.map
66
- //# debugId=3c3c35a5-25eb-5ed0-b613-ff502349f0f9
111
+ //# debugId=ec7f237c-120f-50d6-88bf-a372ec1074b0
@@ -1,9 +1,19 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="2c0014d1-9750-52ee-a907-06d713524f2c")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9bf817d9-a39a-5f35-9cdf-764d79d64533")}catch(e){}}();
3
3
  import { logger } from "../common/logger.js";
4
- import { printDiagnosticsToConsole, printResultToConsoleAndExitGracefully, textOrJson, } from "../common/output.js";
4
+ import { printCriticalFailureToConsoleAndExit, printDiagnosticsToConsole, printResultToConsoleAndExitGracefully, textOrJson, } from "../common/output.js";
5
5
  import settings from "../common/settings.js";
6
+ import { normalizeUrl } from "../common/utils/urls.js";
6
7
  export async function list(argv) {
8
+ if (argv["self-hosted-endpoint"]) {
9
+ const args = argv;
10
+ await listFromSelfHosted(args);
11
+ }
12
+ else {
13
+ await listFromSaas(argv);
14
+ }
15
+ }
16
+ async function listFromSaas(argv) {
7
17
  const { account, project } = argv;
8
18
  const listResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/accounts/${account}/projects/${project}/deployments`, {
9
19
  method: "GET",
@@ -25,5 +35,25 @@ export async function list(argv) {
25
35
  printDiagnosticsToConsole("Error: Failed to list deployed zups. Try again later.");
26
36
  }
27
37
  }
38
+ async function listFromSelfHosted(argv) {
39
+ let endpoint = normalizeUrl(argv["self-hosted-endpoint"]);
40
+ const listResponse = await fetch(`${endpoint}/v1/deployments`, {
41
+ method: "GET",
42
+ headers: {
43
+ Authorization: `Bearer ${argv["api-key"]}`,
44
+ },
45
+ });
46
+ if (listResponse.ok) {
47
+ const { data: deployments } = await listResponse.json();
48
+ const output = deployments
49
+ .map((deployment) => deployment.deploymentUrl)
50
+ .join("\n");
51
+ await printResultToConsoleAndExitGracefully(output);
52
+ }
53
+ else {
54
+ logger.error(JSON.stringify(await listResponse.json(), null, 2), "Failed to upload to self-hosted build endpoint");
55
+ await printCriticalFailureToConsoleAndExit("Error: Failed to upload to self-hosted build endpoint");
56
+ }
57
+ }
28
58
  //# sourceMappingURL=handler.js.map
29
- //# debugId=2c0014d1-9750-52ee-a907-06d713524f2c
59
+ //# debugId=9bf817d9-a39a-5f35-9cdf-764d79d64533
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/cli",
3
- "version": "1.125.0",
3
+ "version": "1.126.0",
4
4
  "type": "module",
5
5
  "repository": "https://github.com/zuplo/cli",
6
6
  "description": "The command-line interface for Zuplo",
package/zup.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node --no-warnings
2
2
  /* eslint-disable */
3
3
  process.removeAllListeners("warning");
4
4
  import "./dist/cli.js";