now supports frontmatter for advanced file templating

This commit is contained in:
Philipp Kunz 2017-05-27 23:52:58 +02:00
parent fa961f86b8
commit b9a346c5d7
8 changed files with 77 additions and 11 deletions

View File

@ -69,9 +69,15 @@ class ScafTemplate {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let smartfileArrayToWrite = plugins.lodash.cloneDeep(this.templateSmartfileArray); let smartfileArrayToWrite = plugins.lodash.cloneDeep(this.templateSmartfileArray);
for (let smartfile of smartfileArrayToWrite) { for (let smartfile of smartfileArrayToWrite) {
// render the template
let template = yield plugins.smarthbs.getTemplateForString(smartfile.contents.toString()); let template = yield plugins.smarthbs.getTemplateForString(smartfile.contents.toString());
let renderedTemplateString = template(this.suppliedVariables); let renderedTemplateString = template(this.suppliedVariables);
smartfile.contents = Buffer.from(renderedTemplateString); // handle frontmatter
let parsedTemplate = plugins.smartfm.parse(renderedTemplateString);
if (parsedTemplate.data.fileName) {
smartfile.updateFileName(parsedTemplate.data.fileName);
}
smartfile.contents = Buffer.from(parsedTemplate.content);
} }
yield plugins.smartfile.memory.smartfileArrayToFs(smartfileArrayToWrite, destinationDirArg); yield plugins.smartfile.memory.smartfileArrayToFs(smartfileArrayToWrite, destinationDirArg);
}); });
@ -132,4 +138,4 @@ class ScafTemplate {
} }
} }
exports.ScafTemplate = ScafTemplate; exports.ScafTemplate = ScafTemplate;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLmNsYXNzZXMuc21hcnRzY2FmLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRzY2FmLmNsYXNzZXMuc21hcnRzY2FmLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7QUFBQSwrQ0FBOEM7QUFDOUMsK0NBQThDO0FBVzlDO0lBQUE7UUFNRSxzQkFBaUIsR0FBUSxFQUFFLENBQUE7UUFDM0IscUJBQ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7Z0JBQ0QsV0FBVyxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsTUFBTSxDQUFDLFdBQVcsRUFBRSxnQkFBZ0IsQ0FBQyxDQUFBO1lBQ3BFLENBQUM7WUFDRCxXQUFXLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLENBQUE7WUFDOUMsTUFBTSxDQUFDLFdBQVcsQ0FBQTtRQUNwQixDQUFDO0tBQUE7SUFFRDs7Ozs7Ozs7Ozs7T0FXRztJQUNXLHNCQUFzQjs7WUFDbEMsSUFBSSxpQkFBaUIsR0FBRyxJQUFJLENBQUMsc0JBQXNCLENBQUMsTUFBTSxDQUFDLFlBQVk7Z0JBQ3JFLE1BQU0sQ0FBQyxZQUFZLENBQUMsVUFBVSxDQUFDLElBQUksS0FBSyxjQUFjLENBQUE7WUFDeEQsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDLENBQUE7WUFFTCxFQUFFLENBQUMsQ0FBQyxpQkFBaUIsQ0FBQyxDQUFDLENBQUM7Z0JBQ3RCLElBQUksYUFBYSxHQUFHLE1BQU0sT0FBTyxDQUFDLFNBQVMsQ0FBQyxrQkFBa0IsQ0FDNUQsaUJBQWlCLENBQUMsUUFBUSxDQUFDLFFBQVEsRUFBRSxDQUN0QyxDQUFBO2dCQUNELElBQUksQ0FBQyxnQkFBZ0IsR0FBRyxhQUFhLENBQUE7WUFDdkMsQ0FBQztZQUFDLElBQUksQ0FBQyxDQUFDO2dCQUNOLElBQUksQ0FBQyxnQkFBZ0IsR0FBRyxFQUFFLENBQUE7WUFDNUIsQ0FBQztRQUNILENBQUM7S0FBQTtDQUNGO0FBcklELG9DQXFJQyJ9

View File

@ -2,8 +2,9 @@ import 'typings-global';
import * as lodash from 'lodash'; import * as lodash from 'lodash';
import * as path from 'path'; import * as path from 'path';
import * as smartfile from 'smartfile'; import * as smartfile from 'smartfile';
import * as smartfm from 'smartfm';
import * as smarthbs from 'smarthbs'; import * as smarthbs from 'smarthbs';
import * as smartinteract from 'smartinteract'; import * as smartinteract from 'smartinteract';
import * as smartq from 'smartq'; import * as smartq from 'smartq';
import * as smartyaml from 'smartyaml'; import * as smartyaml from 'smartyaml';
export { lodash, path, smartfile, smarthbs, smartinteract, smartq, smartyaml }; export { lodash, path, smartfile, smartfm, smarthbs, smartinteract, smartq, smartyaml };

View File

@ -7,6 +7,8 @@ const path = require("path");
exports.path = path; exports.path = path;
const smartfile = require("smartfile"); const smartfile = require("smartfile");
exports.smartfile = smartfile; exports.smartfile = smartfile;
const smartfm = require("smartfm");
exports.smartfm = smartfm;
const smarthbs = require("smarthbs"); const smarthbs = require("smarthbs");
exports.smarthbs = smarthbs; exports.smarthbs = smarthbs;
const smartinteract = require("smartinteract"); const smartinteract = require("smartinteract");
@ -15,4 +17,4 @@ const smartq = require("smartq");
exports.smartq = smartq; exports.smartq = smartq;
const smartyaml = require("smartyaml"); const smartyaml = require("smartyaml");
exports.smartyaml = smartyaml; exports.smartyaml = smartyaml;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNjYWYucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2QixpQ0FBZ0M7QUFTOUIsd0JBQU07QUFSUiw2QkFBNEI7QUFTMUIsb0JBQUk7QUFSTix1Q0FBc0M7QUFTcEMsOEJBQVM7QUFSWCxxQ0FBb0M7QUFTbEMsNEJBQVE7QUFSViwrQ0FBOEM7QUFTNUMsc0NBQWE7QUFSZixpQ0FBZ0M7QUFTOUIsd0JBQU07QUFSUix1Q0FBc0M7QUFTcEMsOEJBQVMifQ== //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzY2FmLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydHNjYWYucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2QixpQ0FBZ0M7QUFVOUIsd0JBQU07QUFUUiw2QkFBNEI7QUFVMUIsb0JBQUk7QUFUTix1Q0FBc0M7QUFVcEMsOEJBQVM7QUFUWCxtQ0FBa0M7QUFVaEMsMEJBQU87QUFUVCxxQ0FBb0M7QUFVbEMsNEJBQVE7QUFUViwrQ0FBOEM7QUFVNUMsc0NBQWE7QUFUZixpQ0FBZ0M7QUFVOUIsd0JBQU07QUFUUix1Q0FBc0M7QUFVcEMsOEJBQVMifQ==

View File

@ -28,7 +28,8 @@
"dependencies": { "dependencies": {
"@types/lodash": "^4.14.64", "@types/lodash": "^4.14.64",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"smartfile": "^4.2.15", "smartfile": "^4.2.16",
"smartfm": "^1.0.5",
"smarthbs": "^1.0.15", "smarthbs": "^1.0.15",
"smartinteract": "^1.0.4", "smartinteract": "^1.0.4",
"smartq": "^1.1.1", "smartq": "^1.1.1",

View File

@ -1 +0,0 @@
awesome!

View File

@ -69,12 +69,22 @@ export class ScafTemplate {
async writeToDisk (destinationDirArg) { async writeToDisk (destinationDirArg) {
let smartfileArrayToWrite = plugins.lodash.cloneDeep(this.templateSmartfileArray) let smartfileArrayToWrite = plugins.lodash.cloneDeep(this.templateSmartfileArray)
for (let smartfile of smartfileArrayToWrite) { for (let smartfile of smartfileArrayToWrite) {
// render the template
let template = await plugins.smarthbs.getTemplateForString( let template = await plugins.smarthbs.getTemplateForString(
smartfile.contents.toString() smartfile.contents.toString()
) )
let renderedTemplateString = template(this.suppliedVariables) let renderedTemplateString = template(this.suppliedVariables)
smartfile.contents = Buffer.from(renderedTemplateString)
// handle frontmatter
let parsedTemplate = plugins.smartfm.parse(renderedTemplateString)
if (parsedTemplate.data.fileName) {
smartfile.updateFileName(parsedTemplate.data.fileName)
} }
smartfile.contents = Buffer.from(parsedTemplate.content)
}
await plugins.smartfile.memory.smartfileArrayToFs(smartfileArrayToWrite, destinationDirArg) await plugins.smartfile.memory.smartfileArrayToFs(smartfileArrayToWrite, destinationDirArg)
} }

View File

@ -2,6 +2,7 @@ import 'typings-global'
import * as lodash from 'lodash' import * as lodash from 'lodash'
import * as path from 'path' import * as path from 'path'
import * as smartfile from 'smartfile' import * as smartfile from 'smartfile'
import * as smartfm from 'smartfm'
import * as smarthbs from 'smarthbs' import * as smarthbs from 'smarthbs'
import * as smartinteract from 'smartinteract' import * as smartinteract from 'smartinteract'
import * as smartq from 'smartq' import * as smartq from 'smartq'
@ -11,6 +12,7 @@ export {
lodash, lodash,
path, path,
smartfile, smartfile,
smartfm,
smarthbs, smarthbs,
smartinteract, smartinteract,
smartq, smartq,

View File

@ -184,6 +184,12 @@ ansi-escapes@^1.1.0:
version "1.4.0" version "1.4.0"
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e"
ansi-red@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/ansi-red/-/ansi-red-0.1.1.tgz#8c638f9d1080800a353c9c28c8a81ca4705d946c"
dependencies:
ansi-wrap "0.1.0"
ansi-regex@^2.0.0: ansi-regex@^2.0.0:
version "2.1.1" version "2.1.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"
@ -192,6 +198,10 @@ ansi-styles@^2.2.1:
version "2.2.1" version "2.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"
ansi-wrap@0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/ansi-wrap/-/ansi-wrap-0.1.0.tgz#a82250ddb0015e9a27ca82e82ea603bbfa45efaf"
argparse@^1.0.7: argparse@^1.0.7:
version "1.0.9" version "1.0.9"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.9.tgz#73d83bc263f86e97f8cc4f6bae1b0e90a7d22c86" resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.9.tgz#73d83bc263f86e97f8cc4f6bae1b0e90a7d22c86"
@ -340,6 +350,10 @@ code-point-at@^1.0.0:
version "1.1.0" version "1.1.0"
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77" resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
coffee-script@^1.12.4:
version "1.12.6"
resolved "https://registry.yarnpkg.com/coffee-script/-/coffee-script-1.12.6.tgz#285a3f7115689065064d6bf9ef4572db66695cbf"
concat-map@0.0.1: concat-map@0.0.1:
version "0.0.1" version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
@ -386,6 +400,12 @@ exit-hook@^1.0.0:
version "1.1.1" version "1.1.1"
resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8" resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8"
extend-shallow@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f"
dependencies:
is-extendable "^0.1.0"
extend@^3.0.0: extend@^3.0.0:
version "3.0.1" version "3.0.1"
resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444"
@ -442,6 +462,16 @@ graceful-fs@^4.1.2, graceful-fs@^4.1.6:
version "4.1.11" version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
gray-matter@^2.1.0:
version "2.1.1"
resolved "https://registry.yarnpkg.com/gray-matter/-/gray-matter-2.1.1.tgz#3042d9adec2a1ded6a7707a9ed2380f8a17a430e"
dependencies:
ansi-red "^0.1.1"
coffee-script "^1.12.4"
extend-shallow "^2.0.1"
js-yaml "^3.8.1"
toml "^2.3.2"
handlebars@^4.0.8: handlebars@^4.0.8:
version "4.0.10" version "4.0.10"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.10.tgz#3d30c718b09a3d96f23ea4cc1f403c4d3ba9ff4f" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.10.tgz#3d30c718b09a3d96f23ea4cc1f403c4d3ba9ff4f"
@ -502,6 +532,10 @@ is-buffer@^1.1.5:
version "1.1.5" version "1.1.5"
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc" resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc"
is-extendable@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89"
is-fullwidth-code-point@^1.0.0: is-fullwidth-code-point@^1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb"
@ -524,7 +558,7 @@ isarray@~1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
js-yaml@^3.8.3, js-yaml@^3.8.4: js-yaml@^3.8.1, js-yaml@^3.8.3, js-yaml@^3.8.4:
version "3.8.4" version "3.8.4"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.8.4.tgz#520b4564f86573ba96662af85a8cafa7b4b5a6f6" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.8.4.tgz#520b4564f86573ba96662af85a8cafa7b4b5a6f6"
dependencies: dependencies:
@ -827,9 +861,9 @@ smartenv@^2.0.0:
smartq "^1.1.1" smartq "^1.1.1"
typings-global "^1.0.14" typings-global "^1.0.14"
smartfile@^4.2.11, smartfile@^4.2.15: smartfile@^4.2.11, smartfile@^4.2.16:
version "4.2.15" version "4.2.16"
resolved "https://registry.yarnpkg.com/smartfile/-/smartfile-4.2.15.tgz#e179bfa2bab107cc11fe800f3cbf194b1370091d" resolved "https://registry.yarnpkg.com/smartfile/-/smartfile-4.2.16.tgz#bb93ab4b66d75733c3c2df5ac1859bec747cf7cf"
dependencies: dependencies:
"@types/fs-extra" "3.x.x" "@types/fs-extra" "3.x.x"
"@types/vinyl" "^2.0.0" "@types/vinyl" "^2.0.0"
@ -844,6 +878,13 @@ smartfile@^4.2.11, smartfile@^4.2.15:
vinyl "^2.0.2" vinyl "^2.0.2"
vinyl-file "^3.0.0" vinyl-file "^3.0.0"
smartfm@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/smartfm/-/smartfm-1.0.5.tgz#3f9cbef3e414cf4519df9a8c2ca1254220af811e"
dependencies:
gray-matter "^2.1.0"
typings-global "^1.0.14"
smarthbs@^1.0.15: smarthbs@^1.0.15:
version "1.0.15" version "1.0.15"
resolved "https://registry.yarnpkg.com/smarthbs/-/smarthbs-1.0.15.tgz#f7c68fbc90f4a03625b52e97cb242dc62bc72359" resolved "https://registry.yarnpkg.com/smarthbs/-/smarthbs-1.0.15.tgz#f7c68fbc90f4a03625b52e97cb242dc62bc72359"
@ -994,6 +1035,10 @@ tmp@^0.0.29:
dependencies: dependencies:
os-tmpdir "~1.0.1" os-tmpdir "~1.0.1"
toml@^2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/toml/-/toml-2.3.2.tgz#5eded5ca42887924949fd06eb0e955656001e834"
type-detect@0.1.1: type-detect@0.1.1:
version "0.1.1" version "0.1.1"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-0.1.1.tgz#0ba5ec2a885640e470ea4e8505971900dac58822" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-0.1.1.tgz#0ba5ec2a885640e470ea4e8505971900dac58822"