@zuplo/cli 1.41.0 → 1.42.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.
- package/dist/cmds/delete.js +6 -1
- package/dist/cmds/deploy.js +2 -1
- package/dist/cmds/list.js +6 -1
- package/dist/cmds/tunnel/create.js +2 -1
- package/dist/cmds/tunnel/delete.js +2 -1
- package/dist/cmds/tunnel/describe.js +2 -1
- package/dist/cmds/tunnel/list.js +2 -1
- package/dist/cmds/tunnel/rotate-token.js +2 -1
- package/dist/cmds/tunnel/services/describe.js +2 -1
- package/dist/cmds/tunnel/services/update.js +2 -1
- package/dist/cmds/variable/create.js +6 -1
- package/dist/cmds/variable/update.js +4 -4
- package/dist/common/constants.js +2 -0
- package/dist/common/middleware/user-configuration.js +59 -0
- package/dist/delete/handler.js +16 -28
- package/dist/deploy/handler.js +24 -36
- package/dist/list/handler.js +12 -24
- package/dist/tunnel/create/handler.js +15 -27
- package/dist/tunnel/delete/handler.js +20 -32
- package/dist/tunnel/describe/handler.js +12 -24
- package/dist/tunnel/list/handler.js +18 -30
- package/dist/tunnel/rotate-token/handler.js +13 -25
- package/dist/tunnel/services/describe/handler.js +12 -24
- package/dist/tunnel/services/update/handler.js +29 -41
- package/dist/variable/create/handler.js +19 -31
- package/dist/variable/update/handler.js +17 -29
- package/package.json +2 -1
package/dist/cmds/delete.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { configure } from "../common/middleware/user-configuration.js";
|
|
1
2
|
import setBlocking from "../common/output.js";
|
|
2
3
|
import { deleteZup } from "../delete/handler.js";
|
|
3
4
|
export default {
|
|
@@ -13,6 +14,10 @@ export default {
|
|
|
13
14
|
.option("url", {
|
|
14
15
|
type: "string",
|
|
15
16
|
describe: "The URL of the zup to delete",
|
|
17
|
+
})
|
|
18
|
+
.option("project", {
|
|
19
|
+
type: "string",
|
|
20
|
+
describe: "The project name",
|
|
16
21
|
})
|
|
17
22
|
.option("wait", {
|
|
18
23
|
type: "boolean",
|
|
@@ -20,7 +25,7 @@ export default {
|
|
|
20
25
|
})
|
|
21
26
|
.boolean("wait")
|
|
22
27
|
.demandOption(["api-key", "url"])
|
|
23
|
-
.middleware([setBlocking]);
|
|
28
|
+
.middleware([setBlocking, configure]);
|
|
24
29
|
},
|
|
25
30
|
handler: async (argv) => {
|
|
26
31
|
await deleteZup(argv);
|
package/dist/cmds/deploy.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { configure } from "../common/middleware/user-configuration.js";
|
|
1
2
|
import setBlocking from "../common/output.js";
|
|
2
3
|
import { validDeployDirectoryValidator } from "../common/validators/file-system-validator.js";
|
|
3
4
|
import { YargsChecker } from "../common/validators/lib.js";
|
|
@@ -29,7 +30,7 @@ export default {
|
|
|
29
30
|
.check(async (argv) => {
|
|
30
31
|
return await new YargsChecker(validDeployDirectoryValidator).check(argv.dir);
|
|
31
32
|
})
|
|
32
|
-
.middleware([setBlocking]);
|
|
33
|
+
.middleware([setBlocking, configure]);
|
|
33
34
|
},
|
|
34
35
|
handler: async (argv) => {
|
|
35
36
|
await deploy(argv);
|
package/dist/cmds/list.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { configure } from "../common/middleware/user-configuration.js";
|
|
1
2
|
import setBlocking from "../common/output.js";
|
|
2
3
|
import { list } from "../list/handler.js";
|
|
3
4
|
export default {
|
|
@@ -9,9 +10,13 @@ export default {
|
|
|
9
10
|
type: "string",
|
|
10
11
|
describe: "The API Key from Zuplo",
|
|
11
12
|
envVar: "API_KEY",
|
|
13
|
+
})
|
|
14
|
+
.option("project", {
|
|
15
|
+
type: "string",
|
|
16
|
+
describe: "The project name",
|
|
12
17
|
})
|
|
13
18
|
.demandOption(["api-key"])
|
|
14
|
-
.middleware([setBlocking]);
|
|
19
|
+
.middleware([setBlocking, configure]);
|
|
15
20
|
},
|
|
16
21
|
handler: async (argv) => {
|
|
17
22
|
await list(argv);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { configure } from "../../common/middleware/user-configuration.js";
|
|
1
2
|
import setBlocking from "../../common/output.js";
|
|
2
3
|
import { create } from "../../tunnel/create/handler.js";
|
|
3
4
|
export default {
|
|
@@ -15,7 +16,7 @@ export default {
|
|
|
15
16
|
envVar: "API_KEY",
|
|
16
17
|
})
|
|
17
18
|
.demandOption(["api-key", "tunnel-name"])
|
|
18
|
-
.middleware([setBlocking]);
|
|
19
|
+
.middleware([setBlocking, configure]);
|
|
19
20
|
},
|
|
20
21
|
handler: async (argv) => {
|
|
21
22
|
create(argv);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { configure } from "../../common/middleware/user-configuration.js";
|
|
1
2
|
import setBlocking from "../../common/output.js";
|
|
2
3
|
import { deleteTunnel } from "../../tunnel/delete/handler.js";
|
|
3
4
|
export default {
|
|
@@ -11,7 +12,7 @@ export default {
|
|
|
11
12
|
envVar: "API_KEY",
|
|
12
13
|
})
|
|
13
14
|
.demandOption(["api-key"])
|
|
14
|
-
.middleware([setBlocking]);
|
|
15
|
+
.middleware([setBlocking, configure]);
|
|
15
16
|
},
|
|
16
17
|
handler: async (argv) => {
|
|
17
18
|
deleteTunnel(argv);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { configure } from "../../common/middleware/user-configuration.js";
|
|
1
2
|
import setBlocking from "../../common/output.js";
|
|
2
3
|
import { describe } from "../../tunnel/describe/handler.js";
|
|
3
4
|
export default {
|
|
@@ -15,7 +16,7 @@ export default {
|
|
|
15
16
|
envVar: "API_KEY",
|
|
16
17
|
})
|
|
17
18
|
.demandOption(["api-key", "tunnel-id"])
|
|
18
|
-
.middleware([setBlocking]);
|
|
19
|
+
.middleware([setBlocking, configure]);
|
|
19
20
|
},
|
|
20
21
|
handler: async (argv) => {
|
|
21
22
|
describe(argv);
|
package/dist/cmds/tunnel/list.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { configure } from "../../common/middleware/user-configuration.js";
|
|
1
2
|
import setBlocking from "../../common/output.js";
|
|
2
3
|
import { list } from "../../tunnel/list/handler.js";
|
|
3
4
|
export default {
|
|
@@ -11,7 +12,7 @@ export default {
|
|
|
11
12
|
envVar: "API_KEY",
|
|
12
13
|
})
|
|
13
14
|
.demandOption(["api-key"])
|
|
14
|
-
.middleware([setBlocking]);
|
|
15
|
+
.middleware([setBlocking, configure]);
|
|
15
16
|
},
|
|
16
17
|
handler: async (argv) => {
|
|
17
18
|
await list(argv);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { configure } from "../../common/middleware/user-configuration.js";
|
|
1
2
|
import setBlocking from "../../common/output.js";
|
|
2
3
|
import { rotateToken } from "../../tunnel/rotate-token/handler.js";
|
|
3
4
|
export default {
|
|
@@ -15,7 +16,7 @@ export default {
|
|
|
15
16
|
envVar: "API_KEY",
|
|
16
17
|
})
|
|
17
18
|
.demandOption(["api-key", "tunnel-id"])
|
|
18
|
-
.middleware([setBlocking]);
|
|
19
|
+
.middleware([setBlocking, configure]);
|
|
19
20
|
},
|
|
20
21
|
handler: async (argv) => {
|
|
21
22
|
rotateToken(argv);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { configure } from "../../../common/middleware/user-configuration.js";
|
|
1
2
|
import setBlocking from "../../../common/output.js";
|
|
2
3
|
import { describe, } from "../../../tunnel/services/describe/handler.js";
|
|
3
4
|
export default {
|
|
@@ -15,7 +16,7 @@ export default {
|
|
|
15
16
|
envVar: "API_KEY",
|
|
16
17
|
})
|
|
17
18
|
.demandOption(["api-key", "tunnel-id"])
|
|
18
|
-
.middleware([setBlocking]);
|
|
19
|
+
.middleware([setBlocking, configure]);
|
|
19
20
|
},
|
|
20
21
|
handler: async (argv) => {
|
|
21
22
|
describe(argv);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { configure } from "../../../common/middleware/user-configuration.js";
|
|
1
2
|
import setBlocking from "../../../common/output.js";
|
|
2
3
|
import { updateServices, } from "../../../tunnel/services/update/handler.js";
|
|
3
4
|
export default {
|
|
@@ -19,7 +20,7 @@ export default {
|
|
|
19
20
|
envVar: "API_KEY",
|
|
20
21
|
})
|
|
21
22
|
.demandOption(["api-key", "configuration-file", "tunnel-id"])
|
|
22
|
-
.middleware([setBlocking]);
|
|
23
|
+
.middleware([setBlocking, configure]);
|
|
23
24
|
},
|
|
24
25
|
handler: async (argv) => {
|
|
25
26
|
updateServices(argv);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { configure } from "../../common/middleware/user-configuration.js";
|
|
1
2
|
import setBlocking from "../../common/output.js";
|
|
2
3
|
import { create } from "../../variable/create/handler.js";
|
|
3
4
|
export default {
|
|
@@ -25,9 +26,13 @@ export default {
|
|
|
25
26
|
type: "string",
|
|
26
27
|
describe: "The API Key from Zuplo",
|
|
27
28
|
envVar: "API_KEY",
|
|
29
|
+
})
|
|
30
|
+
.option("project", {
|
|
31
|
+
type: "string",
|
|
32
|
+
describe: "The project name",
|
|
28
33
|
})
|
|
29
34
|
.demandOption(["api-key", "name", "value", "is-secret", "branch"])
|
|
30
|
-
.middleware([setBlocking]);
|
|
35
|
+
.middleware([setBlocking, configure]);
|
|
31
36
|
},
|
|
32
37
|
handler: async (argv) => {
|
|
33
38
|
create(argv);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { configure } from "../../common/middleware/user-configuration.js";
|
|
1
2
|
import setBlocking from "../../common/output.js";
|
|
2
3
|
import { update } from "../../variable/update/handler.js";
|
|
3
4
|
export default {
|
|
@@ -17,13 +18,12 @@ export default {
|
|
|
17
18
|
type: "string",
|
|
18
19
|
describe: "The branch where the variable exists",
|
|
19
20
|
})
|
|
20
|
-
.option("
|
|
21
|
+
.option("project", {
|
|
21
22
|
type: "string",
|
|
22
|
-
describe: "The
|
|
23
|
-
envVar: "API_KEY",
|
|
23
|
+
describe: "The project name",
|
|
24
24
|
})
|
|
25
25
|
.demandOption(["api-key", "name", "value", "branch"])
|
|
26
|
-
.middleware([setBlocking]);
|
|
26
|
+
.middleware([setBlocking, configure]);
|
|
27
27
|
},
|
|
28
28
|
handler: async (argv) => {
|
|
29
29
|
update(argv);
|
package/dist/common/constants.js
CHANGED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { parse } from "jsonc-parser";
|
|
2
|
+
import { existsSync } from "node:fs";
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
4
|
+
import { resolve } from "node:path";
|
|
5
|
+
import { ZUPLO_FALLBACK_JSON_FILE, ZUPLO_PREFERRED_JSON_FILE, } from "../constants.js";
|
|
6
|
+
import { logger } from "../logger.js";
|
|
7
|
+
import { printCriticalFailureToConsoleAndExit } from "../output.js";
|
|
8
|
+
import settings from "../settings.js";
|
|
9
|
+
export async function configure(argv) {
|
|
10
|
+
const cliParametersConfiguration = { ...argv };
|
|
11
|
+
const whoAmIResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/who-am-i`, {
|
|
12
|
+
method: "GET",
|
|
13
|
+
headers: {
|
|
14
|
+
Authorization: `Bearer ${argv["api-key"]}`,
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
if (whoAmIResponse.ok) {
|
|
18
|
+
const apiKeyMetadata = await whoAmIResponse.json();
|
|
19
|
+
Object.assign(argv, omitNull(apiKeyMetadata));
|
|
20
|
+
const { project: zuploJsoncProject } = await processZuploConfigurationFile();
|
|
21
|
+
if (zuploJsoncProject) {
|
|
22
|
+
argv.project = zuploJsoncProject;
|
|
23
|
+
}
|
|
24
|
+
Object.assign(argv, cliParametersConfiguration);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
logger.trace({ status: whoAmIResponse.status, statusText: whoAmIResponse.statusText }, "Failed to determine who-am-i");
|
|
28
|
+
printCriticalFailureToConsoleAndExit("Error: Failed to validate the API key. Check your API key.");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async function processZuploConfigurationFile() {
|
|
32
|
+
const preferredPath = resolve(".", ZUPLO_PREFERRED_JSON_FILE);
|
|
33
|
+
const fallbackPath = resolve(".", ZUPLO_FALLBACK_JSON_FILE);
|
|
34
|
+
let fileContents = "{}";
|
|
35
|
+
if (existsSync(preferredPath)) {
|
|
36
|
+
fileContents = await readFile(preferredPath, "utf-8");
|
|
37
|
+
}
|
|
38
|
+
else if (existsSync(fallbackPath)) {
|
|
39
|
+
fileContents = await readFile(fallbackPath, "utf-8");
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
logger.trace("No zuplo.jsonc file found");
|
|
43
|
+
return {};
|
|
44
|
+
}
|
|
45
|
+
const errors = [];
|
|
46
|
+
const data = parse(fileContents, errors);
|
|
47
|
+
if (errors.length > 0) {
|
|
48
|
+
logger.trace(errors[0], "Failed to parse zuplo.jsonc");
|
|
49
|
+
printCriticalFailureToConsoleAndExit("Error: Failed to parse the values from zuplo.jsonc. Check your zuplo.jsonc file.");
|
|
50
|
+
}
|
|
51
|
+
return data;
|
|
52
|
+
}
|
|
53
|
+
let omitNull = (obj) => {
|
|
54
|
+
Object.keys(obj)
|
|
55
|
+
.filter((k) => obj[k] === null)
|
|
56
|
+
.forEach((k) => delete obj[k]);
|
|
57
|
+
return obj;
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=user-configuration.js.map
|
package/dist/delete/handler.js
CHANGED
|
@@ -28,46 +28,34 @@ export async function deleteZup(argv) {
|
|
|
28
28
|
logger.error(err, "Failed to parse the URL");
|
|
29
29
|
printCriticalFailureToConsoleAndExit(`Error: Failed to parse the URL: ${argv.url}. Ensure you have entered a valid URL.`);
|
|
30
30
|
}
|
|
31
|
-
const
|
|
32
|
-
|
|
31
|
+
const { account, project } = argv;
|
|
32
|
+
const deleteResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/accounts/${account}/projects/${project}/deployments/${deploymentName}`, {
|
|
33
|
+
method: "DELETE",
|
|
33
34
|
headers: {
|
|
34
35
|
Authorization: `Bearer ${argv["api-key"]}`,
|
|
35
36
|
},
|
|
36
37
|
});
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
if (deleteResponse.ok) {
|
|
46
|
-
if (argv.wait) {
|
|
47
|
-
const deleted = await pingDeployment(argv);
|
|
48
|
-
if (!deleted) {
|
|
49
|
-
logger.error(`Failed to confirm deletion of zup within alloted time frame.`);
|
|
50
|
-
printCriticalFailureToConsoleAndExit(`Error: Failed to confirm deletion of zup within alloted time frame of ${settings.MAX_POLL_RETRIES * settings.POLL_INTERVAL} ms. Your zup is still be available at ${argv.url}.`);
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
printResultToConsoleAndExitGracefully(`Deleted ${argv.url}`);
|
|
54
|
-
}
|
|
38
|
+
if (deleteResponse.ok) {
|
|
39
|
+
if (argv.wait) {
|
|
40
|
+
const deleted = await pingDeployment(argv);
|
|
41
|
+
if (!deleted) {
|
|
42
|
+
logger.error(`Failed to confirm deletion of zup within alloted time frame.`);
|
|
43
|
+
printCriticalFailureToConsoleAndExit(`Error: Failed to confirm deletion of zup within alloted time frame of ${settings.MAX_POLL_RETRIES * settings.POLL_INTERVAL} ms. Your zup is still be available at ${argv.url}.`);
|
|
55
44
|
}
|
|
56
45
|
else {
|
|
57
|
-
printResultToConsoleAndExitGracefully(`
|
|
46
|
+
printResultToConsoleAndExitGracefully(`Deleted ${argv.url}`);
|
|
58
47
|
}
|
|
59
48
|
}
|
|
60
49
|
else {
|
|
61
|
-
|
|
62
|
-
status: deleteResponse.status,
|
|
63
|
-
statusText: deleteResponse.statusText,
|
|
64
|
-
}, "Failed to enqueue the deletion request");
|
|
65
|
-
printCriticalFailureToConsoleAndExit("Error: Failed to enqueue the deletion request. Try again later.");
|
|
50
|
+
printResultToConsoleAndExitGracefully(`Enqueued deletion of ${argv.url}`);
|
|
66
51
|
}
|
|
67
52
|
}
|
|
68
53
|
else {
|
|
69
|
-
logger.error({
|
|
70
|
-
|
|
54
|
+
logger.error({
|
|
55
|
+
status: deleteResponse.status,
|
|
56
|
+
statusText: deleteResponse.statusText,
|
|
57
|
+
}, "Failed to enqueue the deletion request");
|
|
58
|
+
printCriticalFailureToConsoleAndExit("Error: Failed to enqueue the deletion request. Try again later.");
|
|
71
59
|
}
|
|
72
60
|
}
|
|
73
61
|
//# sourceMappingURL=handler.js.map
|
package/dist/deploy/handler.js
CHANGED
|
@@ -2,60 +2,48 @@ import { parse } from "path";
|
|
|
2
2
|
import { logger } from "../common/logger.js";
|
|
3
3
|
import { printCriticalFailureToConsoleAndExit, printDiagnosticsToConsole, printResultToConsoleAndExitGracefully, } from "../common/output.js";
|
|
4
4
|
import settings from "../common/settings.js";
|
|
5
|
-
import {
|
|
5
|
+
import { ARCHIVE_EXTENSION, archive } from "./archive.js";
|
|
6
6
|
import { upload } from "./file-upload.js";
|
|
7
7
|
import { pollDeployment } from "./poll-deployment.js";
|
|
8
8
|
export async function deploy(argv) {
|
|
9
9
|
const archiveMetadata = await archive(argv);
|
|
10
10
|
logger.info(`Tarball created locally at ${archiveMetadata}`);
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
const { account, project } = argv;
|
|
12
|
+
const uploadUrlResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/accounts/${account}/projects/${project}/sources`, {
|
|
13
|
+
method: "POST",
|
|
13
14
|
headers: {
|
|
14
15
|
Authorization: `Bearer ${argv["api-key"]}`,
|
|
15
16
|
},
|
|
16
17
|
});
|
|
17
|
-
if (
|
|
18
|
-
const {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const { uploadUrl } = await uploadUrlResponse.json();
|
|
27
|
-
const uploadResponse = await upload(archiveMetadata.tarball, uploadUrl);
|
|
28
|
-
if (uploadResponse.ok) {
|
|
29
|
-
printDiagnosticsToConsole(`Deploying the current branch ${archiveMetadata.metadata.branch} to project ${project} on account ${account}...`);
|
|
30
|
-
const fileId = parse(new URL(uploadUrl).pathname).base.replace(ARCHIVE_EXTENSION, "");
|
|
31
|
-
const { url, steps, buildResult } = await pollDeployment(argv, fileId, account, project);
|
|
32
|
-
if (url) {
|
|
33
|
-
printResultToConsoleAndExitGracefully(`Deployed to ${url}`);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
const diagnostics = buildResult ?? steps;
|
|
37
|
-
printCriticalFailureToConsoleAndExit(`Failed to deploy the current branch ${archiveMetadata.metadata.branch} to project ${project} on account ${account}. Here's the diagnostics: ${JSON.stringify(diagnostics, null, 2)}`);
|
|
38
|
-
}
|
|
18
|
+
if (uploadUrlResponse.ok) {
|
|
19
|
+
const { uploadUrl } = await uploadUrlResponse.json();
|
|
20
|
+
const uploadResponse = await upload(archiveMetadata.tarball, uploadUrl);
|
|
21
|
+
if (uploadResponse.ok) {
|
|
22
|
+
printDiagnosticsToConsole(`Deploying the current branch ${archiveMetadata.metadata.branch} to project ${project} on account ${account}...`);
|
|
23
|
+
const fileId = parse(new URL(uploadUrl).pathname).base.replace(ARCHIVE_EXTENSION, "");
|
|
24
|
+
const { url, steps, buildResult } = await pollDeployment(argv, fileId, account, project);
|
|
25
|
+
if (url) {
|
|
26
|
+
printResultToConsoleAndExitGracefully(`Deployed to ${url}`);
|
|
39
27
|
}
|
|
40
28
|
else {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
statusText: uploadResponse.statusText,
|
|
44
|
-
}, "Failed to upload source to cloud storage");
|
|
45
|
-
printDiagnosticsToConsole("Error: Failed to upload source to cloud storage. Try again later.");
|
|
29
|
+
const diagnostics = buildResult ?? steps;
|
|
30
|
+
printCriticalFailureToConsoleAndExit(`Failed to deploy the current branch ${archiveMetadata.metadata.branch} to project ${project} on account ${account}. Here's the diagnostics: ${JSON.stringify(diagnostics, null, 2)}`);
|
|
46
31
|
}
|
|
47
32
|
}
|
|
48
33
|
else {
|
|
49
34
|
logger.error({
|
|
50
|
-
status:
|
|
51
|
-
statusText:
|
|
52
|
-
}, "Failed to
|
|
53
|
-
|
|
35
|
+
status: uploadResponse.status,
|
|
36
|
+
statusText: uploadResponse.statusText,
|
|
37
|
+
}, "Failed to upload source to cloud storage");
|
|
38
|
+
printDiagnosticsToConsole("Error: Failed to upload source to cloud storage. Try again later.");
|
|
54
39
|
}
|
|
55
40
|
}
|
|
56
41
|
else {
|
|
57
|
-
logger.error({
|
|
58
|
-
|
|
42
|
+
logger.error({
|
|
43
|
+
status: uploadUrlResponse.status,
|
|
44
|
+
statusText: uploadUrlResponse.statusText,
|
|
45
|
+
}, "Failed to retrieve uploadUrl");
|
|
46
|
+
printCriticalFailureToConsoleAndExit("Error: Failed to determine where to upload your files. Try again later.");
|
|
59
47
|
}
|
|
60
48
|
}
|
|
61
49
|
//# sourceMappingURL=handler.js.map
|
package/dist/list/handler.js
CHANGED
|
@@ -1,37 +1,25 @@
|
|
|
1
1
|
import { logger } from "../common/logger.js";
|
|
2
|
-
import {
|
|
2
|
+
import { printDiagnosticsToConsole, printResultToConsoleAndExitGracefully, } from "../common/output.js";
|
|
3
3
|
import settings from "../common/settings.js";
|
|
4
4
|
export async function list(argv) {
|
|
5
|
-
const
|
|
5
|
+
const { account, project } = argv;
|
|
6
|
+
const listResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/accounts/${account}/projects/${project}/deployments`, {
|
|
6
7
|
method: "GET",
|
|
7
8
|
headers: {
|
|
8
9
|
Authorization: `Bearer ${argv["api-key"]}`,
|
|
9
10
|
},
|
|
10
11
|
});
|
|
11
|
-
if (
|
|
12
|
-
const {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
headers: {
|
|
16
|
-
Authorization: `Bearer ${argv["api-key"]}`,
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
if (listResponse.ok) {
|
|
20
|
-
const { data: deployments } = await listResponse.json();
|
|
21
|
-
const output = deployments.map((deployment) => deployment.url).join("\n");
|
|
22
|
-
printResultToConsoleAndExitGracefully(output);
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
logger.error({
|
|
26
|
-
status: listResponse.status,
|
|
27
|
-
statusText: listResponse.statusText,
|
|
28
|
-
}, "Failed to list deployed zups");
|
|
29
|
-
printDiagnosticsToConsole("Error: Failed to list deployed zups. Try again later.");
|
|
30
|
-
}
|
|
12
|
+
if (listResponse.ok) {
|
|
13
|
+
const { data: deployments } = await listResponse.json();
|
|
14
|
+
const output = deployments.map((deployment) => deployment.url).join("\n");
|
|
15
|
+
printResultToConsoleAndExitGracefully(output);
|
|
31
16
|
}
|
|
32
17
|
else {
|
|
33
|
-
logger.error({
|
|
34
|
-
|
|
18
|
+
logger.error({
|
|
19
|
+
status: listResponse.status,
|
|
20
|
+
statusText: listResponse.statusText,
|
|
21
|
+
}, "Failed to list deployed zups");
|
|
22
|
+
printDiagnosticsToConsole("Error: Failed to list deployed zups. Try again later.");
|
|
35
23
|
}
|
|
36
24
|
}
|
|
37
25
|
//# sourceMappingURL=handler.js.map
|
|
@@ -1,39 +1,27 @@
|
|
|
1
1
|
import { logger } from "../../common/logger.js";
|
|
2
|
-
import {
|
|
2
|
+
import { printDiagnosticsToConsole, printTableToConsoleAndExitGracefully, } from "../../common/output.js";
|
|
3
3
|
import settings from "../../common/settings.js";
|
|
4
4
|
export async function create(argv) {
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const { account } = argv;
|
|
6
|
+
const createResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/accounts/${account}/tunnels`, {
|
|
7
|
+
method: "POST",
|
|
7
8
|
headers: {
|
|
8
9
|
Authorization: `Bearer ${argv["api-key"]}`,
|
|
10
|
+
"Content-Type": "application/json",
|
|
9
11
|
},
|
|
12
|
+
body: JSON.stringify({ name: argv["tunnel-name"] }),
|
|
10
13
|
});
|
|
11
|
-
if (
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
method: "POST",
|
|
15
|
-
headers: {
|
|
16
|
-
Authorization: `Bearer ${argv["api-key"]}`,
|
|
17
|
-
"Content-Type": "application/json",
|
|
18
|
-
},
|
|
19
|
-
body: JSON.stringify({ name: argv["tunnel-name"] }),
|
|
20
|
-
});
|
|
21
|
-
if (createResponse.ok) {
|
|
22
|
-
const tunnel = await createResponse.json();
|
|
23
|
-
printTableToConsoleAndExitGracefully(tunnel);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
logger.error({
|
|
27
|
-
status: createResponse.status,
|
|
28
|
-
statusText: createResponse.statusText,
|
|
29
|
-
response: await createResponse.text(),
|
|
30
|
-
}, "Failed to create tunnel for account");
|
|
31
|
-
printDiagnosticsToConsole("Error: Failed to create tunnel for your account. Check the arguments.");
|
|
32
|
-
}
|
|
14
|
+
if (createResponse.ok) {
|
|
15
|
+
const tunnel = await createResponse.json();
|
|
16
|
+
printTableToConsoleAndExitGracefully(tunnel);
|
|
33
17
|
}
|
|
34
18
|
else {
|
|
35
|
-
logger.error({
|
|
36
|
-
|
|
19
|
+
logger.error({
|
|
20
|
+
status: createResponse.status,
|
|
21
|
+
statusText: createResponse.statusText,
|
|
22
|
+
response: await createResponse.text(),
|
|
23
|
+
}, "Failed to create tunnel for account");
|
|
24
|
+
printDiagnosticsToConsole("Error: Failed to create tunnel for your account. Check the arguments.");
|
|
37
25
|
}
|
|
38
26
|
}
|
|
39
27
|
//# sourceMappingURL=handler.js.map
|
|
@@ -3,48 +3,36 @@ import { printCriticalFailureToConsoleAndExit, printDiagnosticsToConsole, printR
|
|
|
3
3
|
import settings from "../../common/settings.js";
|
|
4
4
|
import { pollTeardownOperation } from "./poll-teardown-operation.js";
|
|
5
5
|
export async function deleteTunnel(argv) {
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const { account } = argv;
|
|
7
|
+
const deleteResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/accounts/${account}/tunnels/${argv["tunnel-id"]}`, {
|
|
8
|
+
method: "DELETE",
|
|
8
9
|
headers: {
|
|
9
10
|
Authorization: `Bearer ${argv["api-key"]}`,
|
|
10
11
|
},
|
|
11
12
|
});
|
|
12
|
-
if (
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
if (deleteResponse.ok) {
|
|
14
|
+
const teardownOperation = await deleteResponse.json();
|
|
15
|
+
printDiagnosticsToConsole(`Deleting tunnel ${argv["tunnel-id"]} on account ${account}...`);
|
|
16
|
+
const polledTearDownOperation = await pollTeardownOperation({
|
|
17
|
+
argv,
|
|
18
|
+
account,
|
|
19
|
+
teardownOperationId: teardownOperation.id,
|
|
19
20
|
});
|
|
20
|
-
if (
|
|
21
|
-
|
|
22
|
-
printDiagnosticsToConsole(`Deleting tunnel ${argv["tunnel-id"]} on account ${account}...`);
|
|
23
|
-
const polledTearDownOperation = await pollTeardownOperation({
|
|
24
|
-
argv,
|
|
25
|
-
account,
|
|
26
|
-
teardownOperationId: teardownOperation.id,
|
|
27
|
-
});
|
|
28
|
-
if (polledTearDownOperation.status === "success") {
|
|
29
|
-
printResultToConsoleAndExitGracefully(`Tunnel ${argv["tunnel-id"]} deleted successfully.`);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
printDiagnosticsToConsole(polledTearDownOperation.details);
|
|
33
|
-
printCriticalFailureToConsoleAndExit(`Tunnel ${argv["tunnel-id"]} failed to delete. Here's the error: ${polledTearDownOperation.message}`);
|
|
34
|
-
}
|
|
21
|
+
if (polledTearDownOperation.status === "success") {
|
|
22
|
+
printResultToConsoleAndExitGracefully(`Tunnel ${argv["tunnel-id"]} deleted successfully.`);
|
|
35
23
|
}
|
|
36
24
|
else {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
statusText: deleteResponse.statusText,
|
|
40
|
-
response: await deleteResponse.text(),
|
|
41
|
-
}, "Failed to delete tunnel for account");
|
|
42
|
-
printDiagnosticsToConsole("Error: Failed to delete the tunnel for your account. Check the arguments.");
|
|
25
|
+
printDiagnosticsToConsole(polledTearDownOperation.details);
|
|
26
|
+
printCriticalFailureToConsoleAndExit(`Tunnel ${argv["tunnel-id"]} failed to delete. Here's the error: ${polledTearDownOperation.message}`);
|
|
43
27
|
}
|
|
44
28
|
}
|
|
45
29
|
else {
|
|
46
|
-
logger.error({
|
|
47
|
-
|
|
30
|
+
logger.error({
|
|
31
|
+
status: deleteResponse.status,
|
|
32
|
+
statusText: deleteResponse.statusText,
|
|
33
|
+
response: await deleteResponse.text(),
|
|
34
|
+
}, "Failed to delete tunnel for account");
|
|
35
|
+
printDiagnosticsToConsole("Error: Failed to delete the tunnel for your account. Check the arguments.");
|
|
48
36
|
}
|
|
49
37
|
}
|
|
50
38
|
//# sourceMappingURL=handler.js.map
|
|
@@ -1,37 +1,25 @@
|
|
|
1
1
|
import { logger } from "../../common/logger.js";
|
|
2
|
-
import {
|
|
2
|
+
import { printDiagnosticsToConsole, printTableToConsoleAndExitGracefully, } from "../../common/output.js";
|
|
3
3
|
import settings from "../../common/settings.js";
|
|
4
4
|
export async function describe(argv) {
|
|
5
|
-
const
|
|
5
|
+
const { account } = argv;
|
|
6
|
+
const describeResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/accounts/${account}/tunnels/${argv["tunnel-id"]}`, {
|
|
6
7
|
method: "GET",
|
|
7
8
|
headers: {
|
|
8
9
|
Authorization: `Bearer ${argv["api-key"]}`,
|
|
9
10
|
},
|
|
10
11
|
});
|
|
11
|
-
if (
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
method: "GET",
|
|
15
|
-
headers: {
|
|
16
|
-
Authorization: `Bearer ${argv["api-key"]}`,
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
if (describeResponse.ok) {
|
|
20
|
-
const tunnel = await describeResponse.json();
|
|
21
|
-
printTableToConsoleAndExitGracefully(tunnel);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
logger.error({
|
|
25
|
-
status: describeResponse.status,
|
|
26
|
-
statusText: describeResponse.statusText,
|
|
27
|
-
response: await describeResponse.text(),
|
|
28
|
-
}, "Failed to describe tunnel for account");
|
|
29
|
-
printDiagnosticsToConsole("Error: Failed to describe tunnel for your account. Check the arguments.");
|
|
30
|
-
}
|
|
12
|
+
if (describeResponse.ok) {
|
|
13
|
+
const tunnel = await describeResponse.json();
|
|
14
|
+
printTableToConsoleAndExitGracefully(tunnel);
|
|
31
15
|
}
|
|
32
16
|
else {
|
|
33
|
-
logger.error({
|
|
34
|
-
|
|
17
|
+
logger.error({
|
|
18
|
+
status: describeResponse.status,
|
|
19
|
+
statusText: describeResponse.statusText,
|
|
20
|
+
response: await describeResponse.text(),
|
|
21
|
+
}, "Failed to describe tunnel for account");
|
|
22
|
+
printDiagnosticsToConsole("Error: Failed to describe tunnel for your account. Check the arguments.");
|
|
35
23
|
}
|
|
36
24
|
}
|
|
37
25
|
//# sourceMappingURL=handler.js.map
|
|
@@ -1,46 +1,34 @@
|
|
|
1
1
|
import { logger } from "../../common/logger.js";
|
|
2
|
-
import {
|
|
2
|
+
import { printDiagnosticsToConsole, printResultToConsoleAndExitGracefully, printTableToConsoleAndExitGracefully, } from "../../common/output.js";
|
|
3
3
|
import settings from "../../common/settings.js";
|
|
4
4
|
export async function list(argv) {
|
|
5
|
-
const
|
|
5
|
+
const { account } = await argv;
|
|
6
|
+
const listResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/accounts/${account}/tunnels`, {
|
|
6
7
|
method: "GET",
|
|
7
8
|
headers: {
|
|
8
9
|
Authorization: `Bearer ${argv["api-key"]}`,
|
|
9
10
|
},
|
|
10
11
|
});
|
|
11
|
-
if (
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
Authorization: `Bearer ${argv["api-key"]}`,
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
if (listResponse.ok) {
|
|
20
|
-
const tunnels = await listResponse.json();
|
|
21
|
-
if (tunnels.data.length === 0) {
|
|
22
|
-
const output = "No tunnels found";
|
|
23
|
-
printResultToConsoleAndExitGracefully(output);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
const table = tunnels.data.map((tunnel) => {
|
|
27
|
-
return { "tunnel-id": tunnel.id, name: tunnel.name };
|
|
28
|
-
});
|
|
29
|
-
printTableToConsoleAndExitGracefully(table);
|
|
30
|
-
}
|
|
12
|
+
if (listResponse.ok) {
|
|
13
|
+
const tunnels = await listResponse.json();
|
|
14
|
+
if (tunnels.data.length === 0) {
|
|
15
|
+
const output = "No tunnels found";
|
|
16
|
+
printResultToConsoleAndExitGracefully(output);
|
|
31
17
|
}
|
|
32
18
|
else {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}, "Failed to list tunnels for account");
|
|
38
|
-
printDiagnosticsToConsole("Error: Failed to list tunnels for your account. Try again later.");
|
|
19
|
+
const table = tunnels.data.map((tunnel) => {
|
|
20
|
+
return { "tunnel-id": tunnel.id, name: tunnel.name };
|
|
21
|
+
});
|
|
22
|
+
printTableToConsoleAndExitGracefully(table);
|
|
39
23
|
}
|
|
40
24
|
}
|
|
41
25
|
else {
|
|
42
|
-
logger.error({
|
|
43
|
-
|
|
26
|
+
logger.error({
|
|
27
|
+
status: listResponse.status,
|
|
28
|
+
statusText: listResponse.statusText,
|
|
29
|
+
response: await listResponse.text(),
|
|
30
|
+
}, "Failed to list tunnels for account");
|
|
31
|
+
printDiagnosticsToConsole("Error: Failed to list tunnels for your account. Try again later.");
|
|
44
32
|
}
|
|
45
33
|
}
|
|
46
34
|
//# sourceMappingURL=handler.js.map
|
|
@@ -1,37 +1,25 @@
|
|
|
1
1
|
import { logger } from "../../common/logger.js";
|
|
2
|
-
import {
|
|
2
|
+
import { printDiagnosticsToConsole, printTableToConsoleAndExitGracefully, } from "../../common/output.js";
|
|
3
3
|
import settings from "../../common/settings.js";
|
|
4
4
|
export async function rotateToken(argv) {
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const { account } = argv;
|
|
6
|
+
const rotateResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/accounts/${account}/tunnels/${argv["tunnel-id"]}/$rotate-token`, {
|
|
7
|
+
method: "POST",
|
|
7
8
|
headers: {
|
|
8
9
|
Authorization: `Bearer ${argv["api-key"]}`,
|
|
9
10
|
},
|
|
10
11
|
});
|
|
11
|
-
if (
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
method: "POST",
|
|
15
|
-
headers: {
|
|
16
|
-
Authorization: `Bearer ${argv["api-key"]}`,
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
if (rotateResponse.ok) {
|
|
20
|
-
const tunnel = await rotateResponse.json();
|
|
21
|
-
printTableToConsoleAndExitGracefully(tunnel);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
logger.error({
|
|
25
|
-
status: rotateResponse.status,
|
|
26
|
-
statusText: rotateResponse.statusText,
|
|
27
|
-
response: await rotateResponse.text(),
|
|
28
|
-
}, "Failed to rotate token for tunnel");
|
|
29
|
-
printDiagnosticsToConsole("Error: Failed to rotate token for tunnel. Check the arguments.");
|
|
30
|
-
}
|
|
12
|
+
if (rotateResponse.ok) {
|
|
13
|
+
const tunnel = await rotateResponse.json();
|
|
14
|
+
printTableToConsoleAndExitGracefully(tunnel);
|
|
31
15
|
}
|
|
32
16
|
else {
|
|
33
|
-
logger.error({
|
|
34
|
-
|
|
17
|
+
logger.error({
|
|
18
|
+
status: rotateResponse.status,
|
|
19
|
+
statusText: rotateResponse.statusText,
|
|
20
|
+
response: await rotateResponse.text(),
|
|
21
|
+
}, "Failed to rotate token for tunnel");
|
|
22
|
+
printDiagnosticsToConsole("Error: Failed to rotate token for tunnel. Check the arguments.");
|
|
35
23
|
}
|
|
36
24
|
}
|
|
37
25
|
//# sourceMappingURL=handler.js.map
|
|
@@ -1,37 +1,25 @@
|
|
|
1
1
|
import { logger } from "../../../common/logger.js";
|
|
2
|
-
import {
|
|
2
|
+
import { printDiagnosticsToConsole, printResultToConsoleAndExitGracefully, } from "../../../common/output.js";
|
|
3
3
|
import settings from "../../../common/settings.js";
|
|
4
4
|
export async function describe(argv) {
|
|
5
|
-
const
|
|
5
|
+
const { account } = argv;
|
|
6
|
+
const describeResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/accounts/${account}/tunnels/${argv["tunnel-id"]}/services-configuration`, {
|
|
6
7
|
method: "GET",
|
|
7
8
|
headers: {
|
|
8
9
|
Authorization: `Bearer ${argv["api-key"]}`,
|
|
9
10
|
},
|
|
10
11
|
});
|
|
11
|
-
if (
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
method: "GET",
|
|
15
|
-
headers: {
|
|
16
|
-
Authorization: `Bearer ${argv["api-key"]}`,
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
if (describeResponse.ok) {
|
|
20
|
-
const tunnel = await describeResponse.json();
|
|
21
|
-
printResultToConsoleAndExitGracefully(JSON.stringify(tunnel, null, 2));
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
logger.error({
|
|
25
|
-
status: describeResponse.status,
|
|
26
|
-
statusText: describeResponse.statusText,
|
|
27
|
-
response: await describeResponse.text(),
|
|
28
|
-
}, "Failed to describe services for tunnel");
|
|
29
|
-
printDiagnosticsToConsole("Error: Failed to describe the services for your tunnel. Check the arguments.");
|
|
30
|
-
}
|
|
12
|
+
if (describeResponse.ok) {
|
|
13
|
+
const tunnel = await describeResponse.json();
|
|
14
|
+
printResultToConsoleAndExitGracefully(JSON.stringify(tunnel, null, 2));
|
|
31
15
|
}
|
|
32
16
|
else {
|
|
33
|
-
logger.error({
|
|
34
|
-
|
|
17
|
+
logger.error({
|
|
18
|
+
status: describeResponse.status,
|
|
19
|
+
statusText: describeResponse.statusText,
|
|
20
|
+
response: await describeResponse.text(),
|
|
21
|
+
}, "Failed to describe services for tunnel");
|
|
22
|
+
printDiagnosticsToConsole("Error: Failed to describe the services for your tunnel. Check the arguments.");
|
|
35
23
|
}
|
|
36
24
|
}
|
|
37
25
|
//# sourceMappingURL=handler.js.map
|
|
@@ -4,57 +4,45 @@ import { printCriticalFailureToConsoleAndExit, printDiagnosticsToConsole, printR
|
|
|
4
4
|
import settings from "../../../common/settings.js";
|
|
5
5
|
import { pollProvisioningOperation } from "./poll-provisioning-operations.js";
|
|
6
6
|
export async function updateServices(argv) {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
let contents;
|
|
8
|
+
try {
|
|
9
|
+
contents = await readFile(argv["configuration-file"], "utf-8");
|
|
10
|
+
}
|
|
11
|
+
catch (err) {
|
|
12
|
+
printCriticalFailureToConsoleAndExit(`Error reading the configuration file at ${argv["configuration-file"]}: ${err.message}}`);
|
|
13
|
+
}
|
|
14
|
+
const { account } = argv;
|
|
15
|
+
const deleteResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/accounts/${account}/tunnels/${argv["tunnel-id"]}/services-configuration`, {
|
|
16
|
+
method: "PUT",
|
|
9
17
|
headers: {
|
|
10
18
|
Authorization: `Bearer ${argv["api-key"]}`,
|
|
19
|
+
"Content-Type": "application/json",
|
|
11
20
|
},
|
|
21
|
+
body: contents,
|
|
12
22
|
});
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
const { account } = await whoAmIResponse.json();
|
|
22
|
-
const deleteResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/accounts/${account}/tunnels/${argv["tunnel-id"]}/services-configuration`, {
|
|
23
|
-
method: "PUT",
|
|
24
|
-
headers: {
|
|
25
|
-
Authorization: `Bearer ${argv["api-key"]}`,
|
|
26
|
-
"Content-Type": "application/json",
|
|
27
|
-
},
|
|
28
|
-
body: contents,
|
|
23
|
+
if (deleteResponse.ok) {
|
|
24
|
+
const provisioningOperation = await deleteResponse.json();
|
|
25
|
+
printDiagnosticsToConsole(`Updating services on tunnel ${argv["tunnel-id"]} on account ${account}...`);
|
|
26
|
+
const polledProvisioningOperation = await pollProvisioningOperation({
|
|
27
|
+
argv,
|
|
28
|
+
account,
|
|
29
|
+
provisioningOperationId: provisioningOperation.id,
|
|
29
30
|
});
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
printDiagnosticsToConsole(`Updating services on tunnel ${argv["tunnel-id"]} on account ${account}...`);
|
|
33
|
-
const polledProvisioningOperation = await pollProvisioningOperation({
|
|
34
|
-
argv,
|
|
35
|
-
account,
|
|
36
|
-
provisioningOperationId: provisioningOperation.id,
|
|
37
|
-
});
|
|
38
|
-
if (polledProvisioningOperation.status === "success") {
|
|
39
|
-
printResultToConsoleAndExitGracefully(`Tunnel ${argv["tunnel-id"]} updated successfully.`);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
printDiagnosticsToConsole(polledProvisioningOperation.details);
|
|
43
|
-
printCriticalFailureToConsoleAndExit(`Tunnel ${argv["tunnel-id"]} failed to update. Here's the error: ${polledProvisioningOperation.message}`);
|
|
44
|
-
}
|
|
31
|
+
if (polledProvisioningOperation.status === "success") {
|
|
32
|
+
printResultToConsoleAndExitGracefully(`Tunnel ${argv["tunnel-id"]} updated successfully.`);
|
|
45
33
|
}
|
|
46
34
|
else {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
statusText: deleteResponse.statusText,
|
|
50
|
-
response: await deleteResponse.text(),
|
|
51
|
-
}, "Failed to update tunnel for account");
|
|
52
|
-
printDiagnosticsToConsole("Error: Failed to update the tunnel for your account. Check the arguments.");
|
|
35
|
+
printDiagnosticsToConsole(polledProvisioningOperation.details);
|
|
36
|
+
printCriticalFailureToConsoleAndExit(`Tunnel ${argv["tunnel-id"]} failed to update. Here's the error: ${polledProvisioningOperation.message}`);
|
|
53
37
|
}
|
|
54
38
|
}
|
|
55
39
|
else {
|
|
56
|
-
logger.error({
|
|
57
|
-
|
|
40
|
+
logger.error({
|
|
41
|
+
status: deleteResponse.status,
|
|
42
|
+
statusText: deleteResponse.statusText,
|
|
43
|
+
response: await deleteResponse.text(),
|
|
44
|
+
}, "Failed to update tunnel for account");
|
|
45
|
+
printDiagnosticsToConsole("Error: Failed to update the tunnel for your account. Check the arguments.");
|
|
58
46
|
}
|
|
59
47
|
}
|
|
60
48
|
//# sourceMappingURL=handler.js.map
|
|
@@ -1,43 +1,31 @@
|
|
|
1
1
|
import { logger } from "../../common/logger.js";
|
|
2
|
-
import {
|
|
2
|
+
import { printDiagnosticsToConsole, printResultToConsole, } from "../../common/output.js";
|
|
3
3
|
import settings from "../../common/settings.js";
|
|
4
4
|
export async function create(argv) {
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const { account, project } = argv;
|
|
6
|
+
const createResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/accounts/${account}/projects/${project}/branches/${encodeURIComponent(argv["branch"])}/variables`, {
|
|
7
|
+
method: "POST",
|
|
7
8
|
headers: {
|
|
8
9
|
Authorization: `Bearer ${argv["api-key"]}`,
|
|
10
|
+
"Content-Type": "application/json",
|
|
9
11
|
},
|
|
12
|
+
body: JSON.stringify({
|
|
13
|
+
name: argv["name"],
|
|
14
|
+
isSecret: argv["is-secret"],
|
|
15
|
+
value: argv["value"],
|
|
16
|
+
}),
|
|
10
17
|
});
|
|
11
|
-
if (
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
headers: {
|
|
16
|
-
Authorization: `Bearer ${argv["api-key"]}`,
|
|
17
|
-
"Content-Type": "application/json",
|
|
18
|
-
},
|
|
19
|
-
body: JSON.stringify({
|
|
20
|
-
name: argv["name"],
|
|
21
|
-
isSecret: argv["is-secret"],
|
|
22
|
-
value: argv["value"],
|
|
23
|
-
}),
|
|
24
|
-
});
|
|
25
|
-
if (createResponse.ok) {
|
|
26
|
-
const variable = await createResponse.json();
|
|
27
|
-
printResultToConsole(variable.name + " created successfully");
|
|
28
|
-
console.log(variable);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
logger.error({
|
|
32
|
-
status: createResponse.status,
|
|
33
|
-
statusText: createResponse.statusText,
|
|
34
|
-
}, "Failed to create variable");
|
|
35
|
-
printDiagnosticsToConsole("Error: Failed to create variable. Check the arguments.");
|
|
36
|
-
}
|
|
18
|
+
if (createResponse.ok) {
|
|
19
|
+
const variable = await createResponse.json();
|
|
20
|
+
printResultToConsole(variable.name + " created successfully");
|
|
21
|
+
console.log(variable);
|
|
37
22
|
}
|
|
38
23
|
else {
|
|
39
|
-
logger.error({
|
|
40
|
-
|
|
24
|
+
logger.error({
|
|
25
|
+
status: createResponse.status,
|
|
26
|
+
statusText: createResponse.statusText,
|
|
27
|
+
}, "Failed to create variable");
|
|
28
|
+
printDiagnosticsToConsole("Error: Failed to create variable. Check the arguments.");
|
|
41
29
|
}
|
|
42
30
|
}
|
|
43
31
|
//# sourceMappingURL=handler.js.map
|
|
@@ -1,41 +1,29 @@
|
|
|
1
1
|
import { logger } from "../../common/logger.js";
|
|
2
|
-
import {
|
|
2
|
+
import { printDiagnosticsToConsole, printResultToConsole, } from "../../common/output.js";
|
|
3
3
|
import settings from "../../common/settings.js";
|
|
4
4
|
export async function update(argv) {
|
|
5
|
-
const
|
|
6
|
-
|
|
5
|
+
const { account, project } = argv;
|
|
6
|
+
const updateResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/accounts/${account}/projects/${project}/branches/${encodeURIComponent(argv["branch"])}/variables/${encodeURIComponent(argv["name"])}`, {
|
|
7
|
+
method: "PATCH",
|
|
7
8
|
headers: {
|
|
8
9
|
Authorization: `Bearer ${argv["api-key"]}`,
|
|
10
|
+
"Content-Type": "application/json",
|
|
9
11
|
},
|
|
12
|
+
body: JSON.stringify({
|
|
13
|
+
value: argv["value"],
|
|
14
|
+
}),
|
|
10
15
|
});
|
|
11
|
-
if (
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
headers: {
|
|
16
|
-
Authorization: `Bearer ${argv["api-key"]}`,
|
|
17
|
-
"Content-Type": "application/json",
|
|
18
|
-
},
|
|
19
|
-
body: JSON.stringify({
|
|
20
|
-
value: argv["value"],
|
|
21
|
-
}),
|
|
22
|
-
});
|
|
23
|
-
if (updateResponse.ok) {
|
|
24
|
-
const variable = await updateResponse.json();
|
|
25
|
-
printResultToConsole(variable.name + " updated successfully");
|
|
26
|
-
console.log(variable);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
logger.error({
|
|
30
|
-
status: updateResponse.status,
|
|
31
|
-
statusText: updateResponse.statusText,
|
|
32
|
-
}, "Failed to update variable");
|
|
33
|
-
printDiagnosticsToConsole("Error: Failed to update variable. Check the arguments.");
|
|
34
|
-
}
|
|
16
|
+
if (updateResponse.ok) {
|
|
17
|
+
const variable = await updateResponse.json();
|
|
18
|
+
printResultToConsole(variable.name + " updated successfully");
|
|
19
|
+
console.log(variable);
|
|
35
20
|
}
|
|
36
21
|
else {
|
|
37
|
-
logger.error({
|
|
38
|
-
|
|
22
|
+
logger.error({
|
|
23
|
+
status: updateResponse.status,
|
|
24
|
+
statusText: updateResponse.statusText,
|
|
25
|
+
}, "Failed to update variable");
|
|
26
|
+
printDiagnosticsToConsole("Error: Failed to update variable. Check the arguments.");
|
|
39
27
|
}
|
|
40
28
|
}
|
|
41
29
|
//# sourceMappingURL=handler.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuplo/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.42.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": "https://github.com/zuplo/cli",
|
|
6
6
|
"author": "Zuplo, Inc.",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"execa": "^6.1.0",
|
|
57
57
|
"fast-glob": "^3.2.12",
|
|
58
58
|
"ignore": "^5.2.4",
|
|
59
|
+
"jsonc-parser": "^3.2.0",
|
|
59
60
|
"pino": "^8.11.0",
|
|
60
61
|
"pino-pretty": "^9.4.0",
|
|
61
62
|
"prettier": "^2.8.7",
|