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

Separate yext/studio into yext/studio-ui #364

Merged
merged 25 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
fd30305
move files to studio-ui
oshi97 Sep 1, 2023
8bc097e
separate out virtual modules from studio-ui and move generateTailwind…
oshi97 Sep 1, 2023
19108c2
good to remove setInitialState yay!
oshi97 Sep 1, 2023
4de6c48
remove workflows for now also extra gitData slice
oshi97 Sep 1, 2023
a2a94cc
tests working?
oshi97 Sep 1, 2023
b50a731
Automated linting update and features.json sync
github-actions[bot] Sep 1, 2023
a295c06
Update run-tests.yml
oshi97 Sep 1, 2023
92eef74
Update tsconfig.json
oshi97 Sep 1, 2023
d1fff41
add proper content path
oshi97 Sep 5, 2023
1545a64
Merge branch 'main' into dev/separate-ui-package
oshi97 Sep 6, 2023
716e133
respond to alex's comments!
oshi97 Sep 8, 2023
7115dba
Merge branch 'main' into dev/separate-ui-package
oshi97 Sep 8, 2023
c4b5dc0
comments
oshi97 Sep 8, 2023
edd0977
Merge branch 'main' into dev/separate-ui-package
oshi97 Sep 14, 2023
3ef9211
fix tests
oshi97 Sep 14, 2023
0f9da96
update script
oshi97 Sep 14, 2023
954beef
Merge branch 'main' into dev/separate-ui-package
oshi97 Sep 14, 2023
77893ec
Update update-minor-versions.mjs
oshi97 Sep 15, 2023
927c6ec
Add HMR for layouts and remove top-level fragments (#373)
nmanu1 Sep 15, 2023
a685d3a
delete page slice
oshi97 Sep 15, 2023
bf4476c
Merge branch 'main' into dev/separate-ui-package
oshi97 Sep 18, 2023
b2433b8
Automated linting update and features.json sync
github-actions[bot] Sep 18, 2023
238b504
Merge branch 'main' into dev/separate-ui-package
oshi97 Sep 19, 2023
99469fb
Automated linting update and features.json sync
github-actions[bot] Sep 19, 2023
76bf68a
remove empty file
oshi97 Sep 19, 2023
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
4 changes: 1 addition & 3 deletions .github/setup-acceptance/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ runs:
using: composite
steps:
- uses: ./.github/setup-ci
- run: |
npm run build -w=packages/studio-plugin
npm run build -w=packages/studio
- run: npm run build
shell: bash
- uses: actions/cache@v3
with:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Run Tests
on: workflow_call

jobs:
studio:
studio-ui:
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
Expand All @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/setup-ci
- run: npm run build -w=packages/studio-plugin
- run: npm test -w=packages/studio -- --coverage=false
- run: npm test -w=packages/studio-ui -- --coverage=false

studio_plugin:
strategy:
Expand All @@ -32,4 +32,5 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/setup-ci
- run: npm run build
- run: npm run build-test-site -w=apps/test-site
- run: npm run typecheck-jest
2 changes: 1 addition & 1 deletion apps/test-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"dev": "studio",
"localData": "yext pages generate-test-data -a",
"start": "craco start",
"build": "craco build"
"build-test-site": "craco build"
},
"browserslist": {
"production": [
Expand Down
4,308 changes: 1,920 additions & 2,388 deletions package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { StudioTailwindTheme } from "@yext/studio-plugin";
import { StudioTailwindTheme } from "../types";

/**
* Generates a safelist for custom test colors, background colors, and font sizes.
Expand Down
1 change: 1 addition & 0 deletions packages/studio-plugin/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { default as TypeGuards } from "./TypeGuards";
export { default as ComponentTreeHelpers } from "./ComponentTreeHelpers";
export { default as transformPropValuesToRaw } from "./transformPropValuesToRaw";
export { default as generateTailwindSafelist } from "./generateTailwindSafelist";
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ const config: Config = {
"\\.[jt]sx?$": "babel-jest",
"\\.svg$": "<rootDir>/tests/__setup__/svgTransformer.cjs",
},
testPathIgnorePatterns: ["lib"],
};
export default config;
72 changes: 72 additions & 0 deletions packages/studio-ui/package.json
alextaing marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"name": "@yext/studio-ui",
"version": "0.22.0",
"types": "./lib/src/index.d.ts",
"main": "./lib/src/index.js",
"type": "module",
"exports": {
".": {
"types": "./lib/src/index.d.ts",
"import": "./lib/src/index.js",
"require": "./lib/src/index.js"
}
},
"files": [
"lib"
],
"scripts": {
"dev": "npm run copy-svg && tsc --watch --preserveWatchOutput -p tsconfig.json",
"copy-svg": "npx copyfiles \"src/**/*.svg\" lib",
alextaing marked this conversation as resolved.
Show resolved Hide resolved
"build": "rimraf lib && npm run copy-svg && tsc -p tsconfig.json",
"test": "jest",
"typecheck-jest": "npx tsc -p tests/tsconfig.json"
},
"dependencies": {
"@dhmk/zustand-lens": "^2.0.5",
"@minoru/react-dnd-treeview": "^3.4.1",
"@restart/ui": "^1.5.2",
"@vitejs/plugin-react": "^4.0.4",
"autoprefixer": "^10.4.14",
"cac": "^6.7.14",
"classnames": "^2.3.2",
"cross-env": "^7.0.3",
"immer": "^9.0.21",
"lodash": "^4.17.21",
"path-browserify": "^1.0.1",
"postcss": "^8.4.27",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-modal": "3.16.1",
"react-toastify": "^9.1.1",
"react-tooltip": "^5.18.0",
"tailwind-merge": "^1.8.1",
"tailwindcss": "^3.3.3",
"zundo": "2.0.0-beta.12",
"zustand": "^4.3.2"
},
"devDependencies": {
"@babel/core": "^7.20.5",
"@babel/plugin-syntax-flow": "^7.18.6",
"@babel/plugin-transform-react-jsx": "^7.19.0",
"@rollup/plugin-typescript": "^10.0.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^14.4.3",
"@types/jest": "^29.2.4",
"@types/lodash": "^4.14.191",
"@types/node": "^18.11.15",
"@types/path-browserify": "^1.0.0",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.10",
"@types/react-modal": "3.13.1",
"@yext/studio-plugin": "*",
"copyfiles": "^2.4.1",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.3.1",
"resize-observer-polyfill": "^1.5.1",
"vite-plugin-svgr": "^3.2.0"
},
"peerDependencies": {
"@yext/studio-plugin": "*"
nmanu1 marked this conversation as resolved.
Show resolved Hide resolved
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { RefObject, useCallback, useEffect, useRef, useState } from "react";
import generateTailwindSafelist from "../utils/generateTailwindSafelist";
import { generateTailwindSafelist } from "@yext/studio-plugin";
import { StudioTailwindTheme } from "@yext/studio-plugin";
import { ReactComponent as EmbedIcon } from "../icons/embed.svg";
import { ReactComponent as X } from "../icons/x.svg";
Expand Down
File renamed without changes.
File renamed without changes
2 changes: 2 additions & 0 deletions packages/studio-ui/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as App } from "./App";
export { default as hotReloadStore } from "./store/hotReloadStore";
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "../tsconfig.json",
"include": ["**/*", "../src/index.d.ts"],
"include": ["**/*", "../src/global.d.ts"],
"compilerOptions": {
"noEmit": true,
"types": [
Expand Down
8 changes: 8 additions & 0 deletions packages/studio-ui/tsconfig.json
alextaing marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "lib",
"types": ["@yext/studio-plugin/virtual-module", "vite-plugin-svgr/client"]
nmanu1 marked this conversation as resolved.
Show resolved Hide resolved
},
"include": ["src"]
}
4 changes: 0 additions & 4 deletions packages/studio/.prettierignore

This file was deleted.

39 changes: 4 additions & 35 deletions packages/studio/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,23 @@
"dev": "tsc --watch --preserveWatchOutput -p tsconfig.node.json & tsc --watch --preserveWatchOutput -p tsconfig.json",
"build": "run-script-os",
"build:default": "npm run build:windows && chmod 755 lib/bin/studio.js",
"build:windows": "rimraf lib && tsc -p tsconfig.node.json && tsc -p tsconfig.json",
"preview": "vite preview",
"test": "jest",
"typecheck-jest": "npx tsc -p tests/tsconfig.json"
"build:windows": "rimraf lib && tsc -p tsconfig.node.json && tsc -p tsconfig.json"
},
"dependencies": {
"@dhmk/zustand-lens": "^2.0.5",
"@minoru/react-dnd-treeview": "^3.4.1",
"@restart/ui": "^1.5.2",
"@vitejs/plugin-react": "^4.0.4",
"@yext/studio-plugin": "0.22.0",
"@yext/studio-ui": "0.22.0",
nmanu1 marked this conversation as resolved.
Show resolved Hide resolved
"autoprefixer": "^10.4.14",
"cac": "^6.7.14",
"classnames": "^2.3.2",
"cross-env": "^7.0.3",
"immer": "^9.0.21",
"lodash": "^4.17.21",
"path-browserify": "^1.0.1",
"postcss": "^8.4.27",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-modal": "3.16.1",
"react-toastify": "^9.1.1",
"react-tooltip": "^5.18.0",
"tailwind-merge": "^1.8.1",
"tailwindcss": "^3.3.3",
"vite": "^4.4.7",
"vite-plugin-svgr": "^2.4.0",
oshi97 marked this conversation as resolved.
Show resolved Hide resolved
"zundo": "2.0.0-beta.12",
"zustand": "^4.3.2"
"vite-plugin-svgr": "^2.4.0"
},
"devDependencies": {
"@babel/core": "^7.20.5",
"@babel/plugin-syntax-flow": "^7.18.6",
"@babel/plugin-transform-react-jsx": "^7.19.0",
"@rollup/plugin-typescript": "^10.0.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^14.4.3",
"@types/jest": "^29.2.4",
"@types/lodash": "^4.14.191",
"@types/node": "^18.11.15",
"@types/path-browserify": "^1.0.0",
"@types/react": "^18.0.26",
"@types/react-dom": "^18.0.10",
"@types/react-modal": "3.13.1",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.3.1",
"resize-observer-polyfill": "^1.5.1"
"@types/react": "^18.0.26"
}
}
6 changes: 2 additions & 4 deletions packages/studio/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import "./tailwind-directives.css";
import "react-tooltip/dist/react-tooltip.css";
import { App, hotReloadStore } from "@yext/studio-ui";
import { StudioHMRPayload, StudioHMRUpdateID } from "@yext/studio-plugin";
import hotReloadStore from "./store/hotReloadStore";
import "./tailwind-directives.css";

if (import.meta.hot) {
import.meta.hot.on(StudioHMRUpdateID, (hmrPayload: StudioHMRPayload) => {
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion packages/studio/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "@yext/studio-plugin";
import path from "path";
import fs from "fs";
import generateTailwindSafelist from "./src/utils/generateTailwindSafelist";
import { generateTailwindSafelist } from "@yext/studio-plugin";

const getRootDir = (): string => {
const cliArgs: CliArgs = JSON.parse(
Expand Down Expand Up @@ -50,6 +50,7 @@ export default {
content: [
path.resolve(__dirname, "src/**/*.{ts,tsx}"),
path.resolve(__dirname, "index.html"),
path.join(path.dirname(require.resolve("@yext/studio-ui")), "**/*.js"),
alextaing marked this conversation as resolved.
Show resolved Hide resolved
...transformedUserContent,
],
safelist: generateTailwindSafelist(userTailwindTheme),
Expand Down
16 changes: 2 additions & 14 deletions packages/studio/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "ESNext",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"noImplicitAny": false,
"moduleResolution": "node",
"resolveJsonModule": true,
"forceConsistentCasingInFileNames": true,
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"jsx": "react-jsx",
"target": "ESNext",
"outDir": "lib",
"types": [
"vite/client",
"@yext/studio-plugin/virtual-module",
"vite-plugin-svgr/client"
]
},
"include": ["src", "types.ts"]
"include": ["src"]
}
2 changes: 1 addition & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"pipeline": {
"build": {
"dependsOn": ["^build"],
"outputs": ["dist/**", "lib/**"]
"outputs": ["lib/**"]
},
"dev": {
"cache": false
Expand Down
42 changes: 28 additions & 14 deletions update-minor-versions.mjs
Original file line number Diff line number Diff line change
@@ -1,35 +1,49 @@
import { execSync } from "child_process";
import fs from "fs";

function readJson(filepath) {
return JSON.parse(fs.readFileSync(filepath, "utf-8"));
}

function bumpStudioPlugin() {
console.log("... bumping studio-plugin");
execSync("npm version minor -w=packages/studio-plugin");
const packageJson = readJson("./packages/studio-plugin/package.json");
const newVersion = packageJson?.version;
if (!newVersion) {
throw new Error("Could not parse studio-plugin version from package.json");
}
return newVersion;
return readVersion("./packages/studio-plugin/package.json");
}

function bumpStudio(newVersion) {
function bumpStudio(pluginVersion, uiVersion) {
console.log("... bumping studio");
const packageJsonPath = "./packages/studio/package.json";
const packageJson = readJson(packageJsonPath);
// `npm i @yext/studio-plugin@${newVersion} --save-exact` does not update the package json,
// likely because the new version does not exist yet.
packageJson.dependencies["@yext/studio-plugin"] = newVersion;
packageJson.dependencies["@yext/studio-plugin"] = pluginVersion;
packageJson.dependencies["@yext/studio-ui"] = uiVersion;
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
execSync("npm version minor -w=packages/studio");
}

function bumpStudioUI() {
console.log("... bumping studio-ui");
execSync("npm version minor -w=packages/studio-ui");
return readVersion("./packages/studio-ui/package.json");
}

function readJson(filepath) {
return JSON.parse(fs.readFileSync(filepath, "utf-8"));
}

function readVersion(packageJsonPath) {
const packageJson = readJson(packageJsonPath);
const newVersion = packageJson?.version;
if (!newVersion) {
throw new Error(
`Could not parse version from package.json at ${packageJsonPath}`
);
}
return newVersion;
}

function main() {
const newVersion = bumpStudioPlugin();
bumpStudio(newVersion);
const pluginVersion = bumpStudioPlugin();
const uiVersion = bumpStudioUI();
bumpStudio(pluginVersion, uiVersion);
}

main();