mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-08-31 20:11:59 +02:00
deploy script
This commit is contained in:
33
tools/deploy.js
Normal file
33
tools/deploy.js
Normal file
@@ -0,0 +1,33 @@
|
||||
var fs = require("fs-extra");
|
||||
var glob = require("glob");
|
||||
var path = require("path");
|
||||
var findLocales = require("./find-locales");
|
||||
var fileNames = ["index.html", "article.js"];
|
||||
|
||||
const BASEDIR = path.join(__dirname, "..");
|
||||
|
||||
console.log("Copying files to over for deployment...");
|
||||
|
||||
// copy all content over
|
||||
findLocales(locales => {
|
||||
locales.forEach(locale => {
|
||||
console.log(`Copying ${locale}`);
|
||||
fileNames.forEach(filename => {
|
||||
fs.copySync(path.join(BASEDIR, locale, filename), path.join(BASEDIR, "..", "bezierinfo", locale, filename));
|
||||
})
|
||||
})
|
||||
|
||||
// copy over all SVG images
|
||||
console.log(`Copying images`);
|
||||
glob(path.join(BASEDIR,"images", "latex", "*.svg"), (err, files) => {
|
||||
files.forEach( file => {
|
||||
fs.copySync(file, path.join(BASEDIR, "..", "bezierinfo", "images", "latex", path.basename(file)));
|
||||
});
|
||||
|
||||
// copy the base article.js as well
|
||||
console.log(`Copying default article.js`);
|
||||
fs.copySync(path.join(BASEDIR, "article.js"), path.join(BASEDIR, "..", "bezierinfo", "article.js"));
|
||||
|
||||
console.log(`Deploy copy complete.`);
|
||||
});
|
||||
});
|
21
tools/find-locales.js
Normal file
21
tools/find-locales.js
Normal file
@@ -0,0 +1,21 @@
|
||||
var glob = require('glob');
|
||||
var path = require("path");
|
||||
|
||||
// make sure we know what our base location is
|
||||
const BASEDIR = path.join(__dirname,"..");
|
||||
|
||||
// find all locales used based on content files
|
||||
module.exports = function findLocales(handleLocales) {
|
||||
glob(path.join(BASEDIR,"components/sections/**/content*md"), (err, files) => {
|
||||
var locales = [];
|
||||
|
||||
files.forEach(file => {
|
||||
let locale = file.match(/content\.([^.]+)\.md/)[1];
|
||||
if (locales.indexOf(locale) === -1) {
|
||||
locales.push(locale);
|
||||
}
|
||||
});
|
||||
|
||||
handleLocales(locales);
|
||||
});
|
||||
};
|
@@ -25,11 +25,11 @@
|
||||
**********************************************************************/
|
||||
|
||||
var fs = require("fs-extra");
|
||||
var glob = require('glob');
|
||||
var path = require("path");
|
||||
var marked = require("marked");
|
||||
var chunk = require("./lib/chunk");
|
||||
var jsxshim = require("./lib/jsx-shim");
|
||||
var findLocales = require("./find-locales");
|
||||
|
||||
// make sure we know what our base location is
|
||||
const BASEDIR = path.join(__dirname,"..");
|
||||
@@ -73,7 +73,7 @@ function processLocation(loc, section, number) {
|
||||
// markdown conversion is a little more work
|
||||
let d = marked(block.data.trim());
|
||||
|
||||
// serious can we fucking not, please.
|
||||
// seriously, can we fucking not, please?
|
||||
d = d.replace('<p></div></p>', '</div>')
|
||||
.replace(/&/g, '&')
|
||||
.replace(/'/g, "'")
|
||||
@@ -217,14 +217,5 @@ function processLocale(locale) {
|
||||
writeContentBundle(locale, content);
|
||||
}
|
||||
|
||||
// find all locales used and generate their respective content dirs
|
||||
glob(path.join(BASEDIR,"components/sections/**/content*md"), (err, files) => {
|
||||
var locales = [];
|
||||
files.forEach(file => {
|
||||
let locale = file.match(/content\.([^.]+)\.md/)[1];
|
||||
if (locales.indexOf(locale) === -1) {
|
||||
locales.push(locale);
|
||||
}
|
||||
});
|
||||
locales.forEach(processLocale);
|
||||
});
|
||||
// run all the things!
|
||||
findLocales(locales => locales.forEach(processLocale));
|
Reference in New Issue
Block a user