From 90ab1049ac5ecb992f2803c9e3c6b43343080ba2 Mon Sep 17 00:00:00 2001 From: Pranav Date: Sun, 5 May 2024 01:21:38 +0530 Subject: [PATCH 1/8] feat: add vscode installer --- cli/src/installers/vscode.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 cli/src/installers/vscode.ts diff --git a/cli/src/installers/vscode.ts b/cli/src/installers/vscode.ts new file mode 100644 index 0000000000..d4706537d3 --- /dev/null +++ b/cli/src/installers/vscode.ts @@ -0,0 +1,13 @@ +import path from "path"; +import fs from "fs-extra"; + +import { type Installer } from "~/installers/index.js"; + +const _vscodeSettingsPath = path.resolve( + __dirname, + "../../template/extras/config/.vscode" +); + +export const vscodeInstaller: Installer = ({ projectDir }) => { + fs.moveSync(_vscodeSettingsPath, path.join(projectDir, ".vscode")); +}; From d8666c1c843b3d32e388170e9b5841c0115b4fe5 Mon Sep 17 00:00:00 2001 From: Pranav Date: Sun, 5 May 2024 01:21:55 +0530 Subject: [PATCH 2/8] feat: add vs code config directory --- .../extras/config/.vscode/settings.json | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 cli/template/extras/config/.vscode/settings.json diff --git a/cli/template/extras/config/.vscode/settings.json b/cli/template/extras/config/.vscode/settings.json new file mode 100644 index 0000000000..f460085039 --- /dev/null +++ b/cli/template/extras/config/.vscode/settings.json @@ -0,0 +1,21 @@ +{ + /** + * Makes sure you're using the TypeScript plugin that comes with Next.js + * + * @see + * https://nextjs.org/docs/app/building-your-application/configuring/typescript#typescript-plugin + */ + "typescript.tsdk": "node_modules/typescript/lib", + "typescript.enablePromptUseWorkspaceTsdk": true, + + /** + * Custom editor labels Makes it easy to distinguish between pages, layouts and API routes in + * Next.js + */ + "workbench.editor.customLabels.patterns": { + "**src/app/**/page.tsx": "${dirname} - Page", + "**src/app/**/layout.tsx": "${dirname} - Layout", + "**src/app/**/route.ts": "${dirname} - API", + "**src/app/**/route.tsx": "${dirname} - API" + } +} From b6ab59913b28ec9d0c9deadc6bf22560fdb9642d Mon Sep 17 00:00:00 2001 From: Pranav Date: Sun, 5 May 2024 01:22:04 +0530 Subject: [PATCH 3/8] use vscode installer --- cli/src/installers/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cli/src/installers/index.ts b/cli/src/installers/index.ts index 69c3479145..57281aae01 100644 --- a/cli/src/installers/index.ts +++ b/cli/src/installers/index.ts @@ -7,6 +7,7 @@ import { type PackageManager } from "~/utils/getUserPkgManager.js"; import { dbContainerInstaller } from "./dbContainer.js"; import { drizzleInstaller } from "./drizzle.js"; import { dynamicEslintInstaller } from "./eslint.js"; +import { vscodeInstaller } from "./vscode.js"; // Turning this into a const allows the list to be iterated over for programatically creating prompt options // Should increase extensability in the future @@ -19,6 +20,7 @@ export const availablePackages = [ "envVariables", "eslint", "dbContainer", + "vscode", ] as const; export type AvailablePackages = (typeof availablePackages)[number]; @@ -86,4 +88,8 @@ export const buildPkgInstallerMap = ( inUse: true, installer: dynamicEslintInstaller, }, + vscode: { + inUse: true, + installer: vscodeInstaller, + }, }); From 4d87ae514f68bfadd19a9d849a6f11cf78da572c Mon Sep 17 00:00:00 2001 From: Pranav Date: Sun, 5 May 2024 01:31:41 +0530 Subject: [PATCH 4/8] patch: update path in pattern --- cli/template/extras/config/.vscode/settings.json | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cli/template/extras/config/.vscode/settings.json b/cli/template/extras/config/.vscode/settings.json index f460085039..0a05d20a55 100644 --- a/cli/template/extras/config/.vscode/settings.json +++ b/cli/template/extras/config/.vscode/settings.json @@ -13,9 +13,8 @@ * Next.js */ "workbench.editor.customLabels.patterns": { - "**src/app/**/page.tsx": "${dirname} - Page", - "**src/app/**/layout.tsx": "${dirname} - Layout", - "**src/app/**/route.ts": "${dirname} - API", - "**src/app/**/route.tsx": "${dirname} - API" + "**/src/app/**/page.tsx": "${dirname} - Page", + "**/src/app/**/layout.tsx": "${dirname} - Layout", + "**/src/app/**/route.{ts,tsx}": "${dirname} - API" } } From 0eb4602be7ee0ff5d66c04d065fc57423d1abe3e Mon Sep 17 00:00:00 2001 From: Pranav Date: Sun, 5 May 2024 01:32:02 +0530 Subject: [PATCH 5/8] patch: add flag to enable custom labels --- cli/template/extras/config/.vscode/settings.json | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/template/extras/config/.vscode/settings.json b/cli/template/extras/config/.vscode/settings.json index 0a05d20a55..71a816ddbc 100644 --- a/cli/template/extras/config/.vscode/settings.json +++ b/cli/template/extras/config/.vscode/settings.json @@ -12,6 +12,7 @@ * Custom editor labels Makes it easy to distinguish between pages, layouts and API routes in * Next.js */ + "workbench.editor.customLabels.enabled": true, "workbench.editor.customLabels.patterns": { "**/src/app/**/page.tsx": "${dirname} - Page", "**/src/app/**/layout.tsx": "${dirname} - Layout", From afcf035c25af787734ca1ed587dd85b6e97eb624 Mon Sep 17 00:00:00 2001 From: Pranav Date: Sun, 5 May 2024 23:55:13 +0530 Subject: [PATCH 6/8] fix: dir not found --- cli/src/installers/vscode.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/cli/src/installers/vscode.ts b/cli/src/installers/vscode.ts index d4706537d3..d008857123 100644 --- a/cli/src/installers/vscode.ts +++ b/cli/src/installers/vscode.ts @@ -1,13 +1,7 @@ -import path from "path"; import fs from "fs-extra"; import { type Installer } from "~/installers/index.js"; -const _vscodeSettingsPath = path.resolve( - __dirname, - "../../template/extras/config/.vscode" -); - export const vscodeInstaller: Installer = ({ projectDir }) => { - fs.moveSync(_vscodeSettingsPath, path.join(projectDir, ".vscode")); + fs.copySync("cli/template/extras/config/.vscode", projectDir + "/.vscode"); }; From f4e00e3bafb5b0a1f406164bba96621389fd56e9 Mon Sep 17 00:00:00 2001 From: Pranav Date: Mon, 6 May 2024 00:05:25 +0530 Subject: [PATCH 7/8] fix: no prompt for using tsdk --- cli/template/extras/config/.vscode/settings.json | 1 - 1 file changed, 1 deletion(-) diff --git a/cli/template/extras/config/.vscode/settings.json b/cli/template/extras/config/.vscode/settings.json index 71a816ddbc..acacff41ed 100644 --- a/cli/template/extras/config/.vscode/settings.json +++ b/cli/template/extras/config/.vscode/settings.json @@ -6,7 +6,6 @@ * https://nextjs.org/docs/app/building-your-application/configuring/typescript#typescript-plugin */ "typescript.tsdk": "node_modules/typescript/lib", - "typescript.enablePromptUseWorkspaceTsdk": true, /** * Custom editor labels Makes it easy to distinguish between pages, layouts and API routes in From ff130cf2f49ceb9377518b67ec815dd6df9600e3 Mon Sep 17 00:00:00 2001 From: Pranav Date: Mon, 6 May 2024 00:13:56 +0530 Subject: [PATCH 8/8] chore: add changesets --- .changeset/few-cougars-live.md | 5 +++++ .changeset/thin-birds-brush.md | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/few-cougars-live.md create mode 100644 .changeset/thin-birds-brush.md diff --git a/.changeset/few-cougars-live.md b/.changeset/few-cougars-live.md new file mode 100644 index 0000000000..43222a7f54 --- /dev/null +++ b/.changeset/few-cougars-live.md @@ -0,0 +1,5 @@ +--- +"create-t3-app": minor +--- + +Use custom editor labels for pages, layouts and API routes. diff --git a/.changeset/thin-birds-brush.md b/.changeset/thin-birds-brush.md new file mode 100644 index 0000000000..06cf5fec83 --- /dev/null +++ b/.changeset/thin-birds-brush.md @@ -0,0 +1,5 @@ +--- +"create-t3-app": minor +--- + +Use the workspace typescript version by default so you get Next.js specific typesafety!