@eclipse-che/che-devworkspace-generator 0.0.1-d7aefd7 → 7.69.0-8717dbc
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/README.md +56 -0
- package/lib/api/devfile-context.d.ts +19 -0
- package/lib/bitbucket/bitbucket-module.d.ts +12 -0
- package/lib/bitbucket/bitbucket-module.js +21 -0
- package/lib/bitbucket/bitbucket-module.js.map +1 -0
- package/lib/bitbucket/bitbucket-resolver.d.ts +17 -0
- package/lib/bitbucket/bitbucket-resolver.js +56 -0
- package/lib/bitbucket/bitbucket-resolver.js.map +1 -0
- package/lib/bitbucket/bitbucket-url.d.ts +22 -0
- package/lib/bitbucket/bitbucket-url.js +38 -0
- package/lib/bitbucket/bitbucket-url.js.map +1 -0
- package/lib/bitbucket-server/bitbucket-server-module.d.ts +12 -0
- package/lib/bitbucket-server/bitbucket-server-module.js +21 -0
- package/lib/bitbucket-server/bitbucket-server-module.js.map +1 -0
- package/lib/bitbucket-server/bitbucket-server-resolver.d.ts +17 -0
- package/lib/bitbucket-server/bitbucket-server-resolver.js +64 -0
- package/lib/bitbucket-server/bitbucket-server-resolver.js.map +1 -0
- package/lib/bitbucket-server/bitbucket-server-url.d.ts +24 -0
- package/lib/bitbucket-server/bitbucket-server-url.js +43 -0
- package/lib/bitbucket-server/bitbucket-server-url.js.map +1 -0
- package/lib/devfile/dev-container-component-finder.d.ts +18 -0
- package/lib/devfile/dev-container-component-finder.js +20 -7
- package/lib/devfile/dev-container-component-finder.js.map +1 -1
- package/lib/devfile/dev-container-component-inserter.d.ts +18 -0
- package/lib/devfile/dev-container-component-inserter.js +98 -0
- package/lib/devfile/dev-container-component-inserter.js.map +1 -0
- package/lib/devfile/devfile-module.d.ts +12 -0
- package/lib/devfile/devfile-module.js +2 -0
- package/lib/devfile/devfile-module.js.map +1 -1
- package/lib/entrypoint.d.ts +11 -0
- package/lib/fetch/fetch-module.d.ts +12 -0
- package/lib/fetch/url-fetcher.d.ts +9 -0
- package/lib/generate.d.ts +16 -0
- package/lib/generate.js +32 -21
- package/lib/generate.js.map +1 -1
- package/lib/github/github-module.d.ts +12 -0
- package/lib/github/github-module.js +3 -1
- package/lib/github/github-module.js.map +1 -1
- package/lib/github/github-resolver.d.ts +17 -0
- package/lib/github/github-resolver.js +10 -5
- package/lib/github/github-resolver.js.map +1 -1
- package/lib/github/github-url.d.ts +27 -0
- package/lib/github/github-url.js +7 -9
- package/lib/github/github-url.js.map +1 -1
- package/lib/inversify/inversify-binding.d.ts +26 -0
- package/lib/inversify/inversify-binding.js +6 -0
- package/lib/inversify/inversify-binding.js.map +1 -1
- package/lib/main.d.ts +38 -0
- package/lib/main.js +106 -66
- package/lib/main.js.map +1 -1
- package/lib/plugin-registry/plugin-registry-module.d.ts +12 -0
- package/lib/plugin-registry/plugin-registry-resolver.d.ts +17 -0
- package/lib/plugin-registry/plugin-registry-resolver.js +1 -1
- package/lib/plugin-registry/plugin-registry-resolver.js.map +1 -1
- package/lib/resolve/git-url-resolver.d.ts +5 -0
- package/lib/resolve/git-url-resolver.js +43 -0
- package/lib/resolve/git-url-resolver.js.map +1 -0
- package/lib/resolve/resolve-module.d.ts +12 -0
- package/lib/resolve/resolve-module.js +19 -0
- package/lib/resolve/resolve-module.js.map +1 -0
- package/lib/resolve/resolver.d.ts +22 -0
- package/lib/resolve/resolver.js +12 -0
- package/lib/resolve/resolver.js.map +1 -0
- package/lib/resolve/url.d.ts +35 -0
- package/lib/resolve/url.js +12 -0
- package/lib/resolve/url.js.map +1 -0
- package/lib/types.d.ts +13 -0
- package/lib/types.js +17 -0
- package/lib/types.js.map +1 -0
- package/package.json +6 -4
- package/src/bitbucket/bitbucket-module.ts +21 -0
- package/src/bitbucket/bitbucket-resolver.ts +46 -0
- package/src/bitbucket/bitbucket-url.ts +41 -0
- package/src/bitbucket-server/bitbucket-server-module.ts +21 -0
- package/src/bitbucket-server/bitbucket-server-resolver.ts +53 -0
- package/src/bitbucket-server/bitbucket-server-url.ts +51 -0
- package/src/devfile/dev-container-component-finder.ts +23 -4
- package/src/devfile/dev-container-component-inserter.ts +49 -0
- package/src/devfile/devfile-module.ts +2 -0
- package/src/generate.ts +59 -25
- package/src/github/github-module.ts +4 -1
- package/src/github/github-resolver.ts +17 -9
- package/src/github/github-url.ts +8 -9
- package/src/inversify/inversify-binding.ts +6 -0
- package/src/main.ts +126 -62
- package/src/plugin-registry/plugin-registry-resolver.ts +1 -1
- package/src/resolve/git-url-resolver.ts +30 -0
- package/src/resolve/resolve-module.ts +18 -0
- package/src/resolve/resolver.ts +25 -0
- package/src/resolve/url.ts +40 -0
- package/src/types.ts +14 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**********************************************************************
|
|
3
|
+
* Copyright (c) 2023 Red Hat, Inc.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made
|
|
6
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
7
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
8
|
+
*
|
|
9
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
10
|
+
***********************************************************************/
|
|
11
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
12
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
13
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
14
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
15
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
16
|
+
};
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (_) try {
|
|
33
|
+
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;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
exports.__esModule = true;
|
|
54
|
+
exports.DevContainerComponentInserter = void 0;
|
|
55
|
+
var inversify_1 = require("inversify");
|
|
56
|
+
/**
|
|
57
|
+
* Adds a new component on empty devfile with specific name and image
|
|
58
|
+
*/
|
|
59
|
+
var DevContainerComponentInserter = /** @class */ (function () {
|
|
60
|
+
function DevContainerComponentInserter() {
|
|
61
|
+
this.DEFAULT_DEV_CONTAINER_IMAGE = 'quay.io/devfile/universal-developer-image:ubi8-latest';
|
|
62
|
+
this.DEFAULT_DEV_CONTAINER_NAME = 'dev';
|
|
63
|
+
}
|
|
64
|
+
DevContainerComponentInserter.prototype.insert = function (devfileContext, defaultComponentImage) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
66
|
+
var devContainerImage, devContainerComponent;
|
|
67
|
+
return __generator(this, function (_a) {
|
|
68
|
+
if (!devfileContext.devWorkspace.spec) {
|
|
69
|
+
devfileContext.devWorkspace.spec = {
|
|
70
|
+
started: true
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if (!devfileContext.devWorkspace.spec.template) {
|
|
74
|
+
devfileContext.devWorkspace.spec.template = {};
|
|
75
|
+
}
|
|
76
|
+
if (!devfileContext.devWorkspace.spec.template.components) {
|
|
77
|
+
devfileContext.devWorkspace.spec.template.components = [];
|
|
78
|
+
}
|
|
79
|
+
devContainerImage = defaultComponentImage ? defaultComponentImage : this.DEFAULT_DEV_CONTAINER_IMAGE;
|
|
80
|
+
console.log("No container component has been found. A default container component with image " + devContainerImage + " will be added.");
|
|
81
|
+
devContainerComponent = {
|
|
82
|
+
name: this.DEFAULT_DEV_CONTAINER_NAME,
|
|
83
|
+
container: {
|
|
84
|
+
image: devContainerImage
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
devfileContext.devWorkspace.spec.template.components.push(devContainerComponent);
|
|
88
|
+
return [2 /*return*/];
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
DevContainerComponentInserter = __decorate([
|
|
93
|
+
(0, inversify_1.injectable)()
|
|
94
|
+
], DevContainerComponentInserter);
|
|
95
|
+
return DevContainerComponentInserter;
|
|
96
|
+
}());
|
|
97
|
+
exports.DevContainerComponentInserter = DevContainerComponentInserter;
|
|
98
|
+
//# sourceMappingURL=dev-container-component-inserter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-container-component-inserter.js","sourceRoot":"","sources":["../../src/devfile/dev-container-component-inserter.ts"],"names":[],"mappings":";AAAA;;;;;;;;yEAQyE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIzE,uCAAuC;AAEvC;;GAEG;AAEH;IAAA;QACW,gCAA2B,GAAG,uDAAuD,CAAC;QACtF,+BAA0B,GAAG,KAAK,CAAC;IA4B9C,CAAC;IA1BO,8CAAM,GAAZ,UAAa,cAA8B,EAAE,qBAA8B;;;;gBACzE,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,EAAE;oBACrC,cAAc,CAAC,YAAY,CAAC,IAAI,GAAG;wBACjC,OAAO,EAAE,IAAI;qBACd,CAAC;iBACH;gBACD,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE;oBAC9C,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;iBAChD;gBACD,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE;oBACzD,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,GAAG,EAAE,CAAC;iBAC3D;gBAEK,iBAAiB,GAAG,qBAAqB,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,IAAI,CAAC,2BAA2B,CAAC;gBAC3G,OAAO,CAAC,GAAG,CACT,qFAAmF,iBAAiB,oBAAiB,CACtH,CAAC;gBACI,qBAAqB,GAA+C;oBACxE,IAAI,EAAE,IAAI,CAAC,0BAA0B;oBACrC,SAAS,EAAE;wBACT,KAAK,EAAE,iBAAiB;qBACzB;iBACF,CAAC;gBAEF,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;;;;KAClF;IA7BU,6BAA6B;QADzC,IAAA,sBAAU,GAAE;OACA,6BAA6B,CA8BzC;IAAD,oCAAC;CAAA,AA9BD,IA8BC;AA9BY,sEAA6B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
* Copyright (c) 2022 Red Hat, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made
|
|
5
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
6
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
***********************************************************************/
|
|
10
|
+
import { ContainerModule } from 'inversify';
|
|
11
|
+
declare const devfileModule: ContainerModule;
|
|
12
|
+
export { devfileModule };
|
|
@@ -12,8 +12,10 @@ exports.devfileModule = void 0;
|
|
|
12
12
|
***********************************************************************/
|
|
13
13
|
var inversify_1 = require("inversify");
|
|
14
14
|
var dev_container_component_finder_1 = require("./dev-container-component-finder");
|
|
15
|
+
var dev_container_component_inserter_1 = require("./dev-container-component-inserter");
|
|
15
16
|
var devfileModule = new inversify_1.ContainerModule(function (bind) {
|
|
16
17
|
bind(dev_container_component_finder_1.DevContainerComponentFinder).toSelf().inSingletonScope();
|
|
18
|
+
bind(dev_container_component_inserter_1.DevContainerComponentInserter).toSelf().inSingletonScope();
|
|
17
19
|
});
|
|
18
20
|
exports.devfileModule = devfileModule;
|
|
19
21
|
//# sourceMappingURL=devfile-module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devfile-module.js","sourceRoot":"","sources":["../../src/devfile/devfile-module.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;yEAQyE;AACzE,uCAAwD;AAExD,mFAA+E;
|
|
1
|
+
{"version":3,"file":"devfile-module.js","sourceRoot":"","sources":["../../src/devfile/devfile-module.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;yEAQyE;AACzE,uCAAwD;AAExD,mFAA+E;AAC/E,uFAAmF;AAEnF,IAAM,aAAa,GAAG,IAAI,2BAAe,CAAC,UAAC,IAAqB;IAC9D,IAAI,CAAC,4DAA2B,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IAC9D,IAAI,CAAC,gEAA6B,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;AAClE,CAAC,CAAC,CAAC;AAEM,sCAAa"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**********************************************************************
|
|
3
|
+
* Copyright (c) 2022 Red Hat, Inc.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made
|
|
6
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
7
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
8
|
+
*
|
|
9
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
10
|
+
***********************************************************************/
|
|
11
|
+
import 'reflect-metadata';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
* Copyright (c) 2022 Red Hat, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made
|
|
5
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
6
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
***********************************************************************/
|
|
10
|
+
import { ContainerModule } from 'inversify';
|
|
11
|
+
declare const fetchModule: ContainerModule;
|
|
12
|
+
export { fetchModule };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Allow to grab external content
|
|
3
|
+
* if browser support is enabled, it will update URLs to make them work on browser side.
|
|
4
|
+
*/
|
|
5
|
+
export declare class UrlFetcher {
|
|
6
|
+
private axiosInstance;
|
|
7
|
+
fetchTextOptionalContent(url: string): Promise<string | undefined>;
|
|
8
|
+
fetchText(url: string): Promise<string>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
* Copyright (c) 2022 Red Hat, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made
|
|
5
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
6
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
***********************************************************************/
|
|
10
|
+
import { DevfileContext } from './api/devfile-context';
|
|
11
|
+
export declare class Generate {
|
|
12
|
+
private devContainerComponentFinder;
|
|
13
|
+
generate(devfileContent: string, editorContent: string, outputFile?: string, injectDefaultComponent?: string, defaultComponentImage?: string): Promise<DevfileContext>;
|
|
14
|
+
generateContent(devfileContent: string, editorContent: string, injectDefaultComponent?: string, defaultComponentImage?: string): Promise<DevfileContext>;
|
|
15
|
+
private createDevWorkspaceMetadata;
|
|
16
|
+
}
|
package/lib/generate.js
CHANGED
|
@@ -78,37 +78,39 @@ var dev_container_component_finder_1 = require("./devfile/dev-container-componen
|
|
|
78
78
|
var Generate = /** @class */ (function () {
|
|
79
79
|
function Generate() {
|
|
80
80
|
}
|
|
81
|
-
|
|
82
|
-
Generate.prototype.generate = function (devfileContent, editorContent, outputFile) {
|
|
81
|
+
Generate.prototype.generate = function (devfileContent, editorContent, outputFile, injectDefaultComponent, defaultComponentImage) {
|
|
83
82
|
return __awaiter(this, void 0, void 0, function () {
|
|
84
83
|
var context, allContentArray, generatedContent;
|
|
85
84
|
return __generator(this, function (_a) {
|
|
86
85
|
switch (_a.label) {
|
|
87
|
-
case 0: return [4 /*yield*/, this.generateContent(devfileContent, editorContent)];
|
|
86
|
+
case 0: return [4 /*yield*/, this.generateContent(devfileContent, editorContent, injectDefaultComponent, defaultComponentImage)];
|
|
88
87
|
case 1:
|
|
89
88
|
context = _a.sent();
|
|
89
|
+
if (!outputFile) return [3 /*break*/, 3];
|
|
90
90
|
allContentArray = context.devWorkspaceTemplates.map(function (template) { return jsYaml.dump(template); });
|
|
91
91
|
allContentArray.push(jsYaml.dump(context.devWorkspace));
|
|
92
92
|
generatedContent = allContentArray.join('---\n');
|
|
93
93
|
return [4 /*yield*/, fs.writeFile(outputFile, generatedContent, 'utf-8')];
|
|
94
94
|
case 2:
|
|
95
95
|
_a.sent();
|
|
96
|
+
_a.label = 3;
|
|
97
|
+
case 3:
|
|
96
98
|
console.log("DevWorkspace " + context.devWorkspaceTemplates[0].metadata.name + " was generated.");
|
|
97
99
|
return [2 /*return*/, context];
|
|
98
100
|
}
|
|
99
101
|
});
|
|
100
102
|
});
|
|
101
103
|
};
|
|
102
|
-
Generate.prototype.generateContent = function (devfileContent, editorContent) {
|
|
104
|
+
Generate.prototype.generateContent = function (devfileContent, editorContent, injectDefaultComponent, defaultComponentImage) {
|
|
103
105
|
return __awaiter(this, void 0, void 0, function () {
|
|
104
|
-
var devfile, suffix, editorDevfile, metadata, editorDevWorkspaceTemplate, devfileMetadata, devfileCopy, editorSpecContribution, devWorkspace, devWorkspaceTemplates, context
|
|
106
|
+
var devfile, suffix, editorDevfile, metadata, editorDevWorkspaceTemplate, devfileMetadata, devfileCopy, editorSpecContribution, devWorkspace, devWorkspaceTemplates, context;
|
|
105
107
|
return __generator(this, function (_a) {
|
|
106
108
|
switch (_a.label) {
|
|
107
109
|
case 0:
|
|
108
110
|
devfile = jsYaml.load(devfileContent);
|
|
109
111
|
suffix = devfile.metadata.name || '';
|
|
110
112
|
editorDevfile = jsYaml.load(editorContent);
|
|
111
|
-
metadata = editorDevfile
|
|
113
|
+
metadata = this.createDevWorkspaceMetadata(editorDevfile);
|
|
112
114
|
// add sufix
|
|
113
115
|
metadata.name = metadata.name + "-" + suffix;
|
|
114
116
|
delete editorDevfile.metadata;
|
|
@@ -119,7 +121,7 @@ var Generate = /** @class */ (function () {
|
|
|
119
121
|
metadata: metadata,
|
|
120
122
|
spec: editorDevfile
|
|
121
123
|
};
|
|
122
|
-
devfileMetadata = devfile
|
|
124
|
+
devfileMetadata = this.createDevWorkspaceMetadata(devfile, true);
|
|
123
125
|
devfileCopy = Object.assign({}, devfile);
|
|
124
126
|
delete devfileCopy.schemaVersion;
|
|
125
127
|
delete devfileCopy.metadata;
|
|
@@ -135,6 +137,7 @@ var Generate = /** @class */ (function () {
|
|
|
135
137
|
metadata: devfileMetadata,
|
|
136
138
|
spec: {
|
|
137
139
|
started: true,
|
|
140
|
+
routingClass: 'che',
|
|
138
141
|
template: devfileCopy,
|
|
139
142
|
contributions: [editorSpecContribution]
|
|
140
143
|
}
|
|
@@ -146,29 +149,37 @@ var Generate = /** @class */ (function () {
|
|
|
146
149
|
devWorkspaceTemplates: devWorkspaceTemplates,
|
|
147
150
|
suffix: suffix
|
|
148
151
|
};
|
|
149
|
-
|
|
152
|
+
// find devContainer component, add a default one if not found
|
|
153
|
+
return [4 /*yield*/, this.devContainerComponentFinder.find(context, injectDefaultComponent, defaultComponentImage)];
|
|
150
154
|
case 1:
|
|
151
|
-
devContainer
|
|
152
|
-
|
|
153
|
-
if (!devContainerAttributes) {
|
|
154
|
-
devContainerAttributes = {};
|
|
155
|
-
devContainerAttributes[Generate_1.MERGE_CONTRIBUTION] = true;
|
|
156
|
-
devContainer.attributes = devContainerAttributes;
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
devContainerAttributes[Generate_1.MERGE_CONTRIBUTION] = true;
|
|
160
|
-
}
|
|
155
|
+
// find devContainer component, add a default one if not found
|
|
156
|
+
_a.sent();
|
|
161
157
|
return [2 /*return*/, context];
|
|
162
158
|
}
|
|
163
159
|
});
|
|
164
160
|
});
|
|
165
161
|
};
|
|
166
|
-
|
|
167
|
-
|
|
162
|
+
Generate.prototype.createDevWorkspaceMetadata = function (devfile, addDevfileContent) {
|
|
163
|
+
if (addDevfileContent === void 0) { addDevfileContent = false; }
|
|
164
|
+
var devWorkspaceMetadata = {};
|
|
165
|
+
var devfileMetadata = devfile.metadata;
|
|
166
|
+
if (devfileMetadata.name) {
|
|
167
|
+
devWorkspaceMetadata.name = devfileMetadata.name;
|
|
168
|
+
}
|
|
169
|
+
if (devfileMetadata.generateName) {
|
|
170
|
+
devWorkspaceMetadata.generateName = devfileMetadata.generateName;
|
|
171
|
+
}
|
|
172
|
+
if (addDevfileContent) {
|
|
173
|
+
devWorkspaceMetadata.annotations = {
|
|
174
|
+
'che.eclipse.org/devfile': jsYaml.dump(devfile)
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
return devWorkspaceMetadata;
|
|
178
|
+
};
|
|
168
179
|
__decorate([
|
|
169
180
|
(0, inversify_1.inject)(dev_container_component_finder_1.DevContainerComponentFinder)
|
|
170
181
|
], Generate.prototype, "devContainerComponentFinder");
|
|
171
|
-
Generate =
|
|
182
|
+
Generate = __decorate([
|
|
172
183
|
(0, inversify_1.injectable)()
|
|
173
184
|
], Generate);
|
|
174
185
|
return Generate;
|
package/lib/generate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":";AAAA;;;;;;;;yEAQyE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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Z,qBAAqB,uBAAA;4BACrB,MAAM,QAAA;yBACP,CAAC;wBAEF,8DAA8D;wBAC9D,qBAAM,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,CAAC,EAAA;;wBADnG,8DAA8D;wBAC9D,SAAmG,CAAC;wBAEpG,sBAAO,OAAO,EAAC;;;;KAChB;IAEO,6CAA0B,GAAlC,UAAmC,OAAoB,EAAE,iBAAyB;QAAzB,kCAAA,EAAA,yBAAyB;QAChF,IAAM,oBAAoB,GAAG,EAAkC,CAAC;QAChE,IAAM,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;QAEzC,IAAI,eAAe,CAAC,IAAI,EAAE;YACxB,oBAAoB,CAAC,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC;SAClD;QACD,IAAI,eAAe,CAAC,YAAY,EAAE;YAChC,oBAAoB,CAAC,YAAY,GAAG,eAAe,CAAC,YAAY,CAAC;SAClE;QACD,IAAI,iBAAiB,EAAE;YACrB,oBAAoB,CAAC,WAAW,GAAG;gBACjC,yBAAyB,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;aAChD,CAAC;SACH;QAED,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IAnHD;QADC,IAAA,kBAAM,EAAC,4DAA2B,CAAC;yDAC6B;IAFtD,QAAQ;QADpB,IAAA,sBAAU,GAAE;OACA,QAAQ,CAsHpB;IAAD,eAAC;CAAA,AAtHD,IAsHC;AAtHY,4BAAQ"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
* Copyright (c) 2022 Red Hat, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made
|
|
5
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
6
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
***********************************************************************/
|
|
10
|
+
import { ContainerModule } from 'inversify';
|
|
11
|
+
declare const githubModule: ContainerModule;
|
|
12
|
+
export { githubModule };
|
|
@@ -12,8 +12,10 @@ exports.githubModule = void 0;
|
|
|
12
12
|
***********************************************************************/
|
|
13
13
|
var inversify_1 = require("inversify");
|
|
14
14
|
var github_resolver_1 = require("./github-resolver");
|
|
15
|
+
var types_1 = require("../types");
|
|
16
|
+
var Resolver = types_1.TYPES.Resolver;
|
|
15
17
|
var githubModule = new inversify_1.ContainerModule(function (bind) {
|
|
16
|
-
bind(github_resolver_1.GithubResolver).
|
|
18
|
+
bind(Resolver).to(github_resolver_1.GithubResolver).inSingletonScope();
|
|
17
19
|
});
|
|
18
20
|
exports.githubModule = githubModule;
|
|
19
21
|
//# sourceMappingURL=github-module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-module.js","sourceRoot":"","sources":["../../src/github/github-module.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;yEAQyE;AACzE,uCAAwD;AAExD,qDAAmD;
|
|
1
|
+
{"version":3,"file":"github-module.js","sourceRoot":"","sources":["../../src/github/github-module.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;yEAQyE;AACzE,uCAAwD;AAExD,qDAAmD;AACnD,kCAAiC;AAEzB,IAAA,QAAQ,GAAK,aAAK,SAAV,CAAW;AAE3B,IAAM,YAAY,GAAG,IAAI,2BAAe,CAAC,UAAC,IAAqB;IAC7D,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,gCAAc,CAAC,CAAC,gBAAgB,EAAE,CAAC;AACvD,CAAC,CAAC,CAAC;AAEM,oCAAY"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
* Copyright (c) 2022 Red Hat, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made
|
|
5
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
6
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
***********************************************************************/
|
|
10
|
+
import { Url } from '../resolve/url';
|
|
11
|
+
import { Resolver } from '../resolve/resolver';
|
|
12
|
+
export declare class GithubResolver implements Resolver {
|
|
13
|
+
static readonly GITHUB_URL_PATTERN: RegExp;
|
|
14
|
+
isValid(url: string): boolean;
|
|
15
|
+
resolve(link: string): Url;
|
|
16
|
+
private getGroup;
|
|
17
|
+
}
|
|
@@ -18,23 +18,28 @@ exports.__esModule = true;
|
|
|
18
18
|
exports.GithubResolver = void 0;
|
|
19
19
|
var github_url_1 = require("./github-url");
|
|
20
20
|
var inversify_1 = require("inversify");
|
|
21
|
-
/**
|
|
22
|
-
* Provides a github URL object allowing to interact
|
|
23
|
-
*/
|
|
24
21
|
var GithubResolver = /** @class */ (function () {
|
|
25
22
|
function GithubResolver() {
|
|
26
23
|
}
|
|
27
24
|
GithubResolver_1 = GithubResolver;
|
|
25
|
+
GithubResolver.prototype.isValid = function (url) {
|
|
26
|
+
return GithubResolver_1.GITHUB_URL_PATTERN.test(url);
|
|
27
|
+
};
|
|
28
28
|
GithubResolver.prototype.resolve = function (link) {
|
|
29
29
|
var match = GithubResolver_1.GITHUB_URL_PATTERN.exec(link);
|
|
30
30
|
if (!match) {
|
|
31
31
|
throw new Error("Invalid github URL: " + link);
|
|
32
32
|
}
|
|
33
|
+
var scheme = this.getGroup(match, 'scheme');
|
|
34
|
+
var hostName = this.getGroup(match, 'host');
|
|
33
35
|
var repoUser = this.getGroup(match, 'repoUser');
|
|
34
36
|
var repoName = this.getGroup(match, 'repoName');
|
|
37
|
+
if (/^[\w-][\w.-]*?\.git$/.test(repoName)) {
|
|
38
|
+
repoName = repoName.substring(0, repoName.length - 4);
|
|
39
|
+
}
|
|
35
40
|
var branchName = this.getGroup(match, 'branchName', 'HEAD');
|
|
36
41
|
var subFolder = this.getGroup(match, 'subFolder');
|
|
37
|
-
return new github_url_1.GithubUrl(repoUser, repoName, branchName, subFolder);
|
|
42
|
+
return new github_url_1.GithubUrl(scheme, hostName, repoUser, repoName, branchName, subFolder);
|
|
38
43
|
};
|
|
39
44
|
GithubResolver.prototype.getGroup = function (match, groupName, defaultValue) {
|
|
40
45
|
if (match.groups && match.groups[groupName]) {
|
|
@@ -44,7 +49,7 @@ var GithubResolver = /** @class */ (function () {
|
|
|
44
49
|
};
|
|
45
50
|
var GithubResolver_1;
|
|
46
51
|
// eslint-disable-next-line max-len
|
|
47
|
-
GithubResolver.GITHUB_URL_PATTERN = /^(
|
|
52
|
+
GithubResolver.GITHUB_URL_PATTERN = /^(?<scheme>https?):\/\/(?<host>github(\..+)?\.[^\/]+)\/(?<repoUser>[^\/]+)\/(?<repoName>[^\/]+)((\/)|\/(blob|tree)\/(?<branchName>[^\/]+)(?:\/(?<subFolder>.*))?)?$/;
|
|
48
53
|
GithubResolver = GithubResolver_1 = __decorate([
|
|
49
54
|
(0, inversify_1.injectable)()
|
|
50
55
|
], GithubResolver);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-resolver.js","sourceRoot":"","sources":["../../src/github/github-resolver.ts"],"names":[],"mappings":";AAAA;;;;;;;;yEAQyE;;;;;;;;;AAEzE,2CAAyC;AACzC,uCAAuC;
|
|
1
|
+
{"version":3,"file":"github-resolver.js","sourceRoot":"","sources":["../../src/github/github-resolver.ts"],"names":[],"mappings":";AAAA;;;;;;;;yEAQyE;;;;;;;;;AAEzE,2CAAyC;AACzC,uCAAuC;AAKvC;IAAA;IAgCA,CAAC;uBAhCY,cAAc;IAKzB,gCAAO,GAAP,UAAQ,GAAW;QACjB,OAAO,gBAAc,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrD,CAAC;IAED,gCAAO,GAAP,UAAQ,IAAY;QAClB,IAAM,KAAK,GAAG,gBAAc,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3D,IAAI,CAAC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;CAAA,AAhCD,IAgCC;AAhCY,wCAAc"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
* Copyright (c) 2022 Red Hat, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made
|
|
5
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
6
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
***********************************************************************/
|
|
10
|
+
import { Url } from '../resolve/url';
|
|
11
|
+
export declare class GithubUrl implements Url {
|
|
12
|
+
private readonly scheme;
|
|
13
|
+
private readonly hostName;
|
|
14
|
+
private readonly repoUser;
|
|
15
|
+
private readonly repoName;
|
|
16
|
+
private readonly branchName;
|
|
17
|
+
private readonly subFolder;
|
|
18
|
+
constructor(scheme: string, hostName: string, repoUser: string, repoName: string, branchName: string, subFolder: string);
|
|
19
|
+
/**
|
|
20
|
+
* Provides the raw link to the given path based on the current repository information
|
|
21
|
+
*/
|
|
22
|
+
getContentUrl(path: string): string;
|
|
23
|
+
getUrl(): string;
|
|
24
|
+
getCloneUrl(): string;
|
|
25
|
+
getRepoName(): string;
|
|
26
|
+
getBranchName(): string;
|
|
27
|
+
}
|
package/lib/github/github-url.js
CHANGED
|
@@ -10,11 +10,10 @@
|
|
|
10
10
|
***********************************************************************/
|
|
11
11
|
exports.__esModule = true;
|
|
12
12
|
exports.GithubUrl = void 0;
|
|
13
|
-
/**
|
|
14
|
-
* Provides helper methods on top of github URL to get for example raw content of get relative links
|
|
15
|
-
*/
|
|
16
13
|
var GithubUrl = /** @class */ (function () {
|
|
17
|
-
function GithubUrl(repoUser, repoName, branchName, subFolder) {
|
|
14
|
+
function GithubUrl(scheme, hostName, repoUser, repoName, branchName, subFolder) {
|
|
15
|
+
this.scheme = scheme;
|
|
16
|
+
this.hostName = hostName;
|
|
18
17
|
this.repoUser = repoUser;
|
|
19
18
|
this.repoName = repoName;
|
|
20
19
|
this.branchName = branchName;
|
|
@@ -24,13 +23,14 @@ var GithubUrl = /** @class */ (function () {
|
|
|
24
23
|
* Provides the raw link to the given path based on the current repository information
|
|
25
24
|
*/
|
|
26
25
|
GithubUrl.prototype.getContentUrl = function (path) {
|
|
27
|
-
|
|
26
|
+
var hostName = this.hostName === 'github.com' ? 'githubusercontent.com' : this.hostName;
|
|
27
|
+
return this.scheme + "://raw." + hostName + "/" + this.repoUser + "/" + this.repoName + "/" + this.branchName + "/" + path;
|
|
28
28
|
};
|
|
29
29
|
GithubUrl.prototype.getUrl = function () {
|
|
30
|
-
return "
|
|
30
|
+
return this.scheme + "://" + this.hostName + "/" + this.repoUser + "/" + this.repoName + "/tree/" + this.branchName + "/" + this.subFolder;
|
|
31
31
|
};
|
|
32
32
|
GithubUrl.prototype.getCloneUrl = function () {
|
|
33
|
-
return "
|
|
33
|
+
return this.scheme + "://" + this.hostName + "/" + this.repoUser + "/" + this.repoName + ".git";
|
|
34
34
|
};
|
|
35
35
|
GithubUrl.prototype.getRepoName = function () {
|
|
36
36
|
return this.repoName;
|
|
@@ -38,8 +38,6 @@ var GithubUrl = /** @class */ (function () {
|
|
|
38
38
|
GithubUrl.prototype.getBranchName = function () {
|
|
39
39
|
return this.branchName;
|
|
40
40
|
};
|
|
41
|
-
// raw link
|
|
42
|
-
GithubUrl.RAW_LINK = 'https://raw.githubusercontent.com';
|
|
43
41
|
return GithubUrl;
|
|
44
42
|
}());
|
|
45
43
|
exports.GithubUrl = GithubUrl;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-url.js","sourceRoot":"","sources":["../../src/github/github-url.ts"],"names":[],"mappings":";AAAA;;;;;;;;yEAQyE;;;
|
|
1
|
+
{"version":3,"file":"github-url.js","sourceRoot":"","sources":["../../src/github/github-url.ts"],"names":[],"mappings":";AAAA;;;;;;;;yEAQyE;;;AAIzE;IACE,mBACmB,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,iCAAa,GAAb,UAAc,IAAY;QACxB,IAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC1F,OAAU,IAAI,CAAC,MAAM,eAAU,QAAQ,SAAI,IAAI,CAAC,QAAQ,SAAI,IAAI,CAAC,QAAQ,SAAI,IAAI,CAAC,UAAU,SAAI,IAAM,CAAC;IACzG,CAAC;IAED,0BAAM,GAAN;QACE,OAAU,IAAI,CAAC,MAAM,WAAM,IAAI,CAAC,QAAQ,SAAI,IAAI,CAAC,QAAQ,SAAI,IAAI,CAAC,QAAQ,cAAS,IAAI,CAAC,UAAU,SAAI,IAAI,CAAC,SAAW,CAAC;IACzH,CAAC;IAED,+BAAW,GAAX;QACE,OAAU,IAAI,CAAC,MAAM,WAAM,IAAI,CAAC,QAAQ,SAAI,IAAI,CAAC,QAAQ,SAAI,IAAI,CAAC,QAAQ,SAAM,CAAC;IACnF,CAAC;IAED,+BAAW,GAAX;QACE,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,iCAAa,GAAb;QACE,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IACH,gBAAC;AAAD,CAAC,AAjCD,IAiCC;AAjCY,8BAAS"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
* Copyright (c) 2022 Red Hat, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made
|
|
5
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
6
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
***********************************************************************/
|
|
10
|
+
import 'reflect-metadata';
|
|
11
|
+
import { AxiosInstance } from 'axios';
|
|
12
|
+
import { Container } from 'inversify';
|
|
13
|
+
/**
|
|
14
|
+
* Manage all bindings for inversify
|
|
15
|
+
*/
|
|
16
|
+
export declare class InversifyBinding {
|
|
17
|
+
private container;
|
|
18
|
+
initBindings(options: InversifyBindingOptions): Promise<Container>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Options for inversify bindings
|
|
22
|
+
*/
|
|
23
|
+
export interface InversifyBindingOptions {
|
|
24
|
+
pluginRegistryUrl: string;
|
|
25
|
+
axiosInstance: AxiosInstance;
|
|
26
|
+
}
|
|
@@ -51,7 +51,10 @@ var inversify_1 = require("inversify");
|
|
|
51
51
|
var devfile_module_1 = require("../devfile/devfile-module");
|
|
52
52
|
var fetch_module_1 = require("../fetch/fetch-module");
|
|
53
53
|
var github_module_1 = require("../github/github-module");
|
|
54
|
+
var resolve_module_1 = require("../resolve/resolve-module");
|
|
54
55
|
var plugin_registry_module_1 = require("../plugin-registry/plugin-registry-module");
|
|
56
|
+
var bitbucket_module_1 = require("../bitbucket/bitbucket-module");
|
|
57
|
+
var bitbucket_server_module_1 = require("../bitbucket-server/bitbucket-server-module");
|
|
55
58
|
/**
|
|
56
59
|
* Manage all bindings for inversify
|
|
57
60
|
*/
|
|
@@ -65,6 +68,9 @@ var InversifyBinding = /** @class */ (function () {
|
|
|
65
68
|
this.container.load(devfile_module_1.devfileModule);
|
|
66
69
|
this.container.load(fetch_module_1.fetchModule);
|
|
67
70
|
this.container.load(github_module_1.githubModule);
|
|
71
|
+
this.container.load(bitbucket_module_1.bitbucketModule);
|
|
72
|
+
this.container.load(bitbucket_server_module_1.bitbucketServerModule);
|
|
73
|
+
this.container.load(resolve_module_1.resolveModule);
|
|
68
74
|
this.container.load(plugin_registry_module_1.pluginRegistryModule);
|
|
69
75
|
this.container.bind(Symbol["for"]('AxiosInstance')).toConstantValue(options.axiosInstance);
|
|
70
76
|
this.container.bind('string').toConstantValue(options.pluginRegistryUrl).whenTargetNamed('PLUGIN_REGISTRY_URL');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inversify-binding.js","sourceRoot":"","sources":["../../src/inversify/inversify-binding.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;yEAQyE;AACzE,4BAA0B;AAG1B,uCAAsC;AACtC,4DAA0D;AAC1D,sDAAoD;AACpD,yDAAuD;AACvD,oFAAiF;
|
|
1
|
+
{"version":3,"file":"inversify-binding.js","sourceRoot":"","sources":["../../src/inversify/inversify-binding.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;yEAQyE;AACzE,4BAA0B;AAG1B,uCAAsC;AACtC,4DAA0D;AAC1D,sDAAoD;AACpD,yDAAuD;AACvD,4DAA0D;AAC1D,oFAAiF;AACjF,kEAAgE;AAChE,uFAAoF;AAEpF;;GAEG;AACH;IAAA;IAmBA,CAAC;IAhBc,uCAAY,GAAzB,UAA0B,OAAgC;;;gBACxD,IAAI,CAAC,SAAS,GAAG,IAAI,qBAAS,EAAE,CAAC;gBAEjC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,8BAAa,CAAC,CAAC;gBACnC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,0BAAW,CAAC,CAAC;gBACjC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,4BAAY,CAAC,CAAC;gBAClC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,kCAAe,CAAC,CAAC;gBACrC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,+CAAqB,CAAC,CAAC;gBAC3C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,8BAAa,CAAC,CAAC;gBACnC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,6CAAoB,CAAC,CAAC;gBAE1C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,KAAG,CAAA,CAAC,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;gBACxF,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAC;gBAEhH,sBAAO,IAAI,CAAC,SAAS,EAAC;;;KACvB;IACH,uBAAC;AAAD,CAAC,AAnBD,IAmBC;AAnBY,4CAAgB"}
|
package/lib/main.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
* Copyright (c) 2022 Red Hat, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made
|
|
5
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
6
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
***********************************************************************/
|
|
10
|
+
import * as axios from 'axios';
|
|
11
|
+
import { DevfileContext } from './api/devfile-context';
|
|
12
|
+
export declare class Main {
|
|
13
|
+
/**
|
|
14
|
+
* Default constructor.
|
|
15
|
+
*/
|
|
16
|
+
constructor();
|
|
17
|
+
generateDevfileContext(params: {
|
|
18
|
+
devfilePath?: string;
|
|
19
|
+
devfileUrl?: string;
|
|
20
|
+
devfileContent?: string;
|
|
21
|
+
outputFile?: string;
|
|
22
|
+
editorPath?: string;
|
|
23
|
+
editorContent?: string;
|
|
24
|
+
editorEntry?: string;
|
|
25
|
+
pluginRegistryUrl?: string;
|
|
26
|
+
projects: {
|
|
27
|
+
name: string;
|
|
28
|
+
location: string;
|
|
29
|
+
}[];
|
|
30
|
+
injectDefaultComponent?: string;
|
|
31
|
+
defaultComponentImage?: string;
|
|
32
|
+
}, axiosInstance: axios.AxiosInstance): Promise<DevfileContext>;
|
|
33
|
+
replaceIfExistingProjects(devfileContent: string, projects: {
|
|
34
|
+
name: string;
|
|
35
|
+
location: string;
|
|
36
|
+
}[]): string;
|
|
37
|
+
start(): Promise<boolean>;
|
|
38
|
+
}
|