0.3.2 • Published 1 year ago

gulp-reinstall v0.3.2

Weekly downloads
23
License
MIT
Repository
github
Last release
1 year ago

gulp-reinstall

gulp-reinstall is a gulp plugin to automatically install npm, bower, tsd, typings, composer and pip packages/dependencies.

NPM

CI build devDependency Status License: MIT

Overview

gulp-reinstall runs package install commands based on the files found in a vinyl stream. The filename determines the command that is run.

The default settings are:

File FoundCommand run
package.jsonnpm install
bower.jsonbower install
tsd.jsontsd reinstall --save
typings.jsontypings install
composer.jsoncomposer install
requirements.txtpip install -r requirements.txt

It will run the command in the directory it finds the file, so if you have configs nested in a lower directory than your gulpfile.js, this will still work.

NOTE gulp-reinstall requires at least NodeJS 8.3.

Usage

var reinstall = require('gulp-reinstall');

gulp.src(['./bower.json', './package.json']).pipe(reinstall());

Options

options.commands

Type: Object

Default: null

Use this option to add or override the command to be run for a particular filename.

var reinstall = require('gulp-reinstall');

gulp
  .src(__dirname + '/templates/**')
  .pipe(gulp.dest('./'))
  .pipe(
    reinstall({
      commands: {
        'package.json': 'yarn',
      },
      yarn: ['install', '--ignore-scripts', '--force'],
    })
  ); // yarn install --ignore-scripts --force

options.production

Type: Boolean

Default: false

Set to true if invocations of npm install and bower install should be appended with the --production parameter.

Example:

var reinstall = require('gulp-reinstall');

gulp
  .src(__dirname + '/templates/**')
  .pipe(gulp.dest('./'))
  // npm install --production
  .pipe(reinstall({ production: true }));

options.ignoreScripts

Type: Boolean

Default: false

Set to true if invocations of npm install should be appended with the --ignore-scripts parameter. Useful for skipping postinstall scripts with npm.

Example:

var reinstall = require('gulp-reinstall');

gulp
  .src(__dirname + '/templates/**')
  .pipe(gulp.dest('./'))
  // npm install --ignore-scripts
  .pipe(reinstall({ ignoreScripts: true }));

options.noOptional

Type: Boolean

Default: false

Set to true if invocations of npm install should be appended with the --no-optional parameter, which will prevent optional dependencies from being installed.

Example:

var reinstall = require('gulp-reinstall');

gulp
  .src(__dirname + '/templates/**')
  .pipe(gulp.dest('./'))
  // npm install --no-optional
  .pipe(reinstall({ noOptional: true }));

options.allowRoot

Type: Boolean

Default: false

Set to true if invocations of bower install should be appended with the --allow-root parameter.

Example:

var reinstall = require('gulp-reinstall');

gulp
  .src(__dirname + '/templates/**')
  .pipe(gulp.dest('./'))
  // bower install --allow-root
  .pipe(reinstall({ allowRoot: true }));

options.args

Type: Array | String

Default: undefined

Specify additional arguments that will be passed to all install command(s).

Example:

var reinstall = require('gulp-reinstall');

gulp
  .src(__dirname + '/templates/**')
  .pipe(gulp.dest('./'))
  .pipe(
    reinstall(
      {
        args: ['dev', '--no-shrinkwrap'],
      } // npm install --dev --no-shrinkwrap
    )
  );

options.\

Type: Array | String | Object

Default: null

Use this to specify additional arguments for a particular command.

Example:

var reinstall = require('gulp-reinstall');

gulp
  .src(__dirname + '/templates/**')
  .pipe(gulp.dest('./'))
  .pipe(
    reinstall({
      // Either a single argument as a string
      npm: '--production',
      // Or arguments as an object (transformed using Dargs: https://www.npmjs.com/package/dargs)
      bower: { allowRoot: true },
      // Or arguments as an array
      pip: ['--target', '.'],
    })
  );

Credits

This plugin is inspired by gulp-install, and significant parts of the source code owe a debt to that plugin, although the main plugin logic is largely rewritten.

The gulp-install plugin appears to be no longer maintained, and is dependent on the now-deprecated gulp-util package. gulp-reinstall removes that dependency, and also reduces the number of package dependencies to avoid npm audit problems in future.

Contributing

Contributions are very welcome! The rest of this section describes how to set yourself up for developing gulp-reinstall.

Getting started

Just clone the repo locally and start hacking. Run npm test to see if stuff broke.

Changelog

This project follows the Keep a Changelog conventions.

Commit mesages

Please use the Angular commit guidelines when writing commit messages.

Release process

(These are mainly notes for the maintainer, if you are contributing you won't need to worry about this)

The release process is driven by release-it. First you create a draft GitHub release locally by using release-it, then you publish the release through the GitHub web UI.

To create a draft release:

  1. On your local computer, checkout the main branch.
  2. Update the changelog.
  3. Run npm run release with the options you want, then follow the prompts. The two most useful options are --dry-run and --preRelease=alpha (or whatever the pre-release version is). Note that you need to add -- before any release-it arguments.

Example:

npm run release -- --dry-run --preRelease=alpha

The release-it settings are configured to create a draft release on GitHub. Once the release is published within GitHub, an automated workflow publishes the package to the npm repository.

Note: in order to run the release process, you need to set up the RELEASEMGMT_GITHUB_API_TOKEN environment variable on your local computer. This should contain a GitHub PAT with the appropriate permissions - see the release-it documentation for more details.

License

Licensed under the MIT License.

0.3.2

1 year ago

0.3.1

1 year ago

0.3.0

3 years ago

0.3.0-alpha.0

3 years ago

0.1.0

4 years ago

0.2.0

4 years ago

0.0.1-alpha.2

4 years ago

0.0.1-alpha.1

4 years ago

0.0.1-alpha.0

4 years ago