From 4454f712ff20cc8ab9406a276ba1fa41d59480e7 Mon Sep 17 00:00:00 2001 From: REJack Date: Thu, 19 Sep 2019 09:02:07 +0200 Subject: [PATCH] plugins prepare enhanced - split Plugins in Plugins & DocsPlugins - created docs-prepare & install npm script - renamed prepare npm script to prepare-release - updated .npmignore --- .npmignore | 1 + build/npm/DocsPlugins.js | 46 ++++++++++++++++++++++++++++++++++++++++ build/npm/DocsPublish.js | 43 +++++++++++++++++++++++++++++++++++++ build/npm/Plugins.js | 43 ------------------------------------- build/npm/Publish.js | 12 ++++++----- package-lock.json | 11 ++++++++++ package.json | 8 ++++--- 7 files changed, 113 insertions(+), 51 deletions(-) create mode 100644 build/npm/DocsPlugins.js create mode 100644 build/npm/DocsPublish.js diff --git a/.npmignore b/.npmignore index c394963d..227c59de 100644 --- a/.npmignore +++ b/.npmignore @@ -1,2 +1,3 @@ /docs/ /plugins/ +!/plugins/flot-old/ diff --git a/build/npm/DocsPlugins.js b/build/npm/DocsPlugins.js new file mode 100644 index 00000000..615e9295 --- /dev/null +++ b/build/npm/DocsPlugins.js @@ -0,0 +1,46 @@ +const Plugins = [ + // AdminLTE Dist + { + from: 'dist/css/', + to : 'docs/assets/css/' + }, + { + from: 'dist/js/', + to : 'docs/assets/js/' + }, + // jQuery + { + from: 'node_modules/jquery/dist/', + to : 'docs/assets/plugins/jquery/' + }, + // Popper + { + from: 'node_modules/popper.js/dist/', + to : 'docs/assets/plugins/popper/' + }, + // Bootstrap + { + from: 'node_modules/bootstrap/dist/js/', + to : 'docs/assets/plugins/bootstrap/js/' + }, + // Font Awesome + { + from: 'node_modules/@fortawesome/fontawesome-free/css/', + to : 'docs/assets/plugins/fontawesome-free/css/' + }, + { + from: 'node_modules/@fortawesome/fontawesome-free/webfonts/', + to : 'docs/assets/plugins/fontawesome-free/webfonts/' + }, + // overlayScrollbars + { + from: 'node_modules/overlayscrollbars/js/', + to : 'docs/assets/plugins/overlayScrollbars/js/' + }, + { + from: 'node_modules/overlayscrollbars/css/', + to : 'docs/assets/plugins/overlayScrollbars/css/' + } +] + +module.exports = Plugins diff --git a/build/npm/DocsPublish.js b/build/npm/DocsPublish.js new file mode 100644 index 00000000..d4a590ed --- /dev/null +++ b/build/npm/DocsPublish.js @@ -0,0 +1,43 @@ +const Plugins = require('./DocsPlugins') +const fse = require('fs-extra') + +class Publish { + constructor() { + this.options = { + verbose: false + } + + this.getArguments() + } + + getArguments() { + if (process.argv.length > 2) { + let arg = process.argv[2] + switch (arg) { + case '-v': + case '--verbose': + this.options.verbose = true + break + default: + throw new Error(`Unknown option ${arg}`) + } + } + } + + run() { + // Publish files + Plugins.forEach((module) => { + try { + fse.copySync(module.from, module.to) + + if (this.options.verbose) { + console.log(`Copied ${module.from} to ${module.to}`) + } + } catch (err) { + console.error(`Error: ${err}`) + } + }) + } +} + +(new Publish()).run() diff --git a/build/npm/Plugins.js b/build/npm/Plugins.js index 254fe1f4..4a5fa501 100644 --- a/build/npm/Plugins.js +++ b/build/npm/Plugins.js @@ -384,49 +384,6 @@ const Plugins = [ from: 'node_modules/bootstrap-switch/dist', to: 'plugins/bootstrap-switch/' }, - - // AdminLTE Dist - { - from: 'dist/css', - to : 'docs/assets/css' - }, - { - from: 'dist/js', - to : 'docs/assets/js' - }, - // jQuery - { - from: 'node_modules/jquery/dist', - to : 'docs/assets/plugins/jquery' - }, - // Popper - { - from: 'node_modules/popper.js/dist', - to : 'docs/assets/plugins/popper' - }, - // Bootstrap - { - from: 'node_modules/bootstrap/dist/js', - to : 'docs/assets/plugins/bootstrap/js' - }, - // Font Awesome - { - from: 'node_modules/@fortawesome/fontawesome-free/css', - to : 'docs/assets/plugins/fontawesome-free/css' - }, - { - from: 'node_modules/@fortawesome/fontawesome-free/webfonts', - to : 'docs/assets/plugins/fontawesome-free/webfonts' - }, - // overlayScrollbars - { - from: 'node_modules/overlayscrollbars/js', - to : 'docs/assets/plugins/overlayScrollbars/js' - }, - { - from: 'node_modules/overlayscrollbars/css', - to : 'docs/assets/plugins/overlayScrollbars/css' - } ] module.exports = Plugins diff --git a/build/npm/Publish.js b/build/npm/Publish.js index c5f32385..4e65e05c 100644 --- a/build/npm/Publish.js +++ b/build/npm/Publish.js @@ -27,13 +27,15 @@ class Publish { run() { // Publish files Plugins.forEach((module) => { - fse.copy(module.from, module.to, error => { - if (error) { - console.error(`Error: ${error}`) - } else if (this.options.verbose) { + try { + fse.copySync(module.from, module.to) + + if (this.options.verbose) { console.log(`Copied ${module.from} to ${module.to}`) } - }) + } catch (err) { + console.error(`Error: ${err}`) + } }) } } diff --git a/package-lock.json b/package-lock.json index 6ec67d5d..edc5fce5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10663,6 +10663,17 @@ "locate-path": "^2.0.0" } }, + "fs-extra": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-5.0.0.tgz", + "integrity": "sha512-66Pm4RYbjzdyeuqudYqhFiNBbCIuI9kgRqLPSHIlXHidW8NIQtVdkM1yeZ4lXwuhbTETv3EUGMNHAAw6hiundQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, "fsevents": { "version": "1.2.9", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.9.tgz", diff --git a/package.json b/package.json index b6ec16b4..20943a12 100644 --- a/package.json +++ b/package.json @@ -12,14 +12,16 @@ "css-minify": "cleancss --level 1 --source-map --source-map-inline-sources --output dist/css/adminlte.min.css dist/css/adminlte.css", "compile": "npm-run-all --parallel js css", "dev": "npm-run-all --parallel watch sync", - "docs-serve": "cd docs/ && bundle exec jekyll serve", - "docs-compile": "cd docs/ && bundle exec jekyll build -d ../docs_html", "docs-clean": "cd docs/ && bundle exec jekyll clean -d ../docs_html", + "docs-compile": "cd docs/ && bundle exec jekyll build -d ../docs_html", + "docs-serve": "cd docs/ && bundle exec jekyll serve", + "docs-prepare": "node build/npm/DocsPublish.js -v", + "install": "npm run plugins", "js": "npm-run-all --sequential js-compile js-minify", "js-compile": "rollup --config build/config/rollup.config.js --sourcemap", "js-minify": "terser --compress typeofs=false --mangle --comments \"/^!/\" --source-map \"content=dist/js/adminlte.js.map,includeSources,url=adminlte.min.js.map\" --output dist/js/adminlte.min.js dist/js/adminlte.js", "production": "npm-run-all --sequential compile plugins", - "prepare": "npm-run-all --sequential compile plugins docs-clean docs-compile", + "prepare-release": "npm-run-all --sequential compile plugins docs-clean docs-compile", "plugins": "node build/npm/Publish.js -v", "sync": "browser-sync start --server --files *.html pages/ dist/", "watch": "npm-run-all --parallel watch-css watch-js", -- GitLab