#! /usr/bin/env node
"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

var _require = require("yargs"),
    argv = _require.argv;

var chalk = require("chalk");

var Adio = require("./..");

var cosmiconfig = require("cosmiconfig");

var explorer = cosmiconfig("adio");
var rootConfig = explorer.searchSync(process.cwd()) || {};
var adio = new Adio(_objectSpread({}, rootConfig.config, {}, argv));

try {
  var results = adio.test();
  var packagesWithErrors = results.filter(function (r) {
    return r.errors.count;
  });

  if (packagesWithErrors.length === 0) {
    console.log(chalk.green("✅  All dependencies in order!"));
    process.exit(0);
  }

  packagesWithErrors.forEach(function (pckg, index) {
    console.log(chalk.red("".concat(index + 1, ". ").concat(pckg.packageJson.name || "🚨 Package name missing.", " (").concat(pckg.dir, ")")));

    if (pckg.errors.deps.src.length) {
      console.log(chalk.cyan("Packages used in source code, but not listed in package.json:"));
      pckg.errors.deps.src.forEach(function (item, index) {
        console.log("".concat(index + 1, ". ").concat(item));
      });
    }

    if (pckg.errors.deps.dependencies.length) {
      console.log(chalk.cyan("Packages listed as a dependency in package.json, but not used in source code:"));
      pckg.errors.deps.dependencies.forEach(function (item, index) {
        console.log("".concat(index + 1, ". ").concat(item));
      });
    }

    if (pckg.errors.deps.devDependencies.length) {
      console.log(chalk.cyan("Packages listed as a devDependency in package.json, but not used in source code:"));
      pckg.errors.deps.devDependencies.forEach(function (item, index) {
        console.log("".concat(index + 1, ". ").concat(item));
      });
    }

    if (pckg.errors.deps.peerDependencies.length) {
      console.log(chalk.cyan("Packages listed as a peerDependency in package.json, but not used in source code:"));
      pckg.errors.deps.peerDependencies.forEach(function (item, index) {
        console.log("".concat(index + 1, ". ").concat(item));
      });
    }

    console.log();
  });
  process.exit(1);
} catch (e) {
  console.log(chalk.red(e.message));
}
//# sourceMappingURL=adio.js.map