mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-25 00:19:11 -05:00
merged renames
This commit is contained in:
@@ -7,7 +7,7 @@ if (!command) {
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const commands = require('./deploy/index')
|
||||
const commands = require('./binary/index')
|
||||
const fn = commands[command]
|
||||
if (!fn) {
|
||||
console.error('Invalid deploy command %s 🚫', command)
|
||||
@@ -0,0 +1,162 @@
|
||||
_ = require("lodash")
|
||||
fs = require("fs-extra")
|
||||
glob = require("glob")
|
||||
Promise = require("bluebird")
|
||||
inquirer = require("inquirer")
|
||||
|
||||
glob = Promise.promisify(glob)
|
||||
|
||||
prompt = (questions) ->
|
||||
Promise.resolve(inquirer.prompt(questions))
|
||||
|
||||
fs = Promise.promisifyAll(fs)
|
||||
|
||||
getZipFile = ->
|
||||
[{
|
||||
name: "zipFile"
|
||||
type: "string"
|
||||
message: "Which zip file should we upload?"
|
||||
}]
|
||||
|
||||
getPlatformQuestion = ->
|
||||
[{
|
||||
name: "platform"
|
||||
type: "list"
|
||||
message: "Which OS should we deploy?"
|
||||
choices: [{
|
||||
name: "Mac"
|
||||
value: "darwin"
|
||||
},{
|
||||
name: "Linux"
|
||||
value: "linux"
|
||||
}]
|
||||
}]
|
||||
|
||||
getQuestions = (version) ->
|
||||
[{
|
||||
name: "publish"
|
||||
type: "list"
|
||||
message: "Publish a new version? (currently: #{version})"
|
||||
choices: [{
|
||||
name: "Yes: set a new version and deploy new version."
|
||||
value: true
|
||||
},{
|
||||
name: "No: just override the current deploy’ed version."
|
||||
value: false
|
||||
}]
|
||||
},{
|
||||
name: "version"
|
||||
type: "input"
|
||||
message: "Bump version to...? (currently: #{version})"
|
||||
default: ->
|
||||
a = version.split(".")
|
||||
v = a[a.length - 1]
|
||||
v = Number(v) + 1
|
||||
a.splice(a.length - 1, 1, v)
|
||||
a.join(".")
|
||||
when: (answers) ->
|
||||
answers.publish
|
||||
}]
|
||||
|
||||
getReleases = (releases) ->
|
||||
[{
|
||||
name: "release"
|
||||
type: "list"
|
||||
message: "Release which version?"
|
||||
choices: _.map releases, (r) ->
|
||||
{
|
||||
name: r
|
||||
value: r
|
||||
}
|
||||
}]
|
||||
|
||||
getVersions = (releases) ->
|
||||
[{
|
||||
name: "version"
|
||||
type: "list"
|
||||
message: "Bump to which version?"
|
||||
choices: _.map releases, (r) ->
|
||||
{
|
||||
name: r
|
||||
value: r
|
||||
}
|
||||
}]
|
||||
|
||||
getBumpTasks = ->
|
||||
[{
|
||||
name: "task"
|
||||
type: "list"
|
||||
message: "Which bump task?"
|
||||
choices: [{
|
||||
name: "Bump Cypress Version for all CI providers"
|
||||
value: "version"
|
||||
},{
|
||||
name: "Run All Projects for all CI providers"
|
||||
value: "run"
|
||||
}]
|
||||
}]
|
||||
|
||||
deployNewVersion = ->
|
||||
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
|
||||
|
||||
whichZipFile = ->
|
||||
prompt(getZipFile())
|
||||
.get("zipFile")
|
||||
|
||||
whichVersion = (distDir) ->
|
||||
## 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)
|
||||
|
||||
prompt(getVersions(versions))
|
||||
.get("version")
|
||||
|
||||
whichRelease = (distDir) ->
|
||||
## 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)
|
||||
|
||||
prompt(getReleases(versions))
|
||||
.get("release")
|
||||
|
||||
whichPlatform = ->
|
||||
prompt(getPlatformQuestion())
|
||||
.get("platform")
|
||||
|
||||
whichBumpTask = ->
|
||||
prompt(getBumpTasks())
|
||||
.get("task")
|
||||
|
||||
module.exports = {
|
||||
getZipFile
|
||||
getPlatformQuestion
|
||||
getQuestions
|
||||
getReleases
|
||||
getVersions
|
||||
getBumpTasks
|
||||
deployNewVersion
|
||||
whichZipFile
|
||||
whichVersion
|
||||
whichRelease
|
||||
whichPlatform
|
||||
whichBumpTask
|
||||
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
_ = require("lodash")
|
||||
fs = require("fs-extra")
|
||||
del = require("del")
|
||||
path = require("path")
|
||||
@@ -19,7 +20,7 @@ Linux = require("./linux")
|
||||
|
||||
fs = Promise.promisifyAll(fs)
|
||||
|
||||
log = (msg, platform) ->
|
||||
logger = (msg) ->
|
||||
console.log(chalk.yellow(msg), chalk.bgWhite(chalk.black(platform)))
|
||||
|
||||
runDarwinSmokeTest = ->
|
||||
@@ -36,12 +37,14 @@ smokeTests = {
|
||||
}
|
||||
|
||||
module.exports = (platform, version) ->
|
||||
distDir = meta.distDir.bind(null, platform)
|
||||
buildDir = meta.buildDir.bind(null, platform)
|
||||
buildAppDir = meta.buildAppDir.bind(null, platform)
|
||||
distDir = _.partial(meta.distDir, platform)
|
||||
buildDir = _.partial(meta.buildDir, platform)
|
||||
buildAppDir = _.partial(meta.buildAppDir, platform)
|
||||
|
||||
log = _.partialRight(logger, platform)
|
||||
|
||||
cleanupPlatform = ->
|
||||
log("#cleanupPlatform", platform)
|
||||
log("#cleanupPlatform")
|
||||
|
||||
cleanup = =>
|
||||
fs.removeAsync(distDir())
|
||||
@@ -50,18 +53,18 @@ module.exports = (platform, version) ->
|
||||
.catch(cleanup)
|
||||
|
||||
buildPackages = ->
|
||||
log("#buildPackages", platform)
|
||||
log("#buildPackages")
|
||||
|
||||
packages.runAllBuild()
|
||||
.then(packages.runAllBuildJs)
|
||||
|
||||
copyPackages = ->
|
||||
log("#copyPackages", platform)
|
||||
log("#copyPackages")
|
||||
|
||||
packages.copyAllToDist(distDir())
|
||||
|
||||
npmInstallPackages = ->
|
||||
log("#npmInstallPackages", platform)
|
||||
log("#npmInstallPackages")
|
||||
|
||||
packages.npmInstallAll(distDir("packages", "*"))
|
||||
|
||||
@@ -85,13 +88,13 @@ module.exports = (platform, version) ->
|
||||
fs.outputFileAsync(distDir("index.js"), str)
|
||||
|
||||
symlinkPackages = ->
|
||||
log("#symlinkPackages", platform)
|
||||
log("#symlinkPackages")
|
||||
|
||||
packages.symlinkAll(distDir("packages", "*", "package.json"), distDir)
|
||||
|
||||
removeTypeScript = ->
|
||||
## remove the .ts files in our packages
|
||||
log("#removeTypeScript", platform)
|
||||
log("#removeTypeScript")
|
||||
del([
|
||||
## include coffee files of packages
|
||||
distDir("**", "*.ts")
|
||||
@@ -108,7 +111,7 @@ module.exports = (platform, version) ->
|
||||
console.log(paths)
|
||||
|
||||
symlinkBuildPackages = ->
|
||||
log("#symlinkBuildPackages", platform)
|
||||
log("#symlinkBuildPackages")
|
||||
wildCard = buildAppDir("packages", "*", "package.json")
|
||||
console.log("packages", wildCard)
|
||||
packages.symlinkAll(
|
||||
@@ -117,7 +120,7 @@ module.exports = (platform, version) ->
|
||||
)
|
||||
|
||||
symlinkDistPackages = ->
|
||||
log("#symlinkDistPackages", platform)
|
||||
log("#symlinkDistPackages")
|
||||
|
||||
packages.symlinkAll(
|
||||
distDir("packages", "*", "package.json"),
|
||||
@@ -125,12 +128,12 @@ module.exports = (platform, version) ->
|
||||
)
|
||||
|
||||
cleanJs = ->
|
||||
log("#cleanJs", platform)
|
||||
log("#cleanJs")
|
||||
|
||||
packages.runAllCleanJs()
|
||||
|
||||
convertCoffeeToJs = ->
|
||||
log("#convertCoffeeToJs", platform)
|
||||
log("#convertCoffeeToJs")
|
||||
|
||||
## grab everything in src
|
||||
## convert to js
|
||||
@@ -152,7 +155,7 @@ module.exports = (platform, version) ->
|
||||
.on("error", reject)
|
||||
|
||||
elBuilder = ->
|
||||
log("#elBuilder", platform)
|
||||
log("#elBuilder")
|
||||
dir = distDir()
|
||||
dist = buildDir()
|
||||
console.log("from #{dir}")
|
||||
@@ -166,7 +169,7 @@ module.exports = (platform, version) ->
|
||||
})
|
||||
|
||||
runSmokeTest = ->
|
||||
log("#runSmokeTest", platform)
|
||||
log("#runSmokeTest")
|
||||
# console.log("skipping smoke test for now")
|
||||
smokeTest = smokeTests[platform]
|
||||
smokeTest()
|
||||
@@ -29,32 +29,32 @@ fail = (str) ->
|
||||
zippedFilename = (platform) ->
|
||||
# TODO use .tar.gz for linux archive. For now to preserve
|
||||
# same file format as before use .zip
|
||||
if platform == "linux" then "cypress.zip" else "cypress.zip"
|
||||
if platform is "linux" then "cypress.zip" else "cypress.zip"
|
||||
|
||||
# goes through the list of properties and asks relevant question
|
||||
# resolves with all relevant options set
|
||||
# if the property already exists, skips the question
|
||||
askMissingOptions = (properties) -> (options = {}) ->
|
||||
questions = {
|
||||
platform: ask.whichPlatform,
|
||||
version: ask.deployNewVersion,
|
||||
# note: zip file might not be absolute
|
||||
zip: ask.whichZipFile
|
||||
}
|
||||
askMissingOptions = (properties = []) ->
|
||||
return (options = {}) ->
|
||||
questions = {
|
||||
platform: ask.whichPlatform,
|
||||
version: ask.deployNewVersion,
|
||||
# note: zip file might not be absolute
|
||||
zip: ask.whichZipFile
|
||||
}
|
||||
|
||||
properties.reduce((prev, property) ->
|
||||
if (check.has(options, property)) then return prev
|
||||
question = questions[property]
|
||||
if (!check.fn(question)) then return prev
|
||||
la(check.fn(question), "cannot find question for property", property)
|
||||
prev.then(() ->
|
||||
question(options[property])
|
||||
.then((answer) ->
|
||||
options[property] = answer
|
||||
options
|
||||
)
|
||||
)
|
||||
, Promise.resolve(options))
|
||||
reducer = (memo, property) ->
|
||||
if (check.has(memo, property)) then return memo
|
||||
question = questions[property]
|
||||
if (!check.fn(question)) then return memo
|
||||
la(check.fn(question), "cannot find question for property", property)
|
||||
|
||||
question(memo[property])
|
||||
.then (answer) ->
|
||||
memo[property] = answer
|
||||
memo
|
||||
|
||||
Promise.reduce(properties, reducer, options)
|
||||
|
||||
## hack for @packages/server modifying cwd
|
||||
process.chdir(cwd)
|
||||
@@ -154,7 +154,7 @@ deploy = {
|
||||
options = @parseOptions(process.argv)
|
||||
askMissingOptions(['version', 'platform'])(options)
|
||||
.then(build)
|
||||
.then(() -> zip(options))
|
||||
.then(() => @zip(options))
|
||||
# assumes options.zip contains the zipped filename
|
||||
.then(upload)
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
_ = require("lodash")
|
||||
fs = require("fs-extra")
|
||||
glob = require("glob")
|
||||
Promise = require("bluebird")
|
||||
inquirer = require("inquirer")
|
||||
|
||||
glob = Promise.promisify(glob)
|
||||
|
||||
prompt = (questions) ->
|
||||
Promise.resolve(inquirer.prompt(questions))
|
||||
|
||||
fs = Promise.promisifyAll(fs)
|
||||
|
||||
getZipFile = ->
|
||||
[{
|
||||
name: "zipFile"
|
||||
type: "string"
|
||||
message: "Which zip file should we upload?"
|
||||
}]
|
||||
|
||||
getPlatformQuestion = ->
|
||||
[{
|
||||
name: "platform"
|
||||
type: "list"
|
||||
message: "Which OS should we deploy?"
|
||||
choices: [{
|
||||
name: "Mac"
|
||||
value: "darwin"
|
||||
},{
|
||||
name: "Linux"
|
||||
value: "linux"
|
||||
}]
|
||||
}]
|
||||
|
||||
module.exports = {
|
||||
getZipFile
|
||||
getPlatformQuestion
|
||||
getQuestions: (version) ->
|
||||
[{
|
||||
name: "publish"
|
||||
type: "list"
|
||||
message: "Publish a new version? (currently: #{version})"
|
||||
choices: [{
|
||||
name: "Yes: set a new version and deploy new version."
|
||||
value: true
|
||||
},{
|
||||
name: "No: just override the current deploy’ed version."
|
||||
value: false
|
||||
}]
|
||||
},{
|
||||
name: "version"
|
||||
type: "input"
|
||||
message: "Bump version to...? (currently: #{version})"
|
||||
default: ->
|
||||
a = version.split(".")
|
||||
v = a[a.length - 1]
|
||||
v = Number(v) + 1
|
||||
a.splice(a.length - 1, 1, v)
|
||||
a.join(".")
|
||||
when: (answers) ->
|
||||
answers.publish
|
||||
}]
|
||||
|
||||
getReleases: (releases) ->
|
||||
[{
|
||||
name: "release"
|
||||
type: "list"
|
||||
message: "Release which version?"
|
||||
choices: _.map releases, (r) ->
|
||||
{
|
||||
name: r
|
||||
value: r
|
||||
}
|
||||
}]
|
||||
|
||||
getVersions: (releases) ->
|
||||
[{
|
||||
name: "version"
|
||||
type: "list"
|
||||
message: "Bump to which version?"
|
||||
choices: _.map releases, (r) ->
|
||||
{
|
||||
name: r
|
||||
value: r
|
||||
}
|
||||
}]
|
||||
|
||||
getBumpTasks: ->
|
||||
[{
|
||||
name: "task"
|
||||
type: "list"
|
||||
message: "Which bump task?"
|
||||
choices: [{
|
||||
name: "Bump Cypress Version for all CI providers"
|
||||
value: "version"
|
||||
},{
|
||||
name: "Run All Projects for all CI providers"
|
||||
value: "run"
|
||||
}]
|
||||
}]
|
||||
|
||||
deployNewVersion: ->
|
||||
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
|
||||
|
||||
whichZipFile: () ->
|
||||
prompt(@getZipFile())
|
||||
.get("zipFile")
|
||||
|
||||
whichVersion: (distDir) ->
|
||||
## 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)
|
||||
|
||||
prompt(@getVersions(versions))
|
||||
.get("version")
|
||||
|
||||
whichRelease: (distDir) ->
|
||||
## 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)
|
||||
|
||||
prompt(@getReleases(versions))
|
||||
.get("release")
|
||||
|
||||
whichPlatform: ->
|
||||
prompt(getPlatformQuestion())
|
||||
.get("platform")
|
||||
|
||||
whichBumpTask: ->
|
||||
prompt(@getBumpTasks())
|
||||
.get("task")
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user