パッケージの詳細

init-roll

guoyunhe105MIT1.4.0

Framework for project creation and migration

node, cli

readme

init-roll

Framework for project creation and migration. Power your create-xxx or @xxx/create-xxx packages.

Install

npm install --save-dev init-roll

Usage

import { init } from 'init-roll';

init('/path/to/template', '/path/to/project', {
  // template parameters
  name: 'foobar',
  description: 'This is foobar',
});

Template writting guides

*.delete

If you created webpack.config.js.delete file, then webpack.config.js will be deleted. This is a convenient way to clean up conflict files and folders.

You can also use EJS syntax in template names, for example src/<%= name %>.delete.

*.default

If you created src/foobar.js.default template (support EJS template syntax):

  • If src/foobar.js doesn't exist, it will be created with content compiled from the template
  • If src/foobar.js exists, nothing will happen

You can also use EJS syntax in template names, for example src/<%= name %>.default.

*.override

If you created src/foobar.js.override template (support EJS template syntax), it will be compiled to src/foobar.js and override existing file.

You can also use EJS syntax in template names, for example src/<%= name %>.override.

*.merge.json

When deal with package.json, you can use /path/to/template/package.merge.json to merge template data with existing data. You can also use EJS template syntax in *.merge.json.

{
  <% if (esmOnly) { %>
  "type": "module",
  "main": "esm/index.js",
  <% } else { %>
  "main": "cjs/index.js",
  "module": "esm/index.js",
  <% } %>
  "bin": "cjs/<%= name %>.js"
}

*.delete.json

If you want to remove conflict keys in package.json file, create /path/to/template/package.delete.json, which contains keys you want to delete and values are null.

{
  "husky": null,
  "devDependencies": {
    "@babel/core": null,
    "webpack": null
  }
}

更新履歴

Changelog

1.4.0 - 2025-04-12

  • Added *.default template support
  • Added *.override template support
  • Deprecated *.ejs template support

1.3.0 - 2024-04-18

  • Changed bumpDependencies behavior to only bump dependencies from template

1.2.0 - 2024-04-07

  • Added prettier option to format updated files

1.1.0 - 2024-03-09

  • Added disableLog option
  • Fixed *.delete.json not saved issue

1.0.0 - 2024-02-02

  • Added init function