@eclipse-che/che-devworkspace-generator 7.92.0 → 7.93.0-next-be04ded
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/LICENSE +201 -0
- package/README.md +51 -9
- package/lib/api/devfile-context.js +2 -2
- package/lib/api/devfile-context.js.map +1 -1
- package/lib/bitbucket/bitbucket-module.js +6 -6
- package/lib/bitbucket/bitbucket-module.js.map +1 -1
- package/lib/bitbucket/bitbucket-resolver.js +23 -26
- package/lib/bitbucket/bitbucket-resolver.js.map +1 -1
- package/lib/bitbucket/bitbucket-url.js +21 -19
- package/lib/bitbucket/bitbucket-url.js.map +1 -1
- package/lib/bitbucket-server/bitbucket-server-module.js +6 -6
- package/lib/bitbucket-server/bitbucket-server-module.js.map +1 -1
- package/lib/bitbucket-server/bitbucket-server-resolver.js +32 -35
- package/lib/bitbucket-server/bitbucket-server-resolver.js.map +1 -1
- package/lib/bitbucket-server/bitbucket-server-url.js +26 -21
- package/lib/bitbucket-server/bitbucket-server-url.js.map +1 -1
- package/lib/devfile/dev-container-component-finder.js +39 -81
- package/lib/devfile/dev-container-component-finder.js.map +1 -1
- package/lib/devfile/dev-container-component-inserter.js +30 -75
- package/lib/devfile/dev-container-component-inserter.js.map +1 -1
- package/lib/devfile/devfile-module.js +5 -5
- package/lib/devfile/devfile-module.js.map +1 -1
- package/lib/devfile-schema/devfile-schema-module.js +4 -4
- package/lib/devfile-schema/devfile-schema-module.js.map +1 -1
- package/lib/devfile-schema/devfile-schema-validator.js +22 -25
- package/lib/devfile-schema/devfile-schema-validator.js.map +1 -1
- package/lib/{plugin-registry/plugin-registry-module.d.ts → editor/editor-module.d.ts} +2 -2
- package/lib/editor/editor-module.js +19 -0
- package/lib/editor/editor-module.js.map +1 -0
- package/lib/{plugin-registry/plugin-registry-resolver.d.ts → editor/editor-resolver.d.ts} +2 -3
- package/lib/editor/editor-resolver.js +64 -0
- package/lib/editor/editor-resolver.js.map +1 -0
- package/lib/entrypoint.js +9 -54
- package/lib/entrypoint.js.map +1 -1
- package/lib/fetch/fetch-module.js +4 -4
- package/lib/fetch/fetch-module.js.map +1 -1
- package/lib/fetch/url-fetcher.js +33 -87
- package/lib/fetch/url-fetcher.js.map +1 -1
- package/lib/generate.js +89 -144
- package/lib/generate.js.map +1 -1
- package/lib/github/github-module.js +6 -6
- package/lib/github/github-module.js.map +1 -1
- package/lib/github/github-resolver.js +26 -29
- package/lib/github/github-resolver.js.map +1 -1
- package/lib/github/github-url.js +24 -19
- package/lib/github/github-url.js.map +1 -1
- package/lib/inversify/inversify-binding.d.ts +0 -1
- package/lib/inversify/inversify-binding.js +25 -68
- package/lib/inversify/inversify-binding.js.map +1 -1
- package/lib/main.d.ts +1 -2
- package/lib/main.js +156 -225
- package/lib/main.js.map +1 -1
- package/lib/resolve/git-url-resolver.js +16 -18
- package/lib/resolve/git-url-resolver.js.map +1 -1
- package/lib/resolve/resolve-module.js +4 -4
- package/lib/resolve/resolve-module.js.map +1 -1
- package/lib/resolve/resolver.js +1 -1
- package/lib/resolve/url.js +1 -1
- package/lib/types.js +3 -3
- package/lib/types.js.map +1 -1
- package/package.json +2 -2
- package/src/{plugin-registry/plugin-registry-module.ts → editor/editor-module.ts} +4 -4
- package/src/{plugin-registry/plugin-registry-resolver.ts → editor/editor-resolver.ts} +5 -10
- package/src/inversify/inversify-binding.ts +2 -4
- package/src/main.ts +12 -28
- package/lib/plugin-registry/plugin-registry-module.js +0 -19
- package/lib/plugin-registry/plugin-registry-module.js.map +0 -1
- package/lib/plugin-registry/plugin-registry-resolver.js +0 -117
- package/lib/plugin-registry/plugin-registry-resolver.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-resolver.js","sourceRoot":"","sources":["../../src/github/github-resolver.ts"],"names":[],"mappings":";AAAA;;;;;;;;yEAQyE
|
|
1
|
+
{"version":3,"file":"github-resolver.js","sourceRoot":"","sources":["../../src/github/github-resolver.ts"],"names":[],"mappings":";AAAA;;;;;;;;yEAQyE;;;;;;;;;;AAEzE,6CAAyC;AACzC,yCAAuC;AAKhC,IAAM,cAAc,GAApB,MAAM,cAAc;;IACzB,mCAAmC;IACnC,MAAM,CAAU,kBAAkB,GAChC,qKAAqK,CAAC;IAExK,OAAO,CAAC,GAAW;QACjB,OAAO,gBAAc,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,CAAC,IAAY;QAClB,MAAM,KAAK,GAAG,gBAAc,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3D,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC;QACjD,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC9C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC9C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAClD,IAAI,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAChD,IAAI,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1C,QAAQ,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACxD,CAAC;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;QAC9D,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACpD,OAAO,IAAI,sBAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;IACpF,CAAC;IAEO,QAAQ,CAAC,KAAsB,EAAE,SAAiB,EAAE,YAAqB;QAC/E,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5C,OAAO,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,YAAY,IAAI,EAAE,CAAC;IAC5B,CAAC;;AA/BU,wCAAc;yBAAd,cAAc;IAD1B,IAAA,sBAAU,GAAE;GACA,cAAc,CAgC1B"}
|
package/lib/github/github-url.js
CHANGED
|
@@ -8,10 +8,16 @@
|
|
|
8
8
|
*
|
|
9
9
|
* SPDX-License-Identifier: EPL-2.0
|
|
10
10
|
***********************************************************************/
|
|
11
|
-
exports
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.GithubUrl = void 0;
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
class GithubUrl {
|
|
14
|
+
scheme;
|
|
15
|
+
hostName;
|
|
16
|
+
repoUser;
|
|
17
|
+
repoName;
|
|
18
|
+
branchName;
|
|
19
|
+
subFolder;
|
|
20
|
+
constructor(scheme, hostName, repoUser, repoName, branchName, subFolder) {
|
|
15
21
|
this.scheme = scheme;
|
|
16
22
|
this.hostName = hostName;
|
|
17
23
|
this.repoUser = repoUser;
|
|
@@ -22,23 +28,22 @@ var GithubUrl = /** @class */ (function () {
|
|
|
22
28
|
/**
|
|
23
29
|
* Provides the raw link to the given path based on the current repository information
|
|
24
30
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return
|
|
34
|
-
}
|
|
35
|
-
|
|
31
|
+
getContentUrl(path) {
|
|
32
|
+
const hostName = this.hostName === 'github.com' ? 'githubusercontent.com' : this.hostName;
|
|
33
|
+
return `${this.scheme}://raw.${hostName}/${this.repoUser}/${this.repoName}/${this.branchName}/${path}`;
|
|
34
|
+
}
|
|
35
|
+
getUrl() {
|
|
36
|
+
return `${this.scheme}://${this.hostName}/${this.repoUser}/${this.repoName}/tree/${this.branchName}/${this.subFolder}`;
|
|
37
|
+
}
|
|
38
|
+
getCloneUrl() {
|
|
39
|
+
return `${this.scheme}://${this.hostName}/${this.repoUser}/${this.repoName}.git`;
|
|
40
|
+
}
|
|
41
|
+
getRepoName() {
|
|
36
42
|
return this.repoName;
|
|
37
|
-
}
|
|
38
|
-
|
|
43
|
+
}
|
|
44
|
+
getBranchName() {
|
|
39
45
|
return this.branchName;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
}());
|
|
46
|
+
}
|
|
47
|
+
}
|
|
43
48
|
exports.GithubUrl = GithubUrl;
|
|
44
49
|
//# sourceMappingURL=github-url.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-url.js","sourceRoot":"","sources":["../../src/github/github-url.ts"],"names":[],"mappings":";AAAA;;;;;;;;yEAQyE;;;AAIzE;
|
|
1
|
+
{"version":3,"file":"github-url.js","sourceRoot":"","sources":["../../src/github/github-url.ts"],"names":[],"mappings":";AAAA;;;;;;;;yEAQyE;;;AAIzE,MAAa,SAAS;IAED;IACA;IACA;IACA;IACA;IACA;IANnB,YACmB,MAAc,EACd,QAAgB,EAChB,QAAgB,EAChB,QAAgB,EAChB,UAAkB,EAClB,SAAiB;QALjB,WAAM,GAAN,MAAM,CAAQ;QACd,aAAQ,GAAR,QAAQ,CAAQ;QAChB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,eAAU,GAAV,UAAU,CAAQ;QAClB,cAAS,GAAT,SAAS,CAAQ;IACjC,CAAC;IAEJ;;OAEG;IACH,aAAa,CAAC,IAAY;QACxB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC1F,OAAO,GAAG,IAAI,CAAC,MAAM,UAAU,QAAQ,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,UAAU,IAAI,IAAI,EAAE,CAAC;IACzG,CAAC;IAED,MAAM;QACJ,OAAO,GAAG,IAAI,CAAC,MAAM,MAAM,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,SAAS,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;IACzH,CAAC;IAED,WAAW;QACT,OAAO,GAAG,IAAI,CAAC,MAAM,MAAM,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,MAAM,CAAC;IACnF,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF;AAjCD,8BAiCC"}
|
|
@@ -1,41 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
exports.__esModule = true;
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.InversifyBinding = void 0;
|
|
40
4
|
/**********************************************************************
|
|
41
5
|
* Copyright (c) 2022-2024
|
|
@@ -47,40 +11,33 @@ exports.InversifyBinding = void 0;
|
|
|
47
11
|
* SPDX-License-Identifier: EPL-2.0
|
|
48
12
|
***********************************************************************/
|
|
49
13
|
require("reflect-metadata");
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
14
|
+
const inversify_1 = require("inversify");
|
|
15
|
+
const devfile_module_1 = require("../devfile/devfile-module");
|
|
16
|
+
const fetch_module_1 = require("../fetch/fetch-module");
|
|
17
|
+
const github_module_1 = require("../github/github-module");
|
|
18
|
+
const resolve_module_1 = require("../resolve/resolve-module");
|
|
19
|
+
const editor_module_1 = require("../editor/editor-module");
|
|
20
|
+
const devfile_schema_module_1 = require("../devfile-schema/devfile-schema-module");
|
|
21
|
+
const bitbucket_module_1 = require("../bitbucket/bitbucket-module");
|
|
22
|
+
const bitbucket_server_module_1 = require("../bitbucket-server/bitbucket-server-module");
|
|
59
23
|
/**
|
|
60
24
|
* Manage all bindings for inversify
|
|
61
25
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
26
|
+
class InversifyBinding {
|
|
27
|
+
container;
|
|
28
|
+
async initBindings(options) {
|
|
29
|
+
this.container = new inversify_1.Container();
|
|
30
|
+
this.container.load(devfile_module_1.devfileModule);
|
|
31
|
+
this.container.load(fetch_module_1.fetchModule);
|
|
32
|
+
this.container.load(github_module_1.githubModule);
|
|
33
|
+
this.container.load(bitbucket_module_1.bitbucketModule);
|
|
34
|
+
this.container.load(bitbucket_server_module_1.bitbucketServerModule);
|
|
35
|
+
this.container.load(resolve_module_1.resolveModule);
|
|
36
|
+
this.container.load(editor_module_1.editorModule);
|
|
37
|
+
this.container.load(devfile_schema_module_1.devfileSchemaModule);
|
|
38
|
+
this.container.bind(Symbol.for('AxiosInstance')).toConstantValue(options.axiosInstance);
|
|
39
|
+
return this.container;
|
|
64
40
|
}
|
|
65
|
-
|
|
66
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
67
|
-
return __generator(this, function (_a) {
|
|
68
|
-
this.container = new inversify_1.Container();
|
|
69
|
-
this.container.load(devfile_module_1.devfileModule);
|
|
70
|
-
this.container.load(fetch_module_1.fetchModule);
|
|
71
|
-
this.container.load(github_module_1.githubModule);
|
|
72
|
-
this.container.load(bitbucket_module_1.bitbucketModule);
|
|
73
|
-
this.container.load(bitbucket_server_module_1.bitbucketServerModule);
|
|
74
|
-
this.container.load(resolve_module_1.resolveModule);
|
|
75
|
-
this.container.load(plugin_registry_module_1.pluginRegistryModule);
|
|
76
|
-
this.container.load(devfile_schema_module_1.devfileSchemaModule);
|
|
77
|
-
this.container.bind(Symbol["for"]('AxiosInstance')).toConstantValue(options.axiosInstance);
|
|
78
|
-
this.container.bind('string').toConstantValue(options.pluginRegistryUrl).whenTargetNamed('PLUGIN_REGISTRY_URL');
|
|
79
|
-
return [2 /*return*/, this.container];
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
};
|
|
83
|
-
return InversifyBinding;
|
|
84
|
-
}());
|
|
41
|
+
}
|
|
85
42
|
exports.InversifyBinding = InversifyBinding;
|
|
86
43
|
//# sourceMappingURL=inversify-binding.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inversify-binding.js","sourceRoot":"","sources":["../../src/inversify/inversify-binding.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"inversify-binding.js","sourceRoot":"","sources":["../../src/inversify/inversify-binding.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;yEAQyE;AACzE,4BAA0B;AAG1B,yCAAsC;AACtC,8DAA0D;AAC1D,wDAAoD;AACpD,2DAAuD;AACvD,8DAA0D;AAC1D,2DAAuD;AACvD,mFAA8E;AAC9E,oEAAgE;AAChE,yFAAoF;AAEpF;;GAEG;AACH,MAAa,gBAAgB;IACnB,SAAS,CAAY;IAEtB,KAAK,CAAC,YAAY,CAAC,OAAgC;QACxD,IAAI,CAAC,SAAS,GAAG,IAAI,qBAAS,EAAE,CAAC;QAEjC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,8BAAa,CAAC,CAAC;QACnC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,0BAAW,CAAC,CAAC;QACjC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,4BAAY,CAAC,CAAC;QAClC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,kCAAe,CAAC,CAAC;QACrC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,+CAAqB,CAAC,CAAC;QAC3C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,8BAAa,CAAC,CAAC;QACnC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,4BAAY,CAAC,CAAC;QAClC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,2CAAmB,CAAC,CAAC;QAEzC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QAExF,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AAnBD,4CAmBC"}
|
package/lib/main.d.ts
CHANGED
package/lib/main.js
CHANGED
|
@@ -31,169 +31,110 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
31
31
|
__setModuleDefault(result, mod);
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
|
-
|
|
35
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
36
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
37
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
38
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
39
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
40
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
41
|
-
});
|
|
42
|
-
};
|
|
43
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
44
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
45
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
46
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
47
|
-
function step(op) {
|
|
48
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
49
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
50
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
51
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
52
|
-
switch (op[0]) {
|
|
53
|
-
case 0: case 1: t = op; break;
|
|
54
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
55
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
56
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
57
|
-
default:
|
|
58
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
59
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
60
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
61
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
62
|
-
if (t[2]) _.ops.pop();
|
|
63
|
-
_.trys.pop(); continue;
|
|
64
|
-
}
|
|
65
|
-
op = body.call(thisArg, _);
|
|
66
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
67
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
exports.__esModule = true;
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
71
35
|
exports.Main = void 0;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
36
|
+
const axios = __importStar(require("axios"));
|
|
37
|
+
const fs = __importStar(require("fs-extra"));
|
|
38
|
+
const generate_1 = require("./generate");
|
|
39
|
+
const devfile_schema_validator_1 = require("./devfile-schema/devfile-schema-validator");
|
|
40
|
+
const jsYaml = __importStar(require("js-yaml"));
|
|
41
|
+
const inversify_binding_1 = require("./inversify/inversify-binding");
|
|
42
|
+
const url_fetcher_1 = require("./fetch/url-fetcher");
|
|
43
|
+
const editor_resolver_1 = require("./editor/editor-resolver");
|
|
44
|
+
const git_url_resolver_1 = require("./resolve/git-url-resolver");
|
|
45
|
+
class Main {
|
|
82
46
|
/**
|
|
83
47
|
* Default constructor.
|
|
84
48
|
*/
|
|
85
|
-
|
|
49
|
+
constructor() {
|
|
86
50
|
// no-op
|
|
87
51
|
}
|
|
88
52
|
// Generates a devfile context object based on params
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
throw new Error('missing devfilePath or devfileUrl or devfileContent');
|
|
100
|
-
}
|
|
101
|
-
if (params.pluginRegistryUrl) {
|
|
102
|
-
pluginRegistryUrl = params.pluginRegistryUrl;
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
pluginRegistryUrl = 'https://eclipse-che.github.io/che-plugin-registry/main/v3';
|
|
106
|
-
console.log("No plug-in registry url. Setting to ".concat(pluginRegistryUrl));
|
|
107
|
-
}
|
|
108
|
-
inversifyBinbding = new inversify_binding_1.InversifyBinding();
|
|
109
|
-
return [4 /*yield*/, inversifyBinbding.initBindings({
|
|
110
|
-
pluginRegistryUrl: pluginRegistryUrl,
|
|
111
|
-
axiosInstance: axiosInstance
|
|
112
|
-
})];
|
|
113
|
-
case 1:
|
|
114
|
-
container = _a.sent();
|
|
115
|
-
container.bind(generate_1.Generate).toSelf().inSingletonScope();
|
|
116
|
-
if (!params.devfileUrl) return [3 /*break*/, 3];
|
|
117
|
-
resolver = container.get(git_url_resolver_1.GitUrlResolver);
|
|
118
|
-
url = resolver.resolve(params.devfileUrl);
|
|
119
|
-
return [4 /*yield*/, container.get(url_fetcher_1.UrlFetcher).fetchText(url.getContentUrl('devfile.yaml'))];
|
|
120
|
-
case 2:
|
|
121
|
-
// user devfile
|
|
122
|
-
devfileContent = _a.sent();
|
|
123
|
-
devfileParsed = jsYaml.load(devfileContent);
|
|
124
|
-
// is there projects in the devfile ?
|
|
125
|
-
if (devfileParsed && !devfileParsed.projects) {
|
|
126
|
-
// no, so add the current project being cloned
|
|
127
|
-
devfileParsed.projects = [
|
|
128
|
-
{
|
|
129
|
-
name: url.getRepoName(),
|
|
130
|
-
git: {
|
|
131
|
-
remotes: { origin: url.getCloneUrl() },
|
|
132
|
-
checkoutFrom: { revision: url.getBranchName() }
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
];
|
|
136
|
-
}
|
|
137
|
-
// get back the content
|
|
138
|
-
devfileContent = jsYaml.dump(devfileParsed);
|
|
139
|
-
return [3 /*break*/, 6];
|
|
140
|
-
case 3:
|
|
141
|
-
if (!params.devfilePath) return [3 /*break*/, 5];
|
|
142
|
-
return [4 /*yield*/, fs.readFile(params.devfilePath)];
|
|
143
|
-
case 4:
|
|
144
|
-
devfileContent = _a.sent();
|
|
145
|
-
return [3 /*break*/, 6];
|
|
146
|
-
case 5:
|
|
147
|
-
devfileContent = params.devfileContent;
|
|
148
|
-
_a.label = 6;
|
|
149
|
-
case 6:
|
|
150
|
-
jsYamlDevfileContent = jsYaml.load(devfileContent);
|
|
151
|
-
schemaVersion = jsYamlDevfileContent.schemaVersion;
|
|
152
|
-
if (!schemaVersion) {
|
|
153
|
-
throw new Error("Devfile is not valid, schemaVersion is required");
|
|
154
|
-
}
|
|
155
|
-
devfileSchemaValidator = container.get(devfile_schema_validator_1.DevfileSchemaValidator);
|
|
156
|
-
console.log("Validating devfile");
|
|
157
|
-
validationResult = devfileSchemaValidator.validateDevfile(jsYamlDevfileContent, schemaVersion);
|
|
158
|
-
if (!validationResult.valid) {
|
|
159
|
-
throw new Error("Devfile schema validation failed. Error: ".concat(validationResult.toString()));
|
|
160
|
-
}
|
|
161
|
-
console.log("Devfile is valid with schema version ".concat(schemaVersion));
|
|
162
|
-
// enhance projects
|
|
163
|
-
devfileContent = this.replaceIfExistingProjects(devfileContent, params.projects);
|
|
164
|
-
if (!params.editorContent) return [3 /*break*/, 7];
|
|
165
|
-
editorContent = params.editorContent;
|
|
166
|
-
return [3 /*break*/, 11];
|
|
167
|
-
case 7:
|
|
168
|
-
if (!params.editorEntry) return [3 /*break*/, 9];
|
|
169
|
-
return [4 /*yield*/, container.get(plugin_registry_resolver_1.PluginRegistryResolver).loadDevfilePlugin(params.editorEntry)];
|
|
170
|
-
case 8:
|
|
171
|
-
editorDevfile = _a.sent();
|
|
172
|
-
editorContent = jsYaml.dump(editorDevfile);
|
|
173
|
-
return [3 /*break*/, 11];
|
|
174
|
-
case 9: return [4 /*yield*/, fs.readFile(params.editorPath)];
|
|
175
|
-
case 10:
|
|
176
|
-
editorContent = _a.sent();
|
|
177
|
-
_a.label = 11;
|
|
178
|
-
case 11:
|
|
179
|
-
generate = container.get(generate_1.Generate);
|
|
180
|
-
return [2 /*return*/, generate.generate(devfileContent, editorContent, params.outputFile, params.injectDefaultComponent, params.defaultComponentImage)];
|
|
181
|
-
}
|
|
182
|
-
});
|
|
53
|
+
async generateDevfileContext(params, axiosInstance) {
|
|
54
|
+
if (!params.editorPath && !params.editorUrl && !params.editorContent) {
|
|
55
|
+
throw new Error('missing editorPath or editorUrl or editorContent');
|
|
56
|
+
}
|
|
57
|
+
if (!params.devfilePath && !params.devfileUrl && !params.devfileContent) {
|
|
58
|
+
throw new Error('missing devfilePath or devfileUrl or devfileContent');
|
|
59
|
+
}
|
|
60
|
+
const inversifyBinbding = new inversify_binding_1.InversifyBinding();
|
|
61
|
+
const container = await inversifyBinbding.initBindings({
|
|
62
|
+
axiosInstance,
|
|
183
63
|
});
|
|
184
|
-
|
|
64
|
+
container.bind(generate_1.Generate).toSelf().inSingletonScope();
|
|
65
|
+
let devfileContent;
|
|
66
|
+
let editorContent;
|
|
67
|
+
// gets the repo URL
|
|
68
|
+
if (params.devfileUrl) {
|
|
69
|
+
const resolver = container.get(git_url_resolver_1.GitUrlResolver);
|
|
70
|
+
const url = resolver.resolve(params.devfileUrl);
|
|
71
|
+
// user devfile
|
|
72
|
+
devfileContent = await container.get(url_fetcher_1.UrlFetcher).fetchText(url.getContentUrl('devfile.yaml'));
|
|
73
|
+
// load content
|
|
74
|
+
const devfileParsed = jsYaml.load(devfileContent);
|
|
75
|
+
// is there projects in the devfile ?
|
|
76
|
+
if (devfileParsed && !devfileParsed.projects) {
|
|
77
|
+
// no, so add the current project being cloned
|
|
78
|
+
devfileParsed.projects = [
|
|
79
|
+
{
|
|
80
|
+
name: url.getRepoName(),
|
|
81
|
+
git: {
|
|
82
|
+
remotes: { origin: url.getCloneUrl() },
|
|
83
|
+
checkoutFrom: { revision: url.getBranchName() },
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
// get back the content
|
|
89
|
+
devfileContent = jsYaml.dump(devfileParsed);
|
|
90
|
+
}
|
|
91
|
+
else if (params.devfilePath) {
|
|
92
|
+
devfileContent = await fs.readFile(params.devfilePath);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
devfileContent = params.devfileContent;
|
|
96
|
+
}
|
|
97
|
+
const jsYamlDevfileContent = jsYaml.load(devfileContent);
|
|
98
|
+
const schemaVersion = jsYamlDevfileContent.schemaVersion;
|
|
99
|
+
if (!schemaVersion) {
|
|
100
|
+
throw new Error(`Devfile is not valid, schemaVersion is required`);
|
|
101
|
+
}
|
|
102
|
+
// validate devfile
|
|
103
|
+
const devfileSchemaValidator = container.get(devfile_schema_validator_1.DevfileSchemaValidator);
|
|
104
|
+
console.log(`Validating devfile`);
|
|
105
|
+
const validationResult = devfileSchemaValidator.validateDevfile(jsYamlDevfileContent, schemaVersion);
|
|
106
|
+
if (!validationResult.valid) {
|
|
107
|
+
throw new Error(`Devfile schema validation failed. Error: ${validationResult.toString()}`);
|
|
108
|
+
}
|
|
109
|
+
console.log(`Devfile is valid with schema version ${schemaVersion}`);
|
|
110
|
+
// enhance projects
|
|
111
|
+
devfileContent = this.replaceIfExistingProjects(devfileContent, params.projects);
|
|
112
|
+
if (params.editorContent) {
|
|
113
|
+
editorContent = params.editorContent;
|
|
114
|
+
}
|
|
115
|
+
else if (params.editorUrl) {
|
|
116
|
+
// devfile of the editor
|
|
117
|
+
const editorDevfile = await container.get(editor_resolver_1.EditorResolver).loadEditor(params.editorUrl);
|
|
118
|
+
editorContent = jsYaml.dump(editorDevfile);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
editorContent = await fs.readFile(params.editorPath);
|
|
122
|
+
}
|
|
123
|
+
const generate = container.get(generate_1.Generate);
|
|
124
|
+
return generate.generate(devfileContent, editorContent, params.outputFile, params.injectDefaultComponent, params.defaultComponentImage);
|
|
125
|
+
}
|
|
185
126
|
// Update project entry based on the projects passed as parameter
|
|
186
|
-
|
|
127
|
+
replaceIfExistingProjects(devfileContent, projects) {
|
|
187
128
|
// do nothing if no override
|
|
188
129
|
if (projects.length === 0) {
|
|
189
130
|
return devfileContent;
|
|
190
131
|
}
|
|
191
|
-
|
|
132
|
+
const devfileParsed = jsYaml.load(devfileContent);
|
|
192
133
|
if (!devfileParsed || !devfileParsed.projects) {
|
|
193
134
|
return devfileContent;
|
|
194
135
|
}
|
|
195
|
-
devfileParsed.projects = devfileParsed.projects.map(
|
|
196
|
-
|
|
136
|
+
devfileParsed.projects = devfileParsed.projects.map(project => {
|
|
137
|
+
const userProjectConfiguration = projects.find(p => p.name === project.name);
|
|
197
138
|
if (userProjectConfiguration) {
|
|
198
139
|
if (userProjectConfiguration.location.endsWith('.zip')) {
|
|
199
140
|
// delete git section and use instead zip
|
|
@@ -207,84 +148,74 @@ var Main = /** @class */ (function () {
|
|
|
207
148
|
return project;
|
|
208
149
|
});
|
|
209
150
|
return jsYaml.dump(devfileParsed);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
_a.label = 1;
|
|
252
|
-
case 1:
|
|
253
|
-
_a.trys.push([1, 3, , 4]);
|
|
254
|
-
if (!editorPath && !editorEntry) {
|
|
255
|
-
throw new Error('missing --editor-path: or --editor-entry: parameter');
|
|
256
|
-
}
|
|
257
|
-
if (!devfilePath && !devfileUrl) {
|
|
258
|
-
throw new Error('missing --devfile-path: or --devfile-url: parameter');
|
|
259
|
-
}
|
|
260
|
-
if (!outputFile) {
|
|
261
|
-
throw new Error('missing --output-file: parameter');
|
|
262
|
-
}
|
|
263
|
-
return [4 /*yield*/, this.generateDevfileContext({
|
|
264
|
-
devfilePath: devfilePath,
|
|
265
|
-
devfileUrl: devfileUrl,
|
|
266
|
-
editorPath: editorPath,
|
|
267
|
-
outputFile: outputFile,
|
|
268
|
-
pluginRegistryUrl: pluginRegistryUrl,
|
|
269
|
-
editorEntry: editorEntry,
|
|
270
|
-
projects: projects,
|
|
271
|
-
injectDefaultComponent: injectDefaultComponent,
|
|
272
|
-
defaultComponentImage: defaultComponentImage
|
|
273
|
-
}, axios["default"])];
|
|
274
|
-
case 2:
|
|
275
|
-
_a.sent();
|
|
276
|
-
return [2 /*return*/, true];
|
|
277
|
-
case 3:
|
|
278
|
-
error_1 = _a.sent();
|
|
279
|
-
console.error('stack=' + error_1.stack);
|
|
280
|
-
console.error('Unable to start', error_1);
|
|
281
|
-
return [2 /*return*/, false];
|
|
282
|
-
case 4: return [2 /*return*/];
|
|
283
|
-
}
|
|
284
|
-
});
|
|
151
|
+
}
|
|
152
|
+
async start() {
|
|
153
|
+
let devfilePath;
|
|
154
|
+
let devfileUrl;
|
|
155
|
+
let outputFile;
|
|
156
|
+
let editorPath;
|
|
157
|
+
let editorUrl;
|
|
158
|
+
let injectDefaultComponent;
|
|
159
|
+
let defaultComponentImage;
|
|
160
|
+
const projects = [];
|
|
161
|
+
const args = process.argv.slice(2);
|
|
162
|
+
args.forEach(arg => {
|
|
163
|
+
if (arg.startsWith('--devfile-path:')) {
|
|
164
|
+
devfilePath = arg.substring('--devfile-path:'.length);
|
|
165
|
+
}
|
|
166
|
+
if (arg.startsWith('--devfile-url:')) {
|
|
167
|
+
devfileUrl = arg.substring('--devfile-url:'.length);
|
|
168
|
+
}
|
|
169
|
+
if (arg.startsWith('--editor-url:')) {
|
|
170
|
+
editorUrl = arg.substring('--editor-url:'.length);
|
|
171
|
+
}
|
|
172
|
+
if (arg.startsWith('--editor-path:')) {
|
|
173
|
+
editorPath = arg.substring('--editor-path:'.length);
|
|
174
|
+
}
|
|
175
|
+
if (arg.startsWith('--output-file:')) {
|
|
176
|
+
outputFile = arg.substring('--output-file:'.length);
|
|
177
|
+
}
|
|
178
|
+
if (arg.startsWith('--project.')) {
|
|
179
|
+
const name = arg.substring('--project.'.length, arg.indexOf('='));
|
|
180
|
+
let location = arg.substring(arg.indexOf('=') + 1);
|
|
181
|
+
location = location.replace('{{_INTERNAL_URL_}}', '{{ INTERNAL_URL }}');
|
|
182
|
+
projects.push({ name, location });
|
|
183
|
+
}
|
|
184
|
+
if (arg.startsWith('--injectDefaultComponent:')) {
|
|
185
|
+
injectDefaultComponent = arg.substring('--injectDefaultComponent:'.length);
|
|
186
|
+
}
|
|
187
|
+
if (arg.startsWith('--defaultComponentImage:')) {
|
|
188
|
+
defaultComponentImage = arg.substring('--defaultComponentImage:'.length);
|
|
189
|
+
}
|
|
285
190
|
});
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
191
|
+
try {
|
|
192
|
+
if (!editorPath && !editorUrl) {
|
|
193
|
+
throw new Error('missing --editor-path: or --editor-url: parameter');
|
|
194
|
+
}
|
|
195
|
+
if (!devfilePath && !devfileUrl) {
|
|
196
|
+
throw new Error('missing --devfile-path: or --devfile-url: parameter');
|
|
197
|
+
}
|
|
198
|
+
if (!outputFile) {
|
|
199
|
+
throw new Error('missing --output-file: parameter');
|
|
200
|
+
}
|
|
201
|
+
await this.generateDevfileContext({
|
|
202
|
+
devfilePath,
|
|
203
|
+
devfileUrl,
|
|
204
|
+
editorPath,
|
|
205
|
+
outputFile,
|
|
206
|
+
editorUrl,
|
|
207
|
+
projects,
|
|
208
|
+
injectDefaultComponent,
|
|
209
|
+
defaultComponentImage,
|
|
210
|
+
}, axios.default);
|
|
211
|
+
return true;
|
|
212
|
+
}
|
|
213
|
+
catch (error) {
|
|
214
|
+
console.error('stack=' + error.stack);
|
|
215
|
+
console.error('Unable to start', error);
|
|
216
|
+
return false;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
289
220
|
exports.Main = Main;
|
|
290
221
|
//# sourceMappingURL=main.js.map
|