create-template-project 0.1.0 → 0.3.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 (84) hide show
  1. package/README.md +11 -11
  2. package/dist/config/dependencies.json +60 -44
  3. package/dist/index.js +1221 -0
  4. package/dist/templates/base/files/.github/workflows/node.js.yml +5 -3
  5. package/dist/templates/base/files/.husky/commit-msg +1 -0
  6. package/dist/templates/base/files/.husky/pre-commit +1 -0
  7. package/dist/templates/base/files/.prettierignore +53 -0
  8. package/dist/templates/base/files/.prettierrc.json +4 -2
  9. package/dist/templates/base/files/AGENTS.md +5 -2
  10. package/dist/templates/base/files/README.md +36 -13
  11. package/dist/templates/base/files/_oxlint.config.ts +17 -33
  12. package/dist/templates/base/files/package.json +1 -1
  13. package/dist/templates/base/files/tsconfig.json +32 -32
  14. package/dist/templates/base/files/vitest.config.ts +11 -2
  15. package/dist/templates/cli/files/package.json +4 -3
  16. package/dist/templates/cli/files/src/index.test.ts +10 -2
  17. package/dist/templates/cli/files/src/index.ts +4 -1
  18. package/dist/templates/cli/files/src/lib.ts +10 -0
  19. package/dist/templates/cli/files/vite.config.ts +22 -0
  20. package/dist/templates/web-app/files/index.html +11 -0
  21. package/dist/templates/web-app/files/playwright.config.ts +26 -0
  22. package/dist/templates/web-app/files/src/App.test.tsx +9 -0
  23. package/dist/templates/web-app/files/src/App.tsx +14 -0
  24. package/dist/templates/web-app/files/src/index.tsx +8 -0
  25. package/dist/templates/web-app/files/tests/e2e/basic.e2e-test.ts +13 -0
  26. package/dist/templates/web-app/files/vite.config.ts +34 -0
  27. package/dist/templates/web-fullstack/files/client/index.html +10 -0
  28. package/dist/templates/{fullstack → web-fullstack}/files/client/package.json +2 -2
  29. package/dist/templates/web-fullstack/files/client/src/App.test.tsx +11 -0
  30. package/dist/templates/{fullstack → web-fullstack}/files/client/src/contexts/AuthContext.tsx +1 -5
  31. package/dist/templates/{fullstack → web-fullstack}/files/client/src/pages/Login.tsx +4 -33
  32. package/dist/templates/web-fullstack/files/client/vite.config.ts +30 -0
  33. package/dist/templates/{fullstack → web-fullstack}/files/package.json +1 -2
  34. package/dist/templates/web-fullstack/files/playwright.config.ts +33 -0
  35. package/dist/templates/{fullstack → web-fullstack}/files/server/package.json +2 -2
  36. package/dist/templates/web-fullstack/files/server/src/index.test.ts +28 -0
  37. package/dist/templates/{fullstack → web-fullstack}/files/server/src/trpc.ts +1 -1
  38. package/dist/templates/web-fullstack/files/server/vite.config.ts +24 -0
  39. package/dist/templates/web-fullstack/files/tests/e2e/basic.e2e-test.ts +14 -0
  40. package/dist/templates/web-vanilla/files/index.html +11 -0
  41. package/dist/templates/web-vanilla/files/package.json +17 -0
  42. package/dist/templates/web-vanilla/files/playwright.config.ts +26 -0
  43. package/dist/templates/web-vanilla/files/src/index.test.ts +12 -0
  44. package/dist/templates/web-vanilla/files/src/index.ts +3 -0
  45. package/dist/templates/web-vanilla/files/src/lib.ts +9 -0
  46. package/dist/templates/web-vanilla/files/tests/e2e/basic.e2e-test.ts +11 -0
  47. package/dist/templates/web-vanilla/files/vite.config.ts +28 -0
  48. package/package.json +25 -27
  49. package/dist/cli.mjs +0 -272
  50. package/dist/generators/project.mjs +0 -354
  51. package/dist/index.d.mts +0 -4
  52. package/dist/index.mjs +0 -32
  53. package/dist/templates/base/index.mjs +0 -16
  54. package/dist/templates/cli/files/tsdown.config.ts +0 -3
  55. package/dist/templates/cli/index.mjs +0 -16
  56. package/dist/templates/fullstack/files/client/index.html +0 -8
  57. package/dist/templates/fullstack/files/client/src/App.test.tsx +0 -8
  58. package/dist/templates/fullstack/files/client/tsdown.config.ts +0 -3
  59. package/dist/templates/fullstack/files/server/src/index.test.ts +0 -7
  60. package/dist/templates/fullstack/files/server/tsdown.config.ts +0 -3
  61. package/dist/templates/fullstack/index.mjs +0 -42
  62. package/dist/templates/webapp/files/backend/src/index.ts +0 -17
  63. package/dist/templates/webapp/files/frontend/index.html +0 -9
  64. package/dist/templates/webapp/files/frontend/src/index.ts +0 -4
  65. package/dist/templates/webapp/files/package.json +0 -13
  66. package/dist/templates/webapp/files/src/index.test.ts +0 -5
  67. package/dist/templates/webapp/files/tsdown.config.ts +0 -10
  68. package/dist/templates/webapp/index.mjs +0 -16
  69. package/dist/templates/webpage/files/index.html +0 -8
  70. package/dist/templates/webpage/files/package.json +0 -8
  71. package/dist/templates/webpage/files/src/index.test.ts +0 -5
  72. package/dist/templates/webpage/files/src/index.ts +0 -1
  73. package/dist/templates/webpage/index.mjs +0 -16
  74. package/dist/types.mjs +0 -30
  75. package/dist/utils/file.mjs +0 -101
  76. /package/dist/templates/{fullstack → web-fullstack}/files/client/src/App.tsx +0 -0
  77. /package/dist/templates/{fullstack → web-fullstack}/files/client/src/components/ProtectedRoute.tsx +0 -0
  78. /package/dist/templates/{fullstack → web-fullstack}/files/client/src/main.tsx +0 -0
  79. /package/dist/templates/{fullstack → web-fullstack}/files/client/src/pages/Dashboard.tsx +0 -0
  80. /package/dist/templates/{fullstack → web-fullstack}/files/client/src/trpc.ts +0 -0
  81. /package/dist/templates/{fullstack → web-fullstack}/files/server/src/context.ts +0 -0
  82. /package/dist/templates/{fullstack → web-fullstack}/files/server/src/index.ts +0 -0
  83. /package/dist/templates/{fullstack → web-fullstack}/files/server/src/routers/_app.ts +0 -0
  84. /package/dist/templates/{fullstack → web-fullstack}/files/server/src/routers/auth.ts +0 -0
@@ -1,15 +1,5 @@
1
1
  import {useState, FormEvent} from 'react';
2
- import {
3
- Button,
4
- TextField,
5
- Dialog,
6
- DialogActions,
7
- DialogContent,
8
- DialogTitle,
9
- Typography,
10
- Alert,
11
- Box,
12
- } from '@mui/material';
2
+ import {Button, TextField, Dialog, DialogActions, DialogContent, DialogTitle, Typography, Alert, Box} from '@mui/material';
13
3
  import {useAuth} from '../contexts/AuthContext.js';
14
4
  import {trpc} from '../trpc.js';
15
5
  import {useNavigate} from 'react-router-dom';
@@ -47,31 +37,12 @@ export const Login = () => {
47
37
  <Typography variant="body2" color="textSecondary">
48
38
  Use <b>demo@example.com</b> / <b>password</b> to login.
49
39
  </Typography>
50
- <TextField
51
- label="Email"
52
- type="email"
53
- fullWidth
54
- required
55
- value={email}
56
- onChange={(e) => setEmail(e.currentTarget.value)}
57
- />
58
- <TextField
59
- label="Password"
60
- type="password"
61
- fullWidth
62
- required
63
- value={password}
64
- onChange={(e) => setPassword(e.currentTarget.value)}
65
- />
40
+ <TextField label="Email" type="email" fullWidth required value={email} onChange={(e) => setEmail(e.currentTarget.value)} />
41
+ <TextField label="Password" type="password" fullWidth required value={password} onChange={(e) => setPassword(e.currentTarget.value)} />
66
42
  </Box>
67
43
  </DialogContent>
68
44
  <DialogActions>
69
- <Button
70
- type="submit"
71
- variant="contained"
72
- fullWidth
73
- disabled={loginMutation.isPending}
74
- >
45
+ <Button type="submit" variant="contained" fullWidth disabled={loginMutation.isPending}>
75
46
  {loginMutation.isPending ? 'Logging in...' : 'Login'}
76
47
  </Button>
77
48
  </DialogActions>
@@ -0,0 +1,30 @@
1
+ import path from 'node:path';
2
+ import {defineConfig} from 'vitest/config';
3
+ import react from '@vitejs/plugin-react';
4
+ import {playwright} from '@vitest/browser-playwright';
5
+
6
+ export default defineConfig({
7
+ plugins: [react()],
8
+ test: {
9
+ include: ['src/**/*.test.{ts,tsx}'],
10
+ coverage: {
11
+ provider: 'v8',
12
+ reporter: ['text', 'json', 'html'],
13
+ },
14
+ browser: {
15
+ enabled: true,
16
+ headless: true,
17
+ screenshotDirectory: path.resolve('./temp/vitest/__screenshots__'),
18
+ instances: [
19
+ {
20
+ browser: 'chromium',
21
+ provider: playwright({
22
+ launchOptions: {
23
+ args: ['--disable-web-security'],
24
+ },
25
+ }),
26
+ },
27
+ ],
28
+ },
29
+ },
30
+ });
@@ -24,8 +24,7 @@
24
24
  "@types/react-dom": "",
25
25
  "@types/express": "",
26
26
  "@types/cors": "",
27
- "@playwright/test": "",
28
- "tsdown": ""
27
+ "@playwright/test": ""
29
28
  },
30
29
  "scripts": {
31
30
  "build": "npm run build --workspaces",
@@ -0,0 +1,33 @@
1
+ import {defineConfig, devices} from '@playwright/test';
2
+
3
+ export default defineConfig({
4
+ testDir: './tests/e2e',
5
+ testMatch: '**/*.e2e-test.ts',
6
+ fullyParallel: true,
7
+ forbidOnly: !!process.env.CI,
8
+ retries: process.env.CI ? 2 : 0,
9
+ workers: process.env.CI ? 1 : undefined,
10
+ reporter: 'html',
11
+ use: {
12
+ baseURL: 'http://localhost:5173',
13
+ trace: 'on-first-retry',
14
+ },
15
+ projects: [
16
+ {
17
+ name: 'chromium',
18
+ use: {...devices['Desktop Chrome']},
19
+ },
20
+ ],
21
+ webServer: [
22
+ {
23
+ command: 'npm run dev --workspace=server',
24
+ port: 3000,
25
+ reuseExistingServer: !process.env.CI,
26
+ },
27
+ {
28
+ command: 'npm run dev --workspace=client',
29
+ port: 5173,
30
+ reuseExistingServer: !process.env.CI,
31
+ },
32
+ ],
33
+ });
@@ -3,8 +3,8 @@
3
3
  "version": "0.1.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
- "build": "tsdown",
7
- "dev": "tsdown --watch",
6
+ "build": "vite build",
7
+ "dev": "vite build --watch",
8
8
  "test": "vitest run"
9
9
  }
10
10
  }
@@ -0,0 +1,28 @@
1
+ import {describe, it, expect} from 'vitest';
2
+ import {appRouter} from './routers/_app.js';
3
+ import {createCallerFactory} from './trpc.js';
4
+
5
+ const createCaller = createCallerFactory(appRouter);
6
+
7
+ describe('auth router', () => {
8
+ it('should login successfully with valid credentials', async () => {
9
+ const caller = createCaller({user: null});
10
+ const result = await caller.auth.login({
11
+ email: 'demo@example.com',
12
+ password: 'password',
13
+ });
14
+
15
+ expect(result).toHaveProperty('token');
16
+ expect(result.user.email).toBe('demo@example.com');
17
+ });
18
+
19
+ it('should throw UNAUTHORIZED for invalid credentials', async () => {
20
+ const caller = createCaller({user: null});
21
+ await expect(
22
+ caller.auth.login({
23
+ email: 'wrong@example.com',
24
+ password: 'password123',
25
+ }),
26
+ ).rejects.toThrow(/Invalid email or password/);
27
+ });
28
+ });
@@ -4,8 +4,8 @@ import {Context} from './context.js';
4
4
  const t = initTRPC.context<Context>().create();
5
5
 
6
6
  export const router = t.router;
7
+ export const createCallerFactory = t.createCallerFactory;
7
8
  export const publicProcedure = t.procedure;
8
-
9
9
  export const protectedProcedure = t.procedure.use(({ctx, next}) => {
10
10
  if (!ctx.user) {
11
11
  throw new TRPCError({code: 'UNAUTHORIZED'});
@@ -0,0 +1,24 @@
1
+ import {defineConfig} from 'vitest/config';
2
+ import path from 'node:path';
3
+
4
+ export default defineConfig({
5
+ build: {
6
+ ssr: true,
7
+ lib: {
8
+ entry: path.resolve(__dirname, 'src/index.ts'),
9
+ formats: ['es'],
10
+ fileName: 'index',
11
+ },
12
+ outDir: 'dist',
13
+ emptyOutDir: true,
14
+ target: 'node22',
15
+ },
16
+ test: {
17
+ globals: true,
18
+ environment: 'node',
19
+ coverage: {
20
+ provider: 'v8',
21
+ reporter: ['text', 'json', 'html'],
22
+ },
23
+ },
24
+ });
@@ -0,0 +1,14 @@
1
+ import {test, expect} from '@playwright/test';
2
+
3
+ test('has title', async ({page}) => {
4
+ await page.goto('/');
5
+ await expect(page).toHaveTitle(/{{projectName}}/);
6
+ });
7
+
8
+ test('can login', async ({page}) => {
9
+ await page.goto('/login');
10
+ await page.fill('input[name="username"]', 'admin');
11
+ await page.fill('input[name="password"]', 'password');
12
+ await page.click('button[type="submit"]');
13
+ await expect(page).toHaveURL('/');
14
+ });
@@ -0,0 +1,11 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>{{projectName}}</title>
5
+ </head>
6
+ <body>
7
+ <h1>{{projectName}}</h1>
8
+ <div id="app"></div>
9
+ <script type="module" src="{{scriptSrc}}"></script>
10
+ </body>
11
+ </html>
@@ -0,0 +1,17 @@
1
+ {
2
+ "devDependencies": {
3
+ "vite": "",
4
+ "vitest": "",
5
+ "@vitest/browser": "",
6
+ "playwright": "",
7
+ "@playwright/test": ""
8
+ },
9
+ "scripts": {
10
+ "dev": "vite",
11
+ "build": "vite build",
12
+ "preview": "vite preview",
13
+ "test": "vitest run",
14
+ "test:ui": "vitest",
15
+ "test:e2e": "playwright test"
16
+ }
17
+ }
@@ -0,0 +1,26 @@
1
+ import {defineConfig, devices} from '@playwright/test';
2
+
3
+ export default defineConfig({
4
+ testDir: './tests/e2e',
5
+ testMatch: '**/*.e2e-test.ts',
6
+ fullyParallel: true,
7
+ forbidOnly: !!process.env.CI,
8
+ retries: process.env.CI ? 2 : 0,
9
+ workers: process.env.CI ? 1 : undefined,
10
+ reporter: 'html',
11
+ use: {
12
+ baseURL: 'http://localhost:5173',
13
+ trace: 'on-first-retry',
14
+ },
15
+ projects: [
16
+ {
17
+ name: 'chromium',
18
+ use: {...devices['Desktop Chrome']},
19
+ },
20
+ ],
21
+ webServer: {
22
+ command: 'npm run dev',
23
+ url: 'http://localhost:5173',
24
+ reuseExistingServer: !process.env.CI,
25
+ },
26
+ });
@@ -0,0 +1,12 @@
1
+ import {expect, test} from 'vitest';
2
+ import {page} from 'vitest/browser';
3
+ import {formatMessage, createHeading} from './lib.js';
4
+
5
+ test('formatMessage returns correct string', () => {
6
+ expect(formatMessage('World')).toBe('Hello, World!');
7
+ });
8
+
9
+ test('createHeading renders in the browser', async () => {
10
+ document.body.appendChild(createHeading('Browser Test'));
11
+ await expect.element(page.getByRole('heading', {name: 'Browser Test'})).toBeVisible();
12
+ });
@@ -0,0 +1,3 @@
1
+ import {createHeading} from './lib.js';
2
+
3
+ document.body.appendChild(createHeading('Hello from Web-Vanilla!'));
@@ -0,0 +1,9 @@
1
+ export const createHeading = (text: string): HTMLHeadingElement => {
2
+ const h1 = document.createElement('h1');
3
+ h1.textContent = text;
4
+ return h1;
5
+ };
6
+
7
+ export const formatMessage = (name: string): string => {
8
+ return `Hello, ${name}!`;
9
+ };
@@ -0,0 +1,11 @@
1
+ import {test, expect} from '@playwright/test';
2
+
3
+ test('has title', async ({page}) => {
4
+ await page.goto('/');
5
+ await expect(page).toHaveTitle(/{{projectName}}/);
6
+ });
7
+
8
+ test('header is visible', async ({page}) => {
9
+ await page.goto('/');
10
+ await expect(page.locator('h1')).toBeVisible();
11
+ });
@@ -0,0 +1,28 @@
1
+ import path from 'node:path';
2
+ import {defineConfig} from 'vitest/config';
3
+ import {playwright} from '@vitest/browser-playwright';
4
+
5
+ export default defineConfig({
6
+ test: {
7
+ include: ['src/**/*.test.ts'],
8
+ coverage: {
9
+ provider: 'v8',
10
+ reporter: ['text', 'json', 'html'],
11
+ },
12
+ browser: {
13
+ enabled: true,
14
+ headless: true,
15
+ screenshotDirectory: path.resolve('./temp/vitest/__screenshots__'),
16
+ instances: [
17
+ {
18
+ browser: 'chromium',
19
+ provider: playwright({
20
+ launchOptions: {
21
+ args: ['--disable-web-security'],
22
+ },
23
+ }),
24
+ },
25
+ ],
26
+ },
27
+ },
28
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-template-project",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Dieter Oberkofler",
@@ -14,32 +14,31 @@
14
14
  "typescript"
15
15
  ],
16
16
  "bin": {
17
- "create-template-project": "./dist/index.mjs"
17
+ "create-template-project": "./dist/index.js"
18
18
  },
19
19
  "scripts": {
20
- "run-interactive": "node dist/index.mjs interactive",
21
- "run-create-cli": "node dist/index.mjs create --name=my-cli --directory=./temp --template=cli --overwrite --package-manager=pnpm --build",
22
- "run-create-webpage": "node dist/index.mjs create --name=my-webpage --directory=./temp --template=webpage --package-manager=pnpm --overwrite --build",
23
- "run-create-webapp": "node dist/index.mjs create --name=my-webapp --directory=./temp --template=webapp --package-manager=pnpm --overwrite --build",
24
- "run-create-fullstack": "node dist/index.mjs create --name=my-fullstack --directory=./temp --template=fullstack --package-manager=pnpm --overwrite --build",
25
- "run-create-all": "npm run run-create-cli && npm run run-create-webpage && npm run run-create-webapp && npm run run-create-fullstack",
26
- "build": "tsdown && node scripts/copy-templates.ts",
20
+ "run-interactive": "node dist/index.js interactive",
21
+ "build": "vite build && node scripts/copy-templates.ts",
27
22
  "dependencies-check": "node scripts/dependencies.ts",
28
23
  "dependencies-update": "node scripts/dependencies.ts --update",
29
- "lint": "tsc && oxlint --ignore-pattern \"src/templates/**/files\" && npm run prettier",
24
+ "lint": "tsc && oxlint --ignore-pattern \"src/templates/**/files\" && pnpm run prettier",
30
25
  "prettier": "prettier --check .",
31
26
  "prettier-write": "prettier --write .",
32
- "test": "vitest run --coverage --exclude '**/*.integration.test.ts'",
33
- "test:integration": "vitest run src/generators/project.integration.test.ts --fileParallelism=false --testTimeout=600000",
34
- "ci": "npm run lint && npm run build && npm run test",
27
+ "test": "vitest run --coverage --exclude '**/*.integration.*.test.ts'",
28
+ "test:integration:cli": "node dist/index.js create --name=my-cli --directory=./temp --template=cli --overwrite --package-manager=pnpm --build --debug --no-progress",
29
+ "test:integration:web-vanilla": "node dist/index.js create --name=my-web-vanilla --directory=./temp --template=web-vanilla --package-manager=pnpm --overwrite --build --debug --no-progress",
30
+ "test:integration:web-app": "node dist/index.js create --name=my-web-app --directory=./temp --template=web-app --package-manager=pnpm --overwrite --build --debug --no-progress",
31
+ "test:integration:web-fullstack": "node dist/index.js create --name=my-web-fullstack --directory=./temp --template=web-fullstack --package-manager=pnpm --overwrite --build --debug --no-progress",
32
+ "test:integration": "pnpm run test:integration:cli && pnpm run test:integration:web-vanilla && pnpm run test:integration:web-app && pnpm run test:integration:web-fullstack",
33
+ "ci": "pnpm run lint && pnpm run build && pnpm run test",
35
34
  "create-changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
36
35
  "prepare": "husky"
37
36
  },
38
- "main": "./dist/index.mjs",
39
- "module": "./dist/index.mjs",
37
+ "main": "./dist/index.js",
38
+ "module": "./dist/index.js",
40
39
  "types": "./dist/index.d.ts",
41
40
  "exports": {
42
- ".": "./dist/index.mjs",
41
+ ".": "./dist/index.js",
43
42
  "./package.json": "./package.json"
44
43
  },
45
44
  "engines": {
@@ -51,29 +50,28 @@
51
50
  },
52
51
  "homepage": "https://github.com/doberkofler/create-template-project#readme",
53
52
  "devDependencies": {
54
- "@commitlint/cli": "20.4.4",
55
- "@commitlint/config-conventional": "20.4.4",
53
+ "@commitlint/cli": "20.5.0",
54
+ "@commitlint/config-conventional": "20.5.0",
56
55
  "@types/cli-progress": "3.11.6",
57
- "@types/debug": "4.1.12",
58
- "@types/node": "25.5.0",
56
+ "@types/debug": "4.1.13",
59
57
  "@vitest/coverage-v8": "4.1.0",
60
- "conventional-changelog": "^7.2.0",
58
+ "conventional-changelog": "7.2.0",
61
59
  "conventional-changelog-angular": "8.3.0",
62
60
  "eslint-plugin-regexp": "3.1.0",
63
61
  "husky": "9.1.7",
64
- "oxlint": "1.55.0",
65
- "oxlint-tsgolint": "0.16.0",
66
- "pnpm": "^10.32.1",
62
+ "oxlint": "1.56.0",
63
+ "oxlint-tsgolint": "0.17.1",
64
+ "pnpm": "10.32.1",
67
65
  "prettier": "3.8.1",
68
- "tsdown": "0.21.2",
69
66
  "typescript": "5.9.3",
67
+ "vite": "8.0.1",
70
68
  "vitest": "4.1.0"
71
69
  },
72
70
  "dependencies": {
73
- "@clack/prompts": "^1.1.0",
71
+ "@clack/prompts": "1.1.0",
74
72
  "commander": "14.0.3",
75
73
  "debug": "4.4.3",
76
- "execa": "^9.6.1",
74
+ "execa": "9.6.1",
77
75
  "zod": "4.3.6"
78
76
  }
79
77
  }