Socket
Socket
Sign inDemoInstall

gatsby-codemods

Package Overview
Dependencies
Maintainers
1
Versions
280
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-codemods

Stub description for gatsby-codemods


Version published
Weekly downloads
1.8K
decreased by-16.9%
Maintainers
1
Weekly downloads
 
Created
Source

gatsby-codemods

A collection of codemod scripts for use with JSCodeshift that help migrate to newer versions of Gatsby.

Note: Codemods are designed to rewrite your project's files. Ensure you have a backup before going any further.

Setup & Run

  • Install JSCodeshift as a global module
npm install --global jscodeshift
  • Install this package
npm install gatsby-codemods@next
  • Run a transform from this package on your project
jscodeshift -t node_modules/gatsby-codemods/transforms/global-graphql-calls.js my-project

Note that jscodeshift tries to match the formatting of your existing code, but you may need to use a tool like prettier to ensure consistency after running these codemods.

Structure of a jscodeshift call:

  • jscodeshift -t <codemod-script> <path>
    • codemod-script - path to the transform file, see available scripts below
    • path - files or directory to transform, typically the path to your Gatsby project
    • use the -d option for a dry-run and use -p to print the output for comparison
    • use the --extensions option if your files have different extensions than .js (for example, --extensions js,jsx)
    • see all available jscodeshift options.

Included scripts

global-graphql-calls

Add import { graphql } from "gatsby" to files that have graphql queries in them. See the [Gatsby v2 migration guide for more details].(https://next.gatsbyjs.org/docs/migrating-from-v1-to-v2/#import-graphql-from-gatsby)

jscodeshift -t node_modules/gatsby-codemods/dist/transforms/global-graphql-calls.js <path>

More scripts

Check out issue 5038 in the Gatsby repo for additional codemod ideas.

We'd love your help with writing these!

Keywords

FAQs

Package last updated on 10 Aug 2018

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