Skip to content

Commit 50bca59

Browse files
authored
Merge pull request #1100 from DivanteLtd/develop
develop -> master (1.0RC3)
2 parents 7acbd41 + 36c8546 commit 50bca59

File tree

185 files changed

+8729
-21028
lines changed

Some content is hidden

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

185 files changed

+8729
-21028
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ core/resource/.ig_feed.json.icloud
1919
core/resource/.order.json.icloud
2020
core/resource/.promoted_offers.json.icloud
2121
core/resource/.slider.json.icloud
22+
yarn-error.log
23+
package-lock.json

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ cache:
99

1010
script:
1111
- yarn lint
12-
- yarn unit
12+
# - yarn unit
1313
- yarn build

config/default.json

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,38 @@
11
{
2+
"server": {
3+
"host": "localhost",
4+
"port": 3000
5+
},
26
"elasticsearch": {
37
"httpAuth": "",
48
"host": "localhost:8080/api/catalog",
59
"index": "vue_storefront_catalog"
610
},
11+
"ssr": {
12+
"executeMixedinAsyncData": true
13+
},
14+
"entities": {
15+
"optimize": true,
16+
"twoStageCaching": true,
17+
"category": {
18+
"includeFields": [ "children_data", "id", "children_count", "sku", "name", "is_active", "parent_id", "level" ]
19+
},
20+
"attribute": {
21+
"includeFields": [ "attribute_code", "id", "entity_type_id", "options", "default_value", "is_user_defined", "frontend_label", "attribute_id", "default_frontend_label", "is_visible_on_front", "is_visible", "is_comparable" ]
22+
},
23+
"productList": {
24+
"includeFields": [ "type_id", "sku", "name", "price", "priceInclTax", "originalPriceInclTax", "id", "image", "sale", "new" ],
25+
"excludeFields": [ "configurable_children", "description", "configurable_options", "sgn", "tax_class_id" ]
26+
},
27+
"productListWithChildren": {
28+
"includeFields": [ "type_id", "sku", "name", "price", "priceInclTax", "originalPriceInclTax", "id", "image", "sale", "new", "configurable_children.image", "configurable_children.sku", "configurable_children.price", "configurable_children.special_price", "configurable_children.priceInclTax", "configurable_children.specialPriceInclTax", "configurable_children.originalPrice", "configurable_children.originalPriceInclTax", "configurable_children.color", "configurable_children.size" ],
29+
"excludeFields": [ "description", "sgn", "tax_class_id" ]
30+
},
31+
"product": {
32+
"excludeFields": [ "updated_at", "created_at", "attribute_set_id", "status", "visibility", "tier_prices", "options_container", "url_key", "msrp_display_actual_price_type", "has_options", "stock.manage_stock", "stock.use_config_min_qty", "stock.use_config_notify_stock_qty", "stock.stock_id", "stock.use_config_backorders", "stock.use_config_enable_qty_inc", "stock.enable_qty_increments", "stock.use_config_manage_stock", "stock.use_config_min_sale_qty", "stock.notify_stock_qty", "stock.use_config_max_sale_qty", "stock.use_config_max_sale_qty", "stock.qty_increments", "small_image"],
33+
"includeFields": null
34+
}
35+
},
736
"cart": {
837
"synchronize": false,
938
"synchronize_totals": false,
@@ -24,16 +53,26 @@
2453
"alwaysSyncPlatformPricesOver": false,
2554
"clearPricesBeforePlatformSync": false,
2655
"waitForPlatformSync": false,
56+
"setupVariantByAttributeCode": false,
2757
"endpoint": "http://localhost:8080/api/product",
28-
"defaultFilters": ["color", "size", "price", "erin_recommends"]
58+
"defaultFilters": ["color", "size", "price", "erin_recommends"],
59+
"galleryVariantsGroupAttribute": "color"
2960
},
3061
"orders": {
3162
"endpoint": "http://localhost:8080/api/order",
3263
"payment_methods_mapping": {
3364
}
3465
},
3566
"users": {
36-
"endpoint": "http://localhost:8080/api/user"
67+
"autoRefreshTokens": true,
68+
"endpoint": "http://localhost:8080/api/user",
69+
"history_endpoint": "http://localhost:8080/api/user/order-history?token={{token}}",
70+
"resetPassword_endpoint": "http://localhost:8080/api/user/resetPassword",
71+
"changePassword_endpoint": "http://localhost:8080/api/user/changePassword?token={{token}}",
72+
"login_endpoint": "http://localhost:8080/api/user/login",
73+
"create_endpoint": "http://localhost:8080/api/user/create",
74+
"me_endpoint": "http://localhost:8080/api/user/me?token={{token}}",
75+
"refresh_endpoint": "http://localhost:8080/api/user/refresh"
3776
},
3877
"stock": {
3978
"synchronize": true,
@@ -57,7 +96,7 @@
5796
"i18n": {
5897
"defaultCountry": "US",
5998
"defaultLanguage": "EN",
60-
"availableLocale": ["en-US","de-DE","fr-FR","es-ES","nl-NL"],
99+
"availableLocale": ["en-US","de-DE","fr-FR","es-ES","nl-NL", "jp-JP", "ru-RU", "it-IT"],
61100
"defaultLocale": "en-US",
62101
"currencyCode": "USD",
63102
"currencySign": "$",
@@ -72,5 +111,5 @@
72111
},
73112
"stripe": {
74113
"api_key": "my_example_api_key"
75-
}
114+
}
76115
}

core/app.js

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,41 @@
1+
if (!global.$VS) global.$VS = {}
2+
3+
import _ from 'lodash'
14
import Vue from 'vue'
25
import App from 'theme/App'
3-
import store from 'core/store'
6+
import store from '@vue-storefront/store'
47
import router from 'core/router'
58
import config from 'config'
69
import appExtend from 'theme/app-extend'
710
import { sync } from 'vuex-router-sync'
11+
import themeModules from 'theme/store'
12+
import EventBus from 'core/plugins/event-bus'
813

914
import { registerTheme, plugins, mixins, filters } from 'core/lib/themes'
1015
import registerExtensions from 'core/lib/extensions'
1116
import extensionEntryPoints from 'src/extensions'
17+
import themeExtensionEntryPoints from 'theme/extensions'
1218

1319
import VueLazyload from 'vue-lazyload'
1420
import Vuelidate from 'vuelidate'
1521
import Meta from 'vue-meta'
1622
import i18n from 'core/lib/i18n'
23+
import VueOffline from 'vue-offline'
24+
import shippingMethods from 'core/resource/shipping_methods.json'
25+
26+
if (themeModules) {
27+
for (const moduleName of Object.keys(themeModules)) {
28+
console.log('Registering custom, theme Vuex store as module', moduleName)
29+
store.registerModule(moduleName, themeModules[moduleName])
30+
}
31+
}
32+
33+
store.init(config, i18n, EventBus)
1734

1835
Vue.use(Vuelidate)
1936
Vue.use(VueLazyload, {attempt: 2})
2037
Vue.use(Meta)
38+
Vue.use(VueOffline)
2139

2240
const pluginsObject = plugins()
2341
Object.keys(pluginsObject).forEach(function (key) {
@@ -46,7 +64,7 @@ export function createApp () {
4664
})
4765

4866
registerExtensions(
49-
extensionEntryPoints,
67+
_.union(extensionEntryPoints, themeExtensionEntryPoints),
5068
app,
5169
router,
5270
store,
@@ -58,17 +76,19 @@ export function createApp () {
5876
app.$emit('application-after-init', app)
5977

6078
if (config.demomode === true) {
61-
global.__DEMO_MODE__ = true
79+
global.$VS.__DEMO_MODE__ = true
6280
} else {
63-
global.__DEMO_MODE__ = false
81+
global.$VS.__DEMO_MODE__ = false
6482
}
6583

66-
global.__VERSION__ = '0.2.0'
67-
global.__CONFIG__ = config
68-
global.__TAX_COUNTRY__ = config.tax.defaultCountry || 'PL'
69-
global.__TAX_REGION__ = config.tax.defaultRegion || ''
70-
global.__I18N_COUNTRY__ = config.i18n.defaultCountry || 'US'
71-
global.__I18N_LANG__ = config.i18n.defaultLanguage || 'EN'
84+
global.$VS.__VERSION__ = '1.0.0-rc2s.0'
85+
global.$VS.__CONFIG__ = config
86+
global.$VS.__TAX_COUNTRY__ = config.tax.defaultCountry || 'PL'
87+
global.$VS.__TAX_REGION__ = config.tax.defaultRegion || ''
88+
global.$VS.__I18N_COUNTRY__ = config.i18n.defaultCountry || 'US'
89+
global.$VS.__I18N_LANG__ = config.i18n.defaultLanguage || 'EN'
90+
91+
store.state.shipping.methods = shippingMethods
7292

7393
return { app, router, store }
7494
}

core/build/webpack.base.config.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const themesRoot = '../../src/themes'
1616

1717
const themeRoot = require('./theme-path')
1818
const themeComponents = themeRoot + '/components'
19+
const themeExtensions = themeRoot + '/extensions'
1920
const themePages = themeRoot + '/pages'
2021
const themePlugins = themeRoot + '/plugins'
2122
const themeFilters = themeRoot + '/filters'
@@ -68,7 +69,6 @@ module.exports = {
6869
'core/plugins': path.resolve(__dirname, '../plugins'),
6970
'core/resource': path.resolve(__dirname, '../resource'),
7071
'core/router': path.resolve(__dirname, '../router'),
71-
'core/store': path.resolve(__dirname, '../store'),
7272
// Theme aliases
7373
'theme': themeRoot,
7474
'theme/app': themeApp,
@@ -79,7 +79,8 @@ module.exports = {
7979
'theme/pages': themePages,
8080
'theme/plugins': themePlugins,
8181
'theme/resource': themeResources,
82-
'theme/store': themeStores
82+
'theme/store': themeStores,
83+
'theme/extensions': themeExtensions
8384
}
8485
},
8586
output: {
@@ -88,12 +89,13 @@ module.exports = {
8889
filename: '[name].[hash].js'
8990
},
9091
module: {
91-
rules: [{
92-
enforce: 'pre',
93-
test: /\.(js|vue)$/,
94-
loader: 'eslint-loader',
95-
exclude: /node_modules/
96-
},
92+
rules: [
93+
{
94+
enforce: 'pre',
95+
test: /\.(js|vue)$/,
96+
loader: 'eslint-loader',
97+
exclude: /node_modules/
98+
},
9799
{
98100
test: /\.vue$/,
99101
loader: 'vue-loader',
@@ -136,6 +138,10 @@ module.exports = {
136138
}
137139
}
138140
]
141+
},
142+
{
143+
test: /\.(woff|woff2|eot|ttf)(\?.*$|$)/,
144+
loader: 'url-loader?importLoaders=1&limit=10000'
139145
}
140146
]
141147
}

core/build/webpack.client.config.js

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ const HTMLPlugin = require('html-webpack-plugin')
66
const SWPrecachePlugin = require('sw-precache-webpack-plugin')
77
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
88
const path = require('path')
9+
const fs = require('fs')
10+
const themeDirectory = require('./theme-path')
11+
const themedIndex = path.join(themeDirectory, 'index.template.html')
912

1013
const config = merge(base, {
1114
resolve: {
@@ -25,7 +28,7 @@ const config = merge(base, {
2528
}),
2629
// generate output HTML
2730
new HTMLPlugin({
28-
template: 'src/index.template.html'
31+
template: fs.existsSync(themedIndex) ? themedIndex : 'src/index.template.html'
2932
})
3033
]
3134
})
@@ -43,24 +46,43 @@ if (process.env.NODE_ENV === 'production') {
4346
'dist/**.*',
4447
'assets/**.*',
4548
'assets/ig/**.*',
46-
'index.html'
49+
'index.html',
50+
'/'
4751
],
4852
runtimeCaching: [
49-
{
53+
{
54+
urlPattern: "^https://fonts\.googleapis\.com/", /** cache the html stub */
55+
handler: "cacheFirst"
56+
},
57+
{
58+
urlPattern: "^https://fonts\.gstatic\.com/", /** cache the html stub */
59+
handler: "cacheFirst"
60+
},
61+
{
62+
urlPattern: "^https://unpkg\.com/", /** cache the html stub */
63+
handler: "cacheFirst"
64+
},
65+
{
5066
urlPattern: "/pwa.html", /** cache the html stub */
51-
handler: "networkFirst"
67+
handler: "fastest"
68+
},{
69+
urlPattern: "/", /** cache the html stub for homepage */
70+
handler: "fastest"
5271
},
5372
{
5473
urlPattern: "/p/*", /** cache the html stub */
55-
handler: "networkFirst"
74+
handler: "fastest"
5675
},
5776
{
5877
urlPattern: "/c/*", /** cache the html stub */
59-
handler: "networkFirst"
78+
handler: "fastest"
6079
},
6180
{
6281
urlPattern: "/img/(.*)",
6382
handler: "fastest"
83+
},{
84+
urlPattern: "/api/catalog/*",
85+
handler: "fastest"
6486
},{
6587
urlPattern: "/api/*",
6688
handler: "networkFirst"
@@ -72,29 +94,13 @@ if (process.env.NODE_ENV === 'production') {
7294
handler: "fastest"
7395
},{
7496
urlPattern: "/assets/*",
75-
handler: "networkFirst"
97+
handler: "fastest"
7698
},{
7799
urlPattern: "/assets/ig/(.*)",
78-
handler: "networkFirst"
100+
handler: "fastest"
79101
},{
80102
urlPattern: "/dist/(.*)",
81103
handler: "fastest"
82-
},{
83-
urlPattern:'/api/catalog/*', /** cache products catalog */
84-
method: "post",
85-
options: {
86-
origin: 'http://localhost:8080',
87-
debug: true
88-
},
89-
handler: "networkFirst"
90-
},{
91-
urlPattern:'/api/*', /** cache products catalog */
92-
method: "post",
93-
options: {
94-
origin: 'https://demo.vuestorefront.io/',
95-
debug: true
96-
},
97-
handler: "networkFirst"
98104
}],
99105
"importScripts": ['/service-worker-ext.js'] /* custom logic */
100106
})

core/client-entry.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { createApp } from './app'
22
import config from 'config'
3-
import { execute } from 'core/lib/task'
3+
import { execute } from '@vue-storefront/store/lib/task'
44
import * as localForage from 'localforage'
55
import EventBus from 'core/plugins/event-bus'
66

77
require('./service-worker-registration') // register the service worker
88

99
const { app, router, store } = createApp()
10-
global.isSSR = false
10+
global.$VS.isSSR = false
1111

1212
if (window.__INITIAL_STATE__) {
1313
store.replaceState(window.__INITIAL_STATE__)
@@ -25,7 +25,7 @@ router.onReady(() => {
2525
return next()
2626
}
2727
Promise.all(activated.map(c => { // TODO: update me for mixins support
28-
const components = c.mixins ? Array.from(c.mixins) : []
28+
const components = c.mixins && config.ssr.executeMixedinAsyncData ? Array.from(c.mixins) : []
2929
components.push(c)
3030
Promise.all(components.map(SubComponent => {
3131
if (SubComponent.asyncData) {
@@ -234,12 +234,12 @@ EventBus.$on('user-after-loggedin', (receivedData) => {
234234
})
235235

236236
EventBus.$on('user-before-logout', () => {
237-
store.dispatch('user/logout')
237+
store.dispatch('user/logout', { silent: false })
238238
store.commit('ui/setSubmenu', {
239239
depth: 0
240240
})
241241

242-
const usersCollection = global.db.usersCollection
242+
const usersCollection = global.$VS.db.usersCollection
243243
usersCollection.setItem('current-token', '')
244244

245245
if (store.state.route.path === '/my-account') {

0 commit comments

Comments
 (0)