1 | let messages = [];
|
2 | let packages = [];
|
3 | let namedImports = [];
|
4 | let extraInstructions = [];
|
5 | export default function deprecatedModule(message, namedImport, packageName, extraInstruction) {
|
6 | if (__DEV__) {
|
7 | messages.push(message);
|
8 | packages.push(packageName);
|
9 | namedImports.push(namedImport);
|
10 | if (extraInstruction) {
|
11 | extraInstructions.push(extraInstruction);
|
12 | }
|
13 | setTimeout(logWarning, 1000);
|
14 | }
|
15 | }
|
16 | function logWarning() {
|
17 | if (!messages.length) {
|
18 | return;
|
19 | }
|
20 | let instructions = '';
|
21 | messages = Array.from(new Set(messages));
|
22 | messages.sort();
|
23 | packages = Array.from(new Set(packages));
|
24 | packages.sort();
|
25 | namedImports = Array.from(new Set(namedImports));
|
26 | namedImports.sort();
|
27 | extraInstructions = Array.from(new Set(extraInstructions));
|
28 | extraInstructions.sort();
|
29 | instructions += namedImports.join(', ');
|
30 | instructions += `.\n\n`;
|
31 | instructions += `1. Add correct versions of these packages to your project using:\n\n`;
|
32 | instructions += ` expo install ${packages.join(' ')}\n\n`;
|
33 | instructions += ` If "install" is not recognized as an expo command, update your expo-cli installation.\n\n`;
|
34 | instructions += `2. Change your imports so they use specific packages instead of the "expo" package:\n\n`;
|
35 | messages.forEach(message => {
|
36 | instructions += ` - ${message}\n`;
|
37 | });
|
38 | if (extraInstructions.length) {
|
39 | instructions += `3. Make the following other changes:\n\n`;
|
40 | extraInstructions.forEach(instruction => {
|
41 | instructions += ` - ${instruction}\n`;
|
42 | });
|
43 | }
|
44 | instructions += '\n';
|
45 | console.log(`The following APIs have moved to separate packages and importing them from the "expo" package is deprecated: ${instructions}`);
|
46 | messages = [];
|
47 | packages = [];
|
48 | namedImports = [];
|
49 | }
|
50 |
|
\ | No newline at end of file |