@eclipse-che/che-devworkspace-generator 0.0.1-a00c266 → 0.0.1-b3f6c7c
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 +42 -14
- package/lib/bitbucket/bitbucket-module.d.ts +12 -0
- package/lib/bitbucket/bitbucket-module.js +21 -0
- package/lib/bitbucket/bitbucket-module.js.map +1 -0
- package/lib/bitbucket/bitbucket-resolver.d.ts +17 -0
- package/lib/bitbucket/bitbucket-resolver.js +56 -0
- package/lib/bitbucket/bitbucket-resolver.js.map +1 -0
- package/lib/bitbucket/bitbucket-url.d.ts +22 -0
- package/lib/bitbucket/bitbucket-url.js +38 -0
- package/lib/bitbucket/bitbucket-url.js.map +1 -0
- package/lib/bitbucket-server/bitbucket-server-module.d.ts +12 -0
- package/lib/bitbucket-server/bitbucket-server-module.js +21 -0
- package/lib/bitbucket-server/bitbucket-server-module.js.map +1 -0
- package/lib/bitbucket-server/bitbucket-server-resolver.d.ts +17 -0
- package/lib/bitbucket-server/bitbucket-server-resolver.js +64 -0
- package/lib/bitbucket-server/bitbucket-server-resolver.js.map +1 -0
- package/lib/bitbucket-server/bitbucket-server-url.d.ts +24 -0
- package/lib/bitbucket-server/bitbucket-server-url.js +43 -0
- package/lib/bitbucket-server/bitbucket-server-url.js.map +1 -0
- package/lib/devfile/dev-container-component-finder.d.ts +2 -1
- package/lib/devfile/dev-container-component-finder.js +20 -7
- package/lib/devfile/dev-container-component-finder.js.map +1 -1
- package/lib/devfile/dev-container-component-inserter.d.ts +18 -0
- package/lib/devfile/dev-container-component-inserter.js +98 -0
- package/lib/devfile/dev-container-component-inserter.js.map +1 -0
- package/lib/devfile/devfile-module.js +2 -0
- package/lib/devfile/devfile-module.js.map +1 -1
- package/lib/generate.d.ts +3 -3
- package/lib/generate.js +29 -21
- package/lib/generate.js.map +1 -1
- package/lib/github/github-module.js +3 -1
- package/lib/github/github-module.js.map +1 -1
- package/lib/github/github-resolver.d.ts +6 -7
- package/lib/github/github-resolver.js +10 -5
- package/lib/github/github-resolver.js.map +1 -1
- package/lib/github/github-url.d.ts +5 -6
- package/lib/github/github-url.js +7 -9
- package/lib/github/github-url.js.map +1 -1
- package/lib/inversify/inversify-binding.js +6 -0
- package/lib/inversify/inversify-binding.js.map +1 -1
- package/lib/main.d.ts +4 -1
- package/lib/main.js +41 -27
- 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/lib/resolve/git-url-resolver.d.ts +5 -0
- package/lib/resolve/git-url-resolver.js +43 -0
- package/lib/resolve/git-url-resolver.js.map +1 -0
- package/lib/resolve/resolve-module.d.ts +12 -0
- package/lib/resolve/resolve-module.js +19 -0
- package/lib/resolve/resolve-module.js.map +1 -0
- package/lib/resolve/resolver.d.ts +22 -0
- package/lib/resolve/resolver.js +12 -0
- package/lib/resolve/resolver.js.map +1 -0
- package/lib/resolve/url.d.ts +35 -0
- package/lib/resolve/url.js +12 -0
- package/lib/resolve/url.js.map +1 -0
- package/lib/types.d.ts +13 -0
- package/lib/types.js +17 -0
- package/lib/types.js.map +1 -0
- package/package.json +1 -1
- package/src/bitbucket/bitbucket-module.ts +21 -0
- package/src/bitbucket/bitbucket-resolver.ts +46 -0
- package/src/bitbucket/bitbucket-url.ts +41 -0
- package/src/bitbucket-server/bitbucket-server-module.ts +21 -0
- package/src/bitbucket-server/bitbucket-server-resolver.ts +53 -0
- package/src/bitbucket-server/bitbucket-server-url.ts +51 -0
- package/src/devfile/dev-container-component-finder.ts +23 -4
- package/src/devfile/dev-container-component-inserter.ts +49 -0
- package/src/devfile/devfile-module.ts +2 -0
- package/src/generate.ts +52 -20
- package/src/github/github-module.ts +4 -1
- package/src/github/github-resolver.ts +17 -9
- package/src/github/github-url.ts +8 -9
- package/src/inversify/inversify-binding.ts +6 -0
- package/src/main.ts +47 -23
- package/src/plugin-registry/plugin-registry-resolver.ts +1 -1
- package/src/resolve/git-url-resolver.ts +30 -0
- package/src/resolve/resolve-module.ts +18 -0
- package/src/resolve/resolver.ts +25 -0
- package/src/resolve/url.ts +40 -0
- package/src/types.ts +14 -0
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,
|
|
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,8CAAkC;AAClC,mEAAiE;AACjE,mDAAiD;AACjD,uFAAoF;AAGpF,+DAA4D;AAE5D;IACE;;OAEG;IACH;QACE,QAAQ;IACV,CAAC;IACD,qDAAqD;IACxC,qCAAsB,GAAnC,UACE,MAYC,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,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;yBACxE;wBAID,IAAI,MAAM,CAAC,iBAAiB,EAAE;4BAC5B,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,CAAC;yBAC9C;6BAAM;4BACL,iBAAiB,GAAG,2DAA2D,CAAC;4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wBAGD,IAAI,CAAC,UAAU,IAAI,CAAC,WAAW,EAAE;4BAC/B,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;yBACxE;wBACD,IAAI,CAAC,WAAW,IAAI,CAAC,UAAU,EAAE;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;gCACR,sBAAsB,wBAAA;gCACtB,qBAAqB,uBAAA;6BACtB,EACD,KAAK,CAAC,SAAO,CAAA,CACd,EAAA;;wBAbD,SAaC,CAAC;wBACF,sBAAO,IAAI,EAAC;;;wBAEZ,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,OAAK,CAAC,KAAK,CAAC,CAAC;wBACtC,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,OAAK,CAAC,CAAC;wBACxC,sBAAO,KAAK,EAAC;;;;;KAEhB;IACH,WAAC;AAAD,CAAC,AAhND,IAgNC;AAhNY,oBAAI"}
|
|
@@ -80,7 +80,7 @@ var url_fetcher_1 = require("../fetch/url-fetcher");
|
|
|
80
80
|
var PluginRegistryResolver = /** @class */ (function () {
|
|
81
81
|
function PluginRegistryResolver() {
|
|
82
82
|
}
|
|
83
|
-
// FQN id (like
|
|
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"}
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
exports.__esModule = true;
|
|
9
|
+
exports.GitUrlResolver = void 0;
|
|
10
|
+
/**********************************************************************
|
|
11
|
+
* Copyright (c) 2023 Red Hat, Inc.
|
|
12
|
+
*
|
|
13
|
+
* This program and the accompanying materials are made
|
|
14
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
15
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
16
|
+
*
|
|
17
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
18
|
+
***********************************************************************/
|
|
19
|
+
var inversify_1 = require("inversify");
|
|
20
|
+
var types_1 = require("../types");
|
|
21
|
+
var Resolver = types_1.TYPES.Resolver;
|
|
22
|
+
var GitUrlResolver = /** @class */ (function () {
|
|
23
|
+
function GitUrlResolver() {
|
|
24
|
+
}
|
|
25
|
+
GitUrlResolver.prototype.resolve = function (link) {
|
|
26
|
+
var resolver = this.resolvers.find(function (r) { return r.isValid(link); });
|
|
27
|
+
if (resolver) {
|
|
28
|
+
return resolver.resolve(link);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw new Error('Can not resolver the URL');
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, inversify_1.multiInject)(Resolver)
|
|
36
|
+
], GitUrlResolver.prototype, "resolvers");
|
|
37
|
+
GitUrlResolver = __decorate([
|
|
38
|
+
(0, inversify_1.injectable)()
|
|
39
|
+
], GitUrlResolver);
|
|
40
|
+
return GitUrlResolver;
|
|
41
|
+
}());
|
|
42
|
+
exports.GitUrlResolver = GitUrlResolver;
|
|
43
|
+
//# sourceMappingURL=git-url-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-url-resolver.js","sourceRoot":"","sources":["../../src/resolve/git-url-resolver.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;yEAQyE;AACzE,uCAAoD;AAEpD,kCAAiC;AAGzB,IAAA,QAAQ,GAAK,aAAK,SAAV,CAAW;AAG3B;IAAA;IAYA,CAAC;IARC,gCAAO,GAAP,UAAQ,IAAY;QAClB,IAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAf,CAAe,CAAC,CAAC;QAC3D,IAAI,QAAQ,EAAE;YACZ,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAC/B;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;SAC7C;IACH,CAAC;IATD;QADC,IAAA,uBAAW,EAAC,QAAQ,CAAC;6CACQ;IAFnB,cAAc;QAD1B,IAAA,sBAAU,GAAE;OACA,cAAc,CAY1B;IAAD,qBAAC;CAAA,AAZD,IAYC;AAZY,wCAAc"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
* Copyright (c) 2023 Red Hat, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made
|
|
5
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
6
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
***********************************************************************/
|
|
10
|
+
import { ContainerModule } from 'inversify';
|
|
11
|
+
declare const resolveModule: ContainerModule;
|
|
12
|
+
export { resolveModule };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.resolveModule = void 0;
|
|
4
|
+
/**********************************************************************
|
|
5
|
+
* Copyright (c) 2023 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 git_url_resolver_1 = require("./git-url-resolver");
|
|
15
|
+
var resolveModule = new inversify_1.ContainerModule(function (bind) {
|
|
16
|
+
bind(git_url_resolver_1.GitUrlResolver).toSelf().inSingletonScope();
|
|
17
|
+
});
|
|
18
|
+
exports.resolveModule = resolveModule;
|
|
19
|
+
//# sourceMappingURL=resolve-module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-module.js","sourceRoot":"","sources":["../../src/resolve/resolve-module.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;yEAQyE;AACzE,uCAAwD;AAExD,uDAAoD;AAEpD,IAAM,aAAa,GAAG,IAAI,2BAAe,CAAC,UAAC,IAAqB;IAC9D,IAAI,CAAC,iCAAc,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;AACnD,CAAC,CAAC,CAAC;AAEM,sCAAa"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
* Copyright (c) 2023 Red Hat, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made
|
|
5
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
6
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
***********************************************************************/
|
|
10
|
+
import { Url } from './url';
|
|
11
|
+
export interface Resolver {
|
|
12
|
+
/**
|
|
13
|
+
* Validates the string url for belonging to a specific Git provider.
|
|
14
|
+
* @param url string representation of Url.
|
|
15
|
+
*/
|
|
16
|
+
isValid(url: string): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Resolves repository string URL to a {@class Url} object.
|
|
19
|
+
* @param url string representation of Url.
|
|
20
|
+
*/
|
|
21
|
+
resolve(url: string): Url;
|
|
22
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**********************************************************************
|
|
3
|
+
* Copyright (c) 2023 Red Hat, Inc.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made
|
|
6
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
7
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
8
|
+
*
|
|
9
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
10
|
+
***********************************************************************/
|
|
11
|
+
exports.__esModule = true;
|
|
12
|
+
//# sourceMappingURL=resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["../../src/resolve/resolver.ts"],"names":[],"mappings":";AAAA;;;;;;;;yEAQyE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
* Copyright (c) 2023 Red Hat, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made
|
|
5
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
6
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
***********************************************************************/
|
|
10
|
+
/**
|
|
11
|
+
* Url object
|
|
12
|
+
*/
|
|
13
|
+
export interface Url {
|
|
14
|
+
/**
|
|
15
|
+
* Provides RAW file content url
|
|
16
|
+
* @param path file path
|
|
17
|
+
*/
|
|
18
|
+
getContentUrl(path: string): any;
|
|
19
|
+
/**
|
|
20
|
+
* Provides repositories Url
|
|
21
|
+
*/
|
|
22
|
+
getUrl(): string;
|
|
23
|
+
/**
|
|
24
|
+
* Provides Git clone url
|
|
25
|
+
*/
|
|
26
|
+
getCloneUrl(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Provides repository name
|
|
29
|
+
*/
|
|
30
|
+
getRepoName(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Provides branch name if initialised.
|
|
33
|
+
*/
|
|
34
|
+
getBranchName(): string;
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**********************************************************************
|
|
3
|
+
* Copyright (c) 2023 Red Hat, Inc.
|
|
4
|
+
*
|
|
5
|
+
* This program and the accompanying materials are made
|
|
6
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
7
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
8
|
+
*
|
|
9
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
10
|
+
***********************************************************************/
|
|
11
|
+
exports.__esModule = true;
|
|
12
|
+
//# sourceMappingURL=url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/resolve/url.ts"],"names":[],"mappings":";AAAA;;;;;;;;yEAQyE"}
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
* Copyright (c) 2023 Red Hat, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made
|
|
5
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
6
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
***********************************************************************/
|
|
10
|
+
declare const TYPES: {
|
|
11
|
+
Resolver: symbol;
|
|
12
|
+
};
|
|
13
|
+
export { TYPES };
|
package/lib/types.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.TYPES = void 0;
|
|
4
|
+
/**********************************************************************
|
|
5
|
+
* Copyright (c) 2023 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 TYPES = {
|
|
14
|
+
Resolver: Symbol["for"]('Resolver')
|
|
15
|
+
};
|
|
16
|
+
exports.TYPES = TYPES;
|
|
17
|
+
//# sourceMappingURL=types.js.map
|
package/lib/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;yEAQyE;AACzE,IAAM,KAAK,GAAG;IACZ,QAAQ,EAAE,MAAM,CAAC,KAAG,CAAA,CAAC,UAAU,CAAC;CACjC,CAAC;AAEO,sBAAK"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
* Copyright (c) 2023 Red Hat, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made
|
|
5
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
6
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
***********************************************************************/
|
|
10
|
+
import { ContainerModule, interfaces } from 'inversify';
|
|
11
|
+
|
|
12
|
+
import { BitbucketResolver } from './bitbucket-resolver';
|
|
13
|
+
import { TYPES } from '../types';
|
|
14
|
+
|
|
15
|
+
const { Resolver } = TYPES;
|
|
16
|
+
|
|
17
|
+
const bitbucketModule = new ContainerModule((bind: interfaces.Bind) => {
|
|
18
|
+
bind(Resolver).to(BitbucketResolver).inSingletonScope();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export { bitbucketModule };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
* Copyright (c) 2023 Red Hat, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made
|
|
5
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
6
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
***********************************************************************/
|
|
10
|
+
|
|
11
|
+
import { BitbucketUrl } from './bitbucket-url';
|
|
12
|
+
import { injectable } from 'inversify';
|
|
13
|
+
import { Url } from '../resolve/url';
|
|
14
|
+
import { Resolver } from '../resolve/resolver';
|
|
15
|
+
|
|
16
|
+
@injectable()
|
|
17
|
+
export class BitbucketResolver implements Resolver {
|
|
18
|
+
// eslint-disable-next-line max-len
|
|
19
|
+
static readonly BITBUCKET_URL_PATTERN: RegExp =
|
|
20
|
+
/^https:\/\/.*@?bitbucket\.org\/(?<workspaceId>[^\/]+)\/(?<repoName>[^\/]+)(\/(src|branch)\/(?<branchName>[^\/]+))?\/?$/;
|
|
21
|
+
|
|
22
|
+
isValid(url: string): boolean {
|
|
23
|
+
return BitbucketResolver.BITBUCKET_URL_PATTERN.test(url);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
resolve(url: string): Url {
|
|
27
|
+
const match = BitbucketResolver.BITBUCKET_URL_PATTERN.exec(url);
|
|
28
|
+
if (!match) {
|
|
29
|
+
throw new Error(`Invalid bitbucket URL: ${url}`);
|
|
30
|
+
}
|
|
31
|
+
const workspaceId = this.getGroup(match, 'workspaceId');
|
|
32
|
+
let repoName = this.getGroup(match, 'repoName');
|
|
33
|
+
if (/^[\w-][\w.-]*?\.git$/.test(repoName)) {
|
|
34
|
+
repoName = repoName.substring(0, repoName.length - 4);
|
|
35
|
+
}
|
|
36
|
+
const branchName = this.getGroup(match, 'branchName', 'HEAD');
|
|
37
|
+
return new BitbucketUrl(workspaceId, repoName, branchName);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private getGroup(match: RegExpExecArray, groupName: string, defaultValue?: string) {
|
|
41
|
+
if (match.groups && match.groups[groupName]) {
|
|
42
|
+
return match.groups[groupName];
|
|
43
|
+
}
|
|
44
|
+
return defaultValue;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
* Copyright (c) 2023 Red Hat, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made
|
|
5
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
6
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
***********************************************************************/
|
|
10
|
+
|
|
11
|
+
import { Url } from '../resolve/url';
|
|
12
|
+
|
|
13
|
+
export class BitbucketUrl implements Url {
|
|
14
|
+
private static readonly BITBUCKET_URL = 'https://bitbucket.org';
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
private readonly workspaceId: string,
|
|
18
|
+
private readonly repoName: string,
|
|
19
|
+
private readonly branchName: string
|
|
20
|
+
) {}
|
|
21
|
+
|
|
22
|
+
getContentUrl(path: string): string {
|
|
23
|
+
return `${BitbucketUrl.BITBUCKET_URL}/${this.workspaceId}/${this.repoName}/raw/${this.branchName}/${path}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
getUrl(): string {
|
|
27
|
+
return `${BitbucketUrl.BITBUCKET_URL}/${this.workspaceId}/${this.repoName}/src/${this.branchName}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getCloneUrl(): string {
|
|
31
|
+
return `${BitbucketUrl.BITBUCKET_URL}/${this.workspaceId}/${this.repoName}.git`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getRepoName(): string {
|
|
35
|
+
return this.repoName;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
getBranchName(): string {
|
|
39
|
+
return this.branchName;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
* Copyright (c) 2023 Red Hat, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made
|
|
5
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
6
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
***********************************************************************/
|
|
10
|
+
import { ContainerModule, interfaces } from 'inversify';
|
|
11
|
+
|
|
12
|
+
import { BitbucketServerResolver } from './bitbucket-server-resolver';
|
|
13
|
+
import { TYPES } from '../types';
|
|
14
|
+
|
|
15
|
+
const { Resolver } = TYPES;
|
|
16
|
+
|
|
17
|
+
const bitbucketServerModule = new ContainerModule((bind: interfaces.Bind) => {
|
|
18
|
+
bind(Resolver).to(BitbucketServerResolver).inSingletonScope();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export { bitbucketServerModule };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
* Copyright (c) 2023 Red Hat, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made
|
|
5
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
6
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
***********************************************************************/
|
|
10
|
+
|
|
11
|
+
import { BitbucketServerUrl } from './bitbucket-server-url';
|
|
12
|
+
import { injectable } from 'inversify';
|
|
13
|
+
import { Url } from '../resolve/url';
|
|
14
|
+
import { Resolver } from '../resolve/resolver';
|
|
15
|
+
|
|
16
|
+
@injectable()
|
|
17
|
+
export class BitbucketServerResolver implements Resolver {
|
|
18
|
+
// eslint-disable-next-line max-len
|
|
19
|
+
static readonly BITBUCKET_URL_PATTERNS: RegExp[] = [
|
|
20
|
+
/^(?<scheme>https?):\/\/(?<host>.*)\/scm\/~(?<user>[^\/]+)\/(?<repo>.*).git$/,
|
|
21
|
+
/^(?<scheme>https?):\/\/(?<host>.*)\/users\/(?<user>[^\/]+)\/repos\/(?<repo>[^\/]+)\/browse(\?at=(?<branch>.*))?$/,
|
|
22
|
+
/^(?<scheme>https?):\/\/(?<host>.*)\/scm\/(?<project>[^\/~]+)\/(?<repo>[^\/]+).git$/,
|
|
23
|
+
/^(?<scheme>https?):\/\/(?<host>.*)\/projects\/(?<project>[^\/]+)\/repos\/(?<repo>[^\/]+)\/browse(\?at=(?<branch>.*))?$/,
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
isValid(url: string): boolean {
|
|
27
|
+
return BitbucketServerResolver.BITBUCKET_URL_PATTERNS.some(p => p.test(url));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
resolve(url: string): Url {
|
|
31
|
+
const regExp = BitbucketServerResolver.BITBUCKET_URL_PATTERNS.find(p => p.test(url));
|
|
32
|
+
if (!regExp) {
|
|
33
|
+
throw new Error(`Invalid bitbucket-server URL: ${url}`);
|
|
34
|
+
}
|
|
35
|
+
const match = regExp.exec(url);
|
|
36
|
+
const scheme = this.getGroup(match, 'scheme');
|
|
37
|
+
const hostName = this.getGroup(match, 'host');
|
|
38
|
+
const user = this.getGroup(match, 'user');
|
|
39
|
+
const project = this.getGroup(match, 'project');
|
|
40
|
+
const repo = this.getGroup(match, 'repo');
|
|
41
|
+
let branch = this.getGroup(match, 'branch');
|
|
42
|
+
if (branch !== undefined && branch.startsWith('refs%2Fheads%2F')) {
|
|
43
|
+
branch = branch.substring(15);
|
|
44
|
+
}
|
|
45
|
+
return new BitbucketServerUrl(scheme, hostName, user, project, repo, branch);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private getGroup(match: RegExpExecArray, groupName: string): string | undefined {
|
|
49
|
+
if (match.groups && match.groups[groupName]) {
|
|
50
|
+
return match.groups[groupName];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
* Copyright (c) 2023 Red Hat, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made
|
|
5
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
6
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
***********************************************************************/
|
|
10
|
+
|
|
11
|
+
import { Url } from '../resolve/url';
|
|
12
|
+
|
|
13
|
+
export class BitbucketServerUrl implements Url {
|
|
14
|
+
constructor(
|
|
15
|
+
private readonly scheme: string,
|
|
16
|
+
private readonly hostName: string,
|
|
17
|
+
private readonly user: string | undefined,
|
|
18
|
+
private readonly project: string | undefined,
|
|
19
|
+
private readonly repo: string,
|
|
20
|
+
private readonly branch: string | undefined
|
|
21
|
+
) {}
|
|
22
|
+
|
|
23
|
+
getContentUrl(path: string): string {
|
|
24
|
+
const isUser = this.user !== undefined;
|
|
25
|
+
return `${this.scheme}://${this.hostName}/${isUser ? 'users' : 'projects'}/${
|
|
26
|
+
isUser ? this.user : this.project
|
|
27
|
+
}/repos/${this.repo}/raw/${path}${this.branch !== undefined ? '?/at=' + this.branch : ''}`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getUrl(): string {
|
|
31
|
+
const isUser = this.user !== undefined;
|
|
32
|
+
return `${this.scheme}://${this.hostName}/${isUser ? 'users' : 'projects'}/${
|
|
33
|
+
isUser ? this.user : this.project
|
|
34
|
+
}/repos/${this.repo}${this.branch !== undefined ? '/browse?at=' + this.branch : ''}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
getCloneUrl(): string {
|
|
38
|
+
const isUser = this.user !== undefined;
|
|
39
|
+
return `${this.scheme}://${this.hostName}/scm/${isUser ? '~' + this.user : this.project.toLowerCase()}/${
|
|
40
|
+
this.repo
|
|
41
|
+
}.git`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
getRepoName(): string {
|
|
45
|
+
return this.repo;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
getBranchName(): string {
|
|
49
|
+
return this.branch;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -10,14 +10,26 @@
|
|
|
10
10
|
|
|
11
11
|
import { DevfileContext } from '../api/devfile-context';
|
|
12
12
|
import { V1alpha2DevWorkspaceSpecTemplateComponents } from '@devfile/api';
|
|
13
|
-
import { injectable } from 'inversify';
|
|
13
|
+
import { inject, injectable } from 'inversify';
|
|
14
|
+
import { DevContainerComponentInserter } from './dev-container-component-inserter';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Need to find dev container from main dev workspace
|
|
17
18
|
*/
|
|
18
19
|
@injectable()
|
|
19
20
|
export class DevContainerComponentFinder {
|
|
20
|
-
|
|
21
|
+
@inject(DevContainerComponentInserter)
|
|
22
|
+
private devContainerComponentInserter: DevContainerComponentInserter;
|
|
23
|
+
|
|
24
|
+
async find(
|
|
25
|
+
devfileContext: DevfileContext,
|
|
26
|
+
injectDefaultComponent?: string,
|
|
27
|
+
defaultComponentImage?: string
|
|
28
|
+
): Promise<V1alpha2DevWorkspaceSpecTemplateComponents | undefined> {
|
|
29
|
+
// if a devfile contains a parent, we should not add a default dev container
|
|
30
|
+
if (devfileContext.devfile?.parent) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
21
33
|
// search in main devWorkspace
|
|
22
34
|
const devComponents = devfileContext.devWorkspace.spec?.template?.components
|
|
23
35
|
?.filter(component => component.container)
|
|
@@ -26,9 +38,16 @@ export class DevContainerComponentFinder {
|
|
|
26
38
|
component => component.container && component.container.mountSources !== false
|
|
27
39
|
);
|
|
28
40
|
|
|
29
|
-
// only one, fine, else error
|
|
30
41
|
if (!devComponents || devComponents.length === 0) {
|
|
31
|
-
|
|
42
|
+
// do not inject a default component if injectDefaultComponent parameter is false
|
|
43
|
+
if (!injectDefaultComponent || injectDefaultComponent !== 'true') {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
this.devContainerComponentInserter.insert(devfileContext, defaultComponentImage);
|
|
47
|
+
|
|
48
|
+
let devComponents = devfileContext.devWorkspace.spec.template.components.filter(component => component.container);
|
|
49
|
+
|
|
50
|
+
return devComponents[0];
|
|
32
51
|
} else if (devComponents.length === 1) {
|
|
33
52
|
return devComponents[0];
|
|
34
53
|
} else {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
* Copyright (c) 2023 Red Hat, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made
|
|
5
|
+
* available under the terms of the Eclipse Public License 2.0
|
|
6
|
+
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
|
7
|
+
*
|
|
8
|
+
* SPDX-License-Identifier: EPL-2.0
|
|
9
|
+
***********************************************************************/
|
|
10
|
+
|
|
11
|
+
import { DevfileContext } from '../api/devfile-context';
|
|
12
|
+
import { V1alpha2DevWorkspaceSpecTemplateComponents } from '@devfile/api';
|
|
13
|
+
import { injectable } from 'inversify';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Adds a new component on empty devfile with specific name and image
|
|
17
|
+
*/
|
|
18
|
+
@injectable()
|
|
19
|
+
export class DevContainerComponentInserter {
|
|
20
|
+
readonly DEFAULT_DEV_CONTAINER_IMAGE = 'quay.io/devfile/universal-developer-image:ubi8-latest';
|
|
21
|
+
readonly DEFAULT_DEV_CONTAINER_NAME = 'dev';
|
|
22
|
+
|
|
23
|
+
async insert(devfileContext: DevfileContext, defaultComponentImage?: string): Promise<void> {
|
|
24
|
+
if (!devfileContext.devWorkspace.spec) {
|
|
25
|
+
devfileContext.devWorkspace.spec = {
|
|
26
|
+
started: true,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (!devfileContext.devWorkspace.spec.template) {
|
|
30
|
+
devfileContext.devWorkspace.spec.template = {};
|
|
31
|
+
}
|
|
32
|
+
if (!devfileContext.devWorkspace.spec.template.components) {
|
|
33
|
+
devfileContext.devWorkspace.spec.template.components = [];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const devContainerImage = defaultComponentImage ? defaultComponentImage : this.DEFAULT_DEV_CONTAINER_IMAGE;
|
|
37
|
+
console.log(
|
|
38
|
+
`No container component has been found. A default container component with image ${devContainerImage} will be added.`
|
|
39
|
+
);
|
|
40
|
+
const devContainerComponent: V1alpha2DevWorkspaceSpecTemplateComponents = {
|
|
41
|
+
name: this.DEFAULT_DEV_CONTAINER_NAME,
|
|
42
|
+
container: {
|
|
43
|
+
image: devContainerImage,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
devfileContext.devWorkspace.spec.template.components.push(devContainerComponent);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -10,9 +10,11 @@
|
|
|
10
10
|
import { ContainerModule, interfaces } from 'inversify';
|
|
11
11
|
|
|
12
12
|
import { DevContainerComponentFinder } from './dev-container-component-finder';
|
|
13
|
+
import { DevContainerComponentInserter } from './dev-container-component-inserter';
|
|
13
14
|
|
|
14
15
|
const devfileModule = new ContainerModule((bind: interfaces.Bind) => {
|
|
15
16
|
bind(DevContainerComponentFinder).toSelf().inSingletonScope();
|
|
17
|
+
bind(DevContainerComponentInserter).toSelf().inSingletonScope();
|
|
16
18
|
});
|
|
17
19
|
|
|
18
20
|
export { devfileModule };
|