import { readFileSync } from 'fs';

export interface IPackage {
  name: string;
  description: string;
  version: TPackageVersion;
  license: string;
  dependencies: string;
  scripts: string;
  devDependencies: string;
}

type digit = number;
export type TPackageVersion = `${digit}.${digit}.${digit}`; // 暂时不考虑 1.0.0-beta这种类型
export function getPackageInfo(path: string): IPackage {
  const str = readFileSync(path, 'utf-8');
  return JSON.parse(str);
}
