Closed Bug 1451911 Opened 6 years ago Closed 6 years ago

Action argument schemas published to NPM should include a JSON formatted version

Categories

(Firefox :: Normandy Client, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
Firefox 61
Tracking Status
firefox61 --- fixed

People

(Reporter: mythmon, Assigned: mythmon)

Details

Attachments

(1 file)

In bug 1440777, I added a set of schemas for local actions in Normandy. These are used by the code to verify the data sent from the server for each action. They are also intended to be used by the server to help validate user input and catch errors sooner. To facilitate this, the schemas are published to NPM.

However, the schemas are published as Javascript files, and the server is written in Python. Although it may be possible to deal with this on the server, it will be much easier to simply publish the schemas in JSON format, which they are anyways. This bug covers publishing a JSON version of the schemas.

This work blocks preference rollout.
Comment on attachment 8965489 [details]
Bug 1451911 - Publish action argument schemas as JSON

https://reviewboard.mozilla.org/r/234258/#review239890


Code analysis found 3 defects in this patch:
 - 3 defects found by mozlint

You can run this analysis locally with:
 - `./mach lint path/to/file` (JS/Python)


If you see a problem in this automated review, please report it here: http://bit.ly/2y9N9Vx


::: toolkit/components/normandy/actions/schemas/export_json.js:8
(Diff revision 1)
> +/**
> + * 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");

Error: 'require' is not defined. [eslint: no-undef]

::: toolkit/components/normandy/actions/schemas/export_json.js:9
(Diff revision 1)
> + * 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");

Error: 'require' is not defined. [eslint: no-undef]

::: toolkit/components/normandy/actions/schemas/index.js:22
(Diff revision 1)
>      }
>    }
>  };
>  
> -if (this.exports) {
> -  this.exports = ActionSchemas;
> +if (typeof module !== "undefined") {
> +  module.exports = ActionSchemas;

Error: 'module' is not defined. [eslint: no-undef]
Comment on attachment 8965489 [details]
Bug 1451911 - Publish action argument schemas as JSON

https://reviewboard.mozilla.org/r/234258/#review239898

lgtm! I'm not sure offhand what the magic incantation is to get eslint to ignore `require` and `module`, I think `/* global require, module */` might do it.
Attachment #8965489 - Flags: review?(rhelmer) → review+
Peter: I've published 0.2.0 to NPM with the changes from this bug. You should be able to access the schemas as JSON from the NPM package now.
Pushed by mcooper@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/119611f33837
Publish action argument schemas as JSON r=rhelmer
https://hg.mozilla.org/mozilla-central/rev/119611f33837
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 61
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: