Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function getLatestVersionNumber(bitIds: BitIds, bitId: BitId): BitId {
if (!bitId.getVersion().latest) return bitId;
// If the bitId provided doesn't contain version we want to ignore scope during search always
// otherwise we will have problems finding the version from the bitmap after we export the component
// because we tag with a name without scope but the bitmap contain it with the scope name since it was exported
// without this, we will always just return the first component in the bitmap which is really bad
const ignoreScope = !bitId.hasScope();
const similarIds = ignoreScope ? bitIds.filterWithoutScopeAndVersion(bitId) : bitIds.filterWithoutVersion(bitId);
const allVersionsForId = similarIds.filter(id => id.hasVersion() && !id.isVersionSnap()).map(id => id.version);
// A case when the provided bitId doesn't exists in the array
if (R.isEmpty(allVersionsForId)) {
if (similarIds.length === 1) return similarIds[0];
if (similarIds.length > 1)
throw new Error(`found multiple snaps for ${bitId.toString()}, unable to figure which one is the latest`);
return bitId;
}
const maxVersion = semver.maxSatisfying(allVersionsForId, '*');
if (!maxVersion) {
throw new Error(
`semver was not able to find the highest version among the following: ${allVersionsForId.join(', ')}`
);
}
const bitIdWithMaxVersion = bitId.changeVersion(maxVersion);
const result = ignoreScope ? bitIds.searchWithoutScope(bitIdWithMaxVersion) : bitIds.search(bitIdWithMaxVersion);
if (!result) {
throw new Error(`getLatestVersionNumber failed to find the id ${bitIdWithMaxVersion.toString()} within bitIds`);
function addCustomResolveAliasesToPackageJson(component: Component, links: LinkFileType[]): boolean {
const resolveAliases = links.reduce((acc, link: LinkFileType) => {
if (link.customResolveMapping) Object.assign(acc, link.customResolveMapping);
return acc;
}, {});
if (R.isEmpty(resolveAliases)) return false;
if (!component.packageJsonFile) return false; // e.g. author doesn't have package.json per component
const bitProperty = component.packageJsonFile.getProperty('bit') || {};
bitProperty.resolveAliases = resolveAliases;
return true;
}
public validate(event: any): Promise {
this.logger.debug('Validation process', { event });
const parsed = cleanNulls(event);
if (!parsed || R.isEmpty(parsed)) { return Promise.resolve(null); }
if (!parsed.type) {
this.logger.debug('Type not found.', { parsed });
return Promise.resolve(null);
}
return schemas(parsed, 'activity')
.then(() => parsed)
.catch((err) => {
this.logger.error(err);
return null;
});
}
_renderContent(){
const content = R.isEmpty(this._subEnvs()) ?
[this._renderPlaceholder()] :
[this._renderList(), this._renderSelected()]
return h.div(".content", content)
}
if (!isEmpty(na)) {
tabs.push({
title: 'North America',
render: () => {
return (
{na.map(renderCard(this.props.selectedID, this.props.handleSelection))}
);
},
});
}
if (!isEmpty(eu)) {
tabs.push({
title: 'Europe',
render: () => {
return (
{eu.map(renderCard(this.props.selectedID, this.props.handleSelection))}
);
},
});
}
if (!isEmpty(as)) {
tabs.push({
title: 'Asia',
render: () => {
const TagsCell = ({ thread, source, onDelete, onAdd }) => (
{R.isEmpty(source.tags) ? (
) : (
<div>
</div>
)}
)
.mergeMap((event: IWebHookEvent) => {
const req = event.request;
const payloadStr = R.path(["body", "payload"], req);
if (R.isEmpty(payloadStr)) {
return Promise.resolve(null);
}
const payload = JSON.parse(payloadStr);
let team = payload.team || {};
if (payload.team_id) {
team = {
id: payload.team_id,
};
}
if (payload.type === "event_callback"
&& payload.event.type === "message") {
return Promise.resolve({
channel: payload.event.channel.id,
subtype: "event_callback",
_populateAllPaths() {
if (R.isEmpty(this.paths)) {
Object.keys(this.components).forEach(componentId => {
const component = this.components[componentId];
component.files.forEach(file => {
const relativeToConsumer = component.rootDir
? pathJoinLinux(component.rootDir, file.relativePath)
: file.relativePath;
this.paths[relativeToConsumer] = component.id;
this.pathsLowerCase[relativeToConsumer.toLowerCase()] = component.id;
});
});
}
}
id: normalized.chatID.toString(),
name: normalized.chatID.toString(),
type: 'Person',
};
if (normalized.type === 'Image' || normalized.type === 'Video') {
let mediaType = 'Image';
if (normalized.type === 'Video') {
mediaType = 'Video';
}
activitystreams.object = {
id: normalized.id.toString() || this.createIdentifier(),
type: mediaType,
url: normalized.content,
};
}
if (R.isEmpty(activitystreams.object) && !R.isEmpty(normalized.content)) {
activitystreams.object = {
content: normalized.content,
id: normalized.id.toString() || this.createIdentifier(),
type: 'Note',
};
}
return Promise.resolve(activitystreams);
}
normalize(event, userInformation) {
get tester(): ?Testers {
const testerObj = transformEnvToObject(this._tester);
if (R.isEmpty(testerObj)) return undefined;
return testerObj;
}