From c50981efa474123b5753a38cd14c35a798e529d9 Mon Sep 17 00:00:00 2001 From: Jamie Mason Date: Thu, 24 Aug 2017 19:19:56 +0100 Subject: [PATCH 1/4] docs(readme): update readme buttons --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3afc932..75fb2d6 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,14 @@ [![NPM version](http://img.shields.io/npm/v/shrinkpack.svg?style=flat-square)](https://www.npmjs.com/package/shrinkpack) [![NPM downloads](http://img.shields.io/npm/dm/shrinkpack.svg?style=flat-square)](https://www.npmjs.com/package/shrinkpack) -[![Build Status](http://img.shields.io/travis/JamieMason/shrinkpack/master.svg?style=flat-square)](https://travis-ci.org/JamieMason/shrinkpack) [![Dependency Status](http://img.shields.io/david/JamieMason/shrinkpack.svg?style=flat-square)](https://david-dm.org/JamieMason/shrinkpack) -[![Join the chat at https://gitter.im/JamieMason/shrinkpack](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/JamieMason/shrinkpack) +[![Build Status](http://img.shields.io/travis/JamieMason/shrinkpack/master.svg?style=flat-square)](https://travis-ci.org/JamieMason/shrinkpack) +[![Gitter Chat for shrinkpack](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/JamieMason/shrinkpack) +[![Donate via PayPal](https://img.shields.io/badge/donate-paypal-blue.svg)](https://www.paypal.me/foldleft) +[![Donate via Gratipay](https://img.shields.io/gratipay/user/JamieMason.svg)](https://gratipay.com/~JamieMason/) [![Analytics](https://ga-beacon.appspot.com/UA-45466560-5/shrinkpack?flat&useReferer)](https://github.com/igrigorik/ga-beacon) +[![Follow JamieMason on GitHub](https://img.shields.io/github/followers/JamieMason.svg?style=social&label=Follow)](https://github.com/JamieMason) +[![Follow fold_left on Twitter](https://img.shields.io/twitter/follow/fold_left.svg?style=social&label=Follow)](https://twitter.com/fold_left) Shrinkpack complements the [npm shrinkwrap](https://docs.npmjs.com/cli/shrinkwrap) command by maintaining a `node_shrinkwrap` directory in your project, containing the exact same tarballs that From 74a3a751cfa399adee54cfd228814699ce450061 Mon Sep 17 00:00:00 2001 From: Jamie Mason Date: Sun, 4 Aug 2019 18:19:02 +0100 Subject: [PATCH 2/4] chore(readme): move sponsorship info --- .github/FUNDING.yml | 2 + .github/ISSUE_TEMPLATE/bug_report.md | 26 ++ .github/ISSUE_TEMPLATE/feature_request.md | 27 ++ .github/PULL_REQUEST_TEMPLATE.md | 23 ++ README.md | 315 +++++++++++----------- 5 files changed, 243 insertions(+), 150 deletions(-) create mode 100644 .github/FUNDING.yml create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..d861f83 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +open_collective: fold_left +custom: ['https://www.paypal.me/foldleft'] diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..d264b47 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,26 @@ +--- +name: Bug Report +about: Explain how to reproduce a Bug +--- + +## Description + + + +## Suggested Solution + + + +## Help Needed + + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..3338d1d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,27 @@ +--- +name: Feature request +about: Suggest an idea for this project +--- + +## Description + + + +## Suggested Solution + + + +## Help Needed + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..cfa67fb --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,23 @@ +## Description (What) + + + +## Justification (Why) + + + +## How Can This Be Tested? + + diff --git a/README.md b/README.md index 75fb2d6..de4be9e 100644 --- a/README.md +++ b/README.md @@ -1,63 +1,41 @@ # shrinkpack +> Fast, resilient, reproducible builds with npm install. + [![NPM version](http://img.shields.io/npm/v/shrinkpack.svg?style=flat-square)](https://www.npmjs.com/package/shrinkpack) [![NPM downloads](http://img.shields.io/npm/dm/shrinkpack.svg?style=flat-square)](https://www.npmjs.com/package/shrinkpack) [![Dependency Status](http://img.shields.io/david/JamieMason/shrinkpack.svg?style=flat-square)](https://david-dm.org/JamieMason/shrinkpack) [![Build Status](http://img.shields.io/travis/JamieMason/shrinkpack/master.svg?style=flat-square)](https://travis-ci.org/JamieMason/shrinkpack) -[![Gitter Chat for shrinkpack](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/JamieMason/shrinkpack) -[![Donate via PayPal](https://img.shields.io/badge/donate-paypal-blue.svg)](https://www.paypal.me/foldleft) -[![Donate via Gratipay](https://img.shields.io/gratipay/user/JamieMason.svg)](https://gratipay.com/~JamieMason/) -[![Analytics](https://ga-beacon.appspot.com/UA-45466560-5/shrinkpack?flat&useReferer)](https://github.com/igrigorik/ga-beacon) [![Follow JamieMason on GitHub](https://img.shields.io/github/followers/JamieMason.svg?style=social&label=Follow)](https://github.com/JamieMason) [![Follow fold_left on Twitter](https://img.shields.io/twitter/follow/fold_left.svg?style=social&label=Follow)](https://twitter.com/fold_left) -Shrinkpack complements the [npm shrinkwrap](https://docs.npmjs.com/cli/shrinkwrap) command by -maintaining a `node_shrinkwrap` directory in your project, containing the exact same tarballs that -`npm install` downloads from [https://registry.npmjs.org](https://registry.npmjs.org). - -The rest of the `npm install` process is exactly the same. The only difference is that no network -activity is necessary when installing and building your project. The `node_shrinkwrap` directory can -be ignored in your editor (much like is done with the `node_modules` directory) but is instead -checked into source control. - -> For context, please see the [target problem](#target-problem) and [justification](#justification) -> sections of this README. - -## Contents - -* [Installation](#installation) -* [Usage](#usage) - * [Command Line](#command-line) - * [Node.js](#nodejs) -* [Target Problem](#target-problem) -* [Justification](#justification) - * [npm shrinkwrap](#npm-shrinkwrap) - * [shrinkpack](#shrinkpack-1) -* [Suitability to your project](#suitability-to-your-project) -* [Tutorial](#tutorial) - * [Create a new project](#create-a-new-project) - * [Set some sensible npm defaults](#set-some-sensible-npm-defaults) - * [Install dependencies](#install-dependencies) - * [Shrinkwrap dependencies](#shrinkwrap-dependencies) - * [Create a project-specific cache (optional)](#create-a-project-specific-cache-optional) - * [Shrinkpack dependencies](#shrinkpack-dependencies) - * [Check into Git](#check-into-git) - * [Clean install](#clean-install) - * [Update Dependencies](#update-dependencies) - * [Toggle Compression](#toggle-compression) - * [Remove Optional Dependencies](#remove-optional-dependencies) - -## Installation +Shrinkpack complements the +[npm shrinkwrap](https://docs.npmjs.com/cli/shrinkwrap) command by maintaining a +`node_shrinkwrap` directory in your project, containing the exact same tarballs +that `npm install` downloads from +[https://registry.npmjs.org](https://registry.npmjs.org). + +The rest of the `npm install` process is exactly the same. The only difference +is that no network activity is necessary when installing and building your +project. The `node_shrinkwrap` directory can be ignored in your editor (much +like is done with the `node_modules` directory) but is instead checked into +source control. + +> For context, please see the [target problem](#target-problem) and +> [justification](#justification) sections of this README. + +## 🌩 Installation ``` npm install --global shrinkpack ``` -> **Note:** npm had a [regression affecting shrinkwrap](https://github.com/npm/npm/pull/13214) in -> versions 3.8.8 to 3.10.3.
-> Please ensure your version of `npm` is 3.10.4 or newer, or 3.8.7 or older. +> **Note:** npm had a +> [regression affecting shrinkwrap](https://github.com/npm/npm/pull/13214) in +> versions 3.8.8 to 3.10.3.
Please ensure your version of `npm` is 3.10.4 or +> newer, or 3.8.7 or older. -## Usage +## 🕹 Usage ### Command Line @@ -94,79 +72,94 @@ Compression: Shrinkpack works in 2 phases; -1. Analyse the project and gather all the diffing information between the file system and the shrinkwrap. -2. Use the diffing information to bring the file system in sync with the shrinkwrap. +1. Analyse the project and gather all the diffing information between the file + system and the shrinkwrap. +2. Use the diffing information to bring the file system in sync with the + shrinkwrap. ```js -var shrinkpack = require('shrinkpack'); +var shrinkpack = require("shrinkpack"); -shrinkpack.analyse({ compress: false, directory: process.cwd(), keepOptional: false }) +shrinkpack + .analyse({ compress: false, directory: process.cwd(), keepOptional: false }) .then(data => shrinkpack.update(data)); ``` -Or to run `shrinkpack` in full, including all the additional logging that you see when using the CLI. +Or to run `shrinkpack` in full, including all the additional logging that you +see when using the CLI. ```js -var shrinkpack = require('shrinkpack'); +var shrinkpack = require("shrinkpack"); -shrinkpack.cli({ compress: false, directory: process.cwd(), keepOptional: false }) +shrinkpack + .cli({ compress: false, directory: process.cwd(), keepOptional: false }) .then(() => {}); ``` -## Target Problem +## 🤔 Target Problem -On most projects I've worked on we've had a [Jenkins](http://jenkins-ci.org/) (or similiar) -continuous integration environment, where we would run tests, analyse code, gather metrics, and -create deployment packages. +On most projects I've worked on we've had a [Jenkins](http://jenkins-ci.org/) +(or similiar) continuous integration environment, where we would run tests, +analyse code, gather metrics, and create deployment packages. -Each time code was pushed to our `develop` and `master` branches, a repeatable process was carried -out where a clean workspace was created, the latest version of the project was installed and -configured, then testing and code analysis took place. +Each time code was pushed to our `develop` and `master` branches, a repeatable +process was carried out where a clean workspace was created, the latest version +of the project was installed and configured, then testing and code analysis took +place. -We were all very happy with this process and the convenience of npm in particular, but the phase of -our builds where `npm install` listed a huge amount of network traffic would always raise the same -concerns; +We were all very happy with this process and the convenience of npm in +particular, but the phase of our builds where `npm install` listed a huge amount +of network traffic would always raise the same concerns; -+ This seems slow, wasteful, and inefficient. -+ We _really_ depend on registry.npmjs.org, what do we do if it goes down? +- This seems slow, wasteful, and inefficient. +- We _really_ depend on registry.npmjs.org, what do we do if it goes down? -The first suggestion was always to check in our dependencies, but the idea of some large and chatty -commits whenever we chose to upgrade or change them would put us off. +The first suggestion was always to check in our dependencies, but the idea of +some large and chatty commits whenever we chose to upgrade or change them would +put us off. -Some teams went a little further and decided that pain was acceptable and decided to proceed, only -to find that some packages such as [phantomjs](https://www.npmjs.com/package/phantomjs) and -[node-sass](https://github.com/sass/node-sass) helpfully install the appropriate binary for you -depending on what system you're running. +Some teams went a little further and decided that pain was acceptable and +decided to proceed, only to find that some packages such as +[phantomjs](https://www.npmjs.com/package/phantomjs) and +[node-sass](https://github.com/sass/node-sass) helpfully install the appropriate +binary for you depending on what system you're running. -This meant that if Chris added `phantomjs` or `node-sass` to the project on his Mac and checked it -into the repository, Helen wouldn't be able to use it on her Windows Machine. +This meant that if Chris added `phantomjs` or `node-sass` to the project on his +Mac and checked it into the repository, Helen wouldn't be able to use it on her +Windows Machine. -The remaining alternatives were proxies, mirrors, and caches-of-sorts. None of which appealed to us -and, grudgingly, we continued as we were (YMMV). +The remaining alternatives were proxies, mirrors, and caches-of-sorts. None of +which appealed to us and, grudgingly, we continued as we were +(YMMV). -## Justification +## 🤷🏽‍♀️ Justification -Whenever we add, remove, or update an npm dependency — we should test our application for -regressions before locking down our dependencies to avoid them mutating over time. +Whenever we add, remove, or update an npm dependency — we should test our +application for regressions before locking down our dependencies to avoid them +mutating over time. -+ You can't be sure of this without `npm shrinkwrap`. -+ Checking in `node_modules` is horrible (and doesn't work in many cases anyway). -+ You can be reasonably sure of this with `npm shrinkwrap`. -+ You can be completely sure of this with `npm shrinkwrap` and `shrinkpack`. +- You can't be sure of this without `npm shrinkwrap`. +- Checking in `node_modules` is horrible (and doesn't work in many cases + anyway). +- You can be reasonably sure of this with `npm shrinkwrap`. +- You can be completely sure of this with `npm shrinkwrap` and `shrinkpack`. ### npm shrinkwrap -`npm shrinkwrap` is something I would recommend you use anyway, even if you don't decide to use -`shrinkpack`. It brings certainty and confidence over exactly what versions of every nested -dependency you've tested against and approved. +`npm shrinkwrap` is something I would recommend you use anyway, even if you +don't decide to use `shrinkpack`. It brings certainty and confidence over +exactly what versions of every nested dependency you've tested against and +approved. -A tagged release should be a locked-down, fixed point in time which has been tested sufficiently -enough that it is approved and trusted. When fed into a repeatable, automated deployment process it -should always result in the same output. +A tagged release should be a locked-down, fixed point in time which has been +tested sufficiently enough that it is approved and trusted. When fed into a +repeatable, automated deployment process it should always result in the same +output. Without `npm shrinkwrap` that's not guaranteed. -Consider this snippet from the `package.json` of a nested dependency in your project as an example; +Consider this snippet from the `package.json` of a nested dependency in your +project as an example; ```json "dependencies": { @@ -174,43 +167,46 @@ Consider this snippet from the `package.json` of a nested dependency in your pro } ``` -If `lolwut@0.2.4` contains a regression and you're not using `npm shrinkwrap`, your project now -contains a regression. +If `lolwut@0.2.4` contains a regression and you're not using `npm shrinkwrap`, +your project now contains a regression. ### shrinkpack -With you hopefully convinced of the merits of `npm shrinkwrap`, `shrinkpack` will hopefully be seen -as a small and complementary addition. +With you hopefully convinced of the merits of `npm shrinkwrap`, `shrinkpack` +will hopefully be seen as a small and complementary addition. -`shrinkpack` takes the .tgz tarballs of that specific, shrinkwrapped dependency graph saved by `npm -shrinkwrap` and stores them within your project. +`shrinkpack` takes the .tgz tarballs of that specific, shrinkwrapped dependency +graph saved by `npm shrinkwrap` and stores them within your project. This means; -+ No need for repeated requests to registry.npmjs.org. -+ Each package/version pair can be checked in as a single tarball, avoiding commits with all kinds - of noisy diffs. -+ Packages can be checked in, while still installed by members of the team on different operating - systems. -+ Complements the typical `npm shrinkwrap` workflow. +- No need for repeated requests to registry.npmjs.org. +- Each package/version pair can be checked in as a single tarball, avoiding + commits with all kinds of noisy diffs. +- Packages can be checked in, while still installed by members of the team on + different operating systems. +- Complements the typical `npm shrinkwrap` workflow. -## Suitability to your project +## 🎯 Suitability to your project -`shrinkpack` is intended for Developers of Apps, Blogs, and Websites – any project which is the root -consumer of dependencies and not a dependency itself. If your project is intended to be installed as -a dependency of another project using `npm install`, let those downstream projects make their own -decisions on bundling. +`shrinkpack` is intended for Developers of Apps, Blogs, and Websites – any +project which is the root consumer of dependencies and not a dependency itself. +If your project is intended to be installed as a dependency of another project +using `npm install`, let those downstream projects make their own decisions on +bundling. -That said, if you're developing an npm package and want to use `shrinkpack` to speed up and -harden your development and CI environments, adding `npm-shrinkwrap.json` and `node_shrinkwrap` to -your `.npmignore` file will allow you to do that, without publishing your shrinkpacked dependencies -to the registry. +That said, if you're developing an npm package and want to use `shrinkpack` to +speed up and harden your development and CI environments, adding +`npm-shrinkwrap.json` and `node_shrinkwrap` to your `.npmignore` file will allow +you to do that, without publishing your shrinkpacked dependencies to the +registry. -It's not recommended to publish a project with bundled or shrinkpacked dependencies to the registry. -If that approach were to gain traction, it is likely that the registry would become bloated due to -the build up of duplicate copies of packages, bundled amongst various other ones. +It's not recommended to publish a project with bundled or shrinkpacked +dependencies to the registry. If that approach were to gain traction, it is +likely that the registry would become bloated due to the build up of duplicate +copies of packages, bundled amongst various other ones. -## Tutorial +## ❓ Tutorial ### Create a new project @@ -229,13 +225,14 @@ npm init --yes ### Set some sensible npm defaults -The default behaviour when installing in npm is to 1) not update package.json and 2) include -wildcards such as `^`, `~`, or `*` in the version numbers stored in package.json if using the -`--save` option when installing. +The default behaviour when installing in npm is to 1) not update package.json +and 2) include wildcards such as `^`, `~`, or `*` in the version numbers stored +in package.json if using the `--save` option when installing. -We want each version of our project to be identical every time it is built, so we can have complete -confidence when the time comes to ship it. Therefore, we want a package.json which is always up to -date and that contains the exact version numbers we have developed and tested against. +We want each version of our project to be identical every time it is built, so +we can have complete confidence when the time comes to ship it. Therefore, we +want a package.json which is always up to date and that contains the exact +version numbers we have developed and tested against. ``` echo save=true >> .npmrc @@ -244,8 +241,9 @@ echo save-exact=true >> .npmrc ### Install dependencies -For the sake of an example, let's install the following packages. I've chosen an older version of -commander so that we can go through how to update a shrinkpacked project later. +For the sake of an example, let's install the following packages. I've chosen an +older version of commander so that we can go through how to update a +shrinkpacked project later. ``` npm install async commander@2.7.1 express lodash request @@ -253,8 +251,8 @@ npm install async commander@2.7.1 express lodash request asciicast -This is typical behaviour, npm downloads the packages from the registry and installs them, leaving -the following directory structure; +This is typical behaviour, npm downloads the packages from the registry and +installs them, leaving the following directory structure; ``` ├── .gitignore @@ -276,12 +274,13 @@ npm shrinkwrap --dev ### Create a project-specific cache (optional) -When using `shrinkpack`, the local file path to dependencies will be added to the `npm` client's -[local cache](https://docs.npmjs.com/cli/cache). This can be problematic when working on several -projects on a single machine ([#31](https://github.com/JamieMason/shrinkpack/issues/31)). +When using `shrinkpack`, the local file path to dependencies will be added to +the `npm` client's [local cache](https://docs.npmjs.com/cli/cache). This can be +problematic when working on several projects on a single machine +([#31](https://github.com/JamieMason/shrinkpack/issues/31)). -This step prevents npm from using this project as a registry should you install the same -package/version pair on another project on your machine. +This step prevents npm from using this project as a registry should you install +the same package/version pair on another project on your machine. ``` echo cache=node_cache >> .npmrc @@ -290,10 +289,11 @@ echo /node_cache >> .gitignore ### Shrinkpack dependencies -Whenever you run `npm install`, npm downloads a .tgz file from http://registry.npmjs.org containing -the installation for each package. Shrinkpack saves these files in a `node_shrinkwrap` directory in -your project, before updating each record in `npm-shrinkwrap.json` to point at those instead of the -public registry. +Whenever you run `npm install`, npm downloads a .tgz file from +http://registry.npmjs.org containing the installation for each package. +Shrinkpack saves these files in a `node_shrinkwrap` directory in your project, +before updating each record in `npm-shrinkwrap.json` to point at those instead +of the public registry. ``` shrinkpack . @@ -334,7 +334,8 @@ git commit -m 'chore(project): initial commit' ### Clean install -We check this code into Git and tell a co-worker that it's ready for them to contribute to. +We check this code into Git and tell a co-worker that it's ready for them to +contribute to. Once they have cloned the project, our co-worker runs; @@ -342,12 +343,14 @@ Once they have cloned the project, our co-worker runs; npm install --loglevel http ``` -This is new behaviour, npm didn't hit the network at all. Instead it read the packages from the -`node_shrinkwrap` directory directly and installed them straight away. Shrinkpack has allowed us to -install our project without any network activity whatsoever – and in a fraction of the time. +This is new behaviour, npm didn't hit the network at all. Instead it read the +packages from the `node_shrinkwrap` directory directly and installed them +straight away. Shrinkpack has allowed us to install our project without any +network activity whatsoever – and in a fraction of the time. -If everything went to plan, the only output will be these expected warnings because we didn't choose -to add a `description` or `repository` to our `package.json`. +If everything went to plan, the only output will be these expected warnings +because we didn't choose to add a `description` or `repository` to our +`package.json`. > ``` > npm WARN shrinkpack-demo@1.0.0 No description @@ -366,8 +369,9 @@ npm install react npm uninstall express ``` -With our local `node_modules` now up to date, we now need to update our `npm-shrinkwrap.json` file -and get our `node_shrinkwrap` directory back in sync with the new changes. +With our local `node_modules` now up to date, we now need to update our +`npm-shrinkwrap.json` file and get our `node_shrinkwrap` directory back in sync +with the new changes. ``` npm shrinkwrap --dev @@ -378,19 +382,30 @@ shrinkpack ### Toggle Compression -The tarballs in the npm registry are gzipped for optimal network performance, but storing binary -files in Git repositories is not optimal. Git is decentralized, so every developer has the full -change history on their computer. Changes in large binary files cause Git repositories to grow by -the size of the file in question every time the file is changed and committed, this growth directly -affects the amount of data end users need to retrieve when they need to clone the repository. +The tarballs in the npm registry are gzipped for optimal network performance, +but storing binary files in Git repositories is not optimal. Git is +decentralized, so every developer has the full change history on their computer. +Changes in large binary files cause Git repositories to grow by the size of the +file in question every time the file is changed and committed, this growth +directly affects the amount of data end users need to retrieve when they need to +clone the repository. -You can toggle between compressed and uncompressed tarballs with `shrinkpack --compress`. +You can toggle between compressed and uncompressed tarballs with +`shrinkpack --compress`. asciicast ### Remove Optional Dependencies -`optionalDependencies` are removed by default, to avoid issues when trying to `npm shrinkwrap` your -project on platforms where that optional dependency was not installed. More detail is available in -this [issue comment](https://github.com/JamieMason/shrinkpack/issues/17#issuecomment-202340196) and -this behaviour can be overriden by using `shrinkpack --keep-optional`. +`optionalDependencies` are removed by default, to avoid issues when trying to +`npm shrinkwrap` your project on platforms where that optional dependency was +not installed. More detail is available in this +[issue comment](https://github.com/JamieMason/shrinkpack/issues/17#issuecomment-202340196) +and this behaviour can be overriden by using `shrinkpack --keep-optional`. + +## 🙋🏾‍♀️ Getting Help + +- Get help with issues by creating a + [Bug Report](https://github.com/JamieMason/shrinkpack/issues/new?template=bug_report.md). +- Discuss ideas by opening a + [Feature Request](https://github.com/JamieMason/shrinkpack/issues/new?template=feature_request.md). From 0118a09749b7aa91117f9d875eb02ea953584e10 Mon Sep 17 00:00:00 2001 From: Jamie Mason Date: Tue, 28 Dec 2021 20:33:49 +0000 Subject: [PATCH 3/4] feat(shrinkpack): add support for npm >= 7 BREAKING CHANGE: - Removed `--compress` option. - Removed `--keep-optional`, optional dependencies are kept by default. - Dropped support for npm@6 and older. - Dropped support for git+ssh and git+https dependencies (but this may return in the future). - Rename node_shrinkwrap directory to node_shrinkpack. --- .editorconfig | 2 +- .eslintignore | 1 + .eslintrc.js | 20 + .github/workflows/ci.yaml | 38 + .gitignore | 4 +- .prettierignore | 1 + .prettierrc | 7 + .travis.yml | 21 - CONTRIBUTING.md | 111 - ISSUE_TEMPLATE.md | 38 - LICENSE | 25 +- README.md | 464 +- cli.js | 57 - index.js | 11 - package-lock.json | 6029 ++++++++++++++++++++ package.json | 90 +- src/@types/lockfile.ts | 47 + src/analyse/create-bundle-directory.js | 22 - src/analyse/dependency/bundle.js | 19 - src/analyse/dependency/cache.js | 19 - src/analyse/dependency/index.js | 102 - src/analyse/dependency/resolve.js | 24 - src/analyse/get-dependencies.js | 30 - src/analyse/get-graph.js | 19 - src/analyse/get-paths.js | 28 - src/analyse/get-stats.js | 41 - src/analyse/get-unused-dependencies.js | 22 - src/analyse/index.js | 94 - src/analyse/prune-optional-dependencies.js | 32 - src/analyse/read-bundle.js | 29 - src/analyse/read-npm-cache.js | 72 - src/bin.ts | 30 + src/cli/display-failure.js | 15 - src/cli/display-summary.js | 21 - src/cli/index.js | 22 - src/index.ts | 91 + src/lib/child-process.js | 11 - src/lib/copy-file.js | 55 - src/lib/delete-file.js | 19 - src/lib/for-each-nested-dependency.js | 38 - src/lib/from-network.ts | 73 + src/lib/fs.js | 21 - src/lib/get-lockfile.ts | 57 + src/lib/get-ssri-from-file.ts | 37 + src/lib/get-time-between.js | 26 - src/lib/get-time-between.ts | 27 + src/lib/log.ts | 28 + src/lib/rate-limit.js | 12 - src/update/add-used-dependencies.js | 14 - src/update/delete-unused-dependencies.js | 27 - src/update/index.js | 22 - src/update/rewrite-graph.js | 23 - test/e2e/test-package.json | 15 - test/e2e/test-util.js | 68 - test/e2e/test.js | 93 - test/integration.sh | 99 + tsconfig.json | 15 + 57 files changed, 6784 insertions(+), 1694 deletions(-) create mode 100644 .eslintignore create mode 100644 .eslintrc.js create mode 100644 .github/workflows/ci.yaml create mode 100644 .prettierignore create mode 100644 .prettierrc delete mode 100644 .travis.yml delete mode 100644 CONTRIBUTING.md delete mode 100644 ISSUE_TEMPLATE.md delete mode 100755 cli.js delete mode 100755 index.js create mode 100644 package-lock.json create mode 100644 src/@types/lockfile.ts delete mode 100644 src/analyse/create-bundle-directory.js delete mode 100644 src/analyse/dependency/bundle.js delete mode 100644 src/analyse/dependency/cache.js delete mode 100644 src/analyse/dependency/index.js delete mode 100644 src/analyse/dependency/resolve.js delete mode 100644 src/analyse/get-dependencies.js delete mode 100644 src/analyse/get-graph.js delete mode 100644 src/analyse/get-paths.js delete mode 100644 src/analyse/get-stats.js delete mode 100644 src/analyse/get-unused-dependencies.js delete mode 100644 src/analyse/index.js delete mode 100644 src/analyse/prune-optional-dependencies.js delete mode 100644 src/analyse/read-bundle.js delete mode 100644 src/analyse/read-npm-cache.js create mode 100755 src/bin.ts delete mode 100644 src/cli/display-failure.js delete mode 100644 src/cli/display-summary.js delete mode 100644 src/cli/index.js create mode 100644 src/index.ts delete mode 100644 src/lib/child-process.js delete mode 100644 src/lib/copy-file.js delete mode 100644 src/lib/delete-file.js delete mode 100644 src/lib/for-each-nested-dependency.js create mode 100644 src/lib/from-network.ts delete mode 100644 src/lib/fs.js create mode 100644 src/lib/get-lockfile.ts create mode 100644 src/lib/get-ssri-from-file.ts delete mode 100644 src/lib/get-time-between.js create mode 100644 src/lib/get-time-between.ts create mode 100644 src/lib/log.ts delete mode 100644 src/lib/rate-limit.js delete mode 100644 src/update/add-used-dependencies.js delete mode 100644 src/update/delete-unused-dependencies.js delete mode 100644 src/update/index.js delete mode 100644 src/update/rewrite-graph.js delete mode 100644 test/e2e/test-package.json delete mode 100644 test/e2e/test-util.js delete mode 100644 test/e2e/test.js create mode 100755 test/integration.sh create mode 100644 tsconfig.json diff --git a/.editorconfig b/.editorconfig index 9129420..2c5b9be 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,6 +1,6 @@ root = true -[*.js] +[*.ts] charset = utf-8 indent_size = 2 indent_style = space diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..cd4efd8 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +*.d.ts diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..b17ba27 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,20 @@ +module.exports = { + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint', 'import'], + extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'], + parserOptions: { + ecmaVersion: 6, + sourceType: 'module', + }, + env: { + es6: true, + node: true, + }, + rules: { + '@typescript-eslint/no-var-requires': 0, + '@typescript-eslint/consistent-type-imports': [ + 2, + { prefer: 'type-imports' }, + ], + }, +}; diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..4488ce0 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,38 @@ +name: verify + +on: + push: + branches: [master] + pull_request_target: + +jobs: + all: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - uses: actions/setup-node@v2 + with: + node-version: 14.x + + - name: Install + run: npm install + + - name: Build + run: npm run build + env: + FORCE_COLOR: 3 + TERM: xterm-256color + + - name: Lint + run: npm run lint + env: + FORCE_COLOR: 3 + TERM: xterm-256color + + - name: Test + run: ./test/integration.sh + env: + FORCE_COLOR: 3 + TERM: xterm-256color diff --git a/.gitignore b/.gitignore index 790c0eb..803d7ba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ *.log *.log.* -control-app +dist +node_cache node_modules -shrinkpacked-app diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..de05607 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +**/*.md diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..f13c4e0 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "arrowParens": "always", + "printWidth": 80, + "proseWrap": "always", + "singleQuote": true, + "trailingComma": "all" +} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 1e23ad9..0000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -language: node_js -node_js: - - '6' - - '5' - - '4' -env: - - NPM_VERSION=4.1.1 - - NPM_VERSION=4.1.0 - - NPM_VERSION=4.0.5 - - NPM_VERSION=4.0.3 - - NPM_VERSION=4.0.2 - - NPM_VERSION=4.0.1 - - NPM_VERSION=4.0.0 - - NPM_VERSION=3.10.10 - - NPM_VERSION=3.10.9 - - NPM_VERSION=3.10.8 - - NPM_VERSION=3.10.7 - - NPM_VERSION=3.10.6 - - NPM_VERSION=3.10.5 -script: - - NPM_VERSION=$NPM_VERSION npm test diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 4136c83..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,111 +0,0 @@ -# Contributing - -## Installation - -1. Download `node` at [nodejs.org](http://nodejs.org) and install it, if you haven't already. -1. Clone the repo. - - ```sh - git clone https://github.com/JamieMason/shrinkpack.git - cd shrinkpack - ``` -1. Install dependencies. - - ```sh - npm install - ``` - -## Running Tests - -1. Download `docker` at [docker.com](https://docs.docker.com) and install it, if you haven't already. -1. Start a Terminal Session with `docker` running. -1. Build the tests - - ```sh - npm run build-tests - ``` -1. Run the tests - - ```sh - npm test - ``` - -## Writing Tests - -There is one set of functional tests at `.test/runtests.sh` which can be run on any combination of node and npm versions to check for issues and regressions. - -If an issue with a known npm package is found or a particular type of package configuration needs testing, add it to `./test/package.json` so it can be included as part of the functional test suite. - -## Configuring Tests - -1. To change the version of `node`, edit the first statement of the `./Dockerfile` from eg `FROM node:4.2.4` to eg `FROM node:6.2.2`. -1. To change the version of `npm`, set the `NPM_VERSION` variable in `scripts.test` in `./package.json`. -1. Build the tests. -1. Run the tests. - -## Coding Style - -This project uses [xo: Happiness JavaScript linter](https://github.com/sindresorhus/xo) and can be linted and formatted by running; - -```sh -npm run lint -``` - -## Commit Message Format - -There are very precise rules over how our git commit messages can be formatted. This leads to more readable messages that are easy to follow when looking through the project history, but also allows us to generate the CHANGELOG.md. - -Each commit message consists of a **header**, a **body** and a **footer**. The header has a special format that includes a **type**, a **scope** and a **subject**: - -``` -(): - - - -