Skip to content

feat(sanity-plugin-studio-smartling): migrate plugin to monorepo#975

Draft
stipsan wants to merge 63 commits into
mainfrom
cursor/migrate-studio-smartling-ebcf
Draft

feat(sanity-plugin-studio-smartling): migrate plugin to monorepo#975
stipsan wants to merge 63 commits into
mainfrom
cursor/migrate-studio-smartling-ebcf

Conversation

@stipsan

@stipsan stipsan commented Jun 12, 2026

Copy link
Copy Markdown
Member

Migrate sanity-plugin-studio-smartling

Ports sanity-plugin-studio-smartling into the monorepo using the pnpm generate "copy plugin" workflow, with full git history imported via git subtree.

Changes

  • Import source via git subtree from sanity-io/sanity-plugin-studio-smartling (history preserved)
  • Scaffold monorepo config (package.json, package.config.ts, tsconfig.json, tsconfig.build.json, vitest.config.ts) and package-exports test
  • Point sanity-translations-tab at the workspace package and add styled-components peer/dev dependency (required by sanity-translations-tab)
  • Restore the original docs/ folder (FAQ + advanced configuration) and original README.md; replace the broken npm description (!smartling gif) with a real one
  • oxlint compliance: type-only imports, Record<string, string> instead of a shadowing Headers interface, guard for indexed access in getTranslationTask, remove stale eslint-disable comments and a console.info debug log
  • Replace Buffer.from(content) + Blob with a native new Blob([content]) in the batch upload path, removing the undeclared buffer dependency (identical UTF-8 output, browser-safe)
  • Add Smartling test-studio example (dev/test-studio/src/smartling/index.tsx) wired as a dedicated smartling-example workspace, mirroring the Transifex example
  • Add major changeset, knip workspace entry, and root README.md plugins table row

Demo

Test studio (pnpm dev), Smartling workspace — document form and the Smartling TranslationsTab view rendering on a test document:

smartling_translations_tab_demo.mp4

Smartling tab in test studio

Transfer verification

  • Trusted publishing configured: npm trust github sanity-plugin-studio-smartling --file=release.yml --repository=sanity-io/plugins
  • package.json dependencies/peerDependencies/exports verified against original repo
  • Test studio example wired and manually verified (pnpm dev)
  • pnpm format, pnpm knip, pnpm lint, pnpm build, pnpm test run all pass
  • Major changeset added with validated breaking changes (vs npm@4.3.3: ESM-only, React 19.2+, react-dom peer, Sanity v5+, Node 20.19+, styled-components peer, React Compiler)

Maintainer follow-up

To show artifacts inline, enable in settings.

Open in Web Open in Cursor 

cngonzalez and others added 30 commits June 27, 2021 16:49
update dependency versions and change createTask flow
* fixes from in-studio testing

* null handling in item progress

* update versions
* Use machine translation workflow when requested

Add optional `isWorkflowMT` boolean param to `createJobBatch` method.
If `true`, pass `localeWorkflows` param with POST request, containing
an array with an object for each locale that has the locale id string
and the workflowUid for machine testing workflow in the AT project.
This param is not necessary if we want to keep the default workflow for
each locale, so only include if `isWorkflowMT` is true.

I couldn't find a way to fetch the workflowUids from the API, but they
can be found on the project dashboard under Project Settings > Workflows,
then clicking "Edit workflow Settings." Looks like uid is the same
across an account/project, so we _can_ use the same one, but I left it
out of this commit in case it should be kept private.
Next iteration will include updating the translations tab config to
include `options`, which could either accept one uid for MT or possibly
and array of workflow names + id's to allow selecting from a custom set
of workflows. This way we can set the ID from each project, instead of
in the plugin.

* Use workflowUid to create task with workflow

Along with updates to translations-tab, use an optional workflowUid (if
present) passed in by the user to set the workflow on task creation,
rather than hard-coding the specific uid string for the machine
translation workflow.

Dev can pass an optional array of `workflowOptions` in the options
config that's sent to `TranslationsTab`, enabling a select option in
the tab for choosing a workflow and passing in `workflowUid` with the
`createTask` params here.

Example:
```
const myCustomConfig = {
  ...defaultFieldLevelConfig,
  workflowOptions: [
    { workflowUid: '35cdc9b707d9', workflowName: 'Machine Translation (testing)' }
  ]
}
```
* version bump to reflect workflow changes

* up serializer version
* Use machine translation workflow when requested

Add optional `isWorkflowMT` boolean param to `createJobBatch` method.
If `true`, pass `localeWorkflows` param with POST request, containing
an array with an object for each locale that has the locale id string
and the workflowUid for machine testing workflow in the AT project.
This param is not necessary if we want to keep the default workflow for
each locale, so only include if `isWorkflowMT` is true.

I couldn't find a way to fetch the workflowUids from the API, but they
can be found on the project dashboard under Project Settings > Workflows,
then clicking "Edit workflow Settings." Looks like uid is the same
across an account/project, so we _can_ use the same one, but I left it
out of this commit in case it should be kept private.
Next iteration will include updating the translations tab config to
include `options`, which could either accept one uid for MT or possibly
and array of workflow names + id's to allow selecting from a custom set
of workflows. This way we can set the ID from each project, instead of
in the plugin.

* Use workflowUid to create task with workflow

Along with updates to translations-tab, use an optional workflowUid (if
present) passed in by the user to set the workflow on task creation,
rather than hard-coding the specific uid string for the machine
translation workflow.

Dev can pass an optional array of `workflowOptions` in the options
config that's sent to `TranslationsTab`, enabling a select option in
the tab for choosing a workflow and passing in `workflowUid` with the
`createTask` params here.

Example:
```
const myCustomConfig = {
  ...defaultFieldLevelConfig,
  workflowOptions: [
    { workflowUid: '35cdc9b707d9', workflowName: 'Machine Translation (testing)' }
  ]
}
```

* Handle errors; await for finished promises

There are lots of points of potential silent and/or unhandled errors
due to not applying await for async functions and/or not using a
`catch` for any errors thrown. If we don't add `await` or `throw`
errors, then the translation tab won't be able to tell if a the call
is actually complete or was successful, resulting in a "Success" toast
that's potentially inaccurate.

I tried manually adding in errors in all the various calls and
triggering the "Import" from the button in the translation tab and this
update (along with the parallel change to `TranslationsTab`) allowed
all of them to be caught in the `try/catch` added to `imortFile` in
TranslationsTab.

Note, however, that I didn't test the documentLevel functions because I
don't have that implemented. I copied the changes made for fieldLevel
and have no reason to believe they wouldn't work :)

* Remove unnecessary catches

* Update package version

* Add `test` script

Adds `test` script so that added workflow doesn't fail, although there
aren't any tests yet

* Comment out test from github workflow

Commenting out `Test` from workflow for now because we don't have any
tests so it fails. Tried to start by adding a simple test, but everything
here is involves fetching from Sanity or Smartling so no simple functions
to add quickly.

* Remove `@sanity/client` dependency

Had added this as a dependency in attempt to fix error showing in VSCode
in helper.js where we import `sanityClient`, but that created different
issues when I tried to use `@sanity/client` instead of
`'part:@sanity/base/client'`, so just removing the dependency from package.
Combined with a parallel update in sanity-translations-tab, this update
includes a link that goes straight to the given task in Smartling, using
the project id and task id. If there is a task, then a link will show
along with the current job to "View Job" so users can easily get to the
associated Smartling job for additional updates or info.
- Explicitly updated with `--save` to latest sanity-translations-tab
(1.4.0), including link out to Smartling job in the UI.
- Also ran `npm update` so there are additional updates in package-lock
* update to 2.0 of translations tab

* fix wrong translation job

* update translations tab

* update packages and lock

* update version
cngonzalez and others added 24 commits March 28, 2023 08:31
Fix incorrect defaultDocumentNode name
* fix: hotfix for custom job names
* feat: move callback to top level and include

* fix: use updated types from tab

---------

Co-authored-by: arthurpereira <arthurpereira@pinterest.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…152e30bf98cefb26f05d610442b731'

git-subtree-dir: plugins/sanity-plugin-studio-smartling
git-subtree-mainline: 064dc6b
git-subtree-split: c524d8c
- Import source via git subtree from sanity-io/sanity-plugin-studio-smartling
- Add monorepo package config, tests, and test-studio example
- Use workspace sanity-translations-tab and add styled-components peer dependency
- Fix type-only imports and indexed access for oxlint compliance
- Replace Buffer usage with native Blob in upload path
@changeset-bot

changeset-bot Bot commented Jun 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f185029

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
sanity-plugin-studio-smartling Major

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

@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
plugins-studio Ready Ready Preview, Comment Jun 12, 2026 2:54pm

Request Review

@stipsan stipsan added the 🤖 bot label Jun 12, 2026 — with Cursor
@socket-security

socket-security Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​sanity/​assist@​6.1.19810010097100

View full report

- Resolve pnpm-lock.yaml conflict by taking main's lockfile and
  re-running pnpm install + pnpm dedupe to re-add the
  sanity-plugin-studio-smartling workspace entries
- smartling now builds against the sanity v6 catalog like sibling
  plugins; peer range ^5 || ^6.0.0-0 already covers v6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants