
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
angular-build-info
Advanced tools
🛠 A CLI to generate an easily importable `build.ts` file containing various details about the application build
angular-build-info
is a command line interface to collect information about your current build. It compiles information such as the timestamp when the application was built, the current git user, the hash of the latest commit and the current version from inside your projects package.json
file.
Example output of the CLI looks as follows:
// Angular build information, automatically generated by `4dams/angular-build-info`
export const buildInfo = {
user: "Juri Adams",
hash: "1e872b5",
version: "1.1.4",
timestamp: "November 15, 2019 16:37:35",
};
Installation is pretty easy:
npm i -g angular-build-info
Running the script with the --init
flag (angular-build-info --init
) then produces a build.ts
file inside your Angular projects src/
folder. You can then proceed to import this file inside your Angular application. An example making use of this information can be found below.
Another important thing to use this tool effectively is to update your package.json
scripts. Below is an example of what your build
or deploy
script might look like.
{
"scripts": {
"build": "angular-build-info && ng build",
"deploy": "angular-build-info && ng build --prod && ./deploy"
}
}
If you now run any of these commands, information about the current build will be saved inside the previously mentioned build.ts
file.
Below is an example of what your app.component.ts
might look like after implementing the information from inside the build.ts
file.
import { Component } from "@angular/core";
import { buildInfo } from "../build";
import { environment } from "../environments/environment";
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.css"],
})
export class AppComponent {
constructor() {
console.log(
`\n%cBuild Info:\n\n` +
`%c ❯ Environment: %c${environment.production ? "production 🏭" : "development 🚧"}\n` +
`%c ❯ Build Version: ${buildInfo.version}\n` +
` ❯ Build Timestamp: ${buildInfo.timestamp}\n` +
` ❯ Build Message: %c${buildInfo.message || "<no message>"}\n`,
"font-size: 14px; color: #7c7c7b;",
"font-size: 12px; color: #7c7c7b",
environment.production ? "font-size: 12px; color: #95c230;" : "font-size: 12px; color: #e26565;",
"font-size: 12px; color: #7c7c7b",
"font-size: 12px; color: #bdc6cf",
);
}
}
This is what the previous code will output in the browser console once you open the app:
This project is underlying the MIT-License. For more information, take a look at this projects LICENSE.md file.
FAQs
🛠 A CLI to generate an easily importable `build.ts` file containing various details about the application build
The npm package angular-build-info receives a total of 938 weekly downloads. As such, angular-build-info popularity was classified as not popular.
We found that angular-build-info demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.