From bbc69c3c4a84a9717eddd5308055546e0391b939 Mon Sep 17 00:00:00 2001 From: Alex Taing Date: Mon, 30 Oct 2023 13:26:31 -0400 Subject: [PATCH 1/9] strict mode --- apps/test-site/package.json | 2 +- packages/studio-plugin/src/types/CliArgs.ts | 2 ++ packages/studio/bin/studio.ts | 10 +++++++++- packages/studio/src/main.tsx | 9 ++++++--- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/apps/test-site/package.json b/apps/test-site/package.json index b1a1b1080..a614114e3 100644 --- a/apps/test-site/package.json +++ b/apps/test-site/package.json @@ -34,7 +34,7 @@ "tailwindcss": "^3.3.4" }, "scripts": { - "dev": "studio", + "dev": "studio --strict", "localData": "yext pages generate-test-data -a", "start": "craco start", "build-test-site": "craco build" diff --git a/packages/studio-plugin/src/types/CliArgs.ts b/packages/studio-plugin/src/types/CliArgs.ts index 6d2acbec6..1ce8fe5e6 100644 --- a/packages/studio-plugin/src/types/CliArgs.ts +++ b/packages/studio-plugin/src/types/CliArgs.ts @@ -3,6 +3,8 @@ export interface CliArgs { port?: string; // The project root for studio. root?: string; + // Whether or not to run Studio in React Strict Mode + strict?: boolean; // Any arguments present after double dashes when invoking studio, e.g. // `npx studio -- args like these` will result in ['args', 'like', 'these'] // Not currently used for anything but always provided by the cac package diff --git a/packages/studio/bin/studio.ts b/packages/studio/bin/studio.ts index 43de13867..7d124d208 100755 --- a/packages/studio/bin/studio.ts +++ b/packages/studio/bin/studio.ts @@ -15,7 +15,14 @@ cli .command("", "start dev server") .option("--port ", "[number] port to run studio") .option("--root ", `[string] path to the root directory`) + .option("--strict", "Runs Studio in React Strict Mode") .action((options: CliArgs) => { + const YEXT_STUDIO_ARGS = JSON.stringify({ + "--": options["--"], + port: options.port, + root: options.root + }) + spawnSync( "npx", [ @@ -31,7 +38,8 @@ cli stdio: ["ignore", "inherit", "inherit"], env: { ...process.env, - YEXT_STUDIO_ARGS: JSON.stringify(options), + YEXT_STUDIO_ARGS, + VITE_STUDIO_STRICT: String(options.strict) }, shell: true, } diff --git a/packages/studio/src/main.tsx b/packages/studio/src/main.tsx index 189477dc7..1ced19491 100644 --- a/packages/studio/src/main.tsx +++ b/packages/studio/src/main.tsx @@ -18,9 +18,12 @@ if (import.meta.hot) { void hotReloadGitData(hmrPayload); }); } +const WrappedApp = import.meta.env.VITE_STUDIO_STRICT === "true" + ? + + + : ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( - - - + WrappedApp ); From 79084fc633c12c2bcc5444292ed8308ef733752f Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 30 Oct 2023 17:31:55 +0000 Subject: [PATCH 2/9] Automated linting update and features.json sync --- packages/studio/bin/studio.ts | 6 +++--- packages/studio/src/main.tsx | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/studio/bin/studio.ts b/packages/studio/bin/studio.ts index 7d124d208..fd61db279 100755 --- a/packages/studio/bin/studio.ts +++ b/packages/studio/bin/studio.ts @@ -20,8 +20,8 @@ cli const YEXT_STUDIO_ARGS = JSON.stringify({ "--": options["--"], port: options.port, - root: options.root - }) + root: options.root, + }); spawnSync( "npx", @@ -39,7 +39,7 @@ cli env: { ...process.env, YEXT_STUDIO_ARGS, - VITE_STUDIO_STRICT: String(options.strict) + VITE_STUDIO_STRICT: String(options.strict), }, shell: true, } diff --git a/packages/studio/src/main.tsx b/packages/studio/src/main.tsx index 1ced19491..32b09d475 100644 --- a/packages/studio/src/main.tsx +++ b/packages/studio/src/main.tsx @@ -18,11 +18,14 @@ if (import.meta.hot) { void hotReloadGitData(hmrPayload); }); } -const WrappedApp = import.meta.env.VITE_STUDIO_STRICT === "true" - ? +const WrappedApp = + import.meta.env.VITE_STUDIO_STRICT === "true" ? ( + - : + ) : ( + + ); ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( WrappedApp From ca21f10f8719d466b22515c4e6447fecf0b282c2 Mon Sep 17 00:00:00 2001 From: Alex Taing Date: Mon, 30 Oct 2023 14:31:50 -0400 Subject: [PATCH 3/9] refactor --- packages/studio/bin/studio.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/studio/bin/studio.ts b/packages/studio/bin/studio.ts index fd61db279..0e5e860d8 100755 --- a/packages/studio/bin/studio.ts +++ b/packages/studio/bin/studio.ts @@ -17,12 +17,7 @@ cli .option("--root ", `[string] path to the root directory`) .option("--strict", "Runs Studio in React Strict Mode") .action((options: CliArgs) => { - const YEXT_STUDIO_ARGS = JSON.stringify({ - "--": options["--"], - port: options.port, - root: options.root, - }); - + const {strict, ...studioArgs} = options spawnSync( "npx", [ @@ -38,8 +33,8 @@ cli stdio: ["ignore", "inherit", "inherit"], env: { ...process.env, - YEXT_STUDIO_ARGS, - VITE_STUDIO_STRICT: String(options.strict), + YEXT_STUDIO_ARGS: JSON.stringify(studioArgs), + VITE_STUDIO_STRICT: String(strict) }, shell: true, } From b8beba6b17ca4b7c9f222eb7440bb1485a549644 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 30 Oct 2023 18:33:22 +0000 Subject: [PATCH 4/9] Automated linting update and features.json sync --- packages/studio/bin/studio.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/studio/bin/studio.ts b/packages/studio/bin/studio.ts index 0e5e860d8..35468c99b 100755 --- a/packages/studio/bin/studio.ts +++ b/packages/studio/bin/studio.ts @@ -17,7 +17,7 @@ cli .option("--root ", `[string] path to the root directory`) .option("--strict", "Runs Studio in React Strict Mode") .action((options: CliArgs) => { - const {strict, ...studioArgs} = options + const { strict, ...studioArgs } = options; spawnSync( "npx", [ @@ -34,7 +34,7 @@ cli env: { ...process.env, YEXT_STUDIO_ARGS: JSON.stringify(studioArgs), - VITE_STUDIO_STRICT: String(strict) + VITE_STUDIO_STRICT: String(strict), }, shell: true, } From ab831ae790f2a6f4a75c56593f5f61fc922889a3 Mon Sep 17 00:00:00 2001 From: Alex Taing Date: Tue, 31 Oct 2023 09:49:08 -0400 Subject: [PATCH 5/9] remove documented argument --- apps/test-site/package.json | 2 +- packages/studio-plugin/src/types/CliArgs.ts | 6 +++--- packages/studio/bin/studio.ts | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/test-site/package.json b/apps/test-site/package.json index a614114e3..33cd5235f 100644 --- a/apps/test-site/package.json +++ b/apps/test-site/package.json @@ -34,7 +34,7 @@ "tailwindcss": "^3.3.4" }, "scripts": { - "dev": "studio --strict", + "dev": "studio -- strict", "localData": "yext pages generate-test-data -a", "start": "craco start", "build-test-site": "craco build" diff --git a/packages/studio-plugin/src/types/CliArgs.ts b/packages/studio-plugin/src/types/CliArgs.ts index 1ce8fe5e6..8f0878cac 100644 --- a/packages/studio-plugin/src/types/CliArgs.ts +++ b/packages/studio-plugin/src/types/CliArgs.ts @@ -3,10 +3,10 @@ export interface CliArgs { port?: string; // The project root for studio. root?: string; - // Whether or not to run Studio in React Strict Mode - strict?: boolean; // Any arguments present after double dashes when invoking studio, e.g. // `npx studio -- args like these` will result in ['args', 'like', 'these'] - // Not currently used for anything but always provided by the cac package + // This option is always provided by the cac package, and we only use it to + // configure Studio to run in React Strict Mode for internal development by + // using `-- strict`. "--"?: string[]; } diff --git a/packages/studio/bin/studio.ts b/packages/studio/bin/studio.ts index 35468c99b..5ec6b8a27 100755 --- a/packages/studio/bin/studio.ts +++ b/packages/studio/bin/studio.ts @@ -15,9 +15,8 @@ cli .command("", "start dev server") .option("--port ", "[number] port to run studio") .option("--root ", `[string] path to the root directory`) - .option("--strict", "Runs Studio in React Strict Mode") .action((options: CliArgs) => { - const { strict, ...studioArgs } = options; + const useStrictMode = options["--"]?.includes("strict") spawnSync( "npx", [ @@ -33,8 +32,8 @@ cli stdio: ["ignore", "inherit", "inherit"], env: { ...process.env, - YEXT_STUDIO_ARGS: JSON.stringify(studioArgs), - VITE_STUDIO_STRICT: String(strict), + YEXT_STUDIO_ARGS: JSON.stringify(options), + VITE_STUDIO_STRICT: String(useStrictMode), }, shell: true, } From ace44dead96755e05c8eda23d806400773a0c57a Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 31 Oct 2023 13:50:14 +0000 Subject: [PATCH 6/9] Automated linting update and features.json sync --- packages/studio/bin/studio.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/studio/bin/studio.ts b/packages/studio/bin/studio.ts index 5ec6b8a27..14e4721db 100755 --- a/packages/studio/bin/studio.ts +++ b/packages/studio/bin/studio.ts @@ -16,7 +16,7 @@ cli .option("--port ", "[number] port to run studio") .option("--root ", `[string] path to the root directory`) .action((options: CliArgs) => { - const useStrictMode = options["--"]?.includes("strict") + const useStrictMode = options["--"]?.includes("strict"); spawnSync( "npx", [ From 868ece3697a87dc2ca16cc8dbcd7b16cf920cb40 Mon Sep 17 00:00:00 2001 From: Alex Taing Date: Tue, 31 Oct 2023 11:00:49 -0400 Subject: [PATCH 7/9] removed optional --- packages/studio-plugin/src/types/CliArgs.ts | 2 +- packages/studio/bin/studio.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/studio-plugin/src/types/CliArgs.ts b/packages/studio-plugin/src/types/CliArgs.ts index 8f0878cac..385121e05 100644 --- a/packages/studio-plugin/src/types/CliArgs.ts +++ b/packages/studio-plugin/src/types/CliArgs.ts @@ -8,5 +8,5 @@ export interface CliArgs { // This option is always provided by the cac package, and we only use it to // configure Studio to run in React Strict Mode for internal development by // using `-- strict`. - "--"?: string[]; + "--": string[]; } diff --git a/packages/studio/bin/studio.ts b/packages/studio/bin/studio.ts index 14e4721db..61fd5e508 100755 --- a/packages/studio/bin/studio.ts +++ b/packages/studio/bin/studio.ts @@ -16,7 +16,7 @@ cli .option("--port ", "[number] port to run studio") .option("--root ", `[string] path to the root directory`) .action((options: CliArgs) => { - const useStrictMode = options["--"]?.includes("strict"); + const useStrictMode = options["--"].includes("strict"); spawnSync( "npx", [ From 5c940712bb628848c7028192d8d1e68f29bdc6fc Mon Sep 17 00:00:00 2001 From: Alex Taing Date: Tue, 31 Oct 2023 11:13:19 -0400 Subject: [PATCH 8/9] remove required --- packages/studio-plugin/src/types/CliArgs.ts | 2 +- packages/studio/bin/studio.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/studio-plugin/src/types/CliArgs.ts b/packages/studio-plugin/src/types/CliArgs.ts index 385121e05..8f0878cac 100644 --- a/packages/studio-plugin/src/types/CliArgs.ts +++ b/packages/studio-plugin/src/types/CliArgs.ts @@ -8,5 +8,5 @@ export interface CliArgs { // This option is always provided by the cac package, and we only use it to // configure Studio to run in React Strict Mode for internal development by // using `-- strict`. - "--": string[]; + "--"?: string[]; } diff --git a/packages/studio/bin/studio.ts b/packages/studio/bin/studio.ts index 61fd5e508..9e3e25946 100755 --- a/packages/studio/bin/studio.ts +++ b/packages/studio/bin/studio.ts @@ -16,7 +16,7 @@ cli .option("--port ", "[number] port to run studio") .option("--root ", `[string] path to the root directory`) .action((options: CliArgs) => { - const useStrictMode = options["--"].includes("strict"); + const useStrictMode = options["--"]?.includes("strict"); spawnSync( "npx", [ @@ -33,7 +33,7 @@ cli env: { ...process.env, YEXT_STUDIO_ARGS: JSON.stringify(options), - VITE_STUDIO_STRICT: String(useStrictMode), + VITE_STUDIO_STRICT: String(useStrictMode ?? false), }, shell: true, } From e543a9fc1472810e7be6025f7a245a76d161add7 Mon Sep 17 00:00:00 2001 From: Alex Taing Date: Tue, 31 Oct 2023 11:25:52 -0400 Subject: [PATCH 9/9] move undefined check --- packages/studio/bin/studio.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/studio/bin/studio.ts b/packages/studio/bin/studio.ts index 9e3e25946..1b4705836 100755 --- a/packages/studio/bin/studio.ts +++ b/packages/studio/bin/studio.ts @@ -16,7 +16,7 @@ cli .option("--port ", "[number] port to run studio") .option("--root ", `[string] path to the root directory`) .action((options: CliArgs) => { - const useStrictMode = options["--"]?.includes("strict"); + const useStrictMode: boolean = options["--"]?.includes("strict") ?? false; spawnSync( "npx", [ @@ -33,7 +33,7 @@ cli env: { ...process.env, YEXT_STUDIO_ARGS: JSON.stringify(options), - VITE_STUDIO_STRICT: String(useStrictMode ?? false), + VITE_STUDIO_STRICT: String(useStrictMode), }, shell: true, }