Skip to content

Commit

Permalink
Revert "feat: add import order sorting via prettier (#1392)"
Browse files Browse the repository at this point in the history
This reverts commit e1a5245.
  • Loading branch information
juliusmarminge committed May 17, 2023
1 parent e1a5245 commit 966ab3e
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 226 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ jobs:
tailwind: ["true", "false"]
nextAuth: ["true", "false"]
prisma: ["true", "false"]
prettierAndExtendedEslint: ["true", "false"]

name: "Build and Start T3 App ${{ matrix.trpc }}-${{ matrix.tailwind }}-${{ matrix.nextAuth }}-${{ matrix.prisma }}-${{ matrix.prettierAndExtendedEslint }}"
name: "Build and Start T3 App ${{ matrix.trpc }}-${{ matrix.tailwind }}-${{ matrix.nextAuth }}-${{ matrix.prisma }}"
steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -66,7 +65,7 @@ jobs:
# has to be scaffolded outside the CLI project so that no lint/tsconfig are leaking
# through. this way it ensures that it is the app's configs that are being used
# FIXME: this is a bit hacky, would rather have --packages=trpc,tailwind,... but not sure how to setup the matrix for that
- run: cd cli && pnpm start ../../ci-${{ matrix.trpc }}-${{ matrix.tailwind }}-${{ matrix.nextAuth }}-${{ matrix.prisma }}-${{ matrix.prettierAndExtendedEslint }} --noGit --CI --trpc=${{ matrix.trpc }} --tailwind=${{ matrix.tailwind }} --nextAuth=${{ matrix.nextAuth }} --prisma=${{ matrix.prisma }} --prettier-and-extended-eslint=${{ matrix.prettierAndExtendedEslint }}
- run: cd ../ci-${{ matrix.trpc }}-${{ matrix.tailwind }}-${{ matrix.nextAuth }}-${{ matrix.prisma }}-${{ matrix.prettierAndExtendedEslint }} && pnpm build
- run: cd cli && pnpm start ../../ci-${{ matrix.trpc }}-${{ matrix.tailwind }}-${{ matrix.nextAuth }}-${{ matrix.prisma }} --noGit --CI --trpc=${{ matrix.trpc }} --tailwind=${{ matrix.tailwind }} --nextAuth=${{ matrix.nextAuth }} --prisma=${{ matrix.prisma }}
- run: cd ../ci-${{ matrix.trpc }}-${{ matrix.tailwind }}-${{ matrix.nextAuth }}-${{ matrix.prisma }} && pnpm build
env:
NEXTAUTH_SECRET: foo
33 changes: 2 additions & 31 deletions cli/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import chalk from "chalk";
import { Command } from "commander";
import inquirer from "inquirer";
import { CREATE_T3_APP, DEFAULT_APP_NAME } from "~/consts.js";
import {
availablePackages,
type AvailablePackages,
} from "~/installers/index.js";
import { type AvailablePackages } from "~/installers/index.js";
import { availablePackages } from "~/installers/index.js";
import { getVersion } from "~/utils/getT3Version.js";
import { getUserPkgManager } from "~/utils/getUserPkgManager.js";
import { logger } from "~/utils/logger.js";
Expand All @@ -17,7 +15,6 @@ interface CliFlags {
noInstall: boolean;
default: boolean;
importAlias: string;
prettierAndExtendedEslint: boolean;

/** @internal Used in CI. */
CI: boolean;
Expand Down Expand Up @@ -50,7 +47,6 @@ const defaultOptions: CliResults = {
prisma: false,
nextAuth: false,
importAlias: "~/",
prettierAndExtendedEslint: false,
},
};

Expand Down Expand Up @@ -118,12 +114,6 @@ export const runCli = async () => {
"Explicitly tell the CLI to use a custom import alias",
defaultOptions.flags.importAlias,
)
/** @experimental - Used for CI E2E tests. Used in conjunction with `--CI` to skip prompting. */
.option(
"-p, --prettier-and-extended-eslint",
"Explicitly tell the CLI to use a custom import alias",
defaultOptions.flags.prettierAndExtendedEslint,
)
/** END CI-FLAGS */
.version(getVersion(), "-v, --version", "Display the version number")
.addHelpText(
Expand Down Expand Up @@ -163,9 +153,6 @@ export const runCli = async () => {
if (cliResults.flags.tailwind) cliResults.packages.push("tailwind");
if (cliResults.flags.prisma) cliResults.packages.push("prisma");
if (cliResults.flags.nextAuth) cliResults.packages.push("nextAuth");
if (cliResults.flags.prettierAndExtendedEslint) {
cliResults.flags.prettierAndExtendedEslint = true;
}
}

// Explained below why this is in a try/catch block
Expand Down Expand Up @@ -199,9 +186,6 @@ export const runCli = async () => {
}

cliResults.flags.importAlias = await promptImportAlias();

cliResults.flags.prettierAndExtendedEslint =
await promtPrettierAndExtendedEslint();
}
} catch (err) {
// If the user is not calling create-t3-app from an interactive terminal, inquirer will throw an error with isTTYError = true
Expand Down Expand Up @@ -345,16 +329,3 @@ const promptImportAlias = async (): Promise<string> => {

return importAlias;
};

const promtPrettierAndExtendedEslint = async (): Promise<boolean> => {
const { prettierAndExtendedEslint } = await inquirer.prompt<
Pick<CliFlags, "prettierAndExtendedEslint">
>({
name: "prettierAndExtendedEslint",
type: "confirm",
message: "Would you like to use prettier and extended eslint conifg?",
default: defaultOptions.flags.prettierAndExtendedEslint,
});

return prettierAndExtendedEslint;
};
14 changes: 0 additions & 14 deletions cli/src/helpers/createProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,20 @@ import path from "path";
import { installPackages } from "~/helpers/installPackages.js";
import { scaffoldProject } from "~/helpers/scaffoldProject.js";
import { selectAppFile, selectIndexFile } from "~/helpers/selectBoilerplate.js";
import { installExtendedEslint } from "~/installers/eslint.js";
import { type PkgInstallerMap } from "~/installers/index.js";
import { installPrettier } from "~/installers/prettier.js";
import { getUserPkgManager } from "~/utils/getUserPkgManager.js";

interface CreateProjectOptions {
projectName: string;
packages: PkgInstallerMap;
noInstall: boolean;
importAlias: string;
prettierAndExtendedEslint: boolean;
}

export const createProject = async ({
projectName,
packages,
noInstall,
prettierAndExtendedEslint,
}: CreateProjectOptions) => {
const pkgManager = getUserPkgManager();
const projectDir = path.resolve(process.cwd(), projectName);
Expand All @@ -40,16 +36,6 @@ export const createProject = async ({
noInstall,
});

if (prettierAndExtendedEslint) {
const installArgs = {
projectDir,
pkgManager,
noInstall,
};
installPrettier(installArgs);
installExtendedEslint(installArgs);
}

// TODO: Look into using handlebars or other templating engine to scaffold without needing to maintain multiple copies of the same file
selectAppFile({ projectDir, packages });
selectIndexFile({ projectDir, packages });
Expand Down
13 changes: 5 additions & 8 deletions cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const main = async () => {
const {
appName,
packages,
flags: { noGit, noInstall, importAlias, prettierAndExtendedEslint },
flags: { noGit, noInstall, importAlias },
} = await runCli();

const usePackages = buildPkgInstallerMap(packages);
Expand All @@ -45,7 +45,6 @@ const main = async () => {
packages: usePackages,
importAlias: importAlias,
noInstall,
prettierAndExtendedEslint,
});

// Write name to package.json
Expand All @@ -68,12 +67,10 @@ const main = async () => {
}

// Rename _eslintrc.json to .eslintrc.json - we use _eslintrc.json to avoid conflicts with the monorepos linter
if (fs.existsSync(path.join(projectDir, "_eslintrc.cjs"))) {
fs.renameSync(
path.join(projectDir, "_eslintrc.cjs"),
path.join(projectDir, ".eslintrc.cjs"),
);
}
fs.renameSync(
path.join(projectDir, "_eslintrc.cjs"),
path.join(projectDir, ".eslintrc.cjs"),
);

if (!noGit) {
await initializeGit(projectDir);
Expand Down
12 changes: 3 additions & 9 deletions cli/src/installers/dependencyVersionMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export const dependencyVersionMap = {
tailwindcss: "^3.3.0",
autoprefixer: "^10.4.14",
postcss: "^8.4.21",
prettier: "^2.8.6",
"prettier-plugin-tailwindcss": "^0.2.6",
"@types/prettier": "^2.7.2",

// tRPC
"@trpc/client": "^10.18.0",
Expand All @@ -23,14 +26,5 @@ export const dependencyVersionMap = {
"@trpc/next": "^10.18.0",
"@tanstack/react-query": "^4.28.0",
superjson: "1.12.2",

// Prettier
prettier: "^2.8.6",
"prettier-plugin-tailwindcss": "^0.2.6",
"@types/prettier": "^2.7.2",
"@ianvs/prettier-plugin-sort-imports": "^3.7.2",

// Eslint
"eslint-config-next": "^13.4.1",
} as const;
export type AvailableDependencies = keyof typeof dependencyVersionMap;
23 changes: 0 additions & 23 deletions cli/src/installers/eslint.ts

This file was deleted.

55 changes: 0 additions & 55 deletions cli/src/installers/prettier.ts

This file was deleted.

13 changes: 12 additions & 1 deletion cli/src/installers/tailwind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ import { addPackageDependency } from "~/utils/addPackageDependency.js";
export const tailwindInstaller: Installer = ({ projectDir }) => {
addPackageDependency({
projectDir,
dependencies: ["tailwindcss", "postcss", "autoprefixer"],
dependencies: [
"tailwindcss",
"postcss",
"autoprefixer",
"prettier",
"prettier-plugin-tailwindcss",
"@types/prettier",
],
devMode: true,
});

Expand All @@ -19,12 +26,16 @@ export const tailwindInstaller: Installer = ({ projectDir }) => {
const postcssCfgSrc = path.join(extrasDir, "config/postcss.config.cjs");
const postcssCfgDest = path.join(projectDir, "postcss.config.cjs");

const prettierSrc = path.join(extrasDir, "config/prettier.config.cjs");
const prettierDest = path.join(projectDir, "prettier.config.cjs");

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

fs.copySync(twCfgSrc, twCfgDest);
fs.copySync(postcssCfgSrc, postcssCfgDest);
fs.copySync(cssSrc, cssDest);
fs.copySync(prettierSrc, prettierDest);

// Remove vanilla css file
const indexModuleCss = path.join(projectDir, "src/pages/index.module.css");
Expand Down
26 changes: 0 additions & 26 deletions cli/src/utils/addPackageScript.ts

This file was deleted.

22 changes: 22 additions & 0 deletions cli/template/base/_eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,33 @@ const path = require("path");

/** @type {import("eslint").Linter.Config} */
const config = {
overrides: [
{
extends: [
"plugin:@typescript-eslint/recommended-requiring-type-checking",
],
files: ["*.ts", "*.tsx"],
parserOptions: {
project: path.join(__dirname, "tsconfig.json"),
},
},
],
parser: "@typescript-eslint/parser",
parserOptions: {
project: path.join(__dirname, "tsconfig.json"),
},
plugins: ["@typescript-eslint"],
extends: ["next/core-web-vitals", "plugin:@typescript-eslint/recommended"],
rules: {
"@typescript-eslint/consistent-type-imports": [
"warn",
{
prefer: "type-imports",
fixStyle: "inline-type-imports",
},
],
"@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }],
},
};

module.exports = config;
1 change: 1 addition & 0 deletions cli/template/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"eslint": "^8.36.0",
"eslint-config-next": "^13.4.1",
"typescript": "^5.0.2"
}
}

0 comments on commit 966ab3e

Please sign in to comment.