feat(cloudinary): migrate sanity-plugin-cloudinary to the monorepo#970
feat(cloudinary): migrate sanity-plugin-cloudinary to the monorepo#970stipsan wants to merge 109 commits into
Conversation
…values from input component itself
…array. One action for adding mutiple assets at once, and one action to configure the setup
fix: create array if not already existing, before adding items. Fixes #1
bump sanity-secrets + sanipack versions
npx @sanity/plugin-kit@1.1.0-ecosystem-preset.7 inject --preset semver-workflow --preset renovatebot
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: ca02117 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
…-plugin-cloudinary-1e91 # Conflicts: # pnpm-lock.yaml
…-plugin-cloudinary-1e91 # Conflicts: # dev/test-studio/sanity.config.ts # knip.jsonc # pnpm-lock.yaml
…-plugin-cloudinary-1e91 # Conflicts: # README.md # dev/test-studio/package.json # knip.jsonc # pnpm-lock.yaml
…-plugin-cloudinary-1e91 # Conflicts: # dev/test-studio/sanity.config.ts # knip.jsonc
There was a problem hiding this comment.
Pull request overview
Ports sanity-plugin-cloudinary into the sanity-io/plugins monorepo, wiring it into the test studio and aligning build/lint/test setup with the monorepo toolchain.
Changes:
- Adds the
plugins/sanity-plugin-cloudinaryworkspace with monorepo config (pkg-utils build, TS/Vitest configs) and a package-exports test. - Integrates the plugin into the dev test-studio via a new
cloudinaryexample workspace module and dependency wiring. - Updates repo-level configs (README plugin list, Knip workspace entry, oxlint override) and adds a major changeset for the migration.
Reviewed changes
Copilot reviewed 31 out of 32 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Adds the Cloudinary plugin to the monorepo “Current Plugins” list. |
| pnpm-lock.yaml | Adds the new workspace and its resolved dependencies (including nanoid v4). |
| plugins/sanity-plugin-cloudinary/vitest.config.ts | Adds per-plugin Vitest config to support vitest-package-exports. |
| plugins/sanity-plugin-cloudinary/tsconfig.json | Adds typecheck TS config extending repo defaults. |
| plugins/sanity-plugin-cloudinary/tsconfig.build.json | Adds build TS config for dist compilation. |
| plugins/sanity-plugin-cloudinary/src/utils.ts | Adds Cloudinary widget loading + encoding helpers used by inputs/asset source. |
| plugins/sanity-plugin-cloudinary/src/types.ts | Adds shared types + window.cloudinary global typing. |
| plugins/sanity-plugin-cloudinary/src/schema/cloudinaryAssetDerived.ts | Adds schema type for derived transformations. |
| plugins/sanity-plugin-cloudinary/src/schema/cloudinaryAssetContextCustom.ts | Adds schema type for Cloudinary context custom fields. |
| plugins/sanity-plugin-cloudinary/src/schema/cloudinaryAssetContext.ts | Adds schema type for Cloudinary asset context wrapper. |
| plugins/sanity-plugin-cloudinary/src/schema/cloudinaryAsset.ts | Adds the main cloudinary.asset schema with custom components. |
| plugins/sanity-plugin-cloudinary/src/index.ts | Exposes plugins/schemas and registers schema + asset-source plugins. |
| plugins/sanity-plugin-cloudinary/src/index.test.ts | Adds package exports manifest snapshot test. |
| plugins/sanity-plugin-cloudinary/src/components/WidgetInput.tsx | Adds the object input UI for selecting/removing Cloudinary assets and opening config. |
| plugins/sanity-plugin-cloudinary/src/components/VideoPlayer.tsx | Adds a simple video preview player for Cloudinary video assets. |
| plugins/sanity-plugin-cloudinary/src/components/SecretsConfigView.tsx | Adds studio-secrets-based configuration UI for Cloudinary credentials. |
| plugins/sanity-plugin-cloudinary/src/components/CloudinaryInput.tsx | Adds the custom input that maps Cloudinary selections to Sanity object value patches. |
| plugins/sanity-plugin-cloudinary/src/components/AssetPreview.tsx | Adds previews for image/pdf/raw/video assets within the custom input. |
| plugins/sanity-plugin-cloudinary/src/components/AssetListFunctions.tsx | Adds array functions to “Add multiple” assets + open configuration from arrays. |
| plugins/sanity-plugin-cloudinary/src/components/AssetDiff.tsx | Adds diff preview support (incl. video) for Cloudinary assets. |
| plugins/sanity-plugin-cloudinary/src/components/asset-source/Icon.tsx | Adds the Cloudinary icon SVG used for the asset source. |
| plugins/sanity-plugin-cloudinary/src/components/asset-source/CloudinaryAssetSource.tsx | Adds the asset source dialog that embeds the Cloudinary Media Library. |
| plugins/sanity-plugin-cloudinary/README.md | Adds plugin documentation (usage/config/examples). |
| plugins/sanity-plugin-cloudinary/package.json | Adds plugin package metadata, deps/peerDeps, exports, and build scripts. |
| plugins/sanity-plugin-cloudinary/package.config.ts | Enables React Compiler + styled-components support for pkg-utils build. |
| plugins/sanity-plugin-cloudinary/CHANGELOG.md | Brings over historical changelog from the standalone repo. |
| knip.jsonc | Registers the new workspace for Knip analysis and ignores a babel-only dependency. |
| dev/test-studio/src/cloudinary/index.tsx | Adds a test-studio example schema and plugin wiring to exercise the integration. |
| dev/test-studio/sanity.config.ts | Registers the new Cloudinary example workspace plugin in the test studio. |
| dev/test-studio/package.json | Adds the Cloudinary plugin workspace dependency to the test studio. |
| .oxlintrc.json | Adds a per-plugin oxlint override for legacy unsafe assertions in this plugin. |
| .changeset/cloudinary-monorepo-transfer.md | Adds a major changeset describing the breaking changes from the monorepo migration. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export const cloudinaryAssetSourcePlugin = definePlugin({ | ||
| name: 'cloudinart-asset-source', | ||
| form: { |
| function loadJS(url: string, callback: () => void) { | ||
| const existingScript = document.getElementById('damWidget') | ||
| if (!existingScript) { | ||
| const script = document.createElement('script') | ||
| script.src = url | ||
| script.id = 'damWidget' | ||
| document.body.appendChild(script) | ||
| script.addEventListener('load', () => { | ||
| callback() | ||
| }) | ||
| } | ||
| if (existingScript && callback) { | ||
| return callback() | ||
| } | ||
| return true | ||
| } |
| const [loadingMessage, setLoadingMessage] = useState<string | undefined>( | ||
| 'Loading Cloudinary Media Libary', | ||
| ) |
| const {secrets} = useSecrets<Secrets>(namespace) | ||
| const cloudName = secrets?.cloudName | ||
| const apiKey = secrets?.apiKey | ||
| const [widgetId] = useState(() => `cloundinaryWidget-${Date.now()}`) |
|
|
||
| useEffect(() => { | ||
| // because we have to access props after loading js in a callback, | ||
| // we cannot pass props as dependecnies as that will cause infinite updates |
| import {defineConfg} from 'sanity' | ||
| import {cloudinaryImageSource} from 'sanity-plugin-cloudinary' | ||
|
|
||
| export default defineConfg({ |
| import {defineConfg} from 'sanity' | ||
| import {cloudinarySchemaPlugin} from 'sanity-plugin-cloudinary' | ||
|
|
||
| export default defineConfg({ |
| // only use clooudinary as an asset source | ||
| return [cloudinaryImageSource] | ||
| } | ||
| // dont add cloudnary as an asset sources | ||
| return previousAssetSources |
| ## Develop & test | ||
|
|
||
| This plugin uses [@sanity/plugin-kit](https://github.com/sanity-io/plugin-kit) | ||
| with default configuration for build & watch scripts. | ||
|
|
||
| See [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugin-kit#testing-a-plugin-in-sanity-studio) | ||
| on how to run this plugin with hotreload in the studio. | ||
|
|
||
| ### Release new version | ||
|
|
||
| Run ["CI & Release" workflow](https://github.com/sanity-io/sanity-plugin-cloudinary/actions/workflows/main.yml). | ||
| 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. |
| { | ||
| "name": "sanity-plugin-cloudinary", | ||
| "version": "1.4.1", | ||
| "description": "Cloudinary integration for Sanity Studio V3.", |
…-plugin-cloudinary-1e91 # Conflicts: # dev/test-studio/sanity.config.ts # knip.jsonc
…-plugin-cloudinary-1e91 # Conflicts: # dev/test-studio/sanity.config.ts # pnpm-lock.yaml
Migrate sanity-plugin-cloudinary
Transfers
sanity-plugin-cloudinaryinto the monorepo using thecopy plugingenerator (git subtree import preserving full history).Demo
cloudinary_plugin_test_studio_demo.mp4
Test-studio walkthrough: the
Cloudinarydocument type renders the custom asset input ("Select…" opens the Cloudinary config dialog), the array field exposes the "Add multiple" function, and "Cloudinary" appears as an asset source on image fields.Cloudinary document form
Changes
git subtreewith history, scaffolded monorepo config (package.json,package.config.ts,tsconfig.json,tsconfig.build.json,vitest.config.ts)@sanity/studio-secretsnow uses the in-repoworkspace:*version (v4),@sanity/uiuses the catalog (v3), dropped@sanity/incompatible-pluginReactdefault imports, replacedscript.onloadwithaddEventListener, replaced theprops as ArrayOfObjectsInputPropscast with theisArrayOfObjectsInputPropstype guard, fixed React Compiler memoization inCloudinaryInput, fixed positivetabIndex, migrated deprecatedStack spacetogap, removed stale eslint directives.oxlintrc.jsonoverride disablingno-unsafe-type-assertionfor this plugin's legacysrc/(same pattern assanity-naive-html-serializer)dev/test-studio/src/cloudinary) exercisingcloudinarySchemaPlugin(singlecloudinary.assetfield + array) andcloudinaryAssetSourcePlugin(image field asset source)Transfer verification
npm trust github sanity-plugin-cloudinary --file=release.yml --repository=sanity-io/pluginspackage.jsondependencies/peerDependencies/exports verified against original repopnpm dev)pnpm format,pnpm knip,pnpm lint,pnpm build,pnpm test runall passMaintainer follow-up
# [This plugin has moved](https://github.com/sanity-io/plugins/tree/main/plugins/sanity-plugin-cloudinary)cloudinaryTo show artifacts inline, enable in settings.