Skip to content

Commit 09ef606

Browse files
author
Tomasz Kostuch
authored
Merge pull request vuestorefront#4547 from DivanteLtd/hotfix/v1.12.1
Hotfix/v1.12.1
2 parents dfdb9f5 + 4318282 commit 09ef606

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+504
-215
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.12.1] - 2020.06.22
9+
10+
### Added
11+
12+
- Add `purgeConfig` to default.json and purge-config loader - @gibkigonzo (#4540)
13+
- Load attributes data of attribute-meta for bundled and grouped products - @cewald (#4551)
14+
- Separate theme installation and add it as yarn init:theme or as a step in yarn installer. - @gibkigonzo (4534, #4552)
15+
16+
### Fixed
17+
18+
- use `config.i18n.defaultLocale` as fallback locale instead of `'en-US'` - @gibkigonzo (#4489)
19+
- use Math.abs on raw price - @gibkigonzo (#4521)
20+
- Clears vuex warnings about overriding state by module - @gibkigonzo (#4541)
21+
22+
### Changed / Improved
23+
824
## [1.12.0] - 2020.06.01
925

1026
### Added

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ You can find some tutorials and explanations on our [YouTube channel](https://ww
156156
- [Starter pack for install](https://docs.vuestorefront.io/guide/cookbook/setup.html)
157157
- [Installing on Linux/MacOS](https://docs.vuestorefront.io/guide/installation/linux-mac.html)
158158
- [Installing on Windows](https://docs.vuestorefront.io/guide/installation/windows.html)
159+
- [Installing theme](https://docs.vuestorefront.io/guide/installation/theme.html)
159160
- [How to install and integrate with Magento2](https://docs.vuestorefront.io/guide/installation/magento.html)
160161
- [Production setup](https://docs.vuestorefront.io/guide/installation/production-setup.html)
161162

config/default.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -871,5 +871,17 @@
871871
},
872872
"varnish": {
873873
"enabled":false
874-
}
874+
},
875+
"purgeConfig": [
876+
"server.invalidateCacheKey",
877+
"server.invalidateCacheForwardUrl",
878+
"server.trace",
879+
"redis",
880+
"install",
881+
"expireHeaders",
882+
"fastly",
883+
"nginx",
884+
"varnish",
885+
"cloudflare"
886+
]
875887
}

core/build/purge-config.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const omit = require('lodash/omit')
2+
3+
/**
4+
* clear config properties that shouldn't be visible on frontend
5+
*/
6+
module.exports = function loader(source) {
7+
let config = JSON.parse(source);
8+
9+
const purgeConfig = (config.purgeConfig || []).slice()
10+
11+
config = omit(config, purgeConfig)
12+
13+
delete config['purgeConfig']
14+
15+
return JSON.stringify(config);
16+
}

core/build/theme-path.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ else {
1515
if(!fs.existsSync(themePath)) {
1616
console.error(`
1717
The theme you want to use does not exist.
18-
Please use 'vsf init' or install manualy one of our official themes:
19-
- https://github.com/DivanteLtd/vsf-capybara#--installation
20-
- https://github.com/DivanteLtd/vsf-default#--installation
18+
Please check theme installation: https://docs.vuestorefront.io/guide/installation/theme.html
2119
`)
2220
process.exit(1)
2321
}

core/build/webpack.base.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ export default {
193193
test: /\.(graphqls|gql)$/,
194194
exclude: /node_modules/,
195195
loader: ['graphql-tag/loader']
196+
},
197+
{
198+
test: /core\/build\/config\.json$/,
199+
loader: path.resolve('core/build/purge-config.js')
196200
}
197201
]
198202
}

core/filters/price.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function price (value, storeView) {
3434

3535
const options = { minimumFractionDigits: fractionDigits, maximumFractionDigits: fractionDigits };
3636

37-
let localePrice = Math.abs(Number(value).toLocaleString(defaultLocale, options)).toFixed(2);
37+
let localePrice = Math.abs(value).toLocaleString(defaultLocale, options);
3838

3939
if (currencyDecimal !== '' || currencyGroup !== '') {
4040
localePrice = replaceSeparators(localePrice, { decimal: currencyDecimal, group: currencyGroup }, getLocaleSeparators(defaultLocale));

core/i18n/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ once('__VUE_EXTEND_I18N__', () => {
88
Vue.use(VueI18n)
99
})
1010

11-
const loadedLanguages = ['en-US']
11+
const defaultLocale = config.i18n.defaultLocale || 'en-US'
12+
const loadedLanguages = [defaultLocale]
1213
const i18n = new VueI18n({
13-
locale: config.i18n.bundleAllStoreviewLanguages ? config.i18n.defaultLocale : 'en-US', // set locale
14-
fallbackLocale: 'en-US',
14+
locale: defaultLocale, // set locale
15+
fallbackLocale: defaultLocale,
1516
messages: config.i18n.bundleAllStoreviewLanguages ? require('./resource/i18n/multistoreLanguages.json') : {
16-
'en-US': require('./resource/i18n/en-US.json')
17+
[defaultLocale]: require(`./resource/i18n/${defaultLocale}.json`)
1718
}
1819
})
1920

core/i18n/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vue-storefront/i18n",
3-
"version": "1.12.0",
3+
"version": "1.12.1",
44
"description": "Vue Storefront i18n",
55
"license": "MIT",
66
"main": "index.ts",

core/i18n/scripts/translation.preprocessor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function convertToObject (array) {
1717

1818
module.exports = function (csvDirectories, config = null) {
1919
const currentLocales = currentBuildLocales()
20-
const fallbackLocale = 'en-US'
20+
const fallbackLocale = config.i18n.defaultLocale || 'en-US'
2121
let messages = {}
2222
let languages = []
2323

@@ -43,7 +43,7 @@ module.exports = function (csvDirectories, config = null) {
4343

4444
// create fallback
4545
console.debug(`Writing JSON file fallback: ${fallbackLocale}.json`)
46-
fs.writeFileSync(path.join(__dirname, '../resource/i18n', `${fallbackLocale}.json`), JSON.stringify(messages[fallbackLocale]))
46+
fs.writeFileSync(path.join(__dirname, '../resource/i18n', `${fallbackLocale}.json`), JSON.stringify(messages[fallbackLocale] || {}))
4747

4848
// bundle all messages in one file
4949
if (config && config.i18n.bundleAllStoreviewLanguages) {

core/lib/multistore.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ export async function prepareStoreView (storeCode: string): Promise<StoreView> {
6666
if (storeView.storeCode && config.storeViews.multistore === true && config.storeViews[storeView.storeCode]) {
6767
storeView = merge(storeView, getExtendedStoreviewConfig(config.storeViews[storeView.storeCode]))
6868
}
69-
rootStore.state.user.current_storecode = storeView.storeCode
69+
70+
if (rootStore.state.user) {
71+
rootStore.state.user.current_storecode = storeView.storeCode
72+
}
7073

7174
if (storeViewHasChanged) {
7275
storeView = coreHooksExecutors.beforeStoreViewChanged(storeView)

core/mixins/onBottomScroll.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const isBottomVisible = () => {
1414
}
1515

1616
/**
17-
* By implementing this mixin add "onBottomScroll" mthod in component.
17+
* By implementing this mixin add "onBottomScroll" method in component.
1818
* It will be invoked when view reach the bottom.
1919
*/
2020
export default {

core/modules/breadcrumbs/helpers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { formatCategoryLink } from '@vue-storefront/core/modules/url/helpers'
55
export function parseCategoryPath (categoryPath) {
66
let routesArray = []
77
for (let category of categoryPath) {
8+
if (category.url_path === undefined || category.url_path === null) continue;
89
routesArray.push({
910
name: category.name,
1011
route_link: formatCategoryLink(category)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import config from 'config'
2+
import Product from '@vue-storefront/core/modules/catalog/types/Product'
3+
4+
/**
5+
* Set associated attributes by meta data of product links
6+
*/
7+
export default async function getAttributesFromMetadata (context: any, products: Product[]) {
8+
if (config.entities.attribute.loadByAttributeMetadata) {
9+
context.dispatch('attribute/loadProductAttributes', { products, merge: true }, { root: true })
10+
}
11+
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import setGroupedProduct from './setGroupedProduct'
22
import setBundleProducts from './setBundleProducts'
3+
import getAttributesFromMetadata from './getAttributesFromMetadata'
34

45
export {
56
setGroupedProduct,
6-
setBundleProducts
7+
setBundleProducts,
8+
getAttributesFromMetadata
79
}

core/modules/catalog/helpers/associatedProducts/setBundleProducts.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import Product from '@vue-storefront/core/modules/catalog/types/Product';
2-
import { isBundleProduct } from './..';
1+
import Product from '@vue-storefront/core/modules/catalog/types/Product'
32
import buildQuery from './buildQuery'
43
import setProductLink from './setProductLink'
5-
import { ProductService } from '@vue-storefront/core/data-resolver/ProductService'
64
import getBundleProductPrice from './getBundleProductPrice'
5+
import { isBundleProduct } from './..'
6+
import { ProductService } from '@vue-storefront/core/data-resolver/ProductService'
7+
import { catalogHooksExecutors } from './../../hooks'
78

89
/**
910
* This function prepare all product_links for bundle products.
@@ -30,6 +31,8 @@ export default async function setBundleProducts (product: Product, { includeFiel
3031
}
3132
})
3233

34+
catalogHooksExecutors.afterSetBundleProducts(items)
35+
3336
for (const bundleOption of product.bundle_options) {
3437
for (const productLink of bundleOption.product_links) {
3538
const associatedProduct = items.find((associatedProduct) => associatedProduct.sku === productLink.sku)

core/modules/catalog/helpers/associatedProducts/setGroupedProduct.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import Product from '@vue-storefront/core/modules/catalog/types/Product';
2-
import { isGroupedProduct } from './..';
1+
import Product from '@vue-storefront/core/modules/catalog/types/Product'
32
import buildQuery from './buildQuery'
43
import setProductLink from './setProductLink'
5-
import { ProductService } from '@vue-storefront/core/data-resolver/ProductService'
64
import getGroupedProductPrice from './getGroupedProductPrice'
5+
import { isGroupedProduct } from './..'
6+
import { ProductService } from '@vue-storefront/core/data-resolver/ProductService'
7+
import { catalogHooksExecutors } from './../../hooks'
78

89
/**
910
* This function prepare all product_links for grouped products.
@@ -29,6 +30,8 @@ export default async function setGroupedProduct (product: Product, { includeFiel
2930
}
3031
})
3132

33+
catalogHooksExecutors.afterSetGroupedProduct(items)
34+
3235
for (const productLink of productLinks) {
3336
const associatedProduct = items.find((associatedProduct) => associatedProduct.sku === productLink.linked_product_sku)
3437
setProductLink(productLink, associatedProduct)

core/modules/catalog/hooks/index.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
1-
import { createMutatorHook } from '@vue-storefront/core/lib/hooks'
1+
import { createMutatorHook, createListenerHook } from '@vue-storefront/core/lib/hooks'
22
import Product from '../types/Product';
33

44
const {
55
hook: beforeTaxesCalculatedHook,
66
executor: beforeTaxesCalculatedExecutor
77
} = createMutatorHook<Product[], Product[]>()
88

9+
const {
10+
hook: afterSetBundleProductsHook,
11+
executor: afterSetBundleProductsExecutor
12+
} = createListenerHook<Product[]>()
13+
14+
const {
15+
hook: afterSetGroupedProductHook,
16+
executor: afterSetGroupedProductExecutor
17+
} = createListenerHook<Product[]>()
18+
919
const catalogHooksExecutors = {
10-
beforeTaxesCalculated: beforeTaxesCalculatedExecutor
20+
beforeTaxesCalculated: beforeTaxesCalculatedExecutor,
21+
afterSetBundleProducts: afterSetBundleProductsExecutor,
22+
afterSetGroupedProduct: afterSetGroupedProductExecutor
1123
}
1224

1325
const catalogHooks = {
14-
beforeTaxesCalculated: beforeTaxesCalculatedHook
26+
beforeTaxesCalculated: beforeTaxesCalculatedHook,
27+
afterSetBundleProducts: afterSetBundleProductsHook,
28+
afterSetGroupedProduct: afterSetGroupedProductHook
1529
}
1630

1731
export {

core/modules/catalog/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { attributeModule } from './store/attribute'
44
import { stockModule } from './store/stock'
55
import { taxModule } from './store/tax'
66
import { categoryModule } from './store/category'
7+
import { catalogHooks } from './hooks'
8+
import { getAttributesFromMetadata } from './helpers/associatedProducts'
79
import { StorageManager } from '@vue-storefront/core/lib/storage-manager'
810
import EventBus from '@vue-storefront/core/compatibility/plugins/event-bus'
911
import config from 'config'
@@ -23,6 +25,9 @@ export const CatalogModule: StorefrontModule = async function ({ store, router,
2325
store.registerModule('tax', taxModule)
2426
store.registerModule('category', categoryModule)
2527

28+
catalogHooks.afterSetBundleProducts(products => getAttributesFromMetadata(store, products))
29+
catalogHooks.afterSetGroupedProduct(products => getAttributesFromMetadata(store, products))
30+
2631
if (!config.entities.attribute.loadByAttributeMetadata) {
2732
await store.dispatch('attribute/list', { // loading attributes for application use
2833
filterValues: uniq([...config.products.defaultFilters, ...config.entities.productListWithChildren.includeFields])

core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vue-storefront/core",
3-
"version": "1.12.0",
3+
"version": "1.12.1",
44
"description": "Vue Storefront Core",
55
"license": "MIT",
66
"main": "app.js",

core/scripts/installer.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const isWindows = require('is-windows')
1212
const isEmptyDir = require('empty-dir')
1313
const commandExists = require('command-exists')
1414
const program = require('commander')
15+
const { createThemeTasks, createThemePrompt } = require('./../../packages/cli/themeTasks')
1516

1617
const SAMPLE_DATA_PATH = 'var/magento2-sample-data'
1718
const TARGET_FRONTEND_CONFIG_FILE = 'config/local.json'
@@ -561,6 +562,33 @@ class Storefront extends Abstract {
561562
resolve(answers)
562563
})
563564
}
565+
566+
/**
567+
* Handles all tasks needed to make theme installation
568+
*/
569+
async themeInstallation () {
570+
// get theme tasks
571+
const { installDeps, cloneTheme, configureTheme } = createThemeTasks(STOREFRONT_DIRECTORY.toString())
572+
573+
// put tasks in order
574+
const tasks = [
575+
cloneTheme,
576+
installDeps,
577+
configureTheme
578+
]
579+
580+
for (let { title, task, skip } of tasks) {
581+
Message.info(title)
582+
583+
const skipAnswer = skip ? await skip(this.answers) : ''
584+
585+
if (skipAnswer) {
586+
Message.warning(skipAnswer)
587+
} else {
588+
await task(this.answers)
589+
}
590+
}
591+
}
564592
}
565593

566594
class Manager extends Abstract {
@@ -654,6 +682,7 @@ class Manager extends Abstract {
654682
initStorefront () {
655683
return this.storefront.goToDirectory()
656684
.then(this.storefront.createConfig.bind(this.storefront))
685+
.then(this.storefront.themeInstallation.bind(this.storefront))
657686
.then(this.storefront.depBuild.bind(this.storefront))
658687
.then(this.storefront.runDevEnvironment.bind(this.storefront))
659688
}
@@ -863,7 +892,8 @@ let questions = [
863892
name: 'ssr_endpoints',
864893
message: `Would You like to create fields for SSR endpoints?`,
865894
default: false
866-
}
895+
},
896+
...createThemePrompt(STOREFRONT_DIRECTORY.toString())
867897
]
868898

869899
async function processAnswers (answers) {

0 commit comments

Comments
 (0)