@eclipse-che/che-devworkspace-generator 0.0.1-25f630b → 0.0.1-4f0e375
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 +50 -0
- package/lib/main.d.ts +4 -2
- package/lib/main.js +27 -22
- package/lib/main.js.map +1 -1
- package/lib/plugin-registry/plugin-registry-resolver.js +1 -1
- package/lib/plugin-registry/plugin-registry-resolver.js.map +1 -1
- package/package.json +1 -1
- package/src/main.ts +46 -35
- package/src/plugin-registry/plugin-registry-resolver.ts +1 -1
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`
|
package/lib/main.d.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* SPDX-License-Identifier: EPL-2.0
|
|
9
9
|
***********************************************************************/
|
|
10
|
+
import * as axios from 'axios';
|
|
10
11
|
import { DevfileContext } from './api/devfile-context';
|
|
11
12
|
export declare class Main {
|
|
12
13
|
/**
|
|
@@ -19,13 +20,14 @@ export declare class Main {
|
|
|
19
20
|
devfileContent?: string;
|
|
20
21
|
outputFile?: string;
|
|
21
22
|
editorPath?: string;
|
|
22
|
-
|
|
23
|
+
editorContent?: string;
|
|
23
24
|
editorEntry?: string;
|
|
25
|
+
pluginRegistryUrl?: string;
|
|
24
26
|
projects: {
|
|
25
27
|
name: string;
|
|
26
28
|
location: string;
|
|
27
29
|
}[];
|
|
28
|
-
}): Promise<DevfileContext>;
|
|
30
|
+
}, axiosInstance: axios.AxiosInstance): Promise<DevfileContext>;
|
|
29
31
|
replaceIfExistingProjects(devfileContent: string, projects: {
|
|
30
32
|
name: string;
|
|
31
33
|
location: string;
|
package/lib/main.js
CHANGED
|
@@ -81,24 +81,25 @@ var Main = /** @class */ (function () {
|
|
|
81
81
|
// no-op
|
|
82
82
|
}
|
|
83
83
|
// Generates a devfile context object based on params
|
|
84
|
-
Main.prototype.generateDevfileContext = function (params) {
|
|
84
|
+
Main.prototype.generateDevfileContext = function (params, axiosInstance) {
|
|
85
85
|
return __awaiter(this, void 0, void 0, function () {
|
|
86
|
-
var
|
|
86
|
+
var pluginRegistryUrl, inversifyBinbding, container, devfileContent, editorContent, githubResolver, githubUrl, devfileParsed, editorDevfile, generate;
|
|
87
87
|
return __generator(this, function (_a) {
|
|
88
88
|
switch (_a.label) {
|
|
89
89
|
case 0:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
throw new Error('missing editorPath or editorEntry');
|
|
90
|
+
if (!params.editorPath && !params.editorEntry && !params.editorContent) {
|
|
91
|
+
throw new Error('missing editorPath or editorEntry or editorContent');
|
|
93
92
|
}
|
|
94
|
-
if (!devfilePath && !devfileUrl && !params.devfileContent) {
|
|
93
|
+
if (!params.devfilePath && !params.devfileUrl && !params.devfileContent) {
|
|
95
94
|
throw new Error('missing devfilePath or devfileUrl or devfileContent');
|
|
96
95
|
}
|
|
97
|
-
if (
|
|
96
|
+
if (params.pluginRegistryUrl) {
|
|
97
|
+
pluginRegistryUrl = params.pluginRegistryUrl;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
98
100
|
pluginRegistryUrl = 'https://eclipse-che.github.io/che-plugin-registry/main/v3';
|
|
99
101
|
console.log("No plug-in registry url. Setting to " + pluginRegistryUrl);
|
|
100
102
|
}
|
|
101
|
-
axiosInstance = axios["default"];
|
|
102
103
|
inversifyBinbding = new inversify_binding_1.InversifyBinding();
|
|
103
104
|
return [4 /*yield*/, inversifyBinbding.initBindings({
|
|
104
105
|
pluginRegistryUrl: pluginRegistryUrl,
|
|
@@ -107,9 +108,9 @@ var Main = /** @class */ (function () {
|
|
|
107
108
|
case 1:
|
|
108
109
|
container = _a.sent();
|
|
109
110
|
container.bind(generate_1.Generate).toSelf().inSingletonScope();
|
|
110
|
-
if (!devfileUrl) return [3 /*break*/, 3];
|
|
111
|
+
if (!params.devfileUrl) return [3 /*break*/, 3];
|
|
111
112
|
githubResolver = container.get(github_resolver_1.GithubResolver);
|
|
112
|
-
githubUrl = githubResolver.resolve(devfileUrl);
|
|
113
|
+
githubUrl = githubResolver.resolve(params.devfileUrl);
|
|
113
114
|
return [4 /*yield*/, container.get(url_fetcher_1.UrlFetcher).fetchText(githubUrl.getContentUrl('devfile.yaml'))];
|
|
114
115
|
case 2:
|
|
115
116
|
// user devfile
|
|
@@ -132,8 +133,8 @@ var Main = /** @class */ (function () {
|
|
|
132
133
|
devfileContent = jsYaml.dump(devfileParsed);
|
|
133
134
|
return [3 /*break*/, 6];
|
|
134
135
|
case 3:
|
|
135
|
-
if (!devfilePath) return [3 /*break*/, 5];
|
|
136
|
-
return [4 /*yield*/, fs.readFile(devfilePath)];
|
|
136
|
+
if (!params.devfilePath) return [3 /*break*/, 5];
|
|
137
|
+
return [4 /*yield*/, fs.readFile(params.devfilePath)];
|
|
137
138
|
case 4:
|
|
138
139
|
devfileContent = _a.sent();
|
|
139
140
|
return [3 /*break*/, 6];
|
|
@@ -142,20 +143,24 @@ var Main = /** @class */ (function () {
|
|
|
142
143
|
_a.label = 6;
|
|
143
144
|
case 6:
|
|
144
145
|
// enhance projects
|
|
145
|
-
devfileContent = this.replaceIfExistingProjects(devfileContent, projects);
|
|
146
|
-
if (!
|
|
147
|
-
|
|
146
|
+
devfileContent = this.replaceIfExistingProjects(devfileContent, params.projects);
|
|
147
|
+
if (!params.editorContent) return [3 /*break*/, 7];
|
|
148
|
+
editorContent = params.editorContent;
|
|
149
|
+
return [3 /*break*/, 11];
|
|
148
150
|
case 7:
|
|
151
|
+
if (!params.editorEntry) return [3 /*break*/, 9];
|
|
152
|
+
return [4 /*yield*/, container.get(plugin_registry_resolver_1.PluginRegistryResolver).loadDevfilePlugin(params.editorEntry)];
|
|
153
|
+
case 8:
|
|
149
154
|
editorDevfile = _a.sent();
|
|
150
155
|
editorContent = jsYaml.dump(editorDevfile);
|
|
151
|
-
return [3 /*break*/,
|
|
152
|
-
case
|
|
153
|
-
case 9:
|
|
154
|
-
editorContent = _a.sent();
|
|
155
|
-
_a.label = 10;
|
|
156
|
+
return [3 /*break*/, 11];
|
|
157
|
+
case 9: return [4 /*yield*/, fs.readFile(params.editorPath)];
|
|
156
158
|
case 10:
|
|
159
|
+
editorContent = _a.sent();
|
|
160
|
+
_a.label = 11;
|
|
161
|
+
case 11:
|
|
157
162
|
generate = container.get(generate_1.Generate);
|
|
158
|
-
return [2 /*return*/, generate.generate(devfileContent, editorContent, outputFile)];
|
|
163
|
+
return [2 /*return*/, generate.generate(devfileContent, editorContent, params.outputFile)];
|
|
159
164
|
}
|
|
160
165
|
});
|
|
161
166
|
});
|
|
@@ -240,7 +245,7 @@ var Main = /** @class */ (function () {
|
|
|
240
245
|
pluginRegistryUrl: pluginRegistryUrl,
|
|
241
246
|
editorEntry: editorEntry,
|
|
242
247
|
projects: projects
|
|
243
|
-
})];
|
|
248
|
+
}, axios["default"])];
|
|
244
249
|
case 2:
|
|
245
250
|
_a.sent();
|
|
246
251
|
return [2 /*return*/, true];
|
package/lib/main.js.map
CHANGED
|
@@ -1 +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,8CAA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,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,AA9LD,IA8LC;AA9LY,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
|
|
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,
|
|
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
package/src/main.ts
CHANGED
|
@@ -27,30 +27,36 @@ export class Main {
|
|
|
27
27
|
// no-op
|
|
28
28
|
}
|
|
29
29
|
// Generates a devfile context object based on params
|
|
30
|
-
public async generateDevfileContext(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
30
|
+
public async generateDevfileContext(
|
|
31
|
+
params: {
|
|
32
|
+
devfilePath?: string;
|
|
33
|
+
devfileUrl?: string;
|
|
34
|
+
devfileContent?: string;
|
|
35
|
+
outputFile?: string;
|
|
36
|
+
editorPath?: string;
|
|
37
|
+
editorContent?: string;
|
|
38
|
+
editorEntry?: string;
|
|
39
|
+
pluginRegistryUrl?: string;
|
|
40
|
+
projects: { name: string; location: string }[];
|
|
41
|
+
},
|
|
42
|
+
axiosInstance: axios.AxiosInstance
|
|
43
|
+
): Promise<DevfileContext> {
|
|
44
|
+
if (!params.editorPath && !params.editorEntry && !params.editorContent) {
|
|
45
|
+
throw new Error('missing editorPath or editorEntry or editorContent');
|
|
44
46
|
}
|
|
45
|
-
if (!devfilePath && !devfileUrl && !params.devfileContent) {
|
|
47
|
+
if (!params.devfilePath && !params.devfileUrl && !params.devfileContent) {
|
|
46
48
|
throw new Error('missing devfilePath or devfileUrl or devfileContent');
|
|
47
49
|
}
|
|
48
|
-
|
|
50
|
+
|
|
51
|
+
let pluginRegistryUrl: string;
|
|
52
|
+
|
|
53
|
+
if (params.pluginRegistryUrl) {
|
|
54
|
+
pluginRegistryUrl = params.pluginRegistryUrl;
|
|
55
|
+
} else {
|
|
49
56
|
pluginRegistryUrl = 'https://eclipse-che.github.io/che-plugin-registry/main/v3';
|
|
50
57
|
console.log(`No plug-in registry url. Setting to ${pluginRegistryUrl}`);
|
|
51
58
|
}
|
|
52
59
|
|
|
53
|
-
const axiosInstance = axios.default;
|
|
54
60
|
const inversifyBinbding = new InversifyBinding();
|
|
55
61
|
const container = await inversifyBinbding.initBindings({
|
|
56
62
|
pluginRegistryUrl,
|
|
@@ -62,9 +68,9 @@ export class Main {
|
|
|
62
68
|
let editorContent;
|
|
63
69
|
|
|
64
70
|
// gets the github URL
|
|
65
|
-
if (devfileUrl) {
|
|
71
|
+
if (params.devfileUrl) {
|
|
66
72
|
const githubResolver = container.get(GithubResolver);
|
|
67
|
-
const githubUrl = githubResolver.resolve(devfileUrl);
|
|
73
|
+
const githubUrl = githubResolver.resolve(params.devfileUrl);
|
|
68
74
|
// user devfile
|
|
69
75
|
devfileContent = await container.get(UrlFetcher).fetchText(githubUrl.getContentUrl('devfile.yaml'));
|
|
70
76
|
|
|
@@ -86,25 +92,27 @@ export class Main {
|
|
|
86
92
|
}
|
|
87
93
|
// get back the content
|
|
88
94
|
devfileContent = jsYaml.dump(devfileParsed);
|
|
89
|
-
} else if (devfilePath) {
|
|
90
|
-
devfileContent = await fs.readFile(devfilePath);
|
|
95
|
+
} else if (params.devfilePath) {
|
|
96
|
+
devfileContent = await fs.readFile(params.devfilePath);
|
|
91
97
|
} else {
|
|
92
98
|
devfileContent = params.devfileContent;
|
|
93
99
|
}
|
|
94
100
|
|
|
95
101
|
// enhance projects
|
|
96
|
-
devfileContent = this.replaceIfExistingProjects(devfileContent, projects);
|
|
102
|
+
devfileContent = this.replaceIfExistingProjects(devfileContent, params.projects);
|
|
97
103
|
|
|
98
|
-
if (
|
|
104
|
+
if (params.editorContent) {
|
|
105
|
+
editorContent = params.editorContent;
|
|
106
|
+
} else if (params.editorEntry) {
|
|
99
107
|
// devfile of the editor
|
|
100
|
-
const editorDevfile = await container.get(PluginRegistryResolver).loadDevfilePlugin(editorEntry);
|
|
108
|
+
const editorDevfile = await container.get(PluginRegistryResolver).loadDevfilePlugin(params.editorEntry);
|
|
101
109
|
editorContent = jsYaml.dump(editorDevfile);
|
|
102
110
|
} else {
|
|
103
|
-
editorContent = await fs.readFile(editorPath);
|
|
111
|
+
editorContent = await fs.readFile(params.editorPath);
|
|
104
112
|
}
|
|
105
113
|
|
|
106
114
|
const generate = container.get(Generate);
|
|
107
|
-
return generate.generate(devfileContent, editorContent, outputFile);
|
|
115
|
+
return generate.generate(devfileContent, editorContent, params.outputFile);
|
|
108
116
|
}
|
|
109
117
|
|
|
110
118
|
// Update project entry based on the projects passed as parameter
|
|
@@ -182,15 +190,18 @@ export class Main {
|
|
|
182
190
|
if (!outputFile) {
|
|
183
191
|
throw new Error('missing --output-file: parameter');
|
|
184
192
|
}
|
|
185
|
-
await this.generateDevfileContext(
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
193
|
+
await this.generateDevfileContext(
|
|
194
|
+
{
|
|
195
|
+
devfilePath,
|
|
196
|
+
devfileUrl,
|
|
197
|
+
editorPath,
|
|
198
|
+
outputFile,
|
|
199
|
+
pluginRegistryUrl,
|
|
200
|
+
editorEntry,
|
|
201
|
+
projects,
|
|
202
|
+
},
|
|
203
|
+
axios.default
|
|
204
|
+
);
|
|
194
205
|
return true;
|
|
195
206
|
} catch (error) {
|
|
196
207
|
console.error('stack=' + error.stack);
|
|
@@ -26,7 +26,7 @@ export class PluginRegistryResolver {
|
|
|
26
26
|
@inject(UrlFetcher)
|
|
27
27
|
private urlFetcher: UrlFetcher;
|
|
28
28
|
|
|
29
|
-
// FQN id (like
|
|
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`;
|