1 | Ember CLI Dependency Checker
|
2 | [](https://github.com/quaertym/ember-cli-dependency-checker/actions/workflows/ci.yml)
|
3 | [](https://codeclimate.com/github/quaertym/ember-cli-dependency-checker)
|
4 | [](http://emberobserver.com/addons/ember-cli-dependency-checker)
|
5 | ============================
|
6 |
|
7 | An Ember CLI addon that checks for missing npm and bower dependencies before running ember commands.
|
8 |
|
9 | ### Installation
|
10 |
|
11 | ```bash
|
12 | ember install ember-cli-dependency-checker
|
13 | ```
|
14 |
|
15 | ### Usage
|
16 |
|
17 | Upon being included in a project (when running `ember build` for example), the dependency checker
|
18 | will 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 |
|
32 | When 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)
|
34 | library:
|
35 |
|
36 | ```
|
37 | npm install --save-dev torii
|
38 | npm shrinkwrap --dev
|
39 | git add package.json npm-shrinkwrap.json
|
40 | git commit -m "Install Torii"
|
41 | ```
|
42 |
|
43 | **If the npm-shrinkwrap.json file is not committed, nested dependencies cannot be confirmed**.
|
44 | Remembering to execute `npm shrinkwrap --dev` and commit `npm-shrinkwrap.json` is akin to committing
|
45 | the `Gemfile.lock` file when using Ruby's Bundler library.
|
46 |
|
47 | If `ember` is run and the contents of `node_modules/` differs from the contents of `package.json`
|
48 | and `npm-shrinkwrap.json` an error will be raised. To resolve a difference in dependencies,
|
49 | you must destroy the `node_modules/` directory and re-run `npm install`. With a blank
|
50 | directory, `npm install` will respect the versions pinned in `npm-shrinkwrap.json`.
|
51 |
|
52 | In some rare cases there may be un-resolvable conflicts between installable versions of
|
53 | dependencies and those pinned. Upgrading packages after deleting the `npm-shrinkwrap.json`
|
54 | file or changing the version of a dependency requested in `package.json` may be the only
|
55 | way to resolve theses cases.
|
56 |
|
57 | ### Deployment with Shrinkwrap
|
58 |
|
59 | Ember-CLI projects may be built on Travis or another dedicated build tool like Jenkins. To
|
60 | ensure that versions of dependencies (including of nested dependencies) are the same during
|
61 | builds as they are on the authoring developer's computer, it is recommended
|
62 | that you confirm dependencies before a build. Do this by running `ember version` to
|
63 | begin a dependency check, then if needed clearing the `node_modules/` and `bower_components/` folder
|
64 | and 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)
|
68 | ember build -e production
|
69 | ```
|
70 |
|
71 | ### Caveats
|
72 |
|
73 | Due to the limited information available in configuration files and packages, git
|
74 | dependencies may fall out of sync. Using shrinkwrap will confirm that they are correct
|
75 | upon installation, but they cannot be confirmed at runtime until improvements are
|
76 | made to the `npm-shrinkwrap.json` file.
|
77 |
|
78 | Pinning solely to versioned releases should be preferred.
|
79 |
|
80 | ### Tests
|
81 |
|
82 | To run tests:
|
83 |
|
84 | `pnpm test`
|
85 |
|
86 | ### LICENSE
|
87 |
|
88 | MIT
|