expo-codemod
Codemod scripts for Expo apps
Last updated 12 days ago by brentvatne .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install expo-codemod 
SYNC missed versions from official npm registry.

expo-codemod

expo-codemod is collection of codemods (transforms) for projects using the Expo SDK and a small command-line interface (CLI) for running the codemods.

The codemods can be used to transform JavaScript (.js, .jsx) and TypeScript (.ts, .tsx) files.

Installation

You can run expo-codemod using npx without having to install it (Node.js 8.x, 10.x or 12.x is required):

npx expo-codemod

Alternatively, you can install it globally:

npm install --global expo-codemod

(Installing with yarn global add works too.)

Usage

npx expo-codemod <transform> <paths...>
Options:
  <transform>                      (required) name of transform to apply to files
                                   (see a list of transforms available below)
  <paths...>                       one or more paths or globs (e.g. src/**/*.js) of sources to transform
                                   files in .gitignore are ignored by default
  -h, --help                       print this help message
  -p, --parser <babel|flow|ts|tsx> parser to use to parse the source files
                                   (default: babel, ts or tsx based on the file extension)

Transforms available:
  sdk33-imports
  sdk37-imports

For example, to apply the sdk33-imports transform to all source files in the src folder, run:

npx expo-codemod sdk33-imports src

You can also use glob patterns (make sure to wrap the patterns in quotes):

npx expo-codemod sdk33-imports '**/*.js' '**/*.{ts,tsx}'

Advanced usage with jscodeshift

The CLI is a wrapper over jscodeshift. If you need more fine grained control of jscodeshift or parser options, you can also use the jscodeshift CLI directly. First install expo-codemod and jscodeshift:

npm install --save-dev expo-codemod
npm install --global jscodeshift

You can pass the transform filename to jscodeshift using the --transform option, for example:

jscodeshift --transform ./node_modules/expo-codemod/build/transforms/sdk33-imports.js --no-babel --ignore-config .gitignore .

Read more about jscodeshift options here.

Troubleshooting

Custom babel.config.js not being used

As per #676 you can pass in the --parser=flow option.

Transforms

sdk33-imports

Used to migrate a project from SDK 32 to SDK 33.

Transforms imports from the expo package that were deprecated in Expo SDK 33 to imports from the individual packages.

Example

Input:

import { Accelerometer, GestureHandler, MapView } from 'expo';

Output:

import { Accelerometer } from 'expo-sensors';
import * as GestureHandler from 'react-native-gesture-handler';
import MapView from 'react-native-maps';

sdk37-imports

Used to migrate a project from SDK 36 to SDK 37.

Transforms imports of AuthSession and ScreenOrientation that were extracted out from the expo package to expo-auth-session and expo-screen-orientation packages for SDK 37.

Example

Input:

import { AuthSession, ScreenOrientation } from 'expo';

Output:

import * as AuthSession from 'expo-auth-session';
import * as ScreenOrientation from 'expo-screen-orientation';

Current Tags

  • 1.0.28                                ...           latest (12 days ago)

41 Versions

  • 1.0.28                                ...           12 days ago
  • 1.0.27                                ...           3 months ago
  • 1.0.26                                ...           3 months ago
  • 1.0.25                                ...           3 months ago
  • 1.0.24                                ...           3 months ago
  • 1.0.23                                ...           3 months ago
  • 1.0.22                                ...           3 months ago
  • 1.0.22-alpha.0                                ...           3 months ago
  • 1.0.21                                ...           3 months ago
  • 1.0.20                                ...           4 months ago
  • 1.0.19                                ...           4 months ago
  • 1.0.18                                ...           4 months ago
  • 1.0.17                                ...           4 months ago
  • 1.0.16                                ...           4 months ago
  • 1.0.15                                ...           5 months ago
  • 1.0.14                                ...           5 months ago
  • 1.0.13                                ...           5 months ago
  • 1.0.12                                ...           6 months ago
  • 1.0.11                                ...           7 months ago
  • 1.0.10                                ...           7 months ago
  • 1.0.9                                ...           8 months ago
  • 1.0.8                                ...           8 months ago
  • 1.0.7                                ...           10 months ago
  • 1.0.7-alpha.0                                ...           a year ago
  • 1.0.6                                ...           a year ago
  • 1.0.5                                ...           a year ago
  • 1.0.4                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
  • 0.0.1-beta.8                                ...           a year ago
  • 0.0.1-beta.7                                ...           a year ago
  • 0.0.1-beta.6                                ...           a year ago
  • 0.0.1-beta-6                                ...           a year ago
  • 0.0.1-beta.5                                ...           a year ago
  • 0.0.1-beta.4                                ...           a year ago
  • 0.0.1-beta.3                                ...           a year ago
  • 0.0.1-beta.2                                ...           a year ago
  • 0.0.1-beta.1                                ...           a year ago
  • 0.0.1-beta.0                                ...           a year ago

Copyright 2014 - 2016 © taobao.org |