Move package code up and add createDeploymentArtifacts to topmost package command.

This commit is contained in:
Frank Schmid 2017-04-20 15:11:35 +02:00
parent b2fe5b6aba
commit 6be0ba2f8f
6 changed files with 20 additions and 7 deletions

View File

@ -8,8 +8,6 @@ const generateCoreTemplate = require('./lib/generateCoreTemplate');
const saveServiceState = require('./lib/saveServiceState');
const saveCompiledTemplate = require('./lib/saveCompiledTemplate');
const mergeIamTemplates = require('./lib/mergeIamTemplates');
const zipService = require('./lib/zipService');
const packageService = require('./lib/packageService');
class AwsPackage {
constructor(serverless, options) {
@ -23,8 +21,6 @@ class AwsPackage {
Object.assign(
this,
packageService,
zipService,
generateCoreTemplate,
mergeIamTemplates,
generateArtifactDirectoryName,
@ -71,9 +67,6 @@ class AwsPackage {
'package:setupProviderConfiguration': () => BbPromise.bind(this)
.then(this.mergeIamTemplates),
'package:createDeploymentArtifacts': () => BbPromise.bind(this)
.then(this.packageService),
'before:package:compileFunctions': () => BbPromise.bind(this)
.then(this.generateArtifactDirectoryName),

View File

@ -1,9 +1,24 @@
'use strict';
const BbPromise = require('bluebird');
const path = require('path');
const zipService = require('./lib/zipService');
const packageService = require('./lib/packageService');
class Package {
constructor(serverless, options) {
this.serverless = serverless;
this.options = options;
this.servicePath = this.serverless.config.servicePath || '';
this.packagePath = this.options.package ||
this.serverless.service.package.path ||
path.join(this.servicePath || '.', '.serverless');
Object.assign(
this,
packageService,
zipService
);
this.commands = {
package: {
@ -33,6 +48,11 @@ class Package {
},
},
};
this.hooks = {
'package:createDeploymentArtifacts': () => BbPromise.bind(this)
.then(this.packageService),
};
}
}