### Install jscodeshift Toolkit Source: https://github.com/minhna/meteor-async-migration/blob/main/README.md Instructions to install the jscodeshift command-line tool globally, which is a prerequisite for running the Meteor migration transforms. ```bash sudo npm install -g jscodeshift ``` -------------------------------- ### Run Migration Transforms Against Sample Files Source: https://github.com/minhna/meteor-async-migration/blob/main/README.md Commands to execute the migration transforms against predefined sample files for testing and debugging purposes. ```bash npm run debug:samples npm run debug:sample:methods npm run debug:sample:publications npm run debug:sample:utils npm run debug:handle-async-import:samples ``` -------------------------------- ### Configure and Run Transforms on Your Codebase Source: https://github.com/minhna/meteor-async-migration/blob/main/README.md Before running the transforms on your own codebase, you may need to modify the `METEOR_ROOT_DIRECTORY` value in `constants.ts` to match your project structure. It is recommended to use `--dry -p` options for testing before applying changes. ```TypeScript constants.ts, modify the `METEOR_ROOT_DIRECTORY` value. ``` ```bash jscodeshift --dry -p YOUR_CODEBASE_DIR ``` -------------------------------- ### Convert Sync Meteor APIs to Async/Await Source: https://github.com/minhna/meteor-async-migration/blob/main/README.md This transform converts synchronous Meteor API calls (e.g., `Links.findOne()`) to their new asynchronous counterparts (e.g., `await Links.findOneAsync()`). It also modifies parent functions to become `async` if they use these new APIs. This script should only be run against server-side APIs. ```TypeScript Transform file: transform.ts ``` ```bash DEBUG="transform:print*" jscodeshift -t transform.ts YOUR_CODEBASE_DIR --parser=tsx ``` -------------------------------- ### Convert Meteor.call to Meteor.callAsync Source: https://github.com/minhna/meteor-async-migration/blob/main/README.md This script finds `Meteor.call()` invocations that lack a callback argument and are not followed by a `.then()` expression, converting them to `await Meteor.callAsync()`. It also updates the parent function to be `async`. Running transforms #2 and #3 again after this is recommended. ```TypeScript Transform file: transform-meteor-call.ts ``` ```bash DEBUG="transform:print*" jscodeshift -t transform-meteor-call.ts YOUR_CODEBASE_DIR --parser=tsx ``` -------------------------------- ### Handle Async Function Exports and Imports Source: https://github.com/minhna/meteor-async-migration/blob/main/README.md This transform addresses async functions that are exported. It scans the codebase to find all imports of such functions, adds `await` expressions to their calls, and converts the calling functions to `async`. This script may need to be run multiple times until no more files are modified. ```TypeScript Transform file: transform-export-async-function.ts ``` ```bash DEBUG="transform:print*" jscodeshift -t transform-export-async-function.ts YOUR_CODEBASE_DIR --parser=tsx ``` -------------------------------- ### Handle Async Functions in React withTracker HOC Source: https://github.com/minhna/meteor-async-migration/blob/main/README.md For React components wrapped with `withTracker`, this script finds async functions within the `withTracker` function prop and applies necessary async/await transformations to the wrapped component. Running transform #2 after this is recommended. ```TypeScript Transform file: transform-component-props-withTracker.ts ``` ```bash DEBUG="transform:print*" jscodeshift -t transform-component-props-withTracker.ts YOUR_CODEBASE_DIR --parser=tsx ``` -------------------------------- ### Scan and Add Await to Async Function Usages Source: https://github.com/minhna/meteor-async-migration/blob/main/README.md After converting sync functions to async, this script identifies where these new async functions are called and automatically adds the `await` keyword. It also converts functions containing `await` expressions into `async` functions. This script may need to be run multiple times until no more files are modified. ```TypeScript Transform file: transform-use-async-functions.ts ``` ```bash DEBUG="transform:print*" jscodeshift -t transform-use-async-functions.ts YOUR_CODEBASE_DIR --parser=tsx ``` -------------------------------- ### Handle Async Functions in React Component Props Source: https://github.com/minhna/meteor-async-migration/blob/main/README.md This transform identifies async functions passed as props to React Components and adds `async`/`await` expressions where necessary. It also supports child components and simple React Context usages. Running transform #2 again after this is recommended. ```TypeScript Transform file: transform-component-props.ts ``` ```bash DEBUG="transform:print*" jscodeshift -t transform-component-props.ts YOUR_CODEBASE_DIR --parser=tsx ``` -------------------------------- ### Additional Utility Transforms Source: https://github.com/minhna/meteor-async-migration/blob/main/README.md A collection of supplementary jscodeshift transforms designed to address specific issues encountered during the migration process, such as renaming functions, removing unnecessary `async` keywords, identifying `await` expressions in non-async functions, and finding `Promise.all` used with `forEach`. ```TypeScript - Rename function: transform-rename-functions.ts - Remove `async` from function which doesn't have `await` expression inside: transform-fix-async-overly.ts - Find `await` expression inside a NOT async function: transform-find-await-without-async.ts - `Promise.all` doesn't work with `forEach`. This transform find all of them: transform-find-promise-all-foreach.ts ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.