forked from LedgerHQ/ledger-live
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.pnpmfile.cjs
185 lines (179 loc) · 5.96 KB
/
.pnpmfile.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/**
* This file exists for the sole purpose of hijacking the packages installation process.
*
* It contains a lot of monkey patches because some packages we use have issues when declaring
* their own dependencies. It causes problems with pnpm which enforces a strict package resolution.
*
* Ideally package maintainers would update their packages and we would not need this file anymore.
* But this is world is cruel… Feel free to reach out and make PRs if you are motivated enough.
*
* See: https://pnpm.io/pnpmfile
*/
const {
process,
addDependencies,
addDevDependencies,
addPeerDependencies,
} = require("./tools/pnpm-utils");
function readPackage(pkg, context) {
const major = parseInt(
pkg.version?.replace(/(\^|~|>=|>|<=|<)/g, "").split(".")[0] || "0"
);
/*
Fix packages using wrong @types/react versions by making it a peer dependency.
So ultimately it uses our types package instead of their own which can conflict.
*/
if (
!!pkg.dependencies["@types/react"] &&
!pkg.name.startsWith("@ledgerhq") &&
!pkg.private
) {
delete pkg.dependencies["@types/react"];
pkg.peerDependencies["@types/react"] = "*";
pkg.peerDependenciesMeta = {
...pkg.peerDependenciesMeta,
"@types/react": { optional: true },
};
}
process(
[
/*
Adding jest and co. as dev. dependencies for /ledgerjs/* sub-packages.
This is done this way because these packages are not hoisted hence unaccessible otherwise.
Furthermore it makes these packages self-contained which eases the CI process.
*/
addDevDependencies(
/^@ledgerhq\/(hw-app.*|hw-transport.*|cryptoassets|devices|errors|logs|react-native-hid|react-native-hw-transport-ble|types-.*)$/,
{
jest: "^27.4.7",
"ts-jest": "^27.1.2",
"ts-node": "^10.4.0",
"@types/node": "*",
"@types/jest": "*",
"source-map-support": "*",
typescript: "^4",
documentation: "13.2.4",
},
{ silent: true }
),
/*
The following packages are broken and do not declare their dependencies properly.
So we are going to patch these until the maintainers fix their own stuff…
Feel free to make PRs if you feel like it :).
*/
/* Storybook packages */
addDependencies("@storybook/webpack-config", { "resolve-from": "*" }),
addDependencies("@storybook/addon-knobs", {
// Match the major version of the package
"@storybook/client-api": major ? "" + major : "*",
}),
/* @celo/* packages */
addDependencies(/@celo\/(?!base)+/, { "@celo/base": `^${pkg.version}` }),
addDependencies("@celo/connect", {
"@celo/base": `^${pkg.version}`,
"web3-eth-contract": pkg.peerDependencies?.web3 ?? "*",
}),
addDependencies("@celo/contractkit", {
"web3-utils": pkg.dependencies?.["web3"],
}),
addDependencies("@celo/utils", {
randombytes: "*",
rlp: "*",
}),
/* @cosmjs/* packages */
addDependencies("@cosmjs/proto-signing", {
"@cosmjs/crypto": pkg.version,
"@cosmjs/encoding": pkg.version,
"@cosmjs/utils": pkg.version,
"@cosmjs/math": pkg.version,
}),
addDependencies("@cosmjs/tendermint-rpc", {
"@cosmjs/utils": pkg.version,
}),
/* @walletconnect/* packages */
addDependencies("@walletconnect/iso-crypto", {
"@walletconnect/encoding": "*",
}),
addDependencies(/^@walletconnect\/.*/, {
tslib: "*",
}),
/* React Native and Metro bundler packages */
// Crashes ios build if removed /!\
addDependencies("react-native-codegen", {
glob: "*",
invariant: "*",
}),
// Crashes ios build if removed /!\
addDependencies("react-native", {
mkdirp: "*",
}),
addPeerDependencies("@react-native-community/cli", {
"metro-resolver": "*",
}),
addPeerDependencies("metro-config", {
"metro-transform-worker": "*",
}),
addPeerDependencies("metro-transform-worker", {
"metro-minify-uglify": "*",
}),
/* @expo/* packages */
addDependencies("@expo/webpack-config", {
"resolve-from": "*",
"fs-extra": "*",
}),
addDependencies("expo-cli", { "@expo/metro-config": "*" }),
addDependencies("@expo/metro-config", { glob: "*" }),
addDependencies("@expo/dev-tools", { "@expo/spawn-async": "*" }),
addDependencies("@expo/dev-server", {
"@expo/config": "*",
"@expo/spawn-async": "*",
glob: "*",
}),
/* Other packages */
addPeerDependencies("@svgr/core", { "@svgr/plugin-svgo": "*" }),
addDependencies("@sentry/react-native", {
tslib: "*",
promise: "*",
}),
addDependencies("react-native-text-input-mask", {
tslib: "*",
}),
addDependencies("react-native-locale", {
fbjs: "*",
}),
addPeerDependencies("any-observable", {
rxjs: "*",
}),
addPeerDependencies("@cspotcode/source-map-support", {
"source-map-support": "*",
}),
addPeerDependencies("eslint-plugin-jest", {
jest: "*",
}),
addPeerDependencies("jest-worker", {
metro: "*",
}),
// "dmg-builder" is required to build .dmg electron apps on macs,
// but is not declared as such by app-builder-lib.
// I'm not adding it as a dependency because if I did,
// then pnpm would fail on win / linux during install.
// Mildly related (error is not the same): https://github.com/pnpm/pnpm/issues/3640
addPeerDependencies("app-builder-lib", {
"dmg-builder": "*",
lodash: "*",
}),
/* Packages that are missing @types/* dependencies */
addPeerDependencies("react-native-gesture-handler", {
"@types/react": "*",
}),
],
pkg,
context
);
return pkg;
}
module.exports = {
hooks: {
readPackage,
},
};