UNPKG

3.95 kBMarkdownView Raw
1Ember CLI Dependency Checker
2[![Build Status](https://github.com/quaertym/ember-cli-dependency-checker/workflows/CI/badge.svg)](https://github.com/quaertym/ember-cli-dependency-checker/actions/workflows/ci.yml)
3[![Code Climate](https://codeclimate.com/github/quaertym/ember-cli-dependency-checker/badges/gpa.svg)](https://codeclimate.com/github/quaertym/ember-cli-dependency-checker)
4[![Ember Observer Score](http://emberobserver.com/badges/ember-cli-dependency-checker.svg)](http://emberobserver.com/addons/ember-cli-dependency-checker)
5============================
6
7An Ember CLI addon that checks for missing npm and bower dependencies before running ember commands.
8
9### Installation
10
11```bash
12ember install ember-cli-dependency-checker
13```
14
15### Usage
16
17Upon being included in a project (when running `ember build` for example), the dependency checker
18will confirm versions according to several signals of intent:
19
20* `bower.json` will be compared to the contents of `bower_components` (or your Ember-CLI
21 configured bower directory)
22* `package.json` will be compared to the contents of `node_modules`. This check only
23 takes the top-level of dependencies into account. Nested dependencies are not confirmed.
24* `npm-shrinkwrap.json`, if present, will be compared to the contents of `node_modules`. This
25 is done only if a `package.json` check does not find any unsatisfied dependencies. Nested
26 dependencies are confirmed.
27
28### Shrinkwrap Workflow
29
30**This workflow presumes npm v2.7.6 - v3.0.0**, though it may work well for earlier versions.
31
32When installing dependencies, it is important that `npm shrinkwrap --dev` is run and the resulting
33`npm-shrinkwrap.json` file committed. For example, to install the [Torii](https://github.com/Vestorly/torii)
34library:
35
36```
37npm install --save-dev torii
38npm shrinkwrap --dev
39git add package.json npm-shrinkwrap.json
40git commit -m "Install Torii"
41```
42
43**If the npm-shrinkwrap.json file is not committed, nested dependencies cannot be confirmed**.
44Remembering to execute `npm shrinkwrap --dev` and commit `npm-shrinkwrap.json` is akin to committing
45the `Gemfile.lock` file when using Ruby's Bundler library.
46
47If `ember` is run and the contents of `node_modules/` differs from the contents of `package.json`
48and `npm-shrinkwrap.json` an error will be raised. To resolve a difference in dependencies,
49you must destroy the `node_modules/` directory and re-run `npm install`. With a blank
50directory, `npm install` will respect the versions pinned in `npm-shrinkwrap.json`.
51
52In some rare cases there may be un-resolvable conflicts between installable versions of
53dependencies and those pinned. Upgrading packages after deleting the `npm-shrinkwrap.json`
54file or changing the version of a dependency requested in `package.json` may be the only
55way to resolve theses cases.
56
57### Deployment with Shrinkwrap
58
59Ember-CLI projects may be built on Travis or another dedicated build tool like Jenkins. To
60ensure that versions of dependencies (including of nested dependencies) are the same during
61builds as they are on the authoring developer's computer, it is recommended
62that you confirm dependencies before a build. Do this by running `ember version` to
63begin a dependency check, then if needed clearing the `node_modules/` and `bower_components/` folder
64and installing dependencies. For example:
65
66```
67([ -f node_modules/ember-cli/bin/ember ] && node_modules/ember-cli/bin/ember version) || (rm -rf node_modules/ bower_components/ && npm install && bower install)
68ember build -e production
69```
70
71### Caveats
72
73Due to the limited information available in configuration files and packages, git
74dependencies may fall out of sync. Using shrinkwrap will confirm that they are correct
75upon installation, but they cannot be confirmed at runtime until improvements are
76made to the `npm-shrinkwrap.json` file.
77
78Pinning solely to versioned releases should be preferred.
79
80### Tests
81
82To run tests:
83
84`pnpm test`
85
86### LICENSE
87
88MIT