This repository has been archived by the owner on Jan 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #372 from DivanteLtd/develop
Release 1.0.0
- Loading branch information
Showing
6 changed files
with
124 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
const merge = require('lodash/merge') | ||
const semverSatisfies = require('semver/functions/satisfies') | ||
|
||
/** | ||
* This is the base configuration for Capybara theme that is common and valid | ||
* for all supported Vue Storefront versions. Any new configuration options | ||
* which will be used in all installations regardless of Vue Storefront | ||
* version should be added here. | ||
*/ | ||
const configBase = { | ||
'theme': '@vue-storefront/theme-capybara', | ||
'products': { | ||
'thumbnails': { | ||
'width': 324, | ||
'height': 489 | ||
} | ||
}, | ||
'cart': { | ||
'thumbnails': { | ||
'width': 210, | ||
'height': 300 | ||
} | ||
}, | ||
'entities': { | ||
'category': { | ||
'categoriesDynamicPrefetch': false | ||
} | ||
}, | ||
'quicklink': { | ||
'enabled': false | ||
} | ||
} | ||
|
||
/** | ||
* This object contains key-value pairs of custom/specific configuration options | ||
* per matching Vue storefront version. Each key is a semver range about Vue | ||
* Storefront version which supports these new options. Each value is a separate | ||
* object cloned from base config and optionally extended by new configuration | ||
* options supported by that particular Vue Storefront version. | ||
*/ | ||
const configVariants = { | ||
'~1.11.0': merge({}, configBase), | ||
'^1.12.0': merge({}, configBase, { | ||
'server': { | ||
'api': 'api-search-query' | ||
}, | ||
'entities': { | ||
'attribute': { | ||
'loadByAttributeMetadata': true | ||
} | ||
}, | ||
'urlModule': { | ||
'enableMapFallbackUrl': true | ||
} | ||
}) | ||
} | ||
|
||
/** | ||
* Find and return first configuration that satisfies semver range for current | ||
* Vue Storefront version. | ||
*/ | ||
module.exports = function (vsfVersion) { | ||
const matchedConfigVersion = Object | ||
.keys(configVariants) | ||
.find(configVersion => semverSatisfies(vsfVersion, configVersion, { includePrerelease: true })) | ||
|
||
return matchedConfigVersion ? configVariants[matchedConfigVersion] : null | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require('fs') | ||
const path = require('path') | ||
const semverInc = require('semver/functions/inc') | ||
|
||
const vsfInstallationDir = path.resolve(__dirname, '..', '..', '..', '..'); | ||
const vsfPackageJsonPath = path.resolve(vsfInstallationDir, 'package.json'); | ||
const themeInstallationDir = path.resolve(__dirname, '..'); | ||
const themeLocalConfigJsPath = path.resolve(themeInstallationDir, 'local.config.js'); | ||
const themeLocalJsonPath = path.resolve(themeInstallationDir, 'local.json'); | ||
|
||
/** | ||
* Supported parameters: | ||
* (no parameter) - Takes Vue Storefront version from package.json from installation directory | ||
* directly as it is defined there and creates local.json configuration. | ||
* --next - Increments Vue Storefront version from package.json to next minor version | ||
* (this is useful if installed Vue Storefront already contains latest changes | ||
* but they are not officially released yet, so version is package.json is still | ||
* the previous one). Incremented Vue Storefront version is then used during | ||
* creation of local.json configuration. | ||
*/ | ||
const parameter = process.argv[2] | ||
|
||
try { | ||
const vsfVersionFromPackageJson = JSON.parse(fs.readFileSync(vsfPackageJsonPath)).version | ||
const vsfVersion = parameter === '--next' | ||
? semverInc(vsfVersionFromPackageJson, 'minor') | ||
: vsfVersionFromPackageJson | ||
|
||
const themeLocalJson = fs.existsSync(themeLocalConfigJsPath) | ||
? require(themeLocalConfigJsPath)(vsfVersion) | ||
: null | ||
|
||
if (themeLocalJson) { | ||
fs.writeFileSync(themeLocalJsonPath, JSON.stringify(themeLocalJson, null, 2)) | ||
} | ||
} catch (e) { | ||
console.error(`Problem with generating local.json configuration\n`, e) | ||
} |