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

d2-manifest

v1.0.0

Published

App manifest generator for DHIS 2 Web Apps

Downloads

1,779

Readme

D2 Manifest

D2 Manifest is a node app that helps generate manifests for DHIS2 apps.

Two modes of operation are supported: Automatic and interactive (manual).

Automatic mode is intended to be used during the build step of webapps. In this mode, field values are read from package.json as well as (optionally) from the command line. The manifest is then verified, before it's written to the target manifest file, typically manifest.webapp.

In interactive mode, initial field values may also be read from both package.json and the command line. Then the user will be given the opportunity to add, change and delete fields in the manifest before saving it to a file.

Basic usage

Basic usage is documented in d2-manifest itself. Using the following command d2-manifest can be made available globally:

npm install -g d2-manifest

You can then get usage information with the following command:

d2-manifest --help

In its simplest form, d2-manifest will read a source file and command line arguments, and write a manifest to a target file. If no source file is specified, some fields will be given default values. If no target file is specified, the manifest will be written to stdout.

Interactive mode can be enabled by specifying --interactive (or -i for short) on the command line. For example:

d2-manifest -i package.json

Using D2 Manifest in your app

The typical usage scenario for d2-manifest is to use it to automatically generate the manifest for your webapp during the build step. This guide assumes that you are using npm both for dependency management and to build your app.

Install d2-manifest as a development dependency (or optionally as a normal dependency):

npm install --save-dev d2-manifest

By default package.json does not contain all the fields that are needed to generate the manifest. Additionally, you may want to specify different values for some fields in the manifest than what's used by package.json. Both of these issues can be resolved by adding a new field to package.json called manifest.webapp. Any fields specified on this object will override any values read from the base object in package.json.

For example:

{
  "version": "1.2.3",
  "name": "my-npm-compatible-package-name",
  "description": "An example app",
  "scripts": {
    "build": "build-my-app && d2-manifest package.json build/manifest.webapp"
  },
  // ... various other fields
  "manifest.webapp": {
    "name": "My Example App for DHIS2",
    "icons": {
      "48": "icon.png"
    },
    "developer": {
      "name": "My Name",
      "email": "[email protected]"
    },
    "activities": {
      "dhis": {
        "href": ".."
      }
    },
    "launch_url": "app.html",
    "default_locale": "en"
  }
}

To generate a new manifest.webapp from package.json, do:

./node_modules/.bin/d2-manifest package.json build/manifest.webapp

You can also specify additional fields on the command line. Fields specified on the command line always override values read from any other source. Additionally, giving a field an empty value ("") on the command line will effectively remove that field from the manifest:

./node_modules/.bin/d2-manifest package.json build/manifest.webapp \
      --manifest.name="Super Cool App Name"

Given the package.json above, and assuming that build-my-app is the command you use to build your app, you could build your app and generate the manifest with the following command:

npm run-script build