Prepare Angular JSON.
Prepare Angular JSON is a lightweight CLI tool that generates a clean angular.json file from a commented angular.jsonc.
It allows you to keep your Angular configuration files readable and well-documented, while staying fully compatible with the Angular CLI.
✨ Features
- ✅ Converts
angular.jsonc(with comments) into validangular.json - ✅ Automatically adds
prepare-jsonandstartscripts to yourpackage.json - ✅ Validates JSON output before writing
- ✅ Ready for integration into CI/CD pipelines
- ✅ No runtime dependencies in your Angular app
🚀 Quick Start
Install globally
npm install -g prepare-angular-json
Run the tool
This will:
-
Create or update
angular.jsonfromangular.jsonc -
Add useful scripts to your
package.jsonif needed
Use it
pnpm start
#or
npm run start🛠 What it does
The tool adds or updates these entries in your package.json:
"scripts": { "prepare-json": "node prepare-angular-json.js", "start": "pnpm run prepare-json && ng serve" }
And generates this file if not present:
// prepare-angular-json.js import { readFileSync, writeFileSync, existsSync } from 'fs'; import stripJsonComments from 'strip-json-comments'; const inputPath = './angular.jsonc'; const outputPath = './angular.json'; if (!existsSync(inputPath)) { console.error(`❌ File "${inputPath}" not found.`); process.exit(1); } try { const jsonWithComments = readFileSync(inputPath, 'utf8'); const cleanedJson = stripJsonComments(jsonWithComments); JSON.parse(cleanedJson); writeFileSync(outputPath, cleanedJson); console.log(`✅ "${outputPath}" successfully created from "${inputPath}".`); } catch (error) { console.error('❌ Error:', error.message); process.exit(1); }