@eclipse-che/che-devworkspace-generator 0.0.1-1671620831

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 (43) hide show
  1. package/lib/api/devfile-context.js +3 -0
  2. package/lib/api/devfile-context.js.map +1 -0
  3. package/lib/devfile/dev-container-component-finder.js +91 -0
  4. package/lib/devfile/dev-container-component-finder.js.map +1 -0
  5. package/lib/devfile/devfile-module.js +19 -0
  6. package/lib/devfile/devfile-module.js.map +1 -0
  7. package/lib/entrypoint.js +67 -0
  8. package/lib/entrypoint.js.map +1 -0
  9. package/lib/fetch/fetch-module.js +19 -0
  10. package/lib/fetch/fetch-module.js.map +1 -0
  11. package/lib/fetch/url-fetcher.js +114 -0
  12. package/lib/fetch/url-fetcher.js.map +1 -0
  13. package/lib/generate.js +177 -0
  14. package/lib/generate.js.map +1 -0
  15. package/lib/github/github-module.js +19 -0
  16. package/lib/github/github-module.js.map +1 -0
  17. package/lib/github/github-resolver.js +54 -0
  18. package/lib/github/github-resolver.js.map +1 -0
  19. package/lib/github/github-url.js +46 -0
  20. package/lib/github/github-url.js.map +1 -0
  21. package/lib/inversify/inversify-binding.js +78 -0
  22. package/lib/inversify/inversify-binding.js.map +1 -0
  23. package/lib/main.js +233 -0
  24. package/lib/main.js.map +1 -0
  25. package/lib/plugin-registry/plugin-registry-module.js +19 -0
  26. package/lib/plugin-registry/plugin-registry-module.js.map +1 -0
  27. package/lib/plugin-registry/plugin-registry-resolver.js +113 -0
  28. package/lib/plugin-registry/plugin-registry-resolver.js.map +1 -0
  29. package/package.json +91 -0
  30. package/src/api/devfile-context.ts +28 -0
  31. package/src/devfile/dev-container-component-finder.ts +43 -0
  32. package/src/devfile/devfile-module.ts +18 -0
  33. package/src/entrypoint.ts +22 -0
  34. package/src/fetch/fetch-module.ts +18 -0
  35. package/src/fetch/url-fetcher.ts +49 -0
  36. package/src/generate.ts +117 -0
  37. package/src/github/github-module.ts +18 -0
  38. package/src/github/github-resolver.ts +41 -0
  39. package/src/github/github-url.ts +47 -0
  40. package/src/inversify/inversify-binding.ts +46 -0
  41. package/src/main.ts +166 -0
  42. package/src/plugin-registry/plugin-registry-module.ts +18 -0
  43. package/src/plugin-registry/plugin-registry-resolver.ts +36 -0
@@ -0,0 +1,46 @@
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
+ exports.__esModule = true;
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
+ var GithubUrl = /** @class */ (function () {
17
+ function GithubUrl(repoUser, repoName, branchName, subFolder) {
18
+ this.repoUser = repoUser;
19
+ this.repoName = repoName;
20
+ this.branchName = branchName;
21
+ this.subFolder = subFolder;
22
+ }
23
+ /**
24
+ * Provides the raw link to the given path based on the current repository information
25
+ */
26
+ GithubUrl.prototype.getContentUrl = function (path) {
27
+ return GithubUrl.RAW_LINK + "/" + this.repoUser + "/" + this.repoName + "/" + this.branchName + "/" + path;
28
+ };
29
+ GithubUrl.prototype.getUrl = function () {
30
+ return "https://github.com/" + this.repoUser + "/" + this.repoName + "/tree/" + this.branchName + "/" + this.subFolder;
31
+ };
32
+ GithubUrl.prototype.getCloneUrl = function () {
33
+ return "https://github.com/" + this.repoUser + "/" + this.repoName + ".git";
34
+ };
35
+ GithubUrl.prototype.getRepoName = function () {
36
+ return this.repoName;
37
+ };
38
+ GithubUrl.prototype.getBranchName = function () {
39
+ return this.branchName;
40
+ };
41
+ // raw link
42
+ GithubUrl.RAW_LINK = 'https://raw.githubusercontent.com';
43
+ return GithubUrl;
44
+ }());
45
+ exports.GithubUrl = GithubUrl;
46
+ //# sourceMappingURL=github-url.js.map
@@ -0,0 +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"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ exports.__esModule = true;
39
+ exports.InversifyBinding = void 0;
40
+ /**********************************************************************
41
+ * Copyright (c) 2022 Red Hat, Inc.
42
+ *
43
+ * This program and the accompanying materials are made
44
+ * available under the terms of the Eclipse Public License 2.0
45
+ * which is available at https://www.eclipse.org/legal/epl-2.0/
46
+ *
47
+ * SPDX-License-Identifier: EPL-2.0
48
+ ***********************************************************************/
49
+ require("reflect-metadata");
50
+ var inversify_1 = require("inversify");
51
+ var devfile_module_1 = require("../devfile/devfile-module");
52
+ var fetch_module_1 = require("../fetch/fetch-module");
53
+ var github_module_1 = require("../github/github-module");
54
+ var plugin_registry_module_1 = require("../plugin-registry/plugin-registry-module");
55
+ /**
56
+ * Manage all bindings for inversify
57
+ */
58
+ var InversifyBinding = /** @class */ (function () {
59
+ function InversifyBinding() {
60
+ }
61
+ InversifyBinding.prototype.initBindings = function (options) {
62
+ return __awaiter(this, void 0, void 0, function () {
63
+ return __generator(this, function (_a) {
64
+ this.container = new inversify_1.Container();
65
+ this.container.load(devfile_module_1.devfileModule);
66
+ this.container.load(fetch_module_1.fetchModule);
67
+ this.container.load(github_module_1.githubModule);
68
+ this.container.load(plugin_registry_module_1.pluginRegistryModule);
69
+ this.container.bind(Symbol["for"]('AxiosInstance')).toConstantValue(options.axiosInstance);
70
+ this.container.bind('string').toConstantValue(options.pluginRegistryUrl).whenTargetNamed('PLUGIN_REGISTRY_URL');
71
+ return [2 /*return*/, this.container];
72
+ });
73
+ });
74
+ };
75
+ return InversifyBinding;
76
+ }());
77
+ exports.InversifyBinding = InversifyBinding;
78
+ //# sourceMappingURL=inversify-binding.js.map
@@ -0,0 +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;AAEjF;;GAEG;AACH;IAAA;IAgBA,CAAC;IAbc,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,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,AAhBD,IAgBC;AAhBY,4CAAgB"}
package/lib/main.js ADDED
@@ -0,0 +1,233 @@
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || function (mod) {
24
+ if (mod && mod.__esModule) return mod;
25
+ var result = {};
26
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
27
+ __setModuleDefault(result, mod);
28
+ return result;
29
+ };
30
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
31
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
32
+ return new (P || (P = Promise))(function (resolve, reject) {
33
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
34
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
35
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
36
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
37
+ });
38
+ };
39
+ var __generator = (this && this.__generator) || function (thisArg, body) {
40
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
41
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
42
+ function verb(n) { return function (v) { return step([n, v]); }; }
43
+ function step(op) {
44
+ if (f) throw new TypeError("Generator is already executing.");
45
+ while (_) try {
46
+ 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;
47
+ if (y = 0, t) op = [op[0] & 2, t.value];
48
+ switch (op[0]) {
49
+ case 0: case 1: t = op; break;
50
+ case 4: _.label++; return { value: op[1], done: false };
51
+ case 5: _.label++; y = op[1]; op = [0]; continue;
52
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
53
+ default:
54
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
55
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
56
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
57
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
58
+ if (t[2]) _.ops.pop();
59
+ _.trys.pop(); continue;
60
+ }
61
+ op = body.call(thisArg, _);
62
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
63
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
64
+ }
65
+ };
66
+ exports.__esModule = true;
67
+ exports.Main = void 0;
68
+ var axios = __importStar(require("axios"));
69
+ var fs = __importStar(require("fs-extra"));
70
+ var generate_1 = require("./generate");
71
+ var github_resolver_1 = require("./github/github-resolver");
72
+ var jsYaml = __importStar(require("js-yaml"));
73
+ var inversify_binding_1 = require("./inversify/inversify-binding");
74
+ var url_fetcher_1 = require("./fetch/url-fetcher");
75
+ var plugin_registry_resolver_1 = require("./plugin-registry/plugin-registry-resolver");
76
+ var Main = /** @class */ (function () {
77
+ function Main() {
78
+ }
79
+ Main.prototype.doStart = function () {
80
+ return __awaiter(this, void 0, void 0, function () {
81
+ var devfilePath, devfileUrl, outputFile, editorPath, pluginRegistryUrl, editorEntry, projects, args, axiosInstance, inversifyBinbding, container, devfileContent, editorContent, githubResolver, githubUrl, devfileParsed, editorDevfile, generate;
82
+ return __generator(this, function (_a) {
83
+ switch (_a.label) {
84
+ case 0:
85
+ projects = [];
86
+ args = process.argv.slice(2);
87
+ args.forEach(function (arg) {
88
+ if (arg.startsWith('--devfile-path:')) {
89
+ devfilePath = arg.substring('--devfile-path:'.length);
90
+ }
91
+ if (arg.startsWith('--devfile-url:')) {
92
+ devfileUrl = arg.substring('--devfile-url:'.length);
93
+ }
94
+ if (arg.startsWith('--plugin-registry-url:')) {
95
+ pluginRegistryUrl = arg.substring('--plugin-registry-url:'.length);
96
+ }
97
+ if (arg.startsWith('--editor-entry:')) {
98
+ editorEntry = arg.substring('--editor-entry:'.length);
99
+ }
100
+ if (arg.startsWith('--editor-path:')) {
101
+ editorPath = arg.substring('--editor-path:'.length);
102
+ }
103
+ if (arg.startsWith('--output-file:')) {
104
+ outputFile = arg.substring('--output-file:'.length);
105
+ }
106
+ if (arg.startsWith('--project.')) {
107
+ var name = arg.substring('--project.'.length, arg.indexOf('='));
108
+ var location = arg.substring(arg.indexOf('=') + 1);
109
+ location = location.replace('{{_INTERNAL_URL_}}', '{{ INTERNAL_URL }}');
110
+ projects.push({ name: name, location: location });
111
+ }
112
+ });
113
+ if (!editorPath && !editorEntry) {
114
+ throw new Error('missing --editor-path: or --editor-entry: parameter');
115
+ }
116
+ if (editorEntry && !pluginRegistryUrl) {
117
+ pluginRegistryUrl = 'https://eclipse-che.github.io/che-plugin-registry/main/v3';
118
+ console.log("No plug-in registry url. Setting to " + pluginRegistryUrl);
119
+ }
120
+ if (!devfilePath && !devfileUrl) {
121
+ throw new Error('missing --devfile-path: or --devfile-url: parameter');
122
+ }
123
+ if (!outputFile) {
124
+ throw new Error('missing --output-file: parameter');
125
+ }
126
+ axiosInstance = axios["default"];
127
+ inversifyBinbding = new inversify_binding_1.InversifyBinding();
128
+ return [4 /*yield*/, inversifyBinbding.initBindings({
129
+ pluginRegistryUrl: pluginRegistryUrl,
130
+ axiosInstance: axiosInstance
131
+ })];
132
+ case 1:
133
+ container = _a.sent();
134
+ container.bind(generate_1.Generate).toSelf().inSingletonScope();
135
+ if (!devfileUrl) return [3 /*break*/, 3];
136
+ githubResolver = container.get(github_resolver_1.GithubResolver);
137
+ githubUrl = githubResolver.resolve(devfileUrl);
138
+ return [4 /*yield*/, container.get(url_fetcher_1.UrlFetcher).fetchText(githubUrl.getContentUrl('devfile.yaml'))];
139
+ case 2:
140
+ // user devfile
141
+ devfileContent = _a.sent();
142
+ devfileParsed = jsYaml.load(devfileContent);
143
+ // is there projects in the devfile ?
144
+ if (devfileParsed && !devfileParsed.projects) {
145
+ // no, so add the current project being cloned
146
+ devfileParsed.projects = [
147
+ {
148
+ name: githubUrl.getRepoName(),
149
+ git: {
150
+ remotes: { origin: githubUrl.getCloneUrl() },
151
+ checkoutFrom: { revision: githubUrl.getBranchName() }
152
+ }
153
+ },
154
+ ];
155
+ }
156
+ // get back the content
157
+ devfileContent = jsYaml.dump(devfileParsed);
158
+ return [3 /*break*/, 5];
159
+ case 3: return [4 /*yield*/, fs.readFile(devfilePath)];
160
+ case 4:
161
+ devfileContent = _a.sent();
162
+ _a.label = 5;
163
+ case 5:
164
+ // enhance projects
165
+ devfileContent = this.replaceIfExistingProjects(devfileContent, projects);
166
+ if (!editorEntry) return [3 /*break*/, 7];
167
+ return [4 /*yield*/, container.get(plugin_registry_resolver_1.PluginRegistryResolver).loadDevfilePlugin(editorEntry)];
168
+ case 6:
169
+ editorDevfile = _a.sent();
170
+ editorContent = jsYaml.dump(editorDevfile);
171
+ return [3 /*break*/, 9];
172
+ case 7: return [4 /*yield*/, fs.readFile(editorPath)];
173
+ case 8:
174
+ editorContent = _a.sent();
175
+ _a.label = 9;
176
+ case 9:
177
+ generate = container.get(generate_1.Generate);
178
+ return [2 /*return*/, generate.generate(devfileContent, editorContent, outputFile)];
179
+ }
180
+ });
181
+ });
182
+ };
183
+ // Update project entry based on the projects passed as parameter
184
+ Main.prototype.replaceIfExistingProjects = function (devfileContent, projects) {
185
+ // do nothing if no override
186
+ if (projects.length === 0) {
187
+ return devfileContent;
188
+ }
189
+ var devfileParsed = jsYaml.load(devfileContent);
190
+ if (!devfileParsed || !devfileParsed.projects) {
191
+ return devfileContent;
192
+ }
193
+ devfileParsed.projects = devfileParsed.projects.map(function (project) {
194
+ var userProjectConfiguration = projects.find(function (p) { return p.name === project.name; });
195
+ if (userProjectConfiguration) {
196
+ if (userProjectConfiguration.location.endsWith('.zip')) {
197
+ // delete git section and use instead zip
198
+ delete project.git;
199
+ project.zip = { location: userProjectConfiguration.location };
200
+ }
201
+ else {
202
+ project.git.remotes.origin = userProjectConfiguration.location;
203
+ }
204
+ }
205
+ return project;
206
+ });
207
+ return jsYaml.dump(devfileParsed);
208
+ };
209
+ Main.prototype.start = function () {
210
+ return __awaiter(this, void 0, void 0, function () {
211
+ var error_1;
212
+ return __generator(this, function (_a) {
213
+ switch (_a.label) {
214
+ case 0:
215
+ _a.trys.push([0, 2, , 3]);
216
+ return [4 /*yield*/, this.doStart()];
217
+ case 1:
218
+ _a.sent();
219
+ return [2 /*return*/, true];
220
+ case 2:
221
+ error_1 = _a.sent();
222
+ console.error('stack=' + error_1.stack);
223
+ console.error('Unable to start', error_1);
224
+ return [2 /*return*/, false];
225
+ case 3: return [2 /*return*/];
226
+ }
227
+ });
228
+ });
229
+ };
230
+ return Main;
231
+ }());
232
+ exports.Main = Main;
233
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AAAA;;;;;;;;yEAQyE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzE,2CAA+B;AAC/B,2CAA+B;AAC/B,uCAAsC;AACtC,4DAA0D;AAC1D,8CAAkC;AAClC,mEAAiE;AACjE,mDAAiD;AACjD,uFAAoF;AAIpF;IAAA;IAgJA,CAAC;IA/IiB,sBAAO,GAAvB;;;;;;wBAOQ,QAAQ,GAAyC,EAAE,CAAC;wBAEpD,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;wBACnC,IAAI,CAAC,OAAO,CAAC,UAAA,GAAG;4BACd,IAAI,GAAG,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE;gCACrC,WAAW,GAAG,GAAG,CAAC,SAAS,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;6BACvD;4BACD,IAAI,GAAG,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE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aAAa,CAAC,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAA,OAAO;YACzD,IAAM,wBAAwB,GAAG,QAAQ,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,IAAI,EAAvB,CAAuB,CAAC,CAAC;YAC7E,IAAI,wBAAwB,EAAE;gBAC5B,IAAI,wBAAwB,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;oBACtD,yCAAyC;oBACzC,OAAO,OAAO,CAAC,GAAG,CAAC;oBACnB,OAAO,CAAC,GAAG,GAAG,EAAE,QAAQ,EAAE,wBAAwB,CAAC,QAAQ,EAAE,CAAC;iBAC/D;qBAAM;oBACL,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,wBAAwB,CAAC,QAAQ,CAAC;iBAChE;aACF;YACD,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACpC,CAAC;IAEK,oBAAK,GAAX;;;;;;;wBAEI,qBAAM,IAAI,CAAC,OAAO,EAAE,EAAA;;wBAApB,SAAoB,CAAC;wBACrB,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,AAhJD,IAgJC;AAhJY,oBAAI"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ exports.__esModule = true;
3
+ exports.pluginRegistryModule = 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 plugin_registry_resolver_1 = require("./plugin-registry-resolver");
15
+ var pluginRegistryModule = new inversify_1.ContainerModule(function (bind) {
16
+ bind(plugin_registry_resolver_1.PluginRegistryResolver).toSelf().inSingletonScope();
17
+ });
18
+ exports.pluginRegistryModule = pluginRegistryModule;
19
+ //# sourceMappingURL=plugin-registry-module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-registry-module.js","sourceRoot":"","sources":["../../src/plugin-registry/plugin-registry-module.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;yEAQyE;AACzE,uCAAwD;AAExD,uEAAoE;AAEpE,IAAM,oBAAoB,GAAG,IAAI,2BAAe,CAAC,UAAC,IAAqB;IACrE,IAAI,CAAC,iDAAsB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;AAC3D,CAAC,CAAC,CAAC;AAEM,oDAAoB"}
@@ -0,0 +1,113 @@
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
24
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
25
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
26
+ 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;
27
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
28
+ };
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ var __generator = (this && this.__generator) || function (thisArg, body) {
46
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
47
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
48
+ function verb(n) { return function (v) { return step([n, v]); }; }
49
+ function step(op) {
50
+ if (f) throw new TypeError("Generator is already executing.");
51
+ while (_) try {
52
+ 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;
53
+ if (y = 0, t) op = [op[0] & 2, t.value];
54
+ switch (op[0]) {
55
+ case 0: case 1: t = op; break;
56
+ case 4: _.label++; return { value: op[1], done: false };
57
+ case 5: _.label++; y = op[1]; op = [0]; continue;
58
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
59
+ default:
60
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
61
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
62
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
63
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
64
+ if (t[2]) _.ops.pop();
65
+ _.trys.pop(); continue;
66
+ }
67
+ op = body.call(thisArg, _);
68
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
69
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
+ }
71
+ };
72
+ exports.__esModule = true;
73
+ exports.PluginRegistryResolver = void 0;
74
+ var jsYaml = __importStar(require("js-yaml"));
75
+ var inversify_1 = require("inversify");
76
+ var url_fetcher_1 = require("../fetch/url-fetcher");
77
+ /**
78
+ * Resolve plug-ins by grabbing the definition from the plug-in registry.
79
+ */
80
+ var PluginRegistryResolver = /** @class */ (function () {
81
+ function PluginRegistryResolver() {
82
+ }
83
+ // FQN id (like eclipse/che-theia/next)
84
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
+ PluginRegistryResolver.prototype.loadDevfilePlugin = function (devfileId) {
86
+ return __awaiter(this, void 0, void 0, function () {
87
+ var devfileUrl, devfileContent;
88
+ return __generator(this, function (_a) {
89
+ switch (_a.label) {
90
+ case 0:
91
+ devfileUrl = this.pluginRegistryUrl + "/plugins/" + devfileId + "/devfile.yaml";
92
+ return [4 /*yield*/, this.urlFetcher.fetchText(devfileUrl)];
93
+ case 1:
94
+ devfileContent = _a.sent();
95
+ return [2 /*return*/, jsYaml.load(devfileContent)];
96
+ }
97
+ });
98
+ });
99
+ };
100
+ __decorate([
101
+ (0, inversify_1.inject)('string'),
102
+ (0, inversify_1.named)('PLUGIN_REGISTRY_URL')
103
+ ], PluginRegistryResolver.prototype, "pluginRegistryUrl");
104
+ __decorate([
105
+ (0, inversify_1.inject)(url_fetcher_1.UrlFetcher)
106
+ ], PluginRegistryResolver.prototype, "urlFetcher");
107
+ PluginRegistryResolver = __decorate([
108
+ (0, inversify_1.injectable)()
109
+ ], PluginRegistryResolver);
110
+ return PluginRegistryResolver;
111
+ }());
112
+ exports.PluginRegistryResolver = PluginRegistryResolver;
113
+ //# sourceMappingURL=plugin-registry-resolver.js.map
@@ -0,0 +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"}
package/package.json ADDED
@@ -0,0 +1,91 @@
1
+ {
2
+ "name": "@eclipse-che/che-devworkspace-generator",
3
+ "version": "0.0.1-1671620831",
4
+ "private": false,
5
+ "description": "Generates DevWorkspaces by transforming existing devfiles",
6
+ "main": "lib/entrypoint.js",
7
+ "bin": {
8
+ "che-devworkspace-generator": "lib/entrypoint.js"
9
+ },
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "files": [
14
+ "lib",
15
+ "src"
16
+ ],
17
+ "scripts": {
18
+ "prepare": "yarn run clean && yarn run build",
19
+ "clean": "rimraf lib",
20
+ "build": "yarn run format && yarn run compile && yarn run lint && yarn run test",
21
+ "compile": "tsc --project .",
22
+ "format": "if-env SKIP_FORMAT=true && echo 'skip format check' || prettier --check '{src,tests}/**/*.ts' package.json",
23
+ "format:fix": "prettier --write '{src,tests}/**/*.ts' package.json",
24
+ "lint": "if-env SKIP_LINT=true && echo 'skip lint check' || eslint --cache=true --no-error-on-unmatched-pattern=true '{src,tests}/(!model|**)/*.ts'",
25
+ "lint:fix": "eslint --fix --cache=true --no-error-on-unmatched-pattern=true \"{src,tests}/(!model|**)/*.{ts,tsx}\"",
26
+ "test": "if-env SKIP_TEST=true && echo 'skip test' || jest --forceExit",
27
+ "watch": "tsc -w",
28
+ "publish:next": "yarn publish --registry=https://registry.npmjs.org/ --no-git-tag-version --new-version 0.0.1-\"$(date +%s)\""
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/eclipse-che/che-devfile-registry.git"
33
+ },
34
+ "author": "",
35
+ "license": "EPL-2.0",
36
+ "bugs": {
37
+ "url": "https://github.com/eclipse/che/issues"
38
+ },
39
+ "homepage": "https://github.com/eclipse-che/che-devfile-registry#readme",
40
+ "dependencies": {
41
+ "@devfile/api": "latest",
42
+ "axios": "0.21.2",
43
+ "fs-extra": "^10.0.0",
44
+ "inversify": "^5.0.1",
45
+ "js-yaml": "^4.0.0",
46
+ "jsonc-parser": "^3.0.0",
47
+ "reflect-metadata": "^0.1.13"
48
+ },
49
+ "devDependencies": {
50
+ "@types/jest": "^27.0.2",
51
+ "eslint": "^8.1.0",
52
+ "if-env": "^1.0.4",
53
+ "jest": "^27.3.1",
54
+ "prettier": "^2.4.1",
55
+ "rimraf": "^3.0.2",
56
+ "rollup": "^2.44.0",
57
+ "ts-jest": "^27.0.7",
58
+ "typescript": "^4.4.4"
59
+ },
60
+ "prettier": {
61
+ "printWidth": 120,
62
+ "singleQuote": true,
63
+ "arrowParens": "avoid"
64
+ },
65
+ "importSort": {
66
+ ".ts": {
67
+ "style": "eslint",
68
+ "parser": "typescript"
69
+ }
70
+ },
71
+ "jest": {
72
+ "clearMocks": true,
73
+ "collectCoverage": true,
74
+ "collectCoverageFrom": [
75
+ "src/**/*.{ts,tsx}"
76
+ ],
77
+ "coverageThreshold": {
78
+ "global": {
79
+ "branches": 100,
80
+ "functions": 100,
81
+ "lines": 100,
82
+ "statements": 100
83
+ }
84
+ },
85
+ "coverageDirectory": "coverage",
86
+ "modulePathIgnorePatterns": [
87
+ "<rootDir>/lib"
88
+ ],
89
+ "preset": "ts-jest"
90
+ }
91
+ }
@@ -0,0 +1,28 @@
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
+ /**
13
+ * Context used on every call to this service to update DevWorkspace
14
+ */
15
+ export interface DevfileContext {
16
+ // devfile Content
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ devfile: any;
19
+
20
+ // devWorkspace
21
+ devWorkspace: V1alpha2DevWorkspace;
22
+
23
+ // devWorkspace templates
24
+ devWorkspaceTemplates: V1alpha2DevWorkspaceTemplate[];
25
+
26
+ // suffix to append on generated names
27
+ suffix: string;
28
+ }