Skip to content

Commit

Permalink
fix: set-version serverless plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
mvayngrib committed Jul 13, 2018
1 parent db6597d commit 8ef2876
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
5 changes: 3 additions & 2 deletions .serverless_plugins/set-version.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

const { StackUtils } = require('../lib/stack-utils')
const vInfo = require('../lib/version')
const versionInfo = require('../lib/version')

class SetVersion {
constructor(serverless, options) {
Expand All @@ -13,11 +13,12 @@ class SetVersion {
}

setVersion() {
const { dir } = StackUtils.getStackLocation({
const { dir } = StackUtils.getStackLocationKeys({
...process.env,
service: this.serverless.service.service,
stage: this.options.stage,
region: this.options.region,
versionInfo,
})

this.serverless.service.package.artifactDirectoryName = dir
Expand Down
26 changes: 20 additions & 6 deletions src/stack-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,24 +537,38 @@ export default class StackUtils {
return this.aws.cloudformation.updateStack(params).promise()
}

public static getStackLocation = ({ service, stage, region, versionInfo, deploymentBucket }: {
public static getStackLocationKeys = ({ service, stage, region, versionInfo }: {
service: string
stage: string
region: string
versionInfo: VersionInfo
deploymentBucket: Bucket
}) => {
const { tag, commit } = versionInfo
const dir = `serverless/${service}/${stage}/${tag}`
const templateKey = `${dir}/compiled-cloudformation-template.json`
const zip = `${dir}/${service}.zip`
const regional = deploymentBucket.getRegionalBucket(region)
const zipKey = `${dir}/${service}.zip`
return {
dir,
templateKey,
zip,
zipKey
}
}

public static getStackLocation = (opts: {
service: string
stage: string
region: string
versionInfo: VersionInfo
deploymentBucket?: Bucket
}) => {
const { region, deploymentBucket } = opts
const regional = deploymentBucket.getRegionalBucket(region)
const loc = StackUtils.getStackLocation(opts)
const { zipKey, templateKey } = loc
return {
...loc,
templateUrl: regional.getUrlForKey(templateKey),
zipUrl: regional.getUrlForKey(templateKey),
zipUrl: regional.getUrlForKey(zipKey),
}
}

Expand Down

0 comments on commit 8ef2876

Please sign in to comment.