Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump eslint plugin and lint precommit #263

Merged
merged 2 commits into from
Nov 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 19 additions & 19 deletions cy_scripts/deploy.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* eslint-disable no-console */

const path = require('path')
const chalk = require('chalk')
const Promise = require('bluebird')
const inquirer = require('inquirer')
const minimist = require('minimist')
const path = require('path')
const chalk = require('chalk')
const Promise = require('bluebird')
const inquirer = require('inquirer')
const minimist = require('minimist')
const debug = require('debug')('deploy')
const questionsRemain = require('@cypress/questions-remain')
const scrape = require('./scrape')
const scrape = require('./scrape')
const shouldDeploy = require('./should-deploy')
const R = require('ramda')
const la = require('lazy-ass')
Expand Down Expand Up @@ -43,7 +43,7 @@ function prompToScrape () {
message: 'Would you like to scrape the docs? (You only need to do this if they have changed on this deployment)',
choices: [
{ name: 'Yes', value: true },
{ name: 'No', value: false },
{ name: 'No', value: false },
],
})
.get('scrape')
Expand Down Expand Up @@ -97,12 +97,12 @@ function doDeploy (env) {
la(isValidEnvironment(env), 'invalid deploy environment', env)
debug('getting current branch')
return getBranch()
.then((branch) => {
console.log('deploying branch %s to environment %s',
chalk.green(branch), chalk.blue(env))
la(is.unemptyString(branch), 'invalid branch name', branch)
return deployEnvironmentBranch(env, branch)
})
.then((branch) => {
console.log('deploying branch %s to environment %s',
chalk.green(branch), chalk.blue(env))
la(is.unemptyString(branch), 'invalid branch name', branch)
return deployEnvironmentBranch(env, branch)
})
}

function deploy () {
Expand All @@ -126,9 +126,9 @@ function deploy () {
}

deploy()
.catch((err) => {
console.error('🔥 deploy failed')
console.error(err)
console.error(err.stack)
process.exit(-1)
})
.catch((err) => {
console.error('🔥 deploy failed')
console.error(err)
console.error(err.stack)
process.exit(-1)
})
104 changes: 52 additions & 52 deletions cy_scripts/should-deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ function isRightBranch (env) {

let branch
return git.branchName()
.then(tap((name) => {
console.log('branch name', name)
branch = name
}))
.then(isBranchAllowedToDeploy)
.then(tap((rightBranch) => {
console.log('is branch %s allowed to deploy %s?',
branch, env, rightBranch)
}))
.then(tap((name) => {
console.log('branch name', name)
branch = name
}))
.then(isBranchAllowedToDeploy)
.then(tap((rightBranch) => {
console.log('is branch %s allowed to deploy %s?',
branch, env, rightBranch)
}))
}

function buildUrlForEnvironment (env) {
Expand All @@ -79,40 +79,40 @@ function lastDeployedCommit (env) {

debug('checking last deploy info using url %s', url)
return got(url, { json: true })
.then(path(['body', 'id']))
.then(tap((id) => {
console.log('docs last deployed for commit', id)
}))
.then(path(['body', 'id']))
.then(tap((id) => {
console.log('docs last deployed for commit', id)
}))
}

const changedFilesSince = (branchName) => (sha) => {
la(is.unemptyString(branchName), 'missing branch name', branchName)
debug('finding files changed in branch %s since commit %s', branchName, sha)
return git.changedFilesAfter(sha, branchName)
.then(tap((list) => {
debug('%s changed since last docs deploy in branch %s',
pluralize('file', list.length, true), branchName)
debug(list.join('\n'))
}))
.then(tap((list) => {
debug('%s changed since last docs deploy in branch %s',
pluralize('file', list.length, true), branchName)
debug(list.join('\n'))
}))
}

function docsFilesChangedSinceLastDeploy (env, branchName) {
return lastDeployedCommit(env)
.then(changedFilesSince(branchName))
.then(tap((list) => {
console.log('changed files')
console.log(list.join('\n'))
console.log('%d documentation %s changed since last doc deploy',
list.length, pluralize('file', list.length))
console.log('in branch %s against environment %s', branchName, env)
}))
.then(docsChanged)
.then(tap((hasDocumentChanges) => {
console.log('has document changes?', hasDocumentChanges)
}))
.catch(T)
// if cannot fetch last build, or some other exception
// then should deploy!
.then(changedFilesSince(branchName))
.then(tap((list) => {
console.log('changed files')
console.log(list.join('\n'))
console.log('%d documentation %s changed since last doc deploy',
list.length, pluralize('file', list.length))
console.log('in branch %s against environment %s', branchName, env)
}))
.then(docsChanged)
.then(tap((hasDocumentChanges) => {
console.log('has document changes?', hasDocumentChanges)
}))
.catch(T)
// if cannot fetch last build, or some other exception
// then should deploy!
}

// resolves with boolean true/false
Expand All @@ -124,22 +124,22 @@ function shouldDeploy (env = 'production') {
}

return git.branchName()
.then((branchName) => {
const questions = [
isRightBranch(env),
docsFilesChangedSinceLastDeploy(env, branchName),
]
return Promise.all(questions)
.then(all(equals(true)))
.then(Boolean)
.then((result) => {
if (isForced) {
console.log('should deploy is forced!')
return isForced
}
return result
})
.then((branchName) => {
const questions = [
isRightBranch(env),
docsFilesChangedSinceLastDeploy(env, branchName),
]
return Promise.all(questions)
.then(all(equals(true)))
.then(Boolean)
.then((result) => {
if (isForced) {
console.log('should deploy is forced!')
return isForced
}
return result
})
})
}

module.exports = shouldDeploy
Expand All @@ -152,8 +152,8 @@ if (!module.parent) {
// .catch(console.error)

shouldDeploy('staging')
.then((should) => {
console.log('should deploy?', should)
})
.catch(console.error)
.then((should) => {
console.log('should deploy?', should)
})
.catch(console.error)
}
12 changes: 6 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ gulp.task('move:doc:search:css', function () {
// move font files
gulp.task('move:fira:fonts', function () {
return gulp
.src('./node_modules/fira/**')
.pipe(gulp.dest('./themes/cypress/source/fonts/vendor/fira'))
.src('./node_modules/fira/**')
.pipe(gulp.dest('./themes/cypress/source/fonts/vendor/fira'))
})

gulp.task('move:font:awesome:fonts', (cb) => {
Expand All @@ -58,14 +58,14 @@ gulp.task('move:font:awesome:fonts', (cb) => {

gulp.task('move:font:awesome:css', function () {
return gulp
.src('./node_modules/font-awesome/css/font-awesome.css')
.pipe(gulp.dest('./themes/cypress/source/fonts/vendor/font-awesome/css'))
.src('./node_modules/font-awesome/css/font-awesome.css')
.pipe(gulp.dest('./themes/cypress/source/fonts/vendor/font-awesome/css'))
})

gulp.task('move:font:awesome:fonts:folder', function () {
return gulp
.src('./node_modules/font-awesome/fonts/*')
.pipe(gulp.dest('./themes/cypress/source/fonts/vendor/font-awesome/fonts'))
.src('./node_modules/font-awesome/fonts/*')
.pipe(gulp.dest('./themes/cypress/source/fonts/vendor/font-awesome/fonts'))
})

gulp.task('revision', () => {
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ process.on('unhandledRejection', function (reason, p) {
console.error('Unhandled Rejection at: Promise ', p)
console.error('reason: ', reason)
process.exit(-1)
});
})

const fs = require('fs')
const path = require('path')
Expand Down
31 changes: 28 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"url": "https://github.com/cypress-io/cypress-documentation.git"
},
"scripts": {
"postinstall": "echo 'This project needs: npm run build'",
"deps": "deps-ok && dependency-check . --no-default-entries --entry cy_scripts/deploy.js",
"prebuild": "npm run clean && npm run deps && gulp pre:build",
"build": "node --stack-size=8192 ./index.js generate",
Expand All @@ -34,8 +33,8 @@
"test-e2e": "start-server-and-test start http://localhost:2222 cypress:run",
"test": "mocha --compilers coffee:coffee-script/register --recursive",
"test-watch": "npm run test --silent -- --watch",
"lint": "echo 'linting scripts'",
"postlint": "eslint --fix *.js cy_scripts/*.js scripts/*.js"
"lint": "echo 'Linting scripts...' && eslint --fix *.js cy_scripts/*.js scripts/*.js && echo 'Lint successful'",
"precommit": "npm run lint"
},
"devDependencies": {
"@cypress/deploy-bits": "1.7.1",
Expand All @@ -54,7 +53,7 @@
"dependency-check": "^2.9.1",
"deps-ok": "^1.2.0",
"eslint": "^4.6.1",
"eslint-plugin-cypress-dev": "^1.0.0",
"eslint-plugin-cypress-dev": "^1.1.1",
"fs-extra": "^4.0.2",
"ggit": "^2.3.0",
"git-last": "^1.2.0",
Expand All @@ -66,6 +65,7 @@
"gulp-debug": "^3.1.0",
"gulp-rev-all": "^0.9.7",
"human-interval": "^0.1.6",
"husky": "0.14.3",
"inquirer": "^4.0.0",
"minimist": "^1.2.0",
"mocha": "^4.0.1",
Expand All @@ -77,8 +77,8 @@
"run-sequence": "^2.2.0",
"sinon": "^4.1.2",
"sinon-chai": "^2.10.0",
"start-server-and-test": "1.0.0",
"snap-shot-it": "^4.0.1",
"start-server-and-test": "1.0.0",
"underscore.string": "^3.3.4",
"wait-on": "^2.0.2",
"yamljs": "^0.3.0"
Expand Down Expand Up @@ -106,4 +106,4 @@
"menuspy": "1.2.1",
"scrollingelement": "1.5.2"
}
}
}