From e6a12b94a73c2d683b1122c082525f57972df120 Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Mon, 19 Jun 2017 14:43:36 -0400 Subject: [PATCH 01/22] root: move deploy scripts from server to top level scripts --- {packages/server => scripts}/deploy/ask.coffee | 0 {packages/server => scripts}/deploy/base.coffee | 0 {packages/server => scripts}/deploy/bump.coffee | 0 {packages/server => scripts}/deploy/darwin.coffee | 0 {packages/server => scripts}/deploy/index.coffee | 0 {packages/server => scripts}/deploy/linux.coffee | 0 {packages/server => scripts}/deploy/log.coffee | 0 {packages/server => scripts}/deploy/meta.coffee | 0 {packages/server => scripts}/deploy/upload.coffee | 0 {packages/server => scripts}/deploy/zip.coffee | 0 10 files changed, 0 insertions(+), 0 deletions(-) rename {packages/server => scripts}/deploy/ask.coffee (100%) rename {packages/server => scripts}/deploy/base.coffee (100%) rename {packages/server => scripts}/deploy/bump.coffee (100%) rename {packages/server => scripts}/deploy/darwin.coffee (100%) rename {packages/server => scripts}/deploy/index.coffee (100%) rename {packages/server => scripts}/deploy/linux.coffee (100%) rename {packages/server => scripts}/deploy/log.coffee (100%) rename {packages/server => scripts}/deploy/meta.coffee (100%) rename {packages/server => scripts}/deploy/upload.coffee (100%) rename {packages/server => scripts}/deploy/zip.coffee (100%) diff --git a/packages/server/deploy/ask.coffee b/scripts/deploy/ask.coffee similarity index 100% rename from packages/server/deploy/ask.coffee rename to scripts/deploy/ask.coffee diff --git a/packages/server/deploy/base.coffee b/scripts/deploy/base.coffee similarity index 100% rename from packages/server/deploy/base.coffee rename to scripts/deploy/base.coffee diff --git a/packages/server/deploy/bump.coffee b/scripts/deploy/bump.coffee similarity index 100% rename from packages/server/deploy/bump.coffee rename to scripts/deploy/bump.coffee diff --git a/packages/server/deploy/darwin.coffee b/scripts/deploy/darwin.coffee similarity index 100% rename from packages/server/deploy/darwin.coffee rename to scripts/deploy/darwin.coffee diff --git a/packages/server/deploy/index.coffee b/scripts/deploy/index.coffee similarity index 100% rename from packages/server/deploy/index.coffee rename to scripts/deploy/index.coffee diff --git a/packages/server/deploy/linux.coffee b/scripts/deploy/linux.coffee similarity index 100% rename from packages/server/deploy/linux.coffee rename to scripts/deploy/linux.coffee diff --git a/packages/server/deploy/log.coffee b/scripts/deploy/log.coffee similarity index 100% rename from packages/server/deploy/log.coffee rename to scripts/deploy/log.coffee diff --git a/packages/server/deploy/meta.coffee b/scripts/deploy/meta.coffee similarity index 100% rename from packages/server/deploy/meta.coffee rename to scripts/deploy/meta.coffee diff --git a/packages/server/deploy/upload.coffee b/scripts/deploy/upload.coffee similarity index 100% rename from packages/server/deploy/upload.coffee rename to scripts/deploy/upload.coffee diff --git a/packages/server/deploy/zip.coffee b/scripts/deploy/zip.coffee similarity index 100% rename from packages/server/deploy/zip.coffee rename to scripts/deploy/zip.coffee From 331f2058d4e16a49a87428fc8e3e0848715c7be5 Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Mon, 19 Jun 2017 14:44:09 -0400 Subject: [PATCH 02/22] remove postinstall download stop variable --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9afb1a1a3c..034302c806 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "all": "node ./scripts/run.js", "test": "echo '⚠️ This root monorepo is only for local development and new contributions. There are no tests.'", "link": "node ./scripts/link-packages.js", - "postinstall": "CYPRESS_DOWNLOAD=0 npm run link && npm run all install && npm run build", + "postinstall": "npm run link && npm run all install && npm run build", "clean-deps": "npm run all clean-deps", "docker": "./scripts/run-docker-local.sh", "lint": "eslint --fix scripts/*.js", From 59f9e894a736ddefbf26724d7f889d44daa93635 Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Mon, 19 Jun 2017 15:46:37 -0400 Subject: [PATCH 03/22] deploy: list all dev dependencies --- .gitignore | 1 + package.json | 27 ++++++- packages/server/package.json | 4 - scripts/deploy.js | 3 + scripts/deploy/ask.coffee | 78 ++++++++++---------- scripts/deploy/base.coffee | 14 ++-- scripts/deploy/bump.coffee | 6 +- scripts/deploy/upload.coffee | 29 +++++--- {packages/server => scripts}/gulpfile.coffee | 0 9 files changed, 92 insertions(+), 70 deletions(-) create mode 100644 scripts/deploy.js rename {packages/server => scripts}/gulpfile.coffee (100%) diff --git a/.gitignore b/.gitignore index 983ea3b568..4d63535605 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,4 @@ docs/support # CLI tool cli/build +scripts/deploy/support/ diff --git a/package.json b/package.json index 034302c806..ff5466d884 100644 --- a/package.json +++ b/package.json @@ -19,24 +19,45 @@ "lint": "eslint --fix scripts/*.js", "pretest": "npm run lint && npm run all lint", "precommit": "lint-staged", - "precommit-lint": "eslint --fix --rule 'no-only-tests/no-only-tests: 2'" + "precommit-lint": "eslint --fix --rule 'no-only-tests/no-only-tests: 2'", + "bump": "gulp bump", + "deploy": "node ./scripts/deploy.js", + "release": "gulp release" }, "lint-staged": { - "*.js": ["precommit-lint", "git add"] + "*.js": [ + "precommit-lint", + "git add" + ] }, "devDependencies": { + "@cypress/bumpercar": "^1.0.6", "@cypress/npm-run-all": "^4.0.4", "ascii-table": "0.0.9", "babel-eslint": "^6.0.4", "bluebird": "^3.4.5", + "chai": "^4.0.2", + "electron-osx-sign": "^0.4.6", "eslint": "^3.18.0", "eslint-plugin-mocha": "^4.9.0", "eslint-plugin-no-only-tests": "levibuzolic/eslint-plugin-no-only-tests#dbb7270c4f48e33081729c0ef076441b39f35487", "eslint-plugin-react": "^5.1.1", "fs-extra": "^2.1.2", + "gulp": "^3.9.1", + "gulp-awspublish": "^3.3.0", + "gulp-coffee": "^2.3.4", + "gulp-debug": "^3.1.0", + "gulp-rename": "^1.2.2", + "human-interval": "^0.1.6", "husky": "^0.13.4", + "konfig": "^0.2.1", "lint-staged": "^3.6.0", - "pre-git": "^3.15.0" + "obfuscator": "^0.5.4", + "plist": "^2.1.0", + "pre-git": "^3.15.0", + "run-sequence": "^1.2.2", + "vagrant": "0.0.1", + "xvfb": "^0.2.3" }, "config": { "pre-git": { diff --git a/packages/server/package.json b/packages/server/package.json index 2ffe923021..7e270df176 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -9,10 +9,7 @@ "start": "node index.js", "server": "node index.js --mode server", "repl": "node repl.js", - "bump": "gulp bump", "clean-deps": "rm -rf node_modules", - "deploy": "gulp deploy", - "release": "gulp release", "test": "./test/support/run", "test-watch": "./test/support/watch test", "test-unit": "./test/support/run test/unit", @@ -46,7 +43,6 @@ "coffee-coverage": "^1.0.1", "cors": "^2.8.3", "coveralls": "^2.11.8", - "cypress-bumpercar": "^1.0.5", "electron-osx-sign": "^0.3.0", "express-session": "^1.14.1", "express-useragent": "^1.0.4", diff --git a/scripts/deploy.js b/scripts/deploy.js new file mode 100644 index 0000000000..55c820a585 --- /dev/null +++ b/scripts/deploy.js @@ -0,0 +1,3 @@ +require('../packages/coffee/register') + +require('./deploy/index') diff --git a/scripts/deploy/ask.coffee b/scripts/deploy/ask.coffee index 46804039fc..7c58556809 100644 --- a/scripts/deploy/ask.coffee +++ b/scripts/deploy/ask.coffee @@ -4,7 +4,10 @@ glob = require("glob") Promise = require("bluebird") inquirer = require("inquirer") -throw new Error("TODO: upgrade inquirer to promise interface") +glob = Promise.promisify(glob) + +prompt = (questions) -> + Promise.resolve(inquirer.prompt(questions)) fs = Promise.promisifyAll(fs) @@ -89,55 +92,48 @@ module.exports = { }] deployNewVersion: -> - new Promise (resolve, reject) => - fs.readJsonAsync("./package.json").then (json) => - inquirer.prompt @getQuestions(json.version), (answers) => - ## set the new version if we're publishing! - ## update our own local package.json as well - if answers.publish - # @updateLocalPackageJson(answers.version, json).then -> - resolve(answers.version) - else - resolve(json.version) + fs.readJsonAsync("./package.json") + .then (json) => + prompt(@getQuestions(json.version)) + .then (answers) -> + ## set the new version if we're publishing! + ## update our own local package.json as well + if answers.publish + # @updateLocalPackageJson(answers.version, json).then -> + answers.version + else + json.version whichVersion: (distDir) -> - new Promise (resolve, reject) => - ## realpath returns the absolute full path - glob "*/package.json", {cwd: distDir, realpath: true}, (err, pkgs) => - return reject(err) if err + ## realpath returns the absolute full path + glob("*/package.json", {cwd: distDir, realpath: true}) + .map (pkg) => + fs.readJsonAsync(pkg) + .get("version") + .then (versions) => + versions = _.uniq(versions) - Promise - .map pkgs, (pkg) -> - fs.readJsonAsync(pkg).get("version") - .then (versions) => - versions = _.uniq(versions) - - inquirer.prompt @getVersions(versions), (answers) => - resolve(answers.version) + prompt(@getVersions(versions)) + .get("version") whichRelease: (distDir) -> - new Promise (resolve, reject) => - ## realpath returns the absolute full path - glob "*/package.json", {cwd: distDir, realpath: true}, (err, pkgs) => - return reject(err) if err + ## realpath returns the absolute full path + glob("*/package.json", {cwd: distDir, realpath: true}) + .map (pkg) => + fs.readJsonAsync(pkg) + .get("version") + .then (versions) => + versions = _.uniq(versions) - Promise - .map pkgs, (pkg) -> - fs.readJsonAsync(pkg).get("version") - .then (versions) => - versions = _.uniq(versions) - - inquirer.prompt @getReleases(versions), (answers) => - resolve(answers.release) + prompt(@getReleases(versions)) + .get("release") whichPlatform: -> - new Promise (resolve, reject) => - inquirer.prompt @getPlatformQuestion(), (answers) => - resolve(answers.platform) + prompt(@getPlatformQuestion()) + .get("platform") whichBumpTask: -> - new Promise (resolve, reject) => - inquirer.prompt @getBumpTasks(), (answers) => - resolve(answers.task) + prompt(@getBumpTasks()) + .get("task") } diff --git a/scripts/deploy/base.coffee b/scripts/deploy/base.coffee index 4de7c5c4bf..968199b3b2 100644 --- a/scripts/deploy/base.coffee +++ b/scripts/deploy/base.coffee @@ -1,7 +1,5 @@ -require("../gulpfile.coffee") - _ = require("lodash") -$ = require("gulp-load-plugins")() +gulpCoffee = require("gulp-coffee") fs = require("fs-extra") cp = require("child_process") path = require("path") @@ -15,10 +13,10 @@ runSequence = require("run-sequence") cypressElectron = require("@packages/electron") log = require("./log") meta = require("./meta") -pkg = require("../package.json") -konfig = require("../lib/konfig") -appData = require("../lib/util/app_data") -Fixtures = require("../test/support/helpers/fixtures") +pkg = require("../../package.json") +konfig = require("@packages/server/lib/konfig") +appData = require("@packages/server/lib/util/app_data") +Fixtures = require("@packages/server/test/support/helpers/fixtures") # pkgr = Promise.promisify(pkgr) fs = Promise.promisifyAll(fs) @@ -126,7 +124,7 @@ class Base ## convert to js new Promise (resolve, reject) => gulp.src(@distDir("src/**/*.coffee")) - .pipe $.coffee() + .pipe gulpCoffee() .pipe gulp.dest(@distDir("src")) .on "end", resolve .on "error", reject diff --git a/scripts/deploy/bump.coffee b/scripts/deploy/bump.coffee index 2548f25403..ee7693e642 100644 --- a/scripts/deploy/bump.coffee +++ b/scripts/deploy/bump.coffee @@ -1,9 +1,11 @@ _ = require("lodash") fs = require("fs-extra") Promise = require("bluebird") -bumpercar = require("cypress-bumpercar") +bumpercar = require("@cypress/bumpercar") +path = require("path") -creds = fs.readJsonSync("./support/ci.json", "utf8") +ciJson = path.join(__dirname, "support/ci.json") +creds = fs.readJsonSync(ciJson, "utf8") ## configure a new Bumpercar car = bumpercar.create({ diff --git a/scripts/deploy/upload.coffee b/scripts/deploy/upload.coffee index 005de43585..bcf87176ea 100644 --- a/scripts/deploy/upload.coffee +++ b/scripts/deploy/upload.coffee @@ -1,20 +1,25 @@ -$ = require("gulp-load-plugins")() +awspublish = require('gulp-awspublish') +rename = require('gulp-rename') +debug = require('gulp-debug') fs = require("fs-extra") cp = require("child_process") path = require("path") gulp = require("gulp") human = require("human-interval") -konfig = require("konfig")() +konfig = require("@packages/server/lib/konfig")() Promise = require("bluebird") meta = require("./meta") +# TODO please do not hardcode me +# CDN_URL = "https://cdn.cypress.io" + fs = Promise.promisifyAll(fs) module.exports = { getPublisher: -> aws = @getAwsObj() - $.awspublish.create + awspublish.create httpOptions: { timeout: human("10 minutes") } @@ -38,7 +43,7 @@ module.exports = { uploadOsName = platform.uploadOsName zipName = platform.zipName - url = [konfig.app.cdn_url, "desktop", version, uploadOsName, zipName].join("/") + url = [konfig('cdn_url'), "desktop", version, uploadOsName, zipName].join("/") cp.exec "cfcli purgefile #{url}", (err, stdout, stderr) -> return reject(err) if err @@ -53,7 +58,7 @@ module.exports = { getUrl = (uploadOsName) -> { - url: [konfig.app.cdn_url, folder, version, uploadOsName, zipName].join("/") + url: [konfig('cdn_url'), folder, version, uploadOsName, zipName].join("/") } obj = { @@ -80,12 +85,12 @@ module.exports = { new Promise (resolve, reject) => @createRemoteManifest(aws.folder, version).then (src) -> gulp.src(src) - .pipe $.rename (p) -> + .pipe rename (p) -> p.dirname = aws.folder + "/" + p.dirname p - .pipe $.debug() + .pipe debug() .pipe publisher.publish(headers) - .pipe $.awspublish.reporter() + .pipe awspublish.reporter() .on "error", reject .on "end", resolve @@ -103,16 +108,16 @@ module.exports = { headers["Cache-Control"] = "no-cache" gulp.src(pathToZipFile) - .pipe $.rename (p) => + .pipe rename (p) => p.dirname = @getUploadDirName(platform) p - .pipe $.debug() + .pipe debug() .pipe publisher.publish(headers) - .pipe $.awspublish.reporter() + .pipe awspublish.reporter() .on "error", reject .on "end", resolve upload() .then => @purgeCache(platform) -} \ No newline at end of file +} diff --git a/packages/server/gulpfile.coffee b/scripts/gulpfile.coffee similarity index 100% rename from packages/server/gulpfile.coffee rename to scripts/gulpfile.coffee From 8bb39d285764589a15914377b895374097dfda71 Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Mon, 19 Jun 2017 15:56:20 -0400 Subject: [PATCH 04/22] working on deploy run --- package.json | 1 + scripts/deploy.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index ff5466d884..19b3bf5e32 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "gulp-rename": "^1.2.2", "human-interval": "^0.1.6", "husky": "^0.13.4", + "inquirer": "^3.1.1", "konfig": "^0.2.1", "lint-staged": "^3.6.0", "obfuscator": "^0.5.4", diff --git a/scripts/deploy.js b/scripts/deploy.js index 55c820a585..c88b5516c1 100644 --- a/scripts/deploy.js +++ b/scripts/deploy.js @@ -1,3 +1,3 @@ require('../packages/coffee/register') -require('./deploy/index') +require('./deploy/index').deploy() From f5aa4d187c4f5d800af9a0bd05617cc2de5a7f49 Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Mon, 19 Jun 2017 16:18:24 -0400 Subject: [PATCH 05/22] WIP comment out obsolete run-sequence --- scripts/deploy/base.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/deploy/base.coffee b/scripts/deploy/base.coffee index 968199b3b2..3a759af793 100644 --- a/scripts/deploy/base.coffee +++ b/scripts/deploy/base.coffee @@ -9,7 +9,7 @@ chalk = require("chalk") expect = require("chai").expect Promise = require("bluebird") obfuscator = require("obfuscator") -runSequence = require("run-sequence") +# runSequence = require("run-sequence") cypressElectron = require("@packages/electron") log = require("./log") meta = require("./meta") From 40759681ebc5ac92484f396168663d78c46e3baa Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Mon, 19 Jun 2017 17:12:31 -0400 Subject: [PATCH 06/22] add cypress-io/cypress-example-recipes --- scripts/deploy/bump.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/deploy/bump.coffee b/scripts/deploy/bump.coffee index ee7693e642..8d01fd596e 100644 --- a/scripts/deploy/bump.coffee +++ b/scripts/deploy/bump.coffee @@ -27,7 +27,8 @@ PROVIDERS = { "cypress-io/cypress-example-kitchensink" "cypress-io/cypress-example-todomvc" "cypress-io/cypress-example-piechopper" - "cypress-io/cypress-example-recipes" + "cypress-io/cypress-example-recipes", + "cypress-io/cypress-example-node-versions" ] travis: [ From 6e2837c7d3db2734b3a32c253831d66dc2d68d66 Mon Sep 17 00:00:00 2001 From: Brian Mann Date: Wed, 21 Jun 2017 13:02:14 -0400 Subject: [PATCH 07/22] root: enable run all to skip package or packages by name --- scripts/run-all.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/scripts/run-all.js b/scripts/run-all.js index 0c9d6255ae..ae280347f4 100644 --- a/scripts/run-all.js +++ b/scripts/run-all.js @@ -32,15 +32,29 @@ const getDirs = () => { .map((dir) => path.join(process.cwd(), dir).replace(/\/$/, '')) } +const packageNameInArray = (dir, packages) => { + const packageName = packageNameFromPath(dir) + return _.includes(packages, packageName) +} + const filterDirsByPackage = (dirs, filter) => { if (!filter) return dirs return dirs.filter((dir) => { - const packageName = packageNameFromPath(dir) - return _.includes(filter, packageName) + return packageNameInArray(dir, filter) }) } +const rejectDirsByPackage = (dirs, rejected) => { + if (!rejected) return dirs + + if (rejected && rejected.length) { + return _.reject(dirs, (dir) => { + return packageNameInArray(dir, rejected) + }) + } +} + const filterDirsByCmd = (dirs, cmd) => { switch (cmd) { case 'install': case 'i': @@ -123,10 +137,12 @@ function keepDirsWithPackageJson (dirs) { module.exports = (cmd, options) => { const packagesFilter = options.package || options.packages + const packagesReject = options['skip-package'] || options['skip-packages'] return getDirs() .then(keepDirsWithPackageJson) .then((dirs) => filterDirsByPackage(dirs, packagesFilter)) + .then((dirs) => rejectDirsByPackage(dirs, packagesReject)) .then((dirs) => checkDirsLength(dirs, `No packages were found with the filter '${packagesFilter}'`)) .then((dirs) => filterDirsByCmd(dirs, cmd)) .then((dirs) => { From 55af26dc0829e01318df2367c7f4d25cc424a1a1 Mon Sep 17 00:00:00 2001 From: Brian Mann Date: Wed, 21 Jun 2017 16:59:53 -0400 Subject: [PATCH 08/22] deploy: move coffee lint to root --- packages/coffeelint.json => coffeelint.json | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename packages/coffeelint.json => coffeelint.json (100%) diff --git a/packages/coffeelint.json b/coffeelint.json similarity index 100% rename from packages/coffeelint.json rename to coffeelint.json From 5160ab7dcfbd6f07d6d9e033a453c07e76917870 Mon Sep 17 00:00:00 2001 From: Brian Mann Date: Wed, 21 Jun 2017 17:00:21 -0400 Subject: [PATCH 09/22] deploy: make bump async --- scripts/deploy/bump.coffee | 39 ++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/scripts/deploy/bump.coffee b/scripts/deploy/bump.coffee index 8d01fd596e..dcda5a9c9c 100644 --- a/scripts/deploy/bump.coffee +++ b/scripts/deploy/bump.coffee @@ -4,20 +4,7 @@ Promise = require("bluebird") bumpercar = require("@cypress/bumpercar") path = require("path") -ciJson = path.join(__dirname, "support/ci.json") -creds = fs.readJsonSync(ciJson, "utf8") - -## configure a new Bumpercar -car = bumpercar.create({ - providers: { - travis: { - githubToken: creds.githubToken - } - circle: { - circleToken: creds.circleToken - } - } -}) +fs = Promise.promisifyAll(fs) PROVIDERS = { circle: [ @@ -43,11 +30,27 @@ PROVIDERS = { } awaitEachProjectAndProvider = (fn) -> - promises = _.map PROVIDERS, (projects, provider) -> - Promise.map projects, (project) -> - fn(project, provider) + ciJson = path.join(__dirname, "support/ci.json") + creds = fs.readJsonSync(ciJson, "utf8") - Promise.all(promises) + fs.readJsonAsync(ciJson) + .then (creds) -> + ## configure a new Bumpercar + car = bumpercar.create({ + providers: { + travis: { + githubToken: creds.githubToken + } + circle: { + circleToken: creds.circleToken + } + } + }) + .then -> + _.map PROVIDERS, (projects, provider) -> + Promise.map projects, (project) -> + fn(project, provider) + .all() module.exports = { version: (version) -> From 60cfee379b04ae968eb98d180a314bd0d0631025 Mon Sep 17 00:00:00 2001 From: Brian Mann Date: Wed, 21 Jun 2017 17:00:42 -0400 Subject: [PATCH 10/22] deploy: WIP update deploy + build processes for monorepo --- scripts/deploy.js | 2 +- scripts/deploy/ask.coffee | 8 +- scripts/deploy/base.coffee | 264 +++++++++++++++++++++++------------- scripts/deploy/index.coffee | 28 ++-- scripts/deploy/log.coffee | 2 +- 5 files changed, 194 insertions(+), 110 deletions(-) diff --git a/scripts/deploy.js b/scripts/deploy.js index c88b5516c1..ace53d9d3e 100644 --- a/scripts/deploy.js +++ b/scripts/deploy.js @@ -1,3 +1,3 @@ -require('../packages/coffee/register') +require('@packages/coffee/register') require('./deploy/index').deploy() diff --git a/scripts/deploy/ask.coffee b/scripts/deploy/ask.coffee index 7c58556809..c134f9f1e4 100644 --- a/scripts/deploy/ask.coffee +++ b/scripts/deploy/ask.coffee @@ -91,7 +91,9 @@ module.exports = { }] }] - deployNewVersion: -> + deployNewVersion: (version) -> + return Promise.resolve(version) if version + fs.readJsonAsync("./package.json") .then (json) => prompt(@getQuestions(json.version)) @@ -128,7 +130,9 @@ module.exports = { prompt(@getReleases(versions)) .get("release") - whichPlatform: -> + whichPlatform: (platform) -> + return Promise.resolve(platform) if platform + prompt(@getPlatformQuestion()) .get("platform") diff --git a/scripts/deploy/base.coffee b/scripts/deploy/base.coffee index 3a759af793..5c9b2e7290 100644 --- a/scripts/deploy/base.coffee +++ b/scripts/deploy/base.coffee @@ -20,8 +20,14 @@ Fixtures = require("@packages/server/test/support/helpers/fixtures") # pkgr = Promise.promisify(pkgr) fs = Promise.promisifyAll(fs) +glob = Promise.promisify(glob) zipName = "cypress.zip" +DEFAULT_PATHS = "node_modules package.json".split(" ") + +pathToPackageJson = (pkg) -> + path.join(pkg, "package.json") + class Base constructor: (os, @options = {}) -> _.defaults @options, @@ -47,8 +53,10 @@ class Base getVersion: -> @options.version ? fs.readJsonSync(@distDir("package.json")).version - copyFiles: -> - @log("#copyFiles") + copyPackages: -> + @log("#copyPackages") + + dist = @distDir() copy = (src, dest) => dest ?= src @@ -56,81 +64,105 @@ class Base fs.copyAsync(src, dest) + copyRelativePathToDist = (relative) -> + dest = path.join(dist, relative) + + console.log(relative, "->", dest) + + # copy = -> + # new Promise (resolve, reject) -> + # cp.spawn("cp", ["-R", relative, dest], {stdio: "inherit"}) + # .on "error", reject + # .on "exit", resolve + + # if relative.includes(".") + # copy() + # else + # fs.ensureDirAsync(dest) + # .then(copy) + + fs.copyAsync(relative, dest) + + copyPackage = (pkg) -> + ## copies the package to dist + ## including the default paths + ## and any specified in package.json files + fs.readJsonAsync(pathToPackageJson(pkg)) + .then (json) -> + ## grab all the files + ## and default included paths + ## and convert to relative paths + DEFAULT_PATHS + .concat(json.files or []) + .map (file) -> + path.join(pkg, file) + .map(copyRelativePathToDist, {concurrency: 1}) + + ## fs-extra concurrency tests (copyPackage / copyRelativePathToDist) + ## 1/1 41688 + ## 1/5 42218 + ## 1/10 42566 + ## 2/1 45041 + ## 2/2 43589 + ## 3/3 51399 + + ## cp -R concurrency tests + ## 1/1 65811 + + started = new Date() + fs - .removeAsync(@distDir()) + .removeAsync(dist) .bind(@) .then -> - fs.ensureDirAsync(@distDir()) + fs.ensureDirAsync(dist) .then -> - [ - ## copy root files - copy("./package.json") - copy("./config/app.yml") - copy("./lib/html") - copy("./lib/public") - copy("./lib/scaffold") - copy("./lib/ipc") + glob("./packages/*") + .map(copyPackage, {concurrency: 1}) + .then -> + console.log("Finished Copying", new Date() - started) - ## copy entry point - copy("./index.js", "/src/index.js") + prunePackages: -> + pathToDistPackages = @distDir("packages", "*") - ## copy coffee src files - copy("./lib/automation", "/src/lib/automation") - copy("./lib/browsers", "/src/lib/browsers") - copy("./lib/controllers", "/src/lib/controllers") - copy("./lib/gui", "/src/lib/gui") - copy("./lib/modes", "/src/lib/modes") - copy("./lib/util", "/src/lib/util") - copy("./lib/api.coffee", "/src/lib/api.coffee") - copy("./lib/cache.coffee", "/src/lib/cache.coffee") - copy("./lib/config.coffee", "/src/lib/config.coffee") - copy("./lib/cwd.coffee", "/src/lib/cwd.coffee") - copy("./lib/cypress.coffee", "/src/lib/cypress.coffee") - copy("./lib/environment.coffee", "/src/lib/environment.coffee") - copy("./lib/errors.coffee", "/src/lib/errors.coffee") - copy("./lib/exception.coffee", "/src/lib/exception.coffee") - copy("./lib/exec.coffee", "/src/lib/exec.coffee") - copy("./lib/file_server.coffee", "/src/lib/file_server.coffee") - copy("./lib/files.coffee", "/src/lib/files.coffee") - copy("./lib/fixture.coffee", "/src/lib/fixture.coffee") - copy("./lib/ids.coffee", "/src/lib/ids.coffee") - copy("./lib/konfig.coffee", "/src/lib/konfig.coffee") - copy("./lib/logger.coffee", "/src/lib/logger.coffee") - copy("./lib/open_project.coffee", "/src/lib/open_project.coffee") - copy("./lib/project.coffee", "/src/lib/project.coffee") - copy("./lib/reporter.coffee", "/src/lib/reporter.coffee") - copy("./lib/request.coffee", "/src/lib/request.coffee") - copy("./lib/routes.coffee", "/src/lib/routes.coffee") - copy("./lib/saved_state.coffee", "/src/lib/saved_state.coffee") - copy("./lib/scaffold.coffee", "/src/lib/scaffold.coffee") - copy("./lib/screenshots.coffee", "/src/lib/screenshots.coffee") - copy("./lib/server.coffee", "/src/lib/server.coffee") - copy("./lib/socket.coffee", "/src/lib/socket.coffee") - copy("./lib/stats.coffee", "/src/lib/stats.coffee") - copy("./lib/stdout.coffee", "/src/lib/stdout.coffee") - copy("./lib/updater.coffee", "/src/lib/updater.coffee") - copy("./lib/upload.coffee", "/src/lib/upload.coffee") - copy("./lib/user.coffee", "/src/lib/user.coffee") - copy("./lib/video.coffee", "/src/lib/video.coffee") - copy("./lib/watchers.coffee", "/src/lib/watchers.coffee") + ## 1,060,495,784 bytes (1.54 GB on disk) for 179,156 items + ## 313,416,512 bytes (376.6 MB on disk) for 23,576 items - ] - .all() + prune = (pkg) -> + console.log("prune", pkg) - convertToJs: -> - @log("#convertToJs") + new Promise (resolve, reject) -> + cp.spawn("npm", ["prune", "--production"], { + cwd: pkg + stdio: "inherit" + }) + .on("error", reject) + .on("exit", (code) -> + if code is 0 + resolve() + else + reject(new Error("'npm prune --production' on #{pkg} failed with exit code: #{code}")) + ) + + ## prunes out all of the devDependencies + ## from what was copied + glob(pathToDistPackages) + .map(prune) + + convertCoffeeToJs: -> + @log("#convertCoffeeToJs") ## grab everything in src ## convert to js new Promise (resolve, reject) => - gulp.src(@distDir("src/**/*.coffee")) + gulp.src(@distDir("lib", "**", "*.coffee")) .pipe gulpCoffee() - .pipe gulp.dest(@distDir("src")) - .on "end", resolve - .on "error", reject + .pipe gulp.dest(@distDir("lib")) + .on("end", resolve) + .on("error", reject) - distDir: (src) -> - args = _.compact [meta.distDir, @osName, src] + distDir: (args...) -> + args = _.compact [meta.distDir, @osName, args...] path.join args... obfuscate: -> @@ -170,23 +202,54 @@ class Base cleanup().catch(cleanup) - ## add tests around this method - updatePackage: -> - @log("#updatePackage") + symlinkPackages: -> + @log("#symlinkPackages") + dist = @distDir() + pathToPackages = path.join('node_modules', '@') + pathToDistPackages = @distDir("packages", "*") + + symlink = (pkg) -> + # console.log(pkg, dist) + ## strip off the initial './' + ## ./packages/foo -> node_modules/@packages/foo + dest = path.join(dist, "node_modules", "@packages", path.basename(pkg)) + + fs.ensureSymlinkAsync(pkg, dest) + + glob(pathToDistPackages) + .map(symlink) + + # // glob all of the names of packages + # glob('./packages/*') + # .map((folder) => { + # // strip off the initial './' + # // ./packages/foo -> node_modules/@packages/foo + # const dest = pathToPackages + folder.slice(2) + # + # console.log('symlinking', folder, '->', dest) + # + # return fs.ensureSymlinkAsync(folder, dest) + # }) + + ## add tests around this method + createRootPackage: -> version = @options.version - fs.readJsonAsync(@distDir("package.json")).then (json) => - json.env = "production" - json.version = version if version - json.scripts = {} + @log("#createRootPackage #{version}") - @log("#settingVersion: #{json.version}") + fs.outputJsonAsync(@distDir("package.json"), { + name: "cypress" + productName: "Cypress", + version: version + main: "index.js" + scripts: {} + env: "production" + }) + .then => + str = "require('./packages/server')" - delete json.devDependencies - delete json.bin - - fs.writeJsonAsync(@distDir("package.json"), json) + fs.outputFileAsync(@distDir("index.js"), str) npmInstall: -> @log("#npmInstall") @@ -245,12 +308,21 @@ class Base log: -> log.apply(@, arguments) - gulpBuild: -> - @log("#gulpBuild") + buildPackages: -> + @log("#buildPackages") new Promise (resolve, reject) -> - runSequence "app:build", (err) -> - if err then reject(err) else resolve() + console.log(process.cwd()) + + ## build all the packages except for + ## cli and docs + cp.spawn("npm", ["run", "all", "build", "--", "--skip-packages", "cli,docs"], { stdio: "inherit" }) + .on "error", reject + .on "exit", (code) -> + if code is 0 + resolve() + else + reject(new Error("'npm run build' failed with exit code: #{code}")) _runProjectTest: -> @log("#runProjectTest") @@ -346,22 +418,24 @@ class Base build: -> Promise .bind(@) - .then(@cleanupPlatform) - .then(@gulpBuild) - .then(@copyFiles) - .then(@updatePackage) - .then(@convertToJs) - .then(@obfuscate) - .then(@cleanupSrc) - .then(@npmInstall) - .then(@npmInstall) - .then(@elBuilder) - .then(@runSmokeTest) - .then(@runProjectTest) - .then(@runFailingProjectTest) - .then(@cleanupCy) - .then(@codeSign) ## codesign after running smoke tests due to changing .cy - .then(@verifyAppCanOpen) + # .then(@cleanupPlatform) + # .then(@buildPackages) + # .then(@copyPackages) + # .then(@prunePackages) + .then(@createRootPackage) + .then(@symlinkPackages) + # .then(@convertCoffeeToJs) + # .then(@obfuscate) + # .then(@cleanupSrc) + # .then(@npmInstall) + # .then(@npmInstall) + # .then(@elBuilder) + # .then(@runSmokeTest) + # .then(@runProjectTest) + # .then(@runFailingProjectTest) + # .then(@cleanupCy) + # .then(@codeSign) ## codesign after running smoke tests due to changing .cy + # .then(@verifyAppCanOpen) .return(@) module.exports = Base diff --git a/scripts/deploy/index.coffee b/scripts/deploy/index.coffee index b61a3d666d..5be04aff96 100644 --- a/scripts/deploy/index.coffee +++ b/scripts/deploy/index.coffee @@ -1,3 +1,6 @@ +## store the cwd +cwd = process.cwd() + _ = require("lodash") os = require("os") chalk = require("chalk") @@ -18,6 +21,9 @@ success = (str) -> fail = (str) -> console.log chalk.bgRed(" " + chalk.black(str) + " ") +## hack for server modifying cwd +process.chdir(cwd) + deploy = { zip: zip ask: ask @@ -82,22 +88,22 @@ deploy = { ## read off the argv options = @parseOptions(process.argv) - ask.whichPlatform() + ask.whichPlatform(options.platform) .then (o) => - ask.deployNewVersion() + ask.deployNewVersion(options.version) .then (version) => options.version = version @getPlatform(o, options).deploy() - .then (platform) => - zip.ditto(platform) - .then => - upload.toS3(platform) - .then -> - success("Dist Complete") - .catch (err) -> - fail("Dist Failed") - console.log(err) + # .then (platform) => + # zip.ditto(platform) + # .then => + # upload.toS3(platform) + # .then -> + # success("Dist Complete") + # .catch (err) -> + # fail("Dist Failed") + # console.log(err) } diff --git a/scripts/deploy/log.coffee b/scripts/deploy/log.coffee index 1c3bc77127..bed77828c6 100644 --- a/scripts/deploy/log.coffee +++ b/scripts/deploy/log.coffee @@ -3,4 +3,4 @@ chalk = require("chalk") module.exports = (msg, color = "yellow") -> return if process.env["NODE_ENV"] is "test" - console.log chalk[color](msg), chalk.bgWhite(chalk.black(@osName)) \ No newline at end of file + console.log chalk[color](msg), chalk.bgWhite(chalk.black(@osName)) From 843fb573202902c0cd43dcf76f5d91beb0b73b45 Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Wed, 21 Jun 2017 17:40:12 -0400 Subject: [PATCH 11/22] Add cypress-io/cypress-example-module-api project build to bump --- scripts/deploy/bump.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/deploy/bump.coffee b/scripts/deploy/bump.coffee index dcda5a9c9c..d2b73229bf 100644 --- a/scripts/deploy/bump.coffee +++ b/scripts/deploy/bump.coffee @@ -16,6 +16,7 @@ PROVIDERS = { "cypress-io/cypress-example-piechopper" "cypress-io/cypress-example-recipes", "cypress-io/cypress-example-node-versions" + "cypress-io/cypress-example-module-api" ] travis: [ From 108426f8d11db3916853cee039e440bfab01f481 Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Wed, 21 Jun 2017 17:40:52 -0400 Subject: [PATCH 12/22] remove commas --- scripts/deploy/bump.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/deploy/bump.coffee b/scripts/deploy/bump.coffee index d2b73229bf..927e8dc9f8 100644 --- a/scripts/deploy/bump.coffee +++ b/scripts/deploy/bump.coffee @@ -14,7 +14,7 @@ PROVIDERS = { "cypress-io/cypress-example-kitchensink" "cypress-io/cypress-example-todomvc" "cypress-io/cypress-example-piechopper" - "cypress-io/cypress-example-recipes", + "cypress-io/cypress-example-recipes" "cypress-io/cypress-example-node-versions" "cypress-io/cypress-example-module-api" ] From 4729caeaf01c611109ae824af4e1ba0f7d625fa9 Mon Sep 17 00:00:00 2001 From: Gleb Bahmutov Date: Thu, 22 Jun 2017 15:27:51 -0400 Subject: [PATCH 13/22] Add project cypress-io/cypress-test-ci-environments to list of projects to test --- scripts/deploy/bump.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/deploy/bump.coffee b/scripts/deploy/bump.coffee index 927e8dc9f8..6a63526c63 100644 --- a/scripts/deploy/bump.coffee +++ b/scripts/deploy/bump.coffee @@ -17,6 +17,7 @@ PROVIDERS = { "cypress-io/cypress-example-recipes" "cypress-io/cypress-example-node-versions" "cypress-io/cypress-example-module-api" + "cypress-io/cypress-test-ci-environments" ] travis: [ From 28cd6f927a3f69ee4181c0f76255495731e1edc5 Mon Sep 17 00:00:00 2001 From: Brian Mann Date: Thu, 22 Jun 2017 16:27:25 -0400 Subject: [PATCH 14/22] deploy: WIP refactor classes -> functional --- scripts/deploy/ask.coffee | 8 +- scripts/deploy/build.coffee | 81 ++++++++++++++++ scripts/deploy/index.coffee | 67 ++++++++----- scripts/deploy/util/packages.coffee | 145 ++++++++++++++++++++++++++++ 4 files changed, 273 insertions(+), 28 deletions(-) create mode 100644 scripts/deploy/build.coffee create mode 100644 scripts/deploy/util/packages.coffee diff --git a/scripts/deploy/ask.coffee b/scripts/deploy/ask.coffee index c134f9f1e4..7c58556809 100644 --- a/scripts/deploy/ask.coffee +++ b/scripts/deploy/ask.coffee @@ -91,9 +91,7 @@ module.exports = { }] }] - deployNewVersion: (version) -> - return Promise.resolve(version) if version - + deployNewVersion: -> fs.readJsonAsync("./package.json") .then (json) => prompt(@getQuestions(json.version)) @@ -130,9 +128,7 @@ module.exports = { prompt(@getReleases(versions)) .get("release") - whichPlatform: (platform) -> - return Promise.resolve(platform) if platform - + whichPlatform: -> prompt(@getPlatformQuestion()) .get("platform") diff --git a/scripts/deploy/build.coffee b/scripts/deploy/build.coffee new file mode 100644 index 0000000000..2e860cd1f9 --- /dev/null +++ b/scripts/deploy/build.coffee @@ -0,0 +1,81 @@ +fs = require("fs-extra") +path = require("path") +chalk = require("chalk") +Promise = require("bluebird") +packages = require("./util/packages") + +fs = Promise.promisifyAll(fs) + +log = (msg, platform) -> + console.log(chalk.yellow(msg), chalk.bgWhite(chalk.black(platform))) + +module.exports = (platform, version) -> + distDir = (args...) -> + path.resolve("dist", platform, args...) + + cleanupPlatform = -> + log("#cleanupPlatform", platform) + + cleanup = => + fs.removeAsync(distDir()) + + cleanup() + .catch(cleanup) + + buildPackages = -> + log("#buildPackages", platform) + + packages.runAllBuild() + + copyPackages = -> + log("#copyPackages", platform) + + packages.copyAllToDist(distDir()) + + prunePackages = -> + log("#prunePackages", platform) + + packages.pruneAll(distDir("packages", "*")) + + createRootPackage = -> + log("#createRootPackage", platform, version) + + fs.outputJsonAsync(distDir("package.json"), { + name: "cypress" + productName: "Cypress", + version: version + main: "index.js" + scripts: {} + env: "production" + }) + .then => + str = "require('./packages/server')" + + fs.outputFileAsync(distDir("index.js"), str) + + symlinkPackages = -> + log("#symlinkPackages", platform) + + packages.symlinkAll(distDir) + + Promise + .bind(@) + .then(cleanupPlatform) + .then(buildPackages) + .then(copyPackages) + .then(prunePackages) + .then(createRootPackage) + .then(symlinkPackages) + # .then(@convertCoffeeToJs) + # .then(@obfuscate) + # .then(@cleanupSrc) + # .then(@npmInstall) + # .then(@npmInstall) + # .then(@elBuilder) + # .then(@runSmokeTest) + # .then(@runProjectTest) + # .then(@runFailingProjectTest) + # .then(@cleanupCy) + # .then(@codeSign) ## codesign after running smoke tests due to changing .cy + # .then(@verifyAppCanOpen) + # .return(@) diff --git a/scripts/deploy/index.coffee b/scripts/deploy/index.coffee index 5be04aff96..2dd076b69c 100644 --- a/scripts/deploy/index.coffee +++ b/scripts/deploy/index.coffee @@ -10,6 +10,7 @@ zip = require("./zip") ask = require("./ask") bump = require("./bump") meta = require("./meta") +build = require("./build") upload = require("./upload") Base = require("./base") Linux = require("./linux") @@ -21,9 +22,27 @@ success = (str) -> fail = (str) -> console.log chalk.bgRed(" " + chalk.black(str) + " ") -## hack for server modifying cwd +## hack for @packages/server modifying cwd process.chdir(cwd) +askWhichPlatform = (platform) -> + ## if we already have a platform + ## just resolve with that + if platform + return Promise.resolve(platform) + + ## else go ask for it! + ask.whichPlatform() + +askWhichVersion = (version) -> + ## if we already have a version + ## just resolve with that + if version + return Promise.resolve(version) + + ## else go ask for it! + ask.deployNewVersion() + deploy = { zip: zip ask: ask @@ -33,27 +52,27 @@ deploy = { Darwin: Darwin Linux: Linux - getPlatform: (platform, options) -> - platform ?= os.platform() - - Platform = @[platform.slice(0, 1).toUpperCase() + platform.slice(1)] - - throw new Error("Platform: '#{platform}' not found") if not Platform - - options ?= @parseOptions(process.argv.slice(2)) - - (new Platform(platform, options)) + # getPlatform: (platform, options) -> + # platform ?= os.platform() + # + # Platform = @[platform.slice(0, 1).toUpperCase() + platform.slice(1)] + # + # throw new Error("Platform: '#{platform}' not found") if not Platform + # + # options ?= @parseOptions(process.argv.slice(2)) + # + # (new Platform(platform, options)) parseOptions: (argv) -> opts = minimist(argv) opts.runTests = false if opts["skip-tests"] opts - build: (platform) -> - ## read off the argv - options = @parseOptions(process.argv) - - @getPlatform(platform?.osName, options).build() + # build: (platform) -> + # ## read off the argv + # options = @parseOptions(process.argv) + # + # @getPlatform(platform?.osName, options).build() bump: -> ask.whichBumpTask() @@ -88,13 +107,17 @@ deploy = { ## read off the argv options = @parseOptions(process.argv) - ask.whichPlatform(options.platform) - .then (o) => - ask.deployNewVersion(options.version) - .then (version) => - options.version = version + askWhichPlatform(options.platform) + .then (platform) -> + askWhichVersion(options.version) + .then (version) -> + # options.version = version - @getPlatform(o, options).deploy() + build(platform, version) + # .return([platform, version]) + # .spread (platform, version) -> + + # @getPlatform(plat, options).deploy() # .then (platform) => # zip.ditto(platform) # .then => diff --git a/scripts/deploy/util/packages.coffee b/scripts/deploy/util/packages.coffee new file mode 100644 index 0000000000..33a5d355b2 --- /dev/null +++ b/scripts/deploy/util/packages.coffee @@ -0,0 +1,145 @@ +_ = require("lodash") +fs = require("fs-extra") +cp = require("child_process") +path = require("path") +glob = require("glob") +Promise = require("bluebird") + +fs = Promise.promisifyAll(fs) +glob = Promise.promisify(glob) + +DEFAULT_PATHS = "node_modules package.json".split(" ") + +pathToPackageJson = (pkg) -> + path.join(pkg, "package.json") + +runAllBuild = -> + new Promise (resolve, reject) -> + reject = _.once(reject) + + ## build all the packages except for + ## cli and docs + cp.spawn("npm", ["run", "all", "build", "--", "--skip-packages", "cli,docs"], { stdio: "inherit" }) + .on "error", reject + .on "exit", (code) -> + if code is 0 + resolve() + else + reject(new Error("'npm run build' failed with exit code: #{code}")) + + +copyAllToDist = (distDir) -> + copyRelativePathToDist = (relative) -> + dest = path.join(distDir, relative) + + console.log(relative, "->", dest) + + fs.copyAsync(relative, dest) + + copyPackage = (pkg) -> + ## copies the package to dist + ## including the default paths + ## and any specified in package.json files + fs.readJsonAsync(pathToPackageJson(pkg)) + .then (json) -> + ## grab all the files + ## and default included paths + ## and convert to relative paths + DEFAULT_PATHS + .concat(json.files or []) + .map (file) -> + path.join(pkg, file) + .map(copyRelativePathToDist, {concurrency: 1}) + + ## fs-extra concurrency tests (copyPackage / copyRelativePathToDist) + ## 1/1 41688 + ## 1/5 42218 + ## 1/10 42566 + ## 2/1 45041 + ## 2/2 43589 + ## 3/3 51399 + + ## cp -R concurrency tests + ## 1/1 65811 + + started = new Date() + + fs.ensureDirAsync(distDir) + .then -> + glob("./packages/*") + .map(copyPackage, {concurrency: 1}) + .then -> + console.log("Finished Copying", new Date() - started) + .delay(10000) + +pruneAll = (pathToPackages) -> + ## 1,060,495,784 bytes (1.54 GB on disk) for 179,156 items + ## 313,416,512 bytes (376.6 MB on disk) for 23,576 items + + retryGlobbing = -> + glob(pathToPackages) + .catch {code: "EMFILE"}, -> + ## wait 1 second then retry + Promise + .delay(1000) + .then(retryGlobbing) + + prune = (pkg) -> + console.log("pruning", pkg) + + new Promise (resolve, reject) -> + reject = _.once(reject) + + ## ignore node_modules/.bin due to symlinking + cp.spawn("npm", ["prune", "--production", "--ignore", "node_modules/\.bin"], { + cwd: pkg + stdio: "inherit" + }) + .on("error", reject) + .on("exit", (code) -> + if code is 0 + resolve() + else + reject(new Error("'npm prune --production' on #{pkg} failed with exit code: #{code}")) + ) + + retryPrune = (pkg) -> + prune(pkg) + .catch {code: "EMFILE"}, -> + Promise + .delay(1000) + .then -> + retryPrune(pkg) + .catch (err) -> + console.log(err, err.code) + throw err + + ## prunes out all of the devDependencies + ## from what was copied + retryGlobbing() + .map(retryPrune, {concurrency: 1}) + +symlinkAll = (distDir) -> + pathToPackages = path.join('node_modules', '@') + pathToDistPackages = distDir("packages", "*") + + symlink = (pkg) -> + # console.log(pkg, dist) + ## strip off the initial './' + ## ./packages/foo -> node_modules/@packages/foo + dest = path.join(distDir(), "node_modules", "@packages", path.basename(pkg)) + + fs.ensureSymlinkAsync(pkg, dest) + + glob(pathToDistPackages) + .map(symlink) + +module.exports = { + runAllBuild + + copyAllToDist + + pruneAll + + symlinkAll +} From 7f476d15f3db66e27c4927a7040ae836f85ba437 Mon Sep 17 00:00:00 2001 From: Brian Mann Date: Thu, 22 Jun 2017 16:35:13 -0400 Subject: [PATCH 15/22] deploy: don't copy node_modules or prune -> just npm install --- scripts/deploy/build.coffee | 8 ++++---- scripts/deploy/util/packages.coffee | 26 +++++++++++++++----------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/scripts/deploy/build.coffee b/scripts/deploy/build.coffee index 2e860cd1f9..f18ff87984 100644 --- a/scripts/deploy/build.coffee +++ b/scripts/deploy/build.coffee @@ -32,10 +32,10 @@ module.exports = (platform, version) -> packages.copyAllToDist(distDir()) - prunePackages = -> - log("#prunePackages", platform) + npmInstallPackages = -> + log("#npmInstallPackages", platform) - packages.pruneAll(distDir("packages", "*")) + packages.npmInstallAll(distDir("packages", "*")) createRootPackage = -> log("#createRootPackage", platform, version) @@ -63,7 +63,7 @@ module.exports = (platform, version) -> .then(cleanupPlatform) .then(buildPackages) .then(copyPackages) - .then(prunePackages) + .then(npmInstallPackages) .then(createRootPackage) .then(symlinkPackages) # .then(@convertCoffeeToJs) diff --git a/scripts/deploy/util/packages.coffee b/scripts/deploy/util/packages.coffee index 33a5d355b2..9fbfd0d01d 100644 --- a/scripts/deploy/util/packages.coffee +++ b/scripts/deploy/util/packages.coffee @@ -8,7 +8,7 @@ Promise = require("bluebird") fs = Promise.promisifyAll(fs) glob = Promise.promisify(glob) -DEFAULT_PATHS = "node_modules package.json".split(" ") +DEFAULT_PATHS = "package.json".split(" ") pathToPackageJson = (pkg) -> path.join(pkg, "package.json") @@ -72,10 +72,12 @@ copyAllToDist = (distDir) -> console.log("Finished Copying", new Date() - started) .delay(10000) -pruneAll = (pathToPackages) -> +npmInstallAll = (pathToPackages) -> ## 1,060,495,784 bytes (1.54 GB on disk) for 179,156 items ## 313,416,512 bytes (376.6 MB on disk) for 23,576 items + started = new Date() + retryGlobbing = -> glob(pathToPackages) .catch {code: "EMFILE"}, -> @@ -84,14 +86,14 @@ pruneAll = (pathToPackages) -> .delay(1000) .then(retryGlobbing) - prune = (pkg) -> - console.log("pruning", pkg) + npmInstall = (pkg) -> + console.log("npm installing", pkg) new Promise (resolve, reject) -> reject = _.once(reject) ## ignore node_modules/.bin due to symlinking - cp.spawn("npm", ["prune", "--production", "--ignore", "node_modules/\.bin"], { + cp.spawn("npm", ["install", "--production"], { cwd: pkg stdio: "inherit" }) @@ -100,16 +102,16 @@ pruneAll = (pathToPackages) -> if code is 0 resolve() else - reject(new Error("'npm prune --production' on #{pkg} failed with exit code: #{code}")) + reject(new Error("'npm install --production' on #{pkg} failed with exit code: #{code}")) ) - retryPrune = (pkg) -> - prune(pkg) + retryNpmInstall = (pkg) -> + npmInstall(pkg) .catch {code: "EMFILE"}, -> Promise .delay(1000) .then -> - retryPrune(pkg) + retryNpmInstall(pkg) .catch (err) -> console.log(err, err.code) throw err @@ -117,7 +119,9 @@ pruneAll = (pathToPackages) -> ## prunes out all of the devDependencies ## from what was copied retryGlobbing() - .map(retryPrune, {concurrency: 1}) + .map(retryNpmInstall) + .then -> + console.log("Finished NPM Installing", new Date() - started) symlinkAll = (distDir) -> pathToPackages = path.join('node_modules', '@') @@ -139,7 +143,7 @@ module.exports = { copyAllToDist - pruneAll + npmInstallAll symlinkAll } From d5c3078cec7b2fce032e8c11eaa6d1265985e60e Mon Sep 17 00:00:00 2001 From: Brian Mann Date: Thu, 22 Jun 2017 17:19:12 -0400 Subject: [PATCH 16/22] cli: consolidate important fields into monorepo root, pull out and build --- cli/package.json | 15 ++------------- cli/scripts/build.js | 15 ++++++++++++++- package.json | 14 ++++++++++++-- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/cli/package.json b/cli/package.json index efc8914956..d8cbce4767 100644 --- a/cli/package.json +++ b/cli/package.json @@ -1,12 +1,11 @@ { "name": "cypress", "version": "0.0.0", - "description": "dev build project for Cypress NPM package", "main": "index.js", + "private": true, "bin": { "cypress": "bin/cypress" }, - "private": true, "scripts": { "pretest": "npm run lint && npm run test-dependencies", "test": "npm run test-unit", @@ -61,15 +60,5 @@ "bin", "lib", "index.js" - ], - "repository": { - "type": "git", - "url": "https://github.com/cypress-io/cypress.git" - }, - "author": "Brian Mann", - "license": "MIT", - "bugs": { - "url": "https://github.com/cypress-io/cypress/issues" - }, - "homepage": "https://github.com/cypress-io/cypress" + ] } diff --git a/cli/scripts/build.js b/cli/scripts/build.js index f208d65b07..3f9f32a2a1 100644 --- a/cli/scripts/build.js +++ b/cli/scripts/build.js @@ -5,7 +5,15 @@ const Promise = require('bluebird') const fs = Promise.promisifyAll(require('fs-extra')) // grab the current version from the root monorepo package.json -const { version, description } = require('../../package.json') +const { + version, + description, + author, + homepage, + license, + bugs, + repository, +} = require('../../package.json') const packageJsonSrc = path.join('package.json') const packageJsonDest = path.join('build', 'package.json') @@ -19,6 +27,11 @@ function preparePackageForNpmRelease (json) { _.extend(json, { version, description, + author, + homepage, + license, + bugs, + repository, scripts: { postinstall: 'node index.js --exec install', size: 't=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";', diff --git a/package.json b/package.json index 3dd366c5d5..2e2814b56b 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { - "name": "cypress-monorepo", + "name": "cypress", + "productName": "Cypresss", "version": "0.19.4", "description": "Cypress.io end to end testing tool", "private": true, @@ -60,5 +61,14 @@ "vagrant": "0.0.1", "xvfb": "^0.2.3" }, - "license": "MIT" + "author": "Brian Mann", + "license": "MIT", + "homepage": "https://github.com/cypress-io/cypress", + "repository": { + "type": "git", + "url": "https://github.com/cypress-io/cypress.git" + }, + "bugs": { + "url": "https://github.com/cypress-io/cypress/issues" + } } From c165c634d41c543408cb4178890fa9dd5cef1622 Mon Sep 17 00:00:00 2001 From: Brian Mann Date: Thu, 22 Jun 2017 17:20:45 -0400 Subject: [PATCH 17/22] all: cleanup package.json, remove versions, license, repo information -move some deps to devDeps --- docs/package.json | 1 - packages/desktop-gui/package.json | 13 +------------ packages/driver/package.json | 3 +-- packages/electron/package.json | 15 ++------------- packages/example/package.json | 21 ++++----------------- packages/extension/package.json | 15 ++------------- packages/https-proxy/package.json | 13 +------------ packages/launcher/package.json | 13 +------------ packages/reporter/package.json | 12 +----------- packages/runner/package.json | 11 +---------- packages/server/package.json | 14 +------------- packages/socket/package.json | 13 +------------ packages/static/package.json | 1 + packages/ts/package.json | 6 +----- 14 files changed, 18 insertions(+), 133 deletions(-) diff --git a/docs/package.json b/docs/package.json index 66c40f155a..456360c932 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,7 +1,6 @@ { "name": "cypress-documentation", "version": "0.0.0", - "description": "Cypress.io documentation", "private": true, "hexo": { "version": "3.3.7" diff --git a/packages/desktop-gui/package.json b/packages/desktop-gui/package.json index 69107720f7..187afe6988 100644 --- a/packages/desktop-gui/package.json +++ b/packages/desktop-gui/package.json @@ -1,7 +1,6 @@ { "name": "@packages/desktop-gui", - "version": "0.4.9", - "description": "Desktop GUI for managing Cypress projects.", + "version": "0.0.0", "main": "lib/gui.js", "private": true, "scripts": { @@ -17,16 +16,6 @@ "test": "echo 'No unit tests to run, but there are e2e tests'", "pretest": "npm run lint" }, - "repository": { - "type": "git", - "url": "https://github.com/cypress-io/cypress-core-desktop-gui.git" - }, - "author": "Brian Mann", - "license": "MIT", - "bugs": { - "url": "https://github.com/cypress-io/cypress-core-desktop-gui/issues" - }, - "homepage": "https://github.com/cypress-io/cypress-core-desktop-gui", "files": [ "dist", "lib" diff --git a/packages/driver/package.json b/packages/driver/package.json index 8095c3aea0..b70e3c2fcf 100644 --- a/packages/driver/package.json +++ b/packages/driver/package.json @@ -1,7 +1,6 @@ { "name": "@packages/driver", - "version": "1.0.0", - "description": "", + "version": "0.0.0", "private": true, "scripts": { "postinstall": "echo '@packages/driver needs: npm run build'", diff --git a/packages/electron/package.json b/packages/electron/package.json index 0c2f6b2980..066b078c70 100644 --- a/packages/electron/package.json +++ b/packages/electron/package.json @@ -1,9 +1,8 @@ { "name": "@packages/electron", - "version": "0.3.4", - "private": true, + "version": "0.0.0", "electronVersion": "1.4.6", - "description": "Cypress electron wrapper shell", + "private": true, "main": "index.js", "scripts": { "postinstall": "echo '@packages/electron needs: npm run build'", @@ -15,16 +14,6 @@ "bin": { "cypress-electron": "./bin/cypress-electron" }, - "repository": { - "type": "git", - "url": "git+https://github.com/cypress-io/cypress-core-electron.git" - }, - "author": "Brian Mann", - "license": "MIT", - "bugs": { - "url": "https://github.com/cypress-io/cypress-core-electron/issues" - }, - "homepage": "https://github.com/cypress-io/cypress-core-electron#readme", "devDependencies": { "@cypress/releaser": "0.1.12", "chai": "^3.5.0", diff --git a/packages/example/package.json b/packages/example/package.json index 2e2035a785..b62a2da67a 100644 --- a/packages/example/package.json +++ b/packages/example/package.json @@ -1,8 +1,7 @@ { "name": "@packages/example", - "version": "0.8.0", + "version": "0.0.0", "private": true, - "description": "Interal Cypress repo for managing https://example.cypress.io", "main": "index.js", "scripts": { "postinstall": "echo '@packages/example needs: npm run build'", @@ -17,29 +16,17 @@ "lint": "$(bin-up eslint) --fix *.js bin/*.js lib/*.js test/*.js", "pretest": "npm run lint" }, - "author": "Brian Mann", - "license": "MIT", - "dependencies": { - "cypress-example-kitchensink": "0.7.0", - "glob": "^7.0.3" - }, "devDependencies": { "@cypress/releaser": "0.1.12", "bin-up": "^1.0.1", "chai": "^3.5.0", + "cypress-example-kitchensink": "0.7.0", + "glob": "^7.0.3", "gulp": "^3.9.1", "gulp-clean": "^0.3.1", "gulp-gh-pages": "^0.5.4", "gulp-rev-all": "^0.8.22", "mocha": "^2.4.5", "run-sequence": "^1.1.5" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/cypress-io/cypress-core-example.git" - }, - "bugs": { - "url": "https://github.com/cypress-io/cypress-core-example/issues" - }, - "homepage": "https://github.com/cypress-io/cypress-core-example#readme" + } } diff --git a/packages/extension/package.json b/packages/extension/package.json index 9b3f1a352a..67bab27d8b 100644 --- a/packages/extension/package.json +++ b/packages/extension/package.json @@ -1,8 +1,7 @@ { "name": "@packages/extension", - "version": "0.4.2", + "version": "0.0.0", "private": true, - "description": "Cypress Chrome Extension", "main": "index.js", "scripts": { "postinstall": "echo '@packages/extension needs: npm run build'", @@ -20,18 +19,9 @@ "lib", "theme" ], - "repository": { - "type": "git", - "url": "git+https://github.com/cypress-io/cypress-core-extension.git" - }, - "author": "Brian Mann", - "license": "MIT", - "bugs": { - "url": "https://github.com/cypress-io/cypress-core-extension/issues" - }, - "homepage": "https://github.com/cypress-io/cypress-core-extension#readme", "devDependencies": { "@cypress/core-socket": "0.1.0", + "@cypress/icons": "0.5.4", "@cypress/releaser": "0.1.12", "browserify": "^13.0.0", "chai": "^3.5.0", @@ -47,7 +37,6 @@ "vinyl-source-stream": "^1.1.0" }, "dependencies": { - "@cypress/icons": "0.5.4", "bluebird": "^3.3.5", "lodash": "^4.11.2" } diff --git a/packages/https-proxy/package.json b/packages/https-proxy/package.json index 8e9b70ff23..bca9e3867c 100644 --- a/packages/https-proxy/package.json +++ b/packages/https-proxy/package.json @@ -1,7 +1,6 @@ { "name": "@packages/https-proxy", - "version": "0.1.5", - "description": "", + "version": "0.0.0", "private": true, "main": "index.js", "scripts": { @@ -12,16 +11,6 @@ "https": "node https.js", "release": "releaser" }, - "repository": { - "type": "git", - "url": "git+https://github.com/cypress-io/cypress-core-https-proxy.git" - }, - "author": "Brian Mann", - "license": "MIT", - "bugs": { - "url": "https://github.com/cypress-io/cypress-core-https-proxy/issues" - }, - "homepage": "https://github.com/cypress-io/cypress-core-https-proxy#readme", "devDependencies": { "@cypress/releaser": "0.1.12", "chai": "^3.5.0", diff --git a/packages/launcher/package.json b/packages/launcher/package.json index 188a32322c..2a5b83b5ac 100644 --- a/packages/launcher/package.json +++ b/packages/launcher/package.json @@ -1,7 +1,6 @@ { "name": "@packages/launcher", - "version": "0.1.1", - "description": "Internal lib for spawning browser processes", + "version": "0.0.0", "private": true, "main": "index.js", "types": "../ts/index.d.ts", @@ -15,16 +14,6 @@ "lint-coffee": "../coffee/node_modules/.bin/coffeelint test/*.coffee test/**/*.coffee", "format-ts": "prettier --no-semi --single-quote --write lib/*.ts lib/**/*.ts" }, - "repository": { - "type": "git", - "url": "git+https://github.com/cypress-io/cypress-core-launcher.git" - }, - "author": "Brian Mann", - "license": "MIT", - "bugs": { - "url": "https://github.com/cypress-io/cypress-core-launcher/issues" - }, - "homepage": "https://github.com/cypress-io/cypress-core-launcher#readme", "devDependencies": { "@cypress/releaser": "0.1.12", "@types/bluebird": "^3.5.3", diff --git a/packages/reporter/package.json b/packages/reporter/package.json index 8e3fdac93b..27bb521791 100644 --- a/packages/reporter/package.json +++ b/packages/reporter/package.json @@ -1,6 +1,6 @@ { "name": "@packages/reporter", - "version": "0.3.4", + "version": "0.0.0", "private": true, "main": "lib/reporter", "browser": "src/main", @@ -32,16 +32,6 @@ ] ] }, - "repository": { - "type": "git", - "url": "git+https://github.com/cypress-io/cypress-core-reporter.git" - }, - "author": "Brian Mann", - "license": "MIT", - "bugs": { - "url": "https://github.com/cypress-io/cypress-core-reporter/issues" - }, - "homepage": "https://github.com/cypress-io/cypress-core-reporter#readme", "files": [ "dist" ], diff --git a/packages/runner/package.json b/packages/runner/package.json index 15161dba79..ca2810e199 100644 --- a/packages/runner/package.json +++ b/packages/runner/package.json @@ -1,17 +1,8 @@ { "name": "@packages/runner", - "version": "0.3.11", + "version": "0.0.0", "main": "lib/runner.js", "private": true, - "repository": { - "type": "git", - "url": "git+https://github.com/cypress-io/cypress-core-runner.git" - }, - "license": "MIT", - "bugs": { - "url": "https://github.com/cypress-io/cypress-core-runner/issues" - }, - "homepage": "https://github.com/cypress-io/cypress-core-runner#readme", "scripts": { "postinstall": "echo '@packages/runner needs: npm run build'", "build": "node ./scripts/build-dev.js", diff --git a/packages/server/package.json b/packages/server/package.json index 7e270df176..6f320934e7 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,9 +1,7 @@ { "name": "@packages/server", - "productName": "Cypress", - "version": "0.19.2", + "version": "0.0.0", "private": true, - "description": "Javascript Test Engine", "main": "index.js", "scripts": { "start": "node index.js", @@ -25,16 +23,6 @@ "coveralls": "cat ./coverage/lcov.info | coveralls", "lint": "../coffee/node_modules/.bin/coffeelint test/*.coffee test/unit/*.coffee test/integration/*.coffee" }, - "repository": { - "type": "git", - "url": "https://github.com/cypress-io/cypress.git" - }, - "author": "Brian Mann", - "license": "MIT", - "bugs": { - "url": "https://github.com/cypress-io/cypress/issues" - }, - "homepage": "https://github.com/cypress-io/cypress", "devDependencies": { "body-parser": "1.12.4", "chokidar-cli": "^1.2.0", diff --git a/packages/socket/package.json b/packages/socket/package.json index 8b85945028..a571a9edf2 100644 --- a/packages/socket/package.json +++ b/packages/socket/package.json @@ -1,24 +1,13 @@ { "name": "@packages/socket", - "version": "0.2.1", + "version": "0.0.0", "private": true, - "description": "Cypress Shared Socket Libs", "main": "index.js", "scripts": { "test": "NODE_ENV=test mocha", "test-watch": "NODE_ENV=test mocha --watch", "clean-deps": "rm -rf node_modules" }, - "repository": { - "type": "git", - "url": "git+https://github.com/cypress-io/cypress-core-socket.git" - }, - "author": "Brian Mann", - "license": "MIT", - "bugs": { - "url": "https://github.com/cypress-io/cypress-core-socket/issues" - }, - "homepage": "https://github.com/cypress-io/cypress-core-socket#readme", "dependencies": { "socket.io": "1.4.5", "socket.io-client": "1.4.5" diff --git a/packages/static/package.json b/packages/static/package.json index d0915cd92e..8b20fb8873 100644 --- a/packages/static/package.json +++ b/packages/static/package.json @@ -1,5 +1,6 @@ { "name": "@packages/static", + "version": "0.0.0", "main": "index.js", "private": true, "scripts": { diff --git a/packages/ts/package.json b/packages/ts/package.json index f382b32ee4..c604df1b3c 100644 --- a/packages/ts/package.json +++ b/packages/ts/package.json @@ -1,15 +1,11 @@ { "name": "@packages/ts", - "version": "1.0.0", + "version": "0.0.0", "private": true, - "description": "TypeScript runtime Node hook", "main": "index.js", "scripts": { "test": "node test" }, - "keywords": [], - "author": "", - "license": "ISC", "devDependencies": { "ts-node": "^3.0.4", "typescript": "^2.3.2" From cb1e555a425757ca749c9449fd7ead24a5219d36 Mon Sep 17 00:00:00 2001 From: Brian Mann Date: Thu, 22 Jun 2017 17:22:06 -0400 Subject: [PATCH 18/22] all: convert es5 -> es6 + fix linting --- packages/driver/lib/driver.js | 13 ++++++------- packages/example/bin/convert.js | 10 ++++++---- packages/example/lib/example.js | 2 +- packages/runner/lib/runner.js | 15 +++++++-------- packages/socket/lib/socket.js | 30 +++++++++++++++--------------- packages/static/lib/static.js | 13 ++++++------- 6 files changed, 41 insertions(+), 42 deletions(-) diff --git a/packages/driver/lib/driver.js b/packages/driver/lib/driver.js index 3ed3138351..7edbdf5b18 100644 --- a/packages/driver/lib/driver.js +++ b/packages/driver/lib/driver.js @@ -1,13 +1,12 @@ -var path = require('path') +const path = require('path') -function dist () { - var args = [].slice.call(arguments) - var paths = [__dirname, '..', 'dist'].concat(args) - return path.join.apply(path, paths) +function dist (...args) { + const paths = [__dirname, '..', 'dist'].concat(args) + return path.join(...paths) } module.exports = { - getPathToDist: function(){ - return dist.apply(null, arguments) + getPathToDist (...args) { + return dist(...args) }, } diff --git a/packages/example/bin/convert.js b/packages/example/bin/convert.js index 3becc31736..422ef984ae 100755 --- a/packages/example/bin/convert.js +++ b/packages/example/bin/convert.js @@ -1,14 +1,16 @@ #!/usr/bin/env node -let fs = require('fs') -let path = require('path') -let glob = require('glob') +/* eslint-disable quotes */ + +const fs = require('fs') +const path = require('path') +const glob = require('glob') function replaceStringsIn (file) { fs.readFile(file, 'utf8', function (err, str) { if (err) throw err - let replace = function (source, dest) { + const replace = function (source, dest) { str = str.split(source).join(dest) } diff --git a/packages/example/lib/example.js b/packages/example/lib/example.js index a633a711fa..bd8b06295c 100644 --- a/packages/example/lib/example.js +++ b/packages/example/lib/example.js @@ -1,4 +1,4 @@ -let path = require('path') +const path = require('path') module.exports = { getPathToExample () { diff --git a/packages/runner/lib/runner.js b/packages/runner/lib/runner.js index 6a0eb10518..5be749ab41 100644 --- a/packages/runner/lib/runner.js +++ b/packages/runner/lib/runner.js @@ -1,17 +1,16 @@ -var path = require('path') +const path = require('path') -function dist () { - var args = [].slice.call(arguments) - var paths = [__dirname, '..', 'dist'].concat(args) - return path.join.apply(path, paths) +function dist (...args) { + const paths = [__dirname, '..', 'dist'].concat(args) + return path.join(...paths) } module.exports = { - getPathToDist: function(){ - return dist.apply(null, arguments) + getPathToDist (...args) { + return dist(...args) }, - getPathToIndex: function(){ + getPathToIndex () { return dist('index.html') }, } diff --git a/packages/socket/lib/socket.js b/packages/socket/lib/socket.js index 9127d8cbc3..5ee3a4866e 100644 --- a/packages/socket/lib/socket.js +++ b/packages/socket/lib/socket.js @@ -1,26 +1,26 @@ -var fs = require("fs") -var path = require("path") -var server = require("socket.io") -var client = require("socket.io-client") -var version = require("socket.io-client/package.json").version -var clientPath = require.resolve("socket.io-client") +const fs = require('fs') +const path = require('path') +const server = require('socket.io') +const client = require('socket.io-client') +const version = require('socket.io-client/package.json').version +const clientPath = require.resolve('socket.io-client') module.exports = { - server: server, + server, - client: client, + client, - getPathToClientSource: function(){ + getPathToClientSource () { // clientPath returns the path to socket.io-client/lib/index.js // so walk up two levels to get to the root - return path.join(clientPath, "..", "..", "socket.io.js") + return path.join(clientPath, '..', '..', 'socket.io.js') }, - getClientVersion: function(){ + getClientVersion () { return version }, - getClientSource: function(){ - return fs.readFileSync(this.getPathToClientSource(), "utf8") - } -} \ No newline at end of file + getClientSource () { + return fs.readFileSync(this.getPathToClientSource(), 'utf8') + }, +} diff --git a/packages/static/lib/static.js b/packages/static/lib/static.js index 3ed3138351..7edbdf5b18 100644 --- a/packages/static/lib/static.js +++ b/packages/static/lib/static.js @@ -1,13 +1,12 @@ -var path = require('path') +const path = require('path') -function dist () { - var args = [].slice.call(arguments) - var paths = [__dirname, '..', 'dist'].concat(args) - return path.join.apply(path, paths) +function dist (...args) { + const paths = [__dirname, '..', 'dist'].concat(args) + return path.join(...paths) } module.exports = { - getPathToDist: function(){ - return dist.apply(null, arguments) + getPathToDist (...args) { + return dist(...args) }, } From aa4f81641b5974bf839cd5ba446bc742df2fa7fd Mon Sep 17 00:00:00 2001 From: Brian Mann Date: Thu, 22 Jun 2017 18:29:18 -0400 Subject: [PATCH 19/22] deploy: specify files to include when copying packages for dist --- packages/driver/package.json | 4 ++++ packages/electron/package.json | 4 ++++ packages/example/package.json | 4 ++++ packages/https-proxy/package.json | 3 +++ packages/launcher/package.json | 3 +++ packages/reporter/package.json | 6 +++++- packages/runner/package.json | 2 +- packages/server/package.json | 4 ++++ packages/socket/package.json | 3 +++ packages/static/package.json | 4 ++++ scripts/deploy/build.coffee | 10 +++++----- scripts/deploy/util/packages.coffee | 2 +- 12 files changed, 41 insertions(+), 8 deletions(-) diff --git a/packages/driver/package.json b/packages/driver/package.json index b70e3c2fcf..51feec04a3 100644 --- a/packages/driver/package.json +++ b/packages/driver/package.json @@ -9,6 +9,10 @@ "clean-deps": "rm -rf node_modules", "test": "gulp test" }, + "files": [ + "dist", + "lib" + ], "devDependencies": { "@cypress/bower-kendo-ui": "0.0.2", "angular": "^1.3.1", diff --git a/packages/electron/package.json b/packages/electron/package.json index 066b078c70..9e8bebe6c8 100644 --- a/packages/electron/package.json +++ b/packages/electron/package.json @@ -14,6 +14,10 @@ "bin": { "cypress-electron": "./bin/cypress-electron" }, + "files": [ + "dist", + "lib" + ], "devDependencies": { "@cypress/releaser": "0.1.12", "chai": "^3.5.0", diff --git a/packages/example/package.json b/packages/example/package.json index b62a2da67a..1dcae8f7b8 100644 --- a/packages/example/package.json +++ b/packages/example/package.json @@ -16,6 +16,10 @@ "lint": "$(bin-up eslint) --fix *.js bin/*.js lib/*.js test/*.js", "pretest": "npm run lint" }, + "files": [ + "cypress", + "lib" + ], "devDependencies": { "@cypress/releaser": "0.1.12", "bin-up": "^1.0.1", diff --git a/packages/https-proxy/package.json b/packages/https-proxy/package.json index bca9e3867c..a45957a91e 100644 --- a/packages/https-proxy/package.json +++ b/packages/https-proxy/package.json @@ -11,6 +11,9 @@ "https": "node https.js", "release": "releaser" }, + "files": [ + "lib" + ], "devDependencies": { "@cypress/releaser": "0.1.12", "chai": "^3.5.0", diff --git a/packages/launcher/package.json b/packages/launcher/package.json index 2a5b83b5ac..831d1ea3e4 100644 --- a/packages/launcher/package.json +++ b/packages/launcher/package.json @@ -14,6 +14,9 @@ "lint-coffee": "../coffee/node_modules/.bin/coffeelint test/*.coffee test/**/*.coffee", "format-ts": "prettier --no-semi --single-quote --write lib/*.ts lib/**/*.ts" }, + "files": [ + "lib" + ], "devDependencies": { "@cypress/releaser": "0.1.12", "@types/bluebird": "^3.5.3", diff --git a/packages/reporter/package.json b/packages/reporter/package.json index 27bb521791..6bb95bff31 100644 --- a/packages/reporter/package.json +++ b/packages/reporter/package.json @@ -2,7 +2,7 @@ "name": "@packages/reporter", "version": "0.0.0", "private": true, - "main": "lib/reporter", + "main": "lib/reporter.js", "browser": "src/main", "scripts": { "postinstall": "echo '@packages/reporter needs: npm run build'", @@ -14,6 +14,10 @@ "test": "node ./scripts/test.js", "lint": "$(bin-up eslint) --fix lib/*.js scripts/*.js src/*.js* src/**/*.js*" }, + "files": [ + "lib", + "dist" + ], "browserify": { "transform": [ [ diff --git a/packages/runner/package.json b/packages/runner/package.json index ca2810e199..89d279d276 100644 --- a/packages/runner/package.json +++ b/packages/runner/package.json @@ -15,7 +15,7 @@ }, "files": [ "dist", - "lib/runner.js" + "lib" ], "devDependencies": { "@cypress/react-tooltip": "^0.2.4", diff --git a/packages/server/package.json b/packages/server/package.json index 6f320934e7..e837e687f4 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -23,6 +23,10 @@ "coveralls": "cat ./coverage/lcov.info | coveralls", "lint": "../coffee/node_modules/.bin/coffeelint test/*.coffee test/unit/*.coffee test/integration/*.coffee" }, + "files": [ + "config", + "lib" + ], "devDependencies": { "body-parser": "1.12.4", "chokidar-cli": "^1.2.0", diff --git a/packages/socket/package.json b/packages/socket/package.json index a571a9edf2..efef150e5c 100644 --- a/packages/socket/package.json +++ b/packages/socket/package.json @@ -8,6 +8,9 @@ "test-watch": "NODE_ENV=test mocha --watch", "clean-deps": "rm -rf node_modules" }, + "files": [ + "lib" + ], "dependencies": { "socket.io": "1.4.5", "socket.io-client": "1.4.5" diff --git a/packages/static/package.json b/packages/static/package.json index 8b20fb8873..41c331a4ee 100644 --- a/packages/static/package.json +++ b/packages/static/package.json @@ -8,6 +8,10 @@ "build": "gulp build", "test": "echo 'Nothing to test yet'" }, + "files": [ + "dist", + "lib" + ], "devDependencies": { "@cypress/icons": "0.5.4", "gulp": "^3.9.1" diff --git a/scripts/deploy/build.coffee b/scripts/deploy/build.coffee index f18ff87984..984d68ac6d 100644 --- a/scripts/deploy/build.coffee +++ b/scripts/deploy/build.coffee @@ -60,12 +60,12 @@ module.exports = (platform, version) -> Promise .bind(@) - .then(cleanupPlatform) - .then(buildPackages) + # .then(cleanupPlatform) + # .then(buildPackages) .then(copyPackages) - .then(npmInstallPackages) - .then(createRootPackage) - .then(symlinkPackages) + # .then(npmInstallPackages) + # .then(createRootPackage) + # .then(symlinkPackages) # .then(@convertCoffeeToJs) # .then(@obfuscate) # .then(@cleanupSrc) diff --git a/scripts/deploy/util/packages.coffee b/scripts/deploy/util/packages.coffee index 9fbfd0d01d..5dcd86be8c 100644 --- a/scripts/deploy/util/packages.coffee +++ b/scripts/deploy/util/packages.coffee @@ -47,6 +47,7 @@ copyAllToDist = (distDir) -> ## and convert to relative paths DEFAULT_PATHS .concat(json.files or []) + .concat(json.main or []) .map (file) -> path.join(pkg, file) .map(copyRelativePathToDist, {concurrency: 1}) @@ -70,7 +71,6 @@ copyAllToDist = (distDir) -> .map(copyPackage, {concurrency: 1}) .then -> console.log("Finished Copying", new Date() - started) - .delay(10000) npmInstallAll = (pathToPackages) -> ## 1,060,495,784 bytes (1.54 GB on disk) for 179,156 items From 69fd1395d09f3e04c179a80d7911fb60c1969d89 Mon Sep 17 00:00:00 2001 From: Brian Mann Date: Thu, 22 Jun 2017 19:13:42 -0400 Subject: [PATCH 20/22] deploy: convert coffee script in place + remove coffee files --- package.json | 2 ++ scripts/deploy/build.coffee | 40 +++++++++++++++++++++++++++++++------ 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 2e2814b56b..3353e00001 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "babel-eslint": "^6.0.4", "bluebird": "^3.4.5", "chai": "^4.0.2", + "del": "^3.0.0", "electron-osx-sign": "^0.4.6", "eslint": "^3.18.0", "eslint-plugin-mocha": "^4.9.0", @@ -59,6 +60,7 @@ "plist": "^2.1.0", "run-sequence": "^1.2.2", "vagrant": "0.0.1", + "vinyl-paths": "^2.1.0", "xvfb": "^0.2.3" }, "author": "Brian Mann", diff --git a/scripts/deploy/build.coffee b/scripts/deploy/build.coffee index 984d68ac6d..fdbbc22de8 100644 --- a/scripts/deploy/build.coffee +++ b/scripts/deploy/build.coffee @@ -1,7 +1,13 @@ fs = require("fs-extra") +del = require("del") path = require("path") +gulp = require("gulp") chalk = require("chalk") Promise = require("bluebird") +gulpDebug = require("gulp-debug") +gulpCoffee = require("gulp-coffee") +vinylPaths = require("vinyl-paths") +coffee = require("@packages/coffee") packages = require("./util/packages") fs = Promise.promisifyAll(fs) @@ -58,15 +64,37 @@ module.exports = (platform, version) -> packages.symlinkAll(distDir) + convertCoffeeToJs = -> + log("#convertCoffeeToJs", platform) + + ## grab everything in src + ## convert to js + new Promise (resolve, reject) => + gulp.src([ + ## include coffee files of packages + distDir("**", "*.coffee") + + ## except those in node_modules + "!" + distDir("**", "node_modules", "**", "*.coffee") + ]) + .pipe vinylPaths(del) + .pipe(gulpDebug()) + .pipe gulpCoffee({ + coffee: coffee + }) + .pipe gulp.dest(distDir()) + .on("end", resolve) + .on("error", reject) + Promise .bind(@) - # .then(cleanupPlatform) - # .then(buildPackages) + .then(cleanupPlatform) + .then(buildPackages) .then(copyPackages) - # .then(npmInstallPackages) - # .then(createRootPackage) - # .then(symlinkPackages) - # .then(@convertCoffeeToJs) + .then(npmInstallPackages) + .then(createRootPackage) + .then(symlinkPackages) + .then(convertCoffeeToJs) # .then(@obfuscate) # .then(@cleanupSrc) # .then(@npmInstall) From fc57090b8d728f51e7182d0a9a4e8df3c5687ac2 Mon Sep 17 00:00:00 2001 From: Brian Mann Date: Fri, 23 Jun 2017 14:26:21 -0400 Subject: [PATCH 21/22] deploy: ignore build --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4d63535605..f374427c1d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ node_modules *.orig dist dist-* +build .vscode .publish From e70cb2aed0cbd64c0c1648c1358164e6df59b785 Mon Sep 17 00:00:00 2001 From: Brian Mann Date: Fri, 23 Jun 2017 14:27:05 -0400 Subject: [PATCH 22/22] deploy: build electron app + symlink node_modules for build app dir --- scripts/deploy/build.coffee | 40 ++++++++++++++++++++++++++--- scripts/deploy/util/packages.coffee | 7 +++-- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/scripts/deploy/build.coffee b/scripts/deploy/build.coffee index fdbbc22de8..5f491744bd 100644 --- a/scripts/deploy/build.coffee +++ b/scripts/deploy/build.coffee @@ -8,6 +8,7 @@ gulpDebug = require("gulp-debug") gulpCoffee = require("gulp-coffee") vinylPaths = require("vinyl-paths") coffee = require("@packages/coffee") +electron = require("@packages/electron") packages = require("./util/packages") fs = Promise.promisifyAll(fs) @@ -16,9 +17,23 @@ log = (msg, platform) -> console.log(chalk.yellow(msg), chalk.bgWhite(chalk.black(platform))) module.exports = (platform, version) -> + ## returns a path into the /dist directory distDir = (args...) -> path.resolve("dist", platform, args...) + ## returns a path into the /build directory + buildDir = (args...) -> + path.resolve("build", platform, args...) + + ## returns a path into the /build/*/app directory + ## specific to each platform + buildAppDir = (args...) -> + switch platform + when "darwin" + buildDir("Cypress.app", "Contents", "resources", "app", args...) + when "linux" + buildDir("Cypress", "resources", "app", args...) + cleanupPlatform = -> log("#cleanupPlatform", platform) @@ -59,8 +74,13 @@ module.exports = (platform, version) -> fs.outputFileAsync(distDir("index.js"), str) - symlinkPackages = -> - log("#symlinkPackages", platform) + symlinkBuildPackages = -> + log("#symlinkBuildPackages", platform) + + packages.symlinkAll(buildAppDir) + + symlinkDistPackages = -> + log("#symlinkDistPackages", platform) packages.symlinkAll(distDir) @@ -86,6 +106,17 @@ module.exports = (platform, version) -> .on("end", resolve) .on("error", reject) + + elBuilder = -> + log("#elBuilder", platform) + + electron.install({ + dir: distDir() + dist: buildDir() + platform: platform + "app-version": version + }) + Promise .bind(@) .then(cleanupPlatform) @@ -93,13 +124,14 @@ module.exports = (platform, version) -> .then(copyPackages) .then(npmInstallPackages) .then(createRootPackage) - .then(symlinkPackages) + .then(symlinkDistPackages) .then(convertCoffeeToJs) # .then(@obfuscate) # .then(@cleanupSrc) # .then(@npmInstall) # .then(@npmInstall) - # .then(@elBuilder) + .then(elBuilder) + .then(symlinkBuildPackages) # .then(@runSmokeTest) # .then(@runProjectTest) # .then(@runFailingProjectTest) diff --git a/scripts/deploy/util/packages.coffee b/scripts/deploy/util/packages.coffee index 5dcd86be8c..4859e46f15 100644 --- a/scripts/deploy/util/packages.coffee +++ b/scripts/deploy/util/packages.coffee @@ -123,15 +123,14 @@ npmInstallAll = (pathToPackages) -> .then -> console.log("Finished NPM Installing", new Date() - started) -symlinkAll = (distDir) -> - pathToPackages = path.join('node_modules', '@') - pathToDistPackages = distDir("packages", "*") +symlinkAll = (pathTo) -> + pathToDistPackages = pathTo("packages", "*") symlink = (pkg) -> # console.log(pkg, dist) ## strip off the initial './' ## ./packages/foo -> node_modules/@packages/foo - dest = path.join(distDir(), "node_modules", "@packages", path.basename(pkg)) + dest = path.join(pathTo(), "node_modules", "@packages", path.basename(pkg)) fs.ensureSymlinkAsync(pkg, dest)