bdy 1.18.34-dev-pipeline → 1.19.0-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.
Files changed (59) hide show
  1. package/distTs/package.json +2 -2
  2. package/distTs/src/api/client.js +27 -86
  3. package/distTs/src/command/artifact/create.js +64 -0
  4. package/distTs/src/command/artifact/delete.js +38 -0
  5. package/distTs/src/command/artifact/docker/login.js +26 -0
  6. package/distTs/src/command/artifact/docker.js +11 -0
  7. package/distTs/src/command/artifact/download.js +138 -0
  8. package/distTs/src/command/artifact/get.js +36 -0
  9. package/distTs/src/command/artifact/list.js +31 -0
  10. package/distTs/src/command/artifact/publish.js +241 -0
  11. package/distTs/src/command/artifact/version/delete.js +39 -0
  12. package/distTs/src/command/artifact/version/get.js +45 -0
  13. package/distTs/src/command/artifact/version/list.js +47 -0
  14. package/distTs/src/command/artifact/version.js +16 -0
  15. package/distTs/src/command/artifact.js +26 -0
  16. package/distTs/src/command/login.js +1 -1
  17. package/distTs/src/command/pipeline/run.js +125 -22
  18. package/distTs/src/command/project/get.js +18 -0
  19. package/distTs/src/command/project/link.js +12 -12
  20. package/distTs/src/command/project/set.js +31 -0
  21. package/distTs/src/command/sandbox/get/yaml.js +30 -0
  22. package/distTs/src/command/vt/scrape.js +193 -0
  23. package/distTs/src/index.js +2 -2
  24. package/distTs/src/input.js +18 -19
  25. package/distTs/src/output.js +31 -149
  26. package/distTs/src/texts.js +162 -184
  27. package/distTs/src/tunnel/output/interactive/tunnel.js +2 -2
  28. package/distTs/src/utils.js +37 -37
  29. package/package.json +2 -2
  30. package/distTs/src/command/crawl/link.js +0 -61
  31. package/distTs/src/command/crawl/run.js +0 -147
  32. package/distTs/src/command/crawl/validation.js +0 -154
  33. package/distTs/src/command/crawl.js +0 -13
  34. package/distTs/src/command/pipeline/run/apply.js +0 -62
  35. package/distTs/src/command/pipeline/run/cancel.js +0 -36
  36. package/distTs/src/command/pipeline/run/list.js +0 -52
  37. package/distTs/src/command/pipeline/run/logs.js +0 -37
  38. package/distTs/src/command/pipeline/run/retry.js +0 -36
  39. package/distTs/src/command/pipeline/run/start.js +0 -96
  40. package/distTs/src/command/pipeline/run/status.js +0 -35
  41. package/distTs/src/command/tests/capture/validation.js +0 -46
  42. package/distTs/src/command/tests/capture.js +0 -103
  43. package/distTs/src/command/tests/unit/link.js +0 -61
  44. package/distTs/src/command/tests/unit/upload.js +0 -91
  45. package/distTs/src/command/tests/unit.js +0 -13
  46. package/distTs/src/command/tests/visual/link.js +0 -61
  47. package/distTs/src/command/tests/visual/session/close.js +0 -32
  48. package/distTs/src/command/tests/visual/session/create.js +0 -86
  49. package/distTs/src/command/tests/visual/session.js +0 -13
  50. package/distTs/src/command/tests/visual/setup.js +0 -20
  51. package/distTs/src/command/tests/visual/shared/validation.js +0 -145
  52. package/distTs/src/command/tests/visual/upload.js +0 -141
  53. package/distTs/src/command/tests/visual.js +0 -17
  54. package/distTs/src/command/tests.js +0 -15
  55. package/distTs/src/crawl/requests.js +0 -141
  56. package/distTs/src/output/pipeline.js +0 -1383
  57. package/distTs/src/types/crawl.js +0 -2
  58. package/distTs/src/types/pipeline.js +0 -424
  59. package/distTs/src/unitTest/context.js +0 -26
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bdy",
3
3
  "preferGlobal": false,
4
- "version": "1.18.34-dev-pipeline",
4
+ "version": "1.19.0-dev",
5
5
  "type": "commonjs",
6
6
  "license": "MIT",
7
7
  "scripts": {
@@ -15,7 +15,7 @@
15
15
  "e2e:auth": "vitest run --config e2e/vitest.config.ts e2e/modules/auth/",
16
16
  "e2e:workspace": "vitest run --config e2e/vitest.config.ts e2e/modules/workspace/",
17
17
  "e2e:project": "vitest run --config e2e/vitest.config.ts e2e/modules/project/",
18
- "e2e:package": "vitest run --config e2e/vitest.config.ts e2e/modules/package/",
18
+ "e2e:artifact": "vitest run --config e2e/vitest.config.ts e2e/modules/artifact/",
19
19
  "e2e:sandbox": "vitest run --config e2e/vitest.config.ts e2e/modules/sandbox/",
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/",
@@ -216,37 +216,6 @@ class ApiClient {
216
216
  throw new Error(texts_1.ERR_REST_API_GENERAL_ERROR);
217
217
  }
218
218
  }
219
- async getPipelineRunActionLogs(workspace, project, pipelineId, executionId, actionExecutionId, offset, limit) {
220
- const query = {
221
- offset: String(offset),
222
- limit: String(limit),
223
- };
224
- return await this.request({
225
- method: 'GET',
226
- path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/executions/${encodeURIComponent(executionId)}/action_executions/${encodeURIComponent(actionExecutionId)}/logs`,
227
- query,
228
- parseResponseBody: true,
229
- });
230
- }
231
- async getPipelineRunActionExecution(workspace, project, pipelineId, executionId, actionExecutionId) {
232
- return await this.request({
233
- method: 'GET',
234
- path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/executions/${encodeURIComponent(executionId)}/action_executions/${encodeURIComponent(actionExecutionId)}`,
235
- parseResponseBody: true,
236
- });
237
- }
238
- async getPipelineRuns(workspace, project, pipelineId, page = 1, perPage = 10) {
239
- const query = {
240
- page: String(page),
241
- per_page: String(perPage),
242
- };
243
- return await this.request({
244
- method: 'GET',
245
- path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/executions`,
246
- query,
247
- parseResponseBody: true,
248
- });
249
- }
250
219
  async getPipelineRun(workspace, project, pipelineId, executionId) {
251
220
  return await this.request({
252
221
  method: 'GET',
@@ -287,34 +256,6 @@ class ApiClient {
287
256
  parseResponseBody: true,
288
257
  });
289
258
  }
290
- async pipelineRunRetry(workspace, project, pipelineId, runId) {
291
- return await this.request({
292
- method: 'PATCH',
293
- path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/executions/${encodeURIComponent(runId)}`,
294
- body: {
295
- operation: 'RETRY',
296
- },
297
- parseResponseBody: true,
298
- });
299
- }
300
- async pipelineRunApply(workspace, project, pipelineId, runId, body) {
301
- return await this.request({
302
- method: 'PATCH',
303
- path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/executions/${encodeURIComponent(runId)}`,
304
- body,
305
- parseResponseBody: true,
306
- });
307
- }
308
- async pipelineRunCancel(workspace, project, pipelineId, runId) {
309
- return await this.request({
310
- method: 'PATCH',
311
- path: `/workspaces/${encodeURIComponent(workspace)}/projects/${encodeURIComponent(project)}/pipelines/${encodeURIComponent(pipelineId)}/executions/${encodeURIComponent(runId)}`,
312
- body: {
313
- operation: 'CANCEL',
314
- },
315
- parseResponseBody: true,
316
- });
317
- }
318
259
  async pipelineRun(workspace, project, pipelineId, body) {
319
260
  return await this.request({
320
261
  method: 'POST',
@@ -701,13 +642,13 @@ class ApiClient {
701
642
  parseResponseBody: true,
702
643
  });
703
644
  }
704
- async getPackages(workspace, project) {
645
+ async getArtifacts(workspace, project) {
705
646
  let query = '';
706
647
  if (project)
707
648
  query += `?project_name=${encodeURIComponent(project)}`;
708
649
  return await this.request({
709
650
  method: 'GET',
710
- path: `/workspaces/${encodeURIComponent(workspace)}/packages${query}`,
651
+ path: `/workspaces/${encodeURIComponent(workspace)}/artifacts${query}`,
711
652
  parseResponseBody: true,
712
653
  });
713
654
  }
@@ -753,20 +694,20 @@ class ApiClient {
753
694
  pipeline: identifier,
754
695
  });
755
696
  }
756
- async deletePackageVersion(workspace, packageId, versionId) {
697
+ async deleteArtifactVersion(workspace, artifactId, versionId) {
757
698
  return await this.request({
758
699
  method: 'DELETE',
759
- path: `/workspaces/${encodeURIComponent(workspace)}/packages/${encodeURIComponent(packageId)}/versions/${encodeURIComponent(versionId)}`,
700
+ path: `/workspaces/${encodeURIComponent(workspace)}/artifacts/${encodeURIComponent(artifactId)}/versions/${encodeURIComponent(versionId)}`,
760
701
  });
761
702
  }
762
- async getPackageVersionByIdentifier(workspace, project, pkg, version) {
703
+ async getArtifactVersionByIdentifier(workspace, project, artifact, version) {
763
704
  const opts = {
764
- package: pkg,
705
+ artifact,
765
706
  };
766
707
  if (project)
767
708
  opts.project = project;
768
709
  if (version)
769
- opts.package_version = version;
710
+ opts.artifact_version = version;
770
711
  return await this.getResourceByIdentifier(workspace, opts);
771
712
  }
772
713
  async getSandboxByIdentifier(workspace, project, sandbox) {
@@ -780,14 +721,14 @@ class ApiClient {
780
721
  return await this.request({
781
722
  method: 'POST',
782
723
  path: `/workspaces/${encodeURIComponent(workspace)}/sandboxes/${encodeURIComponent(sandboxId)}/apps/${encodeURIComponent(appId)}/stop`,
783
- parseResponseBody: true,
724
+ parseResponseBody: true
784
725
  });
785
726
  }
786
727
  async startSandboxApp(workspace, sandboxId, appId) {
787
728
  return await this.request({
788
729
  method: 'POST',
789
730
  path: `/workspaces/${encodeURIComponent(workspace)}/sandboxes/${encodeURIComponent(sandboxId)}/apps/${encodeURIComponent(appId)}/start`,
790
- parseResponseBody: true,
731
+ parseResponseBody: true
791
732
  });
792
733
  }
793
734
  async getSandboxAppLogs(workspace, sandboxId, appId, cursor) {
@@ -801,10 +742,10 @@ class ApiClient {
801
742
  parseResponseBody: true,
802
743
  });
803
744
  }
804
- async getPackageVersions(workspace, pkgId, page = 1, perPage = 10) {
745
+ async getArtifactVersions(workspace, artifactId, page = 1, perPage = 10) {
805
746
  return await this.request({
806
747
  method: 'GET',
807
- path: `/workspaces/${encodeURIComponent(workspace)}/packages/${pkgId}/versions`,
748
+ path: `/workspaces/${encodeURIComponent(workspace)}/artifacts/${artifactId}/versions`,
808
749
  query: {
809
750
  page: page.toString(),
810
751
  per_page: perPage.toString(),
@@ -812,24 +753,24 @@ class ApiClient {
812
753
  parseResponseBody: true,
813
754
  });
814
755
  }
815
- async getPackageVersion(workspace, pkgId, versionId) {
756
+ async getArtifactVersion(workspace, artifactId, versionId) {
816
757
  return await this.request({
817
758
  method: 'GET',
818
- path: `/workspaces/${encodeURIComponent(workspace)}/packages/${encodeURIComponent(pkgId)}/versions/${encodeURIComponent(versionId)}`,
759
+ path: `/workspaces/${encodeURIComponent(workspace)}/artifacts/${encodeURIComponent(artifactId)}/versions/${encodeURIComponent(versionId)}`,
819
760
  parseResponseBody: true,
820
761
  });
821
762
  }
822
- async getPackage(workspace, pkgId) {
763
+ async getArtifact(workspace, artifactId) {
823
764
  return await this.request({
824
765
  method: 'GET',
825
- path: `/workspaces/${encodeURIComponent(workspace)}/packages/${pkgId}`,
766
+ path: `/workspaces/${encodeURIComponent(workspace)}/artifacts/${artifactId}`,
826
767
  parseResponseBody: true,
827
768
  });
828
769
  }
829
- async getPackageLatest(workspace, pkgId) {
770
+ async getArtifactLatest(workspace, artifactId) {
830
771
  const res = await this.request({
831
772
  method: 'GET',
832
- path: `/workspaces/${encodeURIComponent(workspace)}/packages/${encodeURIComponent(pkgId)}/versions?page=1&per_page=1`,
773
+ path: `/workspaces/${encodeURIComponent(workspace)}/artifacts/${encodeURIComponent(artifactId)}/versions?page=1&per_page=1`,
833
774
  parseResponseBody: true,
834
775
  });
835
776
  if (res && res.versions && res.versions.length > 0) {
@@ -837,45 +778,45 @@ class ApiClient {
837
778
  }
838
779
  return null;
839
780
  }
840
- async downloadPackageVersion(workspace, pkgId, versionId) {
781
+ async downloadArtifactVersion(workspace, artifactId, versionId) {
841
782
  return await this.request({
842
783
  method: 'GET',
843
- path: `/workspaces/${encodeURIComponent(workspace)}/packages/${encodeURIComponent(pkgId)}/versions/${encodeURIComponent(versionId)}/download`,
784
+ path: `/workspaces/${encodeURIComponent(workspace)}/artifacts/${encodeURIComponent(artifactId)}/versions/${encodeURIComponent(versionId)}/download`,
844
785
  rawResponseBody: true,
845
786
  });
846
787
  }
847
- async createPackageVersion(workspace, pkgId, version) {
788
+ async createArtifactVersion(workspace, artifactId, version) {
848
789
  return await this.request({
849
790
  method: 'POST',
850
- path: `/workspaces/${encodeURIComponent(workspace)}/packages/${encodeURIComponent(pkgId)}/versions`,
791
+ path: `/workspaces/${encodeURIComponent(workspace)}/artifacts/${encodeURIComponent(artifactId)}/versions`,
851
792
  body: {
852
793
  version,
853
794
  },
854
795
  parseResponseBody: true,
855
796
  });
856
797
  }
857
- async createPackageVersionZip(workspace, pkgId, versionId, file) {
798
+ async createArtifactVersionZip(workspace, artifactId, versionId, file) {
858
799
  const form = new undici_1.FormData();
859
800
  form.append('file', file, 'file.zip');
860
801
  return await this.request({
861
802
  method: 'POST',
862
- path: `/workspaces/${encodeURIComponent(workspace)}/packages/${encodeURIComponent(pkgId)}/versions/${encodeURIComponent(versionId)}/upload`,
803
+ path: `/workspaces/${encodeURIComponent(workspace)}/artifacts/${encodeURIComponent(artifactId)}/versions/${encodeURIComponent(versionId)}/upload`,
863
804
  body: form,
864
805
  parseResponseBody: true,
865
806
  });
866
807
  }
867
- async createPackage(workspace, data) {
808
+ async createArtifact(workspace, data) {
868
809
  return await this.request({
869
810
  method: 'POST',
870
- path: `/workspaces/${encodeURIComponent(workspace)}/packages`,
811
+ path: `/workspaces/${encodeURIComponent(workspace)}/artifacts`,
871
812
  body: data,
872
813
  parseResponseBody: true,
873
814
  });
874
815
  }
875
- async deletePackage(workspace, packageId) {
816
+ async deleteArtifact(workspace, artifactId) {
876
817
  return await this.request({
877
818
  method: 'DELETE',
878
- path: `/workspaces/${encodeURIComponent(workspace)}/packages/${encodeURIComponent(packageId)}`,
819
+ path: `/workspaces/${encodeURIComponent(workspace)}/artifacts/${encodeURIComponent(artifactId)}`,
879
820
  });
880
821
  }
881
822
  }
@@ -0,0 +1,64 @@
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 commandArtifactCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_ARTIFACT_CREATE);
11
+ commandArtifactCreate.alias('add');
12
+ commandArtifactCreate.option('-i, --identifier <identifier>', texts_1.OPT_COMMAND_ARTIFACT_CREATE_IDENTIFIER);
13
+ commandArtifactCreate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
14
+ commandArtifactCreate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
15
+ commandArtifactCreate.option('-t, --type <type>', texts_1.OPT_COMMAND_ARTIFACT_TYPE, utils_1.ARTIFACT_TYPE.BUCKET);
16
+ commandArtifactCreate.option('-b, --buddy', texts_1.OPTION_HTTP_AUTH_BUDDY);
17
+ commandArtifactCreate.option('-a, --auth <user:pass>', texts_1.OPTION_HTTP_AUTH);
18
+ commandArtifactCreate.argument('[name]', texts_1.OPT_COMMAND_ARTIFACT_NAME);
19
+ commandArtifactCreate.addHelpText('after', texts_1.EXAMPLE_ARTIFACT_CREATE);
20
+ commandArtifactCreate.action(async (name, options) => {
21
+ const humanId = require('human-id').default;
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.artifactType(options.type);
26
+ const scope = input_1.default.artifactScope(project);
27
+ if (!name) {
28
+ if (options.identifier)
29
+ name = options.identifier;
30
+ else
31
+ name = humanId({ separator: '-', capitalize: false });
32
+ }
33
+ const data = {
34
+ name,
35
+ type,
36
+ scope,
37
+ authorization: {
38
+ type: utils_1.ARTIFACT_AUTH_TYPE.NONE,
39
+ },
40
+ };
41
+ if (project) {
42
+ data.project = {
43
+ name: project,
44
+ };
45
+ }
46
+ if (options.identifier)
47
+ data.identifier = options.identifier;
48
+ if (options.auth) {
49
+ const { password, login } = input_1.default.auth(options.auth);
50
+ data.authorization = {
51
+ type: utils_1.ARTIFACT_AUTH_TYPE.BASIC,
52
+ user: login,
53
+ password,
54
+ };
55
+ }
56
+ else if (options.buddy) {
57
+ data.authorization = {
58
+ type: utils_1.ARTIFACT_AUTH_TYPE.BUDDY,
59
+ };
60
+ }
61
+ const result = await client.createArtifact(workspace, data);
62
+ output_1.default.exitSuccess((0, texts_1.TXT_ARTIFACT_CREATED)(client.baseUrl, workspace, result));
63
+ });
64
+ exports.default = commandArtifactCreate;
@@ -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 commandArtifactDelete = (0, utils_1.newCommand)('delete', texts_1.DESC_COMMAND_ARTIFACT_DELETE);
11
+ commandArtifactDelete.alias('rm');
12
+ commandArtifactDelete.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
13
+ commandArtifactDelete.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
14
+ commandArtifactDelete.option('-f, --force', texts_1.OPTION_CONFIRM_FORCE);
15
+ commandArtifactDelete.argument('<identifier>', texts_1.OPT_COMMAND_ARTIFACT_IDENTIFIER);
16
+ commandArtifactDelete.addHelpText('after', texts_1.EXAMPLE_ARTIFACT_DELETE);
17
+ commandArtifactDelete.action(async (identifier, options) => {
18
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
19
+ const project = input_1.default.restApiProject(options.project);
20
+ const client = input_1.default.restApiTokenClient();
21
+ const data = await client.getArtifactVersionByIdentifier(workspace, project, identifier);
22
+ if (!data || !data.domain) {
23
+ output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
24
+ }
25
+ if (!data.artifact_id) {
26
+ output_1.default.exitError(texts_1.ERR_ARTIFACT_NOT_FOUND);
27
+ }
28
+ const confirmed = options.force ||
29
+ (await output_1.default.confirm((0, texts_1.TXT_ARTIFACT_DELETE_CONFIRM)(identifier)));
30
+ if (confirmed) {
31
+ await client.deleteArtifact(workspace, data.artifact_id);
32
+ output_1.default.exitSuccess(texts_1.TXT_ARTIFACT_DELETED);
33
+ }
34
+ else {
35
+ output_1.default.exitNormal();
36
+ }
37
+ });
38
+ exports.default = commandArtifactDelete;
@@ -0,0 +1,26 @@
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 output_1 = __importDefault(require("../../../output"));
9
+ const input_1 = __importDefault(require("../../../input"));
10
+ const commandArtifactDockerLogin = (0, utils_1.newCommand)('login', texts_1.DESC_COMMAND_ARTIFACT_DOCKER_LOGIN);
11
+ commandArtifactDockerLogin.option('--token <token>', texts_1.OPTION_REST_API_TOKEN);
12
+ commandArtifactDockerLogin.option('--api <url>', texts_1.OPTION_REST_API_ENDPOINT);
13
+ commandArtifactDockerLogin.option('--region <region>', texts_1.OPTION_REST_API_REGION);
14
+ commandArtifactDockerLogin.action(async (options) => {
15
+ const client = input_1.default.restApiTokenClient(false, options.api, options.region, options.token);
16
+ await client.getInvoker();
17
+ const host = (0, utils_1.getDockerRegistryHostByApiBaseUrl)(client.baseUrl);
18
+ const output = await (0, utils_1.execLocally)(`docker login ${host} -u buddy -p "${client.token}"`);
19
+ if (/Login\sSucceeded/gi.test(output)) {
20
+ output_1.default.exitSuccess(texts_1.TXT_ARTIFACT_DOCKER_LOGIN_SUCCESS);
21
+ }
22
+ else {
23
+ output_1.default.exitError(texts_1.TXT_ARTIFACT_DOCKER_LOGIN_FAILED);
24
+ }
25
+ });
26
+ exports.default = commandArtifactDockerLogin;
@@ -0,0 +1,11 @@
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 login_1 = __importDefault(require("./docker/login"));
9
+ const commandArtifactDocker = (0, utils_1.newCommand)('docker', texts_1.DESC_COMMAND_ARTIFACT_DOCKER_LOGIN);
10
+ commandArtifactDocker.addCommand(login_1.default);
11
+ exports.default = commandArtifactDocker;
@@ -0,0 +1,138 @@
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 logger_1 = __importDefault(require("../../logger"));
11
+ const path_1 = require("path");
12
+ const fs_1 = __importDefault(require("fs"));
13
+ const promises_1 = __importDefault(require("node:stream/promises"));
14
+ const commandArtifactDownload = (0, utils_1.newCommand)('download', texts_1.DESC_COMMAND_ARTIFACT_DOWNLOAD);
15
+ commandArtifactDownload.alias('dd');
16
+ commandArtifactDownload.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
17
+ commandArtifactDownload.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
18
+ commandArtifactDownload.option('-m, --merge', texts_1.OPTION_ARTIFACT_DOWNLOAD_MERGE);
19
+ commandArtifactDownload.option('-r, --replace', texts_1.OPTION_ARTIFACT_DOWNLOAD_REPLACE);
20
+ commandArtifactDownload.argument('<identifier>', texts_1.OPTION_ARTIFACT_ID);
21
+ commandArtifactDownload.argument('<directory>', texts_1.OPTION_ARTIFACT_DOWNLOAD_PATH);
22
+ commandArtifactDownload.addHelpText('after', texts_1.EXAMPLE_ARTIFACT_DOWNLOAD);
23
+ commandArtifactDownload.action(async (id, path, options) => {
24
+ const { v4 } = require('uuid');
25
+ const ArchiverExtract = require('../../unzipper').default;
26
+ const { UNZIPPER_FORMAT } = require('../../unzipper');
27
+ const client = input_1.default.restApiTokenClient();
28
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
29
+ const project = input_1.default.restApiProject(options.project, true);
30
+ // eslint-disable-next-line prefer-const
31
+ let { identifier, version } = input_1.default.artifactSplitIdentifier(id);
32
+ const data = await client.getArtifactVersionByIdentifier(workspace, project, identifier, version);
33
+ if (!data || !data.domain) {
34
+ output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
35
+ }
36
+ if (project && !data.project_identifier) {
37
+ output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
38
+ }
39
+ const artifactId = data.artifact_id;
40
+ if (!artifactId) {
41
+ output_1.default.exitError(texts_1.ERR_ARTIFACT_DOWNLOAD_NOT_FOUND);
42
+ }
43
+ let versionId = data.artifact_version_id;
44
+ if (version && !versionId) {
45
+ output_1.default.exitError(texts_1.ERR_ARTIFACT_VERSION_NOT_FOUND);
46
+ }
47
+ if (!version || !versionId) {
48
+ const v = await client.getArtifactLatest(workspace, artifactId);
49
+ if (!v) {
50
+ output_1.default.exitError(texts_1.ERR_ARTIFACT_VERSION_NOT_FOUND);
51
+ }
52
+ version = v.version;
53
+ versionId = v.id;
54
+ }
55
+ const dirPath = (0, path_1.resolve)(path);
56
+ const exists = fs_1.default.existsSync(dirPath);
57
+ if (!exists) {
58
+ try {
59
+ fs_1.default.mkdirSync(dirPath, {
60
+ recursive: true,
61
+ });
62
+ }
63
+ catch (err) {
64
+ logger_1.default.error(err);
65
+ output_1.default.exitError((0, texts_1.ERR_ARTIFACT_DOWNLOAD_MKDIR)(dirPath));
66
+ }
67
+ }
68
+ else if (options.replace) {
69
+ try {
70
+ fs_1.default.rmSync(dirPath, {
71
+ recursive: true,
72
+ force: true,
73
+ });
74
+ fs_1.default.mkdirSync(dirPath, {
75
+ recursive: true,
76
+ });
77
+ }
78
+ catch (err) {
79
+ logger_1.default.error(err);
80
+ output_1.default.exitError((0, texts_1.ERR_ARTIFACT_DOWNLOAD_REPLACE)(dirPath));
81
+ }
82
+ }
83
+ try {
84
+ const stat = fs_1.default.statSync(dirPath);
85
+ if (!stat.isDirectory()) {
86
+ output_1.default.exitError((0, texts_1.ERR_ARTIFACT_DOWNLOAD_IS_FILE)(dirPath));
87
+ }
88
+ }
89
+ catch (err) {
90
+ logger_1.default.error(err);
91
+ output_1.default.exitError(texts_1.ERR_SWW);
92
+ }
93
+ let empty = true;
94
+ try {
95
+ const entries = fs_1.default.readdirSync(dirPath);
96
+ empty = !entries.length;
97
+ }
98
+ catch (err) {
99
+ logger_1.default.error(err);
100
+ output_1.default.exitError((0, texts_1.ERR_ARTIFACT_DOWNLOAD_READDIR)(dirPath));
101
+ }
102
+ if (!empty && !options.merge) {
103
+ output_1.default.exitError((0, texts_1.ERR_ARTIFACT_DOWNLOAD_NOT_EMPTY_DIR)(dirPath));
104
+ }
105
+ const zipPath = (0, path_1.join)((0, utils_1.getHomeDirectory)(), `${v4()}.zip`);
106
+ const clearZip = () => {
107
+ try {
108
+ fs_1.default.rmSync(zipPath);
109
+ }
110
+ catch {
111
+ // do nothing
112
+ }
113
+ };
114
+ output_1.default.normal(texts_1.TXT_ARTIFACT_DOWNLOADING_ZIP);
115
+ const body = await client.downloadArtifactVersion(workspace, artifactId, versionId);
116
+ try {
117
+ await promises_1.default.pipeline(body, fs_1.default.createWriteStream(zipPath));
118
+ output_1.default.clearPreviousLine();
119
+ output_1.default.normal(texts_1.TXT_ARTIFACT_DOWNLOADED_ZIP);
120
+ output_1.default.normal(texts_1.TXT_ARTIFACT_UNZIPPING);
121
+ let count = 0;
122
+ await ArchiverExtract.extract(UNZIPPER_FORMAT.ZIP, zipPath, dirPath, async () => {
123
+ count += 1;
124
+ output_1.default.clearPreviousLine();
125
+ output_1.default.normal((0, texts_1.TXT_ARTIFACT_UNZIPPING_COUNT)(count));
126
+ });
127
+ clearZip();
128
+ output_1.default.clearPreviousLine();
129
+ output_1.default.normal(texts_1.TXT_ARTIFACT_UNZIPPED);
130
+ }
131
+ catch (err) {
132
+ logger_1.default.error(err);
133
+ clearZip();
134
+ output_1.default.exitError(texts_1.ERR_SWW);
135
+ }
136
+ output_1.default.exitSuccess((0, texts_1.TXT_ARTIFACT_DOWNLOADED)(version, dirPath));
137
+ });
138
+ exports.default = commandArtifactDownload;
@@ -0,0 +1,36 @@
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 commandArtifactGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_ARTIFACT_GET);
11
+ commandArtifactGet.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
12
+ commandArtifactGet.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
13
+ commandArtifactGet.argument('<identifier>', texts_1.OPTION_SANDBOX_IDENTIFIER);
14
+ commandArtifactGet.action(async (identifier, options) => {
15
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
16
+ const project = input_1.default.restApiProject(options.project, true);
17
+ const client = input_1.default.restApiTokenClient();
18
+ const data = await client.getArtifactVersionByIdentifier(workspace, project, identifier);
19
+ if (!data || !data.domain) {
20
+ output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
21
+ }
22
+ if (!data || !data.artifact_id) {
23
+ output_1.default.exitError(texts_1.ERR_ARTIFACT_NOT_FOUND);
24
+ }
25
+ const art = await client.getArtifact(workspace, data.artifact_id);
26
+ output_1.default.object({
27
+ Name: art.name,
28
+ Identifier: art.identifier,
29
+ Type: art.type,
30
+ Scope: art.scope,
31
+ Size: (0, utils_1.formatBytes)(art.size || 0),
32
+ Created: art.created_date,
33
+ });
34
+ output_1.default.exitNormal(`\n${(0, texts_1.TXT_ARTIFACT_PUBLISH)(client.baseUrl, workspace, art)}`);
35
+ });
36
+ exports.default = commandArtifactGet;
@@ -0,0 +1,31 @@
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 output_1 = __importDefault(require("../../output"));
7
+ const texts_1 = require("../../texts");
8
+ const utils_1 = require("../../utils");
9
+ const input_1 = __importDefault(require("../../input"));
10
+ const commandArtifactList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_ARTIFACT_LIST);
11
+ commandArtifactList.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
12
+ commandArtifactList.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
13
+ commandArtifactList.alias('ls');
14
+ commandArtifactList.action(async (options) => {
15
+ const workspace = input_1.default.restApiWorkspace(options.workspace);
16
+ const project = input_1.default.restApiProject(options.project, true);
17
+ const client = input_1.default.restApiTokenClient();
18
+ const response = await client.getArtifacts(workspace, project);
19
+ if (!response.artifacts || response.artifacts.length === 0) {
20
+ output_1.default.exitError(texts_1.ERR_COMMAND_ARTIFACT_NO_PROJECTS);
21
+ }
22
+ const data = [['NAME', 'IDENTIFIER', 'TYPE', 'URL']];
23
+ for (const artifact of response.artifacts) {
24
+ if (project && artifact.scope === utils_1.ARTIFACT_SCOPE.WORKSPACE)
25
+ continue;
26
+ data.push([artifact.name, artifact.identifier, artifact.type, artifact.html_url]);
27
+ }
28
+ output_1.default.table(data);
29
+ output_1.default.exitNormal();
30
+ });
31
+ exports.default = commandArtifactList;