Skip to content

Commit

Permalink
Update base template files (#6)
Browse files Browse the repository at this point in the history
* add sass modules deps & remove prisma

* ignore my-bsmnt-app used in testing

* add base files from next-typescript template

* add sass to base template

* Create metal-carrots-pay.md
  • Loading branch information
Joaquín R. Montes committed Dec 15, 2022
1 parent b6051b6 commit 4acff78
Show file tree
Hide file tree
Showing 76 changed files with 2,154 additions and 579 deletions.
5 changes: 5 additions & 0 deletions .changeset/metal-carrots-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-bsmnt-app": patch
---

Add `next-typescript` template files to the `create-bsmnt-app` starter.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ Thumbs.db

.turbo
.vercel

my-bsmnt-app/
1 change: 0 additions & 1 deletion cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ The _"T3 Stack"_ is a web development stack made by [Theo](https://twitter.com/t
- [tRPC](https://trpc.io)
- [Tailwind CSS](https://tailwindcss.com)
- [TypeScript](https://typescriptlang.org)
- [Prisma](https://prisma.io)
- [NextAuth.js](https://next-auth.js.org)

### So... what is `create-t3-app`? A template?
Expand Down
4 changes: 2 additions & 2 deletions cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"clean": "rm -rf dist .turbo node_modules",
"start": "node dist/index.js",
"lint": "eslint src --cache --cache-strategy content",
"format": "prettier --write --plugin-search-dir=. **/*.{cjs,mjs,ts,tsx,md,json} --ignore-path ../.gitignore",
"format:check": "prettier --check --plugin-search-dir=. **/*.{cjs,mjs,ts,tsx,md,json} --ignore-path ../.gitignore",
"format": "prettier --write --plugin-search-dir=. **/*.{cjs,ts,tsx,md,json} --ignore-path ../.gitignore",
"format:check": "prettier --check --plugin-search-dir=. **/*.{cjs,ts,tsx,json} --ignore-path ../.gitignore",
"release": "changeset version",
"pub:beta": "pnpm build && npm publish --tag beta",
"pub:next": "pnpm build && npm publish --tag next",
Expand Down
14 changes: 1 addition & 13 deletions cli/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ interface CliFlags {
CI: boolean /** @internal - used in CI */;
tailwind: boolean /** @internal - used in CI */;
trpc: boolean /** @internal - used in CI */;
prisma: boolean /** @internal - used in CI */;
nextAuth: boolean /** @internal - used in CI */;
}

Expand All @@ -28,15 +27,14 @@ interface CliResults {

const defaultOptions: CliResults = {
appName: DEFAULT_APP_NAME,
packages: ["nextAuth", "prisma", "tailwind", "trpc"],
packages: ["nextAuth", "tailwind", "trpc"],
flags: {
noGit: false,
noInstall: false,
default: false,
CI: false,
tailwind: false,
trpc: false,
prisma: false,
nextAuth: false,
},
};
Expand Down Expand Up @@ -93,15 +91,6 @@ export const runCli = async () => {
"Experimental: Boolean value if we should install Next-Auth.js. Must be used in conjunction with `--CI`.",
(value) => !!value && value !== "false",
)
/**
* @experimental - used for CI E2E tests
* Used in conjunction with `--CI` to skip prompting
*/
.option(
"--prisma [boolean]",
"Experimental: Boolean value if we should install Prisma. Must be used in conjunction with `--CI`.",
(value) => !!value && value !== "false",
)
/**
* @experimental - used for CI E2E tests
* Used in conjunction with `--CI` to skip prompting
Expand Down Expand Up @@ -150,7 +139,6 @@ export const runCli = async () => {
cliResults.packages = [];
if (cliResults.flags.trpc) cliResults.packages.push("trpc");
if (cliResults.flags.tailwind) cliResults.packages.push("tailwind");
if (cliResults.flags.prisma) cliResults.packages.push("prisma");
if (cliResults.flags.nextAuth) cliResults.packages.push("nextAuth");
}

Expand Down
7 changes: 0 additions & 7 deletions cli/src/helpers/logNextSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { logger } from "~/utils/logger.js";
// This logs the next steps that the user should take in order to advance the project
export const logNextSteps = ({
projectName = DEFAULT_APP_NAME,
packages,
noInstall,
}: Pick<InstallerOptions, "projectName" | "packages" | "noInstall">) => {
const pkgManager = getUserPkgManager();
Expand All @@ -22,11 +21,5 @@ export const logNextSteps = ({
}
}

if (packages?.prisma.inUse) {
logger.info(
` ${pkgManager === "npm" ? "npx" : pkgManager} prisma db push`,
);
}

logger.info(` ${pkgManager === "npm" ? "npm run" : pkgManager} dev`);
};
20 changes: 1 addition & 19 deletions cli/src/installers/envVars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,15 @@ import { PKG_ROOT } from "~/consts.js";

export const envVariablesInstaller: Installer = ({ projectDir, packages }) => {
const usingAuth = packages?.nextAuth.inUse;
const usingPrisma = packages?.prisma.inUse;

const envAssetDir = path.join(PKG_ROOT, "template/addons/env");

let envSchemaFile = "";
let envContent =
"# When adding additional env variables, the schema in /env/schema.mjs should be updated accordingly\n";

switch (true) {
case usingAuth && usingPrisma:
envSchemaFile = "auth-prisma-schema.mjs";
break;
case usingAuth:
envSchemaFile = "auth-schema.mjs";
break;
case usingPrisma:
envSchemaFile = "prisma-schema.mjs";
break;
}

if (usingPrisma) {
envContent += `
# Prisma
DATABASE_URL=file:./db.sqlite
`;
}
if (usingAuth) {
envSchemaFile = "auth-schema.mjs";
envContent += `
# Next Auth
# You can generate the secret via 'openssl rand -base64 32' on Linux
Expand Down
11 changes: 0 additions & 11 deletions cli/src/installers/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { PackageManager } from "~/utils/getUserPkgManager.js";
import { envVariablesInstaller } from "~/installers/envVars.js";
import { nextAuthInstaller } from "~/installers/nextAuth.js";
import { prismaInstaller } from "~/installers/prisma.js";
import { threeInstaller } from "~/installers/three.js";
import { tailwindInstaller } from "~/installers/tailwind.js";
import { trpcInstaller } from "~/installers/trpc.js";
Expand All @@ -11,7 +10,6 @@ import { trpcInstaller } from "~/installers/trpc.js";
export const availablePackages = [
"nextAuth",
"three",
"prisma",
"tailwind",
"trpc",
"envVariables",
Expand All @@ -25,7 +23,6 @@ export type AvailablePackages = typeof availablePackages[number];
export const dependencyVersionMap = {
// NextAuth.js
"next-auth": "^4.18.3",
"@next-auth/prisma-adapter": "^1.0.5",

// Three JS
three: "^0.146.0",
Expand All @@ -34,10 +31,6 @@ export const dependencyVersionMap = {
"@react-three/postprocessing": "^2.7.0",
"@react-three/rapier": "^0.10.0",

// Prisma
prisma: "^4.5.0",
"@prisma/client": "^4.5.0",

// TailwindCSS
tailwindcss: "^3.2.0",
autoprefixer: "^10.4.7",
Expand Down Expand Up @@ -79,10 +72,6 @@ export const buildPkgInstallerMap = (
inUse: packages.includes("nextAuth"),
installer: nextAuthInstaller,
},
prisma: {
inUse: packages.includes("prisma"),
installer: prismaInstaller,
},
three: {
inUse: packages.includes("three"),
installer: threeInstaller,
Expand Down
8 changes: 2 additions & 6 deletions cli/src/installers/nextAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import fs from "fs-extra";
import { PKG_ROOT } from "~/consts.js";
import { addPackageDependency } from "~/utils/addPackageDependency.js";

export const nextAuthInstaller: Installer = ({ projectDir, packages }) => {
export const nextAuthInstaller: Installer = ({ projectDir }) => {
const deps: AvailableDependencies[] = ["next-auth"];
if (packages?.prisma.inUse) deps.push("@next-auth/prisma-adapter");

addPackageDependency({
projectDir,
Expand All @@ -16,10 +15,7 @@ export const nextAuthInstaller: Installer = ({ projectDir, packages }) => {

const nextAuthAssetDir = path.join(PKG_ROOT, "template/addons/next-auth");

const apiHandlerSrc = path.join(
nextAuthAssetDir,
packages?.prisma.inUse ? "api-handler-prisma.ts" : "api-handler.ts",
);
const apiHandlerSrc = path.join(nextAuthAssetDir, "api-handler.ts");
const apiHandlerDest = path.join(
projectDir,
"src/pages/api/auth/[...nextauth].ts",
Expand Down
46 changes: 0 additions & 46 deletions cli/src/installers/prisma.ts

This file was deleted.

2 changes: 1 addition & 1 deletion cli/src/installers/tailwind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const tailwindInstaller: Installer = ({ projectDir }) => {
const prettierDest = path.join(projectDir, "prettier.config.cjs");

const cssSrc = path.join(twAssetDir, "globals.css");
const cssDest = path.join(projectDir, "src/styles/globals.css");
const cssDest = path.join(projectDir, "src/css/tailwind.css");

const indexModuleCss = path.join(projectDir, "src/pages/index.module.css");

Expand Down
14 changes: 2 additions & 12 deletions cli/src/installers/trpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const trpcInstaller: Installer = ({ projectDir, packages }) => {
});

const usingAuth = packages?.nextAuth.inUse;
const usingPrisma = packages?.prisma.inUse;

const trpcAssetDir = path.join(PKG_ROOT, "template/addons/trpc");

Expand All @@ -33,14 +32,7 @@ export const trpcInstaller: Installer = ({ projectDir, packages }) => {
const serverUtilSrc = path.join(trpcAssetDir, serverUtilFile);
const serverUtilDest = path.join(projectDir, "src/server/trpc/trpc.ts");

const contextFile =
usingAuth && usingPrisma
? "auth-prisma-context.ts"
: usingAuth && !usingPrisma
? "auth-context.ts"
: !usingAuth && usingPrisma
? "prisma-context.ts"
: "base-context.ts";
const contextFile = usingAuth ? "auth-context.ts" : "base-context.ts";
const contextSrc = path.join(trpcAssetDir, contextFile);
const contextDest = path.join(projectDir, "src/server/trpc/context.ts");

Expand All @@ -57,9 +49,7 @@ export const trpcInstaller: Installer = ({ projectDir, packages }) => {
"src/server/trpc/router/_app.ts",
);

const exampleRouterFile = usingPrisma
? "example-prisma-router.ts"
: "example-router.ts";
const exampleRouterFile = "example-router.ts";
const exampleRouterSrc = path.join(trpcAssetDir, exampleRouterFile);
const exampleRouterDest = path.join(
projectDir,
Expand Down
30 changes: 0 additions & 30 deletions cli/template/addons/next-auth/api-handler-prisma.ts

This file was deleted.

66 changes: 0 additions & 66 deletions cli/template/addons/prisma/auth-schema.prisma

This file was deleted.

Loading

0 comments on commit 4acff78

Please sign in to comment.