mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-04 14:19:55 -06:00
working on binary zip and unzip (#222)
* working on binary zip and unzip * ignore support folder
This commit is contained in:
@@ -39,8 +39,13 @@ module.exports = (platform, version) ->
|
||||
path.resolve("dist", platform, args...)
|
||||
|
||||
## returns a path into the /build directory
|
||||
## the output folder should have top level "Cypress" folder
|
||||
## build/
|
||||
## <platform>/ = linux or darwin
|
||||
## Cypress/
|
||||
## ... platform-specific files
|
||||
buildDir = (args...) ->
|
||||
path.resolve("build", platform, args...)
|
||||
path.resolve("build", platform, "Cypress", args...)
|
||||
|
||||
## returns a path into the /build/*/app directory
|
||||
## specific to each platform
|
||||
@@ -177,8 +182,9 @@ module.exports = (platform, version) ->
|
||||
smokeTest = smokeTests[platform]
|
||||
smokeTest()
|
||||
|
||||
Promise
|
||||
.bind(@)
|
||||
# Promise
|
||||
# .bind(@)
|
||||
Promise.resolve()
|
||||
.then(cleanupPlatform)
|
||||
.then(buildPackages)
|
||||
.then(copyPackages)
|
||||
@@ -197,9 +203,14 @@ module.exports = (platform, version) ->
|
||||
.then(elBuilder)
|
||||
.then(symlinkBuildPackages)
|
||||
.then(runSmokeTest)
|
||||
|
||||
# older build steps
|
||||
# .then(@runProjectTest)
|
||||
# .then(@runFailingProjectTest)
|
||||
# .then(@cleanupCy)
|
||||
# .then(@codeSign) ## codesign after running smoke tests due to changing .cy
|
||||
# .then(@verifyAppCanOpen)
|
||||
.return(@)
|
||||
# .return(@)
|
||||
.return({
|
||||
buildDir: buildDir()
|
||||
})
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
## store the cwd
|
||||
cwd = process.cwd()
|
||||
|
||||
path = require("path")
|
||||
_ = require("lodash")
|
||||
os = require("os")
|
||||
chalk = require("chalk")
|
||||
@@ -22,6 +23,11 @@ success = (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"
|
||||
|
||||
## hack for @packages/server modifying cwd
|
||||
process.chdir(cwd)
|
||||
|
||||
@@ -115,16 +121,20 @@ deploy = {
|
||||
askWhichVersion(options.version)
|
||||
.then (version) ->
|
||||
# options.version = version
|
||||
|
||||
build(platform, version)
|
||||
# .return([platform, version])
|
||||
# .spread (platform, version) ->
|
||||
|
||||
# @getPlatform(plat, options).deploy()
|
||||
# .then (platform) =>
|
||||
# zip.ditto(platform)
|
||||
# .then =>
|
||||
# upload.toS3(platform)
|
||||
.then (built) =>
|
||||
console.log(built)
|
||||
src = built.buildDir
|
||||
dest = path.resolve(zippedFilename(platform))
|
||||
zip.ditto(src, dest)
|
||||
.then (zippedFilename) =>
|
||||
console.log("Need to upload file %s", zippedFilename)
|
||||
# upload.toS3(platform)
|
||||
# .then ->
|
||||
# success("Dist Complete")
|
||||
# .catch (err) ->
|
||||
|
||||
@@ -10,9 +10,6 @@ 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 = {
|
||||
|
||||
@@ -1,17 +1,58 @@
|
||||
cp = require("child_process")
|
||||
Promise = require("bluebird")
|
||||
os = require("os")
|
||||
execa = require("execa")
|
||||
|
||||
# resolves with zipped filename
|
||||
macZip = (src, dest) ->
|
||||
new Promise (resolve, reject) =>
|
||||
# Ditto (Mac) options
|
||||
# http://www.unix.com/man-page/OSX/1/ditto/
|
||||
# -c create archive
|
||||
# -k set archive format to PKZip
|
||||
# --sequesterRsrc When creating a PKZip archive, preserve resource
|
||||
# forks and HFS meta-data in the subdirectory __MACOSX
|
||||
# --keepParent when zipping folder "foo", makes the folder
|
||||
# the top level in the archive
|
||||
# foo.zip
|
||||
# foo/
|
||||
# ...
|
||||
zip = "ditto -c -k --sequesterRsrc --keepParent #{src} #{dest}"
|
||||
cp.exec zip, {}, (err, stdout, stderr) ->
|
||||
return reject(err) if err
|
||||
|
||||
console.log("✅ ditto zip finished")
|
||||
resolve(dest)
|
||||
|
||||
# resolves with zipped filename
|
||||
linuxZip = (src, dest) ->
|
||||
cmd = "tar -zcvf #{dest} #{src}"
|
||||
console.log("linux zip: #{cmd}")
|
||||
execa.shell(cmd)
|
||||
.then((result) ->
|
||||
console.log("✅ tar finished")
|
||||
dest
|
||||
)
|
||||
.catch((err) ->
|
||||
console.error("⛔️ could not zip #{src} into #{dest}")
|
||||
console.error(err.message)
|
||||
throw err
|
||||
)
|
||||
|
||||
zippers = {
|
||||
# until the CLI tool can unzip both ".zip" and ".tar.gz" files,
|
||||
# must use Mac platform to build the .zip file
|
||||
linux: macZip,
|
||||
darwin: macZip
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
ditto: (platform) ->
|
||||
platform.log("#zip")
|
||||
|
||||
src = platform.buildPathToApp()
|
||||
dest = platform.buildPathToZip()
|
||||
|
||||
new Promise (resolve, reject) =>
|
||||
zip = "ditto -c -k --sequesterRsrc --keepParent #{src} #{dest}"
|
||||
cp.exec zip, {}, (err, stdout, stderr) ->
|
||||
return reject(err) if err
|
||||
|
||||
resolve(dest)
|
||||
ditto: (src, dest) ->
|
||||
platform = os.platform()
|
||||
console.log("#zip", platform)
|
||||
console.log("Zipping %s into %s", src, dest)
|
||||
zipper = zippers[platform]
|
||||
if !zipper
|
||||
throw new Error("Missing zip function for platform #{platform}")
|
||||
zipper(src, dest)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user