-
Notifications
You must be signed in to change notification settings - Fork 3k
npm shrinkwrap
should be idempotent
#5779
Comments
If you're not already aware of it, Uber's |
I'm super aware of |
I'm closing this as this will be addressed by #6933. Further discussion should happen there. |
Reopening because this was not addressed by #6933 |
From a project without an existing node_modules or shrinkwrap:
The shrinkwrap file changes. |
Do check out the somewhat confusingly named https://www.npmjs.com/package/npm-shrinkwrap module in the interim. |
Also related to #7292. We're looking into dropping the |
The original version of the shrinkwrap algorithm saved only versions: commit d54ce3154dfe5283fcfeffc13d4e003bbade6370
Author: Dave Pacheco <dap@joyent.com>
Date: Tue Feb 21 15:32:16 2012 -0800
add "npm shrinkwrap"
diff --git a/lib/install.js b/lib/install.js
--- a/lib/install.js
+++ b/lib/install.js
@@ -138,1 +173,4 @@
- fn(args, where, family, ancestors, true, data, cb)
+ rv["dependencies"] = {}
+ for (key in wrap)
+ rv["dependencies"][key] = wrap[key]["version"]
+ log.verbose([rv["dependencies"]], "readDependencies: returned deps") A later version added support for commit 4bb884d2f8a30701c05ed81f7ace62be53147cae
Author: isaacs <i@izs.me>
Date: Tue Feb 28 17:25:18 2012 -0800
shrinkwrap: Behave properly with url-installed deps
diff --git a/lib/install.js b/lib/install.js
--- a/lib/install.js
+++ b/lib/install.js
@@ -186,2 +187,3 @@
- rv.dependencies[key] = wrap[key].version
+ var w = wrap[key]
+ rv.dependencies[key] = w.from || w.version
}) Later, to make shrinkwrap installs idempotent across machines, support for commit cfce70eae008e39f5ad00b4167fb5bd81857c377
Author: isaacs <i@izs.me>
Date: Mon Jan 14 21:43:51 2013 -0800
Use stashed git sha in shrinkwrap install
Fix #3056
diff --git a/lib/install.js b/lib/install.js
--- a/lib/install.js
+++ b/lib/install.js
@@ -210,3 +210,2 @@
- var w = wrap[key]
- rv.dependencies[key] = w.from || w.version
+ rv.dependencies[key] = readWrap(wrap[key])
}) where function readWrap (w) {
return (w.resolved) ? w.resolved
: (w.from && url.parse(w.from).protocol) ? w.from
: w.version
} When we get back to the long-delayed cache rewrite, we're going to add support for At some point there were versions of npm that depended on all of those fields, and there are various third-party tools like |
@othiym23 thanks for this context. Great background. Agreed that the best solution seems to be making I've pinged @Raynos to discuss how npm-shrinkwrap uses the I'd really like to encourage Ember-CLI users to use shrinkwrap. Along with quaertym/ember-cli-dependency-checker#26 it will provide a decent path to re-producable builds. This issue is the last major blocker for me getting there. |
The most important thing about the Just make sure you always set Also note that |
I'm taking this over to |
And fixed the rest of the way with a781cb7 in npm/npm#multi-stage |
Thanks @iarna! looking forward to when 3 drops. |
Ended up decoupling shrinkwrap from |
Reason: noisy diffs, potential nondeterminism.
Key order within the dependencies and other properties should have a stable ordering (i.e. be sorted). A useful implementation strategy would also involve centralizing all the calls to
JSON.stringify
so that we have a standard way of marshalling objects for external use.The text was updated successfully, but these errors were encountered: