diff --git a/lib/SerializerFileSystem.js b/lib/SerializerFileSystem.js index 256b07010..164494b75 100644 --- a/lib/SerializerFileSystem.js +++ b/lib/SerializerFileSystem.js @@ -459,7 +459,7 @@ class SerializerFileSystem { * Serialize Variables */ - serializeStage(variables) { + serializeVariables(variables) { let _this = this; // Load component, then traverse component dirs to get all functions @@ -472,6 +472,55 @@ class SerializerFileSystem { JSON.stringify(variables.toObject(), null, 2)); }); } + + /** + * Deserialize Templates + */ + + deserializeTemplates(templates) { + + let _this = this; + + // Load component, then traverse component dirs to get all functions + return BbPromise.try(function() { + + // Validate: Check project path is set + if (!_this._S.hasProject()) throw new SError('Templates could not be loaded because no project path has been set on Serverless instance'); + + // Validate: Check exists + if (!SUtils.fileExistsSync(templates._config.filePath)) { + throw new SError('Templates could not be loaded because it does not exist in your project'); + } + + // Set Data + templates.fromObject(SUtils.readFileSync(templates._config.filePath)); + }) + .then(function() { + + // TODO: Look up each parent until s-project.json is found and add parent templates via addParent() + + }) + } + + /** + * Serialize Templates + */ + + // TODO: Finish + + serializeTemplates(templates) { + let _this = this; + + // Load component, then traverse component dirs to get all functions + return BbPromise.try(function() { + + // Validate: Check project path is set + if (!_this._S.hasProject()) throw new SError('Variables could not be saved because no project path has been set on Serverless instance'); + + return SUtils.writeFile(variables._config.filePath, + JSON.stringify(variables.toObject(), null, 2)); + }); + } } module.exports = SerializerFileSystem; diff --git a/lib/Templates.js b/lib/Templates.js index c426349d8..5a452ea0d 100644 --- a/lib/Templates.js +++ b/lib/Templates.js @@ -16,12 +16,12 @@ class Templates { } /** - * Set Parent - * - Optional: For file system serializer - * Format: { path: "", parent: {} } + * Add Parent + * - Parent templates which this template extends + * - Format: {parent} */ - _setParent(parent) { + addParent(parent) { }