bdy 1.25.39-stage → 1.25.41-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 +70 -59
- 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/variable/inject.js +218 -0
- package/distTs/src/command/variable/injection.js +182 -0
- package/distTs/src/command/variable/secretMask.js +100 -0
- package/distTs/src/command/variable.js +2 -0
- package/distTs/src/input.js +33 -10
- package/distTs/src/texts.js +125 -14
- package/distTs/src/utils.js +15 -3
- package/package.json +1 -1
package/distTs/package.json
CHANGED
package/distTs/src/api/client.js
CHANGED
|
@@ -529,120 +529,131 @@ class ApiClient {
|
|
|
529
529
|
});
|
|
530
530
|
}
|
|
531
531
|
// Distro methods
|
|
532
|
+
// An environment-scoped distribution is found only with its environment
|
|
533
|
+
// (`environment_id`), which then decides alone - the backend ignores the
|
|
534
|
+
// project next to it, so it is not sent.
|
|
535
|
+
distroQuery(scope) {
|
|
536
|
+
const query = {};
|
|
537
|
+
if (scope.environmentId)
|
|
538
|
+
query.environment_id = scope.environmentId;
|
|
539
|
+
else if (scope.project)
|
|
540
|
+
query.project_name = scope.project;
|
|
541
|
+
return query;
|
|
542
|
+
}
|
|
543
|
+
distroPath(workspace, distributionId) {
|
|
544
|
+
let path = `/workspaces/${encodeURIComponent(workspace)}/distributions`;
|
|
545
|
+
if (distributionId)
|
|
546
|
+
path += `/${encodeURIComponent(distributionId)}`;
|
|
547
|
+
return path;
|
|
548
|
+
}
|
|
549
|
+
routePath(workspace, distributionId, routeId) {
|
|
550
|
+
let path = `${this.distroPath(workspace, distributionId)}/routes`;
|
|
551
|
+
if (routeId)
|
|
552
|
+
path += `/${encodeURIComponent(routeId)}`;
|
|
553
|
+
return path;
|
|
554
|
+
}
|
|
532
555
|
async createDistro(workspace, body) {
|
|
533
556
|
return await this.request({
|
|
534
557
|
method: 'POST',
|
|
535
|
-
path:
|
|
558
|
+
path: this.distroPath(workspace),
|
|
536
559
|
body,
|
|
537
560
|
parseResponseBody: true,
|
|
538
561
|
});
|
|
539
562
|
}
|
|
540
|
-
async deleteRoute(workspace,
|
|
541
|
-
const query = {};
|
|
542
|
-
if (project)
|
|
543
|
-
query.project_name = project;
|
|
563
|
+
async deleteRoute(workspace, scope, distributionId, routeId) {
|
|
544
564
|
return await this.request({
|
|
545
565
|
method: 'DELETE',
|
|
546
|
-
path:
|
|
547
|
-
query,
|
|
566
|
+
path: this.routePath(workspace, distributionId, routeId),
|
|
567
|
+
query: this.distroQuery(scope),
|
|
548
568
|
});
|
|
549
569
|
}
|
|
550
|
-
async listRoutes(workspace,
|
|
551
|
-
const query = {};
|
|
552
|
-
if (project)
|
|
553
|
-
query.project_name = project;
|
|
570
|
+
async listRoutes(workspace, scope, distributionId) {
|
|
554
571
|
return await this.request({
|
|
555
572
|
method: 'GET',
|
|
556
|
-
path:
|
|
557
|
-
query,
|
|
573
|
+
path: this.routePath(workspace, distributionId),
|
|
574
|
+
query: this.distroQuery(scope),
|
|
558
575
|
parseResponseBody: true,
|
|
559
576
|
});
|
|
560
577
|
}
|
|
561
|
-
async getRoute(workspace,
|
|
562
|
-
const query = {};
|
|
563
|
-
if (project)
|
|
564
|
-
query.project_name = project;
|
|
578
|
+
async getRoute(workspace, scope, distributionId, routeId) {
|
|
565
579
|
return await this.request({
|
|
566
580
|
method: 'GET',
|
|
567
|
-
path:
|
|
568
|
-
query,
|
|
581
|
+
path: this.routePath(workspace, distributionId, routeId),
|
|
582
|
+
query: this.distroQuery(scope),
|
|
569
583
|
parseResponseBody: true,
|
|
570
584
|
});
|
|
571
585
|
}
|
|
572
|
-
async updateRoute(workspace,
|
|
573
|
-
const query = {};
|
|
574
|
-
if (project)
|
|
575
|
-
query.project_name = project;
|
|
586
|
+
async updateRoute(workspace, scope, distributionId, routeId, body) {
|
|
576
587
|
return await this.request({
|
|
577
588
|
method: 'PUT',
|
|
578
|
-
path:
|
|
579
|
-
query,
|
|
589
|
+
path: this.routePath(workspace, distributionId, routeId),
|
|
590
|
+
query: this.distroQuery(scope),
|
|
580
591
|
body,
|
|
581
592
|
parseResponseBody: true,
|
|
582
593
|
});
|
|
583
594
|
}
|
|
584
|
-
async createRoute(workspace,
|
|
585
|
-
const query = {};
|
|
586
|
-
if (project)
|
|
587
|
-
query.project_name = project;
|
|
595
|
+
async createRoute(workspace, scope, distributionId, body) {
|
|
588
596
|
return await this.request({
|
|
589
597
|
method: 'POST',
|
|
590
|
-
path:
|
|
591
|
-
query,
|
|
598
|
+
path: this.routePath(workspace, distributionId),
|
|
599
|
+
query: this.distroQuery(scope),
|
|
592
600
|
body,
|
|
593
601
|
parseResponseBody: true,
|
|
594
602
|
});
|
|
595
603
|
}
|
|
596
|
-
async
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
604
|
+
async purgeRouteCache(workspace, scope, distributionId, routeId, body) {
|
|
605
|
+
return await this.request({
|
|
606
|
+
method: 'POST',
|
|
607
|
+
path: `${this.routePath(workspace, distributionId, routeId)}/cache`,
|
|
608
|
+
query: this.distroQuery(scope),
|
|
609
|
+
body,
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
async deleteDistribution(workspace, scope, distributionId) {
|
|
600
613
|
return await this.request({
|
|
601
614
|
method: 'DELETE',
|
|
602
|
-
path:
|
|
603
|
-
query,
|
|
615
|
+
path: this.distroPath(workspace, distributionId),
|
|
616
|
+
query: this.distroQuery(scope),
|
|
604
617
|
});
|
|
605
618
|
}
|
|
606
|
-
async updateDistribution(workspace,
|
|
607
|
-
const query = {};
|
|
608
|
-
if (project)
|
|
609
|
-
query.project_name = project;
|
|
619
|
+
async updateDistribution(workspace, scope, distributionId, body) {
|
|
610
620
|
return await this.request({
|
|
611
621
|
method: 'PATCH',
|
|
612
|
-
path:
|
|
613
|
-
query,
|
|
622
|
+
path: this.distroPath(workspace, distributionId),
|
|
623
|
+
query: this.distroQuery(scope),
|
|
614
624
|
body,
|
|
615
625
|
parseResponseBody: true,
|
|
616
626
|
});
|
|
617
627
|
}
|
|
618
|
-
async getDistribution(workspace,
|
|
619
|
-
const query = {};
|
|
620
|
-
if (project)
|
|
621
|
-
query.project_name = project;
|
|
628
|
+
async getDistribution(workspace, scope, distributionId) {
|
|
622
629
|
return await this.request({
|
|
623
630
|
method: 'GET',
|
|
624
|
-
path:
|
|
625
|
-
query,
|
|
631
|
+
path: this.distroPath(workspace, distributionId),
|
|
632
|
+
query: this.distroQuery(scope),
|
|
626
633
|
parseResponseBody: true,
|
|
627
634
|
});
|
|
628
635
|
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
query.project_name = project;
|
|
636
|
+
// Exact scope: with an environment only its distributions, with a project
|
|
637
|
+
// only the project's, else only the workspace's.
|
|
638
|
+
async getDistributions(workspace, scope) {
|
|
633
639
|
return await this.request({
|
|
634
640
|
method: 'GET',
|
|
635
|
-
path:
|
|
636
|
-
query,
|
|
641
|
+
path: this.distroPath(workspace),
|
|
642
|
+
query: this.distroQuery(scope),
|
|
637
643
|
parseResponseBody: true,
|
|
638
644
|
});
|
|
639
645
|
}
|
|
640
|
-
|
|
646
|
+
// `environment` is the environment's identifier (it narrows the lookup to
|
|
647
|
+
// that environment's distributions); `project` narrows the environment, or
|
|
648
|
+
// the distribution itself when no environment is given.
|
|
649
|
+
async getDistributionByIdentifier(workspace, line, identifier) {
|
|
641
650
|
const q = {
|
|
642
651
|
distribution: identifier,
|
|
643
652
|
};
|
|
644
|
-
if (project)
|
|
645
|
-
q.project = project;
|
|
653
|
+
if (line.project)
|
|
654
|
+
q.project = line.project;
|
|
655
|
+
if (line.environment)
|
|
656
|
+
q.environment = line.environment;
|
|
646
657
|
return await this.getResourceByIdentifier(workspace, q);
|
|
647
658
|
}
|
|
648
659
|
// Target methods
|
|
@@ -1741,7 +1752,7 @@ class ApiClient {
|
|
|
1741
1752
|
case notes_1.PARENT_NOTE_TYPE.ARTIFACT:
|
|
1742
1753
|
return await this.getArtifact(workspace, id);
|
|
1743
1754
|
case notes_1.PARENT_NOTE_TYPE.DISTRIBUTION:
|
|
1744
|
-
return await this.getDistribution(workspace, ref.project
|
|
1755
|
+
return await this.getDistribution(workspace, { project: ref.project, environmentId: ref.environmentId }, id);
|
|
1745
1756
|
}
|
|
1746
1757
|
}
|
|
1747
1758
|
// Notes of the parents, closest first, each on its own and skipped when it
|
|
@@ -8,6 +8,7 @@ const texts_1 = require("../../texts");
|
|
|
8
8
|
const input_1 = __importDefault(require("../../input"));
|
|
9
9
|
const output_1 = __importDefault(require("../../output"));
|
|
10
10
|
const distro_1 = require("../../types/distro");
|
|
11
|
+
const scope_1 = require("./scope");
|
|
11
12
|
const commandDistroCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_DISTRO_CREATE, {
|
|
12
13
|
requiredScopes: [utils_1.REST_API_SCOPE.DISTRIBUTION_WRITE],
|
|
13
14
|
examples: texts_1.EXAMPLE_DISTRO_CREATE,
|
|
@@ -15,7 +16,8 @@ const commandDistroCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMA
|
|
|
15
16
|
commandDistroCreate.alias('add');
|
|
16
17
|
commandDistroCreate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
17
18
|
commandDistroCreate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
18
|
-
commandDistroCreate.option('--
|
|
19
|
+
commandDistroCreate.option('--environment <identifier>', texts_1.OPTION_DISTRO_ENVIRONMENT);
|
|
20
|
+
commandDistroCreate.option('--scope <scope>', texts_1.OPT_COMMAND_SCOPE_ENVIRONMENT);
|
|
19
21
|
commandDistroCreate.option('-i, --identifier <identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
|
|
20
22
|
commandDistroCreate.option('-n, --name <name>', texts_1.OPT_COMMAND_DISTRO_NAME);
|
|
21
23
|
commandDistroCreate.option('--note <note>', texts_1.OPT_COMMAND_DISTRO_NOTE);
|
|
@@ -24,16 +26,15 @@ commandDistroCreate.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
|
24
26
|
commandDistroCreate.action(async (options) => {
|
|
25
27
|
const humanId = require('human-id').default;
|
|
26
28
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
27
|
-
const project = input_1.default.restApiProject(options.project, true);
|
|
28
29
|
const client = input_1.default.restApiTokenClient();
|
|
29
|
-
const
|
|
30
|
+
const ctx = await (0, scope_1.resolveDistroContext)(client, workspace, options);
|
|
30
31
|
const timestamp = Date.now().toString(36);
|
|
31
32
|
const baseName = humanId({ separator: '-', capitalize: false });
|
|
32
33
|
const defaultIdentifier = `${baseName}-${timestamp}`;
|
|
33
34
|
const body = {
|
|
34
35
|
name: options.name || options.identifier || baseName,
|
|
35
36
|
identifier: options.identifier || defaultIdentifier,
|
|
36
|
-
scope,
|
|
37
|
+
scope: ctx.scope,
|
|
37
38
|
};
|
|
38
39
|
if (options.note) {
|
|
39
40
|
body.note = options.note;
|
|
@@ -41,8 +42,12 @@ commandDistroCreate.action(async (options) => {
|
|
|
41
42
|
if (options.agentNote) {
|
|
42
43
|
body.agent_note = options.agentNote;
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
// an environment distribution has no permissions of its own: they follow
|
|
46
|
+
// the environment
|
|
47
|
+
if (ctx.scope === distro_1.SCOPE.ENVIRONMENT)
|
|
48
|
+
body.environment_id = ctx.environmentId;
|
|
49
|
+
else if (ctx.scope === distro_1.SCOPE.PROJECT)
|
|
50
|
+
body.project_name = ctx.project;
|
|
46
51
|
const result = await client.createDistro(workspace, body);
|
|
47
52
|
if (options.format === 'json') {
|
|
48
53
|
output_1.default.json(result);
|
|
@@ -3,39 +3,32 @@ 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 commandDistroDelete = (0, utils_1.newCommand)('delete', texts_1.DESC_COMMAND_DISTRO_DELETE, {
|
|
13
12
|
requiredScopes: [utils_1.REST_API_SCOPE.DISTRIBUTION_MANAGE],
|
|
14
13
|
examples: texts_1.EXAMPLE_DISTRO_DELETE,
|
|
15
14
|
});
|
|
16
15
|
commandDistroDelete.alias('rm');
|
|
17
16
|
commandDistroDelete.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
18
|
-
commandDistroDelete.option('--scope <scope>', texts_1.
|
|
17
|
+
commandDistroDelete.option('--scope <scope>', texts_1.OPT_COMMAND_SCOPE_ENVIRONMENT);
|
|
19
18
|
commandDistroDelete.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
19
|
+
commandDistroDelete.option('--environment <identifier>', texts_1.OPTION_DISTRO_ENVIRONMENT);
|
|
20
20
|
commandDistroDelete.option('-f, --force', texts_1.OPTION_CONFIRM_FORCE);
|
|
21
21
|
commandDistroDelete.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
22
22
|
commandDistroDelete.argument('<identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
|
|
23
23
|
commandDistroDelete.action(async (identifier, options) => {
|
|
24
24
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
25
|
-
const project = input_1.default.restApiProject(options.project, true);
|
|
26
|
-
const scope = input_1.default.scope(project, options.scope);
|
|
27
25
|
const client = input_1.default.restApiTokenClient();
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
output_1.default.exitError(new cliError_1.default('not_found', texts_1.ERR_WORKSPACE_NOT_FOUND, texts_1.HINT_WORKSPACE_LIST));
|
|
31
|
-
}
|
|
32
|
-
if (!data || !data.distribution_id) {
|
|
33
|
-
output_1.default.exitError(new cliError_1.default('not_found', texts_1.ERR_COMMAND_DISTRO_NOT_FOUND, texts_1.HINT_DISTRO_LIST));
|
|
34
|
-
}
|
|
26
|
+
const ctx = await (0, scope_1.resolveDistroContext)(client, workspace, options, identifier);
|
|
27
|
+
const distributionId = ctx.distributionId;
|
|
35
28
|
const json = options.format === 'json';
|
|
36
29
|
const confirmed = await output_1.default.confirmDestructive(options.force, (0, texts_1.TXT_COMMAND_DISTRO_DELETE_CONFIRM)(identifier), json);
|
|
37
30
|
if (confirmed) {
|
|
38
|
-
await client.deleteDistribution(workspace,
|
|
31
|
+
await client.deleteDistribution(workspace, ctx.api, distributionId);
|
|
39
32
|
output_1.default.exitResult(json, { deleted: identifier }, texts_1.TXT_COMMAND_DISTRO_DELETED);
|
|
40
33
|
}
|
|
41
34
|
else {
|
|
@@ -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 commandDistroGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_DISTRO_GET, {
|
|
13
12
|
requiredScopes: [utils_1.REST_API_SCOPE.DISTRIBUTION_READ],
|
|
14
13
|
examples: texts_1.EXAMPLE_DISTRO_GET,
|
|
15
14
|
});
|
|
16
15
|
commandDistroGet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
17
|
-
commandDistroGet.option('--scope <scope>', texts_1.
|
|
16
|
+
commandDistroGet.option('--scope <scope>', texts_1.OPT_COMMAND_SCOPE_ENVIRONMENT);
|
|
18
17
|
commandDistroGet.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
18
|
+
commandDistroGet.option('--environment <identifier>', texts_1.OPTION_DISTRO_ENVIRONMENT);
|
|
19
19
|
commandDistroGet.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
20
20
|
commandDistroGet.option('--no-parent-notes', texts_1.OPTION_NO_PARENT_NOTES);
|
|
21
21
|
commandDistroGet.argument('<identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
|
|
22
22
|
commandDistroGet.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 || !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 distro = await client.getDistribution(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 distro = await client.getDistribution(workspace, ctx.api, distributionId);
|
|
35
28
|
if (options.format === 'json') {
|
|
36
29
|
output_1.default.json(await client.withParentNotes(workspace, distro, options.parentNotes));
|
|
37
30
|
}
|
|
@@ -7,7 +7,7 @@ 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
|
|
10
|
+
const scope_1 = require("./scope");
|
|
11
11
|
const commandDistroList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_DISTRO_LIST, {
|
|
12
12
|
requiredScopes: [utils_1.REST_API_SCOPE.DISTRIBUTION_READ],
|
|
13
13
|
examples: texts_1.EXAMPLE_DISTRO_LIST,
|
|
@@ -15,15 +15,15 @@ const commandDistroList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_D
|
|
|
15
15
|
commandDistroList.alias('ls');
|
|
16
16
|
commandDistroList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
17
17
|
commandDistroList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
18
|
+
commandDistroList.option('--environment <identifier>', texts_1.OPTION_DISTRO_ENVIRONMENT);
|
|
18
19
|
commandDistroList.option('--format <text|json>', texts_1.OPTION_FORMAT);
|
|
19
|
-
commandDistroList.option('--scope <scope>', texts_1.
|
|
20
|
+
commandDistroList.option('--scope <scope>', texts_1.OPT_COMMAND_SCOPE_ENVIRONMENT);
|
|
20
21
|
commandDistroList.action(async (options) => {
|
|
21
22
|
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
22
|
-
const project = input_1.default.restApiProject(options.project, true);
|
|
23
|
-
const scope = input_1.default.scope(project, options.scope);
|
|
24
|
-
input_1.default.projectScopeNote(options, project, scope, 'distributions');
|
|
25
23
|
const client = input_1.default.restApiTokenClient();
|
|
26
|
-
const
|
|
24
|
+
const ctx = await (0, scope_1.resolveDistroContext)(client, workspace, options);
|
|
25
|
+
input_1.default.projectScopeNote(options, ctx.project, ctx.scope, 'distributions');
|
|
26
|
+
const r = await client.getDistributions(workspace, ctx.api);
|
|
27
27
|
const distributions = r.distributions || [];
|
|
28
28
|
if (options.format === 'json') {
|
|
29
29
|
output_1.default.json(distributions);
|
|
@@ -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);
|