mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-04 22:30:00 -06:00
refactored questions to allow asking only some information
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
"precommit-lint": "eslint --fix --rule 'no-only-tests/no-only-tests: 2'",
|
||||
"bump": "gulp bump",
|
||||
"no-predeploy": "echo 'Just to be safe, rebuilding Sass binary' && npm rebuild node-sass",
|
||||
"deploy": "node ./scripts/deploy.js",
|
||||
"deploy": "node ./scripts/deploy.js deploy",
|
||||
"release": "gulp release"
|
||||
},
|
||||
"lint-staged": {
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/* eslint-disable no-console */
|
||||
require('@packages/coffee/register')
|
||||
|
||||
require('./deploy/index').deploy()
|
||||
const command = process.argv[2]
|
||||
if (!command) {
|
||||
console.error('Missing deploy command ⛔️')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const commands = require('./deploy/index')
|
||||
const fn = commands[command]
|
||||
if (!fn) {
|
||||
console.error('Invalid deploy command %s 🚫', command)
|
||||
}
|
||||
|
||||
fn()
|
||||
.then(() => console.log('✅ %s completed', command))
|
||||
.catch((err) => {
|
||||
console.error('🔥 deploy error')
|
||||
console.error(err)
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
@@ -20,34 +20,6 @@ Base = require("./base")
|
||||
Linux = require("./linux")
|
||||
Darwin = require("./darwin")
|
||||
|
||||
success = (str) ->
|
||||
console.log chalk.bgGreen(" " + chalk.black(str) + " ")
|
||||
|
||||
fail = (str) ->
|
||||
console.log chalk.bgRed(" " + chalk.black(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"
|
||||
|
||||
# resolves with all relevant options set
|
||||
askMissingOptions = (options = {}) ->
|
||||
askWhichPlatform(options.platform)
|
||||
.then((platform) ->
|
||||
options.platform = platform
|
||||
options
|
||||
)
|
||||
.then ->
|
||||
askWhichVersion(options.version)
|
||||
.then((version) ->
|
||||
options.version = version
|
||||
options
|
||||
)
|
||||
|
||||
## hack for @packages/server modifying cwd
|
||||
process.chdir(cwd)
|
||||
|
||||
askWhichPlatform = (platform) ->
|
||||
## if we already have a platform
|
||||
## just resolve with that
|
||||
@@ -66,11 +38,43 @@ askWhichVersion = (version) ->
|
||||
## else go ask for it!
|
||||
ask.deployNewVersion()
|
||||
|
||||
questions = {
|
||||
platform: askWhichPlatform,
|
||||
version: askWhichVersion
|
||||
}
|
||||
|
||||
success = (str) ->
|
||||
console.log chalk.bgGreen(" " + chalk.black(str) + " ")
|
||||
|
||||
fail = (str) ->
|
||||
console.log chalk.bgRed(" " + chalk.black(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"
|
||||
|
||||
# goes through the list of properties and asks relevant question
|
||||
# resolves with all relevant options set
|
||||
askMissingOptions = (properties) -> (options = {}) ->
|
||||
properties.reduce((prev, property) ->
|
||||
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())
|
||||
|
||||
## hack for @packages/server modifying cwd
|
||||
process.chdir(cwd)
|
||||
|
||||
deploy = {
|
||||
zip: zip
|
||||
ask: ask
|
||||
meta: meta
|
||||
upload: upload
|
||||
Base: Base
|
||||
Darwin: Darwin
|
||||
Linux: Linux
|
||||
@@ -91,12 +95,6 @@ deploy = {
|
||||
opts.runTests = false if opts["skip-tests"]
|
||||
opts
|
||||
|
||||
# build: (platform) ->
|
||||
# ## read off the argv
|
||||
# options = @parseOptions(process.argv)
|
||||
#
|
||||
# @getPlatform(platform?.osName, options).build()
|
||||
|
||||
bump: ->
|
||||
ask.whichBumpTask()
|
||||
.then (task) ->
|
||||
@@ -126,20 +124,23 @@ deploy = {
|
||||
ask.whichRelease(meta.distDir)
|
||||
.then(release)
|
||||
|
||||
deploy: ->
|
||||
## read off the argv
|
||||
# to skip further questions like platform and version
|
||||
# pass these as options like this
|
||||
# npm run deploy -- --platform darwin --version 0.20.0
|
||||
build: ->
|
||||
options = @parseOptions(process.argv)
|
||||
askMissingOptions(options)
|
||||
# .then (version) ->
|
||||
# build(platform, version)
|
||||
# .then (built) =>
|
||||
# console.log(built)
|
||||
# src = built.buildDir
|
||||
.then (version) ->
|
||||
build(platform, version)
|
||||
|
||||
zip: ->
|
||||
# TODO only ask for built folder name
|
||||
options = @parseOptions(process.argv)
|
||||
askMissingOptions(options)
|
||||
# .then ({platform, buildDir}) =>
|
||||
# dest = path.resolve(zippedFilename(platform))
|
||||
# zip.ditto(src, dest)
|
||||
# zip.ditto(buildDir, dest)
|
||||
|
||||
upload: ->
|
||||
options = @parseOptions(process.argv)
|
||||
askMissingOptions(options)
|
||||
.then () ->
|
||||
path.resolve("cypress.zip")
|
||||
.then (zippedFilename) =>
|
||||
@@ -152,12 +153,39 @@ deploy = {
|
||||
version: options.version,
|
||||
osName: options.platform
|
||||
})
|
||||
.then ->
|
||||
success("✅ deploy completed")
|
||||
.catch (err) ->
|
||||
fail("🔥 deploy error")
|
||||
console.log(err)
|
||||
|
||||
# goes through the entire pipeline:
|
||||
# - build
|
||||
# - zip
|
||||
# - upload
|
||||
deploy: ->
|
||||
## read off the argv
|
||||
# to skip further questions like platform and version
|
||||
# pass these as options like this
|
||||
# npm run deploy -- --platform darwin --version 0.20.0
|
||||
options = @parseOptions(process.argv)
|
||||
askMissingOptions(['version', 'platform'])(options)
|
||||
.then(console.log)
|
||||
# .then (version) ->
|
||||
# build(platform, version)
|
||||
# .then (built) =>
|
||||
# console.log(built)
|
||||
# src = built.buildDir
|
||||
# dest = path.resolve(zippedFilename(platform))
|
||||
# zip.ditto(src, dest)
|
||||
# .then () ->
|
||||
# path.resolve("cypress.zip")
|
||||
# .then () =>
|
||||
# la(check.unemptyString(options.zipFile),
|
||||
# "missing zipped filename", options)
|
||||
# console.log("Need to upload file %s", options.zipFile)
|
||||
# console.log("for platform %s version %s",
|
||||
# options.platform, options.version)
|
||||
# upload.toS3({
|
||||
# zipFile: options.zipFile,
|
||||
# version: options.version,
|
||||
# platform: options.platform
|
||||
# })
|
||||
}
|
||||
|
||||
module.exports = _.bindAll(deploy, _.functions(deploy))
|
||||
|
||||
@@ -34,17 +34,17 @@ module.exports = {
|
||||
getAwsObj: ->
|
||||
fs.readJsonSync("./support/aws-credentials.json")
|
||||
|
||||
getUploadDirName: ({version, osName}) ->
|
||||
getUploadDirName: ({version, platform}) ->
|
||||
aws = @getAwsObj()
|
||||
dirName = [aws.folder, version, osName, null].join("/")
|
||||
dirName = [aws.folder, version, platform, null].join("/")
|
||||
console.log("target directory %s", dirName)
|
||||
dirName
|
||||
|
||||
purgeCache: ({zipFile, version, osName}) ->
|
||||
purgeCache: ({zipFile, version, platform}) ->
|
||||
new Promise (resolve, reject) =>
|
||||
zipName = path.basename(zipFile)
|
||||
|
||||
url = [konfig('cdn_url'), "desktop", version, osName, zipName].join("/")
|
||||
url = [konfig('cdn_url'), "desktop", version, platform, zipName].join("/")
|
||||
console.log("purging url", url)
|
||||
resolve()
|
||||
# cp.exec "cfcli purgefile #{url}", (err, stdout, stderr) ->
|
||||
@@ -94,11 +94,11 @@ module.exports = {
|
||||
.on "error", reject
|
||||
.on "end", resolve
|
||||
|
||||
toS3: ({zipFile, version, osName}) ->
|
||||
toS3: ({zipFile, version, platform}) ->
|
||||
console.log("#uploadToS3 ⏳")
|
||||
la(check.unemptyString(version), "expected version string", version)
|
||||
la(check.unemptyString(zipFile), "expected zip filename", zipFile)
|
||||
la(isValidPlatform(osName), "invalid osName", osName)
|
||||
la(isValidPlatform(platform), "invalid platform", platform)
|
||||
|
||||
upload = =>
|
||||
new Promise (resolve, reject) =>
|
||||
@@ -109,7 +109,7 @@ module.exports = {
|
||||
|
||||
gulp.src(zipFile)
|
||||
.pipe rename (p) =>
|
||||
p.dirname = @getUploadDirName({version, osName})
|
||||
p.dirname = @getUploadDirName({version, platform})
|
||||
p
|
||||
.pipe debug()
|
||||
# .pipe publisher.publish(headers)
|
||||
|
||||
Reference in New Issue
Block a user