Skip to content
Permalink
Browse files

fix(deploy): update task to allow event hooks

  • Loading branch information
Marten Klitzke
Marten Klitzke committed Jun 18, 2018
1 parent 67131e1 commit ab3d3baf38a3667fddb6a5caedc47617973d1a2c
Showing with 50 additions and 23 deletions.
  1. +1 −0 README.md
  2. +37 −22 index.js
  3. +2 −1 package.json
  4. +10 −0 yarn.lock
@@ -86,6 +86,7 @@ yarn add --dev shipit-release
- Basic Test Setup
- Basic Test Coverage
- Setup Contribution Guidelines
- Cleanup index.js
## License
@@ -1,4 +1,5 @@
const path = require('path2/posix')
const utils = require('shipit-utils')

function getCurrentRelease(result) {
return result.map(item => item.stdout.replace(/\n$/, '').split('/').pop())[0]
@@ -46,54 +47,68 @@ module.exports = function(shipit) {
await shipit.remote(`mkdir -p ${shipit.config.deployTo}`)

shipit.logInfo('Creating releases directory')
return shipit.remote(`mkdir -p ${shipit.releasesPath}`)
})

shipit.task('deploy', async () => {
extendShipit(shipit)
await shipit.remote(`mkdir -p ${shipit.releasesPath}`)

await shipit.start('install')
shipit.emit('build')
return shipit.emit('setup')
})

await shipit.start('upload')
shipit.emit('uploaded')
utils.registerTask(shipit, 'deploy', [
'deploy:install',
'deploy:upload',
'deploy:symlink',
'deploy:cleanup',
'deploy:finish',
])

await shipit.start('symlink')
shipit.emit('symlink')
shipit.task('deploy:finish', () => {
extendShipit(shipit)

await shipit.start('cleanup')
shipit.logInfo(`Done. Deployed version ${shipit.deployTime}`)
shipit.emit('finished')

return shipit.logInfo(`Done. Deployed version ${shipit.deployTime}`)
})

shipit.blTask('install', async () => {
shipit.blTask('deploy:install', async () => {
extendShipit(shipit)

shipit.logInfo('Installing deps & Building')
await shipit.local(shipit.config.installCommand)
return shipit.local(shipit.config.buildCommand)
await shipit.local(shipit.config.buildCommand)

shipit.emit('build')
})

shipit.blTask('upload', async () => {
shipit.blTask('deploy:upload', async () => {
extendShipit(shipit)

const deployPath = path.join(shipit.releasesPath, shipit.deployTime)

shipit.logInfo(`Creating new Release directory "${shipit.deployTime}"`)
await shipit.remote(`mkdir -p ${deployPath}`)

shipit.logInfo('Uploading new Release')
return shipit.copyToRemote(`${shipit.config.dirToCopy}/`, `${deployPath}/`)
await shipit.copyToRemote(`${shipit.config.dirToCopy}/`, `${deployPath}/`)

shipit.emit('uploaded')
})

shipit.blTask('symlink', async () => {
shipit.blTask('deploy:symlink', async () => {
extendShipit(shipit)

const deployPath = path.join(shipit.releasesPath, shipit.deployTime)

shipit.logInfo('Updating current Symlink')
return shipit.remote(`ln -nfs ${deployPath} ${shipit.currentPath}`)
await shipit.remote(`ln -nfs ${deployPath} ${shipit.currentPath}`)

shipit.emit('symlink')
})

shipit.blTask('cleanup', async () => {
shipit.blTask('deploy:cleanup', async () => {
extendShipit(shipit)

shipit.logInfo(`Keeping "${shipit.config.keepReleases}" last releases, cleaning others`)

const command = `(ls -rd ${shipit.releasesPath}/*|head -n ${shipit.config.keepReleases};ls -d ${shipit.releasesPath}/*)|sort|uniq -u|xargs rm -rf`
return shipit.remote(command)
await shipit.remote(command)
})

shipit.task('rollback', async () => {
@@ -20,6 +20,7 @@
"eslint-plugin-import": "2.12.0"
},
"dependencies": {
"path2": "^0.1.0"
"path2": "^0.1.0",
"shipit-utils": "^1.4.0"
}
}
@@ -1012,6 +1012,10 @@ lodash.upperfirst@4.3.1:
version "4.3.1"
resolved "https://registry.yarnpkg.com/lodash.upperfirst/-/lodash.upperfirst-4.3.1.tgz#1365edf431480481ef0d1c68957a5ed99d49f7ce"

lodash@^3.5.0:
version "3.10.1"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"

lodash@^4.17.4, lodash@^4.2.1, lodash@^4.3.0:
version "4.17.10"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"
@@ -1425,6 +1429,12 @@ shebang-regex@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"

shipit-utils@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/shipit-utils/-/shipit-utils-1.4.0.tgz#f963d7f104693711345a8b6ab9b913a2ee343c4c"
dependencies:
lodash "^3.5.0"

signal-exit@^3.0.0, signal-exit@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"

0 comments on commit ab3d3ba

Please sign in to comment.
You can’t perform that action at this time.