envx-gen-pro
v1.0.4
Published
Smart environment manager for Angular: generate environment files and auto-update angular.json / .angular-cli.json
Maintainers
Readme
envx-gen-pro
Smart environment manager for Angular.
Create environment.*.ts files and automatically update angular.json or .angular-cli.json with safe and predictable defaults.
👉 View on npm: https://www.npmjs.com/package/envx-gen-pro
What it isenvx-gen-pro is an Angular environment file generator CLI. It helps you create and manage environment.ts, environment.prod.ts, and custom files such as environment.uat.ts or environment.sit.ts. It also updates angular.json fileReplacements or the legacy .angular-cli.json environments map. Ideal for multi environment Angular apps, CI pipelines, and enterprise Angular projects that want a repeatable workflow.
Table of contents
- Install
- Quick start
- Why envx-gen-pro
- Usage
- Examples
- What gets written
- How angular.json is updated
- Use cases
- Exit codes
- Troubleshooting
- Compatibility
- Uninstall
- Contributing
- Related searches
- License
Install
# Recommended
npm i -g envx-gen-pro
# One-off without global install
# npx installs the package then runs the binary
npx -p envx-gen-pro envx --help
# pnpm users
pnpm dlx envx-gen-pro envx --help
# yarn classic users
yarn dlx envx-gen-pro envx --helpRequirements: Node 16 or newer. Works with Angular projects that use angular.json. Also supports older .angular-cli.json projects.
Quick start
# 1) Create the default environment.ts under src/environments
envx gen
# 2) Create environment.sit.ts under src/environments/f1 and update angular.json
envx gen sit --folder=f1
# 3) Create environment.prod.ts and wire fileReplacements for the production configuration
envx gen prodWhy envx-gen-pro
- No more manual JSON edits for fileReplacements
- Reuse an existing environment as a template
- Consistent structure across teams and CI
- Works with modern Angular CLI and legacy
.angular-cli.json - Safe by default, refuses to overwrite unless you ask for it
Usage
envx [command] [options]Commands
gen [name]
Create an environment file and update Angular config.
nameis optional. If omitted, generatesenvironment.ts- If provided, generates
environment.<name>.ts
Default source when cloning
- If
src/environments/environment.tsexists, new files are cloned from it - Else if
src/environments/environment.prod.tsexists, clone from that - Else a minimal boilerplate is created
Angular config update
- For
angular.jsonAngular 6 and newer, updatesprojects.<project>.architect.build.configurations.<name>.fileReplacements - For
.angular-cli.jsonAngular 5 and older, updatesapps[0].environmentsmap
Options
--folder <relativePath> Folder under src/environments for the new file
Default: "."
Example result: src/environments/<folder>/environment[.<name>].ts
--project <name> Angular project name to update
If omitted, tries "defaultProject" from angular.json
--angular-json <path> Path to angular.json or .angular-cli.json
Default: ./angular.json if present, otherwise ./.angular-cli.json
--no-update-angular Only write the file. Skip changes to Angular config
--clone-from <path|alias> Explicit source file for cloning
Examples:
--clone-from=src/environments/environment.prod.ts
--clone-from=prod
--clone-from=default
--force Overwrite if the target file already exists
--dry-run Show changes without writing
--yes, -y Assume yes for prompts
--json Machine readable result output
--verbose Extra logs
--version Print version
--help Show helpExamples
Create the default env file in a feature folder:
envx gen --folder=mobile
# -> src/environments/mobile/environment.ts
# -> updates angular.json default build input when applicableCreate a UAT env and wire replacements:
envx gen uat
# -> src/environments/environment.uat.ts
# -> adds configurations.uat.fileReplacements
# from environment.ts -> environment.uat.tsCreate SIT under a subfolder and copy from prod:
envx gen sit --folder=f1 --clone-from=prod
# -> src/environments/f1/environment.sit.ts
# -> adds configurations.sit.fileReplacements to point at the new fileMonorepo example with a named project and a custom angular.json path:
envx gen qa --project=dashboard-app --angular-json=apps/dashboard/angular.jsonSkip Angular updates if you only want the file:
envx gen stage --no-update-angularWhat gets written
File pathsrc/environments[/<folder>]/environment[.<name>].ts
File content
Exports a plain environment object. If cloning, the entire source file content is copied then normalized. If bootstrapping, a minimal template is created like:
export const environment = {
production: false
};How angular.json is updated
When you create or reference a custom environment name, envx adds or updates the fileReplacements entry for that configuration.
Before
{
"projects": {
"app": {
"architect": {
"build": {
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
}
}
}
}
}After running envx gen sit
{
"projects": {
"app": {
"architect": {
"build": {
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
},
"sit": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.sit.ts"
}
]
}
}
}
}
}
}
}For .angular-cli.json the apps[0].environments map gets a new key and path.
Use cases
- Generate Angular
environment.tsandenvironment.prod.ts - Create custom environments like
environment.uat.ts,environment.sit.ts,environment.qa.ts - Automate
angular.jsonfileReplacements - Support for Angular workspaces and monorepos
- Useful for CI or CD pipelines that create build specific environment files
Exit codes
0success1fatal error2invalid input or conflicts without--force
Troubleshooting
Target file already exists and you did not pass
--force
The command refuses to overwrite. Rerun with--forceif you are sure.Project could not be resolved
Use--project <name>or setdefaultProjectinangular.json.Using a very old Angular project without
angular.json
Pass--angular-json .angular-cli.json. The tool updates theenvironmentssection.Windows shebang issues
npm creates platform shims for the binary, so it works across OS by default.
Compatibility
- Node 16 or newer
- Angular CLI 6 and newer for
angular.json - Angular CLI 1.x or 5.x supported via
.angular-cli.json
Uninstall
npm uninstall -g envx-gen-proContributing
Issues and PRs are welcome. Please include a failing case or a before and after snippet that makes it easy to reproduce.
Related searches
angular environment generator, angular.json fileReplacements automation, angular multiple environment files, angular CLI environment management, environment.ts vs environment.prod.ts, angular environments cli, angular config environments, angular create environment file, angular workspace environments
License
MIT © 2025 Krishna Saathvik Katari
