bdy 1.22.58 → 1.22.59-master
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
CHANGED
package/distTs/src/cliIndex.js
CHANGED
|
@@ -23,7 +23,6 @@ const whoami_1 = __importDefault(require("./command/whoami"));
|
|
|
23
23
|
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
|
-
const main_1 = __importDefault(require("./main"));
|
|
27
26
|
const distro_1 = __importDefault(require("./command/distro"));
|
|
28
27
|
const register_1 = __importDefault(require("./command/register"));
|
|
29
28
|
function cliIndex() {
|
|
@@ -50,11 +49,11 @@ function cliIndex() {
|
|
|
50
49
|
program.addCommand(workspace_1.default);
|
|
51
50
|
program.addCommand(project_1.default);
|
|
52
51
|
program.addCommand(api_1.default);
|
|
53
|
-
program.action(
|
|
52
|
+
program.action((_, cmd) => {
|
|
54
53
|
if (cmd.args.length > 0) {
|
|
55
54
|
output_1.default.exitError((0, texts_1.ERR_COMMAND_NOT_FOUND)(cmd.args[0]));
|
|
56
55
|
}
|
|
57
|
-
|
|
56
|
+
program.help();
|
|
58
57
|
});
|
|
59
58
|
return program;
|
|
60
59
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
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 distro_1 = require("../../../types/distro");
|
|
10
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
11
|
+
const commandArtifactVersionCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_ARTIFACT_VERSION_CREATE);
|
|
12
|
+
commandArtifactVersionCreate.alias('add');
|
|
13
|
+
commandArtifactVersionCreate.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
14
|
+
commandArtifactVersionCreate.option('--scope <scope>', texts_1.OPT_COMMAND_SCOPE);
|
|
15
|
+
commandArtifactVersionCreate.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
16
|
+
commandArtifactVersionCreate.option('-c, --create', texts_1.OPTION_ARTIFACT_PUBLISH_CREATE);
|
|
17
|
+
commandArtifactVersionCreate.option('--from <version>', texts_1.OPTION_ARTIFACT_VERSION_FROM);
|
|
18
|
+
commandArtifactVersionCreate.argument('<identifier>', texts_1.OPTION_ARTIFACT_ID);
|
|
19
|
+
commandArtifactVersionCreate.addHelpText('after', texts_1.EXAMPLE_ARTIFACT_VERSION_CREATE);
|
|
20
|
+
commandArtifactVersionCreate.action(async (id, options) => {
|
|
21
|
+
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
|
+
const { identifier, version } = input_1.default.artifactSplitIdentifier(id);
|
|
25
|
+
const client = input_1.default.restApiTokenClient();
|
|
26
|
+
const data = await client.getArtifactVersionByIdentifier(workspace, scope === distro_1.SCOPE.PROJECT ? project : null, identifier, version);
|
|
27
|
+
if (!data || !data.domain) {
|
|
28
|
+
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
|
|
29
|
+
}
|
|
30
|
+
if (scope === distro_1.SCOPE.PROJECT && !data.project_identifier) {
|
|
31
|
+
output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
|
|
32
|
+
}
|
|
33
|
+
let artifactId = data.artifact_id;
|
|
34
|
+
if (!artifactId) {
|
|
35
|
+
if (options.create) {
|
|
36
|
+
const data = {
|
|
37
|
+
name: identifier,
|
|
38
|
+
identifier,
|
|
39
|
+
type: utils_1.ARTIFACT_TYPE.BUCKET,
|
|
40
|
+
scope: distro_1.SCOPE.WORKSPACE,
|
|
41
|
+
authorization: {
|
|
42
|
+
type: utils_1.ARTIFACT_AUTH_TYPE.NONE,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
if (scope === distro_1.SCOPE.PROJECT && project) {
|
|
46
|
+
data.scope = distro_1.SCOPE.PROJECT;
|
|
47
|
+
data.project = {
|
|
48
|
+
name: project,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const d = await client.createArtifact(workspace, data);
|
|
52
|
+
artifactId = d.id;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
output_1.default.exitError(texts_1.ERR_ARTIFACT_PUBLISH_NOT_FOUND);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const artifactVersionId = data.artifact_version_id;
|
|
59
|
+
if (artifactVersionId) {
|
|
60
|
+
output_1.default.exitError(texts_1.ERR_ARTIFACT_VERSION_EXISTS_NO_FORCE);
|
|
61
|
+
}
|
|
62
|
+
const d = await client.createArtifactVersion(workspace, artifactId, version, options.from);
|
|
63
|
+
const url = d.version_url;
|
|
64
|
+
output_1.default.object({
|
|
65
|
+
Version: `${identifier}:${version}`,
|
|
66
|
+
URL: url || '-',
|
|
67
|
+
});
|
|
68
|
+
output_1.default.normal((0, texts_1.TXT_ROUTE_SERVE)(`artifact=${identifier}:${version}`));
|
|
69
|
+
output_1.default.exitNormal();
|
|
70
|
+
});
|
|
71
|
+
exports.default = commandArtifactVersionCreate;
|