@sanity/incompatible-plugin
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

@sanity/incompatible-plugin

Small helper library that will display a warning in Sanity Studio v2 when a plugin built for Studio v3 is installed.

Installation

npm i @sanity/incompatible-plugin

or

yarn add @sanity/incompatible-plugin

Usage

In your plugin root directory, create two files:

v2-incompatible.js

const {showIncompatiblePluginDialog} = require('@sanity/incompatible-plugin')
const {name, version} = require('./package.json')

export default showIncompatiblePluginDialog({
  name: name,
  versions: {
    v3: version,
    // Optional: If there is not v2 version of your plugin, v2 can be omitted
    v2: '^1.2.5',
  },
  // Optional: Feel free to put this as field in package.json and import it alongside name and version above
  sanityExchangeUrl: 'https://www.sanity.io/plugins/<plugin-on-sanity-exchanged>',
})

sanity.json

{
  "parts": [
    {
      "implements": "part:@sanity/base/sanity-root",
      "path": "./v2-incompatible.js"
    }
  ]
}

Add these to files in the plugin package.json alongside anything else already there, for instance:

{
  "files": ["src", "lib", "v2-incompatible.js", "sanity.json"]
}

Done!

If your v3 plugin gets installed in a v2 studio by mistake, a dialog will display how to fix it.

Develop

Release new version

Run "CI & Release" workflow. Make sure to select the main branch and check "Release new version".

Semantic release will only release on configured branches, so it is safe to run release on any branch.

Readme

Keywords

Package Sidebar

Install

npm i @sanity/incompatible-plugin

Weekly Downloads

42,954

Version

1.0.4

License

MIT

Unpacked Size

28.7 kB

Total Files

15

Last publish

Collaborators

  • jordanl17
  • tambet
  • jtpetty
  • drewsanity
  • refiito
  • sergeisarviro
  • ash
  • indrek.karner
  • cngonzalez-sanity
  • rdunk
  • rneatherway-sanity
  • ricokahler
  • pedro-sanity
  • jonabc
  • kenjonespizza
  • pauloborgesf
  • binoy14
  • simen.svale
  • svirs
  • josh_sanity_io
  • joneidejohnsen
  • nina.andal
  • rankers
  • snorreeb
  • mattcraig
  • vincentquigley
  • stipsan
  • michael-sanity
  • rubioz
  • tonina
  • ritasdias
  • simeonsanity
  • kmelve
  • bjoerge
  • rexxars
  • skogsmaskin
  • robinpyon
  • mariuslundgard
  • sanity-io
  • evenw
  • radhe_sanity
  • rbotten
  • judofyr
  • obliadp
  • dcilke
  • fredcarlsen
  • hermanw
  • sgulseth
  • atombender