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

@w11k/git-info

v1.1.2

Published

creates a version file to display git info in your angular app

Downloads

15,847

Readme

@w11k/git-info

This schematic fro the angular-cli let's you easily setup a workflow that allows you to access the git-information in your Angular App. Read our detailed blog post about the topic.

Installation

Add this schematic to your project using the ng add command

ng add @w11k/git-info

This will setup everything you need. We will automatically

  • add required devDependencies to your package.json
  • add a script git-version.js in the same folder where your package.json ist
  • add a npm postinstall-hook to the scipts section of your package.json
  • add the automatically generated file to the .gitignore

Customization

By default the schematic hooks into the postinstall-hook that is triggered after npm install has finished. Typically you would execute a fresh npm install on your build server whenever you deploy a new version of your app. If you however don't do a fresh install every time due to caching for example you can call the postinstall hook manually via

npm run postinstall

or use another hook like prebuild or no hook at all, but just a regular script in the scripts section of the package.json

Usage

After each npm install we trigger the npm-hook to update the automatically generated file environments/version.ts This is a normal Typescript file that simply exports a constant. It is very important that this file in not committed to the git-repo. The file looks similar to this:

// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
/* tslint:disable */
export const VERSION = {
    "dirty": true,
    "raw": "34a0f1d-dirty",
    "hash": "34a0f1d",
    "distance": null,
    "tag": null,
    "semver": null,
    "suffix": "34a0f1d-dirty",
    "semverString": null,
    "version": "0.0.0"
};
/* tslint:enable */

To use the generated VERSION you can simply import it in your Angular Components/Services like so

import { Component } from '@angular/core';
import { VERSION } from '../environments/version';  

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app';
  
  constructor() {
    console.log(`Application version is: version (from package.json)=${VERSION.version}, git-tag=${VERSION.tag}, git-hash=${VERSION.hash}`);
  }
}

Automatically bump the version number

To update the version number every time your CI/CD publishes an update to production use

npm version patch

Acknowledgement

  • Idea and Code heavily inspired by this blog post
  • Angular schematic implementation heavily inspired by jest-schematic