From 5b7b7ddadbf2d6c9c3af07378dae29c7673894bc Mon Sep 17 00:00:00 2001 From: Konstantin Raev Date: Sun, 3 Jul 2016 12:26:37 +0100 Subject: [PATCH 1/4] Added 2 more hoisting unit tests --- test/commands/install.js | 80 ++++++++++++++++++ .../.npmrc | 1 + .../fbkpm.lock | 30 +++++++ .../mirror-for-offline/dep-b-1.0.0.tgz | Bin 0 -> 896 bytes .../mirror-for-offline/dep-c-1.0.0.tgz | Bin 0 -> 896 bytes .../mirror-for-offline/dep-d-1.0.0.tgz | Bin 0 -> 887 bytes .../mirror-for-offline/dep-d-2.0.0.tgz | Bin 0 -> 858 bytes .../mirror-for-offline/dep-e-1.0.0.tgz | Bin 0 -> 854 bytes .../mirror-for-offline/dep-e-2.0.0.tgz | Bin 0 -> 863 bytes .../package.json | 8 ++ .../.npmrc | 1 + .../fbkpm.lock | 40 +++++++++ .../mirror-for-offline/dep-a-1.0.0.tgz | Bin 0 -> 890 bytes .../mirror-for-offline/dep-b-1.0.0.tgz | Bin 0 -> 896 bytes .../mirror-for-offline/dep-c-1.0.0.tgz | Bin 0 -> 896 bytes .../mirror-for-offline/dep-c-2.0.0.tgz | Bin 0 -> 863 bytes .../mirror-for-offline/dep-d-1.0.0.tgz | Bin 0 -> 887 bytes .../mirror-for-offline/dep-d-2.0.0.tgz | Bin 0 -> 858 bytes .../mirror-for-offline/dep-e-1.0.0.tgz | Bin 0 -> 854 bytes .../mirror-for-offline/dep-e-2.0.0.tgz | Bin 0 -> 863 bytes .../package.json | 9 ++ 21 files changed, 169 insertions(+) create mode 100644 test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/.npmrc create mode 100644 test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/fbkpm.lock create mode 100644 test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/mirror-for-offline/dep-b-1.0.0.tgz create mode 100644 test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/mirror-for-offline/dep-c-1.0.0.tgz create mode 100644 test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/mirror-for-offline/dep-d-1.0.0.tgz create mode 100644 test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/mirror-for-offline/dep-d-2.0.0.tgz create mode 100644 test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/mirror-for-offline/dep-e-1.0.0.tgz create mode 100644 test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/mirror-for-offline/dep-e-2.0.0.tgz create mode 100644 test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/package.json create mode 100644 test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/.npmrc create mode 100644 test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/fbkpm.lock create mode 100644 test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/mirror-for-offline/dep-a-1.0.0.tgz create mode 100644 test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/mirror-for-offline/dep-b-1.0.0.tgz create mode 100644 test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/mirror-for-offline/dep-c-1.0.0.tgz create mode 100644 test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/mirror-for-offline/dep-c-2.0.0.tgz create mode 100644 test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/mirror-for-offline/dep-d-1.0.0.tgz create mode 100644 test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/mirror-for-offline/dep-d-2.0.0.tgz create mode 100644 test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/mirror-for-offline/dep-e-1.0.0.tgz create mode 100644 test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/mirror-for-offline/dep-e-2.0.0.tgz create mode 100644 test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/package.json diff --git a/test/commands/install.js b/test/commands/install.js index 79d5707e48..e38dd7c61a 100755 --- a/test/commands/install.js +++ b/test/commands/install.js @@ -280,6 +280,86 @@ test("install should dedupe dependencies avoiding conflicts 5", () => { }); }); +test("install should dedupe dependencies avoiding conflicts 6 (jest/jest-runtime case)", () => { + // C@1 -> D@1 -> E@1 + // B@1 -> C@1 -> D@1 -> E@1 + // D@2 + // E@2 + + // should become + + // C@1 -> D@1 + // -> E@1 + // B@1 + // D@2 + // E@2 + + return run({}, [], "install-should-dedupe-avoiding-conflicts-6", async (config) => { + assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, + "node_modules/dep-b/package.json"))).version, "1.0.0"); + assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, + "node_modules/dep-c/package.json"))).version, "1.0.0"); + assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, + "node_modules/dep-d/package.json"))).version, "2.0.0"); + assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, + "node_modules/dep-e/package.json"))).version, "2.0.0"); + + assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, + "node_modules/dep-c/node_modules/dep-d/package.json"))).version, "1.0.0"); + assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, + "node_modules/dep-c/node_modules/dep-e/package.json"))).version, "1.0.0"); + }); +}); + +test("install should dedupe dependencies avoiding conflicts 7", () => { + // A@1 -> C@1 -> D@1 -> E@1 + // B@1 -> C@1 -> D@1 -> E@1 + // C@2 + // D@2 + // E@2 + + // should become + + // A@1 -> C@1 + // -> D@1 + // -> E@1 + // B@1 -> C@1 + // -> D@1 + // -> E@1 + // C@2 + // D@2 + // E@2 + + return run({}, [], "install-should-dedupe-avoiding-conflicts-7", async (config) => { + assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, + "node_modules/dep-a/package.json"))).version, "1.0.0"); + assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, + "node_modules/dep-b/package.json"))).version, "1.0.0"); + assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, + "node_modules/dep-c/package.json"))).version, "2.0.0"); + assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, + "node_modules/dep-d/package.json"))).version, "2.0.0"); + assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, + "node_modules/dep-e/package.json"))).version, "2.0.0"); + + assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, + "node_modules/dep-a/node_modules/dep-c/package.json"))).version, "1.0.0"); + assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, + "node_modules/dep-a/node_modules/dep-d/package.json"))).version, "1.0.0"); + assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, + "node_modules/dep-a/node_modules/dep-e/package.json"))).version, "1.0.0"); + + + assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, + "node_modules/dep-b/node_modules/dep-c/package.json"))).version, "1.0.0"); + assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, + "node_modules/dep-b/node_modules/dep-d/package.json"))).version, "1.0.0"); + assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, + "node_modules/dep-b/node_modules/dep-e/package.json"))).version, "1.0.0"); + + }); +}); + test("upgrade scenario", () => { // left-pad first installed 0.0.9 then updated to 1.1.0 // files in mirror, fbkpm.lock, package.json and node_modules should reflect that diff --git a/test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/.npmrc b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/.npmrc new file mode 100644 index 0000000000..d912bd785c --- /dev/null +++ b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/.npmrc @@ -0,0 +1 @@ +kpm-offline-mirror=./mirror-for-offline diff --git a/test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/fbkpm.lock b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/fbkpm.lock new file mode 100644 index 0000000000..72c72ffe65 --- /dev/null +++ b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/fbkpm.lock @@ -0,0 +1,30 @@ +dep-b@1.0.0: + name dep-b + version "1.0.0" + resolved dep-b-1.0.0.tgz#3ec41d539ec81cbb0b00f3f77cee143104153783 + dependencies: + dep-c "1.0.0" +dep-c@1.0.0: + name dep-c + version "1.0.0" + resolved dep-c-1.0.0.tgz#43df1196c1b62b89ed7169b6b93493d8420763b6 + dependencies: + dep-d "1.0.0" +dep-d@1.0.0: + name dep-d + version "1.0.0" + resolved dep-d-1.0.0.tgz#175ce924c6413b1feeb68b976ae769260cfe0d86 + dependencies: + dep-e "1.0.0" +dep-d@2.0.0: + name dep-d + version "2.0.0" + resolved dep-d-2.0.0.tgz#ada909b78f52d88a60e9c8583ddc0310ff16da40 +dep-e@1.0.0: + name dep-e + version "1.0.0" + resolved dep-e-1.0.0.tgz#8baa9f7eda12e71a95ccfce7e31ace5867617014 +dep-e@2.0.0: + name dep-e + version "2.0.0" + resolved dep-e-2.0.0.tgz#c326a657226d79e68a2208f62a3f3f9f657416a9 diff --git a/test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/mirror-for-offline/dep-b-1.0.0.tgz b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/mirror-for-offline/dep-b-1.0.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..73deff4159d8c1557f8fb8977ba12cb812af968b GIT binary patch literal 896 zcmV-`1AqJ}uNTkG#Xf=+kG(~11(Uhu^e!H2^1 zbDmE4NVHe~ZJ|}~T7)r;FXL5S~5%_Pf`QUiw3kmt#f{4OgZ!on`tRJL6d)P!O%` za-_5o-^)xCK4!kkr?urOAHw{REL)#ss}E(}oreOv@@nmhPX)789-N{m*?2k>MQUVT zO0C%Au}CK%&!8L&7|FR%Fz4A!fGmJ3cw`JeM?tWWV=heL;)#!a+%2?qn27Ut+6>)W z%c4mWUhPGgC_w`gq+(i zx$QtBx{fW+bHQBi5e?wg<0nsl_}MNqXC#W_m{N>L(wbE!)x>TM62nXm*fqEp`52H~jxVa9JA*P%a+ zg$1(#Z9wU=1L-%G(r@Z=9H%QZ`u5(L#DY)rOgwCE8#QI!J3hI8)G_z_@HLcXCbqb8 zGn!3>DvQmC`bW1JvbT4&ud{!XbHk@_F_jB3T)KZvWi_Il83h-oT4&3;Pg6adWx^MW zT${46?P~k{{ym({RO)_TaL*>VUk$!ZhC6p$PPls)_KtPc-};Yr0?|#a&tO`3q W%cC7RciL&EkI}uNTkG#Xf=+kG(~11(Uhu^e!Bb%d zIZq~hB-*R@w$Q3~Ey5UwK>)p9-Az3H-Cb|%KMrsuLIVsvLL)yUVHgHc50l{#6X-3j zXZgR@tSGs$CH~Vq^~=EO`acmlglEsc{qFUnmtHFJa?A*#!OC=|vrNBZXFMwe^23!~ zj+8dydzp#C!^~6pw6CzX%rK!?3f4RGJa&6HG#i2!+ar61(wmCsZesg2m`lpO4R7 zH%I-ow(lAK{Rhs}!Kr)lF+{Bc z8-}`|3RktY1)en@_ZxKfA3)#o(OoJC_D`CX*W9!2uE5%Qkgk(j__lw_6s7soBckKZjSnEb@_k0;s00b`7fg3W&YEsLg`Hub6H;C-otw>5QH@eggGhXYs4*h8? zESL>w14@@2NWZa^ep8p@I9;L9v-i#<7JQm#;$d^!s445-@yY$8j(ISEuc0(EvBi~} z(QGPIS!_nsKf2A3y}he_o&B4f8$N}Lsa%M3>Ham9)rfLt6kMEYoh|D=O?5iUgeMlc zHf3Sk)%N-QdpMh^#QnbDo=tGS8ho1!ckZ~HaQ80k9qX#U^;bFB1IAq6y@Y336?TM{ WM>}%vw9`%>p+5nbPYnA27ytlP_|_-@ literal 0 HcmV?d00001 diff --git a/test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/mirror-for-offline/dep-d-1.0.0.tgz b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/mirror-for-offline/dep-d-1.0.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..7aa4321402c352b165edfa66c6890eabe34fb474 GIT binary patch literal 887 zcmV--1Bm<|iwFP!000001MQaUZqzsw#|LRYAV0++A1G8bV<(v;rSfVKyDN~EivS6& zs!F(tJ7XqeM^0v#Qbyv%_9=KF>|AC-r(G4%a-IJd%O~d?J16!p=P8>%;4J03pR;7l zhP)l!*M*Y3OA*F63uPyYPt#l2^4%JXtW3G#xa=}2XndP9#`R&eBpOS>3KrTO0? z+W zEst|fZS9fg!}I$O9{%&MS!PB_7)6oiVMOBAEHfd;=4g-zrXr=gLFmV^7f04*XbdEd zLPBs9#og0$n2ihZmeT<5hMhHpRFq(!U=jz2cu@Ix#2h@_3029spfUQ^_v2^R)lq+? zv-p2)$$#vdqj8G={=nM4n8_E>FV25-f&d&#R_87_6xZ4fZ)*Ze|YK)7@yCI)_V&LbX#ReIlqo-^A zpD?wb8xCCF8r}PkoBQAE^nd0LYVN;}{lNGUd;f!o;7$McHMHsfe!l*1@M-_oUg+#uUK1(e#ly9vv(Dr^re_BQ0)XrqlT NppQIPFXR9i008k*(O&=n literal 0 HcmV?d00001 diff --git a/test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/mirror-for-offline/dep-d-2.0.0.tgz b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/mirror-for-offline/dep-d-2.0.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..2135e2fd15c13419daa130ddff69d65c3a6e21b5 GIT binary patch literal 858 zcmV-g1Eu^QiwFP!000001MQaIZre5##xr17e2P#af^k zf&gVC#%3*(0wudnQv-XkJ;h#Vr2g1y?Q8{_b_=HOhTze6DC$W3={)DFCxWNK40E2$ z_(Zg$_omS5;97(+4ub#=es`02`bRbDKkws8goO4Qp^+bwFbYTE0Vbm$ir`>%J-7dR zEsByGyT#94r+ygNj5kDN48J`4;m4N`fAvz4ms3U%4K|^3on`thJLg#;kRNX1a-y^m zk7Xtb4>M2Y^Ez^shcIs<%hnU`^-$LR@{o@=t~RdtTrj)K`zZ?JovW!R5+n0cYQ-K+ zMKS|<4&_w9L@tGbCC?TDWC2{kLu2>_^8KAPmckS+pL*EC-Ho<}nYehXP3oRn7R@rj z)h@zBG3pj&$3YpdS0Ou|OeR7Vg8lsTC8A@)8QVgn?OLPBs9#oaIBESnYbonQeT zhn;&!r5VA#wG)a6g~~(57*X6w)yb@2G5WW^`CeOnIqGkXB6e$0P=)yyd{m=Q2E)l@Mk#+C@1{GWf_gtuhQ+MT4h*~E$40TBrM(bz`JR3e4H0T`MgMsCv z8!8A6PMbUDLZw0_QaHQY;JUid0MV^%nK(e}o+O{G=R5tMw6$MZ4qV?o{;~hV?)>}M z53G;4^B;sX?EAm3p}zmS8U5er!~U;5r2nbjFC6=u-YZ_@+U^bu)C|!0S{n}Fcb-f+O=?aaWox6}&@p+z!2hFrmv#mQP zr+1G#;o%UzgVHR-9xFGK#ayVe*v+Vabh{~shgW-D{QI06K8MS>T#0n;{xwz9h;m^R zT%Kv2t?N3?b-KueCsw&OWns(J*7^N=IA5s5{l4IiUEprj_%AH0Iwgn4gdfE literal 0 HcmV?d00001 diff --git a/test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/mirror-for-offline/dep-e-1.0.0.tgz b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/mirror-for-offline/dep-e-1.0.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..ca6c2e109a257605468f67c9d0ff72a887e9ad8e GIT binary patch literal 854 zcmV-c1F8HUiwFP!000001MQaGZre5#$J1M0?Ga9O(X>G;lawsU4LGdmHnhOj7HffG z2m+Lm8Jo3C3Y6?ROAYMB_7r=elKQZ<+Sv*;?G{Y`8-j=D98yQ(Pv-?+JrR5?%pm9K zj88;6`fm%Z4z5KQ<0uT_;CDAkrhinU{__E@L`Y=U2#te?L{W^%0VcyR8p6Tqdba<2 zEsByGd&JMpQ$GxB#v39sf@jaa|KZi6U;MGi%PAv>h8xql&NBUuo%5^^D2O(8IZ@h( zA7v&AA2VO&^V)Ki4`Kd9maR{+*N3w1mxltp@oMdg&jqumd>~Mi?5vJOks6toQY-d& zD$*Iqb10_*CUPkhEP1vNAPe9M9vQ3`0Dbcp~wM^^74cokf|`_9zCsayFJqSk>8LtRjX(c0Pq&zeuX2A$r0@GKwQ zP(jc;ZFbIu8Vi+5;oRK;*VRG;M3>nz(L?K=B%iGpJN=)uwO?5dT;Cr5*#BX7{{tL^ z){jK?{)Z8b`u^{0sPF%7M*lbbYya0?(*IQNM>@S<827#3P0*L4{#N_=|IN1li)r*R z|7ncFzW@6gLW83t1V_-)42}i}ExBn8z-n6h&HNa(5v6`v8mT7RkfJo!{rTBjk(PdL zbg3PZ{MKAmBQ zc`$%)p)?Dz$CaDOVlGr!>_*f-y4{e&!>fIr{kxnSK8MS>T#518{c9?#5#_=txIEK3 zTi11(>+vEJzF6hjl!YxR literal 0 HcmV?d00001 diff --git a/test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/mirror-for-offline/dep-e-2.0.0.tgz b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/mirror-for-offline/dep-e-2.0.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..853b66c35bc29bac901fb1ce51016cf8a8ce0ff9 GIT binary patch literal 863 zcmV-l1EBmLiwFP!000001MQaIZre5##xr0S1D}G`MbieYOj3#@H{j5sThRjBTC4?z zAqY@LKCxNLq(I58)6~FTY)`Ql8mT|F7CT#kCfkDQyCHb=9f~>$(k@;QhRm_aVm zsTe~$`tJ&@_O3;QkSGlC-fwP_On$FM{l`O6iPFekqbv?08pSaqdxRc_QH=MN*K_;7 z*Ssi&v0MDyb?S$~>+zO|4)ISfzx)2plb`(&*U zAe~})hRX@yv0Q+{3z5wM%K{69pBN*~Q4nmcu>e!JeC89MbT`@>rf~jVn~{5JSv1Rp zSGy>O;;>tkEeGSGUWIOXGMR!ZfdBa74Prx_3;T9<9a6+Lx#f8d+|?7Y0Kb0v{KXHy z+QKZjJ6SPf1kt1ot4yk?ecd$1b2;L}Fba}{C9$)NZGa|mL@9~mr29pjX467`03MQI z)VYULno|;3doV6{{aa? z>!Xo9|6#?{^z?bJX9c%l~g0{(rsc z|6&$h=0A%ol-|T1LJMKq0OmC<{bqiI+Kf`aE{#;%EFebt@Fo^_-w9H_xr;4>;m_z#DvXD(wiZj(W=W>ecHL^e1=1u^s>z0071Uz?%R7 literal 0 HcmV?d00001 diff --git a/test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/package.json b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/package.json new file mode 100644 index 0000000000..66bedd2b7d --- /dev/null +++ b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-6/package.json @@ -0,0 +1,8 @@ +{ + "dependencies": { + "dep-b": "1.0.0", + "dep-c": "1.0.0", + "dep-d": "2.0.0", + "dep-e": "2.0.0" + } +} diff --git a/test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/.npmrc b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/.npmrc new file mode 100644 index 0000000000..d912bd785c --- /dev/null +++ b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/.npmrc @@ -0,0 +1 @@ +kpm-offline-mirror=./mirror-for-offline diff --git a/test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/fbkpm.lock b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/fbkpm.lock new file mode 100644 index 0000000000..66aa3cc232 --- /dev/null +++ b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/fbkpm.lock @@ -0,0 +1,40 @@ +dep-a@1.0.0: + name dep-a + version "1.0.0" + resolved dep-a-1.0.0.tgz#e7f20878f3696af17ef69934c320885ffab98651 + dependencies: + dep-c "1.0.0" +dep-b@1.0.0: + name dep-b + version "1.0.0" + resolved dep-b-1.0.0.tgz#3ec41d539ec81cbb0b00f3f77cee143104153783 + dependencies: + dep-c "1.0.0" +dep-c@1.0.0: + name dep-c + version "1.0.0" + resolved dep-c-1.0.0.tgz#43df1196c1b62b89ed7169b6b93493d8420763b6 + dependencies: + dep-d "1.0.0" +dep-c@2.0.0: + name dep-c + version "2.0.0" + resolved dep-c-2.0.0.tgz#be95e9930b466ac728ba44f63b9888aa5c7a78b8 +dep-d@1.0.0: + name dep-d + version "1.0.0" + resolved dep-d-1.0.0.tgz#175ce924c6413b1feeb68b976ae769260cfe0d86 + dependencies: + dep-e "1.0.0" +dep-d@2.0.0: + name dep-d + version "2.0.0" + resolved dep-d-2.0.0.tgz#ada909b78f52d88a60e9c8583ddc0310ff16da40 +dep-e@1.0.0: + name dep-e + version "1.0.0" + resolved dep-e-1.0.0.tgz#8baa9f7eda12e71a95ccfce7e31ace5867617014 +dep-e@2.0.0: + name dep-e + version "2.0.0" + resolved dep-e-2.0.0.tgz#c326a657226d79e68a2208f62a3f3f9f657416a9 diff --git a/test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/mirror-for-offline/dep-a-1.0.0.tgz b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/mirror-for-offline/dep-a-1.0.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..a951a39f3c8c75907fa3fc049f0694d5fc7dabd4 GIT binary patch literal 890 zcmV-=1BLt_iwFP!000001MQaoZre5x$338b419{K{%G2ukx5CGlm;vsbSqk5TZ%Qn zPy_+W$c)WeCIw1%ou&r%Vtb0c&`ABTwKyqKG-I?ge^h_(;L?Z}VCWGq@>gn?rzq~fn%qa<@$Q(qBNZhz(D&)j$4HCgj4C!tV`f=>Vk(G>$ zgTzrt2#%t-y?aj5NiN=V8sOcqHHVOj66_Na;sGKalp2qijfY#IDw*UoMqm4UeD8L9 z)L+|W{QqIaf9#vBae@E-!0e0OXEXUa_CM!8I!6GGC9CrYoD#0iL+fhc)V{e6QLDh3 zp*E<*Rpo7fXWU0ljZWtwIEIgQC?V(^*E6rVXXJK)m3JpuCpFGxsjkUq-x&BgXxSm- zQ|#qN|0hiC7ls2jH%I&YkL&Y)r`7+N8`PYCANzsPk3S}|lHo|r2A7gI7tU+mz zs%Sy_jiL0LYB`qEB^q7xY+Zc8rdi4#)sMB+%esGb{9v!;?)Tv_6ne%lkup7+O}Q-c z&4}uv+YH&-x>{@fPco+26waq&!G}wG*OXq(iiexg*mtm-sX!&%B*zQ~j=a#OCR z&L2L&=}ac}`hxo=!Gp5#tux%cYjeWAd$4t+%KBD+<#-DywRLwBmZoLc9$M~o}uNTkG#Xf=+kG(~11(Uhu^e!H2^1 zbDmE4NVHe~ZJ|}~T7)r;FXL5S~5%_Pf`QUiw3kmt#f{4OgZ!on`tRJL6d)P!O%` za-_5o-^)xCK4!kkr?urOAHw{REL)#ss}E(}oreOv@@nmhPX)789-N{m*?2k>MQUVT zO0C%Au}CK%&!8L&7|FR%Fz4A!fGmJ3cw`JeM?tWWV=heL;)#!a+%2?qn27Ut+6>)W z%c4mWUhPGgC_w`gq+(i zx$QtBx{fW+bHQBi5e?wg<0nsl_}MNqXC#W_m{N>L(wbE!)x>TM62nXm*fqEp`52H~jxVa9JA*P%a+ zg$1(#Z9wU=1L-%G(r@Z=9H%QZ`u5(L#DY)rOgwCE8#QI!J3hI8)G_z_@HLcXCbqb8 zGn!3>DvQmC`bW1JvbT4&ud{!XbHk@_F_jB3T)KZvWi_Il83h-oT4&3;Pg6adWx^MW zT${46?P~k{{ym({RO)_TaL*>VUk$!ZhC6p$PPls)_KtPc-};Yr0?|#a&tO`3q W%cC7RciL&EkI}uNTkG#Xf=+kG(~11(Uhu^e!Bb%d zIZq~hB-*R@w$Q3~Ey5UwK>)p9-Az3H-Cb|%KMrsuLIVsvLL)yUVHgHc50l{#6X-3j zXZgR@tSGs$CH~Vq^~=EO`acmlglEsc{qFUnmtHFJa?A*#!OC=|vrNBZXFMwe^23!~ zj+8dydzp#C!^~6pw6CzX%rK!?3f4RGJa&6HG#i2!+ar61(wmCsZesg2m`lpO4R7 zH%I-ow(lAK{Rhs}!Kr)lF+{Bc z8-}`|3RktY1)en@_ZxKfA3)#o(OoJC_D`CX*W9!2uE5%Qkgk(j__lw_6s7soBckKZjSnEb@_k0;s00b`7fg3W&YEsLg`Hub6H;C-otw>5QH@eggGhXYs4*h8? zESL>w14@@2NWZa^ep8p@I9;L9v-i#<7JQm#;$d^!s445-@yY$8j(ISEuc0(EvBi~} z(QGPIS!_nsKf2A3y}he_o&B4f8$N}Lsa%M3>Ham9)rfLt6kMEYoh|D=O?5iUgeMlc zHf3Sk)%N-QdpMh^#QnbDo=tGS8ho1!ckZ~HaQ80k9qX#U^;bFB1IAq6y@Y336?TM{ WM>}%vw9`%>p+5nbPYnA27ytlP_|_-@ literal 0 HcmV?d00001 diff --git a/test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/mirror-for-offline/dep-c-2.0.0.tgz b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/mirror-for-offline/dep-c-2.0.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..25224ba227828848dbd3b8bcaace87ef1df3317f GIT binary patch literal 863 zcmV-l1EBmLiwFP!000001MQaoZre5x$1`Am419{K{%G2ul}SpGOUXjN`ypqjnFuVNEF3ku!G5d7zePkyqWF) zS@WXg#vbvydFqFO^>{}_hVc5$kIz3medmuvUQQT6G+dibbe8GQ?1X29KtZ&&%dyf% zypWkFe9U~6&uYtMK7{#WS++jOg+7#ZzdRJ+wO4Cbd?uJZ<>M4Z$=2#f6seJUDYatH zCL*1JJb`i|U@R9x!GdRV0kQzD;HfeE6a~Rnj)gFVi>E&JardCD!&IDp)@J0MS{6;3 z@NzH0M6us3%9aOZyv{L(wbE!)zrRj62n}M*f5NOB%w*{T*lTwk~ks+$8pmAB960ZA%7Dr z#KWkwhg6yo91u(+y9b5JhYT^IxD%?=X~7coUw`wxHo86PZ*&p=zghDi(>OZM|6re5 z+qIc|6@BIWM`sAYb7b|NfLFoQd*n literal 0 HcmV?d00001 diff --git a/test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/mirror-for-offline/dep-d-1.0.0.tgz b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/mirror-for-offline/dep-d-1.0.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..7aa4321402c352b165edfa66c6890eabe34fb474 GIT binary patch literal 887 zcmV--1Bm<|iwFP!000001MQaUZqzsw#|LRYAV0++A1G8bV<(v;rSfVKyDN~EivS6& zs!F(tJ7XqeM^0v#Qbyv%_9=KF>|AC-r(G4%a-IJd%O~d?J16!p=P8>%;4J03pR;7l zhP)l!*M*Y3OA*F63uPyYPt#l2^4%JXtW3G#xa=}2XndP9#`R&eBpOS>3KrTO0? z+W zEst|fZS9fg!}I$O9{%&MS!PB_7)6oiVMOBAEHfd;=4g-zrXr=gLFmV^7f04*XbdEd zLPBs9#og0$n2ihZmeT<5hMhHpRFq(!U=jz2cu@Ix#2h@_3029spfUQ^_v2^R)lq+? zv-p2)$$#vdqj8G={=nM4n8_E>FV25-f&d&#R_87_6xZ4fZ)*Ze|YK)7@yCI)_V&LbX#ReIlqo-^A zpD?wb8xCCF8r}PkoBQAE^nd0LYVN;}{lNGUd;f!o;7$McHMHsfe!l*1@M-_oUg+#uUK1(e#ly9vv(Dr^re_BQ0)XrqlT NppQIPFXR9i008k*(O&=n literal 0 HcmV?d00001 diff --git a/test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/mirror-for-offline/dep-d-2.0.0.tgz b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/mirror-for-offline/dep-d-2.0.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..2135e2fd15c13419daa130ddff69d65c3a6e21b5 GIT binary patch literal 858 zcmV-g1Eu^QiwFP!000001MQaIZre5##xr17e2P#af^k zf&gVC#%3*(0wudnQv-XkJ;h#Vr2g1y?Q8{_b_=HOhTze6DC$W3={)DFCxWNK40E2$ z_(Zg$_omS5;97(+4ub#=es`02`bRbDKkws8goO4Qp^+bwFbYTE0Vbm$ir`>%J-7dR zEsByGyT#94r+ygNj5kDN48J`4;m4N`fAvz4ms3U%4K|^3on`thJLg#;kRNX1a-y^m zk7Xtb4>M2Y^Ez^shcIs<%hnU`^-$LR@{o@=t~RdtTrj)K`zZ?JovW!R5+n0cYQ-K+ zMKS|<4&_w9L@tGbCC?TDWC2{kLu2>_^8KAPmckS+pL*EC-Ho<}nYehXP3oRn7R@rj z)h@zBG3pj&$3YpdS0Ou|OeR7Vg8lsTC8A@)8QVgn?OLPBs9#oaIBESnYbonQeT zhn;&!r5VA#wG)a6g~~(57*X6w)yb@2G5WW^`CeOnIqGkXB6e$0P=)yyd{m=Q2E)l@Mk#+C@1{GWf_gtuhQ+MT4h*~E$40TBrM(bz`JR3e4H0T`MgMsCv z8!8A6PMbUDLZw0_QaHQY;JUid0MV^%nK(e}o+O{G=R5tMw6$MZ4qV?o{;~hV?)>}M z53G;4^B;sX?EAm3p}zmS8U5er!~U;5r2nbjFC6=u-YZ_@+U^bu)C|!0S{n}Fcb-f+O=?aaWox6}&@p+z!2hFrmv#mQP zr+1G#;o%UzgVHR-9xFGK#ayVe*v+Vabh{~shgW-D{QI06K8MS>T#0n;{xwz9h;m^R zT%Kv2t?N3?b-KueCsw&OWns(J*7^N=IA5s5{l4IiUEprj_%AH0Iwgn4gdfE literal 0 HcmV?d00001 diff --git a/test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/mirror-for-offline/dep-e-1.0.0.tgz b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/mirror-for-offline/dep-e-1.0.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..ca6c2e109a257605468f67c9d0ff72a887e9ad8e GIT binary patch literal 854 zcmV-c1F8HUiwFP!000001MQaGZre5#$J1M0?Ga9O(X>G;lawsU4LGdmHnhOj7HffG z2m+Lm8Jo3C3Y6?ROAYMB_7r=elKQZ<+Sv*;?G{Y`8-j=D98yQ(Pv-?+JrR5?%pm9K zj88;6`fm%Z4z5KQ<0uT_;CDAkrhinU{__E@L`Y=U2#te?L{W^%0VcyR8p6Tqdba<2 zEsByGd&JMpQ$GxB#v39sf@jaa|KZi6U;MGi%PAv>h8xql&NBUuo%5^^D2O(8IZ@h( zA7v&AA2VO&^V)Ki4`Kd9maR{+*N3w1mxltp@oMdg&jqumd>~Mi?5vJOks6toQY-d& zD$*Iqb10_*CUPkhEP1vNAPe9M9vQ3`0Dbcp~wM^^74cokf|`_9zCsayFJqSk>8LtRjX(c0Pq&zeuX2A$r0@GKwQ zP(jc;ZFbIu8Vi+5;oRK;*VRG;M3>nz(L?K=B%iGpJN=)uwO?5dT;Cr5*#BX7{{tL^ z){jK?{)Z8b`u^{0sPF%7M*lbbYya0?(*IQNM>@S<827#3P0*L4{#N_=|IN1li)r*R z|7ncFzW@6gLW83t1V_-)42}i}ExBn8z-n6h&HNa(5v6`v8mT7RkfJo!{rTBjk(PdL zbg3PZ{MKAmBQ zc`$%)p)?Dz$CaDOVlGr!>_*f-y4{e&!>fIr{kxnSK8MS>T#518{c9?#5#_=txIEK3 zTi11(>+vEJzF6hjl!YxR literal 0 HcmV?d00001 diff --git a/test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/mirror-for-offline/dep-e-2.0.0.tgz b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/mirror-for-offline/dep-e-2.0.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..853b66c35bc29bac901fb1ce51016cf8a8ce0ff9 GIT binary patch literal 863 zcmV-l1EBmLiwFP!000001MQaIZre5##xr0S1D}G`MbieYOj3#@H{j5sThRjBTC4?z zAqY@LKCxNLq(I58)6~FTY)`Ql8mT|F7CT#kCfkDQyCHb=9f~>$(k@;QhRm_aVm zsTe~$`tJ&@_O3;QkSGlC-fwP_On$FM{l`O6iPFekqbv?08pSaqdxRc_QH=MN*K_;7 z*Ssi&v0MDyb?S$~>+zO|4)ISfzx)2plb`(&*U zAe~})hRX@yv0Q+{3z5wM%K{69pBN*~Q4nmcu>e!JeC89MbT`@>rf~jVn~{5JSv1Rp zSGy>O;;>tkEeGSGUWIOXGMR!ZfdBa74Prx_3;T9<9a6+Lx#f8d+|?7Y0Kb0v{KXHy z+QKZjJ6SPf1kt1ot4yk?ecd$1b2;L}Fba}{C9$)NZGa|mL@9~mr29pjX467`03MQI z)VYULno|;3doV6{{aa? z>!Xo9|6#?{^z?bJX9c%l~g0{(rsc z|6&$h=0A%ol-|T1LJMKq0OmC<{bqiI+Kf`aE{#;%EFebt@Fo^_-w9H_xr;4>;m_z#DvXD(wiZj(W=W>ecHL^e1=1u^s>z0071Uz?%R7 literal 0 HcmV?d00001 diff --git a/test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/package.json b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/package.json new file mode 100644 index 0000000000..07a737fdab --- /dev/null +++ b/test/fixtures/install/install-should-dedupe-avoiding-conflicts-7/package.json @@ -0,0 +1,9 @@ +{ + "dependencies": { + "dep-a": "1.0.0", + "dep-b": "1.0.0", + "dep-c": "2.0.0", + "dep-d": "2.0.0", + "dep-e": "2.0.0" + } +} From 45a821e1b2e7d32fe058322a5b81f7f6d469588c Mon Sep 17 00:00:00 2001 From: Konstantin Raev Date: Mon, 4 Jul 2016 13:02:16 +0100 Subject: [PATCH 2/4] refactored a bit --- test/commands/install.js | 240 +++++++++++++++------------------------ 1 file changed, 91 insertions(+), 149 deletions(-) diff --git a/test/commands/install.js b/test/commands/install.js index e38dd7c61a..2db1577093 100755 --- a/test/commands/install.js +++ b/test/commands/install.js @@ -75,6 +75,10 @@ async function run(flags, args, name, checkInstalled, beforeInstall) { await clean(cwd, removeLock); } +async function getPackageVersion(config, packagePath) { + return JSON.parse(await fs.readFile(path.join(config.cwd, `${packagePath}/package.json`))).version; +} + test("root install from shrinkwrap", () => { return run({}, [], "root-install-with-lockfile"); }); @@ -155,13 +159,8 @@ test("install should dedupe dependencies avoiding conflicts 0", () => { // B@1.0.0 // should result in B@2.0.0 not flattened return run({}, [], "install-should-dedupe-avoiding-conflicts-0", async (config) => { - let rawDepBPackage = await fs.readFile(path.join(config.cwd, "node_modules/dep-b/package.json")); - assert.equal(JSON.parse(rawDepBPackage).version, "1.0.0"); - - rawDepBPackage = await fs.readFile( - path.join(config.cwd, "node_modules/dep-a/node_modules/dep-b/package.json") - ); - assert.equal(JSON.parse(rawDepBPackage).version, "2.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-a/node_modules/dep-b"), "2.0.0"); }); }); @@ -169,11 +168,8 @@ test("install should dedupe dependencies avoiding conflicts 1", () => { // A@2.0.1 -> B@2.0.0 // should result in B@2.0.0 flattened return run({}, [], "install-should-dedupe-avoiding-conflicts-1", async (config) => { - let rawDepBPackage = await fs.readFile(path.join(config.cwd, "node_modules/dep-b/package.json")); - assert.equal(JSON.parse(rawDepBPackage).version, "2.0.0"); - - rawDepBPackage = await fs.readFile(path.join(config.cwd, "node_modules/dep-a/package.json")); - assert.equal(JSON.parse(rawDepBPackage).version, "2.0.1"); + assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "2.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-a"), "2.0.1"); }); }); @@ -188,18 +184,12 @@ test("install should dedupe dependencies avoiding conflicts 2", () => { // C@2 return run({}, [], "install-should-dedupe-avoiding-conflicts-2", async (config) => { - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-a/package.json"))).version, "2.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-a/node_modules/dep-b/package.json"))).version, "2.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-c/package.json"))).version, "2.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-d/package.json"))).version, "1.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-b/package.json"))).version, "1.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-b/node_modules/dep-c/package.json"))).version, "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-a"), "2.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-a/node_modules/dep-b"), "2.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-c"), "2.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-d"), "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-b/node_modules/dep-c"), "1.0.0"); }); }); @@ -213,16 +203,11 @@ test("install should dedupe dependencies avoiding conflicts 3", () => { // C@2 // D@1 return run({}, [], "install-should-dedupe-avoiding-conflicts-3", async (config) => { - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-a/package.json"))).version, "2.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-c/package.json"))).version, "2.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-d/package.json"))).version, "1.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-b/package.json"))).version, "2.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-a/node_modules/dep-c/package.json"))).version, "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-a"), "2.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-c"), "2.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-d"), "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "2.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-a/node_modules/dep-c"), "1.0.0"); }); }); @@ -238,16 +223,11 @@ test("install should dedupe dependencies avoiding conflicts 4", () => { // B@2 // D@1 return run({}, [], "install-should-dedupe-avoiding-conflicts-4", async (config) => { - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-a/package.json"))).version, "2.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-c/package.json"))).version, "2.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-d/package.json"))).version, "1.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-b/package.json"))).version, "2.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-a/node_modules/dep-c/package.json"))).version, "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-a"), "2.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-c"), "2.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-d"), "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "2.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-a/node_modules/dep-c"), "1.0.0"); }); }); @@ -264,18 +244,12 @@ test("install should dedupe dependencies avoiding conflicts 5", () => { // -> B@2 return run({}, [], "install-should-dedupe-avoiding-conflicts-5", async (config) => { - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-a/package.json"))).version, "1.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-b/package.json"))).version, "1.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-c/package.json"))).version, "1.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-d/package.json"))).version, "1.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-d/node_modules/dep-a/package.json"))).version, "2.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-d/node_modules/dep-b/package.json"))).version, "2.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-a"), "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-c"), "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-d"), "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-d/node_modules/dep-a"), "2.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-d/node_modules/dep-b"), "2.0.0"); }); }); @@ -295,19 +269,13 @@ test("install should dedupe dependencies avoiding conflicts 6 (jest/jest-runtime // E@2 return run({}, [], "install-should-dedupe-avoiding-conflicts-6", async (config) => { - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-b/package.json"))).version, "1.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-c/package.json"))).version, "1.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-d/package.json"))).version, "2.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-e/package.json"))).version, "2.0.0"); - - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-c/node_modules/dep-d/package.json"))).version, "1.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-c/node_modules/dep-e/package.json"))).version, "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-c"), "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-d"), "2.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-e"), "2.0.0"); + + assert.equal(await getPackageVersion(config, "node_modules/dep-c/node_modules/dep-d"), "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-c/node_modules/dep-e"), "1.0.0"); }); }); @@ -331,31 +299,20 @@ test("install should dedupe dependencies avoiding conflicts 7", () => { // E@2 return run({}, [], "install-should-dedupe-avoiding-conflicts-7", async (config) => { - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-a/package.json"))).version, "1.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-b/package.json"))).version, "1.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-c/package.json"))).version, "2.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-d/package.json"))).version, "2.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-e/package.json"))).version, "2.0.0"); - - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-a/node_modules/dep-c/package.json"))).version, "1.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-a/node_modules/dep-d/package.json"))).version, "1.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-a/node_modules/dep-e/package.json"))).version, "1.0.0"); - - - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-b/node_modules/dep-c/package.json"))).version, "1.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-b/node_modules/dep-d/package.json"))).version, "1.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-b/node_modules/dep-e/package.json"))).version, "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-a"), "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-c"), "2.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-d"), "2.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-e"), "2.0.0"); + + assert.equal(await getPackageVersion(config, "node_modules/dep-a/node_modules/dep-c"), "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-a/node_modules/dep-d"), "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-a/node_modules/dep-e"), "1.0.0"); + + + assert.equal(await getPackageVersion(config, "node_modules/dep-b/node_modules/dep-c"), "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-b/node_modules/dep-d"), "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-b/node_modules/dep-e"), "1.0.0"); }); }); @@ -374,7 +331,7 @@ test("upgrade scenario", () => { return run({ save: true }, ["left-pad@0.0.9"], "install-upgrade-scenario", async (config) => { assert.equal( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/left-pad/package.json"))).version, + await getPackageVersion(config, "node_modules/left-pad"), "0.0.9" ); assert.deepEqual( @@ -394,7 +351,7 @@ test("upgrade scenario", () => { return run({save: true}, ["left-pad@1.1.0"], "install-upgrade-scenario", async (config) => { assert.equal( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/left-pad/package.json"))).version, + await getPackageVersion(config, "node_modules/left-pad"), "1.1.0" ); assert.deepEqual( @@ -429,21 +386,21 @@ test("upgrade scenario 2 (with sub dependencies)", async () => { return run({}, [], fixture, async (config) => { assert(semver.satisfies( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/mime-db/package.json"))).version, + await getPackageVersion(config, "node_modules/mime-db"), "~1.0.1") ); assert.equal( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/mime-types/package.json"))).version, + await getPackageVersion(config, "node_modules/mime-types"), "2.0.0" ); return run({save: true}, ["mime-types@2.1.11"], fixture, async (config) => { assert(semver.satisfies( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/mime-db/package.json"))).version, + await getPackageVersion(config, "node_modules/mime-db"), "~1.23.0" )); assert.equal( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/mime-types/package.json"))).version, + await getPackageVersion(config, "node_modules/mime-types"), "2.1.11" ); @@ -477,7 +434,7 @@ test("downgrade scenario", () => { return run({save: true}, ["left-pad@1.1.0"], "install-downgrade-scenario", async (config) => { assert.equal( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/left-pad/package.json"))).version, + await getPackageVersion(config, "node_modules/left-pad"), "1.1.0" ); assert.deepEqual( @@ -498,7 +455,7 @@ test("downgrade scenario", () => { return run({save: true}, ["left-pad@0.0.9"], "install-downgrade-scenario", async (config) => { assert.equal( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/left-pad/package.json"))).version, + await getPackageVersion(config, "node_modules/left-pad"), "0.0.9" ); assert.deepEqual( @@ -543,12 +500,9 @@ test("install have a clean node_modules after lockfile update (branch switch sce await fs.copy(path.join(cwd, "package.json.before"), path.join(cwd, "package.json")); return run({}, [], fixture, async (config) => { - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-a/package.json"))).version, "1.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-b/package.json"))).version, "2.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-a/node_modules/dep-b/package.json"))).version, "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-a"), "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "2.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-a/node_modules/dep-b"), "1.0.0"); await fs.unlink(path.join(config.cwd, "fbkpm.lock")); await fs.unlink(path.join(config.cwd, "package.json")); @@ -557,10 +511,8 @@ test("install have a clean node_modules after lockfile update (branch switch sce await fs.copy(path.join(cwd, "package.json.after"), path.join(cwd, "package.json")); return run({}, [], fixture, async (config) => { - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-a/package.json"))).version, "1.2.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-b/package.json"))).version, "1.2.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-a"), "1.2.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "1.2.0"); await fs.unlink(path.join(config.cwd, "fbkpm.lock")); await fs.unlink(path.join(config.cwd, "package.json")); @@ -583,10 +535,8 @@ test("install have a clean node_modules after lockfile update (branch switch sce await fs.copy(path.join(cwd, "package.json.before"), path.join(cwd, "package.json")); return run({}, [], fixture, async (config) => { - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-a/package.json"))).version, "1.0.0"); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-b/package.json"))).version, "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-a"), "1.0.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "1.0.0"); await fs.unlink(path.join(config.cwd, "fbkpm.lock")); await fs.unlink(path.join(config.cwd, "package.json")); @@ -595,8 +545,7 @@ test("install have a clean node_modules after lockfile update (branch switch sce await fs.copy(path.join(cwd, "package.json.after"), path.join(cwd, "package.json")); return run({}, [], fixture, async (config) => { - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/dep-a/package.json"))).version, "1.2.0"); + assert.equal(await getPackageVersion(config, "node_modules/dep-a"), "1.2.0"); assert(!await fs.exists(path.join(config.cwd, "node_modules/dep-b"))); @@ -611,7 +560,7 @@ test("uninstall should remove dependency from package.json, fbkpm.lock and node_ return run({}, [], "uninstall-should-clean", async (config, reporter) => { assert.equal( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/dep-a/package.json"))).version, + await getPackageVersion(config, "node_modules/dep-a"), "1.0.0" ); @@ -653,15 +602,15 @@ test("uninstall should remove subdependencies", () => { return run({}, [], "uninstall-should-remove-subdependencies", async (config, reporter) => { assert.equal( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/dep-a/package.json"))).version, + await getPackageVersion(config, "node_modules/dep-a"), "1.0.0" ); assert.equal( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/dep-b/package.json"))).version, + await getPackageVersion(config, "node_modules/dep-b"), "1.0.0" ); assert.equal( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/dep-c/package.json"))).version, + await getPackageVersion(config, "node_modules/dep-c"), "1.0.0" ); @@ -705,12 +654,9 @@ test.skip("install --save should add missing deps to fbkpm and mirror (PR import await fs.copy(path.join(cwd, "fbkpm.lock.before"), path.join(cwd, "fbkpm.lock")); return run({save: true}, [], fixture, async (config, reporter) => { - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/mime-types/package.json"))).version, "2.0.0"); - assert(semver.satisfies(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/mime-db/package.json"))).version, "~1.0.1")); - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/fake-fbkpm-dependency/package.json"))).version, "1.0.1"); + assert.equal(await getPackageVersion(config, "node_modules/mime-types"), "2.0.0"); + assert(semver.satisfies(await getPackageVersion(config, "node_modules/mime-db"), "~1.0.1")); + assert.equal(await getPackageVersion(config, "node_modules/fake-fbkpm-dependency"), "1.0.1"); let mirror = await fs.walk(path.join(config.cwd, mirrorPath)); assert.equal(mirror.length, 3); @@ -745,11 +691,11 @@ test.skip("install --save should update a dependency to fbkpm and mirror (PR imp return run({}, [], fixture, async (config) => { assert(semver.satisfies( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/mime-db/package.json"))).version, + await getPackageVersion(config, "node_modules/mime-db"), "~1.0.1") ); assert.equal( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/mime-types/package.json"))).version, + await getPackageVersion(config, "node_modules/mime-types"), "2.0.0" ); @@ -758,11 +704,11 @@ test.skip("install --save should update a dependency to fbkpm and mirror (PR imp return run({save: true}, [], fixture, async (config) => { assert(semver.satisfies( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/mime-db/package.json"))).version, + await getPackageVersion(config, "node_modules/mime-db"), "~1.23.0" )); assert.equal( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/mime-types/package.json"))).version, + await getPackageVersion(config, "node_modules/mime-types"), "2.1.11" ); @@ -796,10 +742,8 @@ test("install --initMirror should add init mirror deps from package.json", async // initMirror gets converted to save flag in cli/install.js return run({save: true}, [], fixture, async (config, reporter) => { - assert.equal(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/mime-types/package.json"))).version, "2.0.0"); - assert(semver.satisfies(JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/mime-db/package.json"))).version, "~1.0.1")); + assert.equal(await getPackageVersion(config, "node_modules/mime-types"), "2.0.0"); + assert(semver.satisfies(await getPackageVersion(config, "node_modules/mime-db"), "~1.0.1")); let mirror = await fs.walk(path.join(config.cwd, mirrorPath)); assert.equal(mirror.length, 2); @@ -830,26 +774,25 @@ test("install --save with new dependency should be deterministic", async () => { return run({}, [], fixture, async (config) => { assert(semver.satisfies( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/mime-db/package.json"))).version, + await getPackageVersion(config, "node_modules/mime-db"), "~1.0.1") ); assert.equal( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/mime-types/package.json"))).version, + await getPackageVersion(config, "node_modules/mime-types"), "2.0.0" ); return run({save: true}, ["mime-db@1.23.0"], fixture, async (config) => { assert(semver.satisfies( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/mime-db/package.json"))).version, + await getPackageVersion(config, "node_modules/mime-db"), "~1.23.0" )); assert.equal( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/mime-types/package.json"))).version, + await getPackageVersion(config, "node_modules/mime-types"), "2.0.0" ); assert.equal( - JSON.parse(await fs.readFile(path.join(config.cwd, - "node_modules/mime-types/node_modules/mime-db/package.json"))).version, + await getPackageVersion(config, "node_modules/mime-types/node_modules/mime-db"), "1.0.3" ); assert.deepEqual( @@ -888,21 +831,21 @@ test.skip("install --save with new dependency should be deterministic 2", async return run({}, [], fixture, async (config) => { assert.equal( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/mime-db/package.json"))).version, + await getPackageVersion(config, "node_modules/mime-db"), "1.0.1" ); assert.equal( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/mime-types/package.json"))).version, + await getPackageVersion(config, "node_modules/mime-types"), "2.0.0" ); return run({save: true}, ["mime-db@1.0.3"], fixture, async (config) => { assert.equal( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/mime-db/package.json"))).version, + await getPackageVersion(config, "node_modules/mime-db"), "1.0.3" ); assert.equal( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/mime-types/package.json"))).version, + await getPackageVersion(config, "node_modules/mime-types"), "2.0.0" ); assert(!await fs.exists(path.join(config.cwd, "node_modules/mime-types/node-modules/mime-db"))); @@ -929,7 +872,6 @@ test.skip("install --save with new dependency should be deterministic 2", async }); }); - test("install --save should ignore cache", () => { // left-pad@1.1.0 gets installed without --save // left-pad@1.1.0 gets installed with --save @@ -940,13 +882,13 @@ test("install --save should ignore cache", () => { let fixture = "install-save-to-mirror-when-cached"; return run({}, ["left-pad@1.1.0"], fixture, async (config) => { assert.equal( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/left-pad/package.json"))).version, + await getPackageVersion(config, "node_modules/left-pad"), "1.1.0" ); return run({save: true}, ["left-pad@1.1.0"], fixture, async (config) => { assert.equal( - JSON.parse(await fs.readFile(path.join(config.cwd, "node_modules/left-pad/package.json"))).version, + await getPackageVersion(config, "node_modules/left-pad"), "1.1.0" ); assert.deepEqual( From a2139953d59085eeb7dcbc7ec80b437ed2f3da82 Mon Sep 17 00:00:00 2001 From: Konstantin Raev Date: Mon, 4 Jul 2016 13:05:01 +0100 Subject: [PATCH 3/4] more cleanup --- test/commands/install.js | 168 +++++++++++++++++++-------------------- 1 file changed, 84 insertions(+), 84 deletions(-) diff --git a/test/commands/install.js b/test/commands/install.js index 2db1577093..574dc3afdc 100755 --- a/test/commands/install.js +++ b/test/commands/install.js @@ -76,7 +76,7 @@ async function run(flags, args, name, checkInstalled, beforeInstall) { } async function getPackageVersion(config, packagePath) { - return JSON.parse(await fs.readFile(path.join(config.cwd, `${packagePath}/package.json`))).version; + return JSON.parse(await fs.readFile(path.join(config.cwd, `node_modules/${packagePath}/package.json`))).version; } test("root install from shrinkwrap", () => { @@ -159,8 +159,8 @@ test("install should dedupe dependencies avoiding conflicts 0", () => { // B@1.0.0 // should result in B@2.0.0 not flattened return run({}, [], "install-should-dedupe-avoiding-conflicts-0", async (config) => { - assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "1.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-a/node_modules/dep-b"), "2.0.0"); + assert.equal(await getPackageVersion(config, "dep-b"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-a/node_modules/dep-b"), "2.0.0"); }); }); @@ -168,8 +168,8 @@ test("install should dedupe dependencies avoiding conflicts 1", () => { // A@2.0.1 -> B@2.0.0 // should result in B@2.0.0 flattened return run({}, [], "install-should-dedupe-avoiding-conflicts-1", async (config) => { - assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "2.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-a"), "2.0.1"); + assert.equal(await getPackageVersion(config, "dep-b"), "2.0.0"); + assert.equal(await getPackageVersion(config, "dep-a"), "2.0.1"); }); }); @@ -184,12 +184,12 @@ test("install should dedupe dependencies avoiding conflicts 2", () => { // C@2 return run({}, [], "install-should-dedupe-avoiding-conflicts-2", async (config) => { - assert.equal(await getPackageVersion(config, "node_modules/dep-a"), "2.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-a/node_modules/dep-b"), "2.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-c"), "2.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-d"), "1.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "1.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-b/node_modules/dep-c"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-a"), "2.0.0"); + assert.equal(await getPackageVersion(config, "dep-a/node_modules/dep-b"), "2.0.0"); + assert.equal(await getPackageVersion(config, "dep-c"), "2.0.0"); + assert.equal(await getPackageVersion(config, "dep-d"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-b"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-b/node_modules/dep-c"), "1.0.0"); }); }); @@ -203,11 +203,11 @@ test("install should dedupe dependencies avoiding conflicts 3", () => { // C@2 // D@1 return run({}, [], "install-should-dedupe-avoiding-conflicts-3", async (config) => { - assert.equal(await getPackageVersion(config, "node_modules/dep-a"), "2.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-c"), "2.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-d"), "1.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "2.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-a/node_modules/dep-c"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-a"), "2.0.0"); + assert.equal(await getPackageVersion(config, "dep-c"), "2.0.0"); + assert.equal(await getPackageVersion(config, "dep-d"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-b"), "2.0.0"); + assert.equal(await getPackageVersion(config, "dep-a/node_modules/dep-c"), "1.0.0"); }); }); @@ -223,11 +223,11 @@ test("install should dedupe dependencies avoiding conflicts 4", () => { // B@2 // D@1 return run({}, [], "install-should-dedupe-avoiding-conflicts-4", async (config) => { - assert.equal(await getPackageVersion(config, "node_modules/dep-a"), "2.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-c"), "2.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-d"), "1.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "2.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-a/node_modules/dep-c"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-a"), "2.0.0"); + assert.equal(await getPackageVersion(config, "dep-c"), "2.0.0"); + assert.equal(await getPackageVersion(config, "dep-d"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-b"), "2.0.0"); + assert.equal(await getPackageVersion(config, "dep-a/node_modules/dep-c"), "1.0.0"); }); }); @@ -244,12 +244,12 @@ test("install should dedupe dependencies avoiding conflicts 5", () => { // -> B@2 return run({}, [], "install-should-dedupe-avoiding-conflicts-5", async (config) => { - assert.equal(await getPackageVersion(config, "node_modules/dep-a"), "1.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "1.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-c"), "1.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-d"), "1.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-d/node_modules/dep-a"), "2.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-d/node_modules/dep-b"), "2.0.0"); + assert.equal(await getPackageVersion(config, "dep-a"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-b"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-c"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-d"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-d/node_modules/dep-a"), "2.0.0"); + assert.equal(await getPackageVersion(config, "dep-d/node_modules/dep-b"), "2.0.0"); }); }); @@ -269,13 +269,13 @@ test("install should dedupe dependencies avoiding conflicts 6 (jest/jest-runtime // E@2 return run({}, [], "install-should-dedupe-avoiding-conflicts-6", async (config) => { - assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "1.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-c"), "1.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-d"), "2.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-e"), "2.0.0"); + assert.equal(await getPackageVersion(config, "dep-b"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-c"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-d"), "2.0.0"); + assert.equal(await getPackageVersion(config, "dep-e"), "2.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-c/node_modules/dep-d"), "1.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-c/node_modules/dep-e"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-c/node_modules/dep-d"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-c/node_modules/dep-e"), "1.0.0"); }); }); @@ -299,20 +299,20 @@ test("install should dedupe dependencies avoiding conflicts 7", () => { // E@2 return run({}, [], "install-should-dedupe-avoiding-conflicts-7", async (config) => { - assert.equal(await getPackageVersion(config, "node_modules/dep-a"), "1.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "1.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-c"), "2.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-d"), "2.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-e"), "2.0.0"); + assert.equal(await getPackageVersion(config, "dep-a"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-b"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-c"), "2.0.0"); + assert.equal(await getPackageVersion(config, "dep-d"), "2.0.0"); + assert.equal(await getPackageVersion(config, "dep-e"), "2.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-a/node_modules/dep-c"), "1.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-a/node_modules/dep-d"), "1.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-a/node_modules/dep-e"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-a/node_modules/dep-c"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-a/node_modules/dep-d"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-a/node_modules/dep-e"), "1.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-b/node_modules/dep-c"), "1.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-b/node_modules/dep-d"), "1.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-b/node_modules/dep-e"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-b/node_modules/dep-c"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-b/node_modules/dep-d"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-b/node_modules/dep-e"), "1.0.0"); }); }); @@ -331,7 +331,7 @@ test("upgrade scenario", () => { return run({ save: true }, ["left-pad@0.0.9"], "install-upgrade-scenario", async (config) => { assert.equal( - await getPackageVersion(config, "node_modules/left-pad"), + await getPackageVersion(config, "left-pad"), "0.0.9" ); assert.deepEqual( @@ -351,7 +351,7 @@ test("upgrade scenario", () => { return run({save: true}, ["left-pad@1.1.0"], "install-upgrade-scenario", async (config) => { assert.equal( - await getPackageVersion(config, "node_modules/left-pad"), + await getPackageVersion(config, "left-pad"), "1.1.0" ); assert.deepEqual( @@ -386,21 +386,21 @@ test("upgrade scenario 2 (with sub dependencies)", async () => { return run({}, [], fixture, async (config) => { assert(semver.satisfies( - await getPackageVersion(config, "node_modules/mime-db"), + await getPackageVersion(config, "mime-db"), "~1.0.1") ); assert.equal( - await getPackageVersion(config, "node_modules/mime-types"), + await getPackageVersion(config, "mime-types"), "2.0.0" ); return run({save: true}, ["mime-types@2.1.11"], fixture, async (config) => { assert(semver.satisfies( - await getPackageVersion(config, "node_modules/mime-db"), + await getPackageVersion(config, "mime-db"), "~1.23.0" )); assert.equal( - await getPackageVersion(config, "node_modules/mime-types"), + await getPackageVersion(config, "mime-types"), "2.1.11" ); @@ -434,7 +434,7 @@ test("downgrade scenario", () => { return run({save: true}, ["left-pad@1.1.0"], "install-downgrade-scenario", async (config) => { assert.equal( - await getPackageVersion(config, "node_modules/left-pad"), + await getPackageVersion(config, "left-pad"), "1.1.0" ); assert.deepEqual( @@ -455,7 +455,7 @@ test("downgrade scenario", () => { return run({save: true}, ["left-pad@0.0.9"], "install-downgrade-scenario", async (config) => { assert.equal( - await getPackageVersion(config, "node_modules/left-pad"), + await getPackageVersion(config, "left-pad"), "0.0.9" ); assert.deepEqual( @@ -500,9 +500,9 @@ test("install have a clean node_modules after lockfile update (branch switch sce await fs.copy(path.join(cwd, "package.json.before"), path.join(cwd, "package.json")); return run({}, [], fixture, async (config) => { - assert.equal(await getPackageVersion(config, "node_modules/dep-a"), "1.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "2.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-a/node_modules/dep-b"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-a"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-b"), "2.0.0"); + assert.equal(await getPackageVersion(config, "dep-a/node_modules/dep-b"), "1.0.0"); await fs.unlink(path.join(config.cwd, "fbkpm.lock")); await fs.unlink(path.join(config.cwd, "package.json")); @@ -511,8 +511,8 @@ test("install have a clean node_modules after lockfile update (branch switch sce await fs.copy(path.join(cwd, "package.json.after"), path.join(cwd, "package.json")); return run({}, [], fixture, async (config) => { - assert.equal(await getPackageVersion(config, "node_modules/dep-a"), "1.2.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "1.2.0"); + assert.equal(await getPackageVersion(config, "dep-a"), "1.2.0"); + assert.equal(await getPackageVersion(config, "dep-b"), "1.2.0"); await fs.unlink(path.join(config.cwd, "fbkpm.lock")); await fs.unlink(path.join(config.cwd, "package.json")); @@ -535,8 +535,8 @@ test("install have a clean node_modules after lockfile update (branch switch sce await fs.copy(path.join(cwd, "package.json.before"), path.join(cwd, "package.json")); return run({}, [], fixture, async (config) => { - assert.equal(await getPackageVersion(config, "node_modules/dep-a"), "1.0.0"); - assert.equal(await getPackageVersion(config, "node_modules/dep-b"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-a"), "1.0.0"); + assert.equal(await getPackageVersion(config, "dep-b"), "1.0.0"); await fs.unlink(path.join(config.cwd, "fbkpm.lock")); await fs.unlink(path.join(config.cwd, "package.json")); @@ -545,7 +545,7 @@ test("install have a clean node_modules after lockfile update (branch switch sce await fs.copy(path.join(cwd, "package.json.after"), path.join(cwd, "package.json")); return run({}, [], fixture, async (config) => { - assert.equal(await getPackageVersion(config, "node_modules/dep-a"), "1.2.0"); + assert.equal(await getPackageVersion(config, "dep-a"), "1.2.0"); assert(!await fs.exists(path.join(config.cwd, "node_modules/dep-b"))); @@ -560,7 +560,7 @@ test("uninstall should remove dependency from package.json, fbkpm.lock and node_ return run({}, [], "uninstall-should-clean", async (config, reporter) => { assert.equal( - await getPackageVersion(config, "node_modules/dep-a"), + await getPackageVersion(config, "dep-a"), "1.0.0" ); @@ -602,15 +602,15 @@ test("uninstall should remove subdependencies", () => { return run({}, [], "uninstall-should-remove-subdependencies", async (config, reporter) => { assert.equal( - await getPackageVersion(config, "node_modules/dep-a"), + await getPackageVersion(config, "dep-a"), "1.0.0" ); assert.equal( - await getPackageVersion(config, "node_modules/dep-b"), + await getPackageVersion(config, "dep-b"), "1.0.0" ); assert.equal( - await getPackageVersion(config, "node_modules/dep-c"), + await getPackageVersion(config, "dep-c"), "1.0.0" ); @@ -654,9 +654,9 @@ test.skip("install --save should add missing deps to fbkpm and mirror (PR import await fs.copy(path.join(cwd, "fbkpm.lock.before"), path.join(cwd, "fbkpm.lock")); return run({save: true}, [], fixture, async (config, reporter) => { - assert.equal(await getPackageVersion(config, "node_modules/mime-types"), "2.0.0"); - assert(semver.satisfies(await getPackageVersion(config, "node_modules/mime-db"), "~1.0.1")); - assert.equal(await getPackageVersion(config, "node_modules/fake-fbkpm-dependency"), "1.0.1"); + assert.equal(await getPackageVersion(config, "mime-types"), "2.0.0"); + assert(semver.satisfies(await getPackageVersion(config, "mime-db"), "~1.0.1")); + assert.equal(await getPackageVersion(config, "fake-fbkpm-dependency"), "1.0.1"); let mirror = await fs.walk(path.join(config.cwd, mirrorPath)); assert.equal(mirror.length, 3); @@ -691,11 +691,11 @@ test.skip("install --save should update a dependency to fbkpm and mirror (PR imp return run({}, [], fixture, async (config) => { assert(semver.satisfies( - await getPackageVersion(config, "node_modules/mime-db"), + await getPackageVersion(config, "mime-db"), "~1.0.1") ); assert.equal( - await getPackageVersion(config, "node_modules/mime-types"), + await getPackageVersion(config, "mime-types"), "2.0.0" ); @@ -704,11 +704,11 @@ test.skip("install --save should update a dependency to fbkpm and mirror (PR imp return run({save: true}, [], fixture, async (config) => { assert(semver.satisfies( - await getPackageVersion(config, "node_modules/mime-db"), + await getPackageVersion(config, "mime-db"), "~1.23.0" )); assert.equal( - await getPackageVersion(config, "node_modules/mime-types"), + await getPackageVersion(config, "mime-types"), "2.1.11" ); @@ -742,8 +742,8 @@ test("install --initMirror should add init mirror deps from package.json", async // initMirror gets converted to save flag in cli/install.js return run({save: true}, [], fixture, async (config, reporter) => { - assert.equal(await getPackageVersion(config, "node_modules/mime-types"), "2.0.0"); - assert(semver.satisfies(await getPackageVersion(config, "node_modules/mime-db"), "~1.0.1")); + assert.equal(await getPackageVersion(config, "mime-types"), "2.0.0"); + assert(semver.satisfies(await getPackageVersion(config, "mime-db"), "~1.0.1")); let mirror = await fs.walk(path.join(config.cwd, mirrorPath)); assert.equal(mirror.length, 2); @@ -774,25 +774,25 @@ test("install --save with new dependency should be deterministic", async () => { return run({}, [], fixture, async (config) => { assert(semver.satisfies( - await getPackageVersion(config, "node_modules/mime-db"), + await getPackageVersion(config, "mime-db"), "~1.0.1") ); assert.equal( - await getPackageVersion(config, "node_modules/mime-types"), + await getPackageVersion(config, "mime-types"), "2.0.0" ); return run({save: true}, ["mime-db@1.23.0"], fixture, async (config) => { assert(semver.satisfies( - await getPackageVersion(config, "node_modules/mime-db"), + await getPackageVersion(config, "mime-db"), "~1.23.0" )); assert.equal( - await getPackageVersion(config, "node_modules/mime-types"), + await getPackageVersion(config, "mime-types"), "2.0.0" ); assert.equal( - await getPackageVersion(config, "node_modules/mime-types/node_modules/mime-db"), + await getPackageVersion(config, "mime-types/node_modules/mime-db"), "1.0.3" ); assert.deepEqual( @@ -831,21 +831,21 @@ test.skip("install --save with new dependency should be deterministic 2", async return run({}, [], fixture, async (config) => { assert.equal( - await getPackageVersion(config, "node_modules/mime-db"), + await getPackageVersion(config, "mime-db"), "1.0.1" ); assert.equal( - await getPackageVersion(config, "node_modules/mime-types"), + await getPackageVersion(config, "mime-types"), "2.0.0" ); return run({save: true}, ["mime-db@1.0.3"], fixture, async (config) => { assert.equal( - await getPackageVersion(config, "node_modules/mime-db"), + await getPackageVersion(config, "mime-db"), "1.0.3" ); assert.equal( - await getPackageVersion(config, "node_modules/mime-types"), + await getPackageVersion(config, "mime-types"), "2.0.0" ); assert(!await fs.exists(path.join(config.cwd, "node_modules/mime-types/node-modules/mime-db"))); @@ -882,13 +882,13 @@ test("install --save should ignore cache", () => { let fixture = "install-save-to-mirror-when-cached"; return run({}, ["left-pad@1.1.0"], fixture, async (config) => { assert.equal( - await getPackageVersion(config, "node_modules/left-pad"), + await getPackageVersion(config, "left-pad"), "1.1.0" ); return run({save: true}, ["left-pad@1.1.0"], fixture, async (config) => { assert.equal( - await getPackageVersion(config, "node_modules/left-pad"), + await getPackageVersion(config, "left-pad"), "1.1.0" ); assert.deepEqual( From fd30c0b7ad8b7d4ee268ec7ccb76a30165f70473 Mon Sep 17 00:00:00 2001 From: Konstantin Raev Date: Mon, 4 Jul 2016 15:35:16 +0100 Subject: [PATCH 4/4] fixed #86 and lint errors --- Makefile | 2 +- src/cli/commands/install.js | 13 ------------- src/package-linker.js | 4 ++++ test/commands/install.js | 10 ++++++---- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 31cf5bb2cd..2a3de4d18e 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ watch: ./node_modules/.bin/gulp watch test-only: - ./node_modules/.bin/nyc --check-coverage --lines 85 --branches 74 --functions 85 ./node_modules/.bin/ava --verbose test/ + ./node_modules/.bin/nyc --check-coverage --lines 85 --branches 74 --functions 85 ./node_modules/.bin/ava --verbose --concurrency 5 test/ ./node_modules/.bin/nyc report --reporter=lcov lint: diff --git a/src/cli/commands/install.js b/src/cli/commands/install.js index 11f7549668..b6fa0e16e9 100644 --- a/src/cli/commands/install.js +++ b/src/cli/commands/install.js @@ -12,7 +12,6 @@ import type { RegistryNames } from "../../registries/index.js"; import type { Reporter } from "kreporters"; import type Config from "../../config.js"; -import type { DependencyRequestPatterns } from "../../types.js"; import Lockfile from "../../lockfile/index.js"; import lockStringify from "../../lockfile/stringify.js"; import PackageInstallScripts from "../../package-install-scripts.js"; @@ -31,18 +30,6 @@ let invariant = require("invariant"); let emoji = require("node-emoji"); let path = require("path"); -type FetchResolveParams = { - totalSteps: number, - patterns: Array, - requests: DependencyRequestPatterns -}; - -type FetchResolveReturn = { - patterns: Array, - total: number, - step: number -}; - type InstallActions = "install" | "update" | "uninstall"; export class Install { diff --git a/src/package-linker.js b/src/package-linker.js index 680cfc6db5..6d0a5ed764 100644 --- a/src/package-linker.js +++ b/src/package-linker.js @@ -223,6 +223,10 @@ export default class PackageLinker { async copyModules(patterns: Array): Promise { let flatTree = await this.initCopyModules(patterns); + // sorted tree makes file creation and copying not to interfere with each other + flatTree = flatTree.sort((dep1, dep2) => { + return dep1[0].localeCompare(dep2[0]); + }); let self = this; // diff --git a/test/commands/install.js b/test/commands/install.js index 574dc3afdc..35adb3588c 100755 --- a/test/commands/install.js +++ b/test/commands/install.js @@ -76,7 +76,8 @@ async function run(flags, args, name, checkInstalled, beforeInstall) { } async function getPackageVersion(config, packagePath) { - return JSON.parse(await fs.readFile(path.join(config.cwd, `node_modules/${packagePath}/package.json`))).version; + return JSON.parse(await fs.readFile( + path.join(config.cwd, `node_modules/${packagePath}/package.json`))).version; } test("root install from shrinkwrap", () => { @@ -653,7 +654,7 @@ test.skip("install --save should add missing deps to fbkpm and mirror (PR import let cwd = path.join(fixturesLoc, fixture); await fs.copy(path.join(cwd, "fbkpm.lock.before"), path.join(cwd, "fbkpm.lock")); - return run({save: true}, [], fixture, async (config, reporter) => { + return run({save: true}, [], fixture, async (config) => { assert.equal(await getPackageVersion(config, "mime-types"), "2.0.0"); assert(semver.satisfies(await getPackageVersion(config, "mime-db"), "~1.0.1")); assert.equal(await getPackageVersion(config, "fake-fbkpm-dependency"), "1.0.1"); @@ -678,7 +679,8 @@ test.skip("install --save should add missing deps to fbkpm and mirror (PR import }); // TODO https://github.com/facebook/fbkpm/issues/78 -test.skip("install --save should update a dependency to fbkpm and mirror (PR import scenario 2)", async () => { +test.skip("install --save should update a dependency to fbkpm and mirror (PR import scenario 2)", +async () => { // mime-types@2.0.0 is saved in local mirror and gets updated to mime-types@2.1.11 via // a change in package.json, // files in mirror, fbkpm.lock, package.json and node_modules should reflect that @@ -741,7 +743,7 @@ test("install --initMirror should add init mirror deps from package.json", async let fixture = "install-init-mirror"; // initMirror gets converted to save flag in cli/install.js - return run({save: true}, [], fixture, async (config, reporter) => { + return run({save: true}, [], fixture, async (config) => { assert.equal(await getPackageVersion(config, "mime-types"), "2.0.0"); assert(semver.satisfies(await getPackageVersion(config, "mime-db"), "~1.0.1"));