Bug 1451911 - Publish action argument schemas as JSON r=rhelmer
authorMike Cooper <mcooper@mozilla.com>
Thu, 05 Apr 2018 14:56:25 -0700
changeset 412291 119611f33837434c5ab16f8d2d3a431e61cfe493
parent 412290 d9110e28f3612bd40cfa21b29b0e05fc5afd10aa
child 412292 762644e47f6db87d3e034c9e83f80f5df8555386
push id33792
push useraiakab@mozilla.com
push dateSun, 08 Apr 2018 10:26:03 +0000
treeherdermozilla-central@dead7cffc5e3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrhelmer
bugs1451911
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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"
+  }
 }