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

@ngstack/install

v0.3.1

Published

Angular Package Installer

Downloads

1

Readme

Install

Build Status

Command-line utility for installing Angular libraries into the Angular CLI-based projects.

Main features

  • Install library from the NPM or local package (i.e. tarball file)
  • Register assets, styles and scripts with angular.json
  • Register library modules in the application
  • Format updated application module with Prettier
  • Generate new configuration file for a library

Getting the tool

Install as a global package using the following command:

npm i -g @ngstack/install

You can use the tool everywhere using ngi alias.

Options

Run ngi without parameters to see the internal help.

| Name | Description | | ------------------ | ------------------------------------------------------------------ | | -v, --version | output the version number | | -n, --name <name> | set library name if installing from custom sources (default: null) | | --init | create a new configuration file | | --module <module> | module to use for the registration (default: app) | | --import [modules] | list of modules to import | | --skip-install | skip installing library | | --skip-assets | skip copying assets | | --skip-module | skip module registration | | --skip-format | skip code formatting | | -h, --help | output usage information |

Preparing libraries

Add and publish an ngi.json file as part of your library.

Example:

{
  "assets": [
    {
      "glob": "**/*.json",
      "input": "./assets",
      "output": "./assets/plugins"
    }
  ],
  "modules": [
    {
      "name": "MyExtensionModule",
      "namespace": "my-extension"
    }
  ]
}

Based on the configuration above, the tool is going to perform the following actions:

  • copy all JSON files from assets to the assets/plugin folder
  • generate import { MyExtensionModule } from 'my-extension'; in the /src/app/app.module.ts
  • put the MyExtensionModule into the module imports section

Asset configuration

The asset configuration format is based on the Angular CLI settings. However, the input property defines the path relative to the library structure, rather than application one.

{
  "glob": "**/*.json",
  "input": "./assets",
  "output": "./assets/plugins"
}

Styles and Scripts

You can also register custom styles and scripts in the corresponding sections within angular.json file.

Example (ngi.json):

{
  "styles": ["./styles/one.css", "./styles/two.css"],
  "scripts": ["./scripts/test1.js", "./scripts/test2.js"]
}

Upon execution the ngi tool is going to use relative paths to the extension folder.

Example (angular.json)

{
  "styles": [
    "node_modules/my-extension/styles/one.css",
    "node_modules/my-extension/styles/two.css"
  ],
  "scripts": [
    "node_modules/my-extension/scripts/test1.js",
    "node_modules/my-extension/scripts/test2.js"
  ]
}

Installing arbitrary libraries

The tool works best with the ngi.json configuration files that are published with the libraries. However it is also possible to install an arbitrary Angular library.

In this case you need to provide one or multiple module names to import.

ngi @company/library --import=Module1,Module2

As a result of the command above, the tool is going to install @company/library from the NPM, and setup the main application module with two imports:

import { Module1 } from '@company/library';
import { Module2 } from '@company/library';

@NgModule({
  imports: [Module1, Module2]
})
export class AppModule {}

Note that you will have to setup asset rules for angular.json file manually.

Examples

Install library my-extension from the NPM and perform integration tasks if ngi.json file present.

ngi my-extension

Install library from the tarball generated by the npm pack command. Use my-extension name to find and use library in the node_modules.

ngi my-extension-0.0.1.tgz my-extension

Perform only application module integration for manually installed library

ngi my-extension-0.0.1.tgz my-extension --skip-install --skip-assets

License

MIT