@eclipse-che/che-theia-devworkspace-handler
Advanced tools
Comparing version 0.0.1-1636123638 to 0.0.1-1636123823
@@ -16,5 +16,4 @@ /********************************************************************** | ||
export declare class DevContainerComponentFinder { | ||
static readonly DEV_CONTAINER_ATTRIBUTE = "che-theia.eclipse.org/dev-container"; | ||
find(devfileContext: DevfileContext): Promise<V1alpha2DevWorkspaceSpecTemplateComponents>; | ||
} | ||
//# sourceMappingURL=dev-container-component-finder.d.ts.map |
@@ -17,3 +17,2 @@ "use strict"; | ||
}; | ||
var DevContainerComponentFinder_1; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -25,22 +24,8 @@ exports.DevContainerComponentFinder = void 0; | ||
*/ | ||
let DevContainerComponentFinder = DevContainerComponentFinder_1 = class DevContainerComponentFinder { | ||
let DevContainerComponentFinder = class DevContainerComponentFinder { | ||
async find(devfileContext) { | ||
// need to find definition | ||
var _a, _b, _c, _d, _e, _f; | ||
// first search if we have an optional annotated container | ||
const annotatedContainers = (_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(component => component.attributes && | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
component.attributes[DevContainerComponentFinder_1.DEV_CONTAINER_ATTRIBUTE] === true); | ||
if (annotatedContainers) { | ||
if (annotatedContainers.length === 1) { | ||
return annotatedContainers[0]; | ||
} | ||
else if (annotatedContainers.length > 1) { | ||
throw new Error(`Only one container can be annotated with ${DevContainerComponentFinder_1.DEV_CONTAINER_ATTRIBUTE}: true`); | ||
} | ||
} | ||
var _a, _b, _c; | ||
// search in main devWorkspace (exclude theia as component name) | ||
const devComponents = (_f = (_e = (_d = devfileContext.devWorkspace.spec) === null || _d === void 0 ? void 0 : _d.template) === null || _e === void 0 ? void 0 : _e.components) === null || _f === void 0 ? void 0 : _f.filter(component => component.container && component.name !== 'theia-ide').filter( | ||
// we should ignore component that do not mount the sources | ||
component => component.container && component.container.mountSources !== false); | ||
const 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(component => component.container && component.name !== 'theia-ide'); | ||
// only one, fine, else error | ||
@@ -54,9 +39,7 @@ if (!devComponents || devComponents.length === 0) { | ||
else { | ||
console.warn(`More than one dev container component has been potentially found, taking the first one of ${devComponents.map(component => component.name)}`); | ||
return devComponents[0]; | ||
throw new Error(`Too many components have been found that could be considered as dev container. There should be only one to merge sidecars. Found component names: ${devComponents.map(component => component.name)}`); | ||
} | ||
} | ||
}; | ||
DevContainerComponentFinder.DEV_CONTAINER_ATTRIBUTE = 'che-theia.eclipse.org/dev-container'; | ||
DevContainerComponentFinder = DevContainerComponentFinder_1 = __decorate([ | ||
DevContainerComponentFinder = __decorate([ | ||
inversify_1.injectable() | ||
@@ -63,0 +46,0 @@ ], DevContainerComponentFinder); |
{ | ||
"name": "@eclipse-che/che-theia-devworkspace-handler", | ||
"version": "0.0.1-1636123638", | ||
"version": "0.0.1-1636123823", | ||
"private": false, | ||
@@ -16,3 +16,3 @@ "description": "Handle management of che-theia-plugins and devWorkspace templates", | ||
"clean": "rimraf lib", | ||
"build": "yarn run format && yarn run compile && yarn run lint && yarn run test", | ||
"build": "yarn run format && yarn run compile && yarn run lint", | ||
"compile": "tsc --project .", | ||
@@ -19,0 +19,0 @@ "format": "if-env SKIP_FORMAT=true && echo 'skip format check' || prettier --check '{src,tests}/**/*.ts' package.json", |
@@ -20,32 +20,9 @@ /********************************************************************** | ||
export class DevContainerComponentFinder { | ||
public static readonly DEV_CONTAINER_ATTRIBUTE = 'che-theia.eclipse.org/dev-container'; | ||
async find(devfileContext: DevfileContext): Promise<V1alpha2DevWorkspaceSpecTemplateComponents> { | ||
// need to find definition | ||
// first search if we have an optional annotated container | ||
const annotatedContainers = devfileContext.devWorkspace.spec?.template?.components?.filter( | ||
component => | ||
component.attributes && | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(component.attributes as any)[DevContainerComponentFinder.DEV_CONTAINER_ATTRIBUTE] === true | ||
// search in main devWorkspace (exclude theia as component name) | ||
const devComponents = devfileContext.devWorkspace.spec?.template?.components?.filter( | ||
component => component.container && component.name !== 'theia-ide' | ||
); | ||
if (annotatedContainers) { | ||
if (annotatedContainers.length === 1) { | ||
return annotatedContainers[0]; | ||
} else if (annotatedContainers.length > 1) { | ||
throw new Error( | ||
`Only one container can be annotated with ${DevContainerComponentFinder.DEV_CONTAINER_ATTRIBUTE}: true` | ||
); | ||
} | ||
} | ||
// search in main devWorkspace (exclude theia as component name) | ||
const devComponents = devfileContext.devWorkspace.spec?.template?.components | ||
?.filter(component => component.container && component.name !== 'theia-ide') | ||
.filter( | ||
// we should ignore component that do not mount the sources | ||
component => component.container && component.container.mountSources !== false | ||
); | ||
// only one, fine, else error | ||
@@ -57,10 +34,9 @@ if (!devComponents || devComponents.length === 0) { | ||
} else { | ||
console.warn( | ||
`More than one dev container component has been potentially found, taking the first one of ${devComponents.map( | ||
throw new Error( | ||
`Too many components have been found that could be considered as dev container. There should be only one to merge sidecars. Found component names: ${devComponents.map( | ||
component => component.name | ||
)}` | ||
); | ||
return devComponents[0]; | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
200951
3246