import * as Promise from 'bluebird' import { gte as greaterThanOrEqual, lt as lessThan, valid as isValidVersion } from 'semver' import getCobaltVersion from '@cobalt-engine/get-cov' const NPM_STRUCTURE_MIN_VERSION = '2.0.0' const ZERO_MAJOR_VERSION = 'ZERO_MAJOR_VERSION' export function isBowerStructure (presentationDir: string): Promise { return getCobaltVersion(presentationDir) .then(isBower) } export function isNpmStructure (presentationDir: string): Promise { return getCobaltVersion(presentationDir) .then(isNpm) } export function isMajorZeroStructure (presentationDir: string): Promise { return getCobaltVersion(presentationDir) .then((cobaltVersion: string) => cobaltVersion === ZERO_MAJOR_VERSION) } function isBower(cobaltVersion: string): boolean { return !!isValidVersion(cobaltVersion) && lessThan(cobaltVersion, NPM_STRUCTURE_MIN_VERSION) } function isNpm (cobaltVersion: string): boolean { return !!isValidVersion(cobaltVersion) && greaterThanOrEqual(cobaltVersion, NPM_STRUCTURE_MIN_VERSION) }