Merge pull request #630 from Nopik/v0.5-merge

API usage updates after recent merges
This commit is contained in:
Austen 2016-02-12 00:06:31 -08:00
commit 1d11f045bc
3 changed files with 12 additions and 11 deletions

View File

@ -235,8 +235,8 @@ class ServerlessProject {
// TODO: Back Compat Support -- Remove in V1
resources = _this.get().cloudFormation;
} else if (SUtils.fileExistsSync(path.join(_this._S.config.projectPath, 's-resources-cf.json'))) {
resources = SUtils.readAndParseJsonSync(path.join(_this._S.config.projectPath, 's-resources-cf.json'));
} else if (SUtils.fileExistsSync(_this._S.getProject().getFilePath('s-resources-cf.json'))) {
resources = SUtils.readAndParseJsonSync(_this._S.getProject().getFilePath('s-resources-cf.json'));
}
for (let c in _this.components) {

View File

@ -120,10 +120,10 @@ usage: serverless plugin create <plugin>`,
// Name of the plugin
let pluginName = this.evt.options.pluginName;
// Paths
let projectPath = this.S.config.projectPath;
let projectPath = this.S.getProject().getRootPath();
let serverlessPath = this.S.config.serverlessPath;
// Directories
let pluginsDirectory = path.join(projectPath, 'plugins');
let pluginsDirectory = this.S.getProject().getFilePath('plugins');
let pluginDirectory = path.join(pluginsDirectory, pluginName);
let pluginTemplateDirectory = path.join(serverlessPath, 'templates', 'plugin');
// Plugin files from the serverless template directory
@ -155,14 +155,15 @@ usage: serverless plugin create <plugin>`,
// TODO: Remove in V1 because will result in breaking change
// Add the newly create plugin to the plugins array of the projects s-project.json file
let sProjectJson = SUtils.readAndParseJsonSync(path.join(projectPath, 's-project.json'));
// TODO: this belongs to Project class
let sProjectJson = SUtils.readAndParseJsonSync(this.S.getProject().getFilePath('s-project.json'));
sProjectJson.plugins.push(pluginName);
fs.writeFileSync(path.join(projectPath, 's-project.json'), JSON.stringify(sProjectJson, null, 2));
fs.writeFileSync(this.S.getProject().getFilePath('s-project.json'), JSON.stringify(sProjectJson, null, 2));
// Add the newly created plugin to the package.json file of the project
let projectPackageJson = SUtils.readAndParseJsonSync(path.join(projectPath, 'package.json'));
let projectPackageJson = SUtils.readAndParseJsonSync(this.S.getProject().getFilePath('package.json'));
projectPackageJson.dependencies[pluginName] = JSON.parse(packageJson).version;
fs.writeFileSync(path.join(projectPath, 'package.json'), JSON.stringify(projectPackageJson, null, 2));
fs.writeFileSync(this.S.getProject().getFilePath('package.json'), JSON.stringify(projectPackageJson, null, 2));
};
}

View File

@ -83,7 +83,7 @@ module.exports = function(SPlugin, serverlessPath) {
let difference = diffString(templates.deployed, templates.local);
if (difference.trim() === 'undefined') {
SCli.log('Resourses templates are equal');
SCli.log('Resource templates are equal');
}
else {
console.log(difference)
@ -161,7 +161,7 @@ module.exports = function(SPlugin, serverlessPath) {
};
const fileName = `s-resources-cf-${this.evt.options.stage}-${this.evt.options.region.replace(/-/g,'')}.json`,
filePath = `${this.S.config.projectPath}/_meta/resources/${fileName}`;
filePath = this.S.getProject().getFilePath( '_meta', 'resources', fileName );
return this.S.actions.resourcesDeploy(resourcesDeployEvt)
@ -170,7 +170,7 @@ module.exports = function(SPlugin, serverlessPath) {
}
_getDeployedTemplate() {
// const StackName = this.CloudFormation.sGetResourcesStackName(this.evt.options.stage, this.S.state.project.name);
// const StackName = this.CloudFormation.sGetResourcesStackName(this.evt.options.stage, this.S.getProject().getName());
const StackName = this.S.state.getMeta().stages[this.evt.options.stage].regions[this.evt.options.region].variables.resourcesStackName;
return this.CloudFormation.getTemplatePromised({StackName})