From bf26358530cee616ce84e2bc07c5426487f618fc Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Fri, 27 Apr 2018 17:46:37 +0000 Subject: [PATCH 1/3] Add emergence-fire-event command --- bin/fire-event | 50 +++++++++++++++++++++++++++++++++++++++++ package.json | 3 ++- php-bootstrap/event.php | 46 +++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100755 bin/fire-event create mode 100644 php-bootstrap/event.php diff --git a/bin/fire-event b/bin/fire-event new file mode 100755 index 0000000..813be47 --- /dev/null +++ b/bin/fire-event @@ -0,0 +1,50 @@ +#!/usr/bin/env node + + +require('yargs') + .command('$0 ', 'Fire event within site', yargs => { + yargs + .positional('site', { + describe: 'Handle of site to fire event within' + }) + .positional('event', { + describe: 'Name of event to fire' + }) + .positional('context', { + describe: 'Context path to fire event within' + }) + }, argv => { + var path = require('path'), + documentRoot = path.resolve(__dirname, '../php-bootstrap'), + PHPFPM = require('node-phpfpm'), + phpClient = new PHPFPM({ + sockFile: '/emergence/services/run/php-fpm/php-fpm.sock', + documentRoot: documentRoot + '/' + }), + payload = Object.assign({}, argv); + + delete payload._; + delete payload.help; + delete payload.version; + delete payload.site; + delete payload.event; + delete payload.context; + delete payload['$0']; + + // execute event via PHP-FPM interface + phpClient.run({ + uri: 'event.php', + json: { + site: argv.site, + event: argv.event, + context: argv.context, + payload: payload + } + }, function (err, output, phpErrors) { + if (err == 99) console.error('PHPFPM server error'); + console.log(output); + if (phpErrors) console.error(phpErrors); + }); + + }) + .argv; diff --git a/package.json b/package.json index 2874c71..299078c 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ "semver": "^5.1.0", "shelljs": "^0.5.3", "underscore": "1.3.x", - "underscore-cli": "^0.2.19" + "underscore-cli": "^0.2.19", + "yargs": "^11.0.0" }, "bin": { "emergence-kernel": "./bin/kernel", diff --git a/php-bootstrap/event.php b/php-bootstrap/event.php new file mode 100644 index 0000000..9eca178 --- /dev/null +++ b/php-bootstrap/event.php @@ -0,0 +1,46 @@ + Date: Fri, 27 Apr 2018 19:27:22 +0000 Subject: [PATCH 2/3] Register emergence-fire-event command --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 299078c..fb687f0 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,8 @@ "emergence-git-shell": "./bin/git-shell", "emergence-su": "./bin/su", "emergence-create-site": "./bin/create-site.sh", - "emergence-mysql-shell": "./bin/mysql-shell" + "emergence-mysql-shell": "./bin/mysql-shell", + "emergence-fire-event": "./bin/fire-event" }, "repository": { "type": "git", From 53ced060fd1333c9aab11734b99a0c358ed3edc9 Mon Sep 17 00:00:00 2001 From: Chris Alfano Date: Fri, 27 Apr 2018 19:32:46 +0000 Subject: [PATCH 3/3] Bump package version to 1.0.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fb687f0..ab9daca 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "emergence", "preferGlobal": true, - "version": "1.0.6", + "version": "1.0.7", "license": "MIT", "dependencies": { "hostile": "^1.0.2",