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.
- package/README.md +11 -11
- package/dist/config/dependencies.json +60 -44
- package/dist/index.js +1221 -0
- package/dist/templates/base/files/.github/workflows/node.js.yml +5 -3
- 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 +53 -0
- package/dist/templates/base/files/.prettierrc.json +4 -2
- package/dist/templates/base/files/AGENTS.md +5 -2
- package/dist/templates/base/files/README.md +36 -13
- package/dist/templates/base/files/_oxlint.config.ts +17 -33
- package/dist/templates/base/files/package.json +1 -1
- package/dist/templates/base/files/tsconfig.json +32 -32
- package/dist/templates/base/files/vitest.config.ts +11 -2
- 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/index.html +11 -0
- package/dist/templates/web-app/files/playwright.config.ts +26 -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 +8 -0
- package/dist/templates/web-app/files/tests/e2e/basic.e2e-test.ts +13 -0
- package/dist/templates/web-app/files/vite.config.ts +34 -0
- package/dist/templates/web-fullstack/files/client/index.html +10 -0
- package/dist/templates/{fullstack → web-fullstack}/files/client/package.json +2 -2
- package/dist/templates/web-fullstack/files/client/src/App.test.tsx +11 -0
- package/dist/templates/{fullstack → web-fullstack}/files/client/src/contexts/AuthContext.tsx +1 -5
- package/dist/templates/{fullstack → web-fullstack}/files/client/src/pages/Login.tsx +4 -33
- package/dist/templates/web-fullstack/files/client/vite.config.ts +30 -0
- package/dist/templates/{fullstack → web-fullstack}/files/package.json +1 -2
- package/dist/templates/web-fullstack/files/playwright.config.ts +33 -0
- package/dist/templates/{fullstack → web-fullstack}/files/server/package.json +2 -2
- package/dist/templates/web-fullstack/files/server/src/index.test.ts +28 -0
- package/dist/templates/{fullstack → web-fullstack}/files/server/src/trpc.ts +1 -1
- package/dist/templates/web-fullstack/files/server/vite.config.ts +24 -0
- package/dist/templates/web-fullstack/files/tests/e2e/basic.e2e-test.ts +14 -0
- package/dist/templates/web-vanilla/files/index.html +11 -0
- package/dist/templates/web-vanilla/files/package.json +17 -0
- package/dist/templates/web-vanilla/files/playwright.config.ts +26 -0
- package/dist/templates/web-vanilla/files/src/index.test.ts +12 -0
- package/dist/templates/web-vanilla/files/src/index.ts +3 -0
- package/dist/templates/web-vanilla/files/src/lib.ts +9 -0
- package/dist/templates/web-vanilla/files/tests/e2e/basic.e2e-test.ts +11 -0
- package/dist/templates/web-vanilla/files/vite.config.ts +28 -0
- package/package.json +25 -27
- package/dist/cli.mjs +0 -272
- package/dist/generators/project.mjs +0 -354
- package/dist/index.d.mts +0 -4
- package/dist/index.mjs +0 -32
- package/dist/templates/base/index.mjs +0 -16
- package/dist/templates/cli/files/tsdown.config.ts +0 -3
- package/dist/templates/cli/index.mjs +0 -16
- package/dist/templates/fullstack/files/client/index.html +0 -8
- package/dist/templates/fullstack/files/client/src/App.test.tsx +0 -8
- package/dist/templates/fullstack/files/client/tsdown.config.ts +0 -3
- package/dist/templates/fullstack/files/server/src/index.test.ts +0 -7
- package/dist/templates/fullstack/files/server/tsdown.config.ts +0 -3
- package/dist/templates/fullstack/index.mjs +0 -42
- package/dist/templates/webapp/files/backend/src/index.ts +0 -17
- package/dist/templates/webapp/files/frontend/index.html +0 -9
- package/dist/templates/webapp/files/frontend/src/index.ts +0 -4
- package/dist/templates/webapp/files/package.json +0 -13
- package/dist/templates/webapp/files/src/index.test.ts +0 -5
- package/dist/templates/webapp/files/tsdown.config.ts +0 -10
- package/dist/templates/webapp/index.mjs +0 -16
- package/dist/templates/webpage/files/index.html +0 -8
- package/dist/templates/webpage/files/package.json +0 -8
- package/dist/templates/webpage/files/src/index.test.ts +0 -5
- package/dist/templates/webpage/files/src/index.ts +0 -1
- package/dist/templates/webpage/index.mjs +0 -16
- package/dist/types.mjs +0 -30
- package/dist/utils/file.mjs +0 -101
- /package/dist/templates/{fullstack → web-fullstack}/files/client/src/App.tsx +0 -0
- /package/dist/templates/{fullstack → web-fullstack}/files/client/src/components/ProtectedRoute.tsx +0 -0
- /package/dist/templates/{fullstack → web-fullstack}/files/client/src/main.tsx +0 -0
- /package/dist/templates/{fullstack → web-fullstack}/files/client/src/pages/Dashboard.tsx +0 -0
- /package/dist/templates/{fullstack → web-fullstack}/files/client/src/trpc.ts +0 -0
- /package/dist/templates/{fullstack → web-fullstack}/files/server/src/context.ts +0 -0
- /package/dist/templates/{fullstack → web-fullstack}/files/server/src/index.ts +0 -0
- /package/dist/templates/{fullstack → web-fullstack}/files/server/src/routers/_app.ts +0 -0
- /package/dist/templates/{fullstack → web-fullstack}/files/server/src/routers/auth.ts +0 -0
|
@@ -11,10 +11,12 @@ jobs:
|
|
|
11
11
|
runs-on: ubuntu-latest
|
|
12
12
|
steps:
|
|
13
13
|
- uses: actions/checkout@v4
|
|
14
|
+
# [PM_SETUP]
|
|
14
15
|
- name: Use Node.js
|
|
15
16
|
uses: actions/setup-node@v4
|
|
16
17
|
with:
|
|
17
18
|
node-version: '22.x'
|
|
18
|
-
cache: '
|
|
19
|
-
- run:
|
|
20
|
-
|
|
19
|
+
cache: '{{packageManager}}'
|
|
20
|
+
- run: '{{installCommand}}'
|
|
21
|
+
# [PLAYWRIGHT_SETUP]
|
|
22
|
+
- run: '{{packageManager}} run ci'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npx --no -- commitlint --edit "$1"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{{packageManager}} run ci
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# dependencies
|
|
2
|
+
node_modules/
|
|
3
|
+
|
|
4
|
+
# build outputs
|
|
5
|
+
dist/
|
|
6
|
+
build/
|
|
7
|
+
coverage/
|
|
8
|
+
out/
|
|
9
|
+
.next/
|
|
10
|
+
.nuxt/
|
|
11
|
+
.svelte-kit/
|
|
12
|
+
|
|
13
|
+
# logs
|
|
14
|
+
*.log
|
|
15
|
+
npm-debug.log*
|
|
16
|
+
yarn-debug.log*
|
|
17
|
+
yarn-error.log*
|
|
18
|
+
pnpm-debug.log*
|
|
19
|
+
|
|
20
|
+
# env
|
|
21
|
+
.env
|
|
22
|
+
.env.*.local
|
|
23
|
+
|
|
24
|
+
# cache
|
|
25
|
+
.cache/
|
|
26
|
+
.parcel-cache/
|
|
27
|
+
.eslintcache
|
|
28
|
+
|
|
29
|
+
# lock files (optional, usually formatted fine)
|
|
30
|
+
package-lock.json
|
|
31
|
+
yarn.lock
|
|
32
|
+
pnpm-lock.yaml
|
|
33
|
+
|
|
34
|
+
# generated files
|
|
35
|
+
*.min.js
|
|
36
|
+
*.min.css
|
|
37
|
+
|
|
38
|
+
# static assets (optional)
|
|
39
|
+
public/
|
|
40
|
+
assets/
|
|
41
|
+
|
|
42
|
+
# IDE / OS
|
|
43
|
+
.vscode/
|
|
44
|
+
.idea/
|
|
45
|
+
.DS_Store
|
|
46
|
+
Thumbs.db
|
|
47
|
+
|
|
48
|
+
# misc
|
|
49
|
+
tmp/
|
|
50
|
+
temp/
|
|
51
|
+
|
|
52
|
+
# md
|
|
53
|
+
**/*.md
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# Agent Guidelines: {{projectName}}
|
|
2
2
|
|
|
3
3
|
Build/Lint/Test:
|
|
4
|
-
- `npm run ci
|
|
5
|
-
- `
|
|
4
|
+
- `npm run ci`: Runs lint, build, and all tests.
|
|
5
|
+
- `npm run dev`: Starts the development server.
|
|
6
|
+
- `npm run test`: Runs unit tests (browser-based for web projects).
|
|
7
|
+
- `npm run test:e2e`: Runs Playwright E2E tests.
|
|
8
|
+
- `npx vitest <file>`: Runs a specific test file.
|
|
@@ -3,21 +3,44 @@
|
|
|
3
3
|
{{description}}
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/{{projectName}})
|
|
6
|
-
[](https://www.npmjs.com/package/{{projectName}})
|
|
7
6
|
[](https://github.com/doberkofler/{{projectName}}/actions/workflows/node.js.yml)
|
|
8
7
|
|
|
9
|
-
##
|
|
8
|
+
## Development Workflow
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
-
|
|
10
|
+
This project is built using **Vite 8** for high-performance development and bundling.
|
|
11
|
+
|
|
12
|
+
### Available Scripts
|
|
13
|
+
|
|
14
|
+
- `npm run dev`: Starts the development server.
|
|
15
|
+
- `npm run build`: Builds the project for production.
|
|
16
|
+
- `npm run preview`: Previews the production build.
|
|
17
|
+
- `npm run test`: Runs the unit test suite (browser-based for web targets using **Vitest** and **Playwright**).
|
|
18
|
+
- `npm run test:e2e`: Runs E2E tests using **Playwright**.
|
|
19
|
+
- `npm run lint`: Lints and formats the codebase using **oxlint** and **prettier**.
|
|
20
|
+
- `npm run ci`: Full CI pipeline (lint, build, test).
|
|
16
21
|
|
|
17
22
|
## Getting Started
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
npm
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
1. **Install dependencies**:
|
|
25
|
+
```bash
|
|
26
|
+
npm install
|
|
27
|
+
```
|
|
28
|
+
2. **Start development server**:
|
|
29
|
+
```bash
|
|
30
|
+
npm run dev
|
|
31
|
+
```
|
|
32
|
+
3. **Run tests**:
|
|
33
|
+
```bash
|
|
34
|
+
npm run test
|
|
35
|
+
npm run test:e2e
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Tooling
|
|
39
|
+
|
|
40
|
+
- **Vite 8**: Modern, ultra-fast development and build tool.
|
|
41
|
+
- **Vitest**: Vite-native testing framework with browser support.
|
|
42
|
+
- **Playwright**: Reliable E2E and browser automation.
|
|
43
|
+
- **oxlint**: Extremely fast JavaScript/TypeScript linter.
|
|
44
|
+
- **Prettier**: Opinionated code formatter.
|
|
45
|
+
- **Husky & Commitlint**: Ensuring high-quality commit messages.
|
|
46
|
+
- **Conventional Changelog**: Automated changelog generation.
|
|
@@ -1,50 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {defineConfig} from 'oxlint';
|
|
2
2
|
import pluginRegexp from 'eslint-plugin-regexp';
|
|
3
3
|
|
|
4
4
|
export default defineConfig({
|
|
5
5
|
options: {
|
|
6
6
|
typeAware: true,
|
|
7
|
-
typeCheck: true
|
|
7
|
+
typeCheck: true,
|
|
8
8
|
},
|
|
9
|
-
plugins: [
|
|
10
|
-
|
|
11
|
-
'typescript',
|
|
12
|
-
'oxc',
|
|
13
|
-
'import',
|
|
14
|
-
'react',
|
|
15
|
-
'jsdoc',
|
|
16
|
-
'promise',
|
|
17
|
-
'vitest'
|
|
18
|
-
],
|
|
19
|
-
jsPlugins: [
|
|
20
|
-
'eslint-plugin-regexp'
|
|
21
|
-
],
|
|
9
|
+
plugins: ['unicorn', 'typescript', 'oxc', 'import', 'react', 'jsdoc', 'promise', 'vitest'],
|
|
10
|
+
jsPlugins: ['eslint-plugin-regexp'],
|
|
22
11
|
categories: {
|
|
23
|
-
correctness: 'error'
|
|
12
|
+
correctness: 'error',
|
|
24
13
|
},
|
|
25
14
|
rules: {
|
|
26
15
|
...pluginRegexp.configs.recommended.rules,
|
|
16
|
+
curly: ['error', 'all'],
|
|
27
17
|
'typescript/no-unused-vars': [
|
|
28
18
|
'error',
|
|
29
19
|
{
|
|
30
20
|
caughtErrors: 'none',
|
|
31
|
-
argsIgnorePattern: '^_'
|
|
32
|
-
}
|
|
33
|
-
]
|
|
21
|
+
argsIgnorePattern: '^_',
|
|
22
|
+
},
|
|
23
|
+
],
|
|
34
24
|
},
|
|
35
25
|
settings: {
|
|
36
26
|
'jsx-a11y': {
|
|
37
27
|
polymorphicPropName: undefined,
|
|
38
28
|
components: {},
|
|
39
|
-
attributes: {}
|
|
29
|
+
attributes: {},
|
|
40
30
|
},
|
|
41
31
|
next: {
|
|
42
|
-
rootDir: []
|
|
32
|
+
rootDir: [],
|
|
43
33
|
},
|
|
44
34
|
react: {
|
|
45
35
|
formComponents: [],
|
|
46
36
|
linkComponents: [],
|
|
47
|
-
version: undefined
|
|
37
|
+
version: undefined,
|
|
48
38
|
},
|
|
49
39
|
jsdoc: {
|
|
50
40
|
ignorePrivate: false,
|
|
@@ -54,21 +44,15 @@ export default defineConfig({
|
|
|
54
44
|
augmentsExtendsReplacesDocs: false,
|
|
55
45
|
implementsReplacesDocs: false,
|
|
56
46
|
exemptDestructuredRootsFromChecks: false,
|
|
57
|
-
tagNamePreference: {}
|
|
47
|
+
tagNamePreference: {},
|
|
58
48
|
},
|
|
59
49
|
vitest: {
|
|
60
|
-
typecheck: false
|
|
61
|
-
}
|
|
50
|
+
typecheck: false,
|
|
51
|
+
},
|
|
62
52
|
},
|
|
63
53
|
env: {
|
|
64
|
-
builtin: true
|
|
54
|
+
builtin: true,
|
|
65
55
|
},
|
|
66
56
|
globals: {},
|
|
67
|
-
ignorePatterns: [
|
|
68
|
-
'**/.*',
|
|
69
|
-
'node_modules/**',
|
|
70
|
-
'dist/**',
|
|
71
|
-
'coverage/**',
|
|
72
|
-
'public/**'
|
|
73
|
-
]
|
|
57
|
+
ignorePatterns: ['**/.*', 'node_modules/**', 'dist/**', 'coverage/**', 'public/**'],
|
|
74
58
|
});
|
|
@@ -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,42 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
/* Language and Environment */
|
|
4
|
-
"target": "
|
|
5
|
-
"lib": ["
|
|
6
|
-
"module": "
|
|
7
|
-
"moduleResolution": "
|
|
8
|
-
"esModuleInterop": true
|
|
9
|
-
"resolveJsonModule": true
|
|
4
|
+
"target": "ES2023" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
5
|
+
"lib": ["ES2023"] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
|
|
6
|
+
"module": "ESNext" /* Specify what module code is generated. */,
|
|
7
|
+
"moduleResolution": "bundler" /* Specify how TypeScript looks up a file from a given module specifier. */,
|
|
8
|
+
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. */,
|
|
9
|
+
"resolveJsonModule": true /* Enable importing .json files. */,
|
|
10
|
+
"allowImportingTsExtensions": /* Allow imports to include TypeScript file extensions. */ true,
|
|
11
|
+
"noEmit": true /* Disable emitting files from a compilation. */,
|
|
10
12
|
|
|
11
13
|
/* Strict Type-Checking Options */
|
|
12
|
-
"strict": true
|
|
13
|
-
"noImplicitAny": true
|
|
14
|
-
"strictNullChecks": true
|
|
15
|
-
"strictFunctionTypes": true
|
|
16
|
-
"strictBindCallApply": true
|
|
17
|
-
"strictPropertyInitialization": true
|
|
18
|
-
"noImplicitThis": true
|
|
19
|
-
"useUnknownInCatchVariables": true
|
|
20
|
-
"alwaysStrict": true
|
|
21
|
-
"noUnusedLocals": true
|
|
22
|
-
"noUnusedParameters": true
|
|
23
|
-
"exactOptionalPropertyTypes": true
|
|
24
|
-
"noImplicitReturns": true
|
|
25
|
-
"noFallthroughCasesInSwitch": true
|
|
26
|
-
"noUncheckedIndexedAccess": true
|
|
27
|
-
"noImplicitOverride": true
|
|
28
|
-
"noPropertyAccessFromIndexSignature": true
|
|
29
|
-
"allowUnusedLabels": false
|
|
30
|
-
"allowUnreachableCode": false
|
|
14
|
+
"strict": true /* Enable all strict type-checking options. */,
|
|
15
|
+
"noImplicitAny": true /* Enable error reporting for expressions and declarations with an implied 'any' type. */,
|
|
16
|
+
"strictNullChecks": true /* When type checking, take into account 'null' and 'undefined'. */,
|
|
17
|
+
"strictFunctionTypes": true /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */,
|
|
18
|
+
"strictBindCallApply": true /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */,
|
|
19
|
+
"strictPropertyInitialization": true /* Check for class properties that are declared but not set in the constructor. */,
|
|
20
|
+
"noImplicitThis": true /* Enable error reporting when 'this' is given the type 'any'. */,
|
|
21
|
+
"useUnknownInCatchVariables": true /* Default catch clause variables as 'unknown' instead of 'any'. */,
|
|
22
|
+
"alwaysStrict": true /* Ensure 'use strict' is always emitted. */,
|
|
23
|
+
"noUnusedLocals": true /* Enable error reporting when local variables aren't read. */,
|
|
24
|
+
"noUnusedParameters": true /* Raise an error when a function parameter isn't read. */,
|
|
25
|
+
"exactOptionalPropertyTypes": true /* Interpret optional property types as strictly typed, preventing assignment of 'undefined'. */,
|
|
26
|
+
"noImplicitReturns": true /* Enable error reporting for codepaths that do not explicitly return in a function. */,
|
|
27
|
+
"noFallthroughCasesInSwitch": true /* Enable error reporting for fallthrough cases in switch statements. */,
|
|
28
|
+
"noUncheckedIndexedAccess": true /* Add 'undefined' to a type when accessed using an index. */,
|
|
29
|
+
"noImplicitOverride": true /* Ensure overriding members in derived classes are marked with an override modifier. */,
|
|
30
|
+
"noPropertyAccessFromIndexSignature": true /* Enforces using indexed accessors for keys declared using an indexed type. */,
|
|
31
|
+
"allowUnusedLabels": false /* Disable error reporting for unused labels. */,
|
|
32
|
+
"allowUnreachableCode": false /* Disable error reporting for unreachable code. */,
|
|
31
33
|
|
|
32
34
|
/* Emit */
|
|
33
|
-
"outDir": "./dist"
|
|
34
|
-
|
|
35
|
+
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
|
|
36
|
+
|
|
35
37
|
/* Completeness */
|
|
36
|
-
"skipLibCheck": true
|
|
37
|
-
"forceConsistentCasingInFileNames": true
|
|
38
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */,
|
|
39
|
+
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */
|
|
38
40
|
},
|
|
39
|
-
"include": [
|
|
40
|
-
"src/**/*"
|
|
41
|
-
]
|
|
41
|
+
"include": ["src/**/*"]
|
|
42
42
|
}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
-
import {
|
|
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,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:3000',
|
|
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 build && npm run start',
|
|
23
|
+
url: 'http://localhost:3000',
|
|
24
|
+
reuseExistingServer: !process.env.CI,
|
|
25
|
+
},
|
|
26
|
+
});
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
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('api is reachable', async ({page}) => {
|
|
9
|
+
const response = await page.request.get('/api/hello');
|
|
10
|
+
expect(response.ok()).toBeTruthy();
|
|
11
|
+
const data = await response.json();
|
|
12
|
+
expect(data.message).toBe('Hello from Express!');
|
|
13
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
build: {
|
|
9
|
+
outDir: 'dist',
|
|
10
|
+
emptyOutDir: true,
|
|
11
|
+
},
|
|
12
|
+
test: {
|
|
13
|
+
include: ['src/**/*.test.{ts,tsx}'],
|
|
14
|
+
coverage: {
|
|
15
|
+
provider: 'v8',
|
|
16
|
+
reporter: ['text', 'json', 'html'],
|
|
17
|
+
},
|
|
18
|
+
browser: {
|
|
19
|
+
enabled: true,
|
|
20
|
+
headless: true,
|
|
21
|
+
screenshotDirectory: path.resolve('./temp/vitest/__screenshots__'),
|
|
22
|
+
instances: [
|
|
23
|
+
{
|
|
24
|
+
browser: 'chromium',
|
|
25
|
+
provider: playwright({
|
|
26
|
+
launchOptions: {
|
|
27
|
+
args: ['--disable-web-security'],
|
|
28
|
+
},
|
|
29
|
+
}),
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {describe, it, expect} from 'vitest';
|
|
2
|
+
import {render} from 'vitest-browser-react';
|
|
3
|
+
import {page} from 'vitest/browser';
|
|
4
|
+
import {App} from './App.js';
|
|
5
|
+
|
|
6
|
+
describe('App', () => {
|
|
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();
|
|
10
|
+
});
|
|
11
|
+
});
|
package/dist/templates/{fullstack → web-fullstack}/files/client/src/contexts/AuthContext.tsx
RENAMED
|
@@ -47,11 +47,7 @@ export const AuthProvider = ({children}: {children: ReactNode}) => {
|
|
|
47
47
|
setUser(null);
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
return
|
|
51
|
-
<AuthContext.Provider value={{user, token, isLoading, login, logout}}>
|
|
52
|
-
{children}
|
|
53
|
-
</AuthContext.Provider>
|
|
54
|
-
);
|
|
50
|
+
return <AuthContext.Provider value={{user, token, isLoading, login, logout}}>{children}</AuthContext.Provider>;
|
|
55
51
|
};
|
|
56
52
|
|
|
57
53
|
export const useAuth = () => {
|