0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Updated theme engine check for canary

no issue

Theme engine check only worked with v[NUMBER] API format, added exception for canary
This commit is contained in:
Rish 2019-08-09 19:54:34 +05:30 committed by Rishabh Garg
parent e1c7c3ebe2
commit bc415504f7

View file

@ -14,7 +14,8 @@ const allowedKeys = ['ghost-api'];
* 2.0.0 * 2.0.0
* v2 * v2
* v0.1 * v0.1
* * canary
*
* Goal: Extract major version from input. * Goal: Extract major version from input.
* *
* @param packageJson * @param packageJson
@ -27,13 +28,16 @@ module.exports = (packageJson) => {
// CASE: validate // CASE: validate
if (packageJson.engines['ghost-api']) { if (packageJson.engines['ghost-api']) {
const availableApiVersions = {}; const availableApiVersions = {};
config.get('api:versions:all').forEach((version) => { config.get('api:versions:all').forEach((version) => {
availableApiVersions[semver(semver.coerce(version).version).major] = version; if (version === 'canary') {
availableApiVersions.canary = version;
} else {
availableApiVersions[semver(semver.coerce(version).version).major] = version;
}
}); });
const apiVersion = packageJson.engines['ghost-api']; const apiVersion = packageJson.engines['ghost-api'];
const apiVersionMajor = semver(semver.coerce(apiVersion).version).major; const apiVersionMajor = apiVersion === 'canary' ? 'canary' : semver(semver.coerce(apiVersion).version).major;
if (availableApiVersions[apiVersionMajor]) { if (availableApiVersions[apiVersionMajor]) {
packageJson.engines['ghost-api'] = availableApiVersions[apiVersionMajor]; packageJson.engines['ghost-api'] = availableApiVersions[apiVersionMajor];