diff --git a/Gruntfile.js b/Gruntfile.js index 05df9e6..20b501d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -6,6 +6,9 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-ftp-deploy'); + var secret = grunt.file.exists('secrets.json') ? grunt.file.readJSON('secrets.json') : {}; + var config = grunt.file.readJSON('config.json'); + var path = { css_src: 'src/stylesheets/global.scss', css_dest: 'src/stylesheets/global.css', @@ -30,8 +33,8 @@ module.exports = function(grunt) { common changes centralized to key files instead of being littered throughout the Gruntfile. This also makes it easy to .gitignore secrets ================================================= */ - secret: grunt.file.exists('secrets.json') ? grunt.file.readJSON('secrets.json') : {}, - config: grunt.file.readJSON('config.json'), + secret: secret, + config: config, /* SASS ------------------------------------------------- */ @@ -304,14 +307,37 @@ module.exports = function(grunt) { to: "<%= config.strings.litmus_email %>", src: 'dist_test/user_invitation.html' } - } + }, + + 'postmark-templates-generate': { + options: { + src: [path.email_src], + dist: path.dist, + file: '<%= config.templates && config.templates.file %>' + } + }, + + 'postmark-templates-upload': { + options: { + ephemeralUploadResultsProperty: '<%= config.templates && config.templates.ephemeralUploadResultsProperty %>' + } + }, + 'postmark-templates-output': { + options: { + outputFile: '<%= config.templates && config.templates.output_file || config.templates && config.templates.file %>', + cleanOutput: '<%= config.templates && config.templates.clean_output %>', + ephemeralUploadResultsProperty: '<%= config.templates && config.templates.ephemeralUploadResultsProperty %>' + } + }, }); /* Tasks ================================================= */ + grunt.loadTasks('tasks'); + grunt.registerTask('default', ['css', 'html']); // Assets @@ -325,6 +351,9 @@ module.exports = function(grunt) { grunt.registerTask('litmus', ['testBuild', 'postmark:litmus']); grunt.registerTask('flood', ['testBuild', 'postmark:flood']); + // Upload + grunt.registerTask('upload', ['default', 'postmark-templates-generate', 'postmark-templates']); + // Before sending tests via Postmark, ensure that test builds with inlined CSS are generated grunt.registerTask('testBuild', ['default', 'copy:testTemplates', 'premailer:html']); }; diff --git a/example_config.json b/example_config.json index 24d5e59..e087ede 100644 --- a/example_config.json +++ b/example_config.json @@ -50,5 +50,10 @@ "bucket": "", "region": "", "overwrite": true + }, + "templates": { + "file": "templates.json", + "cleanOutput": true, + "ephemeralUploadResultsProperty": "postmark-templates-upload-results" } } diff --git a/package.json b/package.json index 7dd21c5..a0e6f18 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "spamcheck": "grunt spamcheck", "litmus": "grunt litmus", "flood": "grunt flood", + "upload": "grunt upload", "build": "grunt" }, "devDependencies": { @@ -28,7 +29,7 @@ "grunt-contrib-watch": "^1.0.0", "grunt-ftp-deploy": "^0.1.10", "grunt-inline": "^0.3.4", - "grunt-postmark": "0.0.7", + "grunt-postmark": "0.0.8", "grunt-premailer": "^1.0.0", "grunt-prettify": "^0.4.0", "grunt-sass": "^1.0.0", @@ -36,6 +37,7 @@ "grunt-spamcheck": "0.1.1", "grunt-text-replace": "^0.4.0", "load-grunt-tasks": "^3.2.0", - "time-grunt": "^1.2.1" + "time-grunt": "^1.2.1", + "yaml-front-matter": "^3.4.0" } } diff --git a/previews.html b/previews.html index 5db4f22..ee414c7 100644 --- a/previews.html +++ b/previews.html @@ -3,7 +3,7 @@