Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/strapi/codemods
A set of scripts to help migrate Strapi plugins (and in some cases Strapi applications) from v3 to v4
https://github.com/strapi/codemods
hacktoberfest hacktoberfest2022
Last synced: 5 days ago
JSON representation
A set of scripts to help migrate Strapi plugins (and in some cases Strapi applications) from v3 to v4
- Host: GitHub
- URL: https://github.com/strapi/codemods
- Owner: strapi
- Created: 2021-10-13T16:57:08.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-02T15:52:50.000Z (about 1 year ago)
- Last Synced: 2024-08-01T16:29:00.824Z (3 months ago)
- Topics: hacktoberfest, hacktoberfest2022
- Language: JavaScript
- Homepage:
- Size: 678 KB
- Stars: 43
- Watchers: 20
- Forks: 12
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-codemods - strapi/codemods - CLI to help you migrate your Strapi applications & plugins from v3 to v4. (Misc / ant-design)
README
![@strapi/codemods](./preview.png)
# @strapi/codemods
> CLI to help you migrate your Strapi applications & plugins from v3 to v4.
## Features
- Migrate a Strapi application to v4
- Migrate a Strapi plugin to v4
- Migrate a Strapi application or a plugin's dependecies to v4## Getting started
### 🖐 Requirements
Before running any commands, be sure you have initialized a git repository, the working tree is clean, you've pushed your code to GitHub, and you are on a new branch.
### 🕹 Usage
#### Migrate
_Usage with prompt_
```bash
npx @strapi/codemods migrate
```The prompt will ask you:
- What do you want to migrate?
- `Application` (migrate folder structure + dependencies)
- `Plugin` (migrate folder structure + dependencies)
- `Dependencies` (on migrate dependencies)
- Where is the project located? (default: `./`).
- _(plugin only)_ Where do you want to create the v4 plugin_Bypass the prompt_
To bypass the prompts use one of the following commands:
- `Application` migration
```bash
npx @strapi/codemods migrate:application
```- `Plugin` migration
```bash
npx @strapi/codemods migrate:plugin [pathForV4Plugin]
```> Note: if no `pathForV4Plugin` is provided it will be created at `-v4`
- `Dependencies` migration
```bash
npx @strapi/codemods migrate:dependencies
```#### Transform
:warning: _This command will modify your source code. Be sure you have initialized a git repository, the working tree is clean, you've pushed your code to GitHub, and you are on a new branch._
```bash
npx @strapi/codemods transform
```The prompt will ask two questions:
- What kind of transformation you want to perform:
- `find` -> `findMany`: Change `find` method to `findMany`
- `strapi-some-package` -> `@strapi/some-package`: Update strapi scoped imports
- `.models` -> `.contentTypes`: Change model getters to content types
- `strapi.plugins['some-plugin']` -> `strapi.plugin('some-plugin')`: Update top level plugin getters
- `strapi.plugin('some-plugin').controllers['some-controller']` -> `strapi.plugin('some-plugin').controller('some-controller')`: Use plugin getters
- Add arrow function for service export
- Add strapi to bootstrap function params
- Where is the file(s) or folder to transform
Enjoy 🎉