Skip to content
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

Core: Add preset with experimental server API #25664

Merged
merged 9 commits into from
Jan 19, 2024
Merged

Conversation

shilman
Copy link
Member

@shilman shilman commented Jan 19, 2024

Closes N/A

What I did

Added a new core preset called experimental_serverAPI which currently contains a single method, removeAddon, which can be used to run the equivalent of storybook remove but from a Node API:

// .storybook/main.ts
export default {
  experimental_serverChannel: async (channel: Channel, options: Options) => {
    const api = await options.presets.apply<any>('experimental_serverAPI');
    await channel.on('hahaha', () => {
      api.removeAddon('@storybook/addon-links');
    });
    return channel;
  }
}

This involved a very large refactor of code moving a bunch of code out of @storybook/cli and into core-common:

  • JsPackageManager
  • versions.ts
  • utils.ts
  • remove.ts

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

Add the following to a sandbox as .storybook/manager.tsx, along with the snippet above to .storybook/main.ts.

// .storybook/manager.tsx
import React from 'react';
import { addons, useChannel } from '@storybook/manager-api';
import { Addon_TypesEnum } from '@storybook/types';

const TestAddon = () => {
  const emit = useChannel({});
  return <div onClick={() => emit('hahaha')}>Test Addon</div>;
};

addons.register('test-addon', () => {
  addons.add('test-addon/panel', {
    title: 'Test',
    type: Addon_TypesEnum.TOOL,
    render: TestAddon,
  });
});

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found in code/lib/cli/src/sandbox-templates.ts

  • Make sure this PR contains one of the labels below:

    Available labels
    • bug: Internal changes that fixes incorrect behavior.
    • maintenance: User-facing maintenance tasks.
    • dependencies: Upgrading (sometimes downgrading) dependencies.
    • build: Internal-facing build tooling & test updates. Will not show up in release changelog.
    • cleanup: Minor cleanup style change. Will not show up in release changelog.
    • documentation: Documentation only changes. Will not show up in release changelog.
    • feature request: Introducing a new feature.
    • BREAKING CHANGE: Changes that break compatibility in some way with current major version.
    • other: Changes that don't fit in the above categories.

🦋 Canary release

This pull request has been released as version 0.0.0-pr-25664-sha-900501bb. Try it out in a new sandbox by running npx storybook@0.0.0-pr-25664-sha-900501bb sandbox or in an existing project with npx storybook@0.0.0-pr-25664-sha-900501bb upgrade.

More information
Published version 0.0.0-pr-25664-sha-900501bb
Triggered by @shilman
Repository storybookjs/storybook
Branch shilman/remove-addon-api
Commit 900501bb
Datetime Fri Jan 19 16:50:01 UTC 2024 (1705683001)
Workflow run 7586708229

To request a new release of this pull request, mention the @storybookjs/core team.

core team members can create a new canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=25664

@shilman shilman changed the title Move CLI utilities to core-common Core: Add preset with experimental server API Jan 19, 2024
@shilman shilman marked this pull request as ready for review January 19, 2024 11:21
@storybookjs storybookjs deleted a comment from storybook-bot Jan 19, 2024
@storybookjs storybookjs deleted a comment from storybook-bot Jan 19, 2024
@shilman shilman merged commit b620b12 into next Jan 19, 2024
27 of 32 checks passed
@shilman shilman deleted the shilman/remove-addon-api branch January 19, 2024 17:04
@github-actions github-actions bot mentioned this pull request Jan 19, 2024
18 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants