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

refactor: merge monorepo into next #322

Merged
merged 85 commits into from
Aug 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
e7c5059
chore(docs): updated readme to contain @next
juliusmarminge Jul 16, 2022
4d7a3d0
refactor: inject curried `runPkgManagerInstall` to package installers…
ochicf Jul 17, 2022
59f8ad4
feat: migrate env + next config to esm (#205)
danielroe Jul 17, 2022
5294902
chore: move lintstaged config into file (#217)
jln13x Jul 18, 2022
7111033
fix: move gitignore rename call (#215)
HaukeSchnau Jul 18, 2022
1fcec81
feat: add trpc inference helpers
juliusmarminge Jul 18, 2022
15ea5f1
fix(#218): lock react-query to v3
juliusmarminge Jul 18, 2022
8228475
chore(release): 5.1.0
juliusmarminge Jul 18, 2022
37b6283
fix: add missing trpc import
juliusmarminge Jul 18, 2022
cf7be5a
chore(release): 5.1.1
juliusmarminge Jul 18, 2022
5737beb
fix: handle pkg with version in noInstall mode (#220)
amyisdev Jul 19, 2022
9390400
fix: typo in readme
juliusmarminge Jul 19, 2022
0604d21
feat: add db.sqlite-journal to gitignore (#221)
c-ehrlich Jul 19, 2022
fc6519f
fix: typo - rename 'varibles' to 'variables' (#223)
c-ehrlich Jul 19, 2022
b6164d8
fix: missing DATABASE_URL (#222)
c-ehrlich Jul 19, 2022
4cd1402
chore(release): 5.2.0
juliusmarminge Jul 19, 2022
97c9e27
fix: update url in auth prisma schema
juliusmarminge Jul 19, 2022
08e30a0
chore(release): 5.2.1
juliusmarminge Jul 19, 2022
d4cf879
feat: add typesafe client side env variables (#209)
nramkissoon Jul 20, 2022
c881f00
fix: title being offset when using yarn/pnpm
juliusmarminge Jul 21, 2022
1cf9e95
chore(release): bump beta version
juliusmarminge Jul 21, 2022
f5368ac
chore: bump Next.js to 12.2.3
juliusmarminge Jul 22, 2022
efd8f7b
chore(release): bump beta version
juliusmarminge Jul 22, 2022
48c6720
feat: improved logo typography (#238)
c-ehrlich Jul 22, 2022
c904930
chore: bump beta version
nexxeln Jul 22, 2022
1be7713
fix: remove semicolon in _app.tsx with next-auth to avoid early return
nexxeln Jul 22, 2022
126aaae
chore: bump beta version
nexxeln Jul 22, 2022
4ad5c93
chore: add protected trpc router example (#194)
bhatvikrant Jul 22, 2022
53094bd
chore: add link to community (#229)
gcavanunez Jul 23, 2022
52c05b7
docs(readme): add usage for beta and next version (#243)
nexxeln Jul 23, 2022
abb0ee1
chore: add js files to format script (#244)
juliusmarminge Jul 23, 2022
b8a5b3b
chore: remove credentials provider (#246)
juliusmarminge Jul 23, 2022
5aa3865
refactor(cli): add module path aliasing (#247)
abui-am Jul 24, 2022
5b97367
feat: updating tailwind and postcss config's to use .cjs (#242)
JohnDaly Jul 24, 2022
2048783
fix: clarify some comments and rename some files in env (#245)
juliusmarminge Jul 24, 2022
451f7c2
chore(release): bump beta version
juliusmarminge Jul 24, 2022
9cb5ebb
fix: added JSDoc type to clientEnv in all env-schema (#240)
Duckapple Jul 25, 2022
cebef68
chore(release): 5.3.0
juliusmarminge Jul 25, 2022
8507982
refactor(utils): remove unnecessary block (#252)
fernandoxu Jul 25, 2022
8671e8d
chore: update favicon (#253)
nramkissoon Jul 25, 2022
ed42629
fix: missing next-auth types (#255)
zomars Jul 26, 2022
fe86915
fix: height on small screens (#256)
c-ehrlich Jul 26, 2022
f4f7bd8
docs: expand t3-app README (#248)
juliusmarminge Jul 27, 2022
79f3553
revert: extend regular next-auth module (#257)
juliusmarminge Jul 27, 2022
c7d4dce
feat: add deployment strategy to generated README (#258)
nexxeln Jul 29, 2022
37bb958
docs: add instructions on building docker image to readme (#265)
Krish120003 Jul 29, 2022
38a55fd
docs: small adjustments (#266)
juliusmarminge Jul 29, 2022
2179f2d
feat: set appName to directory on 'npx create-t3-app .' (#273)
c-ehrlich Aug 1, 2022
e9507c8
fix(prisma): make db changes for next-auth on mysql obvious (#275)
cyremur Aug 2, 2022
f6474c6
chore(release): 5.4.0
juliusmarminge Aug 2, 2022
6a81f03
feat: make session.user.id non-nullable (#282)
c-ehrlich Aug 5, 2022
9392374
chore(release): 5.5.0
juliusmarminge Aug 7, 2022
f060d59
docs: update tRPC v10 docs link (#291)
Samathingamajig Aug 8, 2022
7822c43
fix: change ! reversion to equality in env validation (#293)
khalil-omer Aug 11, 2022
0be4a97
feat: Include ct3a version as metadata in generated app (#305)
c-ehrlich Aug 11, 2022
b55f196
fix: parse path returned from process.cwd() before using it (#303)
BWsix Aug 11, 2022
0790af7
chore(release): 5.6.0
juliusmarminge Aug 11, 2022
47ab51d
chore: upload T3 logo to github (#311)
nexxeln Aug 12, 2022
bd1819d
chore: ignore package-lock (#315)
juliusmarminge Aug 15, 2022
ad53911
chore: Publish Workflow and other Github enhancements (#308)
juliusmarminge Aug 15, 2022
10561e0
chore(ci): dont use reserved word `package`
juliusmarminge Aug 15, 2022
a7dd1a8
chore(ci): require -> import
juliusmarminge Aug 15, 2022
9dce2f4
chore(ci): authenticate to npm
juliusmarminge Aug 15, 2022
cb61f26
chore: update pr-template
juliusmarminge Aug 15, 2022
e5e3fca
chore(ci): next-release
juliusmarminge Aug 15, 2022
5e0212f
chore(ci): release workflow
juliusmarminge Aug 15, 2022
060d0ad
chore(ci): update scrips
juliusmarminge Aug 15, 2022
75f97ff
chore(ci): update release versioning
juliusmarminge Aug 15, 2022
a04ac90
chore(ci): update versioning scripts
juliusmarminge Aug 15, 2022
143af66
chore(ci): fix no-bin error
juliusmarminge Aug 15, 2022
7a76c95
feat: add base tslint (#317)
juliusmarminge Aug 15, 2022
5d06f24
chore(ci): test changeset with npx
juliusmarminge Aug 15, 2022
a1a2720
chore(ci): test npm
juliusmarminge Aug 15, 2022
d9a1d78
chore(ci): give proper commit message and title
juliusmarminge Aug 15, 2022
775aa29
chore(release): remove standard-version msg from changelog
juliusmarminge Aug 15, 2022
d2d620d
chore(release): version packages (#319)
github-actions[bot] Aug 15, 2022
0f0fc56
chore(release): public access
juliusmarminge Aug 15, 2022
a9e7621
Merge branch 'main' of https://github.com/t3-oss/create-t3-app
juliusmarminge Aug 15, 2022
3bd4482
refactor: turborepo with cli and www (#320)
juliusmarminge Aug 16, 2022
8087812
chore: set type module
juliusmarminge Aug 16, 2022
2ad7770
fix: typo in pub-script
juliusmarminge Aug 16, 2022
489bca5
fix: create npmrc in cli pkg
juliusmarminge Aug 16, 2022
b7d0c28
fix: path in version script
juliusmarminge Aug 16, 2022
ea0b259
refactor: turborepo next
juliusmarminge Aug 16, 2022
98f3899
chore: merge conflicts
juliusmarminge Aug 16, 2022
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
Prev Previous commit
Next Next commit
refactor: turborepo next
  • Loading branch information
juliusmarminge committed Aug 16, 2022
commit ea0b259467f674c46f897a99eeae8c2c66349f80
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
build/
dist/
dist/
.docusaurus
15 changes: 3 additions & 12 deletions cli/src/helpers/createProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { installPackages } from "~/helpers/installPackages.js";
import { scaffoldProject } from "~/helpers/scaffoldProject.js";
import { selectAppFile, selectIndexFile } from "~/helpers/selectBoilerplate.js";
import { getUserPkgManager } from "~/utils/getUserPkgManager.js";
import { curryRunPkgManagerInstall } from "~/utils/runPkgManagerInstall.js";

interface CreateProjectOptions {
projectName: string;
Expand All @@ -19,34 +18,26 @@ export const createProject = async ({
}: CreateProjectOptions) => {
const pkgManager = getUserPkgManager();
const projectDir = path.resolve(process.cwd(), projectName);
const runPkgManagerInstall = curryRunPkgManagerInstall({
projectDir,
pkgManager,
devMode: false,
noInstallMode: noInstall,
});

// Bootstraps the base Next.js application
await scaffoldProject({
projectName,
projectDir,
pkgManager,
noInstall,
runPkgManagerInstall,
});

// Install the selected packages
await installPackages({
installPackages({
projectDir,
pkgManager,
packages,
noInstall,
runPkgManagerInstall,
});

// TODO: Look into using handlebars or other templating engine to scaffold without needing to maintain multiple copies of the same file
await selectAppFile({ projectDir, packages });
await selectIndexFile({ projectDir, packages });
selectAppFile({ projectDir, packages });
selectIndexFile({ projectDir, packages });

return projectDir;
};
8 changes: 4 additions & 4 deletions cli/src/helpers/initGit.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import { execSync } from "child_process";
import chalk from "chalk";
import ora from "ora";
import { execa } from "~/utils/execAsync.js";
import { logger } from "~/utils/logger.js";

// This initializes the Git-repository for the project
export const initializeGit = async (projectDir: string) => {
export const initializeGit = (projectDir: string) => {
logger.info("Initializing Git...");
const spinner = ora("Creating a new git repo...\n").start();
try {
let initCmd = "git init --initial-branch=main";

// --initial-branch flag was added in git v2.28.0
const { stdout: gitVersionOutput } = await execa("git --version"); // git version 2.32.0 ...
const gitVersionOutput = execSync("git --version").toString(); // git version 2.32.0 ...
const gitVersionTag = gitVersionOutput.split(" ")[2];
const major = gitVersionTag?.split(".")[0];
const minor = gitVersionTag?.split(".")[1];
if (Number(major) < 2 || Number(minor) < 28) {
initCmd = "git init && git branch -m main";
}

await execa(initCmd, { cwd: projectDir });
execSync(initCmd, { cwd: projectDir });
spinner.succeed(
`${chalk.green("Successfully initialized")} ${chalk.green.bold("git")}\n`,
);
Expand Down
15 changes: 15 additions & 0 deletions cli/src/helpers/installDependencies.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { execSync } from "child_process";
import ora from "ora";
import { getUserPkgManager } from "~/utils/getUserPkgManager.js";
import { logger } from "~/utils/logger.js";

export const installDependencies = (projectDir: string) => {
logger.info("Installing dependencies...");
const pkgManager = getUserPkgManager();
const command = `${pkgManager} install`;
const spinner = ora(`Running ${command}...\n`).start();

execSync(command, { cwd: projectDir });

spinner.succeed("Successfully installed dependencies!\n");
};
18 changes: 7 additions & 11 deletions cli/src/helpers/installPackages.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { InstallerOptions, PkgInstallerMap } from "../installers/index.js";
import type { InstallerOptions, PkgInstallerMap } from "~/installers/index.js";
import chalk from "chalk";
import ora from "ora";
import { logger } from "~/utils/logger.js";
Expand All @@ -7,21 +7,17 @@ type InstallPackagesOptions = {
packages: PkgInstallerMap;
} & InstallerOptions;
// This runs the installer for all the packages that the user has selected
export const installPackages = async (options: InstallPackagesOptions) => {
const { packages, noInstall } = options;
logger.info(`${noInstall ? "Adding" : "Installing"} packages...`);
export const installPackages = (options: InstallPackagesOptions) => {
const { packages } = options;
logger.info("Adding boilerplate...");

for (const [name, pkgOpts] of Object.entries(packages)) {
if (pkgOpts.inUse) {
const spinner = ora(
`${noInstall ? "Adding" : "Installing"} ${name}...`,
).start();
await pkgOpts.installer(options);
const spinner = ora(`Boilerplating ${name}...`).start();
pkgOpts.installer(options);
spinner.succeed(
chalk.green(
`Successfully ${noInstall ? "added" : "installed"} ${chalk.green.bold(
name,
)}`,
`Successfully setup boilerplate for ${chalk.green.bold(name)}`,
),
);
}
Expand Down
8 changes: 2 additions & 6 deletions cli/src/helpers/scaffoldProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import inquirer from "inquirer";
import ora from "ora";
import { PKG_ROOT } from "~/consts.js";
import { InstallerOptions } from "~/installers/index.js";
import { execa } from "~/utils/execAsync.js";
import { logger } from "~/utils/logger.js";

// This bootstraps the base Next.js application
Expand Down Expand Up @@ -56,14 +55,11 @@ export const scaffoldProject = async ({

spinner.start();

await fs.copy(srcDir, projectDir);
await fs.rename(
fs.copySync(srcDir, projectDir);
fs.renameSync(
path.join(projectDir, "_gitignore"),
path.join(projectDir, ".gitignore"),
);

if (!noInstall) {
await execa(`${pkgManager} install`, { cwd: projectDir });
}
spinner.succeed(`${chalk.cyan.bold(projectName)} scaffolded successfully!\n`);
};
8 changes: 4 additions & 4 deletions cli/src/helpers/selectBoilerplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type SelectBoilerplateProps = Required<
Pick<InstallerOptions, "projectDir" | "packages">
>;
// This generates the _app.tsx file that is used to render the app
export const selectAppFile = async ({
export const selectAppFile = ({
projectDir,
packages,
}: SelectBoilerplateProps) => {
Expand All @@ -28,12 +28,12 @@ export const selectAppFile = async ({
if (appFile !== "") {
const appSrc = path.join(appFileDir, appFile);
const appDest = path.join(projectDir, "src/pages/_app.tsx");
await fs.copy(appSrc, appDest);
fs.copySync(appSrc, appDest);
}
};

// This selects the proper index.tsx to be used that showcases the chosen tech
export const selectIndexFile = async ({
export const selectIndexFile = ({
projectDir,
packages,
}: SelectBoilerplateProps) => {
Expand Down Expand Up @@ -61,6 +61,6 @@ export const selectIndexFile = async ({
if (indexFile !== "") {
const indexSrc = path.join(indexFileDir, indexFile);
const indexDest = path.join(projectDir, "src/pages/index.tsx");
await fs.copy(indexSrc, indexDest);
fs.copySync(indexSrc, indexDest);
}
};
19 changes: 13 additions & 6 deletions cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env node
import type { PackageJson } from "type-fest";
import path from "path";
import fs from "fs-extra";
import { PackageJson } from "type-fest";
import { getVersion } from "./utils/getT3Version.js";
import { runCli } from "~/cli/index.js";
import { createProject } from "~/helpers/createProject.js";
import { initializeGit } from "~/helpers/initGit.js";
Expand All @@ -11,6 +10,8 @@ import { buildPkgInstallerMap } from "~/installers/index.js";
import { logger } from "~/utils/logger.js";
import { parseNameAndPath } from "~/utils/parseNameAndPath.js";
import { renderTitle } from "~/utils/renderTitle.js";
import { installDependencies } from "./helpers/installDependencies.js";
import { getVersion } from "./utils/getT3Version.js";

type CT3APackageJSON = PackageJson & {
ct3aMetadata?: {
Expand Down Expand Up @@ -38,17 +39,23 @@ const main = async () => {
noInstall,
});

if (!noInstall) {
installDependencies(projectDir);
}

if (!noGit) {
await initializeGit(projectDir);
initializeGit(projectDir);
}

logNextSteps({ projectName: appDir, packages: usePackages, noInstall });
const pkgJson = (await fs.readJSON(

// Write name to package.json
const pkgJson = fs.readJSONSync(
path.join(projectDir, "package.json"),
)) as CT3APackageJSON;
) as CT3APackageJSON;
pkgJson.name = scopedAppName;
pkgJson.ct3aMetadata = { initVersion: getVersion() };
await fs.writeJSON(path.join(projectDir, "package.json"), pkgJson, {
fs.writeJSONSync(path.join(projectDir, "package.json"), pkgJson, {
spaces: 2,
});

Expand Down
13 changes: 4 additions & 9 deletions cli/src/installers/envVars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import path from "path";
import fs from "fs-extra";
import { PKG_ROOT } from "~/consts.js";

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

Expand All @@ -31,11 +28,9 @@ export const envVariablesInstaller: Installer = async ({
const envSchemaSrc = path.join(envAssetDir, envFile);
const envSchemaDest = path.join(projectDir, "src/env/schema.mjs");

const envExampleSrc = path.join(projectDir, ".env-example");
const envExample = path.join(projectDir, ".env-example");
const envDest = path.join(projectDir, ".env");

await Promise.all([
fs.copy(envSchemaSrc, envSchemaDest, { overwrite: true }),
fs.rename(envExampleSrc, envDest),
]);
fs.copySync(envSchemaSrc, envSchemaDest);
fs.renameSync(envExample, envDest);
};
37 changes: 30 additions & 7 deletions cli/src/installers/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { PackageManager } from "~/utils/getUserPkgManager.js";
import type { CurriedRunPkgManagerInstallOptions } from "~/utils/runPkgManagerInstall.js";
import { envVariablesInstaller as envVariablesInstaller } from "~/installers/envVars.js";
import { envVariablesInstaller } from "~/installers/envVars.js";
import { nextAuthInstaller } from "~/installers/nextAuth.js";
import { prismaInstaller } from "~/installers/prisma.js";
import { tailwindInstaller } from "~/installers/tailwind.js";
Expand All @@ -15,21 +14,45 @@ export const availablePackages = [
"trpc",
"envVariables",
] as const;

export type AvailablePackages = typeof availablePackages[number];

/*
* This maps the necessary packages to a version.
* This improves performance significantly over fetching it from the npm registry.
*/
export const dependencyVersionMap = {
// NextAuth.js
"next-auth": "^4.10.2",
"@next-auth/prisma-adapter": "^1.0.4",

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

// TailwindCSS
tailwindcss: "^3.1.6",
autoprefixer: "^10.4.7",
postcss: "^8.4.14",

// tRPC
"@trpc/client": "10.0.0-alpha.41",
"@trpc/server": "10.0.0-alpha.41",
"@trpc/react": "10.0.0-alpha.41",
"@trpc/next": "10.0.0-alpha.41",
"react-query": "^3.39.2",
superjson: "^1.9.1",
} as const;
export type AvailableDependencies = keyof typeof dependencyVersionMap;

export interface InstallerOptions {
projectDir: string;
pkgManager: PackageManager;
noInstall: boolean;
packages?: PkgInstallerMap;
projectName?: string;
runPkgManagerInstall: (
opts: CurriedRunPkgManagerInstallOptions,
) => Promise<void>;
}

export type Installer = (opts: InstallerOptions) => Promise<void>;
export type Installer = (opts: InstallerOptions) => void;

export type PkgInstallerMap = {
[pkg in AvailablePackages]: {
Expand Down
29 changes: 13 additions & 16 deletions cli/src/installers/nextAuth.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import type { Installer } from "~/installers/index.js";
import type { Installer, AvailableDependencies } from "~/installers/index.js";
import path from "path";
import fs from "fs-extra";
import { PKG_ROOT } from "~/consts.js";
import { addPackageDependency } from "~/utils/addPackageDependency.js";

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

addPackageDependency({
projectDir,
dependencies: deps,
devMode: false,
});

const nextAuthAssetDir = path.join(PKG_ROOT, "template/addons/next-auth");
Expand All @@ -38,9 +37,7 @@ export const nextAuthInstaller: Installer = async ({
"src/types/next-auth.d.ts",
);

await Promise.all([
fs.copy(apiHandlerSrc, apiHandlerDest),
fs.copy(restrictedApiSrc, restrictedApiDest),
fs.copy(nextAuthDefinitionSrc, nextAuthDefinitionDest),
]);
fs.copySync(apiHandlerSrc, apiHandlerDest);
fs.copySync(restrictedApiSrc, restrictedApiDest);
fs.copySync(nextAuthDefinitionSrc, nextAuthDefinitionDest);
};
Loading