Bug 1451911 - Publish action argument schemas as JSON r?rhelmer draft
authorMike Cooper <mcooper@mozilla.com>
Thu, 05 Apr 2018 14:56:25 -0700
changeset 778207 223c62170add11c4e4caeca5c1b3920100354cb8
parent 777984 110f32790d38a258cab722064aae40736478ef51
push id105429
push userbmo:mcooper@mozilla.com
push dateThu, 05 Apr 2018 23:00:55 +0000
reviewersrhelmer
bugs1451911
milestone61.0a1
Bug 1451911 - Publish action argument schemas as JSON r?rhelmer MozReview-Commit-ID: 8tMyX1PdseV
toolkit/components/normandy/actions/schemas/export_json.js
toolkit/components/normandy/actions/schemas/index.js
toolkit/components/normandy/actions/schemas/package.json
new file mode 100755
--- /dev/null
+++ b/toolkit/components/normandy/actions/schemas/export_json.js
@@ -0,0 +1,16 @@
+#!/usr/bin/env node
+/* eslint-env node */
+
+/**
+ * This script exports the schemas from this package in JSON format, for use by
+ * other tools. It is run as a part of the publishing process to NPM.
+ */
+
+const fs = require("fs");
+const schemas = require("./index.js");
+
+fs.writeFile("./schemas.json", JSON.stringify(schemas), err => {
+  if (err) {
+    console.error("error", err);
+  }
+});
--- a/toolkit/components/normandy/actions/schemas/index.js
+++ b/toolkit/components/normandy/actions/schemas/index.js
@@ -13,11 +13,12 @@ const ActionSchemas = {
         "description": "Message to log to the console",
         "type": "string",
         "default": ""
       }
     }
   }
 };
 
-if (this.exports) {
-  this.exports = ActionSchemas;
+if (typeof module !== "undefined") {
+  /* globals module */
+  module.exports = ActionSchemas;
 }
--- a/toolkit/components/normandy/actions/schemas/package.json
+++ b/toolkit/components/normandy/actions/schemas/package.json
@@ -1,8 +1,11 @@
 {
   "name": "mozilla-normandy-action-argument-schemas",
-  "version": "0.1.0",
+  "version": "0.2.0",
   "description": "Schemas for Normandy action arguments",
   "main": "index.js",
   "author": "Michael Cooper <mcooper@mozilla.com>",
-  "license": "MPL-2.0"
+  "license": "MPL-2.0",
+  "scripts": {
+    "prepack": "node export_json.js"
+  }
 }