Änderungen admin

This commit is contained in:
aschwarz
2023-03-20 17:22:01 +01:00
parent 83ce22c602
commit 4bb21bf23c
600 changed files with 112525 additions and 615 deletions

View File

@ -0,0 +1,5 @@
'use strict';
const renderAssets = require('./render-assets');
renderAssets();

View File

@ -0,0 +1,19 @@
'use strict';
const upath = require('upath');
const sh = require('shelljs');
const renderPug = require('./render-pug');
const srcPath = upath.resolve(upath.dirname(__filename), '../src');
sh.find(srcPath).forEach(_processFile);
function _processFile(filePath) {
if (
filePath.match(/\.pug$/)
&& !filePath.match(/include/)
&& !filePath.match(/mixin/)
&& !filePath.match(/\/pug\/layouts\//)
) {
renderPug(filePath);
}
}

View File

@ -0,0 +1,5 @@
'use strict';
const renderScripts = require('./render-scripts');
renderScripts();

View File

@ -0,0 +1,5 @@
'use strict';
const renderSCSS = require('./render-scss');
renderSCSS();

View File

@ -0,0 +1,7 @@
const sh = require('shelljs');
const upath = require('upath');
const destPath = upath.resolve(upath.dirname(__filename), '../dist');
sh.rm('-rf', `${destPath}/*`)

View File

@ -0,0 +1,11 @@
'use strict';
const fs = require('fs');
const upath = require('upath');
const sh = require('shelljs');
module.exports = function renderAssets() {
const sourcePath = upath.resolve(upath.dirname(__filename), '../src/assets');
const destPath = upath.resolve(upath.dirname(__filename), '../dist/.');
sh.cp('-R', sourcePath, destPath)
};

View File

@ -0,0 +1,35 @@
'use strict';
const fs = require('fs');
const upath = require('upath');
const pug = require('pug');
const sh = require('shelljs');
const prettier = require('prettier');
module.exports = function renderPug(filePath) {
const destPath = filePath.replace(/src\/pug\/\pages/, 'dist').replace(/\.pug$/, '.html');
const srcPath = upath.resolve(upath.dirname(__filename), '../src');
console.log(`### INFO: Rendering ${filePath} to ${destPath}`);
const html = pug.renderFile(filePath, {
doctype: 'html',
filename: filePath,
basedir: srcPath
});
const destPathDirname = upath.dirname(destPath);
if (!sh.test('-e', destPathDirname)) {
sh.mkdir('-p', destPathDirname);
}
const prettified = prettier.format(html, {
printWidth: 1000,
tabWidth: 4,
singleQuote: true,
proseWrap: 'preserve',
endOfLine: 'lf',
parser: 'html',
htmlWhitespaceSensitivity: 'ignore'
});
fs.writeFileSync(destPath, prettified);
};

View File

@ -0,0 +1,26 @@
'use strict';
const fs = require('fs');
const packageJSON = require('../package.json');
const upath = require('upath');
const sh = require('shelljs');
module.exports = function renderScripts() {
const sourcePath = upath.resolve(upath.dirname(__filename), '../src/js');
const destPath = upath.resolve(upath.dirname(__filename), '../dist/.');
sh.cp('-R', sourcePath, destPath)
const sourcePathScriptsJS = upath.resolve(upath.dirname(__filename), '../src/js/scripts.js');
const destPathScriptsJS = upath.resolve(upath.dirname(__filename), '../dist/js/scripts.js');
const copyright = `/*!
* Start Bootstrap - ${packageJSON.title} v${packageJSON.version} (${packageJSON.homepage})
* Copyright 2013-${new Date().getFullYear()} ${packageJSON.author}
* Licensed under ${packageJSON.license} (https://github.com/StartBootstrap/${packageJSON.name}/blob/master/LICENSE)
*/
`
const scriptsJS = fs.readFileSync(sourcePathScriptsJS);
fs.writeFileSync(destPathScriptsJS, copyright + scriptsJS);
};

View File

@ -0,0 +1,42 @@
'use strict';
const autoprefixer = require('autoprefixer')
const fs = require('fs');
const packageJSON = require('../package.json');
const upath = require('upath');
const postcss = require('postcss')
const sass = require('sass');
const sh = require('shelljs');
const stylesPath = '../src/scss/styles.scss';
const destPath = upath.resolve(upath.dirname(__filename), '../dist/css/styles.css');
module.exports = function renderSCSS() {
const results = sass.renderSync({
data: entryPoint,
includePaths: [
upath.resolve(upath.dirname(__filename), '../node_modules')
],
});
const destPathDirname = upath.dirname(destPath);
if (!sh.test('-e', destPathDirname)) {
sh.mkdir('-p', destPathDirname);
}
postcss([ autoprefixer ]).process(results.css, {from: 'styles.css', to: 'styles.css'}).then(result => {
result.warnings().forEach(warn => {
console.warn(warn.toString())
})
fs.writeFileSync(destPath, result.css.toString());
})
};
const entryPoint = `/*!
* Start Bootstrap - ${packageJSON.title} v${packageJSON.version} (${packageJSON.homepage})
* Copyright 2013-${new Date().getFullYear()} ${packageJSON.author}
* Licensed under ${packageJSON.license} (https://github.com/StartBootstrap/${packageJSON.name}/blob/master/LICENSE)
*/
@import "${stylesPath}"
`

View File

@ -0,0 +1,86 @@
'use strict';
const _ = require('lodash');
const chokidar = require('chokidar');
const upath = require('upath');
const renderAssets = require('./render-assets');
const renderPug = require('./render-pug');
const renderScripts = require('./render-scripts');
const renderSCSS = require('./render-scss');
const watcher = chokidar.watch('src', {
persistent: true,
});
let READY = false;
process.title = 'pug-watch';
process.stdout.write('Loading');
let allPugFiles = {};
watcher.on('add', filePath => _processFile(upath.normalize(filePath), 'add'));
watcher.on('change', filePath => _processFile(upath.normalize(filePath), 'change'));
watcher.on('ready', () => {
READY = true;
console.log(' READY TO ROLL!');
});
_handleSCSS();
function _processFile(filePath, watchEvent) {
if (!READY) {
if (filePath.match(/\.pug$/)) {
if (!filePath.match(/includes/) && !filePath.match(/mixins/) && !filePath.match(/\/pug\/layouts\//)) {
allPugFiles[filePath] = true;
}
}
process.stdout.write('.');
return;
}
console.log(`### INFO: File event: ${watchEvent}: ${filePath}`);
if (filePath.match(/\.pug$/)) {
return _handlePug(filePath, watchEvent);
}
if (filePath.match(/\.scss$/)) {
if (watchEvent === 'change') {
return _handleSCSS(filePath, watchEvent);
}
return;
}
if (filePath.match(/src\/js\//)) {
return renderScripts();
}
if (filePath.match(/src\/assets\//)) {
return renderAssets();
}
}
function _handlePug(filePath, watchEvent) {
if (watchEvent === 'change') {
if (filePath.match(/includes/) || filePath.match(/mixins/) || filePath.match(/\/pug\/layouts\//)) {
return _renderAllPug();
}
return renderPug(filePath);
}
if (!filePath.match(/includes/) && !filePath.match(/mixins/) && !filePath.match(/\/pug\/layouts\//)) {
return renderPug(filePath);
}
}
function _renderAllPug() {
console.log('### INFO: Rendering All');
_.each(allPugFiles, (value, filePath) => {
renderPug(filePath);
});
}
function _handleSCSS() {
renderSCSS();
}

View File

@ -0,0 +1,24 @@
const concurrently = require('concurrently');
const upath = require('upath');
const browserSyncPath = upath.resolve(upath.dirname(__filename), '../node_modules/.bin/browser-sync');
concurrently([
{ command: 'node --inspect scripts/sb-watch.js', name: 'SB_WATCH', prefixColor: 'bgBlue.bold' },
{
command: `${browserSyncPath} dist -w --no-online`,
name: 'SB_BROWSER_SYNC',
prefixColor: 'bgBlue.bold',
}
], {
prefix: 'name',
killOthers: ['failure', 'success'],
}).then(success, failure);
function success() {
console.log('Success');
}
function failure() {
console.log('Failure');
}

View File

@ -0,0 +1,24 @@
const concurrently = require('concurrently');
const upath = require('upath');
const browserSyncPath = upath.resolve(upath.dirname(__filename), '../node_modules/.bin/browser-sync');
concurrently([
{ command: 'node scripts/sb-watch.js', name: 'SB_WATCH', prefixColor: 'bgBlue.bold' },
{
command: `"${browserSyncPath}" --reload-delay 2000 --reload-debounce 2000 dist -w --no-online`,
name: 'SB_BROWSER_SYNC',
prefixColor: 'bgGreen.bold',
}
], {
prefix: 'name',
killOthers: ['failure', 'success'],
}).then(success, failure);
function success() {
console.log('Success');
}
function failure() {
console.log('Failure');
}