Skip to content

Commit

Permalink
Merge pull request #3514 in NEXT/platform from ntr/master/component-l…
Browse files Browse the repository at this point in the history
…ibrary-generation-fix to master

* commit '30956f553bc4f7237f26d8a8da3ec9cf7deaada9':
  NTR Fix generation of the static pages
  • Loading branch information
janbuecker committed Jul 5, 2019
2 parents cedfeae + 94656ce commit b13e039
Show file tree
Hide file tree
Showing 7 changed files with 1,906 additions and 1,472 deletions.
1 change: 1 addition & 0 deletions Resources/nuxt-component-library/components/example.vue
Expand Up @@ -213,6 +213,7 @@
const slotsString = Object.keys(slots).reduce((accumulator, slotKey) => {
const slotContent = slots[slotKey];
let slotDefinition = this.component.slots.filter((slot) => {
return slot.name === slotKey;
});
Expand Down
Expand Up @@ -123,7 +123,7 @@ function extractSlots(content) {
isScopedSlot: slotVariables.length > 0,
variables: slotVariables
};
})
});
}

function extractBlocks(file, content) {
Expand All @@ -148,14 +148,18 @@ function extractBlocks(file, content) {

function parseFile(file, importsList) {
const fileName = extractImportFile(importsList)

if (!fileName) {
return {}
return {
slots: [],
blocks: []
};
}
const content = getFileContent(getFullFilePath(file.directory, fileName));

const slots = extractSlots(content).filter((obj, pos, arr) => {
return arr.map(mapObj => mapObj.name).indexOf(obj.name) === pos;
});
}) || [];
const blocks = extractBlocks(file, content);

return {
Expand Down
4 changes: 2 additions & 2 deletions Resources/nuxt-component-library/nuxt.config.js
Expand Up @@ -5,7 +5,7 @@ const fileParser = require(`${__dirname}/lib/file-parser`); // eslint-disable-li
const process = require('process');

function getPathFromRoot(directory) {
const projectRoot = process.env.PROJECT_ROOT || '/Applications/MAMP/htdocs/sw-next-development';
const projectRoot = process.env.PROJECT_ROOT;
return path.join(projectRoot, directory);
}

Expand All @@ -15,7 +15,7 @@ module.exports = {
NODE_ENV: 'development'
},
router: {
mode: 'hash',
mode: 'history',
scrollBehavior() {
return { x: 0, y: 0 };
}
Expand Down
3,285 changes: 1,837 additions & 1,448 deletions Resources/nuxt-component-library/package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions Resources/nuxt-component-library/package.json
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"watch": "nuxt",
"generate": "nuxt generate",
"debug": "node --inspect node_modules/.bin/nuxt"
"debug": "DEBUG='nuxt:*' node --inspect node_modules/.bin/nuxt"
},
"author": "klarstil",
"license": "MIT",
Expand All @@ -17,7 +17,7 @@
"glob": "7.1.3",
"html-loader": "0.5.5",
"node-sass": "4.11.0",
"nuxt": "2.3.4",
"nuxt": "2.8.1",
"pretty": "2.0.0",
"prismjs": "1.15.0",
"sass": "1.17.2",
Expand All @@ -27,6 +27,7 @@
"vue-codemirror": "4.0.5",
"vue-faq-accordion": "1.2.0",
"vue-i18n": "8.1.0",
"vue-prism-component": "1.0.1"
"vue-prism-component": "1.0.1",
"vuex": "3.1.1"
}
}
6 changes: 4 additions & 2 deletions Resources/nuxt-component-library/pages/icons.vue
Expand Up @@ -19,8 +19,10 @@
</template>

<script>
import iconComponents from 'src/app/assets/icons/icons';
const iconNames = iconComponents.map((comp) => comp.name);
export default {
inject: ['iconNames'],
head() {
return {
Expand All @@ -46,7 +48,7 @@
computed: {
icons() {
return this.iconNames.map((iconName) => {
return iconNames.map((iconName) => {
return iconName.replace('icons-', '');
});
}
Expand Down
65 changes: 51 additions & 14 deletions Resources/nuxt-component-library/plugins/shopware.js
@@ -1,19 +1,31 @@
import Vue from 'vue'; // eslint-disable-line import/no-extraneous-dependencies
import Vuex from 'vuex';
import VueI18n from 'vue-i18n';
import enGBMessages from 'src/app/snippet/en-GB.json';
import DeviceHelper from 'src/app/plugin/device-helper.plugin';
import ValidationService from 'src/core/service/validation.service';
import iconComponents from 'src/app/assets/icons/icons';
import VuexModules from 'src/app/state/index';
import EntityStore from 'src/core/data/EntityStore';
import { State } from 'src/core/shopware';
import ShortcutService from 'src/app/service/shortcut.service';

const Shopware = require('src/core/common');
const ContextFactory = require('src/core/factory/context.factory').default;

require('src/app/mixin/index');
require('src/app/directive/index');
require('src/app/filter/index');

// Vue plugins
Vue.use(VueI18n);
Vue.use(DeviceHelper);
Vue.use(Vuex);

const Shopware = require('src/core/common');

// Expose shopware object globally
global.Shopware = Shopware;
window.Shopware = Shopware;

const ContextFactory = require('src/core/factory/context.factory').default;

Shopware.Application.$container.factory('init.context', () => {
return {};
});
Expand All @@ -25,12 +37,9 @@ Shopware.Application.$container.factory('init.contextService', (container) => {
Shopware.Application.$container.factory('service.validationService', () => {
return ValidationService;
});
require('src/app/mixin/index');
require('src/app/directive/index');
require('src/app/filter/index');

function registerBaseComponents(baseComponents, componentFactory) {
const filteredComponents = baseComponents.filter((item) => {
const filteredComponents = baseComponents().filter((item) => {
return item !== undefined;
});

Expand Down Expand Up @@ -62,18 +71,19 @@ directiveRegistry.forEach((directive, name) => {
Vue.directive(name, directive);
});

import iconComponents from 'src/app/assets/icons/icons';

const iconNames = [];

iconComponents.forEach((component) => {
Shopware.Component.register(component.name, component);
iconNames.push(component.name);
});

Shopware.Application.addServiceProvider('iconNames', () => {
return iconNames;
});
Shopware.Application
.addServiceProvider('iconNames', () => {
return iconNames;
})
.addServiceProvider('shortcutService', () => {
return ShortcutService(factoryContainer.shortcut);
});

Shopware.Component.override('sw-error', {
computed: {
Expand Down Expand Up @@ -112,12 +122,39 @@ components.forEach((config) => {
return vueComponent;
});

const stateFactory = Shopware.State;
Object.keys(VuexModules).forEach((storeModule) => {
stateFactory.registerStore(storeModule, VuexModules[storeModule]);
});

function filterStateRegistry(registry) {
const storeModules = {};
registry.forEach((value, key) => {
if (value instanceof EntityStore) {
return;
}

storeModules[key] = value;
});

return storeModules;
}

export default ({ app }) => {
// Apply translations to application
const messages = { 'en-GB': enGBMessages };

const store = new Vuex.Store({
modules: filterStateRegistry(State.getStoreRegistry()),
strict: false
});
State.registerStore('vuex', store);

app.provide = () => {
return Shopware.Application.getContainer('service');
};

app.store = store;
app.i18n = new VueI18n({
locale: 'en-GB',
fallbackLocale: 'en-GB',
Expand Down

0 comments on commit b13e039

Please sign in to comment.