Skip to content

Commit 14579dd

Browse files
committed
feat!: add nestjs support
BREAKING CHANGE: different eslint rules
1 parent 652b776 commit 14579dd

43 files changed

Lines changed: 10817 additions & 65 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- main
7+
- next
78

89
jobs:
910
release:

.releaserc.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
export default {
2-
branches: ["main"],
2+
branches: [
3+
"main",
4+
{
5+
name: "next",
6+
prerelease: "beta",
7+
channel: "next",
8+
},
9+
],
310
plugins: [
411
"@semantic-release/commit-analyzer",
512
"@semantic-release/release-notes-generator",

bin/index.js

100644100755
File mode changed.

eslint.config.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
// eslint-disable-next-line antfu/no-import-dist
12
import { solvro } from "./dist/eslint/index.js";
23

3-
export default solvro({
4-
files: ["./src/cli/**/*.ts"],
5-
rules: {
6-
"unicorn/no-process-exit": "off",
4+
export default solvro(
5+
{
6+
rules: {
7+
"unicorn/no-process-exit": "off",
8+
},
79
},
8-
});
10+
{
11+
ignores: ["tests/**"],
12+
},
13+
);

src/cli/index.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ if (!isGitClean()) {
2525

2626
const packageJson = new PackageJson();
2727

28-
await packageJson.ensureESM();
29-
3028
const projectType = await packageJson.getProjectType();
3129

3230
if (projectType === "adonis") {
@@ -38,11 +36,13 @@ if (projectType === "adonis") {
3836
p.cancel("Zgłoś błąd na GitHubie :(, a my spróbujemy pomóc.");
3937
process.exit(1);
4038
}
39+
40+
await packageJson.ensureESM();
4141
}
4242

43-
if (projectType === "next") {
43+
if (projectType === "react") {
4444
const isConfirmed = await polishConfirm({
45-
message: `Wygląda jakbyś używał Next.js. Czy to się zgadza?`,
45+
message: `Wygląda jakbyś używał Reacta. Czy to się zgadza?`,
4646
});
4747

4848
if (p.isCancel(isConfirmed)) {
@@ -54,11 +54,24 @@ if (projectType === "next") {
5454
p.cancel("Zgłoś błąd na GitHubie :(, a my spróbujemy pomóc.");
5555
process.exit(1);
5656
}
57+
58+
await packageJson.ensureESM();
59+
}
60+
61+
if (projectType === "nestjs") {
62+
const isConfirmed = await polishConfirm({
63+
message: `Wygląda jakbyś używał NestJsa. Czy to się zgadza?`,
64+
});
65+
66+
if (p.isCancel(isConfirmed)) {
67+
p.cancel("😡");
68+
process.exit(1);
69+
}
5770
}
5871

5972
if (projectType === "node") {
6073
p.cancel(
61-
"Nie znaleziono ani Adonisa, ani Next.js. Musisz ręcznie konfigurować projekt.",
74+
"Nie znaleziono ani Adonisa, Reacta, ani NestJsa. Musisz ręcznie konfigurować projekt.",
6275
);
6376
process.exit(1);
6477
}

src/cli/install-commitlint.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { writeFile } from "fs/promises";
2-
import path from "path";
1+
import { writeFile } from "node:fs/promises";
2+
import path from "node:path";
33

44
import { gitRoot } from "../utils/git-root";
55
import { PackageJson } from "../utils/package-json";

src/cli/install-eslint.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const installEslint = async () => {
3333

3434
const type = await packageJson.getProjectType();
3535

36-
if (type === "next") {
36+
if (type === "react" && (await packageJson.hasPackage("next"))) {
3737
const is15 = await packageJson.doesSatisfies("next", ">=15");
3838

3939
if (!is15) {
@@ -53,7 +53,7 @@ export const installEslint = async () => {
5353
if (eslintConfig !== undefined) {
5454
const eslintContent = await fs.readFile(
5555
path.join(root, eslintConfig),
56-
"utf-8",
56+
"utf8",
5757
);
5858

5959
if (eslintContent.includes("export default solvro(")) {

src/cli/install-ga.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ import { PackageJson } from "../utils/package-json";
88
import { adonisCi } from "./templates/adonis-ci";
99
import { adonisMigrationsCi } from "./templates/adonis-ci-migrations";
1010
import { dependabot } from "./templates/dependabot";
11-
import { nextCi } from "./templates/next-ci";
11+
import { reactCi } from "./templates/react-ci";
1212

1313
const packageJson = new PackageJson();
1414

1515
export const installGithubActions = async () => {
1616
const root = gitRoot();
1717
await packageJson.load();
1818

19-
const ghWorkflowsDir = path.join(root, ".github/workflows");
20-
await fs.mkdir(ghWorkflowsDir, { recursive: true });
19+
const ghWorkflowsDirectory = path.join(root, ".github/workflows");
20+
await fs.mkdir(ghWorkflowsDirectory, { recursive: true });
2121

2222
const type = await packageJson.getProjectType();
2323

@@ -32,23 +32,23 @@ export const installGithubActions = async () => {
3232
}
3333

3434
await fs.writeFile(
35-
path.join(ghWorkflowsDir, "ci.yml"),
35+
path.join(ghWorkflowsDirectory, "ci.yml"),
3636
adonisCi({
3737
nodeVersion: "22",
3838
withCommitlint,
3939
}),
4040
);
4141

4242
await fs.writeFile(
43-
path.join(ghWorkflowsDir, "db.yml"),
43+
path.join(ghWorkflowsDirectory, "db.yml"),
4444
adonisMigrationsCi(),
4545
);
4646
}
4747

48-
if (type === "next") {
48+
if (type === "react") {
4949
await fs.writeFile(
50-
path.join(ghWorkflowsDir, "ci.yml"),
51-
nextCi({
50+
path.join(ghWorkflowsDirectory, "ci.yml"),
51+
reactCi({
5252
nodeVersion: "22",
5353
withCommitlint,
5454
}),

src/cli/install-lint-staged.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import assert from "assert";
2-
import { writeFile } from "fs/promises";
1+
import assert from "node:assert";
2+
import { writeFile } from "node:fs/promises";
33

44
import { PackageJson } from "../utils/package-json";
55
import { installHusky } from "./install-husky";

src/cli/templates/nestjs-ci.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { commitLintCi } from "./commit-lint-ci";
2+
3+
export const nestjsCi = ({
4+
nodeVersion,
5+
withCommitlint,
6+
}: {
7+
nodeVersion: string;
8+
withCommitlint: boolean;
9+
}) => `name: CI
10+
11+
on:
12+
push:
13+
branches: ["main"]
14+
pull_request:
15+
16+
jobs:
17+
lint:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Setup node
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: ${nodeVersion}
29+
cache: "npm"
30+
31+
- name: Install dependencies
32+
run: npm ci
33+
${withCommitlint ? commitLintCi() : ""}
34+
- name: Run prettier
35+
run: npm run format:check
36+
if: always()
37+
38+
- name: Run Lint
39+
run: npm run lint
40+
if: always()
41+
42+
- name: Check types
43+
run: npm run typecheck
44+
if: always()
45+
46+
- name: Run tests
47+
run: npm test
48+
if: always()
49+
50+
- name: Run e2e tests
51+
run: npm run test:e2e
52+
if: always()
53+
54+
- name: Build
55+
run: npm run build
56+
if: always()`;

0 commit comments

Comments
 (0)