Git Product home page Git Product logo

init-module's Introduction

NO LONGER MAINTAINED

This is a public archive. Use at your own risk.

๐Ÿ––


init-module

Add some sugar to the npm init command.

npm travis style downloads

npm init allows you to configure a few things and works from a few defaults. init-module is meant to take it a bit further, making all package.json properties editable, adding more defaults to npm config that will autopopulate when you run npm init -y, and allowing you to use npm init as a package.json editor.

Install

npm i -g init-module

Usage

npm allows you to configure an init module that will be loaded by the npm init command to override the default prompts. The init-module program is intended to be used in this manner.

npm set init-module $(init-module --path)

Once you've set the above config property, init-module will simply extend the default npm init command.

npm init

Configuration (npm init)

These defaults are already available to npm init without init-module.

Author Name: init-author-name

  • Default: ""
  • Type: String

The value npm init should use by default for the package author's name.

npm set init-author-name="Your Name"

Author Email: init-author-email

  • Default: ""
  • Type: String

The value npm init should use by default for the package author's email.

npm set init-author-email="[email protected]"

Author URL: init-author-url

  • Default: ""
  • Type: String

The value npm init should use by default for the package author's homepage.

npm set init-author-url="http://yoursite.com"

License init-license

  • Default: "ISC"
  • Type: String

The value npm init should use by default for the package license.

npm set init-license="BSD-2-Clause"

The license name must be a valid SPDX license expression. See https://spdx.org/licenses for more info.

Version init-version

  • Default: "1.0.0"
  • Type: semver

The value that npm init should use by default for the package version number, if not already set in package.json.

npm set init-version="1.0.0"

Configuration (init-module)

These defaults require init-module in order to be available in npm init.

Start Script: init-scripts-start

  • Default: null
  • Type: String

The command to use when running npm start.

npm set init-scripts-start="node ."

Test Script: init-scripts-test

  • Default: 'echo "Error: no test specified" && exit 1'
  • Type: String

The command to use when running npm test.

npm set init-scripts-test="standard"

Example

Here's an example of the init-* contents of my global .npmrc file.

init-author-email = "[email protected]"
init-author-name = "Nate Goldman"
init-author-url = "http://ungoldman.com/"
init-license = "ISC"
init-module = "/Users/ng/dev/github/init-module/init-module.js"
init-scripts-start = "node ."
init-scripts-test = "standard"
init-version = "1.0.0"

All configuration above can be set with npm set, which is just a shortcut for npm config set. You can also edit your .npmrc manually if you prefer (npm config edit will open your global .npmrc file with your default editor).

Running npm init in an empty directory with the above configuration, I get the following:

~/my-module $ npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help json` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg> --save` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
name: (my-module)
version: (1.0.0-alpha)
description: A fine module indeed.
entry point: (index.js)
test command: (standard)
start command: (node .)
git repository: https://github.com/ungoldman/my-module.git
keywords: my, module
author name: (Nate Goldman)
author email: ([email protected])
author url: (http://ungoldman.com)
license: (ISC)
private: (false) true
About to write to /Users/ng/dev/github/init-module/my-module/package.json:

{
  "name": "my-module",
  "version": "1.0.0-alpha",
  "description": "A fine module indeed.",
  "main": "index.js",
  "scripts": {
    "start": "node .",
    "test": "standard"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/ungoldman/my-module.git"
  },
  "keywords": [
    "my",
    "module"
  ],
  "author": "Nate Goldman <[email protected]> (http://ungoldman.com)",
  "license": "ISC",
  "private": true,
  "bugs": {
    "url": "https://github.com/ungoldman/my-module/issues"
  },
  "homepage": "https://github.com/ungoldman/my-module#readme"
}


Is this ok? (yes)

Note that with init-module, running npm init again will allow you to edit all of the above properties, unlike the stock npm init behavior.

name: (my-module)
version: (1.0.0-alpha)
description: (A fine module indeed.)
entry point: (index.js)
test command: (standard && tape test/*.js | tap-spec)
git repository: (git+https://github.com/ungoldman/my-module.git)
keywords: (my, module)
author name: (Nate Goldman)
author email: ([email protected])
author url: (http://ungoldman.com)
license: (ISC)
private: (true)

The "yes" option (force)

Running npm init -y in an empty directory with the example configuration above yields the following package.json:

{
  "name": "my-module",
  "version": "1.0.0-alpha",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "standard && tape test/*.js | tap-spec"
  },
  "author": "Nate Goldman <[email protected]> (http://ungoldman.com)",
  "license": "ISC"
}

Contributing

Contributions welcome! Please read the contributing guidelines first.

See also

License

ISC

init-module's People

Contributors

thancock20 avatar ungoldman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.