@eclipse-che/che-devworkspace-generator 0.0.1-09a1f81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +50 -0
  2. package/lib/api/devfile-context.d.ts +19 -0
  3. package/lib/api/devfile-context.js +3 -0
  4. package/lib/api/devfile-context.js.map +1 -0
  5. package/lib/devfile/dev-container-component-finder.d.ts +17 -0
  6. package/lib/devfile/dev-container-component-finder.js +93 -0
  7. package/lib/devfile/dev-container-component-finder.js.map +1 -0
  8. package/lib/devfile/devfile-module.d.ts +12 -0
  9. package/lib/devfile/devfile-module.js +19 -0
  10. package/lib/devfile/devfile-module.js.map +1 -0
  11. package/lib/entrypoint.d.ts +11 -0
  12. package/lib/entrypoint.js +67 -0
  13. package/lib/entrypoint.js.map +1 -0
  14. package/lib/fetch/fetch-module.d.ts +12 -0
  15. package/lib/fetch/fetch-module.js +19 -0
  16. package/lib/fetch/fetch-module.js.map +1 -0
  17. package/lib/fetch/url-fetcher.d.ts +9 -0
  18. package/lib/fetch/url-fetcher.js +114 -0
  19. package/lib/fetch/url-fetcher.js.map +1 -0
  20. package/lib/generate.d.ts +16 -0
  21. package/lib/generate.js +183 -0
  22. package/lib/generate.js.map +1 -0
  23. package/lib/github/github-module.d.ts +12 -0
  24. package/lib/github/github-module.js +19 -0
  25. package/lib/github/github-module.js.map +1 -0
  26. package/lib/github/github-resolver.d.ts +18 -0
  27. package/lib/github/github-resolver.js +56 -0
  28. package/lib/github/github-resolver.js.map +1 -0
  29. package/lib/github/github-url.d.ts +29 -0
  30. package/lib/github/github-url.js +47 -0
  31. package/lib/github/github-url.js.map +1 -0
  32. package/lib/inversify/inversify-binding.d.ts +26 -0
  33. package/lib/inversify/inversify-binding.js +78 -0
  34. package/lib/inversify/inversify-binding.js.map +1 -0
  35. package/lib/main.d.ts +36 -0
  36. package/lib/main.js +265 -0
  37. package/lib/main.js.map +1 -0
  38. package/lib/plugin-registry/plugin-registry-module.d.ts +12 -0
  39. package/lib/plugin-registry/plugin-registry-module.js +19 -0
  40. package/lib/plugin-registry/plugin-registry-module.js.map +1 -0
  41. package/lib/plugin-registry/plugin-registry-resolver.d.ts +17 -0
  42. package/lib/plugin-registry/plugin-registry-resolver.js +113 -0
  43. package/lib/plugin-registry/plugin-registry-resolver.js.map +1 -0
  44. package/package.json +93 -0
  45. package/src/api/devfile-context.ts +28 -0
  46. package/src/devfile/dev-container-component-finder.ts +45 -0
  47. package/src/devfile/devfile-module.ts +18 -0
  48. package/src/entrypoint.ts +22 -0
  49. package/src/fetch/fetch-module.ts +18 -0
  50. package/src/fetch/url-fetcher.ts +49 -0
  51. package/src/generate.ts +122 -0
  52. package/src/github/github-module.ts +18 -0
  53. package/src/github/github-resolver.ts +43 -0
  54. package/src/github/github-url.ts +47 -0
  55. package/src/inversify/inversify-binding.ts +46 -0
  56. package/src/main.ts +212 -0
  57. package/src/plugin-registry/plugin-registry-module.ts +18 -0
  58. package/src/plugin-registry/plugin-registry-resolver.ts +36 -0
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ ## DevWorkspace Generator
2
+ The library is used by Devfile registry component to generate the DevWorkspace components and DevWorkspace templates. It requires editor definitions from the
3
+ [che-plugin-registry](https://github.com/eclipse-che/che-plugin-registry/).
4
+
5
+ ## How to use the library
6
+ The library can be used as a standalone library.
7
+
8
+ ```
9
+ USAGE
10
+ $ node lib/entrypoint.js [OPTIONS]
11
+
12
+ OPTIONS
13
+ --devfile-url: URL to the git repository that contains devfile.yaml
14
+ or
15
+ --devfile-path: path to the devfile.yaml file
16
+
17
+ --plugin-registry-url: URL to the plugin registry that contains editor definitions (devfile.yaml)
18
+ --editor-entry: editor ID, found on the <plugin-registry-url>, to resolve the devfile.yaml
19
+ or
20
+ --editor-path: local file path of the editor devfile.yaml
21
+
22
+ --output-file: local file path for the generated devworkspace yaml
23
+
24
+ --project.<project-name> local file path for the sample project zip (for airgapped/offline registry builds)
25
+
26
+ EXAMPLES
27
+
28
+ # online example, using editor definition from https://che-plugin-registry-main.surge.sh/
29
+
30
+ $ node lib/entrypoint.js \
31
+ --devfile-url:https://github.com/che-samples/java-spring-petclinic/tree/main \
32
+ --plugin-registry-url:https://che-plugin-registry-main.surge.sh/v3/ \
33
+ --editor-entry:che-incubator/che-code/latest \
34
+ --output-file:/tmp/devworkspace-che-code-latest.yaml`
35
+
36
+ # offline example with devfile.yaml files and zipped project available locally
37
+
38
+ $ node lib/entrypoint.js \
39
+ --devfile-path:/remote-source/python-hello-world/app/devfile.yaml \
40
+ --editor-path:/build/plugins/che-incubator/che-code/latest/devfile.yaml \
41
+ --output-file:./devfiles/python__python-hello-world/devworkspace-che-code-latest.yaml \
42
+ --project.python-hello-world='{{_INTERNAL_URL_}}/resources/v2/python-hello-world.zip'
43
+
44
+ ```
45
+
46
+ The output file `devworkspace-che-code-latest.yaml` contains a DevWorkspace based on the repository devfile and a Che-Code DevWorkspaceTemplate.
47
+
48
+ If the DevWorkspace engine is installed on the cluster, the following command will create a DevWorkspace:
49
+
50
+ `$ kubectl apply -f /tmp/devworkspace-che-code-latest.yaml`
@@ -0,0 +1,19 @@
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 { V1alpha2DevWorkspace, V1alpha2DevWorkspaceTemplate } from '@devfile/api';
11
+ /**
12
+ * Context used on every call to this service to update DevWorkspace
13
+ */
14
+ export interface DevfileContext {
15
+ devfile: any;
16
+ devWorkspace: V1alpha2DevWorkspace;
17
+ devWorkspaceTemplates: V1alpha2DevWorkspaceTemplate[];
18
+ suffix: string;
19
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ //# sourceMappingURL=devfile-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devfile-context.js","sourceRoot":"","sources":["../../src/api/devfile-context.ts"],"names":[],"mappings":""}
@@ -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 { DevfileContext } from '../api/devfile-context';
11
+ import { V1alpha2DevWorkspaceSpecTemplateComponents } from '@devfile/api';
12
+ /**
13
+ * Need to find dev container from main dev workspace
14
+ */
15
+ export declare class DevContainerComponentFinder {
16
+ find(devfileContext: DevfileContext): Promise<V1alpha2DevWorkspaceSpecTemplateComponents | undefined>;
17
+ }
@@ -0,0 +1,93 @@
1
+ "use strict";
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
+ 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.DevContainerComponentFinder = void 0;
55
+ var inversify_1 = require("inversify");
56
+ /**
57
+ * Need to find dev container from main dev workspace
58
+ */
59
+ var DevContainerComponentFinder = /** @class */ (function () {
60
+ function DevContainerComponentFinder() {
61
+ }
62
+ DevContainerComponentFinder.prototype.find = function (devfileContext) {
63
+ var _a, _b, _c;
64
+ return __awaiter(this, void 0, void 0, function () {
65
+ var devComponents;
66
+ return __generator(this, function (_d) {
67
+ devComponents = (_c = (_b = (_a = devfileContext.devWorkspace.spec) === null || _a === void 0 ? void 0 : _a.template) === null || _b === void 0 ? void 0 : _b.components) === null || _c === void 0 ? void 0 : _c.filter(function (component) { return component.container; }).filter(
68
+ // we should ignore component that do not mount the sources
69
+ function (component) { return component.container && component.container.mountSources !== false; });
70
+ if (!devComponents || devComponents.length === 0) {
71
+ if (devfileContext.devfile.parent) {
72
+ return [2 /*return*/, undefined];
73
+ }
74
+ throw new Error('Not able to find any dev container component in DevWorkspace');
75
+ }
76
+ else if (devComponents.length === 1) {
77
+ return [2 /*return*/, devComponents[0]];
78
+ }
79
+ else {
80
+ console.warn("More than one dev container component has been potentially found, taking the first one of " + devComponents.map(function (component) { return component.name; }));
81
+ return [2 /*return*/, devComponents[0]];
82
+ }
83
+ return [2 /*return*/];
84
+ });
85
+ });
86
+ };
87
+ DevContainerComponentFinder = __decorate([
88
+ (0, inversify_1.injectable)()
89
+ ], DevContainerComponentFinder);
90
+ return DevContainerComponentFinder;
91
+ }());
92
+ exports.DevContainerComponentFinder = DevContainerComponentFinder;
93
+ //# sourceMappingURL=dev-container-component-finder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dev-container-component-finder.js","sourceRoot":"","sources":["../../src/devfile/dev-container-component-finder.ts"],"names":[],"mappings":";AAAA;;;;;;;;yEAQyE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIzE,uCAAuC;AAEvC;;GAEG;AAEH;IAAA;IA0BA,CAAC;IAzBO,0CAAI,GAAV,UAAW,cAA8B;;;;;gBAEjC,aAAa,GAAG,MAAA,MAAA,MAAA,cAAc,CAAC,YAAY,CAAC,IAAI,0CAAE,QAAQ,0CAAE,UAAU,0CACxE,MAAM,CAAC,UAAA,SAAS,IAAI,OAAA,SAAS,CAAC,SAAS,EAAnB,CAAmB,EACxC,MAAM;gBACL,2DAA2D;gBAC3D,UAAA,SAAS,IAAI,OAAA,SAAS,CAAC,SAAS,IAAI,SAAS,CAAC,SAAS,CAAC,YAAY,KAAK,KAAK,EAAjE,CAAiE,CAC/E,CAAC;gBAEJ,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;oBAChD,IAAI,cAAc,CAAC,OAAO,CAAC,MAAM,EAAE;wBACjC,sBAAO,SAAS,EAAC;qBAClB;oBACD,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;iBACjF;qBAAM,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;oBACrC,sBAAO,aAAa,CAAC,CAAC,CAAC,EAAC;iBACzB;qBAAM;oBACL,OAAO,CAAC,IAAI,CACV,+FAA6F,aAAa,CAAC,GAAG,CAC5G,UAAA,SAAS,IAAI,OAAA,SAAS,CAAC,IAAI,EAAd,CAAc,CAC1B,CACJ,CAAC;oBACF,sBAAO,aAAa,CAAC,CAAC,CAAC,EAAC;iBACzB;;;;KACF;IAzBU,2BAA2B;QADvC,IAAA,sBAAU,GAAE;OACA,2BAA2B,CA0BvC;IAAD,kCAAC;CAAA,AA1BD,IA0BC;AA1BY,kEAA2B"}
@@ -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 };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.devfileModule = void 0;
4
+ /**********************************************************************
5
+ * Copyright (c) 2022 Red Hat, Inc.
6
+ *
7
+ * This program and the accompanying materials are made
8
+ * available under the terms of the Eclipse Public License 2.0
9
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
10
+ *
11
+ * SPDX-License-Identifier: EPL-2.0
12
+ ***********************************************************************/
13
+ var inversify_1 = require("inversify");
14
+ var dev_container_component_finder_1 = require("./dev-container-component-finder");
15
+ var devfileModule = new inversify_1.ContainerModule(function (bind) {
16
+ bind(dev_container_component_finder_1.DevContainerComponentFinder).toSelf().inSingletonScope();
17
+ });
18
+ exports.devfileModule = devfileModule;
19
+ //# sourceMappingURL=devfile-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devfile-module.js","sourceRoot":"","sources":["../../src/devfile/devfile-module.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;yEAQyE;AACzE,uCAAwD;AAExD,mFAA+E;AAE/E,IAAM,aAAa,GAAG,IAAI,2BAAe,CAAC,UAAC,IAAqB;IAC9D,IAAI,CAAC,4DAA2B,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;AAChE,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,67 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ /**********************************************************************
4
+ * Copyright (c) 2022 Red Hat, Inc.
5
+ *
6
+ * This program and the accompanying materials are made
7
+ * available under the terms of the Eclipse Public License 2.0
8
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
9
+ *
10
+ * SPDX-License-Identifier: EPL-2.0
11
+ ***********************************************************************/
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (_) try {
28
+ 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;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ exports.__esModule = true;
49
+ require("reflect-metadata");
50
+ var main_1 = require("./main");
51
+ (function () { return __awaiter(void 0, void 0, void 0, function () {
52
+ var main, success;
53
+ return __generator(this, function (_a) {
54
+ switch (_a.label) {
55
+ case 0:
56
+ main = new main_1.Main();
57
+ return [4 /*yield*/, main.start()];
58
+ case 1:
59
+ success = _a.sent();
60
+ if (!success) {
61
+ process.exit(1);
62
+ }
63
+ return [2 /*return*/];
64
+ }
65
+ });
66
+ }); })();
67
+ //# sourceMappingURL=entrypoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entrypoint.js","sourceRoot":"","sources":["../src/entrypoint.ts"],"names":[],"mappings":";;AACA;;;;;;;;yEAQyE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzE,4BAA0B;AAE1B,+BAA8B;AAE9B,CAAC;;;;;gBACO,IAAI,GAAG,IAAI,WAAI,EAAE,CAAC;gBACR,qBAAM,IAAI,CAAC,KAAK,EAAE,EAAA;;gBAA5B,OAAO,GAAG,SAAkB;gBAClC,IAAI,CAAC,OAAO,EAAE;oBACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;iBACjB;;;;KACF,CAAC,EAAE,CAAC"}
@@ -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,19 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.fetchModule = void 0;
4
+ /**********************************************************************
5
+ * Copyright (c) 2022 Red Hat, Inc.
6
+ *
7
+ * This program and the accompanying materials are made
8
+ * available under the terms of the Eclipse Public License 2.0
9
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
10
+ *
11
+ * SPDX-License-Identifier: EPL-2.0
12
+ ***********************************************************************/
13
+ var inversify_1 = require("inversify");
14
+ var url_fetcher_1 = require("./url-fetcher");
15
+ var fetchModule = new inversify_1.ContainerModule(function (bind) {
16
+ bind(url_fetcher_1.UrlFetcher).toSelf().inSingletonScope();
17
+ });
18
+ exports.fetchModule = fetchModule;
19
+ //# sourceMappingURL=fetch-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-module.js","sourceRoot":"","sources":["../../src/fetch/fetch-module.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;yEAQyE;AACzE,uCAAwD;AAExD,6CAA2C;AAE3C,IAAM,WAAW,GAAG,IAAI,2BAAe,CAAC,UAAC,IAAqB;IAC5D,IAAI,CAAC,wBAAU,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;AAC/C,CAAC,CAAC,CAAC;AAEM,kCAAW"}
@@ -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,114 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
+ return new (P || (P = Promise))(function (resolve, reject) {
11
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
15
+ });
16
+ };
17
+ var __generator = (this && this.__generator) || function (thisArg, body) {
18
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
19
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
20
+ function verb(n) { return function (v) { return step([n, v]); }; }
21
+ function step(op) {
22
+ if (f) throw new TypeError("Generator is already executing.");
23
+ while (_) try {
24
+ 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;
25
+ if (y = 0, t) op = [op[0] & 2, t.value];
26
+ switch (op[0]) {
27
+ case 0: case 1: t = op; break;
28
+ case 4: _.label++; return { value: op[1], done: false };
29
+ case 5: _.label++; y = op[1]; op = [0]; continue;
30
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
31
+ default:
32
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
33
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
34
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
35
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
36
+ if (t[2]) _.ops.pop();
37
+ _.trys.pop(); continue;
38
+ }
39
+ op = body.call(thisArg, _);
40
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
41
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
42
+ }
43
+ };
44
+ exports.__esModule = true;
45
+ exports.UrlFetcher = void 0;
46
+ /**********************************************************************
47
+ * Copyright (c) 2022 Red Hat, Inc.
48
+ *
49
+ * This program and the accompanying materials are made
50
+ * available under the terms of the Eclipse Public License 2.0
51
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
52
+ *
53
+ * SPDX-License-Identifier: EPL-2.0
54
+ ***********************************************************************/
55
+ var inversify_1 = require("inversify");
56
+ /**
57
+ * Allow to grab external content
58
+ * if browser support is enabled, it will update URLs to make them work on browser side.
59
+ */
60
+ var UrlFetcher = /** @class */ (function () {
61
+ function UrlFetcher() {
62
+ }
63
+ // fetch content optionally, if the URL is not found, we return undefined without throwing errors
64
+ UrlFetcher.prototype.fetchTextOptionalContent = function (url) {
65
+ return __awaiter(this, void 0, void 0, function () {
66
+ var response, error_1;
67
+ return __generator(this, function (_a) {
68
+ switch (_a.label) {
69
+ case 0:
70
+ _a.trys.push([0, 2, , 3]);
71
+ return [4 /*yield*/, this.axiosInstance.get(url, {
72
+ responseType: 'text'
73
+ })];
74
+ case 1:
75
+ response = _a.sent();
76
+ return [2 /*return*/, response.data];
77
+ case 2:
78
+ error_1 = _a.sent();
79
+ // not found then we return undefined
80
+ if (error_1.response && error_1.response.status === 404) {
81
+ return [2 /*return*/, undefined];
82
+ }
83
+ throw error_1;
84
+ case 3: return [2 /*return*/];
85
+ }
86
+ });
87
+ });
88
+ };
89
+ // fetch content
90
+ UrlFetcher.prototype.fetchText = function (url) {
91
+ return __awaiter(this, void 0, void 0, function () {
92
+ var response;
93
+ return __generator(this, function (_a) {
94
+ switch (_a.label) {
95
+ case 0: return [4 /*yield*/, this.axiosInstance.get(url, {
96
+ responseType: 'text'
97
+ })];
98
+ case 1:
99
+ response = _a.sent();
100
+ return [2 /*return*/, response.data];
101
+ }
102
+ });
103
+ });
104
+ };
105
+ __decorate([
106
+ (0, inversify_1.inject)(Symbol["for"]('AxiosInstance'))
107
+ ], UrlFetcher.prototype, "axiosInstance");
108
+ UrlFetcher = __decorate([
109
+ (0, inversify_1.injectable)()
110
+ ], UrlFetcher);
111
+ return UrlFetcher;
112
+ }());
113
+ exports.UrlFetcher = UrlFetcher;
114
+ //# sourceMappingURL=url-fetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url-fetcher.js","sourceRoot":"","sources":["../../src/fetch/url-fetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;yEAQyE;AACzE,uCAA+C;AAI/C;;;GAGG;AAEH;IAAA;IA8BA,CAAC;IAzBC,iGAAiG;IAC3F,6CAAwB,GAA9B,UAA+B,GAAW;;;;;;;wBAErB,qBAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,GAAG,EAAE;gCACzD,YAAY,EAAE,MAAM;6BACrB,CAAC,EAAA;;wBAFI,QAAQ,GAAG,SAEf;wBACF,sBAAO,QAAQ,CAAC,IAAI,EAAC;;;wBAGrB,qCAAqC;wBACrC,IAAI,OAAK,CAAC,QAAQ,IAAI,OAAK,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;4BACnD,sBAAO,SAAS,EAAC;yBAClB;wBACD,MAAM,OAAK,CAAC;;;;;KAEf;IAED,gBAAgB;IACV,8BAAS,GAAf,UAAgB,GAAW;;;;;4BACR,qBAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,GAAG,EAAE;4BACzD,YAAY,EAAE,MAAM;yBACrB,CAAC,EAAA;;wBAFI,QAAQ,GAAG,SAEf;wBACF,sBAAO,QAAQ,CAAC,IAAI,EAAC;;;;KAEtB;IA1BD;QADC,IAAA,kBAAM,EAAC,MAAM,CAAC,KAAG,CAAA,CAAC,eAAe,CAAC,CAAC;6CACC;IAH1B,UAAU;QADtB,IAAA,sBAAU,GAAE;OACA,UAAU,CA8BtB;IAAD,iBAAC;CAAA,AA9BD,IA8BC;AA9BY,gCAAU"}
@@ -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
+ static readonly MERGE_CONTRIBUTION = "controller.devfile.io/merge-contribution";
13
+ private devContainerComponentFinder;
14
+ generate(devfileContent: string, editorContent: string, outputFile?: string): Promise<DevfileContext>;
15
+ generateContent(devfileContent: string, editorContent: string): Promise<DevfileContext>;
16
+ }