@eclipse-che/che-devworkspace-generator 0.0.1-25f630b → 0.0.1-96cdbb4
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 +28 -0
- package/lib/main.d.ts +4 -2
- package/lib/main.js +27 -22
- package/lib/main.js.map +1 -1
- package/package.json +1 -1
- package/src/main.ts +46 -35
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
## DevWorkspace Generator
|
|
2
|
+
The library is used by Devfile registry component to generate the DevWorkspace components and DevWorkspace templates.
|
|
3
|
+
|
|
4
|
+
## How to use the library
|
|
5
|
+
The library could be used as a standalone library.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
USAGE
|
|
9
|
+
$ node lib/entrypoint.js [OPTIONS]
|
|
10
|
+
|
|
11
|
+
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
|
|
19
|
+
|
|
20
|
+
EXAMPLE
|
|
21
|
+
|
|
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
|
+
```
|
|
24
|
+
|
|
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:
|
|
27
|
+
|
|
28
|
+
`$ kubectl apply -f /tmp/all-in-one.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,8CAAkC;AAClC,mEAAiE;AACjE,mDAAiD;AACjD,uFAAoF;AAIpF;IACE;;OAEG;IACH;QACE,QAAQ;IACV,CAAC;IACD,qDAAqD;IACxC,qCAAsB,GAAnC,
|
|
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;IACE;;OAEG;IACH;QACE,QAAQ;IACV,CAAC;IACD,qDAAqD;IACxC,qCAAsB,GAAnC,UACE,MAUC,EACD,aAAkC;;;;;;wBAElC,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE;4BACtE,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;yBACvE;wBACD,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE;4BACvE,MAAM,IAA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;4BAC/B,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;yBACxE;wBACD,IAAI,CAAC,UAAU,EAAE;4BACf,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;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;6BACT,EACD,KAAK,CAAC,SAAO,CAAA,CACd,EAAA;;wBAXD,SAWC,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,AA9LD,IA8LC;AA9LY,oBAAI"}
|
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);
|