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.
- package/distTs/package.json +2 -2
- package/distTs/src/api/client.js +27 -86
- package/distTs/src/command/artifact/create.js +64 -0
- package/distTs/src/command/artifact/delete.js +38 -0
- package/distTs/src/command/artifact/docker/login.js +26 -0
- package/distTs/src/command/artifact/docker.js +11 -0
- package/distTs/src/command/artifact/download.js +138 -0
- package/distTs/src/command/artifact/get.js +36 -0
- package/distTs/src/command/artifact/list.js +31 -0
- package/distTs/src/command/artifact/publish.js +241 -0
- package/distTs/src/command/artifact/version/delete.js +39 -0
- package/distTs/src/command/artifact/version/get.js +45 -0
- package/distTs/src/command/artifact/version/list.js +47 -0
- package/distTs/src/command/artifact/version.js +16 -0
- package/distTs/src/command/artifact.js +26 -0
- package/distTs/src/command/login.js +1 -1
- package/distTs/src/command/pipeline/run.js +125 -22
- package/distTs/src/command/project/get.js +18 -0
- package/distTs/src/command/project/link.js +12 -12
- package/distTs/src/command/project/set.js +31 -0
- package/distTs/src/command/sandbox/get/yaml.js +30 -0
- package/distTs/src/command/vt/scrape.js +193 -0
- package/distTs/src/index.js +2 -2
- package/distTs/src/input.js +18 -19
- package/distTs/src/output.js +31 -149
- package/distTs/src/texts.js +162 -184
- package/distTs/src/tunnel/output/interactive/tunnel.js +2 -2
- package/distTs/src/utils.js +37 -37
- package/package.json +2 -2
- package/distTs/src/command/crawl/link.js +0 -61
- package/distTs/src/command/crawl/run.js +0 -147
- package/distTs/src/command/crawl/validation.js +0 -154
- package/distTs/src/command/crawl.js +0 -13
- package/distTs/src/command/pipeline/run/apply.js +0 -62
- package/distTs/src/command/pipeline/run/cancel.js +0 -36
- package/distTs/src/command/pipeline/run/list.js +0 -52
- package/distTs/src/command/pipeline/run/logs.js +0 -37
- package/distTs/src/command/pipeline/run/retry.js +0 -36
- package/distTs/src/command/pipeline/run/start.js +0 -96
- package/distTs/src/command/pipeline/run/status.js +0 -35
- package/distTs/src/command/tests/capture/validation.js +0 -46
- package/distTs/src/command/tests/capture.js +0 -103
- package/distTs/src/command/tests/unit/link.js +0 -61
- package/distTs/src/command/tests/unit/upload.js +0 -91
- package/distTs/src/command/tests/unit.js +0 -13
- package/distTs/src/command/tests/visual/link.js +0 -61
- package/distTs/src/command/tests/visual/session/close.js +0 -32
- package/distTs/src/command/tests/visual/session/create.js +0 -86
- package/distTs/src/command/tests/visual/session.js +0 -13
- package/distTs/src/command/tests/visual/setup.js +0 -20
- package/distTs/src/command/tests/visual/shared/validation.js +0 -145
- package/distTs/src/command/tests/visual/upload.js +0 -141
- package/distTs/src/command/tests/visual.js +0 -17
- package/distTs/src/command/tests.js +0 -15
- package/distTs/src/crawl/requests.js +0 -141
- package/distTs/src/output/pipeline.js +0 -1383
- package/distTs/src/types/crawl.js +0 -2
- package/distTs/src/types/pipeline.js +0 -424
- package/distTs/src/unitTest/context.js +0 -26
package/distTs/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bdy",
|
|
3
3
|
"preferGlobal": false,
|
|
4
|
-
"version": "1.
|
|
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:
|
|
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/",
|
package/distTs/src/api/client.js
CHANGED
|
@@ -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
|
|
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)}/
|
|
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
|
|
697
|
+
async deleteArtifactVersion(workspace, artifactId, versionId) {
|
|
757
698
|
return await this.request({
|
|
758
699
|
method: 'DELETE',
|
|
759
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/
|
|
700
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/artifacts/${encodeURIComponent(artifactId)}/versions/${encodeURIComponent(versionId)}`,
|
|
760
701
|
});
|
|
761
702
|
}
|
|
762
|
-
async
|
|
703
|
+
async getArtifactVersionByIdentifier(workspace, project, artifact, version) {
|
|
763
704
|
const opts = {
|
|
764
|
-
|
|
705
|
+
artifact,
|
|
765
706
|
};
|
|
766
707
|
if (project)
|
|
767
708
|
opts.project = project;
|
|
768
709
|
if (version)
|
|
769
|
-
opts.
|
|
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
|
|
745
|
+
async getArtifactVersions(workspace, artifactId, page = 1, perPage = 10) {
|
|
805
746
|
return await this.request({
|
|
806
747
|
method: 'GET',
|
|
807
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/
|
|
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
|
|
756
|
+
async getArtifactVersion(workspace, artifactId, versionId) {
|
|
816
757
|
return await this.request({
|
|
817
758
|
method: 'GET',
|
|
818
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/
|
|
759
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/artifacts/${encodeURIComponent(artifactId)}/versions/${encodeURIComponent(versionId)}`,
|
|
819
760
|
parseResponseBody: true,
|
|
820
761
|
});
|
|
821
762
|
}
|
|
822
|
-
async
|
|
763
|
+
async getArtifact(workspace, artifactId) {
|
|
823
764
|
return await this.request({
|
|
824
765
|
method: 'GET',
|
|
825
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/
|
|
766
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/artifacts/${artifactId}`,
|
|
826
767
|
parseResponseBody: true,
|
|
827
768
|
});
|
|
828
769
|
}
|
|
829
|
-
async
|
|
770
|
+
async getArtifactLatest(workspace, artifactId) {
|
|
830
771
|
const res = await this.request({
|
|
831
772
|
method: 'GET',
|
|
832
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/
|
|
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
|
|
781
|
+
async downloadArtifactVersion(workspace, artifactId, versionId) {
|
|
841
782
|
return await this.request({
|
|
842
783
|
method: 'GET',
|
|
843
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/
|
|
784
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/artifacts/${encodeURIComponent(artifactId)}/versions/${encodeURIComponent(versionId)}/download`,
|
|
844
785
|
rawResponseBody: true,
|
|
845
786
|
});
|
|
846
787
|
}
|
|
847
|
-
async
|
|
788
|
+
async createArtifactVersion(workspace, artifactId, version) {
|
|
848
789
|
return await this.request({
|
|
849
790
|
method: 'POST',
|
|
850
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/
|
|
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
|
|
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)}/
|
|
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
|
|
808
|
+
async createArtifact(workspace, data) {
|
|
868
809
|
return await this.request({
|
|
869
810
|
method: 'POST',
|
|
870
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/
|
|
811
|
+
path: `/workspaces/${encodeURIComponent(workspace)}/artifacts`,
|
|
871
812
|
body: data,
|
|
872
813
|
parseResponseBody: true,
|
|
873
814
|
});
|
|
874
815
|
}
|
|
875
|
-
async
|
|
816
|
+
async deleteArtifact(workspace, artifactId) {
|
|
876
817
|
return await this.request({
|
|
877
818
|
method: 'DELETE',
|
|
878
|
-
path: `/workspaces/${encodeURIComponent(workspace)}/
|
|
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;
|