From 093a4ef2403b52c0a260601553623779fcc70f60 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Thu, 28 May 2020 07:28:54 +0800 Subject: [PATCH] feat: add `dependenciesMeta` field (#190) --- index.js | 1 + tests/deps.js | 8 ++++++ tests/snapshots/cli.js.snap | Bin 1829 -> 1858 bytes tests/snapshots/deps.js.md | 52 +++++++++++++++++++++++++++++++++++ tests/snapshots/deps.js.snap | Bin 297 -> 369 bytes tests/snapshots/main.js.md | 2 ++ tests/snapshots/main.js.snap | Bin 1164 -> 1177 bytes 7 files changed, 63 insertions(+) diff --git a/index.js b/index.js index ad84eea9..a7cc417c 100755 --- a/index.js +++ b/index.js @@ -246,6 +246,7 @@ const fields = [ { key: 'resolutions', over: sortObject }, { key: 'dependencies', over: sortObject }, { key: 'devDependencies', over: sortObject }, + { key: 'dependenciesMeta', over: sortObjectBy(undefined, true) }, { key: 'peerDependencies', over: sortObject }, // TODO: only sort depth = 2 { key: 'peerDependenciesMeta', over: sortObjectBy(undefined, true) }, diff --git a/tests/deps.js b/tests/deps.js index 8c5466d1..26d72fcc 100644 --- a/tests/deps.js +++ b/tests/deps.js @@ -29,3 +29,11 @@ test('peerDependenciesMeta', macro.sortObjectAlphabetically, { // TODO: don't use snapshot, find a esaier way for review expect: 'snapshot', }) + +// peerDependenciesMeta +test('dependenciesMeta', macro.sortObjectAlphabetically, { + path: 'dependenciesMeta', + maxDepth: 2, + // TODO: don't use snapshot, find a esaier way for review + expect: 'snapshot', +}) diff --git a/tests/snapshots/cli.js.snap b/tests/snapshots/cli.js.snap index 5a1919f1e282634709fed26fd6b405f8ff7131c8..bc7ecc16b80703c121213ce6f14df1fb0fb32894 100644 GIT binary patch literal 1858 zcmV-I2fg?~RzV}| z37H$2Zo|3gbPF>oK2R4or;BkJF-Bcx%v3as&biFF@7~_>xZL)11xlGU`Qp9jewUte z?{|LR@Atd&DIuYxdFPa9bflo(v_r1`zb$K5KhRZf~WD4;#9%^x8K_z^=5+Jk)S9B0 z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Ve5C?i&O)j0#o1z;4)$Xs^S*$c`6K!p-Aj$L&&fwC27 z0fs8Nrs{O2hs)3yhPmmo2p$YgIXlD7s z?;zX)LhuyCiJycZ7hjNzeZj5pM4f~ej-(yOeMcf?bSyHr9gCE=q}9%j~B!a%!-G5-eIn!vR8 zJWqQEJ^J=__r8rYLZXEK`?^rr74+)apMmfNupc Should sort `dependenciesMeta` as object. + + { + input: `{␊ + "dependenciesMeta": {␊ + "z": "z",␊ + "a": "a"␊ + }␊ + }`, + options: undefined, + output: `{␊ + "dependenciesMeta": {␊ + "a": "a",␊ + "z": "z"␊ + }␊ + }`, + pretty: true, + } + +> Should sort `dependenciesMeta` as object. + + { + input: `{␊ + "dependenciesMeta": {␊ + "z": {␊ + "z": "z",␊ + "a": "a"␊ + },␊ + "a": {␊ + "z": "z",␊ + "a": "a"␊ + }␊ + }␊ + }`, + options: undefined, + output: `{␊ + "dependenciesMeta": {␊ + "a": {␊ + "a": "a",␊ + "z": "z"␊ + },␊ + "z": {␊ + "a": "a",␊ + "z": "z"␊ + }␊ + }␊ + }`, + pretty: true, + } + ## peerDependenciesMeta > Should sort `peerDependenciesMeta` as object. diff --git a/tests/snapshots/deps.js.snap b/tests/snapshots/deps.js.snap index cbfd9075491b9b8bb0ba9f13c31565b357e68ee9..41c3b101c0c49d82fa5b8aabfc5e1f3d5d24481f 100644 GIT binary patch literal 369 zcmV-%0gnDbRzV!QX&fr)P)a`CcAmIzGwh!_F?P<4j;t zB^C(2!^*(G%)k!T#mK?PY6YYnfOrlN?*d|Rpee$PY=Vqz{z+M>$t8@8aHfEO00Sd0 z10xFqBR^0LlL#X-10$;-BWq?}L1_t$XIIUoprBNcnp)(NT9BHTlA4#CnOf|dT9T+_ zr2vux%2olHKtcz?14#f0Ag7kA7R_w-{DP9q{Jdf?pPd&?mMy=ughZ>Mmg%541gq6- z1x2YPC6!<<6F;^vdko?O!)qypVaC+LKxCjnnCKyh5{5vpAcZS&8Ym8W;(UPOAe4we zi3)@ds)*J=W(>{%;%z|8Pid;R0((D&-YK4twbV@Q_ks8?5YMGFwKp&j5m__aBQ000000000Bi zU|?WiWVqulnXb`Q*Yr7Z)grlhX6;N2AYj4>!QX&fW(Ib!7$XNGs}+!T0OC17ybFlM zfog;q*#sHc{FAa$lS>#G;YXX4+3y_ diff --git a/tests/snapshots/main.js.md b/tests/snapshots/main.js.md index 5addc7cd..3d9a735b 100644 --- a/tests/snapshots/main.js.md +++ b/tests/snapshots/main.js.md @@ -32,6 +32,7 @@ Generated by [AVA](https://avajs.dev). "contributors": "contributors",␊ "cpu": "cpu",␊ "dependencies": "dependencies",␊ + "dependenciesMeta": "dependenciesMeta",␊ "description": "description",␊ "devDependencies": "devDependencies",␊ "directories": "directories",␊ @@ -165,6 +166,7 @@ Generated by [AVA](https://avajs.dev). "resolutions": "resolutions",␊ "dependencies": "dependencies",␊ "devDependencies": "devDependencies",␊ + "dependenciesMeta": "dependenciesMeta",␊ "peerDependencies": "peerDependencies",␊ "peerDependenciesMeta": "peerDependenciesMeta",␊ "optionalDependencies": "optionalDependencies",␊ diff --git a/tests/snapshots/main.js.snap b/tests/snapshots/main.js.snap index 2977e85cdd195402abe8c2e1d28a2c5a5231d9ad..14bdce16e5f5c270b9fd58729f47950b5bced461 100644 GIT binary patch delta 1166 zcmV;91abR}37H9hK~_N^Q*L2!b7*gLAa*he0syLq6n6w`%&G`ti4(f_8#*702mk;8 z00003wOGM!+%^!EoZ7Af1hJ8RfSYsk13ndLgQABt0rCL>SK`X_N~B6s>j+IQ`GDSX z?LV}C(Q}Uhdg~AL)?2BWkwi(yYvqD6@xHYCtTNKo9+Vy0`N z8VgyiZViX2wWiODZS6@7@>P=yV?7-)dQ=%stQm=sY0kgpC6_6eiJ(`O>Q1SRTYJ>xsWhh50NUjB0~kNmbF@JDobyF>A|6{^w6Qf=uuW6xB+lFT1+}w zh0i?amW{oDBToZgwhKRW>LKa-@!pLo^b^`0hHm40NV+L=R{y{Xj(QJ4=Q0zLzj7;2 zU~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