From 5d6d3a476fcbd54d136ea3f3e2dbb9421c278273 Mon Sep 17 00:00:00 2001 From: Kaspars Dambis Date: Tue, 17 Dec 2024 09:43:51 +0200 Subject: [PATCH] Add blueprint URL generator --- Gruntfile.js | 34 +++++++++++++++++++++++----------- package.json | 3 ++- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 184caf3..b2e09d9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -3,6 +3,7 @@ const ignoreParse = require( 'parse-gitignore' ); const exec = require( 'child_process' ).exec; +const fs = require( 'fs' ); const deployConfig = { plugin_slug: 'contact-form-7-extras', @@ -97,18 +98,29 @@ module.exports = function( grunt ) { }, } ); - grunt.registerTask( 'check-diff', function() { - const done = this.async(); // This won't work with the ES6 fat arrow syntax. - - exec( 'git diff HEAD --quiet', ( err ) => { - if ( err ) { - grunt.log.error( 'Found uncommited changes in your current working directory.' ); - done( false ); - } + grunt.registerTask( + 'check-diff', + function() { + const done = this.async(); // This won't work with the ES6 fat arrow syntax. + + exec( 'git diff HEAD --quiet', ( err ) => { + if ( err ) { + grunt.log.error( 'Found uncommited changes in your current working directory.' ); + done( false ); + } + + done(); + } ); + } + ); - done(); - } ); - } ); + grunt.registerTask( + 'blueprint-url', + function() { + const blueprintJson = JSON.parse( fs.readFileSync( 'assets/blueprints/blueprint.json', 'utf8' ) ); + grunt.log.write( `Blueprint URL: https://playground.wordpress.net/#${ encodeURI( JSON.stringify( blueprintJson ) ) }` ); + } + ); grunt.registerTask( 'build', [ diff --git a/package.json b/package.json index 3ed9c9f..90980fc 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "build": "grunt build", "deploy": "grunt deploy", "deploy-trunk": "grunt deploy:trunk", - "wp-env": "wp-env" + "wp-env": "wp-env", + "blueprint": "grunt blueprint-url" }, "repository": { "type": "git",