Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tramvai/tools-migrate

Package Overview
Dependencies
Maintainers
0
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tramvai/tools-migrate

Tool for executing code migrations for the tramvai modules.

  • 0.8.3
  • npm
  • Socket score

Version published
Weekly downloads
703
increased by11.94%
Maintainers
0
Weekly downloads
 
Created
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

Package last updated on 08 Jul 2024

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc