mirror of
https://github.com/SrIzan10/next-auth.git
synced 2026-05-01 10:55:20 +00:00
* chore: fix `next-auth` version in `package.json` * chore: add WIP publish script * chore: fix comments, add TODOs * chore: set newer TS target * chore: extract release config * chore: WIP work on publish script * chore: finish up release script * chore: do not push unless not dryRun * chore: add debug env var, return early if no package to update * chore: remove unnecessary comment * chore: remove changeset and unused dependencies * chore: drop `semantic-release` * chore: remove `jsonfile` dependency * chore: address code review * fix: list other commits in changelog when releasing * chore: fix env variable references * chore: fetch with tags and commit history * chore: fix analyze code * chore: fix utils script * chore: better changelog formatting * chore: fix package path * chore: fix some remaining stuff * chore: remove DEBUG flag
34 lines
830 B
TypeScript
34 lines
830 B
TypeScript
import type { PackageJson } from "type-fest"
|
|
|
|
import fs from "fs/promises"
|
|
import path from "path"
|
|
|
|
async function read(directory: string): Promise<PackageJson> {
|
|
const content = await fs.readFile(
|
|
path.join(process.cwd(), directory, "package.json"),
|
|
"utf8"
|
|
)
|
|
return JSON.parse(content)
|
|
}
|
|
|
|
async function update(
|
|
directory: string,
|
|
data: Partial<PackageJson>
|
|
): Promise<void> {
|
|
const original = await pkgJson.read(directory)
|
|
const content = JSON.stringify({ ...original, ...data }, null, 2)
|
|
await fs.writeFile(
|
|
path.join(process.cwd(), directory, "package.json"),
|
|
content,
|
|
"utf8"
|
|
)
|
|
}
|
|
|
|
export const pkgJson = { read, update }
|
|
|
|
export function debug(...args: any[]): void {
|
|
if (!process.env.DEBUG) return
|
|
const [first, ...rest] = args
|
|
console.log(`\n[debug] ${first}\n`, ...rest, "\n")
|
|
}
|