Moving out static food JSON files

Arthur Tkachenko
groceristar
Published in
3 min readMar 2, 2019
Photo by Bonnie Kittle on Unsplash

This article is part of our plans, related to groceristar-fetch, aka static food data plugin.

In order to not get confused, please read the

Main plan

Before we have another repo, that store an old code, that we move into fetch plugin. npm link, github

At the first stage, it was just a separated store of static files.

Then we start to add more methods and then we move everything into our current repository. If we’ll go into separation way — I propose that we should move our data to that repository. But we’ll need to clean it up and update the JSON files. And then connect that plugin with fetch plugin.

Side notes:

  1. I find some cool plugins, like https://www.npmjs.com/package/gray-matter
  2. it can help us with parsing methods. It has some intersections with another project that I want to build, so maybe we should review it too and decide to use or not right now.
  3. I assume that we can create a separated file, that will handle all file imports.
  4. as we did with at getRawFiles
  5. In order to make a smooth transition — we add a new layer for connecting our files #177

Plan

  1. Discuss the current plan. Decide when to start to work on it
  2. Review/Compare data that we have at static-data repository and fetch. Can we delete everything from static-data and move our files?
  3. what minimal impact should we make at static-data? The main goal of this repo will be to return data from files. But should we add Babel, builds, tests, etc? It’ll be cool to keep it as clean as possible, but I think it’s ok to have default JS methods as `parser` and get and basic tests coverage.
  4. discuss what methods we will move to static-data. I need a complete list before we’ll start to do it. it’ll save us time. we also need to figure out what tests should be moved too. I assume it’ll be easy to understand when we’ll have a complete list of methods that we’re moving — so we’ll move all tests, related to that methods…
  5. moving data away, running all tests, publish on npm an update. connect it with fetch and run fetch tests in order to understand that everything works as it was before.
  6. should we update the documentation, readme, docu website?

Next goal: it’s hard to validate the structure of JSON file when we’re working with it manually. I install a plugin `jsonlint` and at the root of the package, we have a config file for it. Right now I add the only `grocery.json`, but I assume we’ll add all of our files to this file and run validation checks. It works only from CLI or at Travis CI builds. It’ll throw an error when something is wrong.

There a lot of different libraries, that works with json files. We need to try some of them and keep a few, that will save time and simplify our main methods. We also need to check if our json files work well with JSON5 specification. Modules, that work with schemas, as jest-json-schema can help us too.

--

--