@eclipse-che/che-devworkspace-generator 0.0.1-4e80d1b → 0.0.1-58f79fb

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 CHANGED
@@ -1,28 +1,56 @@
1
1
  ## DevWorkspace Generator
2
- The library is used by Devfile registry component to generate the DevWorkspace components and DevWorkspace templates.
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/).
3
4
 
4
5
  ## How to use the library
5
- The library could be used as a standalone library.
6
+ The library can be used as a standalone library.
6
7
 
7
8
  ```
8
9
  USAGE
9
10
  $ node lib/entrypoint.js [OPTIONS]
10
11
 
11
12
  OPTIONS
12
- --devfile-path path to the devfile.yaml file
13
- --devfile-url URL to the git repository that contains devfile.yaml
14
- --plugin-registry-url URL to the plugin registry that contains an editor's definition
15
- --editor-entry editor's ID
16
- --editor-path: path to the editor's devfile.yaml file
17
- --output-file path to the file where the generated content will be stored
18
- --project. describes project entry
13
+ --devfile-url: URL to the git repository that contains devfile.yaml
14
+ or
15
+ --devfile-path: path to the devfile.yaml file
19
16
 
20
- EXAMPLE
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
+ --injectDefaultComponent: inject a default dev container component if no component is defined in the devfile and it doesn't provide a parent, the value can be true or false, default is false
27
+
28
+ --defaultComponentImage: image to use for the default dev container component that will be injected if no componetn is defined in the devfile and it doesn't provide a parent devfile, default is quay.io/devfile/universal-developer-image:ubi8-latest
29
+
30
+ EXAMPLES
31
+
32
+ # online example, using editor definition from https://che-plugin-registry-main.surge.sh/
33
+
34
+ $ node lib/entrypoint.js \
35
+ --devfile-url:https://github.com/che-samples/java-spring-petclinic/tree/main \
36
+ --plugin-registry-url:https://che-plugin-registry-main.surge.sh/v3/ \
37
+ --editor-entry:che-incubator/che-code/latest \
38
+ --output-file:/tmp/devworkspace-che-code-latest.yaml \
39
+ --injectDefaultComponent:true \
40
+ --defaultComponentImage:registry.access.redhat.com/ubi8/openjdk-11:latest
41
+
42
+ # offline example with devfile.yaml files and zipped project available locally
43
+
44
+ $ node lib/entrypoint.js \
45
+ --devfile-path:/remote-source/python-hello-world/app/devfile.yaml \
46
+ --editor-path:/build/plugins/che-incubator/che-code/latest/devfile.yaml \
47
+ --output-file:./devfiles/python__python-hello-world/devworkspace-che-code-latest.yaml \
48
+ --project.python-hello-world='{{_INTERNAL_URL_}}/resources/v2/python-hello-world.zip'
21
49
 
22
- $ node lib/entrypoint.js --devfile-url:https://github.com/che-samples/java-spring-petclinic/tree/main --editor-entry:che-incubator/che-code/insiders --plugin-registry-url:https://che-plugin-registry-main.surge.sh/v3/ --output-file:/tmp/all-in-one.yaml`
23
50
  ```
24
51
 
25
- The file `/tmp/all-in-one.yaml` contains a DevWorkspace based on the repository devfile and a Che-Code DevWorkspaceTemplate.
26
- If DevWorkspace engine is available on the cluster, the following command will create a DevWorkspace:
52
+ The output file `devworkspace-che-code-latest.yaml` contains a DevWorkspace based on the repository devfile and a Che-Code DevWorkspaceTemplate.
53
+
54
+ If the DevWorkspace engine is installed on the cluster, the following command will create a DevWorkspace:
27
55
 
28
- `$ kubectl apply -f /tmp/all-in-one.yaml`
56
+ `$ kubectl apply -f /tmp/devworkspace-che-code-latest.yaml`
@@ -13,5 +13,6 @@ import { V1alpha2DevWorkspaceSpecTemplateComponents } from '@devfile/api';
13
13
  * Need to find dev container from main dev workspace
14
14
  */
15
15
  export declare class DevContainerComponentFinder {
16
- find(devfileContext: DevfileContext): Promise<V1alpha2DevWorkspaceSpecTemplateComponents | undefined>;
16
+ private devContainerComponentInserter;
17
+ find(devfileContext: DevfileContext, injectDefaultComponent?: string, defaultComponentImage?: string): Promise<V1alpha2DevWorkspaceSpecTemplateComponents | undefined>;
17
18
  }
@@ -53,23 +53,33 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
53
53
  exports.__esModule = true;
54
54
  exports.DevContainerComponentFinder = void 0;
55
55
  var inversify_1 = require("inversify");
56
+ var dev_container_component_inserter_1 = require("./dev-container-component-inserter");
56
57
  /**
57
58
  * Need to find dev container from main dev workspace
58
59
  */
59
60
  var DevContainerComponentFinder = /** @class */ (function () {
60
61
  function DevContainerComponentFinder() {
61
62
  }
62
- DevContainerComponentFinder.prototype.find = function (devfileContext) {
63
- var _a, _b, _c;
63
+ DevContainerComponentFinder.prototype.find = function (devfileContext, injectDefaultComponent, defaultComponentImage) {
64
+ var _a, _b, _c, _d;
64
65
  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(
66
+ var devComponents, devComponents_1;
67
+ return __generator(this, function (_e) {
68
+ // if a devfile contains a parent, we should not add a default dev container
69
+ if ((_a = devfileContext.devfile) === null || _a === void 0 ? void 0 : _a.parent) {
70
+ return [2 /*return*/, undefined];
71
+ }
72
+ devComponents = (_d = (_c = (_b = devfileContext.devWorkspace.spec) === null || _b === void 0 ? void 0 : _b.template) === null || _c === void 0 ? void 0 : _c.components) === null || _d === void 0 ? void 0 : _d.filter(function (component) { return component.container; }).filter(
68
73
  // we should ignore component that do not mount the sources
69
74
  function (component) { return component.container && component.container.mountSources !== false; });
70
- // only one, fine, else error
71
75
  if (!devComponents || devComponents.length === 0) {
72
- throw new Error('Not able to find any dev container component in DevWorkspace');
76
+ // do not inject a default component if injectDefaultComponent parameter is false
77
+ if (!injectDefaultComponent || injectDefaultComponent !== 'true') {
78
+ return [2 /*return*/, undefined];
79
+ }
80
+ this.devContainerComponentInserter.insert(devfileContext, defaultComponentImage);
81
+ devComponents_1 = devfileContext.devWorkspace.spec.template.components.filter(function (component) { return component.container; });
82
+ return [2 /*return*/, devComponents_1[0]];
73
83
  }
74
84
  else if (devComponents.length === 1) {
75
85
  return [2 /*return*/, devComponents[0]];
@@ -82,6 +92,9 @@ var DevContainerComponentFinder = /** @class */ (function () {
82
92
  });
83
93
  });
84
94
  };
95
+ __decorate([
96
+ (0, inversify_1.inject)(dev_container_component_inserter_1.DevContainerComponentInserter)
97
+ ], DevContainerComponentFinder.prototype, "devContainerComponentInserter");
85
98
  DevContainerComponentFinder = __decorate([
86
99
  (0, inversify_1.injectable)()
87
100
  ], DevContainerComponentFinder);
@@ -1 +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;IAwBA,CAAC;IAvBO,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,6BAA6B;gBAC7B,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE;oBAChD,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;IAvBU,2BAA2B;QADvC,IAAA,sBAAU,GAAE;OACA,2BAA2B,CAwBvC;IAAD,kCAAC;CAAA,AAxBD,IAwBC;AAxBY,kEAA2B"}
1
+ {"version":3,"file":"dev-container-component-finder.js","sourceRoot":"","sources":["../../src/devfile/dev-container-component-finder.ts"],"names":[],"mappings":";AAAA;;;;;;;;yEAQyE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIzE,uCAA+C;AAC/C,uFAAmF;AAEnF;;GAEG;AAEH;IAAA;IA0CA,CAAC;IAtCO,0CAAI,GAAV,UACE,cAA8B,EAC9B,sBAA+B,EAC/B,qBAA8B;;;;;gBAE9B,4EAA4E;gBAC5E,IAAI,MAAA,cAAc,CAAC,OAAO,0CAAE,MAAM,EAAE;oBAClC,sBAAO,SAAS,EAAC;iBAClB;gBAEK,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,iFAAiF;oBACjF,IAAI,CAAC,sBAAsB,IAAI,sBAAsB,KAAK,MAAM,EAAE;wBAChE,sBAAO,SAAS,EAAC;qBAClB;oBACD,IAAI,CAAC,6BAA6B,CAAC,MAAM,CAAC,cAAc,EAAE,qBAAqB,CAAC,CAAC;oBAE7E,kBAAgB,cAAc,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,UAAA,SAAS,IAAI,OAAA,SAAS,CAAC,SAAS,EAAnB,CAAmB,CAAC,CAAC;oBAElH,sBAAO,eAAa,CAAC,CAAC,CAAC,EAAC;iBACzB;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;IAvCD;QADC,IAAA,kBAAM,EAAC,gEAA6B,CAAC;8EAC+B;IAF1D,2BAA2B;QADvC,IAAA,sBAAU,GAAE;OACA,2BAA2B,CA0CvC;IAAD,kCAAC;CAAA,AA1CD,IA0CC;AA1CY,kEAA2B"}
@@ -0,0 +1,18 @@
1
+ /**********************************************************************
2
+ * Copyright (c) 2023 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
+ /**
12
+ * Adds a new component on empty devfile with specific name and image
13
+ */
14
+ export declare class DevContainerComponentInserter {
15
+ readonly DEFAULT_DEV_CONTAINER_IMAGE = "quay.io/devfile/universal-developer-image:ubi8-latest";
16
+ readonly DEFAULT_DEV_CONTAINER_NAME = "dev";
17
+ insert(devfileContext: DevfileContext, defaultComponentImage?: string): Promise<void>;
18
+ }
@@ -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"}
@@ -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;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"}
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"}
package/lib/generate.d.ts CHANGED
@@ -11,6 +11,6 @@ import { DevfileContext } from './api/devfile-context';
11
11
  export declare class Generate {
12
12
  static readonly MERGE_CONTRIBUTION = "controller.devfile.io/merge-contribution";
13
13
  private devContainerComponentFinder;
14
- generate(devfileContent: string, editorContent: string, outputFile?: string): Promise<DevfileContext>;
15
- generateContent(devfileContent: string, editorContent: string): Promise<DevfileContext>;
14
+ generate(devfileContent: string, editorContent: string, outputFile?: string, injectDefaultComponent?: string, defaultComponentImage?: string): Promise<DevfileContext>;
15
+ generateContent(devfileContent: string, editorContent: string, injectDefaultComponent?: string, defaultComponentImage?: string): Promise<DevfileContext>;
16
16
  }
package/lib/generate.js CHANGED
@@ -79,12 +79,12 @@ var Generate = /** @class */ (function () {
79
79
  function Generate() {
80
80
  }
81
81
  Generate_1 = Generate;
82
- Generate.prototype.generate = function (devfileContent, editorContent, outputFile) {
82
+ Generate.prototype.generate = function (devfileContent, editorContent, outputFile, injectDefaultComponent, defaultComponentImage) {
83
83
  return __awaiter(this, void 0, void 0, function () {
84
84
  var context, allContentArray, generatedContent;
85
85
  return __generator(this, function (_a) {
86
86
  switch (_a.label) {
87
- case 0: return [4 /*yield*/, this.generateContent(devfileContent, editorContent)];
87
+ case 0: return [4 /*yield*/, this.generateContent(devfileContent, editorContent, injectDefaultComponent, defaultComponentImage)];
88
88
  case 1:
89
89
  context = _a.sent();
90
90
  if (!outputFile) return [3 /*break*/, 3];
@@ -102,7 +102,7 @@ var Generate = /** @class */ (function () {
102
102
  });
103
103
  });
104
104
  };
105
- Generate.prototype.generateContent = function (devfileContent, editorContent) {
105
+ Generate.prototype.generateContent = function (devfileContent, editorContent, injectDefaultComponent, defaultComponentImage) {
106
106
  return __awaiter(this, void 0, void 0, function () {
107
107
  var devfile, suffix, editorDevfile, metadata, editorDevWorkspaceTemplate, devfileMetadata, devfileCopy, editorSpecContribution, devWorkspace, devWorkspaceTemplates, context, devContainer, devContainerAttributes;
108
108
  return __generator(this, function (_a) {
@@ -149,9 +149,12 @@ var Generate = /** @class */ (function () {
149
149
  devWorkspaceTemplates: devWorkspaceTemplates,
150
150
  suffix: suffix
151
151
  };
152
- return [4 /*yield*/, this.devContainerComponentFinder.find(context)];
152
+ return [4 /*yield*/, this.devContainerComponentFinder.find(context, injectDefaultComponent, defaultComponentImage)];
153
153
  case 1:
154
154
  devContainer = _a.sent();
155
+ if (!devContainer) {
156
+ return [2 /*return*/, context];
157
+ }
155
158
  devContainerAttributes = devContainer.attributes;
156
159
  if (!devContainerAttributes) {
157
160
  devContainerAttributes = {};
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":";AAAA;;;;;;;;yEAQyE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASzE,uCAA+C;AAC/C,8CAAkC;AAClC,2CAA+B;AAE/B,2FAAuF;AAGvF;IAAA;IA8FA,C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,OAAO,EAAE,IAAI;gCACb,QAAQ,EAAE,WAAW;gCACrB,aAAa,EAAE,CAAC,sBAAsB,CAAC;6BACxC;yBACF,CAAC;wBAGI,qBAAqB,GAAG,CAAC,0BAA0B,CAAC,CAAC;wBAErD,OAAO,GAAG;4BACd,OAAO,SAAA;4BACP,YAAY,cAAA;4BACZ,qBAAqB,uBAAA;4BACrB,MAAM,QAAA;yBACP,CAAC;wBAIA,qBAAM,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,CAAC,EAAA;;wBADjG,YAAY,GACd,SAAmG;wBAErG,IAAI,CAAC,YAAY,EAAE;4BACjB,sBAAO,OAAO,EAAC;yBAChB;wBAGG,sBAAsB,GAAG,YAAY,CAAC,UAAU,CAAC;wBACrD,IAAI,CAAC,sBAAsB,EAAE;4BAC3B,sBAAsB,GAAG,EAAE,CAAC;4BAC5B,sBAAsB,CAAC,UAAQ,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAAC;4BAC3D,YAAY,CAAC,UAAU,GAAG,sBAAsB,CAAC;yBAClD;6BAAM;4BACL,sBAAsB,CAAC,UAAQ,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAAC;yBAC5D;wBAED,sBAAO,OAAO,EAAC;;;;KAChB;;IAjHe,2BAAkB,GAAG,0CAA2C,CAAA;IAGhF;QADC,IAAA,kBAAM,EAAC,4DAA2B,CAAC;yDAC6B;IAJtD,QAAQ;QADpB,IAAA,sBAAU,GAAE;OACA,QAAQ,CAmHpB;IAAD,eAAC;CAAA,AAnHD,IAmHC;AAnHY,4BAAQ"}
@@ -30,11 +30,13 @@ var GithubResolver = /** @class */ (function () {
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');
35
37
  var branchName = this.getGroup(match, 'branchName', 'HEAD');
36
38
  var subFolder = this.getGroup(match, 'subFolder');
37
- return new github_url_1.GithubUrl(repoUser, repoName, branchName, subFolder);
39
+ return new github_url_1.GithubUrl(scheme, hostName, repoUser, repoName, branchName, subFolder);
38
40
  };
39
41
  GithubResolver.prototype.getGroup = function (match, groupName, defaultValue) {
40
42
  if (match.groups && match.groups[groupName]) {
@@ -44,7 +46,7 @@ var GithubResolver = /** @class */ (function () {
44
46
  };
45
47
  var GithubResolver_1;
46
48
  // eslint-disable-next-line max-len
47
- GithubResolver.GITHUB_URL_PATTERN = /^(?:http)(?:s)?(?:\:\/\/)github\.com\/(?<repoUser>[^\/]+)\/(?<repoName>[^\/]+)((\/)|(?:\/(blob|tree)\/(?<branchName>[^\/]+)(?:\/(?<subFolder>.*))?))?$/;
49
+ GithubResolver.GITHUB_URL_PATTERN = /^(?<scheme>https?):\/\/(?<host>github(\..+)?\.[^\/]+)\/(?<repoUser>[^\/]+)\/(?<repoName>[^\/]+)((\/)|\/(blob|tree)\/(?<branchName>[^\/]+)(?:\/(?<subFolder>.*))?)?$/;
48
50
  GithubResolver = GithubResolver_1 = __decorate([
49
51
  (0, inversify_1.injectable)()
50
52
  ], 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;AAEvC;;GAEG;AAEH;IAAA;IAuBA,CAAC;uBAvBY,cAAc;IAKzB,gCAAO,GAAP,UAAQ,IAAY;QAClB,IAAM,KAAK,GAAG,gBAAc,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3D,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CAAC,yBAAuB,IAAM,CAAC,CAAC;SAChD;QACD,IAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,KAA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AC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC9C,IAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC9C,IAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAClD,IAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;QAClD,IAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;QAC9D,IAAM,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;IAED,iCAAQ,GAAR,UAAS,KAAsB,EAAE,SAAiB,EAAE,YAAqB;QACvE,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE;YAC3C,OAAO,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;SAChC;QACD,OAAO,YAAY,IAAI,EAAE,CAAC;IAC5B,CAAC;;IAvBD,mCAAmC;IACnB,iCAAkB,GAChC,qKAAsK,CAAA;IAH7J,cAAc;QAD1B,IAAA,sBAAU,GAAE;OACA,cAAc,CAyB1B;IAAD,qBAAC;CAAA,AAzBD,IAyBC;AAzBY,wCAAc"}
@@ -11,12 +11,13 @@
11
11
  * Provides helper methods on top of github URL to get for example raw content of get relative links
12
12
  */
13
13
  export declare class GithubUrl {
14
+ private readonly scheme;
15
+ private readonly hostName;
14
16
  private readonly repoUser;
15
17
  private readonly repoName;
16
18
  private readonly branchName;
17
19
  private readonly subFolder;
18
- static readonly RAW_LINK = "https://raw.githubusercontent.com";
19
- constructor(repoUser: string, repoName: string, branchName: string, subFolder: string);
20
+ constructor(scheme: string, hostName: string, repoUser: string, repoName: string, branchName: string, subFolder: string);
20
21
  /**
21
22
  * Provides the raw link to the given path based on the current repository information
22
23
  */
@@ -14,7 +14,9 @@ exports.GithubUrl = void 0;
14
14
  * Provides helper methods on top of github URL to get for example raw content of get relative links
15
15
  */
16
16
  var GithubUrl = /** @class */ (function () {
17
- function GithubUrl(repoUser, repoName, branchName, subFolder) {
17
+ function GithubUrl(scheme, hostName, repoUser, repoName, branchName, subFolder) {
18
+ this.scheme = scheme;
19
+ this.hostName = hostName;
18
20
  this.repoUser = repoUser;
19
21
  this.repoName = repoName;
20
22
  this.branchName = branchName;
@@ -24,13 +26,14 @@ var GithubUrl = /** @class */ (function () {
24
26
  * Provides the raw link to the given path based on the current repository information
25
27
  */
26
28
  GithubUrl.prototype.getContentUrl = function (path) {
27
- return GithubUrl.RAW_LINK + "/" + this.repoUser + "/" + this.repoName + "/" + this.branchName + "/" + path;
29
+ var hostName = this.hostName === 'github.com' ? 'githubusercontent.com' : this.hostName;
30
+ return this.scheme + "://raw." + hostName + "/" + this.repoUser + "/" + this.repoName + "/" + this.branchName + "/" + path;
28
31
  };
29
32
  GithubUrl.prototype.getUrl = function () {
30
- return "https://github.com/" + this.repoUser + "/" + this.repoName + "/tree/" + this.branchName + "/" + this.subFolder;
33
+ return this.scheme + "://" + this.hostName + "/" + this.repoUser + "/" + this.repoName + "/tree/" + this.branchName + "/" + this.subFolder;
31
34
  };
32
35
  GithubUrl.prototype.getCloneUrl = function () {
33
- return "https://github.com/" + this.repoUser + "/" + this.repoName + ".git";
36
+ return this.scheme + "://" + this.hostName + "/" + this.repoUser + "/" + this.repoName + ".git";
34
37
  };
35
38
  GithubUrl.prototype.getRepoName = function () {
36
39
  return this.repoName;
@@ -38,8 +41,6 @@ var GithubUrl = /** @class */ (function () {
38
41
  GithubUrl.prototype.getBranchName = function () {
39
42
  return this.branchName;
40
43
  };
41
- // raw link
42
- GithubUrl.RAW_LINK = 'https://raw.githubusercontent.com';
43
44
  return GithubUrl;
44
45
  }());
45
46
  exports.GithubUrl = GithubUrl;
@@ -1 +1 @@
1
- {"version":3,"file":"github-url.js","sourceRoot":"","sources":["../../src/github/github-url.ts"],"names":[],"mappings":";AAAA;;;;;;;;yEAQyE;;;AAEzE;;GAEG;AACH;IAIE,mBACmB,QAAgB,EAChB,QAAgB,EAChB,UAAkB,EAClB,SAAiB;QAHjB,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,OAAU,SAAS,CAAC,QAAQ,SAAI,IAAI,CAAC,QAAQ,SAAI,IAAI,CAAC,QAAQ,SAAI,IAAI,CAAC,UAAU,SAAI,IAAM,CAAC;IAC9F,CAAC;IAED,0BAAM,GAAN;QACE,OAAO,wBAAsB,IAAI,CAAC,QAAQ,SAAI,IAAI,CAAC,QAAQ,cAAS,IAAI,CAAC,UAAU,SAAI,IAAI,CAAC,SAAW,CAAC;IAC1G,CAAC;IAED,+BAAW,GAAX;QACE,OAAO,wBAAsB,IAAI,CAAC,QAAQ,SAAI,IAAI,CAAC,QAAQ,SAAM,CAAC;IACpE,CAAC;IAED,+BAAW,GAAX;QACE,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,iCAAa,GAAb;QACE,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IA/BD,WAAW;IACK,kBAAQ,GAAG,mCAAmC,CAAC;IA+BjE,gBAAC;CAAA,AAjCD,IAiCC;AAjCY,8BAAS"}
1
+ {"version":3,"file":"github-url.js","sourceRoot":"","sources":["../../src/github/github-url.ts"],"names":[],"mappings":";AAAA;;;;;;;;yEAQyE;;;AAEzE;;GAEG;AACH;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"}
package/lib/main.d.ts CHANGED
@@ -27,6 +27,8 @@ export declare class Main {
27
27
  name: string;
28
28
  location: string;
29
29
  }[];
30
+ injectDefaultComponent?: string;
31
+ defaultComponentImage?: string;
30
32
  }, axiosInstance: axios.AxiosInstance): Promise<DevfileContext>;
31
33
  replaceIfExistingProjects(devfileContent: string, projects: {
32
34
  name: string;
package/lib/main.js CHANGED
@@ -160,7 +160,7 @@ var Main = /** @class */ (function () {
160
160
  _a.label = 11;
161
161
  case 11:
162
162
  generate = container.get(generate_1.Generate);
163
- return [2 /*return*/, generate.generate(devfileContent, editorContent, params.outputFile)];
163
+ return [2 /*return*/, generate.generate(devfileContent, editorContent, params.outputFile, params.injectDefaultComponent, params.defaultComponentImage)];
164
164
  }
165
165
  });
166
166
  });
@@ -193,7 +193,7 @@ var Main = /** @class */ (function () {
193
193
  };
194
194
  Main.prototype.start = function () {
195
195
  return __awaiter(this, void 0, void 0, function () {
196
- var devfilePath, devfileUrl, outputFile, editorPath, pluginRegistryUrl, editorEntry, projects, args, error_1;
196
+ var devfilePath, devfileUrl, outputFile, editorPath, pluginRegistryUrl, editorEntry, injectDefaultComponent, defaultComponentImage, projects, args, error_1;
197
197
  return __generator(this, function (_a) {
198
198
  switch (_a.label) {
199
199
  case 0:
@@ -224,6 +224,12 @@ var Main = /** @class */ (function () {
224
224
  location = location.replace('{{_INTERNAL_URL_}}', '{{ INTERNAL_URL }}');
225
225
  projects.push({ name: name, location: location });
226
226
  }
227
+ if (arg.startsWith('--injectDefaultComponent:')) {
228
+ injectDefaultComponent = arg.substring('--injectDefaultComponent:'.length);
229
+ }
230
+ if (arg.startsWith('--defaultComponentImage:')) {
231
+ defaultComponentImage = arg.substring('--defaultComponentImage:'.length);
232
+ }
227
233
  });
228
234
  _a.label = 1;
229
235
  case 1:
@@ -244,7 +250,9 @@ var Main = /** @class */ (function () {
244
250
  outputFile: outputFile,
245
251
  pluginRegistryUrl: pluginRegistryUrl,
246
252
  editorEntry: editorEntry,
247
- projects: projects
253
+ projects: projects,
254
+ injectDefaultComponent: injectDefaultComponent,
255
+ defaultComponentImage: defaultComponentImage
248
256
  }, axios["default"])];
249
257
  case 2:
250
258
  _a.sent();
package/lib/main.js.map CHANGED
@@ -1 +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yBACrD;wBACD,qBAAM,IAAI,CAAC,sBAAsB,CAC/B;gCACE,WAAW,aAAA;gCACX,UAAU,YAAA;gCACV,UAAU,YAAA;gCACV,UAAU,YAAA;gCACV,iBAAiB,mBAAA;gCACjB,WAAW,aAAA;gCACX,QAAQ,UAAA;gCACR,sBAAsB,wBAAA;gCACtB,qBAAqB,uBAAA;6BACtB,EACD,KAAK,CAAC,SAAO,CAAA,CACd,EAAA;;wBAbD,SAaC,CAAC;wBACF,sBAAO,IAAI,EAAC;;;wBAEZ,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAK,CAAC,KAAK,CAAC,CAAC;wBACtC,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,OAAK,CAAC,CAAC;wBACxC,sBAAO,KAAK,EAAC;;;;;KAEhB;IACH,WAAC;AAAD,CAAC,AAhND,IAgNC;AAhNY,oBAAI"}
@@ -80,7 +80,7 @@ var url_fetcher_1 = require("../fetch/url-fetcher");
80
80
  var PluginRegistryResolver = /** @class */ (function () {
81
81
  function PluginRegistryResolver() {
82
82
  }
83
- // FQN id (like eclipse/che-theia/next)
83
+ // FQN id (like che-incubator/che-code/next)
84
84
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
85
  PluginRegistryResolver.prototype.loadDevfilePlugin = function (devfileId) {
86
86
  return __awaiter(this, void 0, void 0, function () {
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-registry-resolver.js","sourceRoot":"","sources":["../../src/plugin-registry/plugin-registry-resolver.ts"],"names":[],"mappings":";AAAA;;;;;;;;yEAQyE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzE,8CAAkC;AAElC,uCAAsD;AAEtD,oDAAkD;AAElD;;GAEG;AAEH;IAAA;IAeA,CAAC;IAPC,uCAAuC;IACvC,8DAA8D;IACxD,kDAAiB,GAAvB,UAAwB,SAAiB;;;;;;wBACjC,UAAU,GAAM,IAAI,CAAC,iBAAiB,iBAAY,SAAS,kBAAe,CAAC;wBAC1D,qBAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,EAAA;;wBAA5D,cAAc,GAAG,SAA2C;wBAClE,sBAAO,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,EAAC;;;;KACpC;IAXD;QAFC,IAAA,kBAAM,EAAC,QAAQ,CAAC;QAChB,IAAA,iBAAK,EAAC,qBAAqB,CAAC;6DACK;IAGlC;QADC,IAAA,kBAAM,EAAC,wBAAU,CAAC;sDACY;IANpB,sBAAsB;QADlC,IAAA,sBAAU,GAAE;OACA,sBAAsB,CAelC;IAAD,6BAAC;CAAA,AAfD,IAeC;AAfY,wDAAsB"}
1
+ {"version":3,"file":"plugin-registry-resolver.js","sourceRoot":"","sources":["../../src/plugin-registry/plugin-registry-resolver.ts"],"names":[],"mappings":";AAAA;;;;;;;;yEAQyE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzE,8CAAkC;AAElC,uCAAsD;AAEtD,oDAAkD;AAElD;;GAEG;AAEH;IAAA;IAeA,CAAC;IAPC,4CAA4C;IAC5C,8DAA8D;IACxD,kDAAiB,GAAvB,UAAwB,SAAiB;;;;;;wBACjC,UAAU,GAAM,IAAI,CAAC,iBAAiB,iBAAY,SAAS,kBAAe,CAAC;wBAC1D,qBAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,EAAA;;wBAA5D,cAAc,GAAG,SAA2C;wBAClE,sBAAO,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,EAAC;;;;KACpC;IAXD;QAFC,IAAA,kBAAM,EAAC,QAAQ,CAAC;QAChB,IAAA,iBAAK,EAAC,qBAAqB,CAAC;6DACK;IAGlC;QADC,IAAA,kBAAM,EAAC,wBAAU,CAAC;sDACY;IANpB,sBAAsB;QADlC,IAAA,sBAAU,GAAE;OACA,sBAAsB,CAelC;IAAD,6BAAC;CAAA,AAfD,IAeC;AAfY,wDAAsB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eclipse-che/che-devworkspace-generator",
3
- "version": "0.0.1-4e80d1b",
3
+ "version": "0.0.1-58f79fb",
4
4
  "private": false,
5
5
  "description": "Generates DevWorkspaces by transforming existing devfiles",
6
6
  "main": "lib/entrypoint.js",
@@ -10,14 +10,26 @@
10
10
 
11
11
  import { DevfileContext } from '../api/devfile-context';
12
12
  import { V1alpha2DevWorkspaceSpecTemplateComponents } from '@devfile/api';
13
- import { injectable } from 'inversify';
13
+ import { inject, injectable } from 'inversify';
14
+ import { DevContainerComponentInserter } from './dev-container-component-inserter';
14
15
 
15
16
  /**
16
17
  * Need to find dev container from main dev workspace
17
18
  */
18
19
  @injectable()
19
20
  export class DevContainerComponentFinder {
20
- async find(devfileContext: DevfileContext): Promise<V1alpha2DevWorkspaceSpecTemplateComponents | undefined> {
21
+ @inject(DevContainerComponentInserter)
22
+ private devContainerComponentInserter: DevContainerComponentInserter;
23
+
24
+ async find(
25
+ devfileContext: DevfileContext,
26
+ injectDefaultComponent?: string,
27
+ defaultComponentImage?: string
28
+ ): Promise<V1alpha2DevWorkspaceSpecTemplateComponents | undefined> {
29
+ // if a devfile contains a parent, we should not add a default dev container
30
+ if (devfileContext.devfile?.parent) {
31
+ return undefined;
32
+ }
21
33
  // search in main devWorkspace
22
34
  const devComponents = devfileContext.devWorkspace.spec?.template?.components
23
35
  ?.filter(component => component.container)
@@ -26,9 +38,16 @@ export class DevContainerComponentFinder {
26
38
  component => component.container && component.container.mountSources !== false
27
39
  );
28
40
 
29
- // only one, fine, else error
30
41
  if (!devComponents || devComponents.length === 0) {
31
- throw new Error('Not able to find any dev container component in DevWorkspace');
42
+ // do not inject a default component if injectDefaultComponent parameter is false
43
+ if (!injectDefaultComponent || injectDefaultComponent !== 'true') {
44
+ return undefined;
45
+ }
46
+ this.devContainerComponentInserter.insert(devfileContext, defaultComponentImage);
47
+
48
+ let devComponents = devfileContext.devWorkspace.spec.template.components.filter(component => component.container);
49
+
50
+ return devComponents[0];
32
51
  } else if (devComponents.length === 1) {
33
52
  return devComponents[0];
34
53
  } else {
@@ -0,0 +1,49 @@
1
+ /**********************************************************************
2
+ * Copyright (c) 2023 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
+
11
+ import { DevfileContext } from '../api/devfile-context';
12
+ import { V1alpha2DevWorkspaceSpecTemplateComponents } from '@devfile/api';
13
+ import { injectable } from 'inversify';
14
+
15
+ /**
16
+ * Adds a new component on empty devfile with specific name and image
17
+ */
18
+ @injectable()
19
+ export class DevContainerComponentInserter {
20
+ readonly DEFAULT_DEV_CONTAINER_IMAGE = 'quay.io/devfile/universal-developer-image:ubi8-latest';
21
+ readonly DEFAULT_DEV_CONTAINER_NAME = 'dev';
22
+
23
+ async insert(devfileContext: DevfileContext, defaultComponentImage?: string): Promise<void> {
24
+ if (!devfileContext.devWorkspace.spec) {
25
+ devfileContext.devWorkspace.spec = {
26
+ started: true,
27
+ };
28
+ }
29
+ if (!devfileContext.devWorkspace.spec.template) {
30
+ devfileContext.devWorkspace.spec.template = {};
31
+ }
32
+ if (!devfileContext.devWorkspace.spec.template.components) {
33
+ devfileContext.devWorkspace.spec.template.components = [];
34
+ }
35
+
36
+ const devContainerImage = defaultComponentImage ? defaultComponentImage : this.DEFAULT_DEV_CONTAINER_IMAGE;
37
+ console.log(
38
+ `No container component has been found. A default container component with image ${devContainerImage} will be added.`
39
+ );
40
+ const devContainerComponent: V1alpha2DevWorkspaceSpecTemplateComponents = {
41
+ name: this.DEFAULT_DEV_CONTAINER_NAME,
42
+ container: {
43
+ image: devContainerImage,
44
+ },
45
+ };
46
+
47
+ devfileContext.devWorkspace.spec.template.components.push(devContainerComponent);
48
+ }
49
+ }
@@ -10,9 +10,11 @@
10
10
  import { ContainerModule, interfaces } from 'inversify';
11
11
 
12
12
  import { DevContainerComponentFinder } from './dev-container-component-finder';
13
+ import { DevContainerComponentInserter } from './dev-container-component-inserter';
13
14
 
14
15
  const devfileModule = new ContainerModule((bind: interfaces.Bind) => {
15
16
  bind(DevContainerComponentFinder).toSelf().inSingletonScope();
17
+ bind(DevContainerComponentInserter).toSelf().inSingletonScope();
16
18
  });
17
19
 
18
20
  export { devfileModule };
package/src/generate.ts CHANGED
@@ -28,8 +28,19 @@ export class Generate {
28
28
  @inject(DevContainerComponentFinder)
29
29
  private devContainerComponentFinder: DevContainerComponentFinder;
30
30
 
31
- async generate(devfileContent: string, editorContent: string, outputFile?: string): Promise<DevfileContext> {
32
- const context = await this.generateContent(devfileContent, editorContent);
31
+ async generate(
32
+ devfileContent: string,
33
+ editorContent: string,
34
+ outputFile?: string,
35
+ injectDefaultComponent?: string,
36
+ defaultComponentImage?: string
37
+ ): Promise<DevfileContext> {
38
+ const context = await this.generateContent(
39
+ devfileContent,
40
+ editorContent,
41
+ injectDefaultComponent,
42
+ defaultComponentImage
43
+ );
33
44
 
34
45
  // write the result
35
46
  if (outputFile) {
@@ -46,7 +57,12 @@ export class Generate {
46
57
  return context;
47
58
  }
48
59
 
49
- async generateContent(devfileContent: string, editorContent: string): Promise<DevfileContext> {
60
+ async generateContent(
61
+ devfileContent: string,
62
+ editorContent: string,
63
+ injectDefaultComponent?: string,
64
+ defaultComponentImage?: string
65
+ ): Promise<DevfileContext> {
50
66
  const devfile = jsYaml.load(devfileContent);
51
67
 
52
68
  // const originalDevfile = Object.assign({}, devfile);
@@ -102,7 +118,12 @@ export class Generate {
102
118
  };
103
119
 
104
120
  // grab container where to inject controller.devfile.io/merge-contribution attribute
105
- let devContainer: V1alpha2DevWorkspaceSpecTemplateComponents = await this.devContainerComponentFinder.find(context);
121
+ let devContainer: V1alpha2DevWorkspaceSpecTemplateComponents | undefined =
122
+ await this.devContainerComponentFinder.find(context, injectDefaultComponent, defaultComponentImage);
123
+
124
+ if (!devContainer) {
125
+ return context;
126
+ }
106
127
 
107
128
  // add attributes
108
129
  let devContainerAttributes = devContainer.attributes;
@@ -18,18 +18,20 @@ import { injectable } from 'inversify';
18
18
  export class GithubResolver {
19
19
  // eslint-disable-next-line max-len
20
20
  static readonly GITHUB_URL_PATTERN =
21
- /^(?:http)(?:s)?(?:\:\/\/)github\.com\/(?<repoUser>[^\/]+)\/(?<repoName>[^\/]+)((\/)|(?:\/(blob|tree)\/(?<branchName>[^\/]+)(?:\/(?<subFolder>.*))?))?$/;
21
+ /^(?<scheme>https?):\/\/(?<host>github(\..+)?\.[^\/]+)\/(?<repoUser>[^\/]+)\/(?<repoName>[^\/]+)((\/)|\/(blob|tree)\/(?<branchName>[^\/]+)(?:\/(?<subFolder>.*))?)?$/;
22
22
 
23
23
  resolve(link: string): GithubUrl {
24
24
  const match = GithubResolver.GITHUB_URL_PATTERN.exec(link);
25
25
  if (!match) {
26
26
  throw new Error(`Invalid github URL: ${link}`);
27
27
  }
28
+ const scheme = this.getGroup(match, 'scheme');
29
+ const hostName = this.getGroup(match, 'host');
28
30
  const repoUser = this.getGroup(match, 'repoUser');
29
31
  const repoName = this.getGroup(match, 'repoName');
30
32
  const branchName = this.getGroup(match, 'branchName', 'HEAD');
31
33
  const subFolder = this.getGroup(match, 'subFolder');
32
- return new GithubUrl(repoUser, repoName, branchName, subFolder);
34
+ return new GithubUrl(scheme, hostName, repoUser, repoName, branchName, subFolder);
33
35
  }
34
36
 
35
37
  getGroup(match: RegExpExecArray, groupName: string, defaultValue?: string) {
@@ -12,10 +12,9 @@
12
12
  * Provides helper methods on top of github URL to get for example raw content of get relative links
13
13
  */
14
14
  export class GithubUrl {
15
- // raw link
16
- static readonly RAW_LINK = 'https://raw.githubusercontent.com';
17
-
18
15
  constructor(
16
+ private readonly scheme: string,
17
+ private readonly hostName: string,
19
18
  private readonly repoUser: string,
20
19
  private readonly repoName: string,
21
20
  private readonly branchName: string,
@@ -26,15 +25,16 @@ export class GithubUrl {
26
25
  * Provides the raw link to the given path based on the current repository information
27
26
  */
28
27
  getContentUrl(path: string): string {
29
- return `${GithubUrl.RAW_LINK}/${this.repoUser}/${this.repoName}/${this.branchName}/${path}`;
28
+ const hostName = this.hostName === 'github.com' ? 'githubusercontent.com' : this.hostName;
29
+ return `${this.scheme}://raw.${hostName}/${this.repoUser}/${this.repoName}/${this.branchName}/${path}`;
30
30
  }
31
31
 
32
32
  getUrl(): string {
33
- return `https://github.com/${this.repoUser}/${this.repoName}/tree/${this.branchName}/${this.subFolder}`;
33
+ return `${this.scheme}://${this.hostName}/${this.repoUser}/${this.repoName}/tree/${this.branchName}/${this.subFolder}`;
34
34
  }
35
35
 
36
36
  getCloneUrl(): string {
37
- return `https://github.com/${this.repoUser}/${this.repoName}.git`;
37
+ return `${this.scheme}://${this.hostName}/${this.repoUser}/${this.repoName}.git`;
38
38
  }
39
39
 
40
40
  getRepoName(): string {
package/src/main.ts CHANGED
@@ -38,6 +38,8 @@ export class Main {
38
38
  editorEntry?: string;
39
39
  pluginRegistryUrl?: string;
40
40
  projects: { name: string; location: string }[];
41
+ injectDefaultComponent?: string;
42
+ defaultComponentImage?: string;
41
43
  },
42
44
  axiosInstance: axios.AxiosInstance
43
45
  ): Promise<DevfileContext> {
@@ -112,7 +114,13 @@ export class Main {
112
114
  }
113
115
 
114
116
  const generate = container.get(Generate);
115
- return generate.generate(devfileContent, editorContent, params.outputFile);
117
+ return generate.generate(
118
+ devfileContent,
119
+ editorContent,
120
+ params.outputFile,
121
+ params.injectDefaultComponent,
122
+ params.defaultComponentImage
123
+ );
116
124
  }
117
125
 
118
126
  // Update project entry based on the projects passed as parameter
@@ -149,6 +157,8 @@ export class Main {
149
157
  let editorPath: string | undefined;
150
158
  let pluginRegistryUrl: string | undefined;
151
159
  let editorEntry: string | undefined;
160
+ let injectDefaultComponent: string | undefined;
161
+ let defaultComponentImage: string | undefined;
152
162
  const projects: { name: string; location: string }[] = [];
153
163
 
154
164
  const args = process.argv.slice(2);
@@ -178,6 +188,12 @@ export class Main {
178
188
 
179
189
  projects.push({ name, location });
180
190
  }
191
+ if (arg.startsWith('--injectDefaultComponent:')) {
192
+ injectDefaultComponent = arg.substring('--injectDefaultComponent:'.length);
193
+ }
194
+ if (arg.startsWith('--defaultComponentImage:')) {
195
+ defaultComponentImage = arg.substring('--defaultComponentImage:'.length);
196
+ }
181
197
  });
182
198
 
183
199
  try {
@@ -199,6 +215,8 @@ export class Main {
199
215
  pluginRegistryUrl,
200
216
  editorEntry,
201
217
  projects,
218
+ injectDefaultComponent,
219
+ defaultComponentImage,
202
220
  },
203
221
  axios.default
204
222
  );
@@ -26,7 +26,7 @@ export class PluginRegistryResolver {
26
26
  @inject(UrlFetcher)
27
27
  private urlFetcher: UrlFetcher;
28
28
 
29
- // FQN id (like eclipse/che-theia/next)
29
+ // FQN id (like che-incubator/che-code/next)
30
30
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
31
  async loadDevfilePlugin(devfileId: string): Promise<any> {
32
32
  const devfileUrl = `${this.pluginRegistryUrl}/plugins/${devfileId}/devfile.yaml`;