// boilerplates/abc/files/$package.json.ts
import { loadPackageJson, type TransformerProps } from "@batijs/core";
export default async function getPackageJson(props: TransformerProps) {
const packageJson = await loadPackageJson(props, await import("../package.json").then((x) => x.default));
return packageJson
// set scripts
.setScript("test", {
value: "vitest",
precedence: 0,
})
// add dependencies
.addDependencies(["aws-cdk-lib", "constructs", "source-map-support"])
// add devDependencies with conditions on scripts, meaning that if all
// given scripts are moved or replaced, the dependency will also be removed
.addDevDependencies(["npm-run-all2"], ["deploy:aws", "cdk:app"])
// Only add `eslint-aws` if --eslint is provided
.addDevDependencies(["eslint-aws"], props.meta.BATI.has("eslint"));
}
Example