{"size": 606, "ext": "js", "max_stars_repo_path": "index.js", "max_stars_repo_name": "mymattcarroll/package-diff-summary.js", "max_stars_repo_stars_event_min_datetime": "2020-06-02T17:15:48.000Z", "max_stars_repo_stars_event_max_datetime": "2020-06-02T17:15:48.000Z", "max_issues_repo_path": "index.js", "max_issues_repo_name": "mymattcarroll/package-diff-summary.js", "max_issues_repo_issues_event_min_datetime": "2017-01-09T17:33:37.000Z", "max_issues_repo_issues_event_max_datetime": "2021-04-18T00:25:17.000Z", "max_forks_repo_path": "index.js", "max_forks_repo_name": "mymattcarroll/package-diff-summary.js", "max_forks_repo_forks_event_min_datetime": "2021-04-17T04:32:05.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-17T04:32:05.000Z"}
{"max_stars_count": 1, "max_issues_count": 48, "max_forks_count": 1, "avg_line_length": 24.24, "max_line_length": 82, "alphanum_fraction": 0.6518151815}
/* @flow */
'use strict';

const readPkgUp = require('read-pkg-up');

const git = require('./lib/git.js');
const diff = require('./lib/diff.js');

async function main(
  { previousVersion, cwd } /* : { previousVersion: string, cwd: string } */
) /* : Promise<string> */ {
  const oldPkg = JSON.parse(
    await git.gitShow(previousVersion, 'package.json', cwd)
  );
  const { packageJson } = await readPkgUp({ cwd });

  const delta = diff.diffPackages(oldPkg, packageJson);
  const text = await diff.deltaToMarkdown(delta, oldPkg, cwd); // CLI tool, relax!
  return text;
}

module.exports = {
  main,
};
