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

feat: add vscode installer #1869

Closed
wants to merge 8 commits into from
Closed
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
5 changes: 5 additions & 0 deletions .changeset/few-cougars-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-t3-app": minor
---

Use custom editor labels for pages, layouts and API routes.
5 changes: 5 additions & 0 deletions .changeset/thin-birds-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-t3-app": minor
---

Use the workspace typescript version by default so you get Next.js specific typesafety!
6 changes: 6 additions & 0 deletions cli/src/installers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -19,6 +20,7 @@ export const availablePackages = [
"envVariables",
"eslint",
"dbContainer",
"vscode",
] as const;
export type AvailablePackages = (typeof availablePackages)[number];

Expand Down Expand Up @@ -86,4 +88,8 @@ export const buildPkgInstallerMap = (
inUse: true,
installer: dynamicEslintInstaller,
},
vscode: {
inUse: true,
installer: vscodeInstaller,
},
});
7 changes: 7 additions & 0 deletions cli/src/installers/vscode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import fs from "fs-extra";

import { type Installer } from "~/installers/index.js";

export const vscodeInstaller: Installer = ({ projectDir }) => {
fs.copySync("cli/template/extras/config/.vscode", projectDir + "/.vscode");
};
20 changes: 20 additions & 0 deletions cli/template/extras/config/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
/**
* 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",

/**
* 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",
"**/src/app/**/route.{ts,tsx}": "${dirname} - API"
}
}
Loading