Application.json

So, recently I’ve been finding myself wanting an application.json file. Something that has basically all the contents of the .meteor/* files, but in JSON format.

Reasons

  • Can parse with JSON utilities
  • Use to autofetch packages for local development
  • Use to autoconfig nightwatch.json file
  • Use to autoconfig release track
  • Use to autoconfig documentation (js-doc)
  • Can store in a collection
  • Application configuration versioning
  • Used to generate product demo pages
  • Probably lots more reasons I can’t think of

Example

{
  "id": "5jp9be5bg84q1ad9zcr",
  "name": "Checklist Manifesto",
  "release":"clinical:METEOR@1.1.0.3-rc10",
  "version":"1.2.3",
  "recommended": false,
  "tool": "clinical:meteor-tool@1.0.35_3",
  "description": "An FDA, HIPAA, and HL7 ready version of the Meteor Todos app!",
  "tags": [
    "todos",
    "checklists",
    "universal",
    "workqueue",
    "hl7",
    "fda",
    "hipaa",
    "meteor"
  ],
  "finished-upgraders": [
    "notices-for-0.9.0",
    "notices-for-0.9.1",
    "notices-for-0.9.0",
    "notices-for-0.9.1",
    "0.9.4-platform-file",
    "notices-for-facebook-graph-api-2"
  ],
  "platforms": {
    "server": true,
    "browser": true,
    "ios": true
  },
  "cordova-plugins": [],
  "packages": {
    "accounts-base":"1.2.0",
    "accounts-password":"1.1.1",
    "aldeed:collection2":"2.7.0",
    "aldeed:simple-schema":"1.3.3",
    "anti:gagarin":"0.4.11",
    "autoupdate":"1.2.1",
    "awatson1978:fonts-helveticas":"1.0.4",
    "base64":"1.0.3",
    "binary-heap":"1.0.3",
    "blaze":"2.1.2",
    "blaze-tools":"1.0.3",
    "boilerplate-generator":"1.0.3",
    "callback-hook":"1.0.3",
    "check":"1.0.5",
    "clinical:active-entry":"1.5.21",
    "clinical:active-layout":"0.7.39",
    "clinical:active-users":"0.2.0",
    "clinical:auto-resizing":"0.1.2",
    "clinical:barcode":"3.0.1",
    "clinical:base-model":"1.3.0",
    "clinical:error-pages":"0.1.1",
    "clinical:extended-api":"2.2.3",
    "clinical:fonts":"1.0.0",
    "clinical:glass-ui":"1.3.10",
    "clinical:hipaa-logger":"1.0.1",
    "clinical:hl7-resource-datatypes":"0.1.0",
    "clinical:hl7-resource-diagnostic-order":"1.2.0",
    "clinical:keybindings":"1.2.6",
    "clinical:modals":"1.0.7",
    "clinical:router":"2.0.17",
    "clinical:router-location":"2.0.14",
    "clinical:router-middleware-stack":"2.0.13",
    "clinical:router-url":"2.0.15",
    "clinical:static-pages":"1.0.18",
    "clinical:theming":"0.4.9",
    "clinical:theming-ui":"0.2.7",
    "clinical:ui-vocabulary":"1.0.5",
    "clinical:user-model":"1.4.2",
    "coffeescript":"1.0.6",
    "ddp":"1.1.0",
    "deps":"1.0.7",
    "ejson":"1.0.6",
    "email":"1.0.6",
    "fastclick":"1.0.3",
    "fortawesome:fontawesome":"4.4.0",
    "geojson-utils":"1.0.3",
    "grove:less":"0.1.1",
    "html-tools":"1.0.4",
    "htmljs":"1.0.4",
    "http":"1.1.0",
    "ian:bootstrap-3":"3.3.1",
    "id-map":"1.0.3",
    "insecure":"1.0.3",
    "iron:controller":"1.0.8",
    "iron:core":"1.0.11",
    "iron:dynamic-template":"1.0.8",
    "iron:layout":"1.0.8",
    "jquery":"1.11.3_2",
    "json":"1.0.3",
    "launch-screen":"1.0.2",
    "less":"1.0.14",
    "livedata":"1.0.13",
    "localstorage":"1.0.3",
    "logging":"1.0.7",
    "matb33:collection-hooks":"0.7.15",
    "meteor":"1.1.6",
    "meteor-platform":"1.2.2",
    "meteorhacks:async":"1.0.0",
    "minifiers":"1.1.5",
    "minimongo":"1.0.8",
    "mobile-status-bar":"1.0.3",
    "momentjs:moment":"2.11.1",
    "mongo":"1.1.0",
    "mousetrap:mousetrap":"1.4.6_1",
    "npm-bcrypt":"0.7.8_2",
    "observe-sequence":"1.0.6",
    "ordered-dict":"1.0.3",
    "prime8consulting:meteor-oauth2-server":"0.0.2",
    "raix:eventemitter":"0.1.3",
    "random":"1.0.3",
    "reactive-dict":"1.1.0",
    "reactive-var":"1.0.5",
    "reload":"1.1.3",
    "retry":"1.0.3",
    "routepolicy":"1.0.5",
    "service-configuration":"1.0.4",
    "session":"1.1.0",
    "sha":"1.0.3",
    "simple:json-routes":"2.1.0",
    "socialize:server-time":"0.1.2",
    "spacebars":"1.0.6",
    "spacebars-compiler":"1.0.6",
    "srp":"1.0.3",
    "templating":"1.1.1",
    "tmeasday:publish-with-relations":"0.2.0",
    "tracker":"1.0.7",
    "ui":"1.0.6",
    "underscore":"1.0.3",
    "url":"1.0.4",
    "webapp":"1.2.0",
    "webapp-hashing":"1.0.3"
  }
}

Implementation
I think this is going to require a build plugin. Not just modifying the meteor-tool (which I’ve done), but adding an extra step in the build pipeline.

My initial thought is to create the application.json file, and put the build plugin at the front of the build pipeline, and generate the contents of the .meteor from it. The meteor tool does a lot of modifications to those files, however. So it’s likely that things will get changed out from underneath it.

And, well… I guess I’m looking for thoughts and opinions if this is a good idea, if there’s a package already doing this, packages and files I should look at to implement,EMT this, etc. Any thoughts on how one would get started on something like this?

5 Likes

This looks much better than what Meteor is doing at the moment. I encourage you to discuss this structure with MDG guys. I would love to see this JSON file in my repos instead of a .meteor folder.

Well, sort of trying to have that discussion by posting here! :slight_smile:

There’s a part of me that’s hoping it could be as simple as a build step at the beginning which just writes the files from application.json, like this:

application.json > .meteor/* > .meteor/build/local/*

The problem, of course, is that commands like meteor add and meteor create wouldn’t update the application.json by default. So it seems like implementing such functionality would require identifying all the different sources that write to .meteor/*.

Flipping things around doesn’t seem to be any better. One would still need to get into the innards and rewrite everything.

.meteor/* > application.json > .meteor/build/local/*

So, I suppose the question is then: what are all the tools that write to the .meteor/* files? Erp. :confused:

Starrynight 3.8.16 now includes a command to generate an application.json file. Example usage:

starrynight generate-application-json --name "Checklist Manifesto"

Now we need a build plugin that can parse an application.json into the necessary .meteor/* files. I’m thinking it should look something like this:

Plugin.registerCompiler({
  filenames: ["application.json", "meteor.json"]
}, function () {
  var compiler  = new meteorJsonCompiler();
  return compiler;
});

function meteorJsonCompiler() {}
meteorJsonCompiler.prototype.processFilesForTarget = function (files) {
  fs.readJson(files[0], function(error, applicationJson){
    fs.writeFile({ data: applicationJson["id"], path: '.meteor/.id' });
    fs.writeFile({ data: applicationJson["release"], path: '.meteor/release' });
    fs.writeFile({ data: applicationJson["platforms"], path: '.meteor/platforms' });
    fs.writeFile({ data: applicationJson["finished-upgraders"], path: '.meteor/.finished-upgraders' });
    fs.writeFile({ data: applicationJson["versions"], path: '.meteor/versions' });
  });
};

Why not open a ticket on https://github.com/meteor/meteor/issues and discuss this there? I can’t speak for MDG but IMHO this is magnitudes better than having a .meteor folder in a repository. Much better in so many ways.