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

JS Package Cleanup #442

Merged
merged 3 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bazelignore
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ plugins/stage-revert-data/core/node_modules
tools/asset-testing-library/core/node_modules
docs/storybook/node_modules
plugins/reference-assets/mocks/node_modules
tools/addon-storybook/node_modules
tools/storybook/node_modules
tools/components/node_modules
tools/mocks/node_modules
docs/site/node_modules
2 changes: 1 addition & 1 deletion docs/storybook/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from "path";

const config: StorybookConfig = {
stories: ["../src/**/*.@(stories.@(js|tsx|ts))", "../src/**/*.mdx"],
addons: ["@storybook/addon-docs", "@player-ui/storybook-addon-player"],
addons: ["@storybook/addon-docs", "@player-ui/storybook", "@storybook/addon-webpack5-compiler-babel"],
typescript: {
reactDocgen: false,
},
Expand Down
2 changes: 1 addition & 1 deletion docs/storybook/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PlayerDecorator } from "@player-ui/storybook-addon-player";
import { PlayerDecorator } from "@player-ui/storybook";
import { ReferenceAssetsPlugin } from "@player-ui/reference-assets-plugin-react";
import { CommonTypesPlugin } from "@player-ui/common-types-plugin";
import { DataChangeListenerPlugin } from "@player-ui/data-change-listener-plugin";
Expand Down
3 changes: 2 additions & 1 deletion docs/storybook/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ deps = [
":node_modules/@player-ui/data-change-listener-plugin",
":node_modules/@player-ui/computed-properties-plugin",
":node_modules/@player-ui/react",
":node_modules/@player-ui/storybook-addon-player",
":node_modules/@player-ui/storybook",
"//:node_modules/@babel/preset-typescript",
"//:node_modules/@babel/preset-env",
"//:node_modules/@storybook/react-webpack5",
Expand All @@ -37,6 +37,7 @@ deps = [
"//:node_modules/raw-loader",
"//:node_modules/react",
"//:node_modules/react-dom",
"//:node_modules/@storybook/addon-webpack5-compiler-babel",
"//:typings",
"tsconfig.json",
"package.json",
Expand Down
2 changes: 1 addition & 1 deletion docs/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"@player-ui/reference-assets-plugin-components": "workspace:*",
"@player-ui/mocks": "workspace:*",
"@player-ui/react": "workspace:*",
"@player-ui/storybook-addon-player": "workspace:*"
"@player-ui/storybook": "workspace:*"
}
}
2 changes: 1 addition & 1 deletion docs/storybook/src/ManagedPlayer.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { SuspenseSpinner } from "@player-ui/storybook-addon-player";
import { SuspenseSpinner } from "@player-ui/storybook";
import { Meta, StoryObj } from "@storybook/react";
import { ManagedPlayer } from "@player-ui/react";
import { ReferenceAssetsPlugin } from "@player-ui/reference-assets-plugin-react";
Expand Down
2 changes: 1 addition & 1 deletion docs/storybook/src/Player.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createDSLStory } from "@player-ui/storybook-addon-player";
import { createDSLStory } from "@player-ui/storybook";
import { Meta } from "@storybook/react";

const meta: Meta = {
Expand Down
30 changes: 12 additions & 18 deletions docs/storybook/src/reference-assets/Action.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta } from "@storybook/react";
import { createDSLStory } from "@player-ui/storybook-addon-player";
import { createDSLStory, PlayerStory } from "@player-ui/storybook";
import { Action } from "@player-ui/reference-assets-plugin-react";

const meta: Meta<typeof Action> = {
Expand All @@ -10,29 +10,23 @@ const meta: Meta<typeof Action> = {
export default meta;

export const Basic = createDSLStory(
() =>
import(
"!!raw-loader!@player-ui/mocks/action/action-basic.tsx"
),
() => import("!!raw-loader!@player-ui/mocks/action/action-basic.tsx"),
);

export const Expression = createDSLStory(
() =>
import(
"!!raw-loader!@player-ui/mocks/action/action-counter.tsx"
),
() => import("!!raw-loader!@player-ui/mocks/action/action-counter.tsx"),
);

export const Navigation = createDSLStory(
() =>
import(
"!!raw-loader!@player-ui/mocks/action/action-navigation.tsx"
),
() => import("!!raw-loader!@player-ui/mocks/action/action-navigation.tsx"),
);

export const TransitionToEnd = createDSLStory(
() =>
import(
"!!raw-loader!@player-ui/mocks/action/action-transition-to-end.tsx"
),
export const TransitionToEnd = () => (
<PlayerStory
flow={() =>
import(
"@player-ui/mocks/action/action-transition-to-end.json"
)
}
/>
);
2 changes: 1 addition & 1 deletion docs/storybook/src/reference-assets/Choice.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta } from "@storybook/react";
import { createDSLStory } from "@player-ui/storybook-addon-player";
import { createDSLStory } from "@player-ui/storybook";
import { Choice } from "@player-ui/reference-assets-plugin-react";

const meta: Meta<typeof Choice> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta } from "@storybook/react";
import { createDSLStory } from "@player-ui/storybook-addon-player";
import { createDSLStory } from "@player-ui/storybook";
import { Collection } from "@player-ui/reference-assets-plugin-react";

const meta: Meta<typeof Collection> = {
Expand Down
2 changes: 1 addition & 1 deletion docs/storybook/src/reference-assets/Image.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta } from "@storybook/react";
import { createDSLStory } from "@player-ui/storybook-addon-player";
import { createDSLStory } from "@player-ui/storybook";
import { Image } from "@player-ui/reference-assets-plugin-react";

const meta: Meta<typeof Image> = {
Expand Down
2 changes: 1 addition & 1 deletion docs/storybook/src/reference-assets/Info.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta } from "@storybook/react";
import { createDSLStory } from "@player-ui/storybook-addon-player";
import { createDSLStory } from "@player-ui/storybook";
import { Info } from "@player-ui/reference-assets-plugin-react";

const meta: Meta<typeof Info> = {
Expand Down
2 changes: 1 addition & 1 deletion docs/storybook/src/reference-assets/Input.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta } from "@storybook/react";
import { createDSLStory } from "@player-ui/storybook-addon-player";
import { createDSLStory } from "@player-ui/storybook";
import { Input } from "@player-ui/reference-assets-plugin-react";

const meta: Meta<typeof Input> = {
Expand Down
2 changes: 1 addition & 1 deletion docs/storybook/src/reference-assets/Text.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta } from "@storybook/react";
import { createDSLStory } from "@player-ui/storybook-addon-player";
import { createDSLStory } from "@player-ui/storybook";
import { Text } from "@player-ui/reference-assets-plugin-react";

const meta: Meta<typeof Text> = {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"@radix-ui/react-slot": "^1.0.2",
"@reduxjs/toolkit": "^1.9.5",
"@storybook/addon-docs": "^7.6.10",
"@storybook/addon-webpack5-compiler-babel": "^3.0.3",
"@storybook/builder-vite": "^7.6.10",
"@storybook/channels": "^7.6.10",
"@storybook/components": "^7.6.10",
Expand Down
2 changes: 1 addition & 1 deletion plugins/pubsub/core/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@player-ui/pubsub",
"name": "@player-ui/pubsub-plugin",
"version": "0.0.0-PLACEHOLDER",
"main": "src/index.ts",
"peerDependencies": {
Expand Down
48 changes: 31 additions & 17 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 48 additions & 8 deletions tools/addon-storybook/BUILD → tools/storybook/BUILD
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@rules_player//javascript:defs.bzl", "create_package_json")
load("@aspect_rules_js//js:defs.bzl", "js_binary")
load("@npm//:tsup/package_json.bzl", tsup_bin = "bin")
load("@npm//:defs.bzl", "npm_link_all_packages")

npm_link_all_packages(
name = "node_modules",
)

name = "storybook"

dependencies = [
"//:node_modules/@storybook/manager-api",
"//:node_modules/@storybook/preview-api",
Expand All @@ -24,8 +28,11 @@ dev_dependencies = [
"//:node_modules/@storybook/preview",
]

tsup_name = name + "_tsup"
tsup_target = ":" + tsup_name

tsup_bin.tsup_node(
name = "addon-storybook-tsup",
name = tsup_name,
srcs = glob(["src/**"]) + [
"package.json",
"tsconfig.json",
Expand All @@ -40,22 +47,55 @@ tsup_bin.tsup_node(
chdir = package_name(),
)

package_json_name = name + "_package_json"
package_json_target = ":" + package_json_name

create_package_json(
name = package_json_name,
base_package_json = "package.json",
root_package_json = "//:package.json",
dependencies = dependencies,
stamp = -1,
substitutions = {
"0.0.0-PLACEHOLDER": "{STABLE_VERSION}",
},
custom_entrypoints = True,
)

library_name = name + "_library"
library_target = ":" + library_name

js_library(
name = "addon-storybook-library",
name = library_name,
srcs = glob(["src/**"]) + [
"manager.mjs",
"package.json",
"preview.mjs",
":addon-storybook-tsup",
tsup_target,
package_json_target,
],
)

pkg_name = name
pkg_target = ":" + pkg_name

npm_package(
name = "addon-storybook",
name = pkg_name,
package = pkg_name,
srcs = [
":addon-storybook-library",
":addon-storybook-tsup",
library_target
],
package = "@player-ui/storybook-addon-player",
allow_overwrites = True,
replace_prefixes = {
package_json_name: "package",
},
visibility = ["//visibility:public"],
)

js_binary(
name = name + ".npm-publish",
chdir = package_name() + "/" + pkg_name,
data = [pkg_target],
entry_point = "@aspect_rules_js//npm/private:npm_publish_mjs",
# required to make npm to be available in PATH
include_npm = True,
)
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@player-ui/storybook-addon-player",
"name": "@player-ui/storybook",
"version": "0.0.0-PLACEHOLDER",
"exports": {
".": {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.