From 23a6be121953cc32fb7836f055729003cb37875a Mon Sep 17 00:00:00 2001 From: NGPixel Date: Sat, 3 Feb 2018 16:48:25 -0500 Subject: [PATCH] refactor: removed 1.x client files --- .babelrc | 4 + client/js/app.js | 92 +-- client/js/compatibility.js | 11 - client/js/components/alert.vue | 21 - client/js/components/anchor.vue | 55 -- client/js/components/color-picker.vue | 41 -- client/js/components/editor-codeblock.vue | 128 ---- client/js/components/editor-file.vue | 605 ------------------ client/js/components/editor-video.vue | 94 --- client/js/components/editor.component.js | 221 ------- client/js/components/history.vue | 127 ---- client/js/components/loading-spinner.vue | 12 - client/js/components/login.vue | 11 +- client/js/components/modal-create-page.vue | 67 -- client/js/components/modal-create-user.vue | 105 --- client/js/components/modal-delete-page.vue | 66 -- client/js/components/modal-delete-user.vue | 65 -- client/js/components/modal-discard-page.vue | 43 -- client/js/components/modal-move-page.vue | 86 --- client/js/components/modal-profile-2fa.vue | 66 -- client/js/components/modal-upgrade-system.vue | 70 -- client/js/components/page-loader.vue | 23 - client/js/components/search.vue | 103 --- client/js/components/tree.vue | 84 --- client/js/helpers/index.js | 6 +- client/js/helpers/lodash.js | 65 -- client/js/modules/boot.js | 68 ++ client/js/pages/admin-edit-user.component.js | 72 --- client/js/pages/admin-profile.component.js | 43 -- client/js/pages/admin-settings.component.js | 17 - client/js/pages/admin-theme.component.js | 57 -- client/js/pages/content-view.component.js | 19 - client/js/pages/source-view.component.js | 23 - client/js/store/index.js | 30 +- client/js/store/modules/anchor.js | 22 - client/js/store/modules/editor-codeblock.js | 22 - client/js/store/modules/editor-file.js | 22 - client/js/store/modules/editor-video.js | 19 - client/js/store/modules/editor.js | 22 - client/js/store/modules/modal-create-page.js | 14 - client/js/store/modules/modal-create-user.js | 19 - client/js/store/modules/modal-delete-page.js | 14 - client/js/store/modules/modal-delete-user.js | 14 - client/js/store/modules/modal-discard-page.js | 14 - client/js/store/modules/modal-move-page.js | 14 - client/js/store/modules/modal-profile-2fa.js | 19 - .../js/store/modules/modal-upgrade-system.js | 22 - client/js/store/modules/page-loader.js | 15 - dev/{webpack => config}/postcss.config.js | 4 +- dev/webpack/webpack.common.js | 33 +- dev/webpack/webpack.dev.js | 4 + dev/webpack/webpack.prod.js | 37 +- package.json | 9 +- server/master.js | 9 +- wiki.js | 43 +- yarn.lock | 172 +++-- 56 files changed, 307 insertions(+), 2856 deletions(-) delete mode 100644 client/js/components/alert.vue delete mode 100644 client/js/components/anchor.vue delete mode 100644 client/js/components/color-picker.vue delete mode 100644 client/js/components/editor-codeblock.vue delete mode 100644 client/js/components/editor-file.vue delete mode 100644 client/js/components/editor-video.vue delete mode 100644 client/js/components/editor.component.js delete mode 100644 client/js/components/history.vue delete mode 100644 client/js/components/loading-spinner.vue delete mode 100644 client/js/components/modal-create-page.vue delete mode 100644 client/js/components/modal-create-user.vue delete mode 100644 client/js/components/modal-delete-page.vue delete mode 100644 client/js/components/modal-delete-user.vue delete mode 100644 client/js/components/modal-discard-page.vue delete mode 100644 client/js/components/modal-move-page.vue delete mode 100644 client/js/components/modal-profile-2fa.vue delete mode 100644 client/js/components/modal-upgrade-system.vue delete mode 100644 client/js/components/page-loader.vue delete mode 100644 client/js/components/search.vue delete mode 100644 client/js/components/tree.vue delete mode 100644 client/js/helpers/lodash.js create mode 100644 client/js/modules/boot.js delete mode 100644 client/js/pages/admin-edit-user.component.js delete mode 100644 client/js/pages/admin-profile.component.js delete mode 100644 client/js/pages/admin-settings.component.js delete mode 100644 client/js/pages/admin-theme.component.js delete mode 100644 client/js/pages/content-view.component.js delete mode 100644 client/js/pages/source-view.component.js delete mode 100644 client/js/store/modules/anchor.js delete mode 100644 client/js/store/modules/editor-codeblock.js delete mode 100644 client/js/store/modules/editor-file.js delete mode 100644 client/js/store/modules/editor-video.js delete mode 100644 client/js/store/modules/editor.js delete mode 100644 client/js/store/modules/modal-create-page.js delete mode 100644 client/js/store/modules/modal-create-user.js delete mode 100644 client/js/store/modules/modal-delete-page.js delete mode 100644 client/js/store/modules/modal-delete-user.js delete mode 100644 client/js/store/modules/modal-discard-page.js delete mode 100644 client/js/store/modules/modal-move-page.js delete mode 100644 client/js/store/modules/modal-profile-2fa.js delete mode 100644 client/js/store/modules/modal-upgrade-system.js delete mode 100644 client/js/store/modules/page-loader.js rename dev/{webpack => config}/postcss.config.js (71%) diff --git a/.babelrc b/.babelrc index 7f3648ee..cb993f7a 100644 --- a/.babelrc +++ b/.babelrc @@ -1,5 +1,9 @@ { "comments": true, + "plugins": [ + "lodash", + "graphql-tag" + ], "presets": [ ["env"], "stage-2" diff --git a/client/js/app.js b/client/js/app.js index 2932be56..dc8c6b4e 100644 --- a/client/js/app.js +++ b/client/js/app.js @@ -13,12 +13,14 @@ import { ApolloLink } from 'apollo-link' import { createApolloFetch } from 'apollo-fetch' import { BatchHttpLink } from 'apollo-link-batch-http' import { InMemoryCache } from 'apollo-cache-inmemory' +import Hammer from 'hammerjs' import store from './store' // ==================================== // Load Modules // ==================================== +import boot from './modules/boot' import localization from './modules/localization' // ==================================== @@ -27,47 +29,14 @@ import localization from './modules/localization' import helpers from './helpers' -// ==================================== -// Load Vue Components -// ==================================== - -import alertComponent from './components/alert.vue' -import anchorComponent from './components/anchor.vue' -import colorPickerComponent from './components/color-picker.vue' -import editorCodeblockComponent from './components/editor-codeblock.vue' -import editorFileComponent from './components/editor-file.vue' -import editorVideoComponent from './components/editor-video.vue' -import historyComponent from './components/history.vue' -import loadingSpinnerComponent from './components/loading-spinner.vue' -import loginComponent from './components/login.vue' -import modalCreatePageComponent from './components/modal-create-page.vue' -import modalCreateUserComponent from './components/modal-create-user.vue' -import modalDeletePageComponent from './components/modal-delete-page.vue' -import modalDeleteUserComponent from './components/modal-delete-user.vue' -import modalDiscardPageComponent from './components/modal-discard-page.vue' -import modalMovePageComponent from './components/modal-move-page.vue' -import modalProfile2faComponent from './components/modal-profile-2fa.vue' -import modalUpgradeSystemComponent from './components/modal-upgrade-system.vue' -import navigatorComponent from './components/navigator.vue' -import pageLoaderComponent from './components/page-loader.vue' -import searchComponent from './components/search.vue' -import toggleComponent from './components/toggle.vue' -import treeComponent from './components/tree.vue' - -import adminEditUserComponent from './pages/admin-edit-user.component.js' -import adminProfileComponent from './pages/admin-profile.component.js' -import adminSettingsComponent from './pages/admin-settings.component.js' -import adminThemeComponent from './pages/admin-theme.component.js' -import contentViewComponent from './pages/content-view.component.js' -import editorComponent from './components/editor.component.js' -import sourceViewComponent from './pages/source-view.component.js' - // ==================================== // Initialize Global Vars // ==================================== window.wiki = null +window.boot = boot window.CONSTANTS = CONSTANTS +window.Hammer = Hammer // ==================================== // Initialize Apollo Client (GraphQL) @@ -128,38 +97,12 @@ Vue.use(VeeValidate, { // Register Vue Components // ==================================== -Vue.component('alert', alertComponent) -Vue.component('adminEditUser', adminEditUserComponent) -Vue.component('adminProfile', adminProfileComponent) -Vue.component('adminSettings', adminSettingsComponent) -Vue.component('adminTheme', adminThemeComponent) -Vue.component('anchor', anchorComponent) -Vue.component('colorPicker', colorPickerComponent) -Vue.component('contentView', contentViewComponent) -Vue.component('editor', editorComponent) -Vue.component('editorCodeblock', editorCodeblockComponent) -Vue.component('editorFile', editorFileComponent) -Vue.component('editorVideo', editorVideoComponent) -Vue.component('history', historyComponent) -Vue.component('loadingSpinner', loadingSpinnerComponent) -Vue.component('login', loginComponent) -Vue.component('modalCreatePage', modalCreatePageComponent) -Vue.component('modalCreateUser', modalCreateUserComponent) -Vue.component('modalDeletePage', modalDeletePageComponent) -Vue.component('modalDeleteUser', modalDeleteUserComponent) -Vue.component('modalDiscardPage', modalDiscardPageComponent) -Vue.component('modalMovePage', modalMovePageComponent) -Vue.component('modalProfile2fa', modalProfile2faComponent) -Vue.component('modalUpgradeSystem', modalUpgradeSystemComponent) -Vue.component('navigator', navigatorComponent) -Vue.component('pageLoader', pageLoaderComponent) -Vue.component('search', searchComponent) +Vue.component('login', () => import(/* webpackMode: "eager" */ './components/login.vue')) +Vue.component('navigator', () => import(/* webpackMode: "eager" */ './components/navigator.vue')) Vue.component('setup', () => import(/* webpackChunkName: "setup" */ './components/setup.vue')) -Vue.component('sourceView', sourceViewComponent) -Vue.component('toggle', toggleComponent) -Vue.component('tree', treeComponent) +Vue.component('toggle', () => import(/* webpackMode: "eager" */ './components/toggle.vue')) -document.addEventListener('DOMContentLoaded', ev => { +let bootstrap = () => { // ==================================== // Notifications // ==================================== @@ -178,16 +121,15 @@ document.addEventListener('DOMContentLoaded', ev => { components: {}, mixins: [helpers], store, - i18n, - methods: { - changeTheme(opts) { - this.$el.className = `has-stickynav is-primary-${opts.primary} is-alternate-${opts.alt}` - this.$refs.header.className = `nav is-${opts.primary}` - this.$refs.footer.className = `footer is-${opts.footer}` - } - } + i18n }) + // ---------------------------------- + // Dispatch boot ready + // ---------------------------------- + + window.boot.notify('vue') + // ==================================== // Load Icons // ==================================== @@ -195,4 +137,6 @@ document.addEventListener('DOMContentLoaded', ev => { import(/* webpackChunkName: "icons" */ '../svg/icons.svg').then(icons => { document.body.insertAdjacentHTML('beforeend', icons) }) -}) +} + +window.boot.onDOMReady(bootstrap) diff --git a/client/js/compatibility.js b/client/js/compatibility.js index 937ff749..2662a203 100644 --- a/client/js/compatibility.js +++ b/client/js/compatibility.js @@ -1,14 +1,3 @@ -// ======================================= -// Intl polyfill -// ======================================= -// Requirement: Safari 9 and below - -if (!global.Intl) { - require('intl') - require('intl/locale-data/jsonp/en') - require('intl/locale-data/jsonp/fr') -} - // ======================================= // Promise polyfill // ======================================= diff --git a/client/js/components/alert.vue b/client/js/components/alert.vue deleted file mode 100644 index d683209b..00000000 --- a/client/js/components/alert.vue +++ /dev/null @@ -1,21 +0,0 @@ - - - diff --git a/client/js/components/anchor.vue b/client/js/components/anchor.vue deleted file mode 100644 index 29b9b280..00000000 --- a/client/js/components/anchor.vue +++ /dev/null @@ -1,55 +0,0 @@ - - - diff --git a/client/js/components/color-picker.vue b/client/js/components/color-picker.vue deleted file mode 100644 index cb53dd85..00000000 --- a/client/js/components/color-picker.vue +++ /dev/null @@ -1,41 +0,0 @@ - - - diff --git a/client/js/components/editor-codeblock.vue b/client/js/components/editor-codeblock.vue deleted file mode 100644 index 0f215713..00000000 --- a/client/js/components/editor-codeblock.vue +++ /dev/null @@ -1,128 +0,0 @@ - - - diff --git a/client/js/components/editor-file.vue b/client/js/components/editor-file.vue deleted file mode 100644 index 72f290e9..00000000 --- a/client/js/components/editor-file.vue +++ /dev/null @@ -1,605 +0,0 @@ - - - diff --git a/client/js/components/editor-video.vue b/client/js/components/editor-video.vue deleted file mode 100644 index 59988992..00000000 --- a/client/js/components/editor-video.vue +++ /dev/null @@ -1,94 +0,0 @@ - - - diff --git a/client/js/components/editor.component.js b/client/js/components/editor.component.js deleted file mode 100644 index 41c8dc51..00000000 --- a/client/js/components/editor.component.js +++ /dev/null @@ -1,221 +0,0 @@ -/* global $, siteRoot */ - -let mde - -export default { - name: 'editor', - props: ['currentPath'], - data() { - return {} - }, - computed: { - insertContent() { - return this.$store.state.editor.insertContent - } - }, - methods: { - insert(content) { - if (mde.codemirror.doc.somethingSelected()) { - mde.codemirror.execCommand('singleSelection') - } - mde.codemirror.doc.replaceSelection(this.insertContent) - }, - save() { - let self = this - this.$http.put(window.location.href, { - markdown: mde.value() - }).then(resp => { - return resp.json() - }).then(resp => { - if (resp.ok) { - window.location.assign(siteRoot + '/' + self.currentPath) - } else { - self.$store.dispatch('alert', { - style: 'red', - icon: 'ui-2_square-remove-09', - msg: resp.msg - }) - } - }).catch(err => { - self.$store.dispatch('alert', { - style: 'red', - icon: 'ui-2_square-remove-09', - msg: 'Error: ' + err.body.msg - }) - }) - } - }, - mounted() { - let self = this - FuseBox.import('/js/simplemde/simplemde.min.js', (SimpleMDE) => { - mde = new SimpleMDE({ - autofocus: true, - autoDownloadFontAwesome: false, - element: this.$refs.editorTextArea, - placeholder: 'Enter Markdown formatted content here...', - spellChecker: false, - status: false, - toolbar: [ - { - name: 'bold', - action: SimpleMDE.toggleBold, - className: 'icon-bold', - title: 'Bold' - }, - { - name: 'italic', - action: SimpleMDE.toggleItalic, - className: 'icon-italic', - title: 'Italic' - }, - { - name: 'strikethrough', - action: SimpleMDE.toggleStrikethrough, - className: 'icon-strikethrough', - title: 'Strikethrough' - }, - '|', - { - name: 'heading-1', - action: SimpleMDE.toggleHeading1, - className: 'icon-header fa-header-x fa-header-1', - title: 'Header (Level 1)' - }, - { - name: 'heading-2', - action: SimpleMDE.toggleHeading2, - className: 'icon-header fa-header-x fa-header-2', - title: 'Header (Level 2)' - }, - { - name: 'heading-3', - action: SimpleMDE.toggleHeading3, - className: 'icon-header fa-header-x fa-header-3', - title: 'Header (Level 3)' - }, - { - name: 'quote', - action: SimpleMDE.toggleBlockquote, - className: 'nc-icon-outline text_quote', - title: 'Quote' - }, - '|', - { - name: 'unordered-list', - action: SimpleMDE.toggleUnorderedList, - className: 'nc-icon-outline text_list-bullet', - title: 'Bullet List' - }, - { - name: 'ordered-list', - action: SimpleMDE.toggleOrderedList, - className: 'nc-icon-outline text_list-numbers', - title: 'Numbered List' - }, - '|', - { - name: 'link', - action: (editor) => { - window.alert('Coming soon!') - // todo - }, - className: 'nc-icon-outline ui-2_link-68', - title: 'Insert Link' - }, - { - name: 'image', - action: (editor) => { - self.$store.dispatch('editorFile/open', { mode: 'image' }) - }, - className: 'nc-icon-outline design_image', - title: 'Insert Image' - }, - { - name: 'file', - action: (editor) => { - self.$store.dispatch('editorFile/open', { mode: 'file' }) - }, - className: 'nc-icon-outline files_zip-54', - title: 'Insert File' - }, - { - name: 'video', - action: (editor) => { - self.$store.dispatch('editorVideo/open') - }, - className: 'nc-icon-outline media-1_video-64', - title: 'Insert Video Player' - }, - '|', - { - name: 'inline-code', - action: (editor) => { - if (!editor.codemirror.doc.somethingSelected()) { - return self.$store.dispatch('alert', { - style: 'orange', - icon: 'design_drag', - msg: 'Invalid selection. Select at least 1 character.' - }) - } - let curSel = editor.codemirror.doc.getSelections() - curSel = self._.map(curSel, (s) => { - return '`' + s + '`' - }) - editor.codemirror.doc.replaceSelections(curSel) - }, - className: 'nc-icon-outline arrows-4_enlarge-46', - title: 'Inline Code' - }, - { - name: 'code-block', - action: (editor) => { - self.$store.dispatch('editorCodeblock/open', { - initialContent: (mde.codemirror.doc.somethingSelected()) ? mde.codemirror.doc.getSelection() : '' - }) - }, - className: 'nc-icon-outline design_code', - title: 'Code Block' - }, - '|', - { - name: 'table', - action: (editor) => { - window.alert('Coming soon!') - // todo - }, - className: 'nc-icon-outline ui-2_grid-square', - title: 'Insert Table' - }, - { - name: 'horizontal-rule', - action: SimpleMDE.drawHorizontalRule, - className: 'nc-icon-outline design_distribute-vertical', - title: 'Horizontal Rule' - } - ], - shortcuts: { - 'toggleBlockquote': null, - 'toggleFullScreen': null - } - }) - - // Save - $(window).bind('keydown', (ev) => { - if (ev.ctrlKey || ev.metaKey) { - switch (String.fromCharCode(ev.which).toLowerCase()) { - case 's': - ev.preventDefault() - self.save() - break - } - } - }) - - // Listeners - this.$root.$on('editor/save', this.save) - this.$root.$on('editor/insert', this.insert) - - this.$store.dispatch('pageLoader/complete') - }) - } -} diff --git a/client/js/components/history.vue b/client/js/components/history.vue deleted file mode 100644 index 051a5c04..00000000 --- a/client/js/components/history.vue +++ /dev/null @@ -1,127 +0,0 @@ - - - diff --git a/client/js/components/loading-spinner.vue b/client/js/components/loading-spinner.vue deleted file mode 100644 index 561b0039..00000000 --- a/client/js/components/loading-spinner.vue +++ /dev/null @@ -1,12 +0,0 @@ - - - diff --git a/client/js/components/login.vue b/client/js/components/login.vue index 1a2689ab..71f38a70 100644 --- a/client/js/components/login.vue +++ b/client/js/components/login.vue @@ -31,7 +31,6 @@ /* global CONSTANTS, graphQL, siteConfig */ export default { - name: 'login', data () { return { error: false, @@ -50,6 +49,11 @@ export default { return siteConfig.title } }, + mounted () { + this.$store.commit('navigator/subtitleStatic', 'Login') + this.refreshStrategies() + this.$refs.iptEmail.focus() + }, methods: { selectStrategy (key, useForm) { this.selectedStrategy = key @@ -188,11 +192,6 @@ export default { }) } } - }, - mounted () { - this.$store.commit('navigator/subtitleStatic', 'Login') - this.refreshStrategies() - this.$refs.iptEmail.focus() } } diff --git a/client/js/components/modal-create-page.vue b/client/js/components/modal-create-page.vue deleted file mode 100644 index 41402eb9..00000000 --- a/client/js/components/modal-create-page.vue +++ /dev/null @@ -1,67 +0,0 @@ - - - diff --git a/client/js/components/modal-create-user.vue b/client/js/components/modal-create-user.vue deleted file mode 100644 index 50a5023c..00000000 --- a/client/js/components/modal-create-user.vue +++ /dev/null @@ -1,105 +0,0 @@ - - - diff --git a/client/js/components/modal-delete-page.vue b/client/js/components/modal-delete-page.vue deleted file mode 100644 index 9369c6a7..00000000 --- a/client/js/components/modal-delete-page.vue +++ /dev/null @@ -1,66 +0,0 @@ - - - diff --git a/client/js/components/modal-delete-user.vue b/client/js/components/modal-delete-user.vue deleted file mode 100644 index 95c93ff1..00000000 --- a/client/js/components/modal-delete-user.vue +++ /dev/null @@ -1,65 +0,0 @@ - - - diff --git a/client/js/components/modal-discard-page.vue b/client/js/components/modal-discard-page.vue deleted file mode 100644 index 0d82d987..00000000 --- a/client/js/components/modal-discard-page.vue +++ /dev/null @@ -1,43 +0,0 @@ - - - diff --git a/client/js/components/modal-move-page.vue b/client/js/components/modal-move-page.vue deleted file mode 100644 index 5d2d3049..00000000 --- a/client/js/components/modal-move-page.vue +++ /dev/null @@ -1,86 +0,0 @@ - - - diff --git a/client/js/components/modal-profile-2fa.vue b/client/js/components/modal-profile-2fa.vue deleted file mode 100644 index 81ed361b..00000000 --- a/client/js/components/modal-profile-2fa.vue +++ /dev/null @@ -1,66 +0,0 @@ - - - diff --git a/client/js/components/modal-upgrade-system.vue b/client/js/components/modal-upgrade-system.vue deleted file mode 100644 index 24859a4f..00000000 --- a/client/js/components/modal-upgrade-system.vue +++ /dev/null @@ -1,70 +0,0 @@ - - - diff --git a/client/js/components/page-loader.vue b/client/js/components/page-loader.vue deleted file mode 100644 index e4171b6d..00000000 --- a/client/js/components/page-loader.vue +++ /dev/null @@ -1,23 +0,0 @@ - - - diff --git a/client/js/components/search.vue b/client/js/components/search.vue deleted file mode 100644 index 60d814e1..00000000 --- a/client/js/components/search.vue +++ /dev/null @@ -1,103 +0,0 @@ - - - diff --git a/client/js/components/tree.vue b/client/js/components/tree.vue deleted file mode 100644 index dd6158a8..00000000 --- a/client/js/components/tree.vue +++ /dev/null @@ -1,84 +0,0 @@ - - - diff --git a/client/js/helpers/index.js b/client/js/helpers/index.js index 1b9c9452..649a0275 100644 --- a/client/js/helpers/index.js +++ b/client/js/helpers/index.js @@ -1,13 +1,9 @@ import filesize from 'filesize.js' +import _ from 'lodash' /* global siteConfig */ -const _ = require('./lodash') const helpers = { - /** - * Minimal set of lodash functions - */ - _, /** * Convert bytes to humanized form * @param {number} rawSize Size in bytes diff --git a/client/js/helpers/lodash.js b/client/js/helpers/lodash.js deleted file mode 100644 index 7ea20842..00000000 --- a/client/js/helpers/lodash.js +++ /dev/null @@ -1,65 +0,0 @@ -// ==================================== -// Load minimal lodash -// ==================================== - -import cloneDeep from 'lodash/cloneDeep' -import concat from 'lodash/concat' -import debounce from 'lodash/debounce' -import deburr from 'lodash/deburr' -import delay from 'lodash/delay' -import filter from 'lodash/filter' -import find from 'lodash/find' -import findKey from 'lodash/findKey' -import forEach from 'lodash/forEach' -import includes from 'lodash/includes' -import isBoolean from 'lodash/isBoolean' -import isEmpty from 'lodash/isEmpty' -import isNil from 'lodash/isNil' -import join from 'lodash/join' -import kebabCase from 'lodash/kebabCase' -import last from 'lodash/last' -import map from 'lodash/map' -import nth from 'lodash/nth' -import pullAt from 'lodash/pullAt' -import reject from 'lodash/reject' -import slice from 'lodash/slice' -import split from 'lodash/split' -import startCase from 'lodash/startCase' -import startsWith from 'lodash/startsWith' -import toString from 'lodash/toString' -import toUpper from 'lodash/toUpper' -import trim from 'lodash/trim' - -// ==================================== -// Build lodash object -// ==================================== - -module.exports = { - deburr, - concat, - cloneDeep, - debounce, - delay, - filter, - find, - findKey, - forEach, - includes, - isBoolean, - isEmpty, - isNil, - join, - kebabCase, - last, - map, - nth, - pullAt, - reject, - slice, - split, - startCase, - startsWith, - toString, - toUpper, - trim -} diff --git a/client/js/modules/boot.js b/client/js/modules/boot.js new file mode 100644 index 00000000..4f65c276 --- /dev/null +++ b/client/js/modules/boot.js @@ -0,0 +1,68 @@ +export default { + readyStates: [], + callbacks: [], + /** + * Check if event has been sent + * + * @param {String} evt Event name + * @returns {Boolean} True if fired + */ + isReady (evt) { + return this.readyStates.indexOf(evt) >= 0 + }, + /** + * Register a callback to be executed when event is sent + * + * @param {String} evt Event name to register to + * @param {Function} clb Callback function + * @param {Boolean} once If the callback should be called only once + */ + register (evt, clb, once) { + if (this.isReady(evt)) { + clb() + } else { + this.callbacks.push({ + event: evt, + callback: clb, + once: false, + called: false + }) + } + }, + /** + * Register a callback to be executed only once when event is sent + * + * @param {String} evt Event name to register to + * @param {Function} clb Callback function + */ + registerOnce (evt, clb) { + this.register(evt, clb, true) + }, + /** + * Set ready state and execute callbacks + */ + notify (evt) { + this.readyStates.push(evt) + this.callbacks.forEach(clb => { + if (clb.event === evt) { + if (clb.once && clb.called) { + return + } + clb.called = true + clb.callback() + } + }) + }, + /** + * Execute callback on DOM ready + * + * @param {Function} clb Callback function + */ + onDOMReady (clb) { + if (document.readyState === 'interactive' || document.readyState === 'complete' || document.readyState === 'loaded') { + clb() + } else { + document.addEventListener('DOMContentLoaded', clb) + } + } +} diff --git a/client/js/pages/admin-edit-user.component.js b/client/js/pages/admin-edit-user.component.js deleted file mode 100644 index 17eeb998..00000000 --- a/client/js/pages/admin-edit-user.component.js +++ /dev/null @@ -1,72 +0,0 @@ -export default { - name: 'admin-edit-user', - props: ['usrdata'], - data() { - return { - id: '', - email: '', - password: '********', - name: '', - rights: [], - roleoverride: 'none' - } - }, - methods: { - addRightsRow() { - this.rights.push({ - role: 'write', - path: '/', - exact: false, - deny: false - }) - }, - removeRightsRow(idx) { - this._.pullAt(this.rights, idx) - this.$forceUpdate() - }, - saveUser() { - let self = this - let formattedRights = this._.cloneDeep(this.rights) - switch (this.roleoverride) { - case 'admin': - formattedRights.push({ - role: 'admin', - path: '/', - exact: false, - deny: false - }) - break - } - this.$http.post(window.location.href, { - password: this.password, - name: this.name, - rights: JSON.stringify(formattedRights) - }).then(resp => { - self.$store.dispatch('alert', { - style: 'green', - icon: 'check', - msg: 'Changes have been applied successfully.' - }) - }).catch(err => { - self.$store.dispatch('alert', { - style: 'red', - icon: 'square-cross', - msg: 'Error: ' + err.body.msg - }) - }) - } - }, - mounted() { - let usr = JSON.parse(this.usrdata) - this.id = usr._id - this.email = usr.email - this.name = usr.name - - if (this._.find(usr.rights, { role: 'admin' })) { - this.rights = this._.reject(usr.rights, ['role', 'admin']) - this.roleoverride = 'admin' - } else { - this.rights = usr.rights - } - } -} diff --git a/client/js/pages/admin-profile.component.js b/client/js/pages/admin-profile.component.js deleted file mode 100644 index 935d2fed..00000000 --- a/client/js/pages/admin-profile.component.js +++ /dev/null @@ -1,43 +0,0 @@ -export default { - name: 'admin-profile', - props: ['email', 'name', 'provider', 'tfaIsActive'], - data() { - return { - password: '********', - passwordVerify: '********' - } - }, - computed: { - tfaStatus() { - return this.tfaIsActive ? this.$t('profile.tfaenabled') : this.$t('profile.tfadisabled') - } - }, - methods: { - saveUser() { - let self = this - if (this.password !== this.passwordVerify) { - return self.$store.dispatch('alert', { - style: 'red', - icon: 'square-cross', - msg: 'The passwords don\'t match. Try again.' - }) - } - this.$http.post(window.location.href, { - password: this.password, - name: this.name - }).then(resp => { - self.$store.dispatch('alert', { - style: 'green', - icon: 'check', - msg: 'Changes have been applied successfully.' - }) - }).catch(err => { - self.$store.dispatch('alert', { - style: 'red', - icon: 'square-cross', - msg: 'Error: ' + err.body.msg - }) - }) - } - } -} diff --git a/client/js/pages/admin-settings.component.js b/client/js/pages/admin-settings.component.js deleted file mode 100644 index 573a1f95..00000000 --- a/client/js/pages/admin-settings.component.js +++ /dev/null @@ -1,17 +0,0 @@ -export default { - name: 'admin-settings', - data() { - return {} - }, - methods: { - flushcache() { - window.alert('Coming soon!') - }, - resetaccounts() { - window.alert('Coming soon!') - }, - flushsessions() { - window.alert('Coming soon!') - } - } -} diff --git a/client/js/pages/admin-theme.component.js b/client/js/pages/admin-theme.component.js deleted file mode 100644 index cccb702c..00000000 --- a/client/js/pages/admin-theme.component.js +++ /dev/null @@ -1,57 +0,0 @@ -export default { - name: 'admin-theme', - props: ['themedata'], - data() { - return { - primary: 'indigo', - alt: 'blue-grey', - footer: 'blue-grey', - codedark: 'true', - codecolorize: 'true' - } - }, - watch: { - primary(val) { - this.$root.changeTheme(this.$data) - }, - alt(val) { - this.$root.changeTheme(this.$data) - }, - footer(val) { - this.$root.changeTheme(this.$data) - } - }, - methods: { - saveTheme() { - let self = this - this.$http.post(window.location.href, self.$data).then(resp => { - self.$store.dispatch('alert', { - style: 'green', - icon: 'check', - msg: 'Theme settings have been applied successfully.' - }) - }).catch(err => { - self.$store.dispatch('alert', { - style: 'red', - icon: 'square-cross', - msg: 'Error: ' + err.body.msg - }) - }) - }, - resetTheme() { - this.primary = 'indigo' - this.alt = 'blue-grey' - this.footer = 'blue-grey' - this.codedark = 'true' - this.codecolorize = 'true' - } - }, - mounted() { - let theme = JSON.parse(this.themedata) - this.primary = theme.primary - this.alt = theme.alt - this.footer = theme.footer - this.codedark = theme.code.dark.toString() - this.codecolorize = theme.code.colorize.toString() - } -} diff --git a/client/js/pages/content-view.component.js b/client/js/pages/content-view.component.js deleted file mode 100644 index 24fd66f3..00000000 --- a/client/js/pages/content-view.component.js +++ /dev/null @@ -1,19 +0,0 @@ -/* global $ */ - -export default { - name: 'content-view', - data() { - return {} - }, - mounted() { - let self = this - $('a.toc-anchor').each((i, elm) => { - let hashText = $(elm).attr('href').slice(1) - $(elm).on('click', (ev) => { - ev.stopImmediatePropagation() - self.$store.dispatch('anchor/open', hashText) - return false - }) - }) - } -} diff --git a/client/js/pages/source-view.component.js b/client/js/pages/source-view.component.js deleted file mode 100644 index e1ba5245..00000000 --- a/client/js/pages/source-view.component.js +++ /dev/null @@ -1,23 +0,0 @@ -export default { - name: 'source-view', - data() { - return {} - }, - mounted() { - let self = this - FuseBox.import('/js/ace/ace.js', (ace) => { - let scEditor = ace.edit('source-display') - scEditor.setTheme('ace/theme/dawn') - scEditor.getSession().setMode('ace/mode/markdown') - scEditor.setOption('fontSize', '14px') - scEditor.setOption('hScrollBarAlwaysVisible', false) - scEditor.setOption('wrap', true) - scEditor.setOption('showPrintMargin', false) - scEditor.setReadOnly(true) - scEditor.renderer.updateFull() - scEditor.renderer.on('afterRender', () => { - self.$store.dispatch('pageLoader/complete') - }) - }) - } -} diff --git a/client/js/store/index.js b/client/js/store/index.js index 6bda72f3..84968229 100644 --- a/client/js/store/index.js +++ b/client/js/store/index.js @@ -1,21 +1,7 @@ import Vue from 'vue' import Vuex from 'vuex' -import anchor from './modules/anchor' -import editor from './modules/editor' -import editorCodeblock from './modules/editor-codeblock' -import editorFile from './modules/editor-file' -import editorVideo from './modules/editor-video' -import modalCreatePage from './modules/modal-create-page' -import modalCreateUser from './modules/modal-create-user' -import modalDeleteUser from './modules/modal-delete-user' -import modalDeletePage from './modules/modal-delete-page' -import modalDiscardPage from './modules/modal-discard-page' -import modalMovePage from './modules/modal-move-page' -import modalProfile2fa from './modules/modal-profile-2fa' -import modalUpgradeSystem from './modules/modal-upgrade-system' import navigator from './modules/navigator' -import pageLoader from './modules/page-loader' Vue.use(Vuex) @@ -33,20 +19,6 @@ export default new Vuex.Store({ }, getters: {}, modules: { - anchor, - editor, - editorCodeblock, - editorFile, - editorVideo, - modalCreatePage, - modalCreateUser, - modalDeletePage, - modalDeleteUser, - modalDiscardPage, - modalMovePage, - modalProfile2fa, - modalUpgradeSystem, - navigator, - pageLoader + navigator } }) diff --git a/client/js/store/modules/anchor.js b/client/js/store/modules/anchor.js deleted file mode 100644 index e6696a17..00000000 --- a/client/js/store/modules/anchor.js +++ /dev/null @@ -1,22 +0,0 @@ -export default { - namespaced: true, - state: { - shown: false, - hash: '' - }, - getters: {}, - mutations: { - anchorChange: (state, opts) => { - state.shown = (opts.shown === true) - state.hash = opts.hash || '' - } - }, - actions: { - open({ commit }, hash) { - commit('anchorChange', { shown: true, hash }) - }, - close({ commit }) { - commit('anchorChange', { shown: false }) - } - } -} diff --git a/client/js/store/modules/editor-codeblock.js b/client/js/store/modules/editor-codeblock.js deleted file mode 100644 index 3244a3d8..00000000 --- a/client/js/store/modules/editor-codeblock.js +++ /dev/null @@ -1,22 +0,0 @@ -/* global wikijs */ - -export default { - namespaced: true, - state: { - shown: false, - content: '' - }, - getters: {}, - mutations: { - shownChange: (state, shownState) => { state.shown = shownState }, - contentChange: (state, newContent) => { state.content = newContent } - }, - actions: { - open({ commit }, opts) { - commit('shownChange', true) - commit('contentChange', opts.initialContent || '') - wikijs.$emit('editorCodeblock/init') - }, - close({ commit }) { commit('shownChange', false) } - } -} diff --git a/client/js/store/modules/editor-file.js b/client/js/store/modules/editor-file.js deleted file mode 100644 index 1dd33b26..00000000 --- a/client/js/store/modules/editor-file.js +++ /dev/null @@ -1,22 +0,0 @@ -/* global wikijs */ - -export default { - namespaced: true, - state: { - shown: false, - mode: 'image' - }, - getters: {}, - mutations: { - shownChange: (state, shownState) => { state.shown = shownState }, - modeChange: (state, modeState) => { state.mode = modeState } - }, - actions: { - open({ commit }, opts) { - commit('shownChange', true) - commit('modeChange', opts.mode) - wikijs.$emit('editorFile/init') - }, - close({ commit }) { commit('shownChange', false) } - } -} diff --git a/client/js/store/modules/editor-video.js b/client/js/store/modules/editor-video.js deleted file mode 100644 index d7de8b30..00000000 --- a/client/js/store/modules/editor-video.js +++ /dev/null @@ -1,19 +0,0 @@ -/* global wikijs */ - -export default { - namespaced: true, - state: { - shown: false - }, - getters: {}, - mutations: { - shownChange: (state, shownState) => { state.shown = shownState } - }, - actions: { - open({ commit }) { - commit('shownChange', true) - wikijs.$emit('editorVideo/init') - }, - close({ commit }) { commit('shownChange', false) } - } -} diff --git a/client/js/store/modules/editor.js b/client/js/store/modules/editor.js deleted file mode 100644 index cb64165f..00000000 --- a/client/js/store/modules/editor.js +++ /dev/null @@ -1,22 +0,0 @@ -/* global wikijs */ - -export default { - namespaced: true, - state: { - busy: false, - insertContent: '' - }, - getters: {}, - mutations: { - busyChange: (state, busyState) => { state.shown = busyState }, - insertContentChange: (state, newContent) => { state.insertContent = newContent } - }, - actions: { - busyStart({ commit }) { commit('busyChange', true) }, - busyStop({ commit }) { commit('busyChange', false) }, - insert({ commit }, content) { - commit('insertContentChange', content) - wikijs.$emit('editor/insert') - } - } -} diff --git a/client/js/store/modules/modal-create-page.js b/client/js/store/modules/modal-create-page.js deleted file mode 100644 index 7dc8d763..00000000 --- a/client/js/store/modules/modal-create-page.js +++ /dev/null @@ -1,14 +0,0 @@ -export default { - namespaced: true, - state: { - shown: false - }, - getters: {}, - mutations: { - shownChange: (state, shownState) => { state.shown = shownState } - }, - actions: { - open({ commit }) { commit('shownChange', true) }, - close({ commit }) { commit('shownChange', false) } - } -} diff --git a/client/js/store/modules/modal-create-user.js b/client/js/store/modules/modal-create-user.js deleted file mode 100644 index 087c64a5..00000000 --- a/client/js/store/modules/modal-create-user.js +++ /dev/null @@ -1,19 +0,0 @@ -/* global wikijs */ - -export default { - namespaced: true, - state: { - shown: false - }, - getters: {}, - mutations: { - shownChange: (state, shownState) => { state.shown = shownState } - }, - actions: { - open({ commit }) { - commit('shownChange', true) - wikijs.$emit('modalCreateUser/init') - }, - close({ commit }) { commit('shownChange', false) } - } -} diff --git a/client/js/store/modules/modal-delete-page.js b/client/js/store/modules/modal-delete-page.js deleted file mode 100644 index 7dc8d763..00000000 --- a/client/js/store/modules/modal-delete-page.js +++ /dev/null @@ -1,14 +0,0 @@ -export default { - namespaced: true, - state: { - shown: false - }, - getters: {}, - mutations: { - shownChange: (state, shownState) => { state.shown = shownState } - }, - actions: { - open({ commit }) { commit('shownChange', true) }, - close({ commit }) { commit('shownChange', false) } - } -} diff --git a/client/js/store/modules/modal-delete-user.js b/client/js/store/modules/modal-delete-user.js deleted file mode 100644 index 7dc8d763..00000000 --- a/client/js/store/modules/modal-delete-user.js +++ /dev/null @@ -1,14 +0,0 @@ -export default { - namespaced: true, - state: { - shown: false - }, - getters: {}, - mutations: { - shownChange: (state, shownState) => { state.shown = shownState } - }, - actions: { - open({ commit }) { commit('shownChange', true) }, - close({ commit }) { commit('shownChange', false) } - } -} diff --git a/client/js/store/modules/modal-discard-page.js b/client/js/store/modules/modal-discard-page.js deleted file mode 100644 index 7dc8d763..00000000 --- a/client/js/store/modules/modal-discard-page.js +++ /dev/null @@ -1,14 +0,0 @@ -export default { - namespaced: true, - state: { - shown: false - }, - getters: {}, - mutations: { - shownChange: (state, shownState) => { state.shown = shownState } - }, - actions: { - open({ commit }) { commit('shownChange', true) }, - close({ commit }) { commit('shownChange', false) } - } -} diff --git a/client/js/store/modules/modal-move-page.js b/client/js/store/modules/modal-move-page.js deleted file mode 100644 index 7dc8d763..00000000 --- a/client/js/store/modules/modal-move-page.js +++ /dev/null @@ -1,14 +0,0 @@ -export default { - namespaced: true, - state: { - shown: false - }, - getters: {}, - mutations: { - shownChange: (state, shownState) => { state.shown = shownState } - }, - actions: { - open({ commit }) { commit('shownChange', true) }, - close({ commit }) { commit('shownChange', false) } - } -} diff --git a/client/js/store/modules/modal-profile-2fa.js b/client/js/store/modules/modal-profile-2fa.js deleted file mode 100644 index 706953ca..00000000 --- a/client/js/store/modules/modal-profile-2fa.js +++ /dev/null @@ -1,19 +0,0 @@ -export default { - namespaced: true, - state: { - shown: false, - step: 'confirm' - }, - getters: {}, - mutations: { - shownChange: (state, shownState) => { state.shown = shownState }, - stepChange: (state, stepState) => { state.step = stepState } - }, - actions: { - open({ commit }, opts) { - commit('shownChange', true) - commit('stepChange', 'confirm') - }, - close({ commit }) { commit('shownChange', false) } - } -} diff --git a/client/js/store/modules/modal-upgrade-system.js b/client/js/store/modules/modal-upgrade-system.js deleted file mode 100644 index ea8a5b64..00000000 --- a/client/js/store/modules/modal-upgrade-system.js +++ /dev/null @@ -1,22 +0,0 @@ -export default { - namespaced: true, - state: { - shown: false, - mode: 'upgrade', - step: 'confirm' - }, - getters: {}, - mutations: { - shownChange: (state, shownState) => { state.shown = shownState }, - modeChange: (state, modeState) => { state.mode = modeState }, - stepChange: (state, stepState) => { state.step = stepState } - }, - actions: { - open({ commit }, opts) { - commit('shownChange', true) - commit('modeChange', opts.mode) - commit('stepChange', 'confirm') - }, - close({ commit }) { commit('shownChange', false) } - } -} diff --git a/client/js/store/modules/page-loader.js b/client/js/store/modules/page-loader.js deleted file mode 100644 index 9d77ff72..00000000 --- a/client/js/store/modules/page-loader.js +++ /dev/null @@ -1,15 +0,0 @@ -export default { - namespaced: true, - state: { - shown: true, - msg: 'Loading...' - }, - getters: {}, - mutations: { - shownChange: (state, shownState) => { state.shown = shownState }, - msgChange: (state, newText) => { state.msg = newText } - }, - actions: { - complete({ commit }) { commit('shownChange', false) } - } -} diff --git a/dev/webpack/postcss.config.js b/dev/config/postcss.config.js similarity index 71% rename from dev/webpack/postcss.config.js rename to dev/config/postcss.config.js index 2d146239..1ea3d6f3 100644 --- a/dev/webpack/postcss.config.js +++ b/dev/config/postcss.config.js @@ -7,6 +7,8 @@ module.exports = { removeAll: true } }] - } + }, + 'postcss-flexbugs-fixes': {}, + 'postcss-flexibility': {} } } diff --git a/dev/webpack/webpack.common.js b/dev/webpack/webpack.common.js index 3ed861f5..97cffd4e 100644 --- a/dev/webpack/webpack.common.js +++ b/dev/webpack/webpack.common.js @@ -3,16 +3,20 @@ const fs = require('fs-extra') const webpack = require('webpack') const CopyWebpackPlugin = require('copy-webpack-plugin') -const ProgressBarPlugin = require('progress-bar-webpack-plugin') const ExtractTextPlugin = require('extract-text-webpack-plugin') const NameAllModulesPlugin = require('name-all-modules-plugin') +const LodashModuleReplacementPlugin = require('lodash-webpack-plugin') const babelConfig = fs.readJsonSync(path.join(process.cwd(), '.babelrc')) const postCSSConfig = { config: { - path: path.join(process.cwd(), 'dev/webpack/postcss.config.js') + path: path.join(process.cwd(), 'dev/config/postcss.config.js') } } +const cacheDir = '.webpack-cache/cache' +const babelDir = path.join(process.cwd(), '.webpack-cache/babel') + +process.noDeprecation = true module.exports = { entry: { @@ -32,14 +36,14 @@ module.exports = { { loader: 'cache-loader', options: { - cacheDirectory: '.webpack-cache' + cacheDirectory: cacheDir } }, { loader: 'babel-loader', options: { ...babelConfig, - cacheDirectory: true + cacheDirectory: babelDir } } ] @@ -64,6 +68,12 @@ module.exports = { use: ExtractTextPlugin.extract({ fallback: 'style-loader', use: [ + { + loader: 'cache-loader', + options: { + cacheDirectory: cacheDir + } + }, { loader: 'css-loader' }, @@ -119,14 +129,14 @@ module.exports = { { loader: 'cache-loader', options: { - cacheDirectory: '.webpack-cache' + cacheDirectory: cacheDir } }, { loader: 'babel-loader', options: { babelrc: path.join(process.cwd(), '.babelrc'), - cacheDirectory: true + cacheDirectory: babelDir } } ] @@ -173,17 +183,13 @@ module.exports = { ] }, plugins: [ - new ProgressBarPlugin({ - width: 72, - complete: '▇', - incomplete: '-' - }), new webpack.BannerPlugin('Wiki.js - wiki.js.org - Licensed under AGPL'), new CopyWebpackPlugin([ { from: 'client/static' } ], { }), + new LodashModuleReplacementPlugin(), new webpack.NamedModulesPlugin(), new webpack.NamedChunksPlugin((chunk) => { if (chunk.name) { @@ -207,7 +213,10 @@ module.exports = { symlinks: true, alias: { '@': path.join(process.cwd(), 'client'), - 'vue$': 'vue/dist/vue.common.js' + 'vue$': 'vue/dist/vue.common.js', + // Duplicates fixes: + 'apollo-link': path.join(process.cwd(), 'node_modules/apollo-link'), + 'apollo-utilities': path.join(process.cwd(), 'node_modules/apollo-utilities') }, extensions: [ '.js', diff --git a/dev/webpack/webpack.dev.js b/dev/webpack/webpack.dev.js index 8a3c1e89..7c128354 100644 --- a/dev/webpack/webpack.dev.js +++ b/dev/webpack/webpack.dev.js @@ -3,6 +3,7 @@ const merge = require('webpack-merge') const ExtractTextPlugin = require('extract-text-webpack-plugin') const WriteFilePlugin = require('write-file-webpack-plugin') +const SimpleProgressWebpackPlugin = require('simple-progress-webpack-plugin') const common = require('./webpack.common.js') @@ -15,6 +16,9 @@ module.exports = merge(common, { publicPath: '/' }, plugins: [ + new SimpleProgressWebpackPlugin({ + format: 'compact' + }), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('development') }), diff --git a/dev/webpack/webpack.prod.js b/dev/webpack/webpack.prod.js index 1d239430..ab1a64a8 100644 --- a/dev/webpack/webpack.prod.js +++ b/dev/webpack/webpack.prod.js @@ -1,11 +1,13 @@ const webpack = require('webpack') const merge = require('webpack-merge') +const path = require('path') const CleanWebpackPlugin = require('clean-webpack-plugin') const UglifyJSPlugin = require('uglifyjs-webpack-plugin') const ExtractTextPlugin = require('extract-text-webpack-plugin') const OfflinePlugin = require('offline-plugin') const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin') +const SimpleProgressWebpackPlugin = require('simple-progress-webpack-plugin') const common = require('./webpack.common.js') @@ -14,6 +16,9 @@ module.exports = merge(common, { rules: [] }, plugins: [ + new SimpleProgressWebpackPlugin({ + format: 'expanded' + }), new CleanWebpackPlugin([ 'assets/js/*.*', 'assets/css/*.*', @@ -23,22 +28,44 @@ module.exports = merge(common, { root: process.cwd(), verbose: false }), - new UglifyJSPlugin(), + new UglifyJSPlugin({ + cache: path.join(process.cwd(), '.webpack-cache/uglify'), + parallel: true + }), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }), new ExtractTextPlugin('css/bundle.css'), new OfflinePlugin({ + publicPath: '/', + externals: ['/'], caches: { main: [ 'js/runtime.js', 'js/vendor.js', 'js/client.js' ], - additional: [':externals:'], - optional: ['*.chunk.js'] - } + additional: [ + ':externals:' + ], + optional: [ + 'js/*.chunk.js' + ] + }, + safeToUseOptionalCaches: true }), - new DuplicatePackageCheckerPlugin() + new DuplicatePackageCheckerPlugin(), + // Disable Extract Text Plugin stats: + { + apply(compiler) { + compiler.plugin('done', stats => { + if (Array.isArray(stats.compilation.children)) { + stats.compilation.children = stats.compilation.children.filter(child => { + return child.name.indexOf('extract-text-webpack-plugin') !== 0 + }) + } + }) + } + } ] }) diff --git a/package.json b/package.json index 03485323..85ed408d 100644 --- a/package.json +++ b/package.json @@ -148,6 +148,8 @@ "babel-eslint": "8.2.1", "babel-jest": "22.1.0", "babel-loader": "7.1.2", + "babel-plugin-graphql-tag": "1.3.1", + "babel-plugin-lodash": "3.3.2", "babel-preset-env": "1.6.1", "babel-preset-es2015": "6.24.1", "babel-preset-stage-2": "6.24.1", @@ -171,22 +173,25 @@ "extract-text-webpack-plugin": "3.0.2", "file-loader": "1.1.6", "graphql-tag": "^2.6.1", + "hammerjs": "2.0.8", "i18next-xhr-backend": "1.5.1", - "intl": "1.2.5", "jest": "22.1.4", "jest-junit": "3.4.1", "js-cookie": "2.2.0", + "lodash-webpack-plugin": "0.11.4", "name-all-modules-plugin": "1.0.1", "node-dev": "3.1.3", "node-sass": "4.7.2", "offline-plugin": "4.9.0", + "postcss-flexbugs-fixes": "3.3.0", + "postcss-flexibility": "2.0.0", "postcss-loader": "2.0.10", "postcss-selector-parser": "3.1.1", - "progress-bar-webpack-plugin": "1.10.0", "pug-lint": "2.5.0", "raw-loader": "0.5.1", "sass-loader": "6.0.6", "sass-resources-loader": "1.3.1", + "simple-progress-webpack-plugin": "1.0.4", "style-loader": "0.20.1", "svg-sprite-loader": "3.6.2", "twemoji-awesome": "1.0.6", diff --git a/server/master.js b/server/master.js index 36533eb8..0581fbd2 100644 --- a/server/master.js +++ b/server/master.js @@ -115,13 +115,8 @@ module.exports = async () => { // ---------------------------------------- if (global.DEV) { - const webpackDevMiddleware = require('webpack-dev-middleware') - const webpackHotMiddleware = require('webpack-hot-middleware') - app.use(webpackDevMiddleware(global.WP, { - publicPath: global.WPCONFIG.output.publicPath, - logger: wiki.logger - })) - app.use(webpackHotMiddleware(global.WP)) + app.use(global.WP_DEV.devMiddleware) + app.use(global.WP_DEV.hotMiddleware) } // ---------------------------------------- diff --git a/wiki.js b/wiki.js index adee226f..cb38dd9e 100644 --- a/wiki.js +++ b/wiki.js @@ -71,26 +71,35 @@ const init = { const webpack = require('webpack') const chokidar = require('chokidar') - global.WPCONFIG = require('./dev/webpack/webpack.dev.js') global.DEV = true - global.WP = webpack(global.WPCONFIG) - require('./server') + global.WP_CONFIG = require('./dev/webpack/webpack.dev.js') + global.WP = webpack(global.WP_CONFIG) + global.WP_DEV = { + devMiddleware: require('webpack-dev-middleware')(global.WP, { + publicPath: global.WP_CONFIG.output.publicPath + }), + hotMiddleware: require('webpack-hot-middleware')(global.WP) + } + global.WP_DEV.devMiddleware.waitUntilValid(() => { + console.info('>>> Starting Wiki.js in DEVELOPER mode...') + require('./server') - const devWatcher = chokidar.watch('./server') - devWatcher.on('ready', () => { - devWatcher.on('all', () => { - console.warn('--- >>>>>>>>>>>>>>>>>>>>>>>>>>>> ---') - console.warn('--- Changes detected: Restarting ---') - console.warn('--- <<<<<<<<<<<<<<<<<<<<<<<<<<<< ---') - global.wiki.server.destroy(() => { - global.wiki = {} - for (const workerId in cluster.workers) { - cluster.workers[workerId].kill() - } - Object.keys(require.cache).forEach(function(id) { - if (/[/\\]server[/\\]/.test(id)) delete require.cache[id] + const devWatcher = chokidar.watch('./server') + devWatcher.on('ready', () => { + devWatcher.on('all', () => { + console.warn('--- >>>>>>>>>>>>>>>>>>>>>>>>>>>> ---') + console.warn('--- Changes detected: Restarting ---') + console.warn('--- <<<<<<<<<<<<<<<<<<<<<<<<<<<< ---') + global.wiki.server.destroy(() => { + global.wiki = {} + for (const workerId in cluster.workers) { + cluster.workers[workerId].kill() + } + Object.keys(require.cache).forEach(function(id) { + if (/[/\\]server[/\\]/.test(id)) delete require.cache[id] + }) + require('./server') }) - require('./server') }) }) }) diff --git a/yarn.lock b/yarn.lock index e7858416..c95ca502 100644 --- a/yarn.lock +++ b/yarn.lock @@ -324,6 +324,10 @@ ansi-escape-sequences@^3.0.0: dependencies: array-back "^1.0.3" +ansi-escapes@^1.0.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e" + ansi-escapes@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-2.0.0.tgz#5bae52be424878dd9783e8910e3fc2922e83c81b" @@ -938,6 +942,13 @@ babel-helper-hoist-variables@^6.24.1: babel-runtime "^6.22.0" babel-types "^6.24.1" +babel-helper-module-imports@^7.0.0-beta.3: + version "7.0.0-beta.3" + resolved "https://registry.yarnpkg.com/babel-helper-module-imports/-/babel-helper-module-imports-7.0.0-beta.3.tgz#e15764e3af9c8e11810c09f78f498a2bdc71585a" + dependencies: + babel-types "7.0.0-beta.3" + lodash "^4.2.0" + babel-helper-optimise-call-expression@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz#f7a13427ba9f73f8f4fa993c54a97882d1244257" @@ -988,6 +999,14 @@ babel-jest@22.1.0, babel-jest@^22.1.0: babel-plugin-istanbul "^4.1.5" babel-preset-jest "^22.1.0" +babel-literal-to-ast@^0.1.2: + version "0.1.2" + resolved "https://registry.yarnpkg.com/babel-literal-to-ast/-/babel-literal-to-ast-0.1.2.tgz#f50aa963711935adf19da0d5a4defc827ad5f403" + dependencies: + babel-traverse "^6.0.20" + babel-types "^6.0.19" + babylon "^6.0.18" + babel-loader@7.1.2: version "7.1.2" resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-7.1.2.tgz#f6cbe122710f1aa2af4d881c6d5b54358ca24126" @@ -1008,6 +1027,14 @@ babel-plugin-check-es2015-constants@^6.22.0: dependencies: babel-runtime "^6.22.0" +babel-plugin-graphql-tag@1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/babel-plugin-graphql-tag/-/babel-plugin-graphql-tag-1.3.1.tgz#a2f0696ec711464a2082011e0c796a2dacedd39a" + dependencies: + babel-literal-to-ast "^0.1.2" + babel-types "^6.24.1" + debug "^2.6.8" + babel-plugin-istanbul@^4.1.5: version "4.1.5" resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.5.tgz#6760cdd977f411d3e175bb064f2bc327d99b2b6e" @@ -1020,6 +1047,16 @@ babel-plugin-jest-hoist@^22.1.0: version "22.1.0" resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-22.1.0.tgz#c1281dd7887d77a1711dc760468c3b8285dde9ee" +babel-plugin-lodash@3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/babel-plugin-lodash/-/babel-plugin-lodash-3.3.2.tgz#da3a5b49ba27447f54463f6c4fa81396ccdd463f" + dependencies: + babel-helper-module-imports "^7.0.0-beta.3" + babel-types "^6.26.0" + glob "^7.1.1" + lodash "^4.17.4" + require-package-name "^2.0.1" + babel-plugin-syntax-async-functions@^6.8.0: version "6.13.0" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95" @@ -1464,6 +1501,20 @@ babel-template@^6.26.0: babylon "^6.18.0" lodash "^4.17.4" +babel-traverse@^6.0.20, babel-traverse@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" + dependencies: + babel-code-frame "^6.26.0" + babel-messages "^6.23.0" + babel-runtime "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + debug "^2.6.8" + globals "^9.18.0" + invariant "^2.2.2" + lodash "^4.17.4" + babel-traverse@^6.18.0, babel-traverse@^6.24.1, babel-traverse@^6.25.0: version "6.25.0" resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.25.0.tgz#2257497e2fcd19b89edc13c4c91381f9512496f1" @@ -1478,19 +1529,22 @@ babel-traverse@^6.18.0, babel-traverse@^6.24.1, babel-traverse@^6.25.0: invariant "^2.2.0" lodash "^4.2.0" -babel-traverse@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" +babel-types@7.0.0-beta.3: + version "7.0.0-beta.3" + resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-7.0.0-beta.3.tgz#cd927ca70e0ae8ab05f4aab83778cfb3e6eb20b4" + dependencies: + esutils "^2.0.2" + lodash "^4.2.0" + to-fast-properties "^2.0.0" + +babel-types@^6.0.19, babel-types@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" dependencies: - babel-code-frame "^6.26.0" - babel-messages "^6.23.0" babel-runtime "^6.26.0" - babel-types "^6.26.0" - babylon "^6.18.0" - debug "^2.6.8" - globals "^9.18.0" - invariant "^2.2.2" + esutils "^2.0.2" lodash "^4.17.4" + to-fast-properties "^1.0.3" babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.25.0: version "6.25.0" @@ -1501,27 +1555,18 @@ babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.25 lodash "^4.2.0" to-fast-properties "^1.0.1" -babel-types@^6.26.0: - version "6.26.0" - resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" - dependencies: - babel-runtime "^6.26.0" - esutils "^2.0.2" - lodash "^4.17.4" - to-fast-properties "^1.0.3" - babylon@7.0.0-beta.36: version "7.0.0-beta.36" resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.36.tgz#3a3683ba6a9a1e02b0aa507c8e63435e39305b9e" +babylon@^6.0.18, babylon@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" + babylon@^6.17.2: version "6.17.4" resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.4.tgz#3e8b7402b88d22c3423e137a1577883b15ff869a" -babylon@^6.18.0: - version "6.18.0" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" - backo@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/backo/-/backo-1.1.0.tgz#a36c4468923f2d265c9e8a709ea56ecdaff807e6" @@ -2025,7 +2070,7 @@ center-align@^0.1.1: align-text "^0.1.3" lazy-cache "^1.0.3" -chalk@^1.0.0, chalk@^1.1, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3: +chalk@1.1.x, chalk@^1.0.0, chalk@^1.1, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" dependencies: @@ -2173,7 +2218,7 @@ clean-webpack-plugin@0.1.18: dependencies: rimraf "^2.6.1" -cli-cursor@^2.1.0: +cli-cursor@^2.0.0, cli-cursor@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5" dependencies: @@ -3998,7 +4043,7 @@ feature-detect-es6@^1.3.1: dependencies: array-back "^1.0.3" -figures@^2.0.0: +figures@2.0.x, figures@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" dependencies: @@ -4568,6 +4613,10 @@ gzip-size@^3.0.0: dependencies: duplexer "^0.1.1" +hammerjs@2.0.8: + version "2.0.8" + resolved "https://registry.yarnpkg.com/hammerjs/-/hammerjs-2.0.8.tgz#04ef77862cff2bb79d30f7692095930222bf60f1" + handlebars@^4.0.3: version "4.0.10" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.10.tgz#3d30c718b09a3d96f23ea4cc1f403c4d3ba9ff4f" @@ -4627,10 +4676,6 @@ has-symbol-support-x@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/has-symbol-support-x/-/has-symbol-support-x-1.4.0.tgz#442d89b1d0ac6cf5ff2f7b916ee539869b93a256" -has-symbols@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.0.tgz#ba1a8f1af2a0fc39650f5c850367704122063b44" - has-to-string-tag-x@^1.2.0: version "1.4.0" resolved "https://registry.yarnpkg.com/has-to-string-tag-x/-/has-to-string-tag-x-1.4.0.tgz#49d7bcde85c2409be38ac327e3e119a451657c7b" @@ -4997,10 +5042,6 @@ interpret@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.3.tgz#cbc35c62eeee73f19ab7b10a801511401afc0f90" -intl@1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/intl/-/intl-1.2.5.tgz#82244a2190c4e419f8371f5aa34daa3420e2abde" - invariant@^2.2.0, invariant@^2.2.2: version "2.2.2" resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" @@ -6200,6 +6241,12 @@ locate-path@^2.0.0: p-locate "^2.0.0" path-exists "^3.0.0" +lodash-webpack-plugin@0.11.4: + version "0.11.4" + resolved "https://registry.yarnpkg.com/lodash-webpack-plugin/-/lodash-webpack-plugin-0.11.4.tgz#6c3ecba3d4b8d24b53940b63542715c5ed3c4ac5" + dependencies: + lodash "^4.17.4" + lodash._arraycopy@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/lodash._arraycopy/-/lodash._arraycopy-3.0.0.tgz#76e7b7c1f1fb92547374878a562ed06a3e50f6e1" @@ -6425,6 +6472,14 @@ log-symbols@^2.1.0: dependencies: chalk "^2.0.1" +log-update@2.0.x: + version "2.0.0" + resolved "https://registry.yarnpkg.com/log-update/-/log-update-2.0.0.tgz#7f4354d7be1be62b724fcbb3c4b94454c0db5e26" + dependencies: + ansi-escapes "^1.0.0" + cli-cursor "^2.0.0" + wrap-ansi "^2.1.0" + loglevelnext@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/loglevelnext/-/loglevelnext-1.0.3.tgz#0f69277e73bbbf2cd61b94d82313216bf87ac66e" @@ -7266,7 +7321,7 @@ object-copy@^0.1.0: define-property "^0.2.5" kind-of "^3.0.3" -object-keys@^1.0.11, object-keys@^1.0.8: +object-keys@^1.0.8: version "1.0.11" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d" @@ -7284,15 +7339,6 @@ object-visit@^1.0.0: dependencies: isobject "^3.0.0" -object.assign@^4.0.1: - version "4.1.0" - resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.1.0.tgz#968bf1100d7956bb3ca086f006f846b3bc4008da" - dependencies: - define-properties "^1.1.2" - function-bind "^1.1.1" - has-symbols "^1.0.0" - object-keys "^1.0.11" - object.getownpropertydescriptors@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.0.3.tgz#8758c846f5b407adab0f236e0986f14b051caa16" @@ -8090,6 +8136,18 @@ postcss-filter-plugins@^2.0.0: postcss "^5.0.4" uniqid "^4.0.0" +postcss-flexbugs-fixes@3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/postcss-flexbugs-fixes/-/postcss-flexbugs-fixes-3.3.0.tgz#e00849b536063749da50a0d410ba5d9ee65e27b8" + dependencies: + postcss "^6.0.1" + +postcss-flexibility@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/postcss-flexibility/-/postcss-flexibility-2.0.0.tgz#5612c1b85d6595ed480966839928a41617a6a768" + dependencies: + postcss "^6.0.1" + postcss-load-config@^1.1.0, postcss-load-config@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-1.2.0.tgz#539e9afc9ddc8620121ebf9d8c3673e0ce50d28a" @@ -8591,18 +8649,6 @@ process@~0.5.1: version "0.5.2" resolved "https://registry.yarnpkg.com/process/-/process-0.5.2.tgz#1638d8a8e34c2f440a91db95ab9aeb677fc185cf" -progress-bar-webpack-plugin@1.10.0: - version "1.10.0" - resolved "https://registry.yarnpkg.com/progress-bar-webpack-plugin/-/progress-bar-webpack-plugin-1.10.0.tgz#e0b1063aa03c79e298a9340598590bb61efef9a4" - dependencies: - chalk "^1.1.1" - object.assign "^4.0.1" - progress "^1.1.8" - -progress@^1.1.8: - version "1.1.8" - resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be" - progress@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f" @@ -9273,6 +9319,10 @@ require-main-filename@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" +require-package-name@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/require-package-name/-/require-package-name-2.0.1.tgz#c11e97276b65b8e2923f75dabf5fb2ef0c3841b9" + require-uncached@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3" @@ -9709,6 +9759,14 @@ simple-lru-cache@0.0.x: version "0.0.2" resolved "https://registry.yarnpkg.com/simple-lru-cache/-/simple-lru-cache-0.0.2.tgz#d59cc3a193c1a5d0320f84ee732f6e4713e511dd" +simple-progress-webpack-plugin@1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/simple-progress-webpack-plugin/-/simple-progress-webpack-plugin-1.0.4.tgz#b27127731040aa106500c43d043697cc9bac3743" + dependencies: + chalk "1.1.x" + figures "2.0.x" + log-update "2.0.x" + simple-swizzle@^0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a" @@ -11115,7 +11173,7 @@ worker-farm@^1.5.2: errno "^0.1.4" xtend "^4.0.1" -wrap-ansi@^2.0.0: +wrap-ansi@^2.0.0, wrap-ansi@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" dependencies: