Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.
/ create-oss Public archive

init module used for OSS projects by the npm CLI team

License

Notifications You must be signed in to change notification settings

npm/create-oss

Folders and files

NameName
Last commit message
Last commit date
Aug 29, 2024
Oct 29, 2022
Dec 14, 2022
Dec 14, 2022
Aug 29, 2024
Dec 4, 2023
Aug 27, 2024
Oct 29, 2022
Dec 15, 2022
Dec 15, 2022
Oct 29, 2022
May 31, 2023
Jun 9, 2021
Oct 29, 2022
Aug 27, 2024
Aug 29, 2024
May 3, 2024

Repository files navigation

@npmcli/create-oss

This is a module designed to be consumed with npm init @npmcli/oss.

It creates a package.json containing some default fields for the npm CLI team.

Usage

> mkdir foo
> cd foo
> npm init @npmcli/oss

package.json

The default package.json is defined in lib/defaults.js and looks like the following:

const prompt = require('./prompt.js')
const defaults = {
  name: prompt({
    default: (_, { path }) => `@npmcli/${basename(path)}`,
    edit: true,
  }),
  version: '1.0.0',
  description: prompt(),
  main: 'lib/index.js',
  keywords: ['npm', 'oss'],
}

Prompting

The prompt function accepts any options allowed by read with a few minor tweaks.

If a prompt option is not specified, it will default to the name of the field being prompted for. As an example, in the above defaults the prompt for the description field will be description:.

The default option may be set to a value, or a function. If a function is used, it will be called with the name of the property and the options object. The result is awaited, so async functions can be used as well as sync.