KEMBAR78
GitHub - ackheron/prepare-angular-json: Generate a valid angular.json from a commented angular.jsonc. CLI-ready, CI-friendly, and perfect for clean Angular configs.
Skip to content

Generate a valid angular.json from a commented angular.jsonc. CLI-ready, CI-friendly, and perfect for clean Angular configs.

License

Notifications You must be signed in to change notification settings

ackheron/prepare-angular-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 valid angular.json
  • ✅ Automatically adds prepare-json and start scripts to your package.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

prepare-angular-json

This will:

  • Create or update angular.json from angular.jsonc

  • Add useful scripts to your package.json if 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);
}

About

Generate a valid angular.json from a commented angular.jsonc. CLI-ready, CI-friendly, and perfect for clean Angular configs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published