diff --git a/scripts/gen-changelog.ts b/scripts/gen-changelog.ts index 0d01ff8f..4a4774be 100644 --- a/scripts/gen-changelog.ts +++ b/scripts/gen-changelog.ts @@ -1,6 +1,6 @@ -import { git, readPackageJSON } from './utils.ts'; +import packageJSON from '../package.json' with { type: 'json' }; +import { git } from './utils.ts'; -const packageJSON = readPackageJSON(); const labelsConfig: { [label: string]: { section: string; fold?: boolean } } = { 'PR: breaking change 💥': { section: 'Breaking Change 💥', diff --git a/scripts/utils.ts b/scripts/utils.ts index b45ec3e9..857b31d7 100644 --- a/scripts/utils.ts +++ b/scripts/utils.ts @@ -1,11 +1,4 @@ -import * as childProcess from 'node:child_process'; -import * as fs from 'node:fs'; -import * as path from 'node:path'; - -export function localRepoPath(...paths: ReadonlyArray): string { - const repoDir = path.resolve(import.meta.dirname, '..'); - return path.join(repoDir, ...paths); -} +import childProcess from 'node:child_process'; interface GITOptions extends SpawnOptions { quiet?: boolean; @@ -74,24 +67,3 @@ function spawn( throw new Error(`Command failed: ${command} ${args.join(' ')}`); } } - -interface PackageJSON { - description: string; - version: string; - private?: boolean; - repository?: { url?: string }; - scripts?: { [name: string]: string }; - type?: string; - exports: { [path: string]: string }; - types?: string; - typesVersions: { [ranges: string]: { [path: string]: Array } }; - devDependencies?: { [name: string]: string }; - publishConfig: { tag: string }; -} - -export function readPackageJSON( - dirPath: string = localRepoPath(), -): PackageJSON { - const filepath = path.join(dirPath, 'package.json'); - return JSON.parse(fs.readFileSync(filepath, 'utf-8')); -}