Skip to content

Conversation

@Adammatthiesen
Copy link
Member

@Adammatthiesen Adammatthiesen commented May 11, 2025

  • 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.

Summary by CodeRabbit

  • Refactor
    • Updated plugin configuration to use a new hooks-based integration pattern for improved alignment with recent platform changes.
    • Consolidated dashboard and page type setup into dedicated configuration hooks.
    • Raised minimum required StudioCMS version to beta.18 for relevant packages.
  • Chores
    • Updated version requirements and workspace metadata to support StudioCMS beta.18.
    • Added documentation for patch updates to package changelogs.

…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-bot
Copy link

changeset-bot bot commented May 11, 2025

🦋 Changeset detected

Latest commit: c5a4820

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

This PR includes changesets to release 3 packages
Name Type
@studiocms/socialposter Patch
@studiocms/wysiwyg Patch
@studiocms/grapesjs-plugin Patch

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 11, 2025

Walkthrough

This change refactors the configuration structure for the @studiocms/socialposter and @studiocms/wysiwyg plugins to use a new hooks-based integration pattern, updates their minimum StudioCMS version requirement to beta.18, and updates workspace and changeset metadata to reflect these changes.

Changes

File(s) Change Summary
.changeset/fresh-pandas-stop.md Added a changeset documenting a patch update for @studiocms/socialposter and @studiocms/wysiwyg for beta.18 support.
packages/studiocms_socialposter/src/index.ts Refactored plugin configuration to nest integration hooks under studiocms:astro:config using addIntegrations; moved dashboard setup to studiocms:config:setup hook; updated minimum StudioCMS version to beta.18; no changes to exported function signatures.
packages/studiocms_wysiwyg/src/studio/index.ts Refactored plugin configuration to use unified hooks object with studiocms:astro:config and studiocms:config:setup; moved page type registration to rendering setup hook; updated minimum StudioCMS version to beta.18; no changes to exported function signatures.
packages/studiocms_wysiwyg/src/wysiwyg/index.ts Updated minimum StudioCMS version to beta.18; replaced top-level pageTypes and integration with unified hooks-based configuration; moved route injection and sanitize option setup into Astro integration hooks; no changes to exported function signatures.
pnpm-workspace.yaml Updated version requirements for @studiocms/blog, @studiocms/devapps, and studiocms in catalog to beta.18; increased minimum studiocms version in catalogs.min to beta.18.

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
Loading

Possibly related PRs

Suggested reviewers

  • RATIU5

Poem

Hopping through hooks, a rabbit refines,
Plugins now dance in neat, tidy lines.
Beta.18 is the burrow we seek,
With routes and dashboards—no hide and seek!
Workspace is fresh, the changeset sings,
StudioCMS grows stronger on springy new springs!
🐇✨

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@pkg-pr-new
Copy link

pkg-pr-new bot commented May 11, 2025

Open in StackBlitz

npm i https://pkg.pr.new/withstudiocms/experiments/@studiocms/grapesjs-plugin@19
npm i https://pkg.pr.new/withstudiocms/experiments/@studiocms/socialposter@19
npm i https://pkg.pr.new/withstudiocms/experiments/@studiocms/wysiwyg@19

commit: c5a4820

@Adammatthiesen Adammatthiesen marked this pull request as ready for review May 11, 2025 04:50
@Adammatthiesen Adammatthiesen requested a review from a team as a code owner May 11, 2025 04:50
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 issue

Fail fast when a required licenseKey is missing

licenseKey is 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 schema

The 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-identical injectRoute blocks into a loop

You 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 import

The 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

📥 Commits

Reviewing files that changed from the base of the PR and between a505458 and c5a4820.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is 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-dependencies

All direct StudioCMS packages now pin to 0.1.0-beta.18, and the global catalogs.min floor has been raised accordingly.
Before merging, confirm that:

  1. No packages in packages/* still publish a peer range capped at <0.1.0-beta.18 (otherwise they will fail to install).
  2. The CI matrix installs with pnpm install --frozen-lockfile on 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 updates

The 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 architecture

The 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.

@Adammatthiesen Adammatthiesen merged commit df7df72 into main May 11, 2025
11 checks passed
@Adammatthiesen Adammatthiesen deleted the beta.18 branch May 11, 2025 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants