@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.
- package/lib/api/devfile-context.js +3 -0
- package/lib/api/devfile-context.js.map +1 -0
- package/lib/devfile/dev-container-component-finder.js +91 -0
- package/lib/devfile/dev-container-component-finder.js.map +1 -0
- package/lib/devfile/devfile-module.js +19 -0
- package/lib/devfile/devfile-module.js.map +1 -0
- package/lib/entrypoint.js +67 -0
- package/lib/entrypoint.js.map +1 -0
- package/lib/fetch/fetch-module.js +19 -0
- package/lib/fetch/fetch-module.js.map +1 -0
- package/lib/fetch/url-fetcher.js +114 -0
- package/lib/fetch/url-fetcher.js.map +1 -0
- package/lib/generate.js +177 -0
- package/lib/generate.js.map +1 -0
- package/lib/github/github-module.js +19 -0
- package/lib/github/github-module.js.map +1 -0
- package/lib/github/github-resolver.js +54 -0
- package/lib/github/github-resolver.js.map +1 -0
- package/lib/github/github-url.js +46 -0
- package/lib/github/github-url.js.map +1 -0
- package/lib/inversify/inversify-binding.js +78 -0
- package/lib/inversify/inversify-binding.js.map +1 -0
- package/lib/main.js +233 -0
- package/lib/main.js.map +1 -0
- package/lib/plugin-registry/plugin-registry-module.js +19 -0
- package/lib/plugin-registry/plugin-registry-module.js.map +1 -0
- package/lib/plugin-registry/plugin-registry-resolver.js +113 -0
- package/lib/plugin-registry/plugin-registry-resolver.js.map +1 -0
- package/package.json +91 -0
- package/src/api/devfile-context.ts +28 -0
- package/src/devfile/dev-container-component-finder.ts +43 -0
- package/src/devfile/devfile-module.ts +18 -0
- package/src/entrypoint.ts +22 -0
- package/src/fetch/fetch-module.ts +18 -0
- package/src/fetch/url-fetcher.ts +49 -0
- package/src/generate.ts +117 -0
- package/src/github/github-module.ts +18 -0
- package/src/github/github-resolver.ts +41 -0
- package/src/github/github-url.ts +47 -0
- package/src/inversify/inversify-binding.ts +46 -0
- package/src/main.ts +166 -0
- package/src/plugin-registry/plugin-registry-module.ts +18 -0
- package/src/plugin-registry/plugin-registry-resolver.ts +36 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devfile-context.js","sourceRoot":"","sources":["../../src/api/devfile-context.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**********************************************************************
|
|
3
|
+
* Copyright (c) 2022 Red Hat, Inc.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made
|
|
6
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
7
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
8
|
+
*
|
|
9
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
10
|
+
***********************************************************************/
|
|
11
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
12
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
13
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
14
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
15
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
16
|
+
};
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (_) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
exports.__esModule = true;
|
|
54
|
+
exports.DevContainerComponentFinder = void 0;
|
|
55
|
+
var inversify_1 = require("inversify");
|
|
56
|
+
/**
|
|
57
|
+
* Need to find dev container from main dev workspace
|
|
58
|
+
*/
|
|
59
|
+
var DevContainerComponentFinder = /** @class */ (function () {
|
|
60
|
+
function DevContainerComponentFinder() {
|
|
61
|
+
}
|
|
62
|
+
DevContainerComponentFinder.prototype.find = function (devfileContext) {
|
|
63
|
+
var _a, _b, _c;
|
|
64
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
+
var devComponents;
|
|
66
|
+
return __generator(this, function (_d) {
|
|
67
|
+
devComponents = (_c = (_b = (_a = devfileContext.devWorkspace.spec) === null || _a === void 0 ? void 0 : _a.template) === null || _b === void 0 ? void 0 : _b.components) === null || _c === void 0 ? void 0 : _c.filter(function (component) { return component.container; }).filter(
|
|
68
|
+
// we should ignore component that do not mount the sources
|
|
69
|
+
function (component) { return component.container && component.container.mountSources !== false; });
|
|
70
|
+
// only one, fine, else error
|
|
71
|
+
if (!devComponents || devComponents.length === 0) {
|
|
72
|
+
throw new Error('Not able to find any dev container component in DevWorkspace');
|
|
73
|
+
}
|
|
74
|
+
else if (devComponents.length === 1) {
|
|
75
|
+
return [2 /*return*/, devComponents[0]];
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
console.warn("More than one dev container component has been potentially found, taking the first one of " + devComponents.map(function (component) { return component.name; }));
|
|
79
|
+
return [2 /*return*/, devComponents[0]];
|
|
80
|
+
}
|
|
81
|
+
return [2 /*return*/];
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
DevContainerComponentFinder = __decorate([
|
|
86
|
+
(0, inversify_1.injectable)()
|
|
87
|
+
], DevContainerComponentFinder);
|
|
88
|
+
return DevContainerComponentFinder;
|
|
89
|
+
}());
|
|
90
|
+
exports.DevContainerComponentFinder = DevContainerComponentFinder;
|
|
91
|
+
//# sourceMappingURL=dev-container-component-finder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-container-component-finder.js","sourceRoot":"","sources":["../../src/devfile/dev-container-component-finder.ts"],"names":[],"mappings":";AAAA;;;;;;;;yEAQyE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIzE,uCAAuC;AAEvC;;GAEG;AAEH;IAAA;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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.devfileModule = void 0;
|
|
4
|
+
/**********************************************************************
|
|
5
|
+
* Copyright (c) 2022 Red Hat, Inc.
|
|
6
|
+
*
|
|
7
|
+
* This program and the accompanying materials are made
|
|
8
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
9
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
10
|
+
*
|
|
11
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
12
|
+
***********************************************************************/
|
|
13
|
+
var inversify_1 = require("inversify");
|
|
14
|
+
var dev_container_component_finder_1 = require("./dev-container-component-finder");
|
|
15
|
+
var devfileModule = new inversify_1.ContainerModule(function (bind) {
|
|
16
|
+
bind(dev_container_component_finder_1.DevContainerComponentFinder).toSelf().inSingletonScope();
|
|
17
|
+
});
|
|
18
|
+
exports.devfileModule = devfileModule;
|
|
19
|
+
//# sourceMappingURL=devfile-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devfile-module.js","sourceRoot":"","sources":["../../src/devfile/devfile-module.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;yEAQyE;AACzE,uCAAwD;AAExD,mFAA+E;AAE/E,IAAM,aAAa,GAAG,IAAI,2BAAe,CAAC,UAAC,IAAqB;IAC9D,IAAI,CAAC,4DAA2B,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;AAChE,CAAC,CAAC,CAAC;AAEM,sCAAa"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**********************************************************************
|
|
4
|
+
* Copyright (c) 2022 Red Hat, Inc.
|
|
5
|
+
*
|
|
6
|
+
* This program and the accompanying materials are made
|
|
7
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
8
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
9
|
+
*
|
|
10
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
11
|
+
***********************************************************************/
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (_) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
exports.__esModule = true;
|
|
49
|
+
require("reflect-metadata");
|
|
50
|
+
var main_1 = require("./main");
|
|
51
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
52
|
+
var main, success;
|
|
53
|
+
return __generator(this, function (_a) {
|
|
54
|
+
switch (_a.label) {
|
|
55
|
+
case 0:
|
|
56
|
+
main = new main_1.Main();
|
|
57
|
+
return [4 /*yield*/, main.start()];
|
|
58
|
+
case 1:
|
|
59
|
+
success = _a.sent();
|
|
60
|
+
if (!success) {
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
return [2 /*return*/];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}); })();
|
|
67
|
+
//# sourceMappingURL=entrypoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entrypoint.js","sourceRoot":"","sources":["../src/entrypoint.ts"],"names":[],"mappings":";;AACA;;;;;;;;yEAQyE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEzE,4BAA0B;AAE1B,+BAA8B;AAE9B,CAAC;;;;;gBACO,IAAI,GAAG,IAAI,WAAI,EAAE,CAAC;gBACR,qBAAM,IAAI,CAAC,KAAK,EAAE,EAAA;;gBAA5B,OAAO,GAAG,SAAkB;gBAClC,IAAI,CAAC,OAAO,EAAE;oBACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;iBACjB;;;;KACF,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.fetchModule = void 0;
|
|
4
|
+
/**********************************************************************
|
|
5
|
+
* Copyright (c) 2022 Red Hat, Inc.
|
|
6
|
+
*
|
|
7
|
+
* This program and the accompanying materials are made
|
|
8
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
9
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
10
|
+
*
|
|
11
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
12
|
+
***********************************************************************/
|
|
13
|
+
var inversify_1 = require("inversify");
|
|
14
|
+
var url_fetcher_1 = require("./url-fetcher");
|
|
15
|
+
var fetchModule = new inversify_1.ContainerModule(function (bind) {
|
|
16
|
+
bind(url_fetcher_1.UrlFetcher).toSelf().inSingletonScope();
|
|
17
|
+
});
|
|
18
|
+
exports.fetchModule = fetchModule;
|
|
19
|
+
//# sourceMappingURL=fetch-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-module.js","sourceRoot":"","sources":["../../src/fetch/fetch-module.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;yEAQyE;AACzE,uCAAwD;AAExD,6CAA2C;AAE3C,IAAM,WAAW,GAAG,IAAI,2BAAe,CAAC,UAAC,IAAqB;IAC5D,IAAI,CAAC,wBAAU,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;AAC/C,CAAC,CAAC,CAAC;AAEM,kCAAW"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
18
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
19
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
20
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
21
|
+
function step(op) {
|
|
22
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
23
|
+
while (_) try {
|
|
24
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
25
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
26
|
+
switch (op[0]) {
|
|
27
|
+
case 0: case 1: t = op; break;
|
|
28
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
29
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
30
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
31
|
+
default:
|
|
32
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
33
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
34
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
35
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
36
|
+
if (t[2]) _.ops.pop();
|
|
37
|
+
_.trys.pop(); continue;
|
|
38
|
+
}
|
|
39
|
+
op = body.call(thisArg, _);
|
|
40
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
41
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.__esModule = true;
|
|
45
|
+
exports.UrlFetcher = void 0;
|
|
46
|
+
/**********************************************************************
|
|
47
|
+
* Copyright (c) 2022 Red Hat, Inc.
|
|
48
|
+
*
|
|
49
|
+
* This program and the accompanying materials are made
|
|
50
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
51
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
52
|
+
*
|
|
53
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
54
|
+
***********************************************************************/
|
|
55
|
+
var inversify_1 = require("inversify");
|
|
56
|
+
/**
|
|
57
|
+
* Allow to grab external content
|
|
58
|
+
* if browser support is enabled, it will update URLs to make them work on browser side.
|
|
59
|
+
*/
|
|
60
|
+
var UrlFetcher = /** @class */ (function () {
|
|
61
|
+
function UrlFetcher() {
|
|
62
|
+
}
|
|
63
|
+
// fetch content optionally, if the URL is not found, we return undefined without throwing errors
|
|
64
|
+
UrlFetcher.prototype.fetchTextOptionalContent = function (url) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
66
|
+
var response, error_1;
|
|
67
|
+
return __generator(this, function (_a) {
|
|
68
|
+
switch (_a.label) {
|
|
69
|
+
case 0:
|
|
70
|
+
_a.trys.push([0, 2, , 3]);
|
|
71
|
+
return [4 /*yield*/, this.axiosInstance.get(url, {
|
|
72
|
+
responseType: 'text'
|
|
73
|
+
})];
|
|
74
|
+
case 1:
|
|
75
|
+
response = _a.sent();
|
|
76
|
+
return [2 /*return*/, response.data];
|
|
77
|
+
case 2:
|
|
78
|
+
error_1 = _a.sent();
|
|
79
|
+
// not found then we return undefined
|
|
80
|
+
if (error_1.response && error_1.response.status === 404) {
|
|
81
|
+
return [2 /*return*/, undefined];
|
|
82
|
+
}
|
|
83
|
+
throw error_1;
|
|
84
|
+
case 3: return [2 /*return*/];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
// fetch content
|
|
90
|
+
UrlFetcher.prototype.fetchText = function (url) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
92
|
+
var response;
|
|
93
|
+
return __generator(this, function (_a) {
|
|
94
|
+
switch (_a.label) {
|
|
95
|
+
case 0: return [4 /*yield*/, this.axiosInstance.get(url, {
|
|
96
|
+
responseType: 'text'
|
|
97
|
+
})];
|
|
98
|
+
case 1:
|
|
99
|
+
response = _a.sent();
|
|
100
|
+
return [2 /*return*/, response.data];
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
__decorate([
|
|
106
|
+
(0, inversify_1.inject)(Symbol["for"]('AxiosInstance'))
|
|
107
|
+
], UrlFetcher.prototype, "axiosInstance");
|
|
108
|
+
UrlFetcher = __decorate([
|
|
109
|
+
(0, inversify_1.injectable)()
|
|
110
|
+
], UrlFetcher);
|
|
111
|
+
return UrlFetcher;
|
|
112
|
+
}());
|
|
113
|
+
exports.UrlFetcher = UrlFetcher;
|
|
114
|
+
//# sourceMappingURL=url-fetcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-fetcher.js","sourceRoot":"","sources":["../../src/fetch/url-fetcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;yEAQyE;AACzE,uCAA+C;AAI/C;;;GAGG;AAEH;IAAA;IA8BA,CAAC;IAzBC,iGAAiG;IAC3F,6CAAwB,GAA9B,UAA+B,GAAW;;;;;;;wBAErB,qBAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,GAAG,EAAE;gCACzD,YAAY,EAAE,MAAM;6BACrB,CAAC,EAAA;;wBAFI,QAAQ,GAAG,SAEf;wBACF,sBAAO,QAAQ,CAAC,IAAI,EAAC;;;wBAGrB,qCAAqC;wBACrC,IAAI,OAAK,CAAC,QAAQ,IAAI,OAAK,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;4BACnD,sBAAO,SAAS,EAAC;yBAClB;wBACD,MAAM,OAAK,CAAC;;;;;KAEf;IAED,gBAAgB;IACV,8BAAS,GAAf,UAAgB,GAAW;;;;;4BACR,qBAAM,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,GAAG,EAAE;4BACzD,YAAY,EAAE,MAAM;yBACrB,CAAC,EAAA;;wBAFI,QAAQ,GAAG,SAEf;wBACF,sBAAO,QAAQ,CAAC,IAAI,EAAC;;;;KAEtB;IA1BD;QADC,IAAA,kBAAM,EAAC,MAAM,CAAC,KAAG,CAAA,CAAC,eAAe,CAAC,CAAC;6CACC;IAH1B,UAAU;QADtB,IAAA,sBAAU,GAAE;OACA,UAAU,CA8BtB;IAAD,iBAAC;CAAA,AA9BD,IA8BC;AA9BY,gCAAU"}
|
package/lib/generate.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
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.Generate = void 0;
|
|
74
|
+
var inversify_1 = require("inversify");
|
|
75
|
+
var jsYaml = __importStar(require("js-yaml"));
|
|
76
|
+
var fs = __importStar(require("fs-extra"));
|
|
77
|
+
var dev_container_component_finder_1 = require("./devfile/dev-container-component-finder");
|
|
78
|
+
var Generate = /** @class */ (function () {
|
|
79
|
+
function Generate() {
|
|
80
|
+
}
|
|
81
|
+
Generate_1 = Generate;
|
|
82
|
+
Generate.prototype.generate = function (devfileContent, editorContent, outputFile) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
84
|
+
var context, allContentArray, generatedContent;
|
|
85
|
+
return __generator(this, function (_a) {
|
|
86
|
+
switch (_a.label) {
|
|
87
|
+
case 0: return [4 /*yield*/, this.generateContent(devfileContent, editorContent)];
|
|
88
|
+
case 1:
|
|
89
|
+
context = _a.sent();
|
|
90
|
+
allContentArray = context.devWorkspaceTemplates.map(function (template) { return jsYaml.dump(template); });
|
|
91
|
+
allContentArray.push(jsYaml.dump(context.devWorkspace));
|
|
92
|
+
generatedContent = allContentArray.join('---\n');
|
|
93
|
+
return [4 /*yield*/, fs.writeFile(outputFile, generatedContent, 'utf-8')];
|
|
94
|
+
case 2:
|
|
95
|
+
_a.sent();
|
|
96
|
+
console.log("DevWorkspace " + context.devWorkspaceTemplates[0].metadata.name + " was generated.");
|
|
97
|
+
return [2 /*return*/, context];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
Generate.prototype.generateContent = function (devfileContent, editorContent) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
104
|
+
var devfile, suffix, editorDevfile, metadata, editorDevWorkspaceTemplate, devfileMetadata, devfileCopy, editorSpecContribution, devWorkspace, devWorkspaceTemplates, context, devContainer, devContainerAttributes;
|
|
105
|
+
return __generator(this, function (_a) {
|
|
106
|
+
switch (_a.label) {
|
|
107
|
+
case 0:
|
|
108
|
+
devfile = jsYaml.load(devfileContent);
|
|
109
|
+
suffix = devfile.metadata.name || '';
|
|
110
|
+
editorDevfile = jsYaml.load(editorContent);
|
|
111
|
+
metadata = editorDevfile.metadata;
|
|
112
|
+
// add sufix
|
|
113
|
+
metadata.name = metadata.name + "-" + suffix;
|
|
114
|
+
delete editorDevfile.metadata;
|
|
115
|
+
delete editorDevfile.schemaVersion;
|
|
116
|
+
editorDevWorkspaceTemplate = {
|
|
117
|
+
apiVersion: 'workspace.devfile.io/v1alpha2',
|
|
118
|
+
kind: 'DevWorkspaceTemplate',
|
|
119
|
+
metadata: metadata,
|
|
120
|
+
spec: editorDevfile
|
|
121
|
+
};
|
|
122
|
+
devfileMetadata = devfile.metadata;
|
|
123
|
+
devfileCopy = Object.assign({}, devfile);
|
|
124
|
+
delete devfileCopy.schemaVersion;
|
|
125
|
+
delete devfileCopy.metadata;
|
|
126
|
+
editorSpecContribution = {
|
|
127
|
+
name: 'editor',
|
|
128
|
+
kubernetes: {
|
|
129
|
+
name: editorDevWorkspaceTemplate.metadata.name
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
devWorkspace = {
|
|
133
|
+
apiVersion: 'workspace.devfile.io/v1alpha2',
|
|
134
|
+
kind: 'DevWorkspace',
|
|
135
|
+
metadata: devfileMetadata,
|
|
136
|
+
spec: {
|
|
137
|
+
started: true,
|
|
138
|
+
template: devfileCopy,
|
|
139
|
+
contributions: [editorSpecContribution]
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
devWorkspaceTemplates = [editorDevWorkspaceTemplate];
|
|
143
|
+
context = {
|
|
144
|
+
devfile: devfile,
|
|
145
|
+
devWorkspace: devWorkspace,
|
|
146
|
+
devWorkspaceTemplates: devWorkspaceTemplates,
|
|
147
|
+
suffix: suffix
|
|
148
|
+
};
|
|
149
|
+
return [4 /*yield*/, this.devContainerComponentFinder.find(context)];
|
|
150
|
+
case 1:
|
|
151
|
+
devContainer = _a.sent();
|
|
152
|
+
devContainerAttributes = devContainer.attributes;
|
|
153
|
+
if (!devContainerAttributes) {
|
|
154
|
+
devContainerAttributes = {};
|
|
155
|
+
devContainerAttributes[Generate_1.MERGE_CONTRIBUTION] = true;
|
|
156
|
+
devContainer.attributes = devContainerAttributes;
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
devContainerAttributes[Generate_1.MERGE_CONTRIBUTION] = true;
|
|
160
|
+
}
|
|
161
|
+
return [2 /*return*/, context];
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
var Generate_1;
|
|
167
|
+
Generate.MERGE_CONTRIBUTION = 'controller.devfile.io/merge-contribution';
|
|
168
|
+
__decorate([
|
|
169
|
+
(0, inversify_1.inject)(dev_container_component_finder_1.DevContainerComponentFinder)
|
|
170
|
+
], Generate.prototype, "devContainerComponentFinder");
|
|
171
|
+
Generate = Generate_1 = __decorate([
|
|
172
|
+
(0, inversify_1.injectable)()
|
|
173
|
+
], Generate);
|
|
174
|
+
return Generate;
|
|
175
|
+
}());
|
|
176
|
+
exports.Generate = Generate;
|
|
177
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/generate.ts"],"names":[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AAG,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;;IA1Fe,2BAAkB,GAAG,0CAA2C,CAAA;IAGhF;QADC,IAAA,kBAAM,EAAC,4DAA2B,CAAC;yDAC6B;IAJtD,QAAQ;QADpB,IAAA,sBAAU,GAAE;OACA,QAAQ,CA4FpB;IAAD,eAAC;CAAA,AA5FD,IA4FC;AA5FY,4BAAQ"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.githubModule = 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 github_resolver_1 = require("./github-resolver");
|
|
15
|
+
var githubModule = new inversify_1.ContainerModule(function (bind) {
|
|
16
|
+
bind(github_resolver_1.GithubResolver).toSelf().inSingletonScope();
|
|
17
|
+
});
|
|
18
|
+
exports.githubModule = githubModule;
|
|
19
|
+
//# sourceMappingURL=github-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github-module.js","sourceRoot":"","sources":["../../src/github/github-module.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;yEAQyE;AACzE,uCAAwD;AAExD,qDAAmD;AAEnD,IAAM,YAAY,GAAG,IAAI,2BAAe,CAAC,UAAC,IAAqB;IAC7D,IAAI,CAAC,gCAAc,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;AACnD,CAAC,CAAC,CAAC;AAEM,oCAAY"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**********************************************************************
|
|
3
|
+
* Copyright (c) 2022 Red Hat, Inc.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made
|
|
6
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
7
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
8
|
+
*
|
|
9
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
10
|
+
***********************************************************************/
|
|
11
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
12
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
13
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
14
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
15
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
16
|
+
};
|
|
17
|
+
exports.__esModule = true;
|
|
18
|
+
exports.GithubResolver = void 0;
|
|
19
|
+
var github_url_1 = require("./github-url");
|
|
20
|
+
var inversify_1 = require("inversify");
|
|
21
|
+
/**
|
|
22
|
+
* Provides a github URL object allowing to interact
|
|
23
|
+
*/
|
|
24
|
+
var GithubResolver = /** @class */ (function () {
|
|
25
|
+
function GithubResolver() {
|
|
26
|
+
}
|
|
27
|
+
GithubResolver_1 = GithubResolver;
|
|
28
|
+
GithubResolver.prototype.resolve = function (link) {
|
|
29
|
+
var match = GithubResolver_1.GITHUB_URL_PATTERN.exec(link);
|
|
30
|
+
if (!match) {
|
|
31
|
+
throw new Error("Invalid github URL: " + link);
|
|
32
|
+
}
|
|
33
|
+
var repoUser = this.getGroup(match, 'repoUser');
|
|
34
|
+
var repoName = this.getGroup(match, 'repoName');
|
|
35
|
+
var branchName = this.getGroup(match, 'branchName', 'HEAD');
|
|
36
|
+
var subFolder = this.getGroup(match, 'subFolder');
|
|
37
|
+
return new github_url_1.GithubUrl(repoUser, repoName, branchName, subFolder);
|
|
38
|
+
};
|
|
39
|
+
GithubResolver.prototype.getGroup = function (match, groupName, defaultValue) {
|
|
40
|
+
if (match.groups && match.groups[groupName]) {
|
|
41
|
+
return match.groups[groupName];
|
|
42
|
+
}
|
|
43
|
+
return defaultValue || '';
|
|
44
|
+
};
|
|
45
|
+
var GithubResolver_1;
|
|
46
|
+
// eslint-disable-next-line max-len
|
|
47
|
+
GithubResolver.GITHUB_URL_PATTERN = /^(?:http)(?:s)?(?:\:\/\/)github\.com\/(?<repoUser>[^\/]+)\/(?<repoName>[^\/]+)((\/)|(?:\/(blob|tree)\/(?<branchName>[^\/]+)(?:\/(?<subFolder>.*))?))?$/;
|
|
48
|
+
GithubResolver = GithubResolver_1 = __decorate([
|
|
49
|
+
(0, inversify_1.injectable)()
|
|
50
|
+
], GithubResolver);
|
|
51
|
+
return GithubResolver;
|
|
52
|
+
}());
|
|
53
|
+
exports.GithubResolver = GithubResolver;
|
|
54
|
+
//# sourceMappingURL=github-resolver.js.map
|
|
@@ -0,0 +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,CAA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