@zuplo/cli 1.35.0 → 1.37.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/README.md +10 -0
- package/dist/cli.js +2 -0
- package/dist/cmds/variable/create.js +36 -0
- package/dist/cmds/variable/index.js +13 -0
- package/dist/cmds/variable/update.js +32 -0
- package/dist/common/models.js +2 -0
- package/dist/tunnel/delete/handler.js +1 -0
- package/dist/tunnel/list/handler.js +2 -2
- package/dist/tunnel/services/update/handler.js +1 -0
- package/dist/variable/create/handler.js +43 -0
- package/dist/variable/models.js +2 -0
- package/dist/variable/update/handler.js +41 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ Commands:
|
|
|
10
10
|
zup list Lists all deployed zups
|
|
11
11
|
zup test Runs the tests under /tests against an endpoint
|
|
12
12
|
zup tunnel Tunnel commands
|
|
13
|
+
zup variable Environment Variable commands
|
|
13
14
|
|
|
14
15
|
zup tunnel
|
|
15
16
|
|
|
@@ -31,4 +32,13 @@ Commands:
|
|
|
31
32
|
zup tunnel services describe Describes the services for this tunnel
|
|
32
33
|
zup tunnel services update Updates the services for this tunnel
|
|
33
34
|
|
|
35
|
+
|
|
36
|
+
zup variable
|
|
37
|
+
|
|
38
|
+
Variable commands
|
|
39
|
+
|
|
40
|
+
Commands:
|
|
41
|
+
zup variable create Creates a new variable for a branch
|
|
42
|
+
zup variable update Updates an existing variable for a branch
|
|
43
|
+
|
|
34
44
|
```
|
package/dist/cli.js
CHANGED
|
@@ -9,6 +9,7 @@ import deploy from "./cmds/deploy.js";
|
|
|
9
9
|
import list from "./cmds/list.js";
|
|
10
10
|
import test from "./cmds/test.js";
|
|
11
11
|
import tunnel from "./cmds/tunnel/index.js";
|
|
12
|
+
import variable from "./cmds/variable/index.js";
|
|
12
13
|
import { printCriticalFailureToConsoleAndExit } from "./common/output.js";
|
|
13
14
|
const MIN_NODE_VERSION = "18.0.0";
|
|
14
15
|
if (gte(process.versions.node, MIN_NODE_VERSION)) {
|
|
@@ -20,6 +21,7 @@ if (gte(process.versions.node, MIN_NODE_VERSION)) {
|
|
|
20
21
|
.command(list)
|
|
21
22
|
.command(test)
|
|
22
23
|
.command(tunnel)
|
|
24
|
+
.command(variable)
|
|
23
25
|
.demandCommand()
|
|
24
26
|
.strictCommands()
|
|
25
27
|
.help().argv;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import setBlocking from "../../common/output.js";
|
|
2
|
+
import { create } from "../../variable/create/handler.js";
|
|
3
|
+
export default {
|
|
4
|
+
desc: "Creates a new variable for a branch",
|
|
5
|
+
command: "create",
|
|
6
|
+
builder: (yargs) => {
|
|
7
|
+
return yargs
|
|
8
|
+
.option("name", {
|
|
9
|
+
type: "string",
|
|
10
|
+
describe: "The name of the variable to create",
|
|
11
|
+
})
|
|
12
|
+
.option("value", {
|
|
13
|
+
type: "string",
|
|
14
|
+
describe: "The value of the variable to create",
|
|
15
|
+
})
|
|
16
|
+
.option("is-secret", {
|
|
17
|
+
type: "boolean",
|
|
18
|
+
describe: "Is the variable a secret",
|
|
19
|
+
})
|
|
20
|
+
.option("branch", {
|
|
21
|
+
type: "string",
|
|
22
|
+
describe: "The branch where the variable should be set",
|
|
23
|
+
})
|
|
24
|
+
.option("api-key", {
|
|
25
|
+
type: "string",
|
|
26
|
+
describe: "The API Key from Zuplo",
|
|
27
|
+
envVar: "API_KEY",
|
|
28
|
+
})
|
|
29
|
+
.demandOption(["api-key", "name", "value", "is-Secret", "branch"])
|
|
30
|
+
.middleware([setBlocking]);
|
|
31
|
+
},
|
|
32
|
+
handler: async (argv) => {
|
|
33
|
+
create(argv);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { groupHandler } from "../../common/handler.js";
|
|
2
|
+
import create from "./create.js";
|
|
3
|
+
import update from "./update.js";
|
|
4
|
+
const commands = {
|
|
5
|
+
describe: "Variable commands",
|
|
6
|
+
command: "variable",
|
|
7
|
+
builder: (yargs) => {
|
|
8
|
+
return yargs.command(create).command(update).help();
|
|
9
|
+
},
|
|
10
|
+
handler: groupHandler,
|
|
11
|
+
};
|
|
12
|
+
export default commands;
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import setBlocking from "../../common/output.js";
|
|
2
|
+
import { update } from "../../variable/update/handler.js";
|
|
3
|
+
export default {
|
|
4
|
+
desc: "Updates an existing variable for a branch",
|
|
5
|
+
command: "update",
|
|
6
|
+
builder: (yargs) => {
|
|
7
|
+
return yargs
|
|
8
|
+
.option("name", {
|
|
9
|
+
type: "string",
|
|
10
|
+
describe: "The name of the variable to update",
|
|
11
|
+
})
|
|
12
|
+
.option("value", {
|
|
13
|
+
type: "string",
|
|
14
|
+
describe: "The value of the variable to update",
|
|
15
|
+
})
|
|
16
|
+
.option("branch", {
|
|
17
|
+
type: "string",
|
|
18
|
+
describe: "The branch where the variable exists",
|
|
19
|
+
})
|
|
20
|
+
.option("api-key", {
|
|
21
|
+
type: "string",
|
|
22
|
+
describe: "The API Key from Zuplo",
|
|
23
|
+
envVar: "API_KEY",
|
|
24
|
+
})
|
|
25
|
+
.demandOption(["api-key", "name", "value", "branch"])
|
|
26
|
+
.middleware([setBlocking]);
|
|
27
|
+
},
|
|
28
|
+
handler: async (argv) => {
|
|
29
|
+
update(argv);
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -29,6 +29,7 @@ export async function deleteTunnel(argv) {
|
|
|
29
29
|
printResultToConsoleAndExitGracefully(`Tunnel ${argv["tunnel-id"]} deleted successfully.`);
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
|
+
printDiagnosticsToConsole(polledTearDownOperation.details);
|
|
32
33
|
printCriticalFailureToConsoleAndExit(`Tunnel ${argv["tunnel-id"]} failed to delete. Here's the error: ${polledTearDownOperation.message}`);
|
|
33
34
|
}
|
|
34
35
|
}
|
|
@@ -18,12 +18,12 @@ export async function list(argv) {
|
|
|
18
18
|
});
|
|
19
19
|
if (listResponse.ok) {
|
|
20
20
|
const tunnels = await listResponse.json();
|
|
21
|
-
if (tunnels.length === 0) {
|
|
21
|
+
if (tunnels.data.length === 0) {
|
|
22
22
|
const output = "No tunnels found";
|
|
23
23
|
printResultToConsoleAndExitGracefully(output);
|
|
24
24
|
}
|
|
25
25
|
else {
|
|
26
|
-
const table = tunnels.map((tunnel) => {
|
|
26
|
+
const table = tunnels.data.map((tunnel) => {
|
|
27
27
|
return { "tunnel-id": tunnel.id, name: tunnel.name };
|
|
28
28
|
});
|
|
29
29
|
printTableToConsoleAndExitGracefully(table);
|
|
@@ -39,6 +39,7 @@ export async function updateServices(argv) {
|
|
|
39
39
|
printResultToConsoleAndExitGracefully(`Tunnel ${argv["tunnel-id"]} updated successfully.`);
|
|
40
40
|
}
|
|
41
41
|
else {
|
|
42
|
+
printDiagnosticsToConsole(polledProvisioningOperation.details);
|
|
42
43
|
printCriticalFailureToConsoleAndExit(`Tunnel ${argv["tunnel-id"]} failed to update. Here's the error: ${polledProvisioningOperation.message}`);
|
|
43
44
|
}
|
|
44
45
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { logger } from "../../common/logger.js";
|
|
2
|
+
import { printCriticalFailureToConsoleAndExit, printDiagnosticsToConsole, printResultToConsole, } from "../../common/output.js";
|
|
3
|
+
import settings from "../../common/settings.js";
|
|
4
|
+
export async function create(argv) {
|
|
5
|
+
const whoAmIResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/who-am-i`, {
|
|
6
|
+
method: "GET",
|
|
7
|
+
headers: {
|
|
8
|
+
Authorization: `Bearer ${argv["api-key"]}`,
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
if (whoAmIResponse.ok) {
|
|
12
|
+
const { account, project } = await whoAmIResponse.json();
|
|
13
|
+
const createResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/accounts/${account}/projects/${project}/branches/${encodeURIComponent(argv["branch"])}/variables`, {
|
|
14
|
+
method: "POST",
|
|
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
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
logger.error({ status: whoAmIResponse.status, statusText: whoAmIResponse.statusText }, "Failed to determine who-am-i");
|
|
40
|
+
printCriticalFailureToConsoleAndExit("Error: Failed to validate the API key. Check your API key.");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=handler.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { logger } from "../../common/logger.js";
|
|
2
|
+
import { printCriticalFailureToConsoleAndExit, printDiagnosticsToConsole, printResultToConsole, } from "../../common/output.js";
|
|
3
|
+
import settings from "../../common/settings.js";
|
|
4
|
+
export async function update(argv) {
|
|
5
|
+
const whoAmIResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/who-am-i`, {
|
|
6
|
+
method: "GET",
|
|
7
|
+
headers: {
|
|
8
|
+
Authorization: `Bearer ${argv["api-key"]}`,
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
if (whoAmIResponse.ok) {
|
|
12
|
+
const { account, project } = await whoAmIResponse.json();
|
|
13
|
+
const updateResponse = await fetch(`${settings.ZUPLO_DEVELOPER_API_ENDPOINT}/v1/accounts/${account}/projects/${project}/branches/${encodeURIComponent(argv["branch"])}/variables/${encodeURIComponent(argv["name"])}`, {
|
|
14
|
+
method: "PATCH",
|
|
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
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
logger.error({ status: whoAmIResponse.status, statusText: whoAmIResponse.statusText }, "Failed to determine who-am-i");
|
|
38
|
+
printCriticalFailureToConsoleAndExit("Error: Failed to validate the API key. Check your API key.");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=handler.js.map
|