create-template-project 0.2.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.
- package/README.md +3 -3
- package/dist/config/dependencies.json +10 -14
- package/dist/index.js +1221 -0
- package/dist/templates/base/files/.husky/commit-msg +1 -0
- package/dist/templates/base/files/.husky/pre-commit +1 -0
- package/dist/templates/base/files/.prettierignore +3 -0
- package/dist/templates/base/files/package.json +1 -1
- package/dist/templates/base/files/vitest.config.ts +10 -1
- package/dist/templates/cli/files/package.json +4 -3
- package/dist/templates/cli/files/src/index.test.ts +10 -2
- package/dist/templates/cli/files/src/index.ts +4 -1
- package/dist/templates/cli/files/src/lib.ts +10 -0
- package/dist/templates/cli/files/vite.config.ts +22 -0
- package/dist/templates/web-app/files/src/App.test.tsx +9 -0
- package/dist/templates/web-app/files/src/App.tsx +14 -0
- package/dist/templates/web-app/files/src/index.tsx +1 -14
- package/dist/templates/web-app/files/vite.config.ts +4 -0
- package/dist/templates/web-fullstack/files/client/src/App.test.tsx +5 -2
- package/dist/templates/web-fullstack/files/client/vite.config.ts +4 -0
- package/dist/templates/web-fullstack/files/package.json +1 -2
- package/dist/templates/web-fullstack/files/server/src/index.test.ts +24 -3
- package/dist/templates/web-fullstack/files/server/src/trpc.ts +1 -1
- package/dist/templates/web-fullstack/files/server/vite.config.ts +6 -3
- package/dist/templates/web-vanilla/files/index.html +1 -1
- package/dist/templates/web-vanilla/files/src/index.test.ts +9 -2
- package/dist/templates/web-vanilla/files/src/index.ts +3 -1
- package/dist/templates/web-vanilla/files/src/lib.ts +9 -0
- package/dist/templates/web-vanilla/files/vite.config.ts +4 -0
- package/package.json +13 -18
- package/dist/cli.mjs +0 -308
- package/dist/generators/info.mjs +0 -58
- package/dist/generators/project.mjs +0 -387
- package/dist/index.d.mts +0 -4
- package/dist/index.mjs +0 -35
- package/dist/templates/base/index.mjs +0 -55
- package/dist/templates/cli/files/tsdown.config.ts +0 -3
- package/dist/templates/cli/index.mjs +0 -29
- package/dist/templates/web-app/files/src/index.test.ts +0 -5
- package/dist/templates/web-app/index.mjs +0 -69
- package/dist/templates/web-fullstack/index.mjs +0 -78
- package/dist/templates/web-vanilla/index.mjs +0 -45
- package/dist/types.mjs +0 -30
- package/dist/utils/file.mjs +0 -119
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npx --no -- commitlint --edit "$1"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{{packageManager}} run ci
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"prettier-write": "prettier --write .",
|
|
9
9
|
"test": "vitest run --coverage",
|
|
10
10
|
"ci": "npm run lint && npm run build && npm run test",
|
|
11
|
+
"create-changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
|
|
11
12
|
"prepare": "husky"
|
|
12
13
|
},
|
|
13
14
|
"dependencies": {
|
|
@@ -24,7 +25,6 @@
|
|
|
24
25
|
"oxlint": "",
|
|
25
26
|
"oxlint-tsgolint": "",
|
|
26
27
|
"eslint-plugin-regexp": "",
|
|
27
|
-
"tinyexec": "",
|
|
28
28
|
"prettier": "",
|
|
29
29
|
"typescript": "",
|
|
30
30
|
"vitest": ""
|
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import {defineConfig} from 'vitest/config';
|
|
2
2
|
|
|
3
|
-
export default defineConfig({
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
coverage: {
|
|
6
|
+
provider: 'v8',
|
|
7
|
+
reporter: ['text', 'json', 'html'],
|
|
8
|
+
include: ['src/**/*.ts', 'src/**/*.tsx'],
|
|
9
|
+
exclude: ['src/**/*.test.ts', 'src/**/*.test.tsx', 'src/**/*.d.ts'],
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
});
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
|
+
"bin": "./dist/index.js",
|
|
2
3
|
"dependencies": {
|
|
3
4
|
"commander": "",
|
|
4
5
|
"cli-progress": ""
|
|
5
6
|
},
|
|
6
7
|
"devDependencies": {
|
|
7
8
|
"@types/cli-progress": "",
|
|
8
|
-
"
|
|
9
|
+
"vite": ""
|
|
9
10
|
},
|
|
10
11
|
"scripts": {
|
|
11
|
-
"dev": "
|
|
12
|
-
"build": "
|
|
12
|
+
"dev": "vite build --watch",
|
|
13
|
+
"build": "vite build"
|
|
13
14
|
}
|
|
14
15
|
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import {expect, test} from 'vitest';
|
|
2
|
+
import {greet, calculateProgress} from './lib.js';
|
|
2
3
|
|
|
3
|
-
test('
|
|
4
|
-
expect(
|
|
4
|
+
test('greet returns correct message', () => {
|
|
5
|
+
expect(greet('Vitest')).toBe('Hello, Vitest! Welcome to your new CLI.');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
test('calculateProgress works correctly', () => {
|
|
9
|
+
expect(calculateProgress(50, 100)).toBe(50);
|
|
10
|
+
expect(calculateProgress(1, 3)).toBe(33);
|
|
11
|
+
expect(calculateProgress(0, 100)).toBe(0);
|
|
12
|
+
expect(calculateProgress(50, 0)).toBe(0);
|
|
5
13
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
1
2
|
import {Command} from 'commander';
|
|
2
3
|
import {SingleBar, Presets} from 'cli-progress';
|
|
3
4
|
|
|
@@ -10,4 +11,6 @@ bar.start(100, 0);
|
|
|
10
11
|
bar.update(50);
|
|
11
12
|
bar.stop();
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
import {greet} from './lib.js';
|
|
15
|
+
|
|
16
|
+
console.log(greet('Developer'));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const greet = (name: string): string => {
|
|
2
|
+
return `Hello, ${name}! Welcome to your new CLI.`;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export const calculateProgress = (current: number, total: number): number => {
|
|
6
|
+
if (total === 0) {
|
|
7
|
+
return 0;
|
|
8
|
+
}
|
|
9
|
+
return Math.round((current / total) * 100);
|
|
10
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
coverage: {
|
|
18
|
+
provider: 'v8',
|
|
19
|
+
reporter: ['text', 'json', 'html'],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import {expect, test} from 'vitest';
|
|
2
|
+
import {render} from 'vitest-browser-react';
|
|
3
|
+
import {page} from 'vitest/browser';
|
|
4
|
+
import {App} from './App.js';
|
|
5
|
+
|
|
6
|
+
test('renders hello message in the browser', async () => {
|
|
7
|
+
await render(<App />);
|
|
8
|
+
await expect.element(page.getByText(/Hello from React!/i)).toBeVisible();
|
|
9
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {Typography, Container, Box} from '@mui/material';
|
|
2
|
+
|
|
3
|
+
export const App = () => {
|
|
4
|
+
return (
|
|
5
|
+
<Container maxWidth="sm">
|
|
6
|
+
<Box sx={{my: 4, textAlign: 'center'}}>
|
|
7
|
+
<Typography variant="h4" component="h1" gutterBottom>
|
|
8
|
+
Hello from React!
|
|
9
|
+
</Typography>
|
|
10
|
+
<Typography variant="body1">This project was scaffolded with the web-app template.</Typography>
|
|
11
|
+
</Box>
|
|
12
|
+
</Container>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
import {createRoot} from 'react-dom/client';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const App = () => {
|
|
5
|
-
return (
|
|
6
|
-
<Container maxWidth="sm">
|
|
7
|
-
<Box sx={{my: 4, textAlign: 'center'}}>
|
|
8
|
-
<Typography variant="h4" component="h1" gutterBottom>
|
|
9
|
-
Hello from React!
|
|
10
|
-
</Typography>
|
|
11
|
-
<Typography variant="body1">This project was scaffolded with the web-app template.</Typography>
|
|
12
|
-
</Box>
|
|
13
|
-
</Container>
|
|
14
|
-
);
|
|
15
|
-
};
|
|
2
|
+
import {App} from './App.js';
|
|
16
3
|
|
|
17
4
|
const container = document.getElementById('app');
|
|
18
5
|
if (container) {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import {describe, it, expect} from 'vitest';
|
|
2
|
+
import {render} from 'vitest-browser-react';
|
|
3
|
+
import {page} from 'vitest/browser';
|
|
2
4
|
import {App} from './App.js';
|
|
3
5
|
|
|
4
6
|
describe('App', () => {
|
|
5
|
-
it('should
|
|
6
|
-
|
|
7
|
+
it('should render in the browser', async () => {
|
|
8
|
+
await render(<App />);
|
|
9
|
+
await expect.element(page.getByRole('heading', {name: /Login/i}).or(page.getByRole('heading', {name: /Dashboard/i}))).toBeVisible();
|
|
7
10
|
});
|
|
8
11
|
});
|
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
import {describe, it, expect} from 'vitest';
|
|
2
|
+
import {appRouter} from './routers/_app.js';
|
|
3
|
+
import {createCallerFactory} from './trpc.js';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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/);
|
|
6
27
|
});
|
|
7
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'});
|
|
@@ -3,6 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
|
|
4
4
|
export default defineConfig({
|
|
5
5
|
build: {
|
|
6
|
+
ssr: true,
|
|
6
7
|
lib: {
|
|
7
8
|
entry: path.resolve(__dirname, 'src/index.ts'),
|
|
8
9
|
formats: ['es'],
|
|
@@ -10,12 +11,14 @@ export default defineConfig({
|
|
|
10
11
|
},
|
|
11
12
|
outDir: 'dist',
|
|
12
13
|
emptyOutDir: true,
|
|
13
|
-
|
|
14
|
-
external: ['express', 'cors', 'zod', '@trpc/server', 'node:path', 'node:url'],
|
|
15
|
-
},
|
|
14
|
+
target: 'node22',
|
|
16
15
|
},
|
|
17
16
|
test: {
|
|
18
17
|
globals: true,
|
|
19
18
|
environment: 'node',
|
|
19
|
+
coverage: {
|
|
20
|
+
provider: 'v8',
|
|
21
|
+
reporter: ['text', 'json', 'html'],
|
|
22
|
+
},
|
|
20
23
|
},
|
|
21
24
|
});
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import {expect, test} from 'vitest';
|
|
2
|
+
import {page} from 'vitest/browser';
|
|
3
|
+
import {formatMessage, createHeading} from './lib.js';
|
|
2
4
|
|
|
3
|
-
test('
|
|
4
|
-
expect(
|
|
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();
|
|
5
12
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-template-project",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Dieter Oberkofler",
|
|
@@ -14,36 +14,31 @@
|
|
|
14
14
|
"typescript"
|
|
15
15
|
],
|
|
16
16
|
"bin": {
|
|
17
|
-
"create-template-project": "./dist/index.
|
|
17
|
+
"create-template-project": "./dist/index.js"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
|
-
"run-interactive": "node dist/index.
|
|
21
|
-
"
|
|
22
|
-
"run-create:web-vanilla": "node dist/index.mjs create --name=my-web-vanilla --directory=./temp --template=web-vanilla --package-manager=pnpm --overwrite --build",
|
|
23
|
-
"run-create:web-app": "node dist/index.mjs create --name=my-web-app --directory=./temp --template=web-app --package-manager=pnpm --overwrite --build",
|
|
24
|
-
"run-create:web-fullstack": "node dist/index.mjs create --name=my-web-fullstack --directory=./temp --template=web-fullstack --package-manager=pnpm --overwrite --build",
|
|
25
|
-
"run-create": "pnpm run build && pnpm run run-create:cli && pnpm run run-create:web-vanilla && pnpm run run-create:web-app && pnpm run run-create:web-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
24
|
"lint": "tsc && oxlint --ignore-pattern \"src/templates/**/files\" && pnpm run prettier",
|
|
30
25
|
"prettier": "prettier --check .",
|
|
31
26
|
"prettier-write": "prettier --write .",
|
|
32
27
|
"test": "vitest run --coverage --exclude '**/*.integration.*.test.ts'",
|
|
33
|
-
"test:integration:cli": "
|
|
34
|
-
"test:integration:web-vanilla": "
|
|
35
|
-
"test:integration:web-app": "
|
|
36
|
-
"test:integration:web-fullstack": "
|
|
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",
|
|
37
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",
|
|
38
33
|
"ci": "pnpm run lint && pnpm run build && pnpm run test",
|
|
39
34
|
"create-changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
|
|
40
35
|
"prepare": "husky"
|
|
41
36
|
},
|
|
42
|
-
"main": "./dist/index.
|
|
43
|
-
"module": "./dist/index.
|
|
37
|
+
"main": "./dist/index.js",
|
|
38
|
+
"module": "./dist/index.js",
|
|
44
39
|
"types": "./dist/index.d.ts",
|
|
45
40
|
"exports": {
|
|
46
|
-
".": "./dist/index.
|
|
41
|
+
".": "./dist/index.js",
|
|
47
42
|
"./package.json": "./package.json"
|
|
48
43
|
},
|
|
49
44
|
"engines": {
|
|
@@ -65,11 +60,11 @@
|
|
|
65
60
|
"eslint-plugin-regexp": "3.1.0",
|
|
66
61
|
"husky": "9.1.7",
|
|
67
62
|
"oxlint": "1.56.0",
|
|
68
|
-
"oxlint-tsgolint": "0.17.
|
|
63
|
+
"oxlint-tsgolint": "0.17.1",
|
|
69
64
|
"pnpm": "10.32.1",
|
|
70
65
|
"prettier": "3.8.1",
|
|
71
|
-
"tsdown": "0.21.4",
|
|
72
66
|
"typescript": "5.9.3",
|
|
67
|
+
"vite": "8.0.1",
|
|
73
68
|
"vitest": "4.1.0"
|
|
74
69
|
},
|
|
75
70
|
"dependencies": {
|