expo-codemod 1.1.6 → 56.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +75 -102
- package/bin/expo-codemod.js +1 -6
- package/build/index.d.ts +1 -0
- package/build/index.js +70 -0
- package/build/index.js.map +1 -0
- package/build/log.d.ts +6 -0
- package/build/log.js +41 -0
- package/build/log.js.map +1 -0
- package/build/run/index.d.ts +17 -0
- package/build/run/index.js +136 -0
- package/build/run/index.js.map +1 -0
- package/build/transforms/index.d.ts +3 -0
- package/build/transforms/index.js +23 -0
- package/build/transforms/index.js.map +1 -0
- package/build/transforms/sdk-56-expo-router-react-navigation-replace.d.ts +14 -0
- package/build/transforms/sdk-56-expo-router-react-navigation-replace.js +106 -0
- package/build/transforms/sdk-56-expo-router-react-navigation-replace.js.map +1 -0
- package/build/utils/args.d.ts +3 -0
- package/build/utils/args.js +73 -0
- package/build/utils/args.js.map +1 -0
- package/build/utils/runner.d.ts +7 -0
- package/build/utils/runner.js +23 -0
- package/build/utils/runner.js.map +1 -0
- package/package.json +34 -24
- package/build/cli.d.ts +0 -1
- package/build/cli.js +0 -106
- package/build/cli.js.map +0 -1
- package/build/transforms/sdk33-imports.d.ts +0 -2
- package/build/transforms/sdk33-imports.js +0 -174
- package/build/transforms/sdk33-imports.js.map +0 -1
- package/build/transforms/sdk37-imports.d.ts +0 -2
- package/build/transforms/sdk37-imports.js +0 -66
- package/build/transforms/sdk37-imports.js.map +0 -1
- package/build/transforms/sdk41-async-storage.d.ts +0 -2
- package/build/transforms/sdk41-async-storage.js +0 -47
- package/build/transforms/sdk41-async-storage.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdk33-imports.js","sourceRoot":"","sources":["../../src/transforms/sdk33-imports.ts"],"names":[],"mappings":";;AAaA,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC3B,CAAC,eAAe,EAAE,cAAc,CAAC;IACjC,CAAC,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S,CAAC,IAAI,KAAK,iBAAiB,IAAI,SAAS,CAAC,IAAI,KAAK,wBAAwB,CACtF,CAAA,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,YAAY,CACnB,SAA8E;IAE9E,IAAI,SAAS,CAAC,KAAK,EAAE;QACnB,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;KAC7B;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,gBAAgB,CACvB,CAAsE,EACtE,CAAsE;IAEtE,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AAC9D,CAAC","sourcesContent":["import {\n API,\n FileInfo,\n Identifier,\n ImportDeclaration,\n ImportDefaultSpecifier,\n ImportNamespaceSpecifier,\n ImportSpecifier,\n JSCodeshift,\n JSXIdentifier,\n TSTypeParameter,\n} from 'jscodeshift';\n\nconst namedImports = new Map([\n ['Accelerometer', 'expo-sensors'],\n ['AdMobBanner', 'expo-ads-admob'],\n ['AdMobInterstitial', 'expo-ads-admob'],\n ['AdMobRewarded', 'expo-ads-admob'],\n ['Asset', 'expo-asset'],\n ['Audio', 'expo-av'],\n ['BarCodeScanner', 'expo-barcode-scanner'],\n ['Barometer', 'expo-sensors'],\n ['BlurView', 'expo-blur'],\n ['Camera', 'expo-camera'],\n ['GLView', 'expo-gl'],\n ['Gyroscope', 'expo-sensors'],\n ['LinearGradient', 'expo-linear-gradient'],\n ['Magnetometer', 'expo-sensors'],\n ['MagnetometerUncalibrated', 'expo-sensors'],\n ['PublisherBanner', 'expo-ads-admob'],\n ['SQLite', 'expo-sqlite'],\n ['Video', 'expo-av'],\n ['WebView', 'react-native-webview'],\n]);\n\nconst defaultImports = new Map([\n ['Constants', 'expo-constants'],\n ['KeepAwake', 'expo-keep-awake'],\n ['MapView', 'react-native-maps'],\n]);\n\nconst namespaceImports = new Map([\n ['Amplitude', 'expo-analytics-amplitude'],\n ['AppAuth', 'expo-app-auth'],\n ['BackgroundFetch', 'expo-background-fetch'],\n ['Brightness', 'expo-brightness'],\n ['Calendar', 'expo-calendar'],\n ['Contacts', 'expo-contacts'],\n ['Crypto', 'expo-crypto'],\n ['DocumentPicker', 'expo-document-picker'],\n ['Facebook', 'expo-facebook'],\n ['FacebookAds', 'expo-ads-facebook'],\n ['FaceDetector', 'expo-face-detector'],\n ['FileSystem', 'expo-file-system'],\n ['Font', 'expo-font'],\n ['GestureHandler', 'react-native-gesture-handler'],\n ['GL', 'expo-gl'],\n ['GoogleSignIn', 'expo-google-sign-in'],\n ['Haptic', 'expo-haptics'],\n ['Haptics', 'expo-haptics'],\n ['Icon', '@expo/vector-icons'],\n ['ImageManipulator', 'expo-image-manipulator'],\n ['ImagePicker', 'expo-image-picker'],\n ['IntentLauncher', 'expo-intent-launcher'],\n ['IntentLauncherAndroid', 'expo-intent-launcher'],\n ['LocalAuthentication', 'expo-local-authentication'],\n ['Localization', 'expo-localization'],\n ['Location', 'expo-location'],\n ['MailComposer', 'expo-mail-composer'],\n ['MediaLibrary', 'expo-media-library'],\n ['Permissions', 'expo-permissions'],\n ['Print', 'expo-print'],\n ['Random', 'expo-random'],\n ['SecureStore', 'expo-secure-store'],\n ['Segment', 'expo-analytics-segment'],\n ['Sensors', 'expo-sensors'],\n ['Sharing', 'expo-sharing'],\n ['SMS', 'expo-sms'],\n ['Speech', 'expo-speech'],\n ['Svg', 'react-native-svg'],\n ['TaskManager', 'expo-task-manager'],\n ['WebBrowser', 'expo-web-browser'],\n]);\n\nconst allDeprecatedImports = new Map();\nfor (const [name, packageName] of namedImports) {\n allDeprecatedImports.set(name, { type: 'ImportSpecifier', packageName });\n}\nfor (const [name, packageName] of defaultImports) {\n allDeprecatedImports.set(name, { type: 'ImportDefaultSpecifier', packageName });\n}\nfor (const [name, packageName] of namespaceImports) {\n allDeprecatedImports.set(name, { type: 'ImportNamespaceSpecifier', packageName });\n}\n\nexport default function transform(fileInfo: FileInfo, api: API, options: object) {\n const j = api.jscodeshift;\n const root = j(fileInfo.source);\n const getFirstNode = () => root.find(j.Program).get('body', 0).node;\n const originalFirstNode = getFirstNode();\n const originalComments = originalFirstNode.comments;\n\n // import { Name } from 'expo';\n const expoImports = root\n .find(j.ImportDeclaration)\n .filter(path => path.node.source.value === 'expo');\n\n const importedModules: Map<\n string,\n Identifier | JSXIdentifier | TSTypeParameter | null\n > = new Map();\n\n expoImports\n .find(j.ImportSpecifier)\n .filter(p => allDeprecatedImports.has(p.node.imported.name))\n .forEach(path => {\n const importedName = path.node.imported.name;\n const local = path.node.local;\n importedModules.set(importedName, local ?? null);\n j(path).remove();\n });\n\n // import * as Expo from 'expo';\n expoImports.find(j.ImportNamespaceSpecifier).forEach(path => {\n if (path.node.local == null) return;\n\n const expoNamespace = path.node.local.name;\n root\n .find(j.MemberExpression)\n .filter(\n p =>\n (p.node.object.type === 'Identifier' || p.node.object.type === 'JSXIdentifier') &&\n (p.node.property.type === 'Identifier' || p.node.property.type === 'JSXIdentifier') &&\n p.node.object.name === expoNamespace &&\n allDeprecatedImports.has(p.node.property.name)\n )\n .forEach(p => {\n const property = p.node.property as Identifier | JSXIdentifier;\n const importedName = property.name;\n importedModules.set(importedName, null);\n p.replace(property);\n });\n });\n\n for (let [importedName, local] of importedModules.entries()) {\n local = local || j.identifier(importedName);\n const info = allDeprecatedImports.get(importedName);\n if (!info) {\n return;\n }\n api.stats(info.packageName);\n\n let specifier;\n if (info.type === 'ImportSpecifier') {\n specifier = j.importSpecifier(j.identifier(importedName), local);\n } else if (info.type === 'ImportDefaultSpecifier') {\n specifier = j.importDefaultSpecifier(local);\n } else {\n specifier = j.importNamespaceSpecifier(local);\n }\n\n const existingImports = findNonNamespaceImports(j, root, info.packageName);\n if (existingImports.size() && specifier.type !== 'ImportNamespaceSpecifier') {\n const specifiers = existingImports.get(0).node.specifiers;\n specifiers.push(specifier);\n specifiers.sort(specifierCompare);\n } else {\n const newImport = j.importDeclaration([specifier], j.literal(info.packageName));\n expoImports.insertAfter(newImport);\n }\n }\n\n const emptyImports = expoImports.filter(path => path.node.specifiers?.length === 0);\n emptyImports.remove();\n // If the first node has been modified or deleted, reattach the comments\n const firstNode = getFirstNode();\n if (firstNode !== originalFirstNode) {\n firstNode.comments = originalComments;\n }\n\n return root.toSource({ quote: 'single' });\n}\n\nfunction findNonNamespaceImports(j: JSCodeshift, root: any, sourceName: string) {\n return root.find(j.ImportDeclaration).filter((path: any) => {\n const node = path.node as ImportDeclaration;\n return (\n node.source.value === sourceName &&\n node.specifiers?.some(\n specifier =>\n specifier.type === 'ImportSpecifier' || specifier.type === 'ImportDefaultSpecifier'\n )\n );\n });\n}\n\nfunction sortableName(\n specifier: ImportSpecifier | ImportNamespaceSpecifier | ImportDefaultSpecifier\n) {\n if (specifier.local) {\n return specifier.local.name;\n }\n return '';\n}\n\nfunction specifierCompare(\n a: ImportSpecifier | ImportNamespaceSpecifier | ImportDefaultSpecifier,\n b: ImportSpecifier | ImportNamespaceSpecifier | ImportDefaultSpecifier\n) {\n return sortableName(a).localeCompare(sortableName(b), 'en');\n}\n"]}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const allDeprecatedImports = new Map([
|
|
4
|
-
['AuthSession', { packageName: 'expo-auth-session' }],
|
|
5
|
-
['ScreenOrientation', { packageName: 'expo-screen-orientation' }],
|
|
6
|
-
]);
|
|
7
|
-
function transform(fileInfo, api, options) {
|
|
8
|
-
const j = api.jscodeshift;
|
|
9
|
-
const root = j(fileInfo.source);
|
|
10
|
-
const getFirstNode = () => root.find(j.Program).get('body', 0).node;
|
|
11
|
-
const originalFirstNode = getFirstNode();
|
|
12
|
-
const originalComments = originalFirstNode.comments;
|
|
13
|
-
// import { Name } from 'expo';
|
|
14
|
-
const expoImports = root
|
|
15
|
-
.find(j.ImportDeclaration)
|
|
16
|
-
.filter(path => path.node.source.value === 'expo');
|
|
17
|
-
const importedModules = new Map();
|
|
18
|
-
expoImports
|
|
19
|
-
.find(j.ImportSpecifier)
|
|
20
|
-
.filter(p => allDeprecatedImports.has(p.node.imported.name))
|
|
21
|
-
.forEach(path => {
|
|
22
|
-
const importedName = path.node.imported.name;
|
|
23
|
-
const local = path.node.local;
|
|
24
|
-
importedModules.set(importedName, local !== null && local !== void 0 ? local : null);
|
|
25
|
-
j(path).remove();
|
|
26
|
-
});
|
|
27
|
-
// import * as Expo from 'expo';
|
|
28
|
-
expoImports.find(j.ImportNamespaceSpecifier).forEach(path => {
|
|
29
|
-
if (path.node.local == null)
|
|
30
|
-
return;
|
|
31
|
-
const expoNamespace = path.node.local.name;
|
|
32
|
-
root
|
|
33
|
-
.find(j.MemberExpression)
|
|
34
|
-
.filter(p => (p.node.object.type === 'Identifier' || p.node.object.type === 'JSXIdentifier') &&
|
|
35
|
-
(p.node.property.type === 'Identifier' || p.node.property.type === 'JSXIdentifier') &&
|
|
36
|
-
p.node.object.name === expoNamespace &&
|
|
37
|
-
allDeprecatedImports.has(p.node.property.name))
|
|
38
|
-
.forEach(p => {
|
|
39
|
-
const property = p.node.property;
|
|
40
|
-
const importedName = property.name;
|
|
41
|
-
importedModules.set(importedName, null);
|
|
42
|
-
p.replace(property);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
for (let [importedName, local] of [...importedModules.entries()].reverse()) {
|
|
46
|
-
local = local || j.identifier(importedName);
|
|
47
|
-
const info = allDeprecatedImports.get(importedName);
|
|
48
|
-
if (!info) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
api.stats(info.packageName);
|
|
52
|
-
const specifier = j.importNamespaceSpecifier(local);
|
|
53
|
-
const newImport = j.importDeclaration([specifier], j.literal(info.packageName));
|
|
54
|
-
expoImports.insertAfter(newImport);
|
|
55
|
-
}
|
|
56
|
-
const emptyImports = expoImports.filter(path => { var _a; return ((_a = path.node.specifiers) === null || _a === void 0 ? void 0 : _a.length) === 0; });
|
|
57
|
-
emptyImports.remove();
|
|
58
|
-
// If the first node has been modified or deleted, reattach the comments
|
|
59
|
-
const firstNode = getFirstNode();
|
|
60
|
-
if (firstNode !== originalFirstNode) {
|
|
61
|
-
firstNode.comments = originalComments;
|
|
62
|
-
}
|
|
63
|
-
return root.toSource({ quote: 'single' });
|
|
64
|
-
}
|
|
65
|
-
exports.default = transform;
|
|
66
|
-
//# sourceMappingURL=sdk37-imports.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdk37-imports.js","sourceRoot":"","sources":["../../src/transforms/sdk37-imports.ts"],"names":[],"mappings":";;AAEA,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,CAAC,aAAa,EAAE,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC;IACrD,CAAC,mBAAmB,EAAE,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAC;CAClE,CAAC,CAAC;AAEH,SAAwB,SAAS,CAAC,QAAkB,EAAE,GAAQ,EAAE,OAAe;IAC7E,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAC;IAC1B,MAAM,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAChC,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACpE,MAAM,iBAAiB,GAAG,YAAY,EAAE,CAAC;IACzC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,QAAQ,CAAC;IAEpD,+BAA+B;IAC/B,MAAM,WAAW,GAAG,IAAI;SACrB,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC;SACzB,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC;IAErD,MAAM,eAAe,G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AAM,SAAS,GAAG,YAAY,EAAE,CAAC;IACjC,IAAI,SAAS,KAAK,iBAAiB,EAAE;QACnC,SAAS,CAAC,QAAQ,GAAG,gBAAgB,CAAC;KACvC;IAED,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC5C,CAAC;AAvED,4BAuEC","sourcesContent":["import { API, FileInfo, Identifier, JSXIdentifier, TSTypeParameter } from 'jscodeshift';\n\nconst allDeprecatedImports = new Map([\n ['AuthSession', { packageName: 'expo-auth-session' }],\n ['ScreenOrientation', { packageName: 'expo-screen-orientation' }],\n]);\n\nexport default function transform(fileInfo: FileInfo, api: API, options: object) {\n const j = api.jscodeshift;\n const root = j(fileInfo.source);\n const getFirstNode = () => root.find(j.Program).get('body', 0).node;\n const originalFirstNode = getFirstNode();\n const originalComments = originalFirstNode.comments;\n\n // import { Name } from 'expo';\n const expoImports = root\n .find(j.ImportDeclaration)\n .filter(path => path.node.source.value === 'expo');\n\n const importedModules: Map<\n string,\n Identifier | JSXIdentifier | TSTypeParameter | null\n > = new Map();\n\n expoImports\n .find(j.ImportSpecifier)\n .filter(p => allDeprecatedImports.has(p.node.imported.name))\n .forEach(path => {\n const importedName = path.node.imported.name;\n const local = path.node.local;\n importedModules.set(importedName, local ?? null);\n j(path).remove();\n });\n\n // import * as Expo from 'expo';\n expoImports.find(j.ImportNamespaceSpecifier).forEach(path => {\n if (path.node.local == null) return;\n\n const expoNamespace = path.node.local.name;\n root\n .find(j.MemberExpression)\n .filter(\n p =>\n (p.node.object.type === 'Identifier' || p.node.object.type === 'JSXIdentifier') &&\n (p.node.property.type === 'Identifier' || p.node.property.type === 'JSXIdentifier') &&\n p.node.object.name === expoNamespace &&\n allDeprecatedImports.has(p.node.property.name)\n )\n .forEach(p => {\n const property = p.node.property as Identifier | JSXIdentifier;\n const importedName = property.name;\n importedModules.set(importedName, null);\n p.replace(property);\n });\n });\n\n for (let [importedName, local] of [...importedModules.entries()].reverse()) {\n local = local || j.identifier(importedName);\n const info = allDeprecatedImports.get(importedName);\n if (!info) {\n return;\n }\n api.stats(info.packageName);\n\n const specifier = j.importNamespaceSpecifier(local);\n const newImport = j.importDeclaration([specifier], j.literal(info.packageName));\n expoImports.insertAfter(newImport);\n }\n\n const emptyImports = expoImports.filter(path => path.node.specifiers?.length === 0);\n emptyImports.remove();\n // If the first node has been modified or deleted, reattach the comments\n const firstNode = getFirstNode();\n if (firstNode !== originalFirstNode) {\n firstNode.comments = originalComments;\n }\n\n return root.toSource({ quote: 'single' });\n}\n"]}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function renameImportSource(node) {
|
|
4
|
-
if (node != null &&
|
|
5
|
-
'value' in node &&
|
|
6
|
-
typeof node.value === 'string' &&
|
|
7
|
-
(node.value === '@react-native-community/async-storage' ||
|
|
8
|
-
node.value.startsWith('@react-native-community/async-storage/'))) {
|
|
9
|
-
node.value = node.value.replace('@react-native-community/async-storage', '@react-native-async-storage/async-storage');
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
function transform(fileInfo, api) {
|
|
13
|
-
const j = api.jscodeshift;
|
|
14
|
-
const root = j(fileInfo.source);
|
|
15
|
-
// import AsyncStorage from '@react-native-community/async-storage';
|
|
16
|
-
root.find(j.ImportDeclaration).forEach(path => {
|
|
17
|
-
renameImportSource(path.node.source);
|
|
18
|
-
});
|
|
19
|
-
// export default from '@react-native-community/async-storage/jest/async-storage-mock';
|
|
20
|
-
root.find(j.ExportNamedDeclaration).forEach(path => {
|
|
21
|
-
renameImportSource(path.node.source);
|
|
22
|
-
});
|
|
23
|
-
// require('@react-native-community/async-storage');
|
|
24
|
-
root
|
|
25
|
-
.find(j.CallExpression, {
|
|
26
|
-
type: 'CallExpression',
|
|
27
|
-
callee: { name: 'require' },
|
|
28
|
-
})
|
|
29
|
-
.forEach(path => renameImportSource(path.node));
|
|
30
|
-
// jest.mock('@react-native-community/async-storage', () => mockAsyncStorage);
|
|
31
|
-
root
|
|
32
|
-
.find(j.CallExpression, {
|
|
33
|
-
type: 'CallExpression',
|
|
34
|
-
callee: {
|
|
35
|
-
type: 'MemberExpression',
|
|
36
|
-
object: { type: 'Identifier', name: 'jest' },
|
|
37
|
-
property: {
|
|
38
|
-
type: 'Identifier',
|
|
39
|
-
name: 'mock',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
})
|
|
43
|
-
.forEach(path => renameImportSource(path.node.arguments[0]));
|
|
44
|
-
return root.toSource({ quote: 'single' });
|
|
45
|
-
}
|
|
46
|
-
exports.default = transform;
|
|
47
|
-
//# sourceMappingURL=sdk41-async-storage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdk41-async-storage.js","sourceRoot":"","sources":["../../src/transforms/sdk41-async-storage.ts"],"names":[],"mappings":";;AAEA,SAAS,kBAAkB,CAAC,IAAqB;IAC/C,IACE,IAAI,IAAI,IAAI;QACZ,OAAO,IAAI,IAAI;QACf,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ;QAC9B,CAAC,IAAI,CAAC,KAAK,KAAK,uCAAuC;YACrD,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,wCAAwC,CAAC,CAAC,EAClE;QACA,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAC7B,uCAAuC,EACvC,2CAA2C,CAC5C,CAAC;KACH;AACH,CAAC;AAED,SAAwB,SAAS,CAAC,QAAkB,EAAE,GAAQ;IAC5D,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAC;IAC1B,MAAM,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAEhC,oEAAoE;IACpE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC5C,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,uFAAuF;IACvF,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACjD,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,oDAAoD;IACpD,IAAI;SACD,IAAI,CAAC,CAAC,CAAC,cAAc,EAAE;QACtB,IAAI,EAAE,gBAAgB;QACtB,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;KAC5B,CAAC;SACD,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAElD,8EAA8E;IAC9E,IAAI;SACD,IAAI,CAAC,CAAC,CAAC,cAAc,EAAE;QACtB,IAAI,EAAE,gBAAgB;QACtB,MAAM,EAAE;YACN,IAAI,EAAE,kBAAkB;YACxB,MAAM,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE;YAC5C,QAAQ,EAAE;gBACR,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,MAAM;aACb;SACF;KACF,CAAC;SACD,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE/D,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC5C,CAAC;AAtCD,4BAsCC","sourcesContent":["import { API, ASTNode, FileInfo } from 'jscodeshift';\n\nfunction renameImportSource(node?: ASTNode | null) {\n if (\n node != null &&\n 'value' in node &&\n typeof node.value === 'string' &&\n (node.value === '@react-native-community/async-storage' ||\n node.value.startsWith('@react-native-community/async-storage/'))\n ) {\n node.value = node.value.replace(\n '@react-native-community/async-storage',\n '@react-native-async-storage/async-storage'\n );\n }\n}\n\nexport default function transform(fileInfo: FileInfo, api: API) {\n const j = api.jscodeshift;\n const root = j(fileInfo.source);\n\n // import AsyncStorage from '@react-native-community/async-storage';\n root.find(j.ImportDeclaration).forEach(path => {\n renameImportSource(path.node.source);\n });\n\n // export default from '@react-native-community/async-storage/jest/async-storage-mock';\n root.find(j.ExportNamedDeclaration).forEach(path => {\n renameImportSource(path.node.source);\n });\n\n // require('@react-native-community/async-storage');\n root\n .find(j.CallExpression, {\n type: 'CallExpression',\n callee: { name: 'require' },\n })\n .forEach(path => renameImportSource(path.node));\n\n // jest.mock('@react-native-community/async-storage', () => mockAsyncStorage);\n root\n .find(j.CallExpression, {\n type: 'CallExpression',\n callee: {\n type: 'MemberExpression',\n object: { type: 'Identifier', name: 'jest' },\n property: {\n type: 'Identifier',\n name: 'mock',\n },\n },\n })\n .forEach(path => renameImportSource(path.node.arguments[0]));\n\n return root.toSource({ quote: 'single' });\n}\n"]}
|