bdy 1.25.40-dev → 1.25.42-dev
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/distTs/package.json +1 -1
- package/distTs/src/api/client.js +129 -60
- package/distTs/src/command/agent/debug.js +22 -1
- package/distTs/src/command/agent/disable.js +21 -2
- package/distTs/src/command/agent/enable.js +21 -2
- package/distTs/src/command/agent/proxy/disable.js +16 -2
- package/distTs/src/command/agent/proxy/enable.js +16 -2
- package/distTs/src/command/agent/proxy/status.js +32 -13
- package/distTs/src/command/agent/remote.js +219 -0
- package/distTs/src/command/agent/status.js +78 -48
- package/distTs/src/command/agent/tags/get.js +37 -13
- package/distTs/src/command/agent/tags/set.js +30 -9
- package/distTs/src/command/agent/target/disable.js +16 -2
- package/distTs/src/command/agent/target/enable.js +16 -2
- package/distTs/src/command/agent/target/status.js +32 -13
- package/distTs/src/command/agent/tunnel/disable.js +16 -2
- package/distTs/src/command/agent/tunnel/enable.js +16 -2
- package/distTs/src/command/agent/tunnel/http.js +21 -0
- package/distTs/src/command/agent/tunnel/list.js +28 -6
- package/distTs/src/command/agent/tunnel/remove.js +29 -1
- package/distTs/src/command/agent/tunnel/start.js +23 -0
- package/distTs/src/command/agent/tunnel/status.js +50 -13
- package/distTs/src/command/agent/tunnel/tcp.js +21 -0
- package/distTs/src/command/agent/tunnel/tls.js +21 -0
- package/distTs/src/command/agent/update.js +17 -1
- package/distTs/src/command/agent/version.js +28 -5
- package/distTs/src/command/distro/create.js +11 -6
- package/distTs/src/command/distro/delete.js +6 -13
- package/distTs/src/command/distro/get.js +6 -13
- package/distTs/src/command/distro/list.js +6 -6
- package/distTs/src/command/distro/open.js +5 -10
- package/distTs/src/command/distro/route/create.js +6 -14
- package/distTs/src/command/distro/route/delete.js +6 -13
- package/distTs/src/command/distro/route/get.js +9 -14
- package/distTs/src/command/distro/route/list.js +6 -13
- package/distTs/src/command/distro/route/open.js +5 -10
- package/distTs/src/command/distro/route/purge.js +42 -0
- package/distTs/src/command/distro/route/update.js +8 -15
- package/distTs/src/command/distro/route.js +3 -0
- package/distTs/src/command/distro/scope.js +77 -0
- package/distTs/src/command/distro/update.js +5 -13
- package/distTs/src/command/distro.js +1 -0
- package/distTs/src/command/pre.js +2 -1
- package/distTs/src/format.js +6 -0
- package/distTs/src/input.js +33 -10
- package/distTs/src/output.js +16 -0
- package/distTs/src/texts.js +273 -31
- package/distTs/src/tunnel/output/interactive/tunnel.js +67 -8
- package/distTs/src/tunnel/output/noninteractive/tunnel.js +8 -0
- package/distTs/src/types/serverAgent.js +2 -0
- package/package.json +1 -1
|
@@ -7,27 +7,22 @@ const utils_1 = require("../../utils");
|
|
|
7
7
|
const texts_1 = require("../../texts");
|
|
8
8
|
const input_1 = __importDefault(require("../../input"));
|
|
9
9
|
const output_1 = __importDefault(require("../../output"));
|
|
10
|
-
const
|
|
11
|
-
const distro_1 = require("../../types/distro");
|
|
10
|
+
const scope_1 = require("./scope");
|
|
12
11
|
const commandDistroOpen = (0, utils_1.newCommand)('open', texts_1.DESC_COMMAND_RESOURCE_OPEN, {
|
|
13
12
|
requiredScopes: [utils_1.REST_API_SCOPE.DISTRIBUTION_READ],
|
|
14
13
|
examples: [{ description: 'Open a distribution in Buddy', command: 'bdy distro open my-distro' }],
|
|
15
14
|
});
|
|
16
15
|
commandDistroOpen.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
17
16
|
commandDistroOpen.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
18
|
-
commandDistroOpen.option('--
|
|
17
|
+
commandDistroOpen.option('--environment <identifier>', texts_1.OPTION_DISTRO_ENVIRONMENT);
|
|
18
|
+
commandDistroOpen.option('--scope <scope>', texts_1.OPT_COMMAND_SCOPE_ENVIRONMENT);
|
|
19
19
|
commandDistroOpen.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
20
20
|
commandDistroOpen.argument('<identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
|
|
21
21
|
commandDistroOpen.action(async (identifier, options) => {
|
|
22
22
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
23
|
-
const project = input_1.default.restApiProject(options.project, true);
|
|
24
|
-
const scope = input_1.default.scope(project, options.scope);
|
|
25
|
-
const scopedProject = scope === distro_1.SCOPE.PROJECT ? project : null;
|
|
26
23
|
const client = input_1.default.restApiTokenClient();
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
throw new cliError_1.default('not_found', texts_1.ERR_COMMAND_DISTRO_NOT_FOUND, texts_1.HINT_DISTRO_LIST);
|
|
30
|
-
const distro = await client.getDistribution(workspace, scopedProject, data.distribution_id);
|
|
24
|
+
const ctx = await (0, scope_1.resolveDistroContext)(client, workspace, options, identifier);
|
|
25
|
+
const distro = await client.getDistribution(workspace, ctx.api, ctx.distributionId);
|
|
31
26
|
await output_1.default.openUrl(distro.html_url, options.format === 'json');
|
|
32
27
|
});
|
|
33
28
|
exports.default = commandDistroOpen;
|
|
@@ -3,12 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const cliError_1 = __importDefault(require("../../../cliError"));
|
|
7
6
|
const utils_1 = require("../../../utils");
|
|
8
7
|
const texts_1 = require("../../../texts");
|
|
9
8
|
const input_1 = __importDefault(require("../../../input"));
|
|
10
9
|
const output_1 = __importDefault(require("../../../output"));
|
|
11
|
-
const
|
|
10
|
+
const scope_1 = require("../scope");
|
|
12
11
|
const commandDistroRouteCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_ROUTE_CREATE, {
|
|
13
12
|
requiredScopes: [utils_1.REST_API_SCOPE.DISTRIBUTION_WRITE],
|
|
14
13
|
examples: texts_1.EXAMPLE_ROUTE_CREATE,
|
|
@@ -16,7 +15,8 @@ const commandDistroRouteCreate = (0, utils_1.newCommand)('create', texts_1.DESC_
|
|
|
16
15
|
commandDistroRouteCreate.alias('add');
|
|
17
16
|
commandDistroRouteCreate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
18
17
|
commandDistroRouteCreate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
19
|
-
commandDistroRouteCreate.option('--
|
|
18
|
+
commandDistroRouteCreate.option('--environment <identifier>', texts_1.OPTION_DISTRO_ENVIRONMENT);
|
|
19
|
+
commandDistroRouteCreate.option('--scope <scope>', texts_1.OPT_COMMAND_SCOPE_ENVIRONMENT);
|
|
20
20
|
commandDistroRouteCreate.option('-t, --type <type>', texts_1.OPT_COMMAND_ROUTE_TYPE);
|
|
21
21
|
commandDistroRouteCreate.option('-s, --subdomain <subdomain>', texts_1.OPT_COMMAND_ROUTE_SUBDOMAIN);
|
|
22
22
|
commandDistroRouteCreate.option('-d, --domain <domain>', texts_1.OPT_COMMAND_ROUTE_DOMAIN);
|
|
@@ -28,8 +28,6 @@ commandDistroRouteCreate.argument('<identifier>', texts_1.OPT_COMMAND_DISTRO_IDE
|
|
|
28
28
|
commandDistroRouteCreate.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
29
29
|
commandDistroRouteCreate.action(async (identifier, options) => {
|
|
30
30
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
31
|
-
const project = input_1.default.restApiProject(options.project, true);
|
|
32
|
-
const scope = input_1.default.scope(project, options.scope);
|
|
33
31
|
const client = input_1.default.restApiTokenClient();
|
|
34
32
|
const type = input_1.default.routeType(options.type);
|
|
35
33
|
const body = {
|
|
@@ -46,15 +44,9 @@ commandDistroRouteCreate.action(async (identifier, options) => {
|
|
|
46
44
|
body.note = options.note;
|
|
47
45
|
if (options.agentNote)
|
|
48
46
|
body.agent_note = options.agentNote;
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
if (!data?.distribution_id) {
|
|
54
|
-
output_1.default.exitError(new cliError_1.default('not_found', texts_1.ERR_COMMAND_DISTRO_NOT_FOUND, texts_1.HINT_DISTRO_LIST));
|
|
55
|
-
}
|
|
56
|
-
body.targets = await input_1.default.routeTarget(client, workspace, scope === distro_1.SCOPE.PROJECT ? project : null, options.target);
|
|
57
|
-
const result = await client.createRoute(workspace, scope === distro_1.SCOPE.PROJECT ? project : null, data.distribution_id, body);
|
|
47
|
+
const ctx = await (0, scope_1.resolveDistroContext)(client, workspace, options, identifier);
|
|
48
|
+
body.targets = await input_1.default.routeTarget(client, workspace, ctx, options.target);
|
|
49
|
+
const result = await client.createRoute(workspace, ctx.api, ctx.distributionId, body);
|
|
58
50
|
if (options.format === 'json') {
|
|
59
51
|
output_1.default.json(result);
|
|
60
52
|
output_1.default.exitNormal();
|
|
@@ -3,12 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const cliError_1 = __importDefault(require("../../../cliError"));
|
|
7
6
|
const utils_1 = require("../../../utils");
|
|
8
7
|
const texts_1 = require("../../../texts");
|
|
9
8
|
const input_1 = __importDefault(require("../../../input"));
|
|
10
9
|
const output_1 = __importDefault(require("../../../output"));
|
|
11
|
-
const
|
|
10
|
+
const scope_1 = require("../scope");
|
|
12
11
|
const commandDistroRouteDelete = (0, utils_1.newCommand)('delete', texts_1.DESC_COMMAND_ROUTE_DELETE, {
|
|
13
12
|
requiredScopes: [utils_1.REST_API_SCOPE.DISTRIBUTION_MANAGE],
|
|
14
13
|
examples: texts_1.EXAMPLE_ROUTE_DELETE,
|
|
@@ -16,27 +15,21 @@ const commandDistroRouteDelete = (0, utils_1.newCommand)('delete', texts_1.DESC_
|
|
|
16
15
|
commandDistroRouteDelete.alias('rm');
|
|
17
16
|
commandDistroRouteDelete.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
18
17
|
commandDistroRouteDelete.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
19
|
-
commandDistroRouteDelete.option('--
|
|
18
|
+
commandDistroRouteDelete.option('--environment <identifier>', texts_1.OPTION_DISTRO_ENVIRONMENT);
|
|
19
|
+
commandDistroRouteDelete.option('--scope <scope>', texts_1.OPT_COMMAND_SCOPE_ENVIRONMENT);
|
|
20
20
|
commandDistroRouteDelete.option('-f, --force', texts_1.OPTION_CONFIRM_FORCE);
|
|
21
21
|
commandDistroRouteDelete.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
22
22
|
commandDistroRouteDelete.argument('<identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
|
|
23
23
|
commandDistroRouteDelete.argument('<route-id>', texts_1.OPT_COMMAND_ROUTE_ID);
|
|
24
24
|
commandDistroRouteDelete.action(async (identifier, routeId, options) => {
|
|
25
25
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
26
|
-
const project = input_1.default.restApiProject(options.project, true);
|
|
27
|
-
const scope = input_1.default.scope(project, options.scope);
|
|
28
26
|
const client = input_1.default.restApiTokenClient();
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
output_1.default.exitError(new cliError_1.default('not_found', texts_1.ERR_WORKSPACE_NOT_FOUND, texts_1.HINT_WORKSPACE_LIST));
|
|
32
|
-
}
|
|
33
|
-
if (!data?.distribution_id) {
|
|
34
|
-
output_1.default.exitError(new cliError_1.default('not_found', texts_1.ERR_COMMAND_DISTRO_NOT_FOUND, texts_1.HINT_DISTRO_LIST));
|
|
35
|
-
}
|
|
27
|
+
const ctx = await (0, scope_1.resolveDistroContext)(client, workspace, options, identifier);
|
|
28
|
+
const distributionId = ctx.distributionId;
|
|
36
29
|
const json = options.format === 'json';
|
|
37
30
|
const confirmed = await output_1.default.confirmDestructive(options.force, (0, texts_1.TXT_COMMAND_ROUTE_DELETE_CONFIRM)(identifier, routeId), json);
|
|
38
31
|
if (confirmed) {
|
|
39
|
-
await client.deleteRoute(workspace,
|
|
32
|
+
await client.deleteRoute(workspace, ctx.api, distributionId, routeId);
|
|
40
33
|
output_1.default.exitResult(json, { deleted: routeId }, texts_1.TXT_COMMAND_ROUTE_DELETED);
|
|
41
34
|
}
|
|
42
35
|
else {
|
|
@@ -3,13 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const cliError_1 = __importDefault(require("../../../cliError"));
|
|
7
6
|
const utils_1 = require("../../../utils");
|
|
8
7
|
const texts_1 = require("../../../texts");
|
|
9
8
|
const input_1 = __importDefault(require("../../../input"));
|
|
10
9
|
const notes_1 = require("../../../types/notes");
|
|
11
10
|
const output_1 = __importDefault(require("../../../output"));
|
|
12
11
|
const distro_1 = require("../../../types/distro");
|
|
12
|
+
const scope_1 = require("../scope");
|
|
13
13
|
const targetText = (target) => {
|
|
14
14
|
if (target.type === distro_1.ROUTE_TARGET_TYPE.ARTIFACT && target.artifact) {
|
|
15
15
|
return `artifact ${target.artifact.id}:${target.artifact.version_id}`;
|
|
@@ -24,31 +24,26 @@ const commandDistroRouteGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAN
|
|
|
24
24
|
examples: texts_1.EXAMPLE_ROUTE_GET,
|
|
25
25
|
});
|
|
26
26
|
commandDistroRouteGet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
27
|
-
commandDistroRouteGet.option('--scope <scope>', texts_1.
|
|
27
|
+
commandDistroRouteGet.option('--scope <scope>', texts_1.OPT_COMMAND_SCOPE_ENVIRONMENT);
|
|
28
28
|
commandDistroRouteGet.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
29
|
+
commandDistroRouteGet.option('--environment <identifier>', texts_1.OPTION_DISTRO_ENVIRONMENT);
|
|
29
30
|
commandDistroRouteGet.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
30
31
|
commandDistroRouteGet.option('--no-parent-notes', texts_1.OPTION_NO_PARENT_NOTES);
|
|
31
32
|
commandDistroRouteGet.argument('<identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
|
|
32
33
|
commandDistroRouteGet.argument('<route-id>', texts_1.OPT_COMMAND_ROUTE_ID);
|
|
33
34
|
commandDistroRouteGet.action(async (identifier, routeId, options) => {
|
|
34
35
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
35
|
-
const project = input_1.default.restApiProject(options.project, true);
|
|
36
|
-
const scope = input_1.default.scope(project, options.scope);
|
|
37
36
|
const client = input_1.default.restApiTokenClient();
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
if (!data?.distribution_id) {
|
|
43
|
-
output_1.default.exitError(new cliError_1.default('not_found', texts_1.ERR_COMMAND_DISTRO_NOT_FOUND, texts_1.HINT_DISTRO_LIST));
|
|
44
|
-
}
|
|
45
|
-
const route = await client.getRoute(workspace, scope === distro_1.SCOPE.PROJECT ? project : null, data.distribution_id, routeId);
|
|
37
|
+
const ctx = await (0, scope_1.resolveDistroContext)(client, workspace, options, identifier);
|
|
38
|
+
const distributionId = ctx.distributionId;
|
|
39
|
+
const route = await client.getRoute(workspace, ctx.api, distributionId, routeId);
|
|
46
40
|
if (options.format === 'json') {
|
|
47
41
|
output_1.default.json(await client.withParentNotes(workspace, route, options.parentNotes, [
|
|
48
42
|
{
|
|
49
43
|
type: notes_1.PARENT_NOTE_TYPE.DISTRIBUTION,
|
|
50
|
-
id:
|
|
51
|
-
project:
|
|
44
|
+
id: distributionId,
|
|
45
|
+
project: ctx.api.project,
|
|
46
|
+
environmentId: ctx.api.environmentId,
|
|
52
47
|
},
|
|
53
48
|
]));
|
|
54
49
|
}
|
|
@@ -3,35 +3,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const cliError_1 = __importDefault(require("../../../cliError"));
|
|
7
6
|
const utils_1 = require("../../../utils");
|
|
8
7
|
const texts_1 = require("../../../texts");
|
|
9
8
|
const input_1 = __importDefault(require("../../../input"));
|
|
10
9
|
const output_1 = __importDefault(require("../../../output"));
|
|
11
|
-
const
|
|
10
|
+
const scope_1 = require("../scope");
|
|
12
11
|
const commandDistroRouteList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_ROUTE_LIST, {
|
|
13
12
|
requiredScopes: [utils_1.REST_API_SCOPE.DISTRIBUTION_READ],
|
|
14
13
|
examples: texts_1.EXAMPLE_ROUTE_LIST,
|
|
15
14
|
});
|
|
16
15
|
commandDistroRouteList.alias('ls');
|
|
17
16
|
commandDistroRouteList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
18
|
-
commandDistroRouteList.option('--scope <scope>', texts_1.
|
|
17
|
+
commandDistroRouteList.option('--scope <scope>', texts_1.OPT_COMMAND_SCOPE_ENVIRONMENT);
|
|
19
18
|
commandDistroRouteList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
19
|
+
commandDistroRouteList.option('--environment <identifier>', texts_1.OPTION_DISTRO_ENVIRONMENT);
|
|
20
20
|
commandDistroRouteList.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
21
21
|
commandDistroRouteList.argument('<identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
|
|
22
22
|
commandDistroRouteList.action(async (identifier, options) => {
|
|
23
23
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
24
|
-
const project = input_1.default.restApiProject(options.project, true);
|
|
25
|
-
const scope = input_1.default.scope(project, options.scope);
|
|
26
24
|
const client = input_1.default.restApiTokenClient();
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
if (!data?.distribution_id) {
|
|
32
|
-
output_1.default.exitError(new cliError_1.default('not_found', texts_1.ERR_COMMAND_DISTRO_NOT_FOUND, texts_1.HINT_DISTRO_LIST));
|
|
33
|
-
}
|
|
34
|
-
const r = await client.listRoutes(workspace, scope === distro_1.SCOPE.PROJECT ? project : null, data.distribution_id);
|
|
25
|
+
const ctx = await (0, scope_1.resolveDistroContext)(client, workspace, options, identifier);
|
|
26
|
+
const distributionId = ctx.distributionId;
|
|
27
|
+
const r = await client.listRoutes(workspace, ctx.api, distributionId);
|
|
35
28
|
const routes = r.routes || [];
|
|
36
29
|
if (options.format === 'json') {
|
|
37
30
|
output_1.default.json(routes);
|
|
@@ -7,28 +7,23 @@ const utils_1 = require("../../../utils");
|
|
|
7
7
|
const texts_1 = require("../../../texts");
|
|
8
8
|
const input_1 = __importDefault(require("../../../input"));
|
|
9
9
|
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
-
const
|
|
11
|
-
const distro_1 = require("../../../types/distro");
|
|
10
|
+
const scope_1 = require("../scope");
|
|
12
11
|
const commandDistroRouteOpen = (0, utils_1.newCommand)('open', texts_1.DESC_COMMAND_RESOURCE_OPEN, {
|
|
13
12
|
requiredScopes: [utils_1.REST_API_SCOPE.DISTRIBUTION_READ],
|
|
14
13
|
examples: [{ description: 'Open a distribution route in Buddy', command: 'bdy distro route open my-distro 123' }],
|
|
15
14
|
});
|
|
16
15
|
commandDistroRouteOpen.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
17
16
|
commandDistroRouteOpen.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
18
|
-
commandDistroRouteOpen.option('--
|
|
17
|
+
commandDistroRouteOpen.option('--environment <identifier>', texts_1.OPTION_DISTRO_ENVIRONMENT);
|
|
18
|
+
commandDistroRouteOpen.option('--scope <scope>', texts_1.OPT_COMMAND_SCOPE_ENVIRONMENT);
|
|
19
19
|
commandDistroRouteOpen.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
20
20
|
commandDistroRouteOpen.argument('<identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
|
|
21
21
|
commandDistroRouteOpen.argument('<route-id>', texts_1.OPT_COMMAND_ROUTE_ID);
|
|
22
22
|
commandDistroRouteOpen.action(async (identifier, routeId, options) => {
|
|
23
23
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
24
|
-
const project = input_1.default.restApiProject(options.project, true);
|
|
25
|
-
const scope = input_1.default.scope(project, options.scope);
|
|
26
|
-
const scopedProject = scope === distro_1.SCOPE.PROJECT ? project : null;
|
|
27
24
|
const client = input_1.default.restApiTokenClient();
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
throw new cliError_1.default('not_found', texts_1.ERR_COMMAND_DISTRO_NOT_FOUND, texts_1.HINT_DISTRO_LIST);
|
|
31
|
-
const route = await client.getRoute(workspace, scopedProject, data.distribution_id, routeId);
|
|
25
|
+
const ctx = await (0, scope_1.resolveDistroContext)(client, workspace, options, identifier);
|
|
26
|
+
const route = await client.getRoute(workspace, ctx.api, ctx.distributionId, routeId);
|
|
32
27
|
await output_1.default.openUrl(route.html_url, options.format === 'json');
|
|
33
28
|
});
|
|
34
29
|
exports.default = commandDistroRouteOpen;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const input_1 = __importDefault(require("../../../input"));
|
|
9
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
+
const scope_1 = require("../scope");
|
|
11
|
+
// --path repeats instead of taking a list: a variadic option would swallow the
|
|
12
|
+
// positional arguments that follow it
|
|
13
|
+
const collect = (value, previous = []) => [...previous, value];
|
|
14
|
+
const commandDistroRoutePurge = (0, utils_1.newCommand)('purge', texts_1.DESC_COMMAND_ROUTE_PURGE, {
|
|
15
|
+
requiredScopes: [utils_1.REST_API_SCOPE.DISTRIBUTION_WRITE],
|
|
16
|
+
examples: texts_1.EXAMPLE_ROUTE_PURGE,
|
|
17
|
+
});
|
|
18
|
+
commandDistroRoutePurge.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
19
|
+
commandDistroRoutePurge.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
20
|
+
commandDistroRoutePurge.option('--environment <identifier>', texts_1.OPTION_DISTRO_ENVIRONMENT);
|
|
21
|
+
commandDistroRoutePurge.option('--scope <scope>', texts_1.OPT_COMMAND_SCOPE_ENVIRONMENT);
|
|
22
|
+
commandDistroRoutePurge.option('--all', texts_1.OPT_COMMAND_ROUTE_PURGE_ALL);
|
|
23
|
+
commandDistroRoutePurge.option('--path <path>', texts_1.OPT_COMMAND_ROUTE_PURGE_PATH, collect);
|
|
24
|
+
commandDistroRoutePurge.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
25
|
+
commandDistroRoutePurge.argument('<identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
|
|
26
|
+
commandDistroRoutePurge.argument('<route-id>', texts_1.OPT_COMMAND_ROUTE_ID);
|
|
27
|
+
commandDistroRoutePurge.action(async (identifier, routeId, options) => {
|
|
28
|
+
const paths = options.path || [];
|
|
29
|
+
// one or the other: --all already covers every path
|
|
30
|
+
if (!!options.all === paths.length > 0) {
|
|
31
|
+
output_1.default.exitError(texts_1.ERR_COMMAND_ROUTE_PURGE_WHAT);
|
|
32
|
+
}
|
|
33
|
+
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
34
|
+
const client = input_1.default.restApiTokenClient();
|
|
35
|
+
const ctx = await (0, scope_1.resolveDistroContext)(client, workspace, options, identifier);
|
|
36
|
+
const body = { purge_all: !!options.all };
|
|
37
|
+
if (paths.length)
|
|
38
|
+
body.purge_paths = paths;
|
|
39
|
+
await client.purgeRouteCache(workspace, ctx.api, ctx.distributionId, routeId, body);
|
|
40
|
+
output_1.default.exitResult(options.format === 'json', { purged: routeId, ...body }, texts_1.TXT_COMMAND_ROUTE_PURGED);
|
|
41
|
+
});
|
|
42
|
+
exports.default = commandDistroRoutePurge;
|
|
@@ -3,20 +3,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const cliError_1 = __importDefault(require("../../../cliError"));
|
|
7
6
|
const utils_1 = require("../../../utils");
|
|
8
7
|
const texts_1 = require("../../../texts");
|
|
9
8
|
const input_1 = __importDefault(require("../../../input"));
|
|
10
9
|
const output_1 = __importDefault(require("../../../output"));
|
|
11
|
-
const
|
|
10
|
+
const scope_1 = require("../scope");
|
|
12
11
|
const commandDistroRouteUpdate = (0, utils_1.newCommand)('update', texts_1.DESC_COMMAND_ROUTE_UPDATE, {
|
|
13
12
|
requiredScopes: [utils_1.REST_API_SCOPE.DISTRIBUTION_WRITE],
|
|
14
13
|
examples: texts_1.EXAMPLE_ROUTE_UPDATE,
|
|
15
14
|
});
|
|
16
15
|
commandDistroRouteUpdate.alias('edit');
|
|
17
16
|
commandDistroRouteUpdate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
18
|
-
commandDistroRouteUpdate.option('--scope <scope>', texts_1.
|
|
17
|
+
commandDistroRouteUpdate.option('--scope <scope>', texts_1.OPT_COMMAND_SCOPE_ENVIRONMENT);
|
|
19
18
|
commandDistroRouteUpdate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
19
|
+
commandDistroRouteUpdate.option('--environment <identifier>', texts_1.OPTION_DISTRO_ENVIRONMENT);
|
|
20
20
|
commandDistroRouteUpdate.option('-t, --type <type>', texts_1.OPT_COMMAND_ROUTE_TYPE);
|
|
21
21
|
commandDistroRouteUpdate.option('-s, --subdomain <subdomain>', texts_1.OPT_COMMAND_ROUTE_SUBDOMAIN);
|
|
22
22
|
commandDistroRouteUpdate.option('-d, --domain <domain>', texts_1.OPT_COMMAND_ROUTE_DOMAIN);
|
|
@@ -29,17 +29,10 @@ commandDistroRouteUpdate.argument('<route-id>', texts_1.OPT_COMMAND_ROUTE_ID);
|
|
|
29
29
|
commandDistroRouteUpdate.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
30
30
|
commandDistroRouteUpdate.action(async (identifier, routeId, options) => {
|
|
31
31
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
32
|
-
const project = input_1.default.restApiProject(options.project, true);
|
|
33
|
-
const scope = input_1.default.scope(project, options.scope);
|
|
34
32
|
const client = input_1.default.restApiTokenClient();
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
if (!data?.distribution_id) {
|
|
40
|
-
output_1.default.exitError(new cliError_1.default('not_found', texts_1.ERR_COMMAND_DISTRO_NOT_FOUND, texts_1.HINT_DISTRO_LIST));
|
|
41
|
-
}
|
|
42
|
-
const route = await client.getRoute(workspace, scope === distro_1.SCOPE.PROJECT ? project : null, data.distribution_id, routeId);
|
|
33
|
+
const ctx = await (0, scope_1.resolveDistroContext)(client, workspace, options, identifier);
|
|
34
|
+
const distributionId = ctx.distributionId;
|
|
35
|
+
const route = await client.getRoute(workspace, ctx.api, distributionId, routeId);
|
|
43
36
|
let changed = false;
|
|
44
37
|
// This endpoint is a full replace: whatever the body omits is cleared. The
|
|
45
38
|
// PATCH route exists but validates the body as a complete route too, so it
|
|
@@ -77,13 +70,13 @@ commandDistroRouteUpdate.action(async (identifier, routeId, options) => {
|
|
|
77
70
|
changed = true;
|
|
78
71
|
}
|
|
79
72
|
if (options.target && options.target.length > 0) {
|
|
80
|
-
body.targets = await input_1.default.routeTarget(client, workspace,
|
|
73
|
+
body.targets = await input_1.default.routeTarget(client, workspace, ctx, options.target);
|
|
81
74
|
changed = true;
|
|
82
75
|
}
|
|
83
76
|
if (!changed) {
|
|
84
77
|
output_1.default.exitError(texts_1.ERR_COMMAND_NO_UPDATE);
|
|
85
78
|
}
|
|
86
|
-
const result = await client.updateRoute(workspace,
|
|
79
|
+
const result = await client.updateRoute(workspace, ctx.api, distributionId, routeId, body);
|
|
87
80
|
if (options.format === 'json') {
|
|
88
81
|
output_1.default.json(result);
|
|
89
82
|
output_1.default.exitNormal();
|
|
@@ -11,6 +11,7 @@ const get_1 = __importDefault(require("./route/get"));
|
|
|
11
11
|
const delete_1 = __importDefault(require("./route/delete"));
|
|
12
12
|
const update_1 = __importDefault(require("./route/update"));
|
|
13
13
|
const open_1 = __importDefault(require("./route/open"));
|
|
14
|
+
const purge_1 = __importDefault(require("./route/purge"));
|
|
14
15
|
const commandDistroRoute = (0, utils_1.newCommand)('route', texts_1.DESC_COMMAND_ROUTE, {
|
|
15
16
|
examples: [
|
|
16
17
|
...texts_1.EXAMPLE_ROUTE_CREATE,
|
|
@@ -18,6 +19,7 @@ const commandDistroRoute = (0, utils_1.newCommand)('route', texts_1.DESC_COMMAND
|
|
|
18
19
|
...texts_1.EXAMPLE_ROUTE_LIST,
|
|
19
20
|
...texts_1.EXAMPLE_ROUTE_GET,
|
|
20
21
|
...texts_1.EXAMPLE_ROUTE_DELETE,
|
|
22
|
+
...texts_1.EXAMPLE_ROUTE_PURGE,
|
|
21
23
|
],
|
|
22
24
|
});
|
|
23
25
|
commandDistroRoute.addCommand(create_1.default);
|
|
@@ -26,4 +28,5 @@ commandDistroRoute.addCommand(list_1.default);
|
|
|
26
28
|
commandDistroRoute.addCommand(get_1.default);
|
|
27
29
|
commandDistroRoute.addCommand(open_1.default);
|
|
28
30
|
commandDistroRoute.addCommand(delete_1.default);
|
|
31
|
+
commandDistroRoute.addCommand(purge_1.default);
|
|
29
32
|
exports.default = commandDistroRoute;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.resolveDistroContext = void 0;
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../output"));
|
|
9
|
+
const cliError_1 = __importDefault(require("../../cliError"));
|
|
10
|
+
const input_1 = __importDefault(require("../../input"));
|
|
11
|
+
const distro_1 = require("../../types/distro");
|
|
12
|
+
// Shared resolve preamble of the distro and route commands: flags/env ->
|
|
13
|
+
// scope -> /identifiers -> hash ids, exiting on a miss.
|
|
14
|
+
//
|
|
15
|
+
// Environments exist in projects and in the workspace. An explicit --project
|
|
16
|
+
// is a statement "the environment of this project", so it never falls back;
|
|
17
|
+
// a project implied by BUDDY_PROJECT or a linked directory only narrows the
|
|
18
|
+
// first lookup, and a workspace environment of that identifier is used when
|
|
19
|
+
// the project has none - otherwise a workspace environment's distributions
|
|
20
|
+
// would be unreachable from inside a linked project.
|
|
21
|
+
const resolveDistroContext = async (client, workspace, options, distribution) => {
|
|
22
|
+
const project = input_1.default.restApiProject(options.project, true);
|
|
23
|
+
const scope = input_1.default.scope(project, options.scope || '', options.environment, true);
|
|
24
|
+
if (options.environment && scope !== distro_1.SCOPE.ENVIRONMENT) {
|
|
25
|
+
output_1.default.exitError(texts_1.ERR_COMMAND_DISTRO_ENVIRONMENT_SCOPE);
|
|
26
|
+
}
|
|
27
|
+
const ctx = {
|
|
28
|
+
scope,
|
|
29
|
+
project: scope === distro_1.SCOPE.WORKSPACE ? null : project,
|
|
30
|
+
environment: null,
|
|
31
|
+
environmentId: null,
|
|
32
|
+
api: {},
|
|
33
|
+
distributionId: null,
|
|
34
|
+
};
|
|
35
|
+
let resolved = null;
|
|
36
|
+
if (scope === distro_1.SCOPE.ENVIRONMENT) {
|
|
37
|
+
const environment = options.environment;
|
|
38
|
+
resolved = await client.getResourceByIdentifier(workspace, {
|
|
39
|
+
project: project || undefined,
|
|
40
|
+
environment,
|
|
41
|
+
distribution,
|
|
42
|
+
});
|
|
43
|
+
if (resolved.domain && !resolved.environment_id && project && !options.project) {
|
|
44
|
+
ctx.project = null;
|
|
45
|
+
resolved = await client.getResourceByIdentifier(workspace, {
|
|
46
|
+
environment,
|
|
47
|
+
distribution,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
if (!resolved.domain) {
|
|
51
|
+
output_1.default.exitError(new cliError_1.default('not_found', texts_1.ERR_WORKSPACE_NOT_FOUND, texts_1.HINT_WORKSPACE_LIST));
|
|
52
|
+
}
|
|
53
|
+
if (!resolved.environment_id) {
|
|
54
|
+
output_1.default.exitError(new cliError_1.default('not_found', texts_1.ERR_ENVIRONMENT_NOT_FOUND, texts_1.HINT_ENVIRONMENT_LIST));
|
|
55
|
+
}
|
|
56
|
+
ctx.environment = environment;
|
|
57
|
+
ctx.environmentId = resolved.environment_id;
|
|
58
|
+
ctx.api = { environmentId: ctx.environmentId };
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
ctx.api = { project: ctx.project };
|
|
62
|
+
if (distribution) {
|
|
63
|
+
resolved = await client.getDistributionByIdentifier(workspace, { project: ctx.project }, distribution);
|
|
64
|
+
if (!resolved.domain) {
|
|
65
|
+
output_1.default.exitError(new cliError_1.default('not_found', texts_1.ERR_WORKSPACE_NOT_FOUND, texts_1.HINT_WORKSPACE_LIST));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (distribution) {
|
|
70
|
+
if (!resolved?.distribution_id) {
|
|
71
|
+
output_1.default.exitError(new cliError_1.default('not_found', texts_1.ERR_COMMAND_DISTRO_NOT_FOUND, texts_1.HINT_DISTRO_LIST));
|
|
72
|
+
}
|
|
73
|
+
ctx.distributionId = resolved.distribution_id;
|
|
74
|
+
}
|
|
75
|
+
return ctx;
|
|
76
|
+
};
|
|
77
|
+
exports.resolveDistroContext = resolveDistroContext;
|
|
@@ -3,20 +3,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const cliError_1 = __importDefault(require("../../cliError"));
|
|
7
6
|
const utils_1 = require("../../utils");
|
|
8
7
|
const texts_1 = require("../../texts");
|
|
9
8
|
const input_1 = __importDefault(require("../../input"));
|
|
10
9
|
const output_1 = __importDefault(require("../../output"));
|
|
11
|
-
const
|
|
10
|
+
const scope_1 = require("./scope");
|
|
12
11
|
const commandDistroUpdate = (0, utils_1.newCommand)('update', texts_1.DESC_COMMAND_DISTRO_UPDATE, {
|
|
13
12
|
requiredScopes: [utils_1.REST_API_SCOPE.DISTRIBUTION_WRITE],
|
|
14
13
|
examples: texts_1.EXAMPLE_DISTRO_UPDATE,
|
|
15
14
|
});
|
|
16
15
|
commandDistroUpdate.alias('edit');
|
|
17
16
|
commandDistroUpdate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
18
|
-
commandDistroUpdate.option('--scope <scope>', texts_1.
|
|
17
|
+
commandDistroUpdate.option('--scope <scope>', texts_1.OPT_COMMAND_SCOPE_ENVIRONMENT);
|
|
19
18
|
commandDistroUpdate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
19
|
+
commandDistroUpdate.option('--environment <identifier>', texts_1.OPTION_DISTRO_ENVIRONMENT);
|
|
20
20
|
commandDistroUpdate.option('-n, --name <name>', texts_1.OPT_COMMAND_DISTRO_NAME);
|
|
21
21
|
commandDistroUpdate.option('--note <note>', texts_1.OPT_COMMAND_DISTRO_NOTE);
|
|
22
22
|
commandDistroUpdate.option('--agent-note <note>', texts_1.OPT_COMMAND_DISTRO_AGENT_NOTE);
|
|
@@ -29,8 +29,6 @@ commandDistroUpdate.action(async (identifier, options) => {
|
|
|
29
29
|
output_1.default.exitError(texts_1.ERR_COMMAND_DISTRO_ENABLE_DISABLE);
|
|
30
30
|
}
|
|
31
31
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
32
|
-
const project = input_1.default.restApiProject(options.project, true);
|
|
33
|
-
const scope = input_1.default.scope(project, options.scope);
|
|
34
32
|
const body = {};
|
|
35
33
|
let changed = false;
|
|
36
34
|
if (options.name) {
|
|
@@ -53,14 +51,8 @@ commandDistroUpdate.action(async (identifier, options) => {
|
|
|
53
51
|
output_1.default.exitError(texts_1.ERR_COMMAND_NO_UPDATE);
|
|
54
52
|
}
|
|
55
53
|
const client = input_1.default.restApiTokenClient();
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
output_1.default.exitError(new cliError_1.default('not_found', texts_1.ERR_WORKSPACE_NOT_FOUND, texts_1.HINT_WORKSPACE_LIST));
|
|
59
|
-
}
|
|
60
|
-
if (!data || !data.distribution_id) {
|
|
61
|
-
output_1.default.exitError(new cliError_1.default('not_found', texts_1.ERR_COMMAND_DISTRO_NOT_FOUND, texts_1.HINT_DISTRO_LIST));
|
|
62
|
-
}
|
|
63
|
-
const result = await client.updateDistribution(workspace, scope === distro_1.SCOPE.PROJECT ? project : null, data.distribution_id, body);
|
|
54
|
+
const ctx = await (0, scope_1.resolveDistroContext)(client, workspace, options, identifier);
|
|
55
|
+
const result = await client.updateDistribution(workspace, ctx.api, ctx.distributionId, body);
|
|
64
56
|
if (options.format === 'json') {
|
|
65
57
|
output_1.default.json(result);
|
|
66
58
|
output_1.default.exitNormal();
|
|
@@ -24,6 +24,7 @@ const commandDistro = (0, utils_1.newCommand)('distro', texts_1.DESC_COMMAND_DIS
|
|
|
24
24
|
...texts_1.EXAMPLE_ROUTE_LIST,
|
|
25
25
|
...texts_1.EXAMPLE_ROUTE_GET,
|
|
26
26
|
...texts_1.EXAMPLE_ROUTE_DELETE,
|
|
27
|
+
...texts_1.EXAMPLE_ROUTE_PURGE,
|
|
27
28
|
],
|
|
28
29
|
});
|
|
29
30
|
commandDistro.addCommand(create_1.default);
|
|
@@ -19,7 +19,8 @@ const commandPre = async (_, command) => {
|
|
|
19
19
|
command.agentPort = 0;
|
|
20
20
|
command.agentId = '';
|
|
21
21
|
try {
|
|
22
|
-
|
|
22
|
+
// --agent works on an agent through the REST API: the local one is not asked
|
|
23
|
+
if (!(0, utils_1.isDocker)() && !command.opts()?.agent) {
|
|
23
24
|
const hasConfig = AgentManager.system.hasSystemConfig();
|
|
24
25
|
if (hasConfig) {
|
|
25
26
|
command.agentInstalled = true;
|
package/distTs/src/format.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
7
|
const punycode_1 = __importDefault(require("punycode/"));
|
|
8
8
|
const tunnel_1 = require("./types/tunnel");
|
|
9
|
+
const texts_1 = require("./texts");
|
|
9
10
|
class Format {
|
|
10
11
|
static date() {
|
|
11
12
|
const dt = new Date();
|
|
@@ -132,7 +133,12 @@ class Format {
|
|
|
132
133
|
static entryHostEncoded(tunnel) {
|
|
133
134
|
return punycode_1.default.toASCII(this.entryHost(tunnel));
|
|
134
135
|
}
|
|
136
|
+
// No ssh id yet: the tunnel has no registration on the proxy, so no address
|
|
137
|
+
// either (the REST view then leaves out `ssh` and `endpoint_url` alike).
|
|
135
138
|
static entry(tunnel) {
|
|
139
|
+
if (tunnel.sshId === undefined || tunnel.sshId === null) {
|
|
140
|
+
return texts_1.TXT_TUNNEL_ENTRY_PENDING;
|
|
141
|
+
}
|
|
136
142
|
let entry = '';
|
|
137
143
|
if (tunnel.type === tunnel_1.TUNNEL_TYPE.HTTP)
|
|
138
144
|
entry += 'https://';
|