Installations
npm install ng-process-env
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
16.20.0
NPM Version
8.19.4
Score
68.2
Supply Chain
96.9
Quality
74.4
Maintenance
100
Vulnerability
97.3
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (98.49%)
JavaScript (1.51%)
Developer
danduh
Download Statistics
Total Downloads
143,864
Last Day
231
Last Week
977
Last Month
4,000
Last Year
64,009
GitHub Statistics
19 Stars
47 Commits
3 Forks
1 Watching
10 Branches
1 Contributors
Bundle Size
317.00 B
Minified
245.00 B
Minified + Gzipped
Package Meta Information
Latest Version
16.0.6
Package Id
ng-process-env@16.0.6
Unpacked Size
52.94 kB
Size
14.14 kB
File Count
41
NPM Version
8.19.4
Node Version
16.20.0
Publised On
08 May 2023
Total Downloads
Cumulative downloads
Total Downloads
143,864
Last day
-3.8%
231
Compared to previous day
Last week
-14.8%
977
Compared to previous week
Last month
2.2%
4,000
Compared to previous month
Last year
14.3%
64,009
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Environment variables from process into Angular app
Angular already has its own environment system, which allows us to configure everything in src/environments/environment.ts, and we can create as many environments as we need. The problem is, sometimes you want to use the System Environment variables, for example, some configuration from the CI server or if the build process is running an "on-premise" server; in this case, the Angular environment system will not help.
ng-process-env will help you to retrieve values from System Environment variables (process.env[]
) and update
relevant environment.ts
file.
Installing
Just add it into your app.
1npm i ng-process-env
Run
1ng g ng-process-env:process-env
For monorepo managed by NRWL, use
nx
command instead ofng
You will be prompted to insert relevant project name.
1? Project name to update angular.json config. 2(you can skip and do it later using schematics or manually) my-app 3 Project my-app will be updated 4 Env File will be created at apps/my-app/src/environments
1? You can set name for config to be updated or added as a new one, 'onprem' - default
Define configuration name. It will create:
environment.<myconfig>.ts
file in your /environments folder.<myconfig>
section in your angular.json or project.json for nrwl managed monorepo
environment.
1export const environment = { 2 production: false, 3 baseUrl: 'http://localhost:4200', 4 envVar: { 5 /** 6 * Add environment variables you want to retriev from process 7 * PORT:4200, 8 * VAR_NAME: defaultValue 9 */ 10 } 11};
angular.json \ project.json
1{ 2 "targets": { 3 "build": { 4 ... 5 "configurations": { 6 "myconfig": { 7 "fileReplacements": [ 8 { 9 "replace": "apps/portfolio/src/environments/environment.ts", 10 "with": "apps/portfolio/src/environments/environment.myconfig.ts" 11 } 12 ] 13 } 14 } 15 } 16 } 17}
Update myconfig
section according to your needs
Collect Vars
Open a created file environment.<myconfig>.ts
Update envVar
section with variables you want to be retrieved from process.env
.
- Important: set default values.
1export const environment = { 2 production: false, 3 baseUrl: 'http://localhost:4200', 4 envVar: { 5 myVarA: 3, 6 myVarB: 'someValue' 7 } 8};
This part can be run during CI/CD process
To update the created environment.process.env
.
1export myVarA=4 2export myVarB=otherValue 3ng run my-app:collect-vars
It will change file to:
1export const environment = { 2 production: false, 3 baseUrl: "http://localhost:4200", 4 envVar: { 5 myVarA: 4 as number, 6 myVarB: "otherValue" 7 } 8};
After it, you can run a build command.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/danduh/ng-process-env/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/danduh/ng-process-env/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/danduh/ng-process-env/main.yml/main?enable=pin
- Info: 0 out of 3 GitHub-owned GitHubAction dependencies pinned
- Info: 1 out of 1 npmCommand dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Info: no jobLevel write permissions found
Reason
Found 0/24 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 9 are checked with a SAST tool
Reason
32 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-353f-5xf4-qw67
- Warn: Project is vulnerable to: GHSA-c24v-8rfc-w8vw
- Warn: Project is vulnerable to: GHSA-8jhw-289h-jh2g
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986 / GHSA-64vr-g452-qvp3
- Warn: Project is vulnerable to: GHSA-9cwx-2883-4wfx
- Warn: Project is vulnerable to: GHSA-vg6x-rcgg-rjx6
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
2.9
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to ng-process-env
@ng-heroes/ng-process-env
**ng-process-env** will help you to retrieve values from System Environment variables and update relevant `environment.ts` file.
@teamteanpm2024/maxime-unde-voluptas
**[angular's nicest part](https://github.com/angular/angular.js/blob/6b049c74ccc9ee19688bb9bbe504c300e61776dc/src/ng/parse.js) extracted as a standalone module for the browser and node.**