clean up building scripts, remove obsolete stuff
This commit is contained in:
parent
8689f3349e
commit
a2a2fcba82
67
package-lock.json
generated
67
package-lock.json
generated
|
@ -5883,12 +5883,10 @@
|
|||
}
|
||||
},
|
||||
"mkdirp": {
|
||||
"version": "0.5.5",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
|
||||
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
|
||||
"requires": {
|
||||
"minimist": "^1.2.5"
|
||||
}
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
|
||||
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
|
||||
"dev": true
|
||||
},
|
||||
"mkdirp-classic": {
|
||||
"version": "0.5.3",
|
||||
|
@ -5958,6 +5956,16 @@
|
|||
"on-finished": "^2.3.0",
|
||||
"type-is": "^1.6.4",
|
||||
"xtend": "^4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"mkdirp": {
|
||||
"version": "0.5.5",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
|
||||
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
|
||||
"requires": {
|
||||
"minimist": "^1.2.5"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"mysql2": {
|
||||
|
@ -6112,6 +6120,14 @@
|
|||
"tar": "^4.4.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"mkdirp": {
|
||||
"version": "0.5.5",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
|
||||
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
|
||||
"requires": {
|
||||
"minimist": "^1.2.5"
|
||||
}
|
||||
},
|
||||
"rimraf": {
|
||||
"version": "2.7.1",
|
||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
|
||||
|
@ -8292,6 +8308,15 @@
|
|||
"supports-color": "^5.3.0"
|
||||
}
|
||||
},
|
||||
"mkdirp": {
|
||||
"version": "0.5.5",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
|
||||
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"minimist": "^1.2.5"
|
||||
}
|
||||
},
|
||||
"supports-color": {
|
||||
"version": "5.5.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
||||
|
@ -8389,6 +8414,16 @@
|
|||
"mkdirp": "^0.5.0",
|
||||
"safe-buffer": "^5.1.2",
|
||||
"yallist": "^3.0.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"mkdirp": {
|
||||
"version": "0.5.5",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
|
||||
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
|
||||
"requires": {
|
||||
"minimist": "^1.2.5"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"tar-fs": {
|
||||
|
@ -9496,6 +9531,17 @@
|
|||
"dev": true,
|
||||
"requires": {
|
||||
"mkdirp": "^0.5.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"mkdirp": {
|
||||
"version": "0.5.5",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
|
||||
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"minimist": "^1.2.5"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"write-file-atomic": {
|
||||
|
@ -9544,6 +9590,15 @@
|
|||
"supports-color": "^5.3.0"
|
||||
}
|
||||
},
|
||||
"mkdirp": {
|
||||
"version": "0.5.5",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
|
||||
"integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"minimist": "^1.2.5"
|
||||
}
|
||||
},
|
||||
"supports-color": {
|
||||
"version": "5.5.0",
|
||||
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
"description": "Unlimited planet canvas for placing pixels",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"build": "babel-node tools/run build",
|
||||
"clean": "babel-node tools/run clean",
|
||||
"build": "babel-node scripts/run build",
|
||||
"clean": "babel-node scripts/run clean",
|
||||
"webpack": "webpack --config webpack.config.web.babel.js && webpack --config webpack.config.client.babel.js",
|
||||
"babel-node": "cd $INIT_CWD && babel-node",
|
||||
"lint": "cd $INIT_CWD && eslint --ext .jsx --ext .js",
|
||||
|
@ -127,7 +127,9 @@
|
|||
"eslint-plugin-react": "^7.21.2",
|
||||
"flow-bin": "^0.138.0",
|
||||
"generate-package-json-webpack-plugin": "^2.1.1",
|
||||
"glob": "^7.1.6",
|
||||
"json-loader": "^0.5.4",
|
||||
"mkdirp": "^1.0.4",
|
||||
"npm-check": "^5.9.2",
|
||||
"react-hot-loader": "^4.13.0",
|
||||
"react-svg-loader": "^3.0.3",
|
||||
|
|
23
scripts/clean.js
Normal file
23
scripts/clean.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Cleans up the output (build) directory.
|
||||
*/
|
||||
|
||||
import rimraf from 'rimraf';
|
||||
import path from 'path';
|
||||
|
||||
const builddir = path.resolve(__dirname, '../build');
|
||||
|
||||
|
||||
function clean() {
|
||||
return new Promise(
|
||||
(resolve, reject) => rimraf(`${builddir}/*`, {
|
||||
glob: {
|
||||
nosort: true,
|
||||
dot: true,
|
||||
ignore: ['build/.git'],
|
||||
},
|
||||
}, (err, result) => (err) ? reject(err) : resolve(result)),
|
||||
);
|
||||
}
|
||||
|
||||
export default clean;
|
98
scripts/copy.js
Normal file
98
scripts/copy.js
Normal file
|
@ -0,0 +1,98 @@
|
|||
/**
|
||||
* copies files to build directory
|
||||
*/
|
||||
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import glob from 'glob';
|
||||
import mkdirp from 'mkdirp';
|
||||
|
||||
const builddir = path.resolve(__dirname, '../build');
|
||||
const deploydir = path.resolve(__dirname, '../deployment');
|
||||
const publicdir = path.resolve(__dirname, '../public');
|
||||
const srcdir = path.resolve(__dirname, '../src');
|
||||
|
||||
/*
|
||||
* following functions are copied from
|
||||
* React Starter Kit (https://www.reactstarterkit.com/)
|
||||
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.txt file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
const readDir = (pattern, options) => new Promise((resolve, reject) => glob(pattern, options, (err, result) => (err ? reject(err) : resolve(result))));
|
||||
|
||||
const copyFile = (source, target) => new Promise((resolve, reject) => {
|
||||
let cbCalled = false;
|
||||
function done(err) {
|
||||
if (!cbCalled) {
|
||||
cbCalled = true;
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
}
|
||||
const rd = fs.createReadStream(source);
|
||||
rd.on('error', (err) => done(err));
|
||||
const wr = fs.createWriteStream(target);
|
||||
wr.on('error', (err) => done(err));
|
||||
wr.on('close', (err) => done(err));
|
||||
rd.pipe(wr);
|
||||
});
|
||||
|
||||
const copyDir = async (source, target) => {
|
||||
const dirs = await readDir('**/*.*', {
|
||||
cwd: source,
|
||||
nosort: true,
|
||||
dot: true,
|
||||
});
|
||||
await Promise.all(dirs.map(async (dir) => {
|
||||
const from = path.resolve(source, dir);
|
||||
const to = path.resolve(target, dir);
|
||||
mkdirp.sync(path.dirname(to));
|
||||
await copyFile(from, to);
|
||||
}));
|
||||
};
|
||||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Copies static files such as robots.txt, favicon.ico to the
|
||||
* output (build) folder.
|
||||
*/
|
||||
async function copy() {
|
||||
mkdirp.sync(`${builddir}/public/assets`);
|
||||
return Promise.all([
|
||||
copyDir(
|
||||
`${publicdir}`,
|
||||
`${builddir}/public`,
|
||||
),
|
||||
copyFile(
|
||||
`${srcdir}/canvases.json`,
|
||||
`${builddir}/canvases.json`,
|
||||
),
|
||||
copyFile(
|
||||
`${srcdir}/proxies.json`,
|
||||
`${builddir}/proxies.json`,
|
||||
),
|
||||
copyFile(
|
||||
`${deploydir}/example-ecosystem.yml`,
|
||||
`${builddir}/ecosystem.example.yml`,
|
||||
),
|
||||
copyFile(
|
||||
`${deploydir}/example-ecosystem-backup.yml`,
|
||||
`${builddir}/ecosystem-backup.example.yml`,
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
export default copy;
|
|
@ -4,10 +4,15 @@
|
|||
*/
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import CleanCSS from 'clean-css';
|
||||
import crypto from 'crypto';
|
||||
|
||||
const FOLDER = './src/styles';
|
||||
const rootdir = path.resolve(__dirname, '..');
|
||||
const assetdir = path.resolve(__dirname, '../build/public/assets');
|
||||
const builddir = path.resolve(__dirname, '../build');
|
||||
|
||||
const FOLDER = path.resolve(__dirname, '../src/styles');
|
||||
const FILES = [
|
||||
'default.css',
|
||||
'dark.css',
|
||||
|
@ -39,11 +44,11 @@ async function minifyCss() {
|
|||
const hash = crypto.createHash('md5').update(output.styles).digest('hex');
|
||||
const key = file.substr(0, file.indexOf('.'));
|
||||
const filename = `${key}.${hash.substr(0, 8)}.css`;
|
||||
fs.writeFileSync(`./build/public/assets/${filename}`, output.styles, 'utf8');
|
||||
fs.writeFileSync(`${assetdir}/${filename}`, output.styles, 'utf8');
|
||||
assets[key] = `/assets/${filename}`;
|
||||
});
|
||||
const json = JSON.stringify(assets);
|
||||
fs.writeFileSync('./build/styleassets.json', json);
|
||||
fs.writeFileSync(`${builddir}/styleassets.json`, json);
|
||||
}
|
||||
|
||||
export default minifyCss;
|
|
@ -1,25 +0,0 @@
|
|||
/**
|
||||
* React Starter Kit (https://www.reactstarterkit.com/)
|
||||
*
|
||||
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.txt file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import { cleanDir } from './lib/fs';
|
||||
|
||||
/**
|
||||
* Cleans up the output (build) directory.
|
||||
*/
|
||||
function clean() {
|
||||
return Promise.all([
|
||||
cleanDir('build/*', {
|
||||
nosort: true,
|
||||
dot: true,
|
||||
ignore: ['build/.git'],
|
||||
}),
|
||||
]);
|
||||
}
|
||||
|
||||
export default clean;
|
|
@ -1,26 +0,0 @@
|
|||
/**
|
||||
*/
|
||||
|
||||
import path from 'path';
|
||||
import { writeFile, copyFile, makeDir, copyDir, cleanDir } from './lib/fs';
|
||||
import pkg from '../package.json';
|
||||
|
||||
/**
|
||||
* Copies static files such as robots.txt, favicon.ico to the
|
||||
* output (build) folder.
|
||||
*/
|
||||
async function copy() {
|
||||
await makeDir('build');
|
||||
await Promise.all([
|
||||
makeDir('build/log'),
|
||||
copyFile('LICENSE', 'build/LICENSE'),
|
||||
copyDir('public', 'build/public'),
|
||||
copyFile('src/canvases.json', 'build/canvases.json'),
|
||||
copyFile('src/proxies.json', 'build/proxies.json'),
|
||||
copyFile('tools/example-ecosystem.yml', 'build/ecosystem.example.yml'),
|
||||
copyFile('tools/example-ecosystem-backup.yml', 'build/ecosystem-backup.example.yml'),
|
||||
]);
|
||||
await makeDir('build/public/assets');
|
||||
}
|
||||
|
||||
export default copy;
|
|
@ -1,33 +0,0 @@
|
|||
/**
|
||||
* React Starter Kit (https://www.reactstarterkit.com/)
|
||||
*
|
||||
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.txt file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import cp from 'child_process';
|
||||
|
||||
export const spawn = (command, args, options) => new Promise((resolve, reject) => {
|
||||
cp.spawn(command, args, options).on('close', (code) => {
|
||||
if (code === 0) {
|
||||
resolve();
|
||||
} else {
|
||||
reject(new Error(`${command} ${args.join(' ')} => ${code} (error)`));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
export const exec = (command, options) => new Promise((resolve, reject) => {
|
||||
cp.exec(command, options, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
|
||||
resolve({ stdout, stderr });
|
||||
});
|
||||
});
|
||||
|
||||
export default { spawn, exec };
|
|
@ -1,99 +0,0 @@
|
|||
/**
|
||||
* React Starter Kit (https://www.reactstarterkit.com/)
|
||||
*
|
||||
* Copyright © 2014-present Kriasoft, LLC. All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE.txt file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import glob from 'glob';
|
||||
import mkdirp from 'mkdirp';
|
||||
import rimraf from 'rimraf';
|
||||
|
||||
export const readFile = file => new Promise((resolve, reject) => {
|
||||
fs.readFile(file, 'utf8', (err, data) => (err ? reject(err) : resolve(data)));
|
||||
});
|
||||
|
||||
export const writeFile = (file, contents) => new Promise((resolve, reject) => {
|
||||
fs.writeFile(file, contents, 'utf8', err => (err ? reject(err) : resolve()));
|
||||
});
|
||||
|
||||
export const renameFile = (source, target) => new Promise((resolve, reject) => {
|
||||
fs.rename(source, target, err => (err ? reject(err) : resolve()));
|
||||
});
|
||||
|
||||
export const copyFile = (source, target) => new Promise((resolve, reject) => {
|
||||
let cbCalled = false;
|
||||
function done(err) {
|
||||
if (!cbCalled) {
|
||||
cbCalled = true;
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const rd = fs.createReadStream(source);
|
||||
rd.on('error', err => done(err));
|
||||
const wr = fs.createWriteStream(target);
|
||||
wr.on('error', err => done(err));
|
||||
wr.on('close', err => done(err));
|
||||
rd.pipe(wr);
|
||||
});
|
||||
|
||||
export const readDir = (pattern, options) => new Promise((resolve, reject) =>
|
||||
glob(pattern, options, (err, result) => (err ? reject(err) : resolve(result))),
|
||||
);
|
||||
|
||||
export const makeDir = name => new Promise((resolve, reject) => {
|
||||
mkdirp(name, err => (err ? reject(err) : resolve()));
|
||||
});
|
||||
|
||||
export const moveDir = async (source, target) => {
|
||||
const dirs = await readDir('**/*.*', {
|
||||
cwd: source,
|
||||
nosort: true,
|
||||
dot: true,
|
||||
});
|
||||
await Promise.all(dirs.map(async (dir) => {
|
||||
const from = path.resolve(source, dir);
|
||||
const to = path.resolve(target, dir);
|
||||
await makeDir(path.dirname(to));
|
||||
await renameFile(from, to);
|
||||
}));
|
||||
};
|
||||
|
||||
export const copyDir = async (source, target) => {
|
||||
const dirs = await readDir('**/*.*', {
|
||||
cwd: source,
|
||||
nosort: true,
|
||||
dot: true,
|
||||
});
|
||||
await Promise.all(dirs.map(async (dir) => {
|
||||
const from = path.resolve(source, dir);
|
||||
const to = path.resolve(target, dir);
|
||||
await makeDir(path.dirname(to));
|
||||
await copyFile(from, to);
|
||||
}));
|
||||
};
|
||||
|
||||
export const cleanDir = (pattern, options) => new Promise((resolve, reject) =>
|
||||
rimraf(pattern, { glob: options }, (err, result) => (err ? reject(err) : resolve(result))),
|
||||
);
|
||||
|
||||
export default {
|
||||
readFile,
|
||||
writeFile,
|
||||
renameFile,
|
||||
copyFile,
|
||||
readDir,
|
||||
makeDir,
|
||||
copyDir,
|
||||
moveDir,
|
||||
cleanDir,
|
||||
};
|
|
@ -9,7 +9,7 @@ import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
|
|||
import pkg from './package.json';
|
||||
|
||||
const isDebug = process.argv.includes('--debug');
|
||||
const isVerbose = process.argv.includes('--verbose');
|
||||
const VERBOSE = false;
|
||||
const isAnalyze = process.argv.includes('--analyze')
|
||||
|| process.argv.includes('--analyse');
|
||||
|
||||
|
@ -47,7 +47,7 @@ export default {
|
|||
output: {
|
||||
path: path.resolve(__dirname, './build/public/assets'),
|
||||
publicPath: '/assets/',
|
||||
pathinfo: isVerbose,
|
||||
pathinfo: VERBOSE,
|
||||
filename: isDebug ? '[name].js' : '[name].[chunkhash:8].js',
|
||||
chunkFilename: isDebug ? '[name].chunk.js' : '[name].[chunkhash:8].js',
|
||||
},
|
||||
|
@ -162,7 +162,7 @@ export default {
|
|||
test: /[\\/]node_modules[\\/]three[\\/]/,
|
||||
name: 'three',
|
||||
chunks: 'all',
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -9,7 +9,7 @@ import GeneratePackageJsonPlugin from 'generate-package-json-webpack-plugin';
|
|||
import pkg from './package.json';
|
||||
|
||||
const isDebug = process.argv.includes('--debug');
|
||||
const isVerbose = process.argv.includes('--verbose');
|
||||
const VERBOSE = false;
|
||||
|
||||
const basePackageValues = {
|
||||
name: pkg.name,
|
||||
|
@ -54,7 +54,7 @@ export default {
|
|||
},
|
||||
|
||||
output: {
|
||||
pathinfo: isVerbose,
|
||||
pathinfo: VERBOSE,
|
||||
path: path.resolve(__dirname, './build'),
|
||||
libraryTarget: 'commonjs2',
|
||||
},
|
||||
|
@ -97,7 +97,7 @@ export default {
|
|||
loader: 'css-loader',
|
||||
options: {
|
||||
importLoaders: 1,
|
||||
sourceMap: isDebug,
|
||||
sourceMap: false,
|
||||
modules: false,
|
||||
},
|
||||
},
|
||||
|
@ -121,7 +121,7 @@ export default {
|
|||
}),
|
||||
// create package.json for deployment
|
||||
new GeneratePackageJsonPlugin(basePackageValues, {
|
||||
debug: true,
|
||||
debug: VERBOSE,
|
||||
sourcePackageFilenames: [
|
||||
path.resolve(__dirname, './package.json'),
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue
Block a user