Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #372 from DivanteLtd/develop
Browse files Browse the repository at this point in the history
Release 1.0.0
  • Loading branch information
Tomasz Kostuch authored Jun 2, 2020
2 parents 1202f53 + 6db48e1 commit b800005
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 37 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.0-rc.2] - UNRELEASED
## [1.0.0] - 2020.06.02

### Added
### Changed / Improved

- Support theme configuration via CLI (#369)
- Update types for `getBundleOptionsValues` (#371)

## [1.0.0-rc.2] - 2020-05-13

### Added

Expand Down
2 changes: 1 addition & 1 deletion helpers/price.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function calculateBundleOptionsPrice (product) {
const allBundleOptions = product.bundle_options || []
const selectedBundleOptions = Object.values(get(product, 'product_option.extension_attributes.bundle_options', {}))
const price = getBundleOptionPrice(
getBundleOptionsValues(selectedBundleOptions, allBundleOptions)
getBundleOptionsValues(selectedBundleOptions as any[], allBundleOptions)
)

return price.priceInclTax
Expand Down
68 changes: 68 additions & 0 deletions local.config.js
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
};
32 changes: 0 additions & 32 deletions local.json

This file was deleted.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"name": "@vue-storefront/theme-capybara",
"version": "1.0.0-rc.2",
"version": "1.0.0",
"description": "New theme for Vue Storefront based on Storefront UI",
"main": "index.js",
"scripts": {
"test:unit": "echo \"No test specified yet\" && exit 0",
"lint": "cd ../../../ && yarn lint",
"dev": "cd ../../../ && yarn dev"
"dev": "cd ../../../ && yarn dev",
"generate-local-config": "node ./scripts/generate-local-config",
"generate-local-config:next": "yarn generate-local-config --next"
},
"license": "MIT",
"dependencies": {
Expand All @@ -25,7 +27,8 @@
},
"devDependencies": {
"husky": "^3.1.0",
"postcss-filter-stream": "^0.0.6"
"postcss-filter-stream": "^0.0.6",
"semver": "^7.3.2"
},
"sideEffects": [
"*.(sc|sa|c)?ss",
Expand Down
40 changes: 40 additions & 0 deletions scripts/generate-local-config.js
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)
}

0 comments on commit b800005

Please sign in to comment.