npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@webed/build-info

v1.0.3

Published

🛠 A CLI to generate an easily importable `build.ts` file containing various details about the application build

Downloads

7

Readme

Description

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 and Usage

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.

Implementing in Angular

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:

Authors

License

This project is underlying the MIT-License. For more information, take a look at this projects LICENSE.md file.