Socket
Socket
Sign inDemoInstall

@strapi/codemods

Package Overview
Dependencies
557
Maintainers
11
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @strapi/codemods

![@strapi/codemods](./preview.png)


Version published
Weekly downloads
336
increased by63.11%
Maintainers
11
Created
Weekly downloads
 

Readme

Source

@strapi/codemods

@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

⏳ Installation

yarn add @strapi/codemods

or

npm install --save @strapi/codemods

🖐 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

yarn @strapi/codemods migrate

or

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
yarn @strapi/codemods migrate:application <path>
  • Plugin migration
yarn @strapi/codemods migrate:plugin <path> [pathForV4Plugin]

Note: if no pathForV4Plugin is provided it will be created at <path>-v4

  • Dependencies migration
yarn @strapi/codemods migrate:dependencies <path>
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.

yarn @strapi/codemods transform

or

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 🎉

FAQs

Last updated on 07 Jun 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc