commit e5637864705685fc5d55153a44af8aa9faa1a4e8
parent a49722f8060d848a0743f11d5d259acd246e00ff
Author: Konstantin Tarkus <hello@tarkus.me>
Date: Wed, 30 Sep 2015 11:26:33 +0300
Log to the console when an automation script starts/ends running
Diffstat:
9 files changed, 53 insertions(+), 30 deletions(-)
diff --git a/package.json b/package.json
@@ -7,14 +7,14 @@
},
"dependencies": {
"babel": "5.8.23",
- "classnames": "2.1.3",
+ "classnames": "2.1.4",
"eventemitter3": "1.1.1",
"express": "4.13.3",
"fastclick": "1.0.6",
"fbjs": "0.2.1",
"flux": "2.1.1",
"front-matter": "1.0.0",
- "history": "1.10.1",
+ "history": "1.11.1",
"jade": "1.11.0",
"normalize.css": "3.0.3",
"react": "0.14.0-rc1",
@@ -27,23 +27,23 @@
"autoprefixer": "^6.0.3",
"babel-eslint": "^4.1.3",
"babel-loader": "^5.3.2",
- "browser-sync": "^2.9.6",
+ "browser-sync": "^2.9.7",
"css-loader": "^0.19.0",
"csscomb": "^3.1.8",
"del": "^2.0.2",
"eslint": "^1.5.1",
- "eslint-config-airbnb": "0.0.8",
+ "eslint-config-airbnb": "0.1.0",
"eslint-loader": "^1.0.0",
- "eslint-plugin-react": "^3.4.2",
+ "eslint-plugin-react": "^3.5.0",
"gaze": "^0.5.1",
"git-repository": "^0.1.1",
- "glob": "^5.0.14",
- "jest-cli": "^0.5.7",
- "jscs": "^2.1.1",
+ "glob": "^5.0.15",
+ "jest-cli": "^0.5.8",
+ "jscs": "^2.2.1",
"lodash.merge": "^3.3.2",
"mkdirp": "^0.5.1",
"ncp": "^2.0.0",
- "postcss": "^5.0.6",
+ "postcss": "^5.0.8",
"postcss-cssnext": "^2.1.0",
"postcss-import": "^7.0.0",
"postcss-loader": "^0.6.0",
@@ -55,7 +55,7 @@
"url-loader": "^0.5.6",
"webpack": "^1.12.2",
"webpack-dev-middleware": "^1.2.0",
- "webpack-hot-middleware": "^2.2.0"
+ "webpack-hot-middleware": "^2.3.0"
},
"jest": {
"rootDir": "./src",
diff --git a/tools/build.js b/tools/build.js
@@ -7,14 +7,15 @@
* LICENSE.txt file in the root directory of this source tree.
*/
+import task from './lib/task';
+
/**
* Compiles the project from source files into a distributable
* format and copies it to the output (build) folder.
*/
-export default async () => {
- console.log('build');
+export default task('build', async () => {
await require('./clean')();
await require('./copy')();
await require('./bundle')();
-};
+});
diff --git a/tools/bundle.js b/tools/bundle.js
@@ -8,14 +8,14 @@
*/
import webpack from 'webpack';
+import task from './lib/task';
import config from './config';
/**
* Bundles JavaScript, CSS and images into one or more packages
* ready to be used in a browser.
*/
-export default async () => new Promise((resolve, reject) => {
- console.log('bundle');
+export default task('bundle', async () => new Promise((resolve, reject) => {
const bundler = webpack(config);
let bundlerRunCount = 0;
@@ -36,4 +36,4 @@ export default async () => new Promise((resolve, reject) => {
} else {
bundler.run(bundle);
}
-});
+}));
diff --git a/tools/clean.js b/tools/clean.js
@@ -8,13 +8,13 @@
*/
import del from 'del';
+import task from './lib/task';
import fs from './lib/fs';
/**
* Cleans up the output (build) directory.
*/
-export default async () => {
- console.log('clean');
+export default task('clean', async () => {
await del(['.tmp', 'build/*', '!build/.git'], {dot: true});
await fs.makeDir('build/public');
-};
+});
diff --git a/tools/copy.js b/tools/copy.js
@@ -9,6 +9,7 @@
import path from 'path';
import replace from 'replace';
+import task from './lib/task';
import copy from './lib/copy';
import watch from './lib/watch';
@@ -16,8 +17,7 @@ import watch from './lib/watch';
* Copies static files such as robots.txt, favicon.ico to the
* output (build) folder.
*/
-export default async () => {
- console.log('copy');
+export default task('copy', async () => {
await Promise.all([
copy('src/public', 'build/public'),
copy('src/content', 'build/content'),
@@ -39,4 +39,4 @@ export default async () => {
await copy(`src/content/${relPath}`, `build/content/${relPath}`);
});
}
-};
+});
diff --git a/tools/deploy.js b/tools/deploy.js
@@ -8,6 +8,7 @@
*/
import GitRepo from 'git-repository';
+import task from './lib/task';
import fetch from './lib/fetch';
// TODO: Update deployment URL
@@ -22,7 +23,7 @@ const getRemote = (slot) => ({
* Deploy the contents of the `/build` folder to a remote
* server via Git. Example: `npm run deploy -- production`
*/
-export default async () => {
+export default task('deploy', async () => {
// By default deploy to the staging deployment slot
const remote = getRemote(process.argv.includes('production') ? null : 'staging');
@@ -51,4 +52,4 @@ export default async () => {
// Check if the site was successfully deployed
const response = await fetch(remote.website);
console.log(`${remote.website} -> ${response.statusCode}`);
-};
+});
diff --git a/tools/lib/task.js b/tools/lib/task.js
@@ -0,0 +1,21 @@
+/**
+ * React Starter Kit (http://www.reactstarterkit.com/)
+ *
+ * Copyright © 2014-2015 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.
+ */
+
+function format(time) {
+ return time.toTimeString().replace(/.*(\d{2}:\d{2}:\d{2}).*/, '$1');
+}
+
+export default (name, fn) => async () => {
+ const start = new Date();
+ console.log(`[${format(start)}] Starting '${name}'...`);
+ await fn();
+ const end = new Date();
+ const time = end.getTime() - start.getTime();
+ console.log(`[${format(end)}] Finished '${name}' after ${time} ms`);
+};
diff --git a/tools/serve.js b/tools/serve.js
@@ -9,14 +9,13 @@
import path from 'path';
import cp from 'child_process';
+import task from './lib/task';
import watch from './lib/watch';
/**
* Launches Node.js/Express web server in a separate (forked) process.
*/
-export default () => new Promise((resolve, reject) => {
- console.log('serve');
-
+export default task('serve', () => new Promise((resolve, reject) => {
function start() {
const server = cp.fork(path.join(__dirname, '../build/server.js'), {
env: Object.assign({ NODE_ENV: 'development' }, process.env),
@@ -43,4 +42,4 @@ export default () => new Promise((resolve, reject) => {
});
});
}
-});
+}));
diff --git a/tools/start.js b/tools/start.js
@@ -11,6 +11,7 @@ import browserSync from 'browser-sync';
import webpack from 'webpack';
import webpackDevMiddleware from 'webpack-dev-middleware';
import webpackHotMiddleware from 'webpack-hot-middleware';
+import task from './lib/task';
global.WATCH = true;
const config = require('./config')[0]; // Client-side bundle configuration
@@ -20,7 +21,7 @@ const bundler = webpack(config);
* Launches a development web server with "live reload" functionality -
* synchronizing URLs, interactions and code changes across multiple devices.
*/
-export default async () => {
+export default task('start', async () => {
await require('./build')();
await require('./serve')();
@@ -59,4 +60,4 @@ export default async () => {
'build/templates/**/*.*',
],
});
-};
+});