add scrolling grid bg
update copyright year remove old libs update to v0.12.0.
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
{
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
/** TACO Express Default Options **/
|
||||
|
||||
/*
|
||||
The function used to log output (console.log, morgan, etc).
|
||||
Should take one (or more) strings as arguments.
|
||||
*/
|
||||
logFunction: null,
|
||||
|
||||
build: {},
|
||||
site: {},
|
||||
serve: {
|
||||
port: 5000,
|
||||
},
|
||||
}
|
@@ -1,43 +0,0 @@
|
||||
module.exports = (opts, envKey) => {
|
||||
const
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
|
||||
json5 = require('json5'),
|
||||
|
||||
{ convertCamelToUpperSnakeCase, readJsonIfExists } = require('./utils'),
|
||||
|
||||
{ cwd, env } = process,
|
||||
|
||||
def = readJsonIfExists(path.resolve(__dirname, 'defaults.json5')),
|
||||
|
||||
// gets value from ENV || options || defaults (in that order)
|
||||
getVal = (envName) => {
|
||||
const snakeEnvName = `${envKey}_${convertCamelToUpperSnakeCase(envName)}`;
|
||||
if (env[snakeEnvName]) return env[snakeEnvName];
|
||||
if (opts[envName]) return opts[envName];
|
||||
return def[envName];
|
||||
},
|
||||
|
||||
// gets array from ENV || options || defaults (in that order)
|
||||
getArray = (envName, optName = '') => {
|
||||
if (optName === '') {
|
||||
optName = envName;
|
||||
envName = convertCamelToUpperSnakeCase(envName);
|
||||
}
|
||||
envName = `${envKey}_${envName}`;
|
||||
if (env[envName]) return env[envName].split(path.delimiter);
|
||||
if (Array.isArray(opts[optName]) && opts[optName].length) return opts[optName];
|
||||
return def[optName];
|
||||
};
|
||||
|
||||
|
||||
return {
|
||||
|
||||
...Object.keys(def).reduce((acc, curr) => {
|
||||
if (Array.isArray(def[curr])) acc[curr] = getArray(curr);
|
||||
else acc[curr] = getVal(curr);
|
||||
return acc;
|
||||
}, {}),
|
||||
};
|
||||
};
|
26
lib/serve.js
26
lib/serve.js
@@ -1,26 +0,0 @@
|
||||
module.exports = async (config) => {
|
||||
let isReady = false;
|
||||
const
|
||||
http = require('http'),
|
||||
|
||||
address = require('network-address'),
|
||||
handler = require('serve-handler'),
|
||||
|
||||
build = require('./build'),
|
||||
|
||||
{ build: buildOpts, logFunction: log = () => {}, serve: serveOpts } = config || {},
|
||||
{ outputPath, srcPath } = buildOpts || {},
|
||||
{ port = 5000 } = serveOpts || {},
|
||||
|
||||
server = http.createServer((request, response) => {
|
||||
// You pass two more arguments for config and middleware
|
||||
// More details here: https://github.com/vercel/serve-handler#options
|
||||
return handler(request, response, { public: outputPath });
|
||||
});
|
||||
|
||||
await build(config);
|
||||
|
||||
server.listen(port, async () => {
|
||||
log(`Running at http://${address()}:${port} / http://localhost:${port}`);
|
||||
});
|
||||
};
|
57
lib/utils.js
57
lib/utils.js
@@ -1,57 +0,0 @@
|
||||
module.exports = (() => {
|
||||
const
|
||||
chalk = require('chalk'),
|
||||
|
||||
getTime = () => {
|
||||
const
|
||||
now = new Date(),
|
||||
tzo = -now.getTimezoneOffset(),
|
||||
dif = tzo >= 0 ? '+' : '-',
|
||||
|
||||
pad = (num) => {
|
||||
const norm = Math.floor(Math.abs(num));
|
||||
return `${norm < 10 ? '0' : ''}${norm}`;
|
||||
};
|
||||
return [
|
||||
now.getFullYear(),
|
||||
'-',
|
||||
pad(now.getMonth() + 1),
|
||||
'-',
|
||||
pad(now.getDate()),
|
||||
'T',
|
||||
pad(now.getHours()),
|
||||
':',
|
||||
pad(now.getMinutes()),
|
||||
':',
|
||||
pad(now.getSeconds()),
|
||||
dif,
|
||||
pad(tzo / 60),
|
||||
':',
|
||||
pad(tzo % 60)
|
||||
].join('');
|
||||
};
|
||||
|
||||
return {
|
||||
convertCamelToUpperSnakeCase:
|
||||
str => str.replace(/[A-Z]/g, letter => `_${letter}`).toUpperCase(),
|
||||
|
||||
getTime,
|
||||
|
||||
log: (msg) => console.log(`${chalk.grey(`${getTime()}:`)} ${msg}`),
|
||||
|
||||
readJsonIfExists: (filePath) => {
|
||||
const
|
||||
fs = require('fs'),
|
||||
|
||||
json5 = require('json5');
|
||||
|
||||
try {
|
||||
return json5.parse(fs.readFileSync(filePath, {encoding: 'utf8'}));
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') return {};
|
||||
throw err;
|
||||
}
|
||||
},
|
||||
|
||||
};
|
||||
})();
|
58
lib/watch.js
58
lib/watch.js
@@ -1,58 +0,0 @@
|
||||
module.exports = async (config) => {
|
||||
let isReady = false;
|
||||
const
|
||||
http = require('http'),
|
||||
|
||||
chokidar = require('chokidar'),
|
||||
address = require('network-address'),
|
||||
handler = require('serve-handler'),
|
||||
|
||||
build = require('./build'),
|
||||
rebuild = (cfg) => {
|
||||
isReady = false;
|
||||
build({ ...cfg, isRebuild: true });
|
||||
isReady = true;
|
||||
},
|
||||
|
||||
{ build: buildOpts, logFunction: log = () => {}, serve: serveOpts } = config || {},
|
||||
{ outputPath, srcPath } = buildOpts || {},
|
||||
{ port = 5000 } = serveOpts || {},
|
||||
|
||||
watcher = chokidar.watch([srcPath, '*.json'], {
|
||||
ignored: /(^|[\/\\])\../, // ignore dotfiles
|
||||
persistent: true
|
||||
})
|
||||
.on('add', (path) => {
|
||||
if (isReady) {
|
||||
log(`File ${path} has been added`)
|
||||
rebuild(config);
|
||||
}
|
||||
})
|
||||
.on('change', (path) => {
|
||||
if (isReady) {
|
||||
log(`File ${path} has been changed`)
|
||||
rebuild(config);
|
||||
}
|
||||
})
|
||||
.on('ready', () => {
|
||||
isReady = true;
|
||||
})
|
||||
.on('unlink', (path) => {
|
||||
if (isReady) {
|
||||
log(`File ${path} has been removed`)
|
||||
rebuild(config);
|
||||
}
|
||||
}),
|
||||
|
||||
server = http.createServer((request, response) => {
|
||||
// You pass two more arguments for config and middleware
|
||||
// More details here: https://github.com/vercel/serve-handler#options
|
||||
return handler(request, response, { public: outputPath });
|
||||
});
|
||||
|
||||
await build(config);
|
||||
|
||||
server.listen(port, () => {
|
||||
log(`Running at http://${address()}:${port} / http://localhost:${port}`);
|
||||
});
|
||||
};
|
Reference in New Issue
Block a user