From 0dc0f09742b05545c7b61ef0397e54e0a558f2f8 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Fri, 28 Sep 2018 13:06:58 +0200 Subject: [PATCH] remove gulp-util, Travis updates --- .travis.yml | 4 ++-- README.md | 5 ++--- _ci/setup.sh | 2 +- gulpfile.babel.js | 44 ++++++++++++++++++++++++-------------------- package.json | 9 +++++---- 5 files changed, 34 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index b41f56c..3872af7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: ruby rvm: - - 2.4 + - 2.5 cache: bundler: true @@ -8,7 +8,7 @@ cache: - $TRAVIS_BUILD_DIR/node_modules before_install: - - nvm install 9 + - nvm install 10 before_script: "_ci/setup.sh" script: "_ci/build.sh" diff --git a/README.md b/README.md index 6abbf92..4b9daf9 100644 --- a/README.md +++ b/README.md @@ -66,8 +66,7 @@ Some pages like front page source their content dynamically during site build. T You need to have the following tools installed on your development machine before moving on: -- [node.js](http://nodejs.org/) & [npm](https://npmjs.org/) -- (optional) use [Yarn](https://yarnpkg.com) instead of npm for faster dependency installations +- [Node.js](http://nodejs.org/) & [npm](https://npmjs.org/) - [Ruby](https://www.ruby-lang.org) (for sanity, install with [rvm](https://rvm.io/)) - [Bundler](http://bundler.io/) @@ -185,7 +184,7 @@ At the moment, jQuery is only used for the form submissions for its simple `$.aj For all code in this repository the Apache License, Version 2.0 is applied. ```text -Copyright Interplanetary Database Foundation 2017. All rights reserved. +Copyright Interplanetary Database Foundation 2018. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/_ci/setup.sh b/_ci/setup.sh index fef53ce..90dd95f 100755 --- a/_ci/setup.sh +++ b/_ci/setup.sh @@ -7,7 +7,7 @@ echo " Installing dependencies " echo "=============================================" echo "$(tput sgr0)" # reset -npm install gulpjs/gulp.git#4.0 -g +npm install gulp@next -g npm install # Travis does that automatically after selecting ruby diff --git a/gulpfile.babel.js b/gulpfile.babel.js index cc6cc98..974bba2 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -8,6 +8,8 @@ import browser from 'browser-sync' import critical from 'critical' import yaml from 'js-yaml' import request from 'request' +import chalk from 'chalk' +import minimist from 'minimist' // required to get our mix of old and ES6+ js to work with ugify-js 3 import uglifyjs from 'uglify-es' @@ -24,14 +26,16 @@ const site = yaml.safeLoad(fs.readFileSync('./_config.yml')) // handle errors const onError = (error) => { - console.log($.util.colors.red('\nYou fucked up:', error.message, 'on line', error.lineNumber, '\n')) + console.log(chalk.red('\nYou fucked up:', error.message, 'on line', error.lineNumber, '\n')) this.emit('end') } // 'development' is just default, production overrides are triggered // by adding the production flag to the gulp command e.g. `gulp build --production` -const isProduction = ($.util.env.production === true) -const isStaging = ($.util.env.staging === true) +const options = minimist(process.argv.slice(2)) + +const isProduction = options.production === true +const isStaging = options.staging === true // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -296,17 +300,17 @@ export const watchSrc = () => { const buildBanner = (done) => { let buildEnvironment - if ($.util.env.production) { + if (isProduction) { buildEnvironment = 'production' - } else if ($.util.env.staging) { + } else if (isStaging) { buildEnvironment = 'staging' } else { buildEnvironment = 'dev' } - console.log($.util.colors.gray(' ------------------------------------------')) - console.log($.util.colors.green(` Building ${buildEnvironment} version...`)) - console.log($.util.colors.gray(' ------------------------------------------')) + console.log(chalk.gray(' ------------------------------------------')) + console.log(chalk.green(` Building ${buildEnvironment} version...`)) + console.log(chalk.gray(' ------------------------------------------')) done() } @@ -318,18 +322,18 @@ const buildBanner = (done) => { const deployBanner = (done) => { let deployTarget - if ($.util.env.live) { + if (options.live) { deployTarget = 'Live' } else { deployTarget = 'Beta' } - if (($.util.env.live || $.util.env.beta || $.util.env.gamma) === true) { - console.log($.util.colors.gray(' ------------------------------------------')) - console.log($.util.colors.green(` Deploying to ${deployTarget}... `)) - console.log($.util.colors.gray(' ------------------------------------------')) + if ((options.live || options.beta || options.gamma) === true) { + console.log(chalk.gray(' ------------------------------------------')) + console.log(chalk.green(` Deploying to ${deployTarget}... `)) + console.log(chalk.gray(' ------------------------------------------')) } else { - console.log($.util.colors.red('\nHold your horses! You need to specify a deployment target like so: gulp deploy --beta. Possible targets are: --live, --beta, --gamma\n')) + console.log(chalk.red('\nHold your horses! You need to specify a deployment target like so: gulp deploy --beta. Possible targets are: --live, --beta, --gamma\n')) } done() } @@ -376,14 +380,14 @@ export const s3 = () => { // create publisher, define config let publisher - if ($.util.env.live === true) { + if (options.live === true) { publisher = $.awspublish.create({ 'params': { 'Bucket': S3BUCKET }, 'accessKeyId': process.env.AWS_ACCESS_KEY, 'secretAccessKey': process.env.AWS_SECRET_KEY, 'region': S3REGION }) - } else if ($.util.env.beta === true) { + } else if (options.beta === true) { publisher = $.awspublish.create({ 'params': { 'Bucket': S3BUCKET_BETA }, 'accessKeyId': process.env.AWS_BETA_ACCESS_KEY, @@ -459,17 +463,17 @@ export const seo = (done) => { const showResponse = (error, response) => { if (error) { - $.util.log($.util.colors.red(error)) + console.log(chalk.red(error)) } else { - $.util.log($.util.colors.gray('Status:', response && response.statusCode)) + console.log(chalk.gray('Status:', response && response.statusCode)) if (response.statusCode === 200) { - $.util.log($.util.colors.green('Successfully notified')) + console.log(chalk.green('Successfully notified')) } } } - if ($.util.env.live === true) { + if (options.live === true) { request(`${googleUrl + site.url}/sitemap.xml`, showResponse) request(`${bingUrl + site.url}/sitemap.xml`, showResponse) } diff --git a/package.json b/package.json index 3d565d1..43f98b0 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "ipdb-site", + "name": "@ipdb/website", "version": "1.0.0", "author": { "name": "Matthias Kretschmann", @@ -38,8 +38,9 @@ "@babel/core": "^7.1.0", "@babel/preset-env": "^7.1.0", "@babel/register": "^7.0.0", - "babel-eslint": "^8.2.6", + "babel-eslint": "^10.0.1", "browser-sync": "^2.24.7", + "chalk": "^2.4.1", "concurrent-transform": "^1.0.0", "critical": "^1.3.4", "cross-spawn": "^6.0.5", @@ -47,7 +48,7 @@ "eslint": "^5.6.0", "eslint-config-ascribe": "^3.0.5", "eslint-plugin-import": "^2.14.0", - "gulp": "github:gulpjs/gulp#4.0", + "gulp": "next", "gulp-autoprefixer": "^6.0.0", "gulp-awspublish": "^3.4.0", "gulp-awspublish-router": "^0.1.5", @@ -68,8 +69,8 @@ "gulp-sourcemaps": "^2.6.4", "gulp-svg-sprite": "^1.5.0", "gulp-uglify": "^3.0.1", - "gulp-util": "^3.0.8", "js-yaml": "^3.12.0", + "minimist": "^1.2.0", "request": "^2.88.0", "stylelint": "^9.6.0", "stylelint-config-bigchaindb": "^1.2.1",