From 8e2f450fa3707e54c39129e8893c9fab49039e10 Mon Sep 17 00:00:00 2001 From: Kamil Burzynski Date: Fri, 12 Feb 2016 08:45:54 +0100 Subject: [PATCH] API usage updates after recent merges --- lib/ServerlessProject.js | 4 ++-- lib/actions/PluginCreate.js | 13 +++++++------ lib/actions/ResourcesDiff.js | 6 +++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/ServerlessProject.js b/lib/ServerlessProject.js index 16890ccc1..6b87f7289 100644 --- a/lib/ServerlessProject.js +++ b/lib/ServerlessProject.js @@ -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) { diff --git a/lib/actions/PluginCreate.js b/lib/actions/PluginCreate.js index d4cd50e0d..c2b0c4690 100644 --- a/lib/actions/PluginCreate.js +++ b/lib/actions/PluginCreate.js @@ -120,10 +120,10 @@ usage: serverless plugin create `, // 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 `, // 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)); }; } diff --git a/lib/actions/ResourcesDiff.js b/lib/actions/ResourcesDiff.js index 60e505dae..c13dfca62 100644 --- a/lib/actions/ResourcesDiff.js +++ b/lib/actions/ResourcesDiff.js @@ -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})