mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
SerializerFileSystem: sstart Templates
This commit is contained in:
parent
05662606cb
commit
4ddea440eb
@ -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;
|
||||
|
||||
@ -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) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user