UNPKG

@reliverse/rse

Version:

@reliverse/rse is your all-in-one companion for bootstrapping and improving any kind of projects (especially web apps built with frameworks like Next.js) — whether you're kicking off something new or upgrading an existing app. It is also a little AI-power

24 lines (23 loc) 937 B
import path from "@reliverse/pathkit"; import fs from "@reliverse/relifso"; import { relinka } from "@reliverse/relinka"; import { definePackageJSON, writePackageJSON } from "pkg-types"; export async function createPackageJSON(projectPath, projectName, isLib) { const packageJson = definePackageJSON({ name: projectName, version: "0.1.0", description: `${projectName} is built with \u2764\uFE0F by @rse`, type: "module", ...isLib ? {} : { private: true } }); const filename = "package.json"; const packageJsonPath = path.join(projectPath, filename); await writePackageJSON(packageJsonPath, packageJson); const content = await fs.readFile(packageJsonPath, "utf-8"); const formatted = JSON.stringify(JSON.parse(content), null, 2); await fs.writeFile(packageJsonPath, formatted, "utf-8"); relinka( "verbose", `Created ${filename} with ${isLib ? "library" : "application"} configuration` ); }