/*

The react library needs special preparation because the dependencies in package.json
represent the dependencies of the web application and the desktop application,
which includes a lot of junk if you're only using this as a react package.

For example, you don't need a video conversion library (ffmpeg) if you're importing
a react component.

This script replaces the package.json dependencies list with only whitelisted
dependencies.

In the future, we might want to add optional peer dependencies, because if you're
using configuration GUIs in the react app you might want a couple extra deps.

*/
var fs = require("fs");

var path = require("path");

var deps = ["react-image-annotate", "@material-ui/core", "@material-ui/styles", "@material-ui/icons", "moment", "react-dropzone", "react-icons", "react-select", "seamless-immutable", "styled-components", "use-event-callback", "material-survey", "react", "react-markdown", "react-nlp-annotate", "spelling", "i18next", "react-i18next", "i18next-browser-languagedetector", "react-time-series"];
var originalPackageJSON = JSON.parse(fs.readFileSync(path.join(__dirname, "../package.json")).toString());
var newDependencies = {};

for (var _i = 0, _deps = deps; _i < _deps.length; _i++) {
  var dep = _deps[_i];
  newDependencies[dep] = originalPackageJSON.dependencies[dep] || originalPackageJSON.devDependencies[dep];
}

fs.writeFileSync(path.join(__dirname, "../package.json"), JSON.stringify(Object.assign({}, originalPackageJSON, {
  devDependencies: Object.assign({}, originalPackageJSON.devDependencies, originalPackageJSON.dependencies),
  dependencies: newDependencies
}), null, "  "));