Socket
Socket
Sign inDemoInstall

@tramvai/tools-migrate

Package Overview
Dependencies
10
Maintainers
3
Versions
102
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tramvai/tools-migrate


Version published
Maintainers
3
Install size
23.6 MB
Created

Readme

Source

Tool for code migrations

Tool for executing code migrations for the tramvai modules.

How does it work:

  • in published module folder __migrations__ contains migrations files for the execution
  • found migrations that were have not been executed before are running
  • migrations can change files package.json, tramvai.json and project source code
  • after migration run information about executed migrations is added to file .tramvai-migrate-applied.json to the project root
  • all of the changed files after migrations should be added and committed to remote repository

How to

Disable migrations

To disable migration add environment variable SKIP_TRAMVAI_MIGRATIONS.

Add new migration

You can add new migration with command yarn generate:migration. You will need to specify package name for the migration and the migration name itself.

Also add to this package's package.json folder with the built migrations to the field files if it wasn't specified before:

"files": [
    "lib",
    "__migrations__"
],

Migration is a function that accepts special api using which it implements changes to the source code or configs.

export interface Api {
  packageJSON: PackageJSON; // object represented root package.json
  tramvaiJSON: TramvaiJSON; // object represented tramvai.json
  transform: (transformer: Transform, pathTransformer?: PathTransformer) => Promise<void>; // function that accepts transform function for `jscodeshift` and transform function for the file renames
}

Code transformations is done with jscodeshift

How to

Write migration

Transformation

Rules:

  • Prefer to return null | undefined or original source from the transform function in cases when migration doesn't change source code. Otherwise it will lead to unnecessary fs writing.
  • Prefer to use embedded methods of collections returned by call j(source) to make searches and transforms

FAQs

Last updated on 20 Oct 2023

Did you know?

Socket

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc