@forsakringskassan/vue-lib-template 1.5.2 → 1.6.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/files/README.md +3 -46
- package/files/_env +1 -0
- package/files/_gitignore +10 -2
- package/files/_htmlvalidateignore +6 -2
- package/files/_prettierignore +6 -2
- package/files/docs/build.mts +7 -1
- package/files/docs/package.json +1 -1
- package/files/docs/src/bundle-mocks.ts +2 -1
- package/files/package.json +5 -6
- package/files/project-guide/development.md +32 -20
- package/files/project-guide/documentation.md +2 -1
- package/files/src/components/guide/FcCatInfo/cat-api.spec.ts +2 -0
- package/files/src/components/guide/FcCatInfo/cat-api.ts +4 -1
- package/files/src/vite-env.d.ts +7 -0
- package/hooks/install.mjs +15 -0
- package/index.js +1 -1
- package/package.json +29 -5
package/files/README.md
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
En mall för hur ett komponentbibliotek fungerar.
|
|
4
4
|
|
|
5
|
+
Läs mer i [guide för att skapa komponenter](./project-guide/index.md).
|
|
6
|
+
|
|
5
7
|
## Dokumentation
|
|
6
8
|
|
|
7
9
|
Bygg och starta dokumentationen med:
|
|
8
10
|
|
|
9
11
|
```bash
|
|
10
|
-
npm run build
|
|
12
|
+
npm run build
|
|
11
13
|
npm run start:docs
|
|
12
14
|
```
|
|
13
15
|
|
|
@@ -42,48 +44,3 @@ vue:${component}
|
|
|
42
44
|
```
|
|
43
45
|
|
|
44
46
|
Dokumentationen genereras med [`@forsakringskassan/docs-generator`](https://forsakringskassan.github.io/docs-generator/latest/).
|
|
45
|
-
|
|
46
|
-
## Att dokumentera
|
|
47
|
-
|
|
48
|
-
- [ ] ingress
|
|
49
|
-
- [ ] quick start: de vanliga kommandon man behöver
|
|
50
|
-
- [ ] lintning och statisk kodanalys
|
|
51
|
-
- vilka verktyg körs och varför
|
|
52
|
-
- förklara html-validate och no-unknown-elements
|
|
53
|
-
- [ ] förklara varför vi använder api-extractor/värde | public internal | dts-fil
|
|
54
|
-
- [ ] förstå vad paketet levererar
|
|
55
|
-
- [ ] så här kör du cypress
|
|
56
|
-
- [ ] bundling och inte bundling, hur gör jag
|
|
57
|
-
- [ ] hur dokumenterar man komponenter?
|
|
58
|
-
- [x] hur bygger man dokumentationen?
|
|
59
|
-
- [x] hur startar man dokumentationen?
|
|
60
|
-
- [ ] checklista över vad som ska fungera
|
|
61
|
-
- importera static assets
|
|
62
|
-
- vscode: ska inte visa squiggly lines vid import av static assets
|
|
63
|
-
- vscode: ska inte visa squiggly lines vid cy.mount i komponenttest
|
|
64
|
-
|
|
65
|
-
## Att göra
|
|
66
|
-
|
|
67
|
-
- [x] börja med att kopiera alla rotfiler och cypresskatalog etc från designsystem (det vi inte fick med som körs från roten t ex lint osv)
|
|
68
|
-
- [x] docs
|
|
69
|
-
- [x] sandbox eller inte
|
|
70
|
-
- [ ] stylelint, även på sfc
|
|
71
|
-
- [x] levera css
|
|
72
|
-
- [ ] postcss med autoprefixer ska köras
|
|
73
|
-
- [x] trimma allowScripts (jättelåg prio)
|
|
74
|
-
- [x] semantic release för vanligt repo
|
|
75
|
-
- [ ] uppdatera .gitignore med app.vue
|
|
76
|
-
- [ ] pretest: att vara eller att inte vara, det är frågan
|
|
77
|
-
- [x] npm start
|
|
78
|
-
- [x] npm start AwesomeComponent
|
|
79
|
-
- [x] npm test
|
|
80
|
-
- [x] npm run build
|
|
81
|
-
- [x] npm run build:docs
|
|
82
|
-
- [x] npm run start:docs
|
|
83
|
-
- [x] apimock
|
|
84
|
-
- [x] bättre exempelkomponent
|
|
85
|
-
- [x] bättre enhetstest
|
|
86
|
-
- [x] bättre komponenttest
|
|
87
|
-
- [x] live exempel
|
|
88
|
-
- [ ] skill för att skapa live exempel
|
|
89
|
-
- [ ] skript för att rensa demo-filer
|
package/files/_env
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
VITE_CAT_API_URL=/api/cat
|
package/files/_gitignore
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
# This file is managed by @forsakringskassan/vue-lib-template.
|
|
2
|
-
#
|
|
1
|
+
# This file is partially managed by @forsakringskassan/vue-lib-template.
|
|
2
|
+
#
|
|
3
|
+
# Place your own rules below the "Add local changes below" comment.
|
|
4
|
+
# Rules above that line may be overwritten.
|
|
3
5
|
|
|
4
6
|
# vite dev
|
|
5
7
|
# /src/vite-dev/app.vue
|
|
6
8
|
*.tgz
|
|
7
9
|
node_modules/
|
|
8
10
|
|
|
11
|
+
# Environment files
|
|
12
|
+
.env
|
|
13
|
+
.env.*
|
|
14
|
+
|
|
9
15
|
# Build artifacts
|
|
10
16
|
.eslintcache
|
|
11
17
|
coverage/
|
|
@@ -25,3 +31,5 @@ test-results/
|
|
|
25
31
|
*.njsproj
|
|
26
32
|
*.sln
|
|
27
33
|
*.sw?
|
|
34
|
+
|
|
35
|
+
# --- Add local changes below ---
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
# This file is managed by @forsakringskassan/vue-lib-template.
|
|
2
|
-
#
|
|
1
|
+
# This file is partially managed by @forsakringskassan/vue-lib-template.
|
|
2
|
+
#
|
|
3
|
+
# Place your own rules below the "Add local changes below" comment.
|
|
4
|
+
# Rules above that line may be overwritten.
|
|
3
5
|
|
|
4
6
|
# generated files
|
|
5
7
|
dist/
|
|
6
8
|
docs/public/
|
|
7
9
|
docs/node_modules/
|
|
8
10
|
docs/temp/
|
|
11
|
+
|
|
12
|
+
# --- Add local changes below ---
|
package/files/_prettierignore
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
# This file is managed by @forsakringskassan/vue-lib-template.
|
|
2
|
-
#
|
|
1
|
+
# This file is partially managed by @forsakringskassan/vue-lib-template.
|
|
2
|
+
#
|
|
3
|
+
# Place your own rules below the "Add local changes below" comment.
|
|
4
|
+
# Rules above that line may be overwritten.
|
|
3
5
|
|
|
4
6
|
# owned by tooling
|
|
5
7
|
package-lock.json
|
|
@@ -30,3 +32,5 @@ yarn-error.log*
|
|
|
30
32
|
*.njsproj
|
|
31
33
|
*.sln
|
|
32
34
|
*.sw?
|
|
35
|
+
|
|
36
|
+
# --- Add local changes below ---
|
package/files/docs/build.mts
CHANGED
|
@@ -66,7 +66,13 @@ docs.compileScript("#apimock", "./src/bundle-mocks.ts", {
|
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
const mswUrl = new URL(import.meta.resolve("msw/mockServiceWorker.js"));
|
|
69
|
-
docs.compileWorker("#mock-service-worker", mswUrl
|
|
69
|
+
docs.compileWorker("#mock-service-worker", mswUrl, {
|
|
70
|
+
/* this format must match `docs/src/bunde-mocks.ts`, we use iife over esm
|
|
71
|
+
* until we can properly deploy everywhere (when deployed internally the
|
|
72
|
+
* service worker refused to load due to a redirect 302), if this is changed
|
|
73
|
+
* make sure it runs when deployed internally */
|
|
74
|
+
format: "iife",
|
|
75
|
+
});
|
|
70
76
|
|
|
71
77
|
await docs.build([
|
|
72
78
|
{
|
package/files/docs/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@fkui/icon-lib-default": "6.59.0",
|
|
14
14
|
"@fkui/vue": "6.59.0",
|
|
15
15
|
"@forsakringskassan/apimock-express": "4.2.1",
|
|
16
|
-
"@forsakringskassan/docs-generator": "3.
|
|
16
|
+
"@forsakringskassan/docs-generator": "3.14.0",
|
|
17
17
|
"@tsconfig/node24": "24.0.5",
|
|
18
18
|
"@tsconfig/recommended": "1.0.13",
|
|
19
19
|
"http-server": "14.1.1",
|
package/files/package.json
CHANGED
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
],
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "run-s build:lib build:dts build:api",
|
|
48
|
+
"postbuild": "npm run -w docs build",
|
|
48
49
|
"build:api": "fk-api-extractor api-extractor.*.json",
|
|
49
|
-
"build:docs": "npm run -w docs build",
|
|
50
50
|
"build:dts": "vue-tsc -b",
|
|
51
51
|
"build:lib": "fk-build-vue-lib --clean --selectors",
|
|
52
52
|
"clean": "rimraf -g dist temp",
|
|
@@ -66,7 +66,6 @@
|
|
|
66
66
|
"start:docs": "npm start -w docs",
|
|
67
67
|
"stylelint": "stylelint \"src/**/*.{css,scss,vue}\"",
|
|
68
68
|
"stylelint:fix": "npm run stylelint -- --fix",
|
|
69
|
-
"pretest": "npm run lint",
|
|
70
69
|
"test": "vitest run",
|
|
71
70
|
"unit": "vitest run --no-coverage"
|
|
72
71
|
},
|
|
@@ -98,7 +97,7 @@
|
|
|
98
97
|
"@forsakringskassan/commitlint-config": "4.2.8",
|
|
99
98
|
"@forsakringskassan/cypress-config": "1.10.0",
|
|
100
99
|
"@forsakringskassan/cypress-visual-regression": "5.2.0",
|
|
101
|
-
"@forsakringskassan/docs-generator": "3.
|
|
100
|
+
"@forsakringskassan/docs-generator": "3.14.0",
|
|
102
101
|
"@forsakringskassan/docs-live-example": "3.0.2",
|
|
103
102
|
"@forsakringskassan/eslint-config": "15.11.4",
|
|
104
103
|
"@forsakringskassan/eslint-config-cli": "15.11.0",
|
|
@@ -112,9 +111,9 @@
|
|
|
112
111
|
"@forsakringskassan/stylelint-config": "3.5.0",
|
|
113
112
|
"@forsakringskassan/vite-lib-config": "5.12.5",
|
|
114
113
|
"@forsakringskassan/vitest-config-jsdom": "5.0.0",
|
|
115
|
-
"@forsakringskassan/vue-lib-template": "1.
|
|
114
|
+
"@forsakringskassan/vue-lib-template": "1.6.0",
|
|
116
115
|
"@html-validate/release-scripts": "7.6.12",
|
|
117
|
-
"@types/node": "24.
|
|
116
|
+
"@types/node": "24.19.0",
|
|
118
117
|
"@typescript/native": "npm:typescript@7.0.2",
|
|
119
118
|
"@vue/server-renderer": "3.5.43",
|
|
120
119
|
"@vue/test-utils": "2.5.1",
|
|
@@ -130,7 +129,7 @@
|
|
|
130
129
|
"rimraf": "6.1.3",
|
|
131
130
|
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
132
131
|
"vite": "8.3.1",
|
|
133
|
-
"vitest": "5.0.
|
|
132
|
+
"vitest": "5.0.2",
|
|
134
133
|
"vue": "3.5.43",
|
|
135
134
|
"vue-tsc": "3.3.11"
|
|
136
135
|
},
|
|
@@ -55,25 +55,24 @@ Refer to [FcCatInfoComponent.vue](https://github.com/Forsakringskassan/vue-lib-t
|
|
|
55
55
|
|
|
56
56
|
Use the repository scripts from the root of the project unless stated otherwise. The most important commands for daily development are marked in **bold**.
|
|
57
57
|
|
|
58
|
-
| Command | Use it for
|
|
59
|
-
| ------------------------ |
|
|
60
|
-
| **`npm start`** | Start the Vite development server using `src/vite-dev/app.vue`.
|
|
61
|
-
| **`npm run build`** | Build the library, declaration files, API reports, and the Cloneman template.
|
|
62
|
-
| `npm run build:lib` | Build the distributable JavaScript and CSS library bundle.
|
|
63
|
-
| `npm run build:dts` | Check and emit TypeScript declaration files.
|
|
64
|
-
| `npm run build:api` | Update API Extractor reports for the public package surface.
|
|
65
|
-
| **`npm run
|
|
66
|
-
| **`npm
|
|
67
|
-
| **`npm
|
|
68
|
-
| **`npm run
|
|
69
|
-
| **`npm run lint`**
|
|
70
|
-
|
|
|
71
|
-
| `npm run prettier:
|
|
72
|
-
| `npm run
|
|
73
|
-
| `npm run
|
|
74
|
-
| `npm run
|
|
75
|
-
| `npm run
|
|
76
|
-
| `npm run clean` | Remove generated `dist/` and `temp/` files. |
|
|
58
|
+
| Command | Use it for |
|
|
59
|
+
| ------------------------ | ------------------------------------------------------------------------------------------- |
|
|
60
|
+
| **`npm start`** | Start the Vite development server using `src/vite-dev/app.vue`. |
|
|
61
|
+
| **`npm run build`** | Build the library, declaration files, API reports, documentation and the Cloneman template. |
|
|
62
|
+
| `npm run build:lib` | Build the distributable JavaScript and CSS library bundle. |
|
|
63
|
+
| `npm run build:dts` | Check and emit TypeScript declaration files. |
|
|
64
|
+
| `npm run build:api` | Update API Extractor reports for the public package surface. |
|
|
65
|
+
| **`npm run start:docs`** | Serve the generated documentation site locally at `http://localhost:8080`. |
|
|
66
|
+
| **`npm test`** | Run Vitest |
|
|
67
|
+
| **`npm run unit`** | Run Vitest without coverage. Useful for a quick unit-test loop. |
|
|
68
|
+
| **`npm run lint`** | Run Prettier, ESLint, Stylelint, and HTML validation checks. |
|
|
69
|
+
| **`npm run lint:fix`** | Apply available automatic formatting and lint fixes. Review the resulting diff. |
|
|
70
|
+
| `npm run prettier:check` | Check formatting without changing files. |
|
|
71
|
+
| `npm run prettier:write` | Format supported files. |
|
|
72
|
+
| `npm run eslint` | Run ESLint with its cache. |
|
|
73
|
+
| `npm run stylelint` | Check styles in `src/**/*.css` and `src/**/*.scss`. |
|
|
74
|
+
| `npm run html-validate` | Validate HTML, Vue files, and Markdown examples. |
|
|
75
|
+
| `npm run clean` | Remove generated `dist/` and `temp/` files. |
|
|
77
76
|
|
|
78
77
|
## Running examples
|
|
79
78
|
|
|
@@ -85,12 +84,25 @@ npm start catinfo
|
|
|
85
84
|
|
|
86
85
|
This uses fuzzy search to find and start the best matching file in `src/examples/` (e.g., `CatInfoExample.vue`).
|
|
87
86
|
|
|
87
|
+
## API URL configuration
|
|
88
|
+
|
|
89
|
+
The cat example reads its endpoint from the Vite environment variable `VITE_CAT_API_URL` in `.env`.
|
|
90
|
+
The repository's `.env` sets the local mock endpoint:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
VITE_CAT_API_URL=/api/cat
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
If you need to vary variables between different environments, create additional `.env` files for each mode, for example `.env.development` and `.env.production`. See the [Vite documentation](https://vite.dev/guide/env-and-mode#env-variables).
|
|
97
|
+
|
|
98
|
+
Restart the development server after changing the value in an env file.
|
|
99
|
+
|
|
88
100
|
## Documentation commands
|
|
89
101
|
|
|
90
102
|
Documentation is maintained in `docs/` and generated with [`@forsakringskassan/docs-generator`](https://forsakringskassan.github.io/docs-generator/latest/). A typical local workflow is:
|
|
91
103
|
|
|
92
104
|
```bash
|
|
93
|
-
npm run build
|
|
105
|
+
npm run build
|
|
94
106
|
npm run start:docs
|
|
95
107
|
```
|
|
96
108
|
|
|
@@ -47,7 +47,8 @@ The reference implementation shows this pattern in [FcCatInfoComponentLiveExampl
|
|
|
47
47
|
|
|
48
48
|
See the [docs-live-example README](https://github.com/Forsakringskassan/docs-live-example/blob/main/README.md) for the implementation details behind interactive examples.
|
|
49
49
|
|
|
50
|
-
A runnable example is part of the documentation contract, not optional decoration.
|
|
50
|
+
A runnable example is part of the documentation contract, not optional decoration.
|
|
51
|
+
Add at least one for every component and verify it through `npm run build` and the local documentation server.
|
|
51
52
|
|
|
52
53
|
## Explain usage and constraints
|
|
53
54
|
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { Cat } from "./cat-types";
|
|
2
2
|
|
|
3
|
+
const apiUrl = import.meta.env.VITE_CAT_API_URL;
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* @internal
|
|
5
7
|
*/
|
|
6
8
|
export async function catGetById(id: string): Promise<Cat> {
|
|
7
|
-
const
|
|
9
|
+
const query = new URLSearchParams({ id }).toString();
|
|
10
|
+
const response = await fetch(`${apiUrl}?${query}`);
|
|
8
11
|
|
|
9
12
|
if (!response.ok) {
|
|
10
13
|
const errorData = (await response.json()) as { error?: string };
|
package/hooks/install.mjs
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
async function updatePackagejson(context ) {
|
|
4
|
+
const { getParameter, updateJsonFile } = context;
|
|
5
|
+
|
|
6
|
+
/* write repository url to "package.json" */
|
|
7
|
+
const repoUrl = getParameter("code-repo-url");
|
|
8
|
+
await updateJsonFile("package.json", {
|
|
9
|
+
repository: {
|
|
10
|
+
type: "git",
|
|
11
|
+
url: `git+${repoUrl}`,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
3
16
|
async function enableDeployDocs(context ) {
|
|
4
17
|
const { getParameter, replaceInFile } = context;
|
|
5
18
|
const url = getParameter("docs-repo-url");
|
|
@@ -14,6 +27,8 @@ export async function install(context ) {
|
|
|
14
27
|
const { getApplicationName, replaceInFile } = context;
|
|
15
28
|
const scopedName = getApplicationName();
|
|
16
29
|
|
|
30
|
+
await updatePackagejson(context);
|
|
31
|
+
|
|
17
32
|
/* update placeholder names with the real application name (from package.json) */
|
|
18
33
|
const placeholder = /"@forsakringskassan\/vue-lib-template(\/[^"]+)?"/g;
|
|
19
34
|
const quotedName = (_ , subpath ) => {
|
package/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
const options = {
|
|
9
9
|
...packageJson.cloneman,
|
|
10
|
-
fileHash: "
|
|
10
|
+
fileHash: "2040dc28f6d366d8e92dd5c1c12f9505f76448c8ad88483604b79c89c2c5376a",
|
|
11
11
|
filesDir: path.join(import.meta.dirname, "files"),
|
|
12
12
|
hooksDir: path.join(import.meta.dirname, "hooks"),
|
|
13
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forsakringskassan/vue-lib-template",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Vue library template based on Cloneman",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"template",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
".agents/skills/documentation/SKILL.md",
|
|
28
28
|
".agents/skills/documentation/template.md",
|
|
29
29
|
".editorconfig",
|
|
30
|
+
".env",
|
|
30
31
|
".gitignore",
|
|
31
32
|
".htmlvalidate.json",
|
|
32
33
|
".htmlvalidateignore",
|
|
@@ -101,6 +102,7 @@
|
|
|
101
102
|
"src/style.scss",
|
|
102
103
|
"src/theme.scss",
|
|
103
104
|
"src/vite-dev/app.vue",
|
|
105
|
+
"src/vite-env.d.ts",
|
|
104
106
|
"tsconfig.cypress.json",
|
|
105
107
|
"tsconfig.json",
|
|
106
108
|
"tsconfig.lib.json",
|
|
@@ -111,10 +113,7 @@
|
|
|
111
113
|
".agents/skills/documentation/SKILL.md",
|
|
112
114
|
".agents/skills/documentation/template.md",
|
|
113
115
|
".editorconfig",
|
|
114
|
-
".gitignore",
|
|
115
116
|
".htmlvalidate.json",
|
|
116
|
-
".htmlvalidateignore",
|
|
117
|
-
".prettierignore",
|
|
118
117
|
".vscode/extensions.json",
|
|
119
118
|
".vscode/settings.json",
|
|
120
119
|
"api-extractor.lib.json",
|
|
@@ -148,6 +147,24 @@
|
|
|
148
147
|
"vite.config.mts"
|
|
149
148
|
],
|
|
150
149
|
"partiallyManagedFiles": [
|
|
150
|
+
{
|
|
151
|
+
"filename": ".gitignore",
|
|
152
|
+
"include": {
|
|
153
|
+
"above": "--- Add local changes below ---"
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"filename": ".htmlvalidateignore",
|
|
158
|
+
"include": {
|
|
159
|
+
"above": "--- Add local changes below ---"
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"filename": ".prettierignore",
|
|
164
|
+
"include": {
|
|
165
|
+
"above": "--- Add local changes below ---"
|
|
166
|
+
}
|
|
167
|
+
},
|
|
151
168
|
{
|
|
152
169
|
"filename": "src/theme.scss",
|
|
153
170
|
"include": {
|
|
@@ -188,10 +205,17 @@
|
|
|
188
205
|
"fk-icons"
|
|
189
206
|
],
|
|
190
207
|
"parameters": [
|
|
208
|
+
{
|
|
209
|
+
"key": "code-repo-url",
|
|
210
|
+
"description": "URL to code repository",
|
|
211
|
+
"help": "Format: https://example.net/project/repo.git",
|
|
212
|
+
"required": true,
|
|
213
|
+
"pattern": "https://.*.git"
|
|
214
|
+
},
|
|
191
215
|
{
|
|
192
216
|
"key": "docs-repo-url",
|
|
193
217
|
"description": "URL to repository to deploy documentation to",
|
|
194
|
-
"help": "Format: ssh://user@
|
|
218
|
+
"help": "Format: ssh://user@example.net:project/repo.git",
|
|
195
219
|
"required": false,
|
|
196
220
|
"defaultValue": "",
|
|
197
221
|
"pattern": "ssh://.*.git"
|