bdy 1.22.42-dev → 1.22.42-dev-distro-dev-distro

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.22.42-dev",
4
+ "version": "1.22.42-dev-distro-dev-distro",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -20,7 +20,8 @@
20
20
  "e2e:api": "vitest run --config e2e/vitest.config.ts e2e/modules/api/",
21
21
  "e2e:pipeline": "vitest run --config e2e/vitest.config.ts e2e/modules/pipeline/",
22
22
  "e2e:tunnel": "vitest run --config e2e/vitest.config.ts e2e/modules/tunnel/",
23
- "e2e:agent": "vitest run --config e2e/vitest.config.ts e2e/modules/agent/"
23
+ "e2e:agent": "vitest run --config e2e/vitest.config.ts e2e/modules/agent/",
24
+ "e2e:distro": "vitest run --config e2e/vitest.config.ts e2e/modules/distro/"
24
25
  },
25
26
  "files": [
26
27
  "distTs"
@@ -240,7 +240,7 @@ class ApiClient {
240
240
  method: 'PATCH',
241
241
  path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/yaml`,
242
242
  body,
243
- parseResponseBody: true
243
+ parseResponseBody: true,
244
244
  });
245
245
  }
246
246
  async createPipeline(workspace, project, body) {
@@ -248,7 +248,7 @@ class ApiClient {
248
248
  method: 'POST',
249
249
  path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines`,
250
250
  body,
251
- parseResponseBody: true
251
+ parseResponseBody: true,
252
252
  });
253
253
  }
254
254
  async getPipelines(workspace, project, page = 1, perPage = 10) {
@@ -438,6 +438,77 @@ class ApiClient {
438
438
  parseResponseBody: false,
439
439
  });
440
440
  }
441
+ // Distro methods
442
+ async createDistro(workspace, body) {
443
+ return await this.request({
444
+ method: 'POST',
445
+ path: `/workspaces/${encodeURIComponent(workspace)}/distributions`,
446
+ body,
447
+ parseResponseBody: true,
448
+ });
449
+ }
450
+ async deleteRoute(workspace, project, distributionId, routeId) {
451
+ const query = {};
452
+ if (project)
453
+ query.project_name = project;
454
+ return await this.request({
455
+ method: 'DELETE',
456
+ path: `/workspaces/${encodeURIComponent(workspace)}/distributions/${encodeURIComponent(distributionId)}/routes/${encodeURIComponent(routeId)}`,
457
+ query
458
+ });
459
+ }
460
+ async listRoutes(workspace, project, distributionId) {
461
+ const query = {};
462
+ if (project)
463
+ query.project_name = project;
464
+ return await this.request({
465
+ method: 'GET',
466
+ path: `/workspaces/${encodeURIComponent(workspace)}/distributions/${encodeURIComponent(distributionId)}/routes`,
467
+ query,
468
+ parseResponseBody: true
469
+ });
470
+ }
471
+ async createRoute(workspace, project, distributionId, body) {
472
+ const query = {};
473
+ if (project)
474
+ query.project_name = project;
475
+ return await this.request({
476
+ method: 'POST',
477
+ path: `/workspaces/${encodeURIComponent(workspace)}/distributions/${encodeURIComponent(distributionId)}/routes`,
478
+ query,
479
+ body,
480
+ parseResponseBody: true,
481
+ });
482
+ }
483
+ async deleteDistribution(workspace, project, distributionId) {
484
+ const query = {};
485
+ if (project)
486
+ query.project_name = project;
487
+ return await this.request({
488
+ method: 'DELETE',
489
+ path: `/workspaces/${encodeURIComponent(workspace)}/distributions/${encodeURIComponent(distributionId)}`,
490
+ query,
491
+ });
492
+ }
493
+ async getDistributions(workspace, project) {
494
+ const query = {};
495
+ if (project)
496
+ query.project_name = project;
497
+ return await this.request({
498
+ method: 'GET',
499
+ path: `/workspaces/${encodeURIComponent(workspace)}/distributions`,
500
+ query,
501
+ parseResponseBody: true,
502
+ });
503
+ }
504
+ async getDistributionByIdentifier(workspace, project, identifier) {
505
+ const q = {
506
+ distribution: identifier,
507
+ };
508
+ if (project)
509
+ q.project = project;
510
+ return await this.getResourceByIdentifier(workspace, q);
511
+ }
441
512
  // Sandbox methods
442
513
  async createSandbox(workspace, project, body) {
443
514
  return await this.request({
@@ -24,6 +24,7 @@ const artifact_1 = __importDefault(require("./command/artifact"));
24
24
  const api_1 = __importDefault(require("./command/api"));
25
25
  const domain_1 = __importDefault(require("./command/domain"));
26
26
  const main_1 = __importDefault(require("./main"));
27
+ const distro_1 = __importDefault(require("./command/distro"));
27
28
  function cliIndex() {
28
29
  const program = (0, utils_1.newCommand)('', texts_1.DESC_PROGRAM);
29
30
  program.hook('preAction', pre_1.default);
@@ -40,6 +41,7 @@ function cliIndex() {
40
41
  program.addCommand(artifact_1.default);
41
42
  program.addCommand(sandbox_1.default);
42
43
  program.addCommand(domain_1.default);
44
+ program.addCommand(distro_1.default);
43
45
  program.addCommand(login_1.default);
44
46
  program.addCommand(whoami_1.default);
45
47
  program.addCommand(logout_1.default);
@@ -0,0 +1,40 @@
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 commandDistroCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_DISTRO_CREATE);
11
+ commandDistroCreate.alias('add');
12
+ commandDistroCreate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
+ commandDistroCreate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
+ commandDistroCreate.option('-s, --scope <scope>', texts_1.OPT_COMMAND_DISTRO_SCOPE);
15
+ commandDistroCreate.option('-i, --identifier <identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
16
+ commandDistroCreate.option('-n, --name <name>', texts_1.OPT_COMMAND_DISTRO_NAME);
17
+ commandDistroCreate.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_DISTRO_CREATE}`);
18
+ commandDistroCreate.action(async (options) => {
19
+ const humanId = require('human-id').default;
20
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
21
+ const project = input_1.default.restApiProject(options.project, true);
22
+ const client = input_1.default.restApiTokenClient();
23
+ const scope = input_1.default.distroScope(project, options.scope);
24
+ const timestamp = Date.now().toString(36);
25
+ const baseName = humanId({ separator: '-', capitalize: false });
26
+ const defaultIdentifier = `${baseName}-${timestamp}`;
27
+ const body = {
28
+ name: options.name || options.identifier || baseName,
29
+ identifier: options.identifier || defaultIdentifier,
30
+ scope,
31
+ };
32
+ if (project)
33
+ body.project_name = project;
34
+ const result = await client.createDistro(workspace, body);
35
+ output_1.default.identifier(result.identifier);
36
+ output_1.default.cyan(result.html_url);
37
+ output_1.default.green(texts_1.TXT_COMMAND_DISTRO_CREATED);
38
+ output_1.default.exitNormal();
39
+ });
40
+ exports.default = commandDistroCreate;
@@ -0,0 +1,38 @@
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 commandDistroDelete = (0, utils_1.newCommand)('delete', texts_1.DESC_COMMAND_DISTRO_DELETE);
11
+ commandDistroDelete.alias('rm');
12
+ commandDistroDelete.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
+ commandDistroDelete.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
+ commandDistroDelete.option('-f, --force', texts_1.OPTION_CONFIRM_FORCE);
15
+ commandDistroDelete.argument('<identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
16
+ commandDistroDelete.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_DISTRO_DELETE}`);
17
+ commandDistroDelete.action(async (identifier, options) => {
18
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
19
+ const project = input_1.default.restApiProject(options.project, true);
20
+ const client = input_1.default.restApiTokenClient();
21
+ const data = await client.getDistributionByIdentifier(workspace, project, identifier);
22
+ if (!data || !data.domain) {
23
+ output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
24
+ }
25
+ if (!data || !data.distribution_id) {
26
+ output_1.default.exitError(texts_1.ERR_COMMAND_DISTRO_NOT_FOUND);
27
+ }
28
+ const confirmed = options.force ||
29
+ (await output_1.default.confirm((0, texts_1.TXT_COMMAND_DISTRO_DELETE_CONFIRM)(identifier)));
30
+ if (confirmed) {
31
+ await client.deleteDistribution(workspace, project, data.distribution_id);
32
+ output_1.default.exitSuccess(texts_1.TXT_COMMAND_DISTRO_DELETED);
33
+ }
34
+ else {
35
+ output_1.default.exitNormal();
36
+ }
37
+ });
38
+ exports.default = commandDistroDelete;
@@ -0,0 +1,35 @@
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 commandDistroList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_DISTRO_LIST);
11
+ commandDistroList.alias('ls');
12
+ commandDistroList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
+ commandDistroList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
+ commandDistroList.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_DISTRO_LIST}`);
15
+ commandDistroList.action(async (options) => {
16
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
17
+ const project = input_1.default.restApiProject(options.project, true);
18
+ const client = input_1.default.restApiTokenClient();
19
+ const r = await client.getDistributions(workspace, project);
20
+ if (!r.distributions?.length) {
21
+ output_1.default.exitNormal(texts_1.TXT_COMMAND_DISTROS_NOT_FOUND);
22
+ }
23
+ const data = [['NAME', 'ID', 'IDENTIFIER', 'URL']];
24
+ for (const d of r.distributions) {
25
+ data.push([
26
+ d.name || '-',
27
+ String(d.id || '-'),
28
+ d.identifier || '-',
29
+ d.html_url || '-',
30
+ ]);
31
+ }
32
+ output_1.default.table(data);
33
+ output_1.default.exitNormal();
34
+ });
35
+ exports.default = commandDistroList;
@@ -0,0 +1,50 @@
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 commandDistroRouteCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_ROUTE_CREATE);
11
+ commandDistroRouteCreate.alias('add');
12
+ commandDistroRouteCreate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
+ commandDistroRouteCreate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
+ commandDistroRouteCreate.option('-t, --type <type>', texts_1.OPT_COMMAND_ROUTE_TYPE);
15
+ commandDistroRouteCreate.option('-s, --subdomain <subdomain>', texts_1.OPT_COMMAND_ROUTE_SUBDOMAIN);
16
+ commandDistroRouteCreate.option('-d, --domain <domain>', texts_1.OPT_COMMAND_ROUTE_DOMAIN);
17
+ commandDistroRouteCreate.option('--path <path>', texts_1.OPT_COMMAND_ROUTE_PATH);
18
+ commandDistroRouteCreate.option('--target <targets...>', texts_1.OPT_COMMAND_ROUTE_TARGET);
19
+ commandDistroRouteCreate.argument('<identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
20
+ commandDistroRouteCreate.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_ROUTE_CREATE}`);
21
+ commandDistroRouteCreate.action(async (identifier, options) => {
22
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
23
+ const project = input_1.default.restApiProject(options.project, true);
24
+ const client = input_1.default.restApiTokenClient();
25
+ const type = input_1.default.routeType(options.type);
26
+ const body = {
27
+ type,
28
+ targets: {}
29
+ };
30
+ if (options.subdomain)
31
+ body.subdomain = options.subdomain;
32
+ if (options.domain)
33
+ body.domain = options.domain;
34
+ if (options.path)
35
+ body.path = input_1.default.routePath(options.path);
36
+ const data = await client.getDistributionByIdentifier(workspace, project, identifier);
37
+ if (!data?.domain) {
38
+ output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
39
+ }
40
+ if (!data?.distribution_id) {
41
+ output_1.default.exitError(texts_1.ERR_COMMAND_DISTRO_NOT_FOUND);
42
+ }
43
+ body.targets = await input_1.default.routeTarget(client, workspace, project, options.target);
44
+ const result = await client.createRoute(workspace, project, data.distribution_id, body);
45
+ output_1.default.id(result.id);
46
+ output_1.default.cyan(result.html_url);
47
+ output_1.default.green(texts_1.TXT_COMMAND_ROUTE_CREATED);
48
+ output_1.default.exitNormal();
49
+ });
50
+ exports.default = commandDistroRouteCreate;
@@ -0,0 +1,39 @@
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 commandDistroRouteDelete = (0, utils_1.newCommand)('delete', texts_1.DESC_COMMAND_ROUTE_DELETE);
11
+ commandDistroRouteDelete.alias('rm');
12
+ commandDistroRouteDelete.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
+ commandDistroRouteDelete.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
+ commandDistroRouteDelete.option('-f, --force', texts_1.OPTION_CONFIRM_FORCE);
15
+ commandDistroRouteDelete.argument('<identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
16
+ commandDistroRouteDelete.argument('<route-id>', texts_1.OPT_COMMAND_ROUTE_ID);
17
+ commandDistroRouteDelete.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_ROUTE_DELETE}`);
18
+ commandDistroRouteDelete.action(async (identifier, routeId, options) => {
19
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
20
+ const project = input_1.default.restApiProject(options.project, true);
21
+ const client = input_1.default.restApiTokenClient();
22
+ const data = await client.getDistributionByIdentifier(workspace, project, identifier);
23
+ if (!data?.domain) {
24
+ output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
25
+ }
26
+ if (!data?.distribution_id) {
27
+ output_1.default.exitError(texts_1.ERR_COMMAND_DISTRO_NOT_FOUND);
28
+ }
29
+ const confirmed = options.force ||
30
+ (await output_1.default.confirm((0, texts_1.TXT_COMMAND_ROUTE_DELETE_CONFIRM)(identifier, routeId)));
31
+ if (confirmed) {
32
+ await client.deleteRoute(workspace, project, data.distribution_id, routeId);
33
+ output_1.default.exitSuccess(texts_1.TXT_COMMAND_ROUTE_DELETED);
34
+ }
35
+ else {
36
+ output_1.default.exitNormal();
37
+ }
38
+ });
39
+ exports.default = commandDistroRouteDelete;
@@ -0,0 +1,45 @@
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 commandDistroRouteList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_ROUTE_LIST);
11
+ commandDistroRouteList.alias('ls');
12
+ commandDistroRouteList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
+ commandDistroRouteList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
+ commandDistroRouteList.argument('<identifier>', texts_1.OPT_COMMAND_DISTRO_IDENTIFIER);
15
+ commandDistroRouteList.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_ROUTE_LIST}`);
16
+ commandDistroRouteList.action(async (identifier, options) => {
17
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
18
+ const project = input_1.default.restApiProject(options.project, true);
19
+ const client = input_1.default.restApiTokenClient();
20
+ const data = await client.getDistributionByIdentifier(workspace, project, identifier);
21
+ if (!data?.domain) {
22
+ output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
23
+ }
24
+ if (!data?.distribution_id) {
25
+ output_1.default.exitError(texts_1.ERR_COMMAND_DISTRO_NOT_FOUND);
26
+ }
27
+ const r = await client.listRoutes(workspace, project, data.distribution_id);
28
+ if (!r.routes?.length) {
29
+ output_1.default.exitNormal(texts_1.TXT_COMMAND_ROUTES_NOT_FOUND);
30
+ }
31
+ const table = [['ID', 'TYPE', 'SUBDOMAIN', 'DOMAIN', 'PATH', 'URL']];
32
+ for (const route of r.routes) {
33
+ table.push([
34
+ route.id || '-',
35
+ route.type || '-',
36
+ route.subdomain || '-',
37
+ route.domain || '-',
38
+ route.path || '-',
39
+ route.html_url || '-',
40
+ ]);
41
+ }
42
+ output_1.default.table(table);
43
+ output_1.default.exitNormal();
44
+ });
45
+ exports.default = commandDistroRouteList;
@@ -0,0 +1,18 @@
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 create_1 = __importDefault(require("./route/create"));
9
+ const list_1 = __importDefault(require("./route/list"));
10
+ const delete_1 = __importDefault(require("./route/delete"));
11
+ const commandDistroRoute = (0, utils_1.newCommand)('route', texts_1.DESC_COMMAND_ROUTE);
12
+ commandDistroRoute.addCommand(create_1.default);
13
+ commandDistroRoute.addCommand(list_1.default);
14
+ commandDistroRoute.addCommand(delete_1.default);
15
+ commandDistroRoute.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_ROUTE_CREATE}
16
+ ${texts_1.EXAMPLE_ROUTE_LIST}
17
+ ${texts_1.EXAMPLE_ROUTE_DELETE}`);
18
+ exports.default = commandDistroRoute;
@@ -0,0 +1,23 @@
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 create_1 = __importDefault(require("./distro/create"));
9
+ const delete_1 = __importDefault(require("./distro/delete"));
10
+ const list_1 = __importDefault(require("./distro/list"));
11
+ const route_1 = __importDefault(require("./distro/route"));
12
+ const commandDistro = (0, utils_1.newCommand)('distro', texts_1.DESC_COMMAND_DISTRO);
13
+ commandDistro.addCommand(create_1.default);
14
+ commandDistro.addCommand(list_1.default);
15
+ commandDistro.addCommand(delete_1.default);
16
+ commandDistro.addCommand(route_1.default);
17
+ commandDistro.addHelpText('after', `\nEXAMPLES:${texts_1.EXAMPLE_DISTRO_CREATE}
18
+ ${texts_1.EXAMPLE_DISTRO_LIST}
19
+ ${texts_1.EXAMPLE_DISTRO_DELETE}
20
+ ${texts_1.EXAMPLE_ROUTE_CREATE}
21
+ ${texts_1.EXAMPLE_ROUTE_LIST}
22
+ ${texts_1.EXAMPLE_ROUTE_DELETE}`);
23
+ exports.default = commandDistro;
@@ -29,6 +29,7 @@ const OAUTH_CLIENT_APP_SCOPES = [
29
29
  'INTEGRATION_MANAGE',
30
30
  'SANDBOX_MANAGE',
31
31
  'ARTIFACT_MANAGE',
32
+ 'DISTRIBUTION_MANAGE',
32
33
  'TUNNEL_MANAGE',
33
34
  'UNIT_TEST_MANAGE',
34
35
  ];
@@ -23,7 +23,7 @@ commandPipelineList.action(async (options) => {
23
23
  const client = input_1.default.restApiTokenClient();
24
24
  const r = await client.getPipelines(workspace, project, page, perPage);
25
25
  if (!r.pipelines.length) {
26
- output_1.default.exitError(texts_1.ERR_PIPELINES_NOT_FOUND);
26
+ output_1.default.exitNormal(texts_1.TXT_PIPELINES_NOT_FOUND);
27
27
  }
28
28
  if (options.format === 'json') {
29
29
  output_1.default.json(r.pipelines);
@@ -0,0 +1,62 @@
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 pipeline_1 = require("../../../types/pipeline");
11
+ const commandPipelineRunApply = (0, utils_1.newCommand)('apply', texts_1.DESC_COMMAND_PIPELINE_RUN_APPLY);
12
+ commandPipelineRunApply.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
+ commandPipelineRunApply.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
+ commandPipelineRunApply.option('-n, --no-wait', texts_1.OPTION_PIPELINE_RUN_NO_WAIT);
15
+ commandPipelineRunApply.argument('<identifier>', texts_1.OPTION_PIPELINE_RUN_ARGUMENT);
16
+ commandPipelineRunApply.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
17
+ commandPipelineRunApply.argument('<run-action-id>', texts_1.OPTION_PIPELINE_RUN_ACTION_ID);
18
+ commandPipelineRunApply.option('-v,--variable <variables...>', texts_1.OPTION_PIPELINE_RUN_VAR);
19
+ commandPipelineRunApply.addHelpText('after', texts_1.EXAMPLE_PIPELINE_RUN_APPLY);
20
+ commandPipelineRunApply.action(async (identifier, runId, runActionId, options) => {
21
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
22
+ const project = input_1.default.restApiProject(options.project);
23
+ const rid = input_1.default.pipelineRunId(runId);
24
+ const variables = input_1.default.pipelineRunVariable(options.variable || [], false);
25
+ const client = input_1.default.restApiTokenClient();
26
+ const data = await client.getPipelineByIdentifier(workspace, project, identifier);
27
+ if (!data || !data.domain) {
28
+ output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
29
+ }
30
+ if (!data.project_identifier) {
31
+ output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
32
+ }
33
+ if (!data.pipeline_id) {
34
+ output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
35
+ }
36
+ const a = await client.getPipelineRunActionExecution(workspace, project, data.pipeline_id, rid, runActionId);
37
+ let type;
38
+ if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_APPLY) {
39
+ type = 'APPLY';
40
+ }
41
+ else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VT_SESSION) {
42
+ type = 'APPROVE_VT';
43
+ }
44
+ else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VARIABLES) {
45
+ type = 'APPLY_VARIABLES';
46
+ }
47
+ else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_SETTABLE_VARIABLES) {
48
+ type = 'SET_VARIABLES';
49
+ }
50
+ else {
51
+ output_1.default.exitError(texts_1.ERR_CANT_APPLY_ACTION_EXECUTION);
52
+ }
53
+ const body = {
54
+ operation: type,
55
+ approve_action_id: runActionId,
56
+ variables,
57
+ };
58
+ await client.pipelineRunApply(workspace, project, data.pipeline_id, rid, body);
59
+ const OutputPipeline = require('../../../output/pipeline').default;
60
+ await OutputPipeline.runStatus(client, workspace, project, data.pipeline_id, rid, !options.wait);
61
+ });
62
+ exports.default = commandPipelineRunApply;