Keep npm package in sync with its template


Keywords
npm, template
License
BSD-2-Clause
Install
npm install npm-template-sync@7.8.26

Documentation

npm Greenkeeper semantic-release styled with prettier Build Status codecov.io Coverage Status Known Vulnerabilities GitHub Issues Stories in Ready Dependency Status devDependency Status docs XO code style downloads Commitizen friendly

npm-template-sync

Keep npm package in sync with its template

npm-template-sync --template aTemplateGithubUser/aRepo myGithubUser/myRepo

define (initial) properties to be used in the template

npm-template-sync --define "description=a very new fantastic module" -t myUser/myTemplate myUser/newModule

merges contents from template repo into destination repo handling some special cases for:

  • Licenses - rewriting license years
  • line set files like .npmignore and .gitignore - by merging both sets together
  • package.json - merge devDependencies, engines and scripts
  • rollup.conf.js - copy / rewrite

generated pull request

Some templates

API

Table of Contents

Context

Parameters

  • provider RepositoryProvider
  • options Object

Properties

  • provider RepositoryProvider
  • options Object
    • options.templateBranchName string

PreparedContext

context prepared to execute one package

Parameters

Properties

usedDevModules

all used dev modules

Returns Set<string>

executeSingleRepo

Returns Promise<PullRequest>

File

Mergable File

Parameters

  • path string location in the repository
  • options Object mergin options (optional, default {})

Properties

properties

Deliver some key properties

Parameters

  • branch Branch

Returns Object

merge

Parameters

  • context PreparedContect

Returns Object merged content

templateOptions

find merger options in the template section of a package.json

Parameters

Returns Object

compareVersion

compare two versions

Parameters

Returns number -1 if a < b, 0 if a == b and 1 if a > b

Readme

Extends File

injects badges into README.md

sortedKeys

order in which json keys are written

Package

Extends File

Merger for package.json

properties

Deliver some key properties

Parameters

  • branch Branch

Returns Object

defaultMerge

Parameters

  • destination
  • target
  • template
  • dp
  • name
  • messages

normalizePackage

bring package into nomalized (sorted) form

Parameters

Returns Object normalized source

MergeAndRemoveLineSet

Extends MergeLineSet

MergeLineSet

Extends File

File where every line is a key

defaultIgnoreSet

entries to be skipped from result

Returns Set<string>

NpmIgnore

Extends MergeAndRemoveLineSet

defaultIgnoreSet

entries to be skipped from result

Returns Set<string>

ReplaceIfEmpty

Extends File

Overwrites none existing file from template

Replace

Extends File

Replace file from template (always)

install

With npm do:

npm install -g npm-template-sync

# npm-template-sync --help

license

BSD-2-Clause