Skip to content

Commit

Permalink
Extract react-cosmos-plugin-open-fixture plugin (#1379)
Browse files Browse the repository at this point in the history
* Extract react-cosmos-plugin-open-file plugin

* Rename plugin

* Convert to devServer plugin

* Move UI plugin specs to shared package

* Move core UI slots and plugin mocks to shared package

* Move core UI to shared package

* Update startDevServer.ts

* Update getCosmosPluginConfigs.test.ts

* Move slots to shared package

* Extract react-cosmos-plugin-open-fixture plugin UI plugin

* Update getCosmosPluginConfigs.ts

* Update startDevServer.ts

* Ignore plugins from node_modules by default
  • Loading branch information
ovidiuch committed Mar 28, 2022
1 parent 40c34a0 commit ffbf754
Show file tree
Hide file tree
Showing 531 changed files with 750 additions and 542 deletions.
2 changes: 1 addition & 1 deletion example/booleanInputPlugin/src/ui.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { ValueInputSlotProps } from 'react-cosmos-playground2/plugin';
import { ValueInputSlotProps } from 'react-cosmos-shared2/ui';
import { createPlugin } from 'react-plugin';
import { BooleanInput } from './BooleanInput';

Expand Down
1 change: 0 additions & 1 deletion example/booleanInputPlugin/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { join } = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const src = join(__dirname, 'src');
const dist = join(__dirname, 'dist');
Expand Down
3 changes: 2 additions & 1 deletion example/cosmos.config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"disablePlugins": false,
"globalImports": ["src/polyfills.ts", "src/global.css"],
"staticPath": "static"
"staticPath": "static",
"plugins": ["react-cosmos-plugin-open-fixture"]
}
3 changes: 2 additions & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"start": "cosmos"
},
"dependencies": {
"react-cosmos": "^5.7.2"
"react-cosmos": "^5.7.2",
"react-cosmos-plugin-open-fixture": "^5.7.2"
}
}
1 change: 0 additions & 1 deletion packages/react-cosmos-playground2/plugin.d.ts

This file was deleted.

3 changes: 1 addition & 2 deletions packages/react-cosmos-playground2/src/global/style.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { fontFamily, grey8, white3 } from 'react-cosmos-shared2/ui';
import { createGlobalStyle } from 'styled-components';
import { grey8, white3 } from '../shared/colors';
import { fontFamily } from '../shared/vars';

export const GlobalStyle = createGlobalStyle`
html {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-cosmos-playground2/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import 'whatwg-fetch';
import * as React from 'react';
import * as ReactDom from 'react-dom';
import * as ReactPlugin from 'react-plugin';
import { CoreSpec } from 'react-cosmos-shared2/ui';
import { CosmosPluginConfig } from 'react-cosmos-plugin';
import { GlobalStyle } from './global/style';
import { CoreSpec } from './plugins/Core/public';
import { DEFAULT_PLUGIN_CONFIG } from './shared/plugin';

import './plugins/pluginEntry';
Expand Down
1 change: 0 additions & 1 deletion packages/react-cosmos-playground2/src/plugin.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { BuildMessage } from 'react-cosmos-shared2/build';
import { loadPlugins, resetPlugins } from 'react-plugin';
import {
getMessageHandlerContext,
mockMessageHandler,
mockNotifications,
} from '../../testHelpers/pluginMocks';
} from 'react-cosmos-shared2/ui';
import { loadPlugins, resetPlugins } from 'react-plugin';

beforeEach(() => jest.isolateModules(() => require('.')));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { createPlugin, PluginContext } from 'react-plugin';
import { Message } from 'react-cosmos-shared2/util';
import { BuildMessage } from 'react-cosmos-shared2/build';
import { MessageHandlerSpec } from '../MessageHandler/public';
import { NotificationsSpec } from '../Notifications/public';
import { BuildNotificationsSpec } from './public';
import {
BuildNotificationsSpec,
MessageHandlerSpec,
NotificationsSpec,
} from 'react-cosmos-shared2/ui';
import { Message } from 'react-cosmos-shared2/util';
import { createPlugin, PluginContext } from 'react-plugin';

type BuildNotificationsContext = PluginContext<BuildNotificationsSpec>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import {
FixtureStateValues,
updateFixtureStateClassState,
} from 'react-cosmos-shared2/fixtureState';
import { IconButton32, RotateCcwIcon } from 'react-cosmos-shared2/ui';
import { StateUpdater } from 'react-cosmos-shared2/util';
import { IconButton32 } from '../../../shared/buttons';
import { RotateCcwIcon } from '../../../shared/icons';
import {
Actions,
Body,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import React from 'react';
import { FixtureElementId } from 'react-cosmos-shared2/fixtureState';
import { FixtureId } from 'react-cosmos-shared2/renderer';
import {
ClassStatePanelSpec,
SidePanelRowSlotProps,
StorageSpec,
} from 'react-cosmos-shared2/ui';
import { createPlugin, PluginContext } from 'react-plugin';
import { SidePanelRowSlotProps } from '../../shared/slots/SidePanelRowSlot';
import { TreeExpansion } from '../../shared/treeExpansion';
import {
FixtureExpansionGroup,
getFixtureExpansion,
updateElementExpansion,
} from '../../shared/valueInputTree';
import { StorageSpec } from '../Storage/public';
import { ClassStatePanel } from './ClassStatePanel';
import { ClassStatePanelSpec } from './public';
import { CLASS_STATE_TREE_EXPANSION_STORAGE_KEY } from './shared';

type ClassStatePanelContext = PluginContext<ClassStatePanelSpec>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { RuntimeStatus, UrlStatus } from '../RendererPreview/public';
import { RuntimeStatus, UrlStatus } from 'react-cosmos-shared2/ui';
import { NoFixtureSelected } from './NoFixtureSelected';
import { RendererNotResponding } from './RendererNotResponding';
import { ContentContainer, OverlayContainer } from './shared';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { screenGrey1, screenGrey5 } from 'react-cosmos-shared2/ui';
import styled from 'styled-components';
import { screenGrey1, screenGrey5 } from '../../shared/colors';
import { KeyBox } from '../../shared/KeyBox';

type Props = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { screenGrey3 } from 'react-cosmos-shared2/ui';
import styled from 'styled-components';
import { screenGrey3 } from '../../shared/colors';
import { BlankCanvasIllustration } from '../../shared/illustrations';
import { KeyShortcut } from './KeyShortcut';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import styled from 'styled-components';
import {
screenGrey3,
screenGrey5,
screenPrimary2,
screenPrimary3,
} from '../../shared/colors';
} from 'react-cosmos-shared2/ui';
import styled from 'styled-components';
import { ArtificialIntelligenceIllustration } from '../../shared/illustrations';
import {
ContentContainer,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';
import styled from 'styled-components';
import {
screenGrey1,
screenGrey3,
screenGrey5,
screenPrimary1,
screenPrimary2,
screenPrimary3,
} from '../../shared/colors';
} from 'react-cosmos-shared2/ui';
import styled from 'styled-components';
import { AstronautIllustration } from '../../shared/illustrations';
import {
ContentContainer,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { render } from '@testing-library/react';
import React from 'react';
import { loadPlugins, resetPlugins, Slot } from 'react-plugin';
import {
mockRendererCore,
mockRendererPreview,
mockRouter,
mockStorage,
} from '../../../testHelpers/pluginMocks';
} from 'react-cosmos-shared2/ui';
import { loadPlugins, resetPlugins, Slot } from 'react-plugin';
import { WELCOME_DISMISS_STORAGE_KEY } from '../welcomeDismiss';

beforeEach(() => jest.isolateModules(() => require('..')));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { render } from '@testing-library/react';
import React from 'react';
import { loadPlugins, Slot, resetPlugins } from 'react-plugin';
import {
mockRendererCore,
mockRendererPreview,
mockRouter,
mockStorage,
} from '../../../testHelpers/pluginMocks';
} from 'react-cosmos-shared2/ui';
import { loadPlugins, resetPlugins, Slot } from 'react-plugin';

beforeEach(() => jest.isolateModules(() => require('..')));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { render } from '@testing-library/react';
import React from 'react';
import { loadPlugins, Slot, resetPlugins } from 'react-plugin';
import {
mockRendererCore,
mockRendererPreview,
mockRouter,
mockStorage,
} from '../../../testHelpers/pluginMocks';
} from 'react-cosmos-shared2/ui';
import { loadPlugins, resetPlugins, Slot } from 'react-plugin';

beforeEach(() => jest.isolateModules(() => require('..')));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { render } from '@testing-library/react';
import React from 'react';
import { loadPlugins, Slot, resetPlugins } from 'react-plugin';
import {
mockRendererCore,
mockRendererPreview,
mockRouter,
mockStorage,
} from '../../../testHelpers/pluginMocks';
} from 'react-cosmos-shared2/ui';
import { loadPlugins, resetPlugins, Slot } from 'react-plugin';

beforeEach(() => jest.isolateModules(() => require('..')));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { render } from '@testing-library/react';
import React from 'react';
import { loadPlugins, Slot, resetPlugins } from 'react-plugin';
import {
mockRendererCore,
mockRendererPreview,
mockRouter,
mockStorage,
} from '../../../testHelpers/pluginMocks';
} from 'react-cosmos-shared2/ui';
import { loadPlugins, resetPlugins, Slot } from 'react-plugin';

beforeEach(() => jest.isolateModules(() => require('..')));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { render } from '@testing-library/react';
import React from 'react';
import { loadPlugins, Slot, resetPlugins } from 'react-plugin';
import {
mockRendererCore,
mockRendererPreview,
mockRouter,
mockStorage,
} from '../../../testHelpers/pluginMocks';
} from 'react-cosmos-shared2/ui';
import { loadPlugins, resetPlugins, Slot } from 'react-plugin';

beforeEach(() => jest.isolateModules(() => require('..')));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { screenGrey6 } from 'react-cosmos-shared2/ui';
import styled from 'styled-components';
import { screenGrey6 } from '../../shared/colors';

export default ({ children }: { children: React.ReactNode }) => (
<Wrapper>{children}</Wrapper>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from 'react';
import {
ContentOverlaySpec,
RendererCoreSpec,
RendererPreviewSpec,
RouterSpec,
} from 'react-cosmos-shared2/ui';
import { createPlugin } from 'react-plugin';
import { ContentOverlay } from './ContentOverlay';
import { RouterSpec } from '../Router/public';
import { RendererCoreSpec } from '../RendererCore/public';
import { RendererPreviewSpec } from '../RendererPreview/public';
import { ContentOverlaySpec } from './public';
import { useWelcomeDismiss } from './welcomeDismiss';

const { plug, register } = createPlugin<ContentOverlaySpec>({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { PluginContext } from 'react-plugin';
import styled from 'styled-components';
import {
ContentOverlaySpec,
screenGrey1,
screenGrey2,
screenGrey5,
screenGrey6,
screenPrimary2,
screenPrimary3,
} from '../../shared/colors';
import { ContentOverlaySpec } from './public';
} from 'react-cosmos-shared2/ui';
import { PluginContext } from 'react-plugin';
import styled from 'styled-components';

export type ContentOverlayContext = PluginContext<ContentOverlaySpec>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { StorageSpec } from '../Storage/public';
import { StorageSpec } from 'react-cosmos-shared2/ui';
import { ContentOverlayContext } from './shared';

export const WELCOME_DISMISS_STORAGE_KEY = 'welcomeDismissedAt';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@ import {
FixtureStateControl,
FixtureStateControls,
} from 'react-cosmos-shared2/fixtureState';
import {
ControlActionSlot,
ControlSlot,
IconButton32,
RotateCcwIcon,
} from 'react-cosmos-shared2/ui';
import { StateUpdater } from 'react-cosmos-shared2/util';
import { IconButton32 } from '../../shared/buttons';
import { RotateCcwIcon } from '../../shared/icons';
import {
Actions,
Body,
Container,
Header,
Title,
} from '../../shared/sidePanelUi';
import { ControlActionSlot } from '../../shared/slots/ControlActionSlot';
import { ControlSlot } from '../../shared/slots/ControlSlot';

type Props = {
fixtureState: FixtureState;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React from 'react';
import {
ControlPanelSpec,
SidePanelRowSlotProps,
} from 'react-cosmos-shared2/ui';
import { createPlugin } from 'react-plugin';
import { SidePanelRowSlotProps } from '../../shared/slots/SidePanelRowSlot';
import { ControlPanel } from './ControlPanel';
import { ControlPanelSpec } from './public';

const { namedPlug, register } = createPlugin<ControlPanelSpec>({
name: 'controlPanel',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { FixtureStateSelectControl } from 'react-cosmos-shared2/fixtureState';
import { lightBlue } from '../../shared/colors';
import { lightBlue } from 'react-cosmos-shared2/ui';
import { Select } from '../../shared/inputs/Select';
import {
Label,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React, { useCallback } from 'react';
import { FixtureStateSelectControl } from 'react-cosmos-shared2/fixtureState';
import { ControlSelectSpec, ControlSlotProps } from 'react-cosmos-shared2/ui';
import { createPlugin } from 'react-plugin';
import { ControlSlotProps } from '../../shared/slots/ControlSlot';
import { ControlSelectSpec } from './public';
import { SelectValueInput } from './SelectValueInput';

const { plug, register } = createPlugin<ControlSelectSpec>({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { CoreSpec, getCoreMethods, mockStorage } from 'react-cosmos-shared2/ui';
import { loadPlugins, resetPlugins } from 'react-plugin';
import { mockStorage, getCoreMethods } from '../../testHelpers/pluginMocks';
import { CoreSpec } from './public';

beforeEach(() => jest.isolateModules(() => require('.')));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { omit } from 'lodash';
import { registerShortcuts } from 'react-cosmos-shared2/playground';
import { Commands, CoreSpec } from 'react-cosmos-shared2/ui';
import { createPlugin, PluginContext } from 'react-plugin';
import { Commands, CoreSpec } from './public';

type CoreContext = PluginContext<CoreSpec>;

Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit ffbf754

Please sign in to comment.