-
-
Notifications
You must be signed in to change notification settings - Fork 2
chore: update studiocms to beta.18 #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…o beta.18 - Updated minimum version for StudioCMS WYSIWYG and Blog to 0.1.0-beta.18. - Refactored integration hooks for better configuration handling in WYSIWYG and Blog. - Added new route patterns for WYSIWYG and Blog integrations. - Updated pnpm-lock.yaml and pnpm-workspace.yaml to reflect new version dependencies. - Created a changeset for the patch release to support beta.18.
🦋 Changeset detectedLatest commit: c5a4820 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
WalkthroughThis change refactors the configuration structure for the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Plugin
participant StudioCMS
participant Astro
User->>Plugin: Initialize plugin with options
Plugin->>StudioCMS: Register hooks (studiocms:astro:config, studiocms:config:setup)
StudioCMS->>Plugin: Call studiocms:astro:config
Plugin->>Astro: addIntegrations (register astro:config:setup, astro:config:done)
Astro->>Plugin: Call astro:config:setup
Plugin->>Astro: Inject routes / setup virtual imports
Astro->>Plugin: Call astro:config:done
Plugin->>Astro: Set sanitize options
StudioCMS->>Plugin: Call studiocms:config:setup
Plugin->>StudioCMS: setDashboard or setRendering
Possibly related PRs
Suggested reviewers
Poem
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
packages/studiocms_wysiwyg/src/studio/index.ts (1)
43-50:⚠️ Potential issueFail fast when a required
licenseKeyis missing
licenseKeyis marked as mandatory in the type, but at runtime the function still runs if the caller forgets it, ultimately emitting:export const licenseKey = undefined;into the virtual module. This breaks the editor only at usage time and is hard to trace.
function studiocmsWYSIWYGStudio(options: StudioCMSWYSIWYGStudioOptions): StudioCMSPlugin { + if (!options?.licenseKey) { + throw new Error( + '[@studiocms/wysiwyg/studio] "licenseKey" option is required but was not provided.', + ); + }A quick check protects developers and surfaces misconfiguration instantly.
🧹 Nitpick comments (3)
packages/studiocms_socialposter/src/index.ts (2)
51-99: Reduce boiler-plate when declaring env schemaThe 40-line block that manually repeats
envField.string({...})for every variable is verbose and hard to keep in sync.
A small helper can generate the schema in ~10 lines and prevents typos (e.g. mismatched option flags).- addAstroEnvConfig(params, { - validateSecrets: true, - schema: { - BLUESKY_SERVICE: envField.string({ context: 'server', access: 'secret', optional: !options.bluesky }), - ... - }, - }); + const services = { + bluesky: ['BLUESKY_SERVICE', 'BLUESKY_USERNAME', 'BLUESKY_PASSWORD'], + threads: ['THREADS_USER_ID', 'THREADS_ACCESS_TOKEN'], + twitter: [ + 'TWITTER_API_KEY', + 'TWITTER_API_SECRET', + 'TWITTER_ACCESS_TOKEN', + 'TWITTER_ACCESS_SECRET', + ], + }; + + const schema = Object.fromEntries( + Object.entries(services).flatMap(([svc, vars]) => + vars.map((name) => [ + name, + envField.string({ context: 'server', access: 'secret', optional: !options[svc as keyof typeof options] }), + ]), + ), + ); + + addAstroEnvConfig(params, { validateSecrets: true, schema });The behaviour is identical but far easier to extend (e.g. adding Mastodon support).
110-131: Optional: collapse the three nearly-identicalinjectRouteblocks into a loopYou could DRY these sections:
const routeMap = { bluesky: 'post-to-bluesky', threads: 'post-to-threads', twitter: 'post-to-twitter', } as const; (Object.keys(routeMap) as Array<keyof typeof routeMap>) .filter((svc) => options[svc]) .forEach((svc) => injectRoute({ pattern: `/studiocms_api/socialposter/${routeMap[svc]}`, entrypoint: resolve(`./routes/${routeMap[svc].replace(/-/g, '')}.js`), prerender: false, }), );Not mandatory, but it trims repetition and lowers the chance of future copy-paste slip-ups.
packages/studiocms_wysiwyg/src/studio/index.ts (1)
61-71: Minor DX nit – consider newline/semicolon in generated virtual importThe template currently emits a file ending with
...googleFontsAPIKey = "xxx";\nexport * from ... }'without a trailing newline or semicolon after the re-export. Most bundlers cope, but adding one (\n;) avoids accidental ASI edge cases if more code is concatenated later.Not urgent, just worth considering.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (5)
.changeset/fresh-pandas-stop.md(1 hunks)packages/studiocms_socialposter/src/index.ts(1 hunks)packages/studiocms_wysiwyg/src/studio/index.ts(1 hunks)packages/studiocms_wysiwyg/src/wysiwyg/index.ts(1 hunks)pnpm-workspace.yaml(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
packages/studiocms_socialposter/src/index.ts (1)
packages/studiocms_socialposter/src/utils/astroEnvConfig.ts (1)
addAstroEnvConfig(7-12)
packages/studiocms_wysiwyg/src/studio/index.ts (2)
packages/studiocms_wysiwyg/src/studio/shared.ts (1)
shared(18-23)packages/studiocms_wysiwyg/src/wysiwyg/shared.ts (1)
shared(18-23)
packages/studiocms_wysiwyg/src/wysiwyg/index.ts (1)
packages/studiocms_wysiwyg/src/wysiwyg/shared.ts (1)
shared(18-23)
🔇 Additional comments (3)
pnpm-workspace.yaml (1)
5-12: Version bumps look coherent – please double-check transitive peer-dependenciesAll direct StudioCMS packages now pin to
0.1.0-beta.18, and the globalcatalogs.minfloor has been raised accordingly.
Before merging, confirm that:
- No packages in
packages/*still publish a peer range capped at<0.1.0-beta.18(otherwise they will fail to install).- The CI matrix installs with
pnpm install --frozen-lockfileon a clean cache so any lock inconsistencies are surfaced early.If both pass, this file is good to go.
Also applies to: 18-18
.changeset/fresh-pandas-stop.md (1)
1-7: LGTM - Appropriate changeset for version updatesThe changeset correctly documents patch updates for both affected packages to support StudioCMS beta.18.
packages/studiocms_wysiwyg/src/wysiwyg/index.ts (1)
36-67: Great refactoring to hooks-based architectureThe plugin configuration has been successfully restructured to use the new hooks-based pattern, which improves separation of concerns:
- 'studiocms:astro:config' hook handles Astro integration concerns (route injection and sanitize options)
- 'studiocms:config:setup' hook handles CMS content concerns (page type registration)
This architecture should make the plugin more maintainable and consistent with other StudioCMS plugins.
Summary by CodeRabbit