@absterr/nestkit 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +62 -2
  3. package/dist/cli.js +439 -0
  4. package/dist/options.js +98 -0
  5. package/dist/package-managers.js +23 -0
  6. package/dist/scaffold.js +158 -0
  7. package/dist/settings.js +52 -0
  8. package/dist/versions.js +33 -0
  9. package/package.json +47 -4
  10. package/templates/agent-files/11/AGENTS.md +24 -0
  11. package/templates/agent-files/12/AGENTS.md +39 -0
  12. package/templates/agent-files/common/CLAUDE.md +1 -0
  13. package/templates/base/README.md +70 -0
  14. package/templates/base/gitattributes +1 -0
  15. package/templates/base/gitignore +8 -0
  16. package/templates/base/nest-cli.json +11 -0
  17. package/templates/base/package.json +32 -0
  18. package/templates/base/src/app.controller.ts +12 -0
  19. package/templates/base/src/app.module.ts +10 -0
  20. package/templates/base/src/app.service.ts +8 -0
  21. package/templates/base/src/main.ts +13 -0
  22. package/templates/cjs-module/package.json +7 -0
  23. package/templates/code-quality/biome/biome.json +47 -0
  24. package/templates/code-quality/biome/package.json +14 -0
  25. package/templates/code-quality/eslint/eslint.config.mjs +35 -0
  26. package/templates/code-quality/eslint/package.json +14 -0
  27. package/templates/code-quality/oxlint/.oxlintrc.json +8 -0
  28. package/templates/code-quality/oxlint/package.json +10 -0
  29. package/templates/code-quality/prettier/.prettierignore +10 -0
  30. package/templates/code-quality/prettier/.prettierrc +7 -0
  31. package/templates/code-quality/prettier/package.json +9 -0
  32. package/templates/e2e-tests/cypress/gitignore +2 -0
  33. package/templates/e2e-tests/cypress/package.json +12 -0
  34. package/templates/e2e-tests/cypress/test/app.cy.ts +10 -0
  35. package/templates/e2e-tests/cypress/test/cypress.config.mjs +9 -0
  36. package/templates/e2e-tests/cypress/test/tsconfig.json +8 -0
  37. package/templates/e2e-tests/e2e-scripts/package.json +5 -0
  38. package/templates/e2e-tests/e2e-scripts/scripts/test-e2e.mjs +48 -0
  39. package/templates/e2e-tests/playwright/gitignore +2 -0
  40. package/templates/e2e-tests/playwright/package.json +8 -0
  41. package/templates/e2e-tests/playwright/test/app.e2e-spec.ts +8 -0
  42. package/templates/e2e-tests/playwright/test/playwright.config.mjs +9 -0
  43. package/templates/e2e-tests/runner-configs/jest/test/jest-e2e.json +9 -0
  44. package/templates/e2e-tests/runner-configs/mocha/cjs-mocha/test/.mocharc.e2e.json +5 -0
  45. package/templates/e2e-tests/runner-configs/mocha/esm-mocha/test/.mocharc.e2e.json +5 -0
  46. package/templates/e2e-tests/runner-configs/vitest/test/vitest.config.e2e.mjs +15 -0
  47. package/templates/e2e-tests/selenium/jest-selenium/package.json +5 -0
  48. package/templates/e2e-tests/selenium/jest-selenium/test/app.e2e-spec.ts +25 -0
  49. package/templates/e2e-tests/selenium/mocha-selenium/package.json +5 -0
  50. package/templates/e2e-tests/selenium/mocha-selenium/test/app.e2e-spec.ts +28 -0
  51. package/templates/e2e-tests/selenium/package.json +6 -0
  52. package/templates/e2e-tests/selenium/vitest-selenium/package.json +5 -0
  53. package/templates/e2e-tests/selenium/vitest-selenium/test/app.e2e-spec.ts +26 -0
  54. package/templates/e2e-tests/supertest/jest-supertest/package.json +5 -0
  55. package/templates/e2e-tests/supertest/jest-supertest/test/app.e2e-spec.ts +29 -0
  56. package/templates/e2e-tests/supertest/mocha-supertest/package.json +5 -0
  57. package/templates/e2e-tests/supertest/mocha-supertest/test/app.e2e-spec.ts +30 -0
  58. package/templates/e2e-tests/supertest/package.json +6 -0
  59. package/templates/e2e-tests/supertest/vitest-supertest/package.json +5 -0
  60. package/templates/e2e-tests/supertest/vitest-supertest/test/app.e2e-spec.ts +30 -0
  61. package/templates/environment/arktype/package.json +5 -0
  62. package/templates/environment/arktype/src/config/env/env.schema.ts +12 -0
  63. package/templates/environment/arktype/src/config/env/validate.ts +12 -0
  64. package/templates/environment/class-validator/package.json +6 -0
  65. package/templates/environment/class-validator/src/config/env/env.schema.ts +15 -0
  66. package/templates/environment/class-validator/src/config/env/validate.ts +15 -0
  67. package/templates/environment/common/package.json +5 -0
  68. package/templates/environment/common/src/app.module.ts +11 -0
  69. package/templates/environment/common/src/config/env/env.module.ts +17 -0
  70. package/templates/environment/common/src/config/env/env.provider.ts +17 -0
  71. package/templates/environment/common/src/main.ts +15 -0
  72. package/templates/environment/joi/package.json +5 -0
  73. package/templates/environment/joi/src/config/env/env.schema.ts +16 -0
  74. package/templates/environment/joi/src/config/env/validate.ts +16 -0
  75. package/templates/environment/valibot/package.json +5 -0
  76. package/templates/environment/valibot/src/config/env/env.schema.ts +20 -0
  77. package/templates/environment/valibot/src/config/env/validate.ts +16 -0
  78. package/templates/environment/vanilla/src/config/env/env.schema.ts +26 -0
  79. package/templates/environment/vanilla/src/config/env/validate.ts +18 -0
  80. package/templates/environment/zod/package.json +5 -0
  81. package/templates/environment/zod/src/config/env/env.schema.ts +11 -0
  82. package/templates/environment/zod/src/config/env/validate.ts +19 -0
  83. package/templates/esm-module/package.json +3 -0
  84. package/templates/test-runners/common/package.json +5 -0
  85. package/templates/test-runners/jest/eslint-jest/eslint.config.mjs +36 -0
  86. package/templates/test-runners/jest/package.json +7 -0
  87. package/templates/test-runners/mocha/package.json +8 -0
  88. package/templates/test-runners/vitest/eslint-vitest/eslint.config.mjs +43 -0
  89. package/templates/test-runners/vitest/package.json +7 -0
  90. package/templates/unit-tests/common/gitignore +1 -0
  91. package/templates/unit-tests/common/nest-cli.json +8 -0
  92. package/templates/unit-tests/jest/jest.config.json +10 -0
  93. package/templates/unit-tests/jest/package.json +7 -0
  94. package/templates/unit-tests/jest/src/app.controller.spec.ts +22 -0
  95. package/templates/unit-tests/mocha/cjs-mocha/.mocharc.json +5 -0
  96. package/templates/unit-tests/mocha/cjs-mocha/package.json +5 -0
  97. package/templates/unit-tests/mocha/esm-mocha/.mocharc.json +5 -0
  98. package/templates/unit-tests/mocha/package.json +9 -0
  99. package/templates/unit-tests/mocha/src/app.controller.spec.ts +23 -0
  100. package/templates/unit-tests/vitest/package.json +10 -0
  101. package/templates/unit-tests/vitest/src/app.controller.spec.ts +23 -0
  102. package/templates/unit-tests/vitest/vitest.config.mjs +14 -0
  103. package/templates/versions/11/tsconfig.build.json +4 -0
  104. package/templates/versions/11/tsconfig.json +26 -0
  105. package/templates/versions/12/tsconfig.build.json +8 -0
  106. package/templates/versions/12/tsconfig.json +27 -0
@@ -0,0 +1,5 @@
1
+ {
2
+ "dependencies": {
3
+ "valibot": "^1.5.0"
4
+ }
5
+ }
@@ -0,0 +1,20 @@
1
+ import * as v from "valibot";
2
+
3
+ const port = v.pipe(
4
+ v.unknown(),
5
+ v.transform(Number),
6
+ v.integer(),
7
+ v.minValue(1),
8
+ v.maxValue(65535)
9
+ );
10
+
11
+ // Add environment variables types here
12
+ export const envSchema = v.object({
13
+ NODE_ENV: v.optional(
14
+ v.picklist(["development", "production", "test"]),
15
+ "development"
16
+ ),
17
+ PORT: v.optional(port, 3000),
18
+ });
19
+
20
+ export type EnvironmentVariables = v.InferOutput<typeof envSchema>;
@@ -0,0 +1,16 @@
1
+ import * as v from "valibot";
2
+ import { envSchema } from "./env.schema";
3
+
4
+ export default function validate(config: Record<string, unknown>) {
5
+ const result = v.safeParse(envSchema, config, { abortPipeEarly: true });
6
+
7
+ if (!result.success) {
8
+ const formatted = result.issues.map(formatIssue).join("\n");
9
+ throw new Error(`Config validation error:\n${formatted}`);
10
+ }
11
+
12
+ return result.output;
13
+ }
14
+
15
+ const formatIssue = (issue: v.BaseIssue<unknown>) =>
16
+ `${v.getDotPath(issue)}: ${issue.message}`;
@@ -0,0 +1,26 @@
1
+ // Add environment variables types and rules here
2
+ export const envSchema = {
3
+ NODE_ENV: {
4
+ default: "development" as const,
5
+ validate: (value: unknown) =>
6
+ ["development", "production", "test"].includes(String(value)),
7
+ },
8
+ PORT: {
9
+ default: 3000,
10
+ validate: (value: unknown) => {
11
+ const port = Number(value);
12
+ return Number.isInteger(port) && port >= 1 && port <= 65535;
13
+ },
14
+ transform: Number,
15
+ },
16
+ };
17
+
18
+ type Schema = typeof envSchema;
19
+
20
+ export type EnvironmentVariables = {
21
+ [K in keyof Schema]: Schema[K]["default"] extends string
22
+ ? Schema[K]["default"] extends "development"
23
+ ? "development" | "production" | "test"
24
+ : Schema[K]["default"]
25
+ : number;
26
+ };
@@ -0,0 +1,18 @@
1
+ import { type EnvironmentVariables, envSchema } from "./env.schema";
2
+
3
+ export default function validate(config: Record<string, unknown>) {
4
+ const result: Record<string, unknown> = {};
5
+
6
+ for (const [key, rule] of Object.entries(envSchema)) {
7
+ const value = config[key] ?? rule.default;
8
+ const parsed = "transform" in rule ? rule.transform(value) : value;
9
+
10
+ if (!rule.validate(parsed)) {
11
+ throw new Error(`Config validation error: ${key} is invalid`);
12
+ }
13
+
14
+ result[key] = parsed;
15
+ }
16
+
17
+ return result as EnvironmentVariables;
18
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "dependencies": {
3
+ "zod": "^4.6.7"
4
+ }
5
+ }
@@ -0,0 +1,11 @@
1
+ import { z } from "zod";
2
+
3
+ // Add environment variables types here
4
+ export const envSchema = z.object({
5
+ NODE_ENV: z
6
+ .enum(["development", "production", "test"])
7
+ .default("development"),
8
+ PORT: z.coerce.number().int().min(1).max(65535).default(3000),
9
+ });
10
+
11
+ export type EnvironmentVariables = z.infer<typeof envSchema>;
@@ -0,0 +1,19 @@
1
+ import { z } from "zod";
2
+ import { envSchema } from "./env.schema";
3
+
4
+ export default function validate(config: Record<string, unknown>) {
5
+ const parsed = envSchema.safeParse(config);
6
+
7
+ if (!parsed.success) {
8
+ const formatted = formatZodIssues(parsed.error.issues);
9
+ throw new Error(`Config validation error:\n${formatted}`);
10
+ }
11
+
12
+ return parsed.data;
13
+ }
14
+
15
+ const formatZodIssue = (issue: z.core.$ZodIssue) =>
16
+ `${issue.path.join(".")}: ${issue.message}`;
17
+
18
+ const formatZodIssues = (issues: z.core.$ZodIssue[]) =>
19
+ issues.map(formatZodIssue).join("\n");
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "devDependencies": {
3
+ "@nestjs/testing": "^11.0.1"
4
+ }
5
+ }
@@ -0,0 +1,36 @@
1
+ // @ts-check
2
+ import eslint from "@eslint/js";
3
+ import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
4
+ import { defineConfig } from "eslint/config";
5
+ import globals from "globals";
6
+ import tseslint from "typescript-eslint";
7
+
8
+ export default defineConfig(
9
+ {
10
+ ignores: ["eslint.config.mjs", "**/*.mjs", "dist/**"],
11
+ },
12
+ eslint.configs.recommended,
13
+ ...tseslint.configs.recommendedTypeChecked,
14
+ eslintPluginPrettierRecommended,
15
+ {
16
+ languageOptions: {
17
+ globals: {
18
+ ...globals.node,
19
+ ...globals.jest,
20
+ },
21
+ sourceType: "commonjs",
22
+ parserOptions: {
23
+ projectService: true,
24
+ tsconfigRootDir: import.meta.dirname,
25
+ },
26
+ },
27
+ },
28
+ {
29
+ rules: {
30
+ "@typescript-eslint/no-explicit-any": "warn",
31
+ "@typescript-eslint/no-floating-promises": "warn",
32
+ "@typescript-eslint/no-unsafe-argument": "warn",
33
+ "prettier/prettier": ["error", { endOfLine: "auto" }],
34
+ },
35
+ }
36
+ );
@@ -0,0 +1,7 @@
1
+ {
2
+ "devDependencies": {
3
+ "@types/jest": "^30.0.0",
4
+ "jest": "^30.0.0",
5
+ "ts-jest": "^29.2.5"
6
+ }
7
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "devDependencies": {
3
+ "@swc-node/register": "^1.12.1",
4
+ "@swc/core": "^1.16.22",
5
+ "@types/mocha": "^10.0.10",
6
+ "mocha": "^12.0.3"
7
+ }
8
+ }
@@ -0,0 +1,43 @@
1
+ // @ts-check
2
+ import eslint from "@eslint/js";
3
+ import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
4
+ import { defineConfig } from "eslint/config";
5
+ import globals from "globals";
6
+ import tseslint from "typescript-eslint";
7
+
8
+ export default defineConfig(
9
+ {
10
+ ignores: ["eslint.config.mjs", "**/*.mjs", "dist/**"],
11
+ },
12
+ eslint.configs.recommended,
13
+ ...tseslint.configs.recommendedTypeChecked,
14
+ eslintPluginPrettierRecommended,
15
+ {
16
+ languageOptions: {
17
+ globals: {
18
+ ...globals.node,
19
+ },
20
+ sourceType: "commonjs",
21
+ parserOptions: {
22
+ projectService: true,
23
+ tsconfigRootDir: import.meta.dirname,
24
+ },
25
+ },
26
+ },
27
+ {
28
+ rules: {
29
+ "@typescript-eslint/no-explicit-any": "warn",
30
+ "@typescript-eslint/no-floating-promises": "warn",
31
+ "@typescript-eslint/no-unsafe-argument": "warn",
32
+ "prettier/prettier": ["error", { endOfLine: "auto" }],
33
+ },
34
+ },
35
+ {
36
+ files: ["src/**/*.spec.ts", "test/**/*.ts"],
37
+ rules: {
38
+ "@typescript-eslint/no-unsafe-assignment": "off",
39
+ "@typescript-eslint/no-unsafe-call": "off",
40
+ "@typescript-eslint/no-unsafe-member-access": "off",
41
+ },
42
+ }
43
+ );
@@ -0,0 +1,7 @@
1
+ {
2
+ "devDependencies": {
3
+ "@swc/core": "^1.16.22",
4
+ "unplugin-swc": "^2.0.0",
5
+ "vitest": "^5.1.0"
6
+ }
7
+ }
@@ -0,0 +1 @@
1
+ /coverage
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/nest-cli",
3
+ "collection": "@nestjs/schematics",
4
+ "sourceRoot": "src",
5
+ "compilerOptions": {
6
+ "deleteOutDir": true
7
+ }
8
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "rootDir": ".",
3
+ "testEnvironment": "node",
4
+ "testMatch": ["<rootDir>/src/**/*.spec.ts"],
5
+ "transform": {
6
+ "^.+\\.ts$": "ts-jest"
7
+ },
8
+ "collectCoverageFrom": ["src/**/*.ts", "!src/**/*.spec.ts"],
9
+ "coverageDirectory": "coverage"
10
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "scripts": {
3
+ "test": "jest",
4
+ "test:watch": "jest --watch",
5
+ "test:cov": "jest --coverage"
6
+ }
7
+ }
@@ -0,0 +1,22 @@
1
+ import { Test, TestingModule } from "@nestjs/testing";
2
+ import { AppController } from "./app.controller";
3
+ import { AppService } from "./app.service";
4
+
5
+ describe("AppController", () => {
6
+ let appController: AppController;
7
+
8
+ beforeEach(async () => {
9
+ const app: TestingModule = await Test.createTestingModule({
10
+ controllers: [AppController],
11
+ providers: [AppService],
12
+ }).compile();
13
+
14
+ appController = app.get<AppController>(AppController);
15
+ });
16
+
17
+ describe("root", () => {
18
+ it('should return "Hello World!"', () => {
19
+ expect(appController.getHello()).toBe("Hello World!");
20
+ });
21
+ });
22
+ });
@@ -0,0 +1,5 @@
1
+ {
2
+ "require": ["reflect-metadata", "@swc-node/register"],
3
+ "extension": ["ts"],
4
+ "spec": ["src/**/*.spec.ts"]
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "scripts": {
3
+ "test:watch": "mocha --watch"
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "node-option": ["import=@swc-node/register/esm-register"],
3
+ "extension": ["ts"],
4
+ "spec": ["src/**/*.spec.ts"]
5
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "scripts": {
3
+ "test": "mocha",
4
+ "test:cov": "c8 mocha"
5
+ },
6
+ "devDependencies": {
7
+ "c8": "^12.0.0"
8
+ }
9
+ }
@@ -0,0 +1,23 @@
1
+ import { Test, TestingModule } from "@nestjs/testing";
2
+ import assert from "node:assert/strict";
3
+ import { AppController } from "./app.controller";
4
+ import { AppService } from "./app.service";
5
+
6
+ describe("AppController", () => {
7
+ let appController: AppController;
8
+
9
+ beforeEach(async () => {
10
+ const app: TestingModule = await Test.createTestingModule({
11
+ controllers: [AppController],
12
+ providers: [AppService],
13
+ }).compile();
14
+
15
+ appController = app.get<AppController>(AppController);
16
+ });
17
+
18
+ describe("root", () => {
19
+ it('should return "Hello World!"', () => {
20
+ assert.equal(appController.getHello(), "Hello World!");
21
+ });
22
+ });
23
+ });
@@ -0,0 +1,10 @@
1
+ {
2
+ "scripts": {
3
+ "test": "vitest run",
4
+ "test:watch": "vitest",
5
+ "test:cov": "vitest run --coverage"
6
+ },
7
+ "devDependencies": {
8
+ "@vitest/coverage-v8": "^5.1.0"
9
+ }
10
+ }
@@ -0,0 +1,23 @@
1
+ import { Test, TestingModule } from "@nestjs/testing";
2
+ import { beforeEach, describe, expect, it } from "vitest";
3
+ import { AppController } from "./app.controller";
4
+ import { AppService } from "./app.service";
5
+
6
+ describe("AppController", () => {
7
+ let appController: AppController;
8
+
9
+ beforeEach(async () => {
10
+ const app: TestingModule = await Test.createTestingModule({
11
+ controllers: [AppController],
12
+ providers: [AppService],
13
+ }).compile();
14
+
15
+ appController = app.get<AppController>(AppController);
16
+ });
17
+
18
+ describe("root", () => {
19
+ it('should return "Hello World!"', () => {
20
+ expect(appController.getHello()).toBe("Hello World!");
21
+ });
22
+ });
23
+ });
@@ -0,0 +1,14 @@
1
+ import swc from "unplugin-swc";
2
+ import { defineConfig } from "vitest/config";
3
+
4
+ export default defineConfig({
5
+ plugins: [
6
+ swc.vite({
7
+ module: { type: "es6" },
8
+ }),
9
+ ],
10
+ test: {
11
+ environment: "node",
12
+ include: ["src/**/*.spec.ts"],
13
+ },
14
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
4
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "nodenext",
4
+ "moduleResolution": "nodenext",
5
+ "resolvePackageJsonExports": true,
6
+ "esModuleInterop": true,
7
+ "isolatedModules": true,
8
+ "declaration": true,
9
+ "removeComments": true,
10
+ "emitDecoratorMetadata": true,
11
+ "experimentalDecorators": true,
12
+ "allowSyntheticDefaultImports": true,
13
+ "target": "ES2023",
14
+ "sourceMap": true,
15
+ "outDir": "./dist",
16
+ "baseUrl": "./",
17
+ "incremental": true,
18
+ "skipLibCheck": true,
19
+ "strictNullChecks": true,
20
+ "forceConsistentCasingInFileNames": true,
21
+ "noImplicitAny": false,
22
+ "strictBindCallApply": false,
23
+ "noFallthroughCasesInSwitch": false
24
+ },
25
+ "include": ["src/**/*", "test/**/*"]
26
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "./src"
5
+ },
6
+ "include": ["src"],
7
+ "exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
8
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "nodenext",
4
+ "moduleResolution": "nodenext",
5
+ "resolvePackageJsonExports": true,
6
+ "esModuleInterop": true,
7
+ "isolatedModules": true,
8
+ "declaration": true,
9
+ "removeComments": true,
10
+ "emitDecoratorMetadata": true,
11
+ "experimentalDecorators": true,
12
+ "allowSyntheticDefaultImports": true,
13
+ "target": "ES2023",
14
+ "sourceMap": true,
15
+ "outDir": "./dist",
16
+ "rootDir": "./",
17
+ "types": ["node"],
18
+ "incremental": true,
19
+ "skipLibCheck": true,
20
+ "strictNullChecks": true,
21
+ "forceConsistentCasingInFileNames": true,
22
+ "noImplicitAny": false,
23
+ "strictBindCallApply": false,
24
+ "noFallthroughCasesInSwitch": false
25
+ },
26
+ "include": ["src/**/*", "test/**/*"]
27
+ }