@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 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:docs
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
- # Changes will be overwritten!
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
- # Changes will be overwritten!
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 ---
@@ -1,5 +1,7 @@
1
- # This file is managed by @forsakringskassan/vue-lib-template.
2
- # Changes will be overwritten!
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 ---
@@ -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
  {
@@ -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.12.1",
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",
@@ -6,5 +6,6 @@ import mocks from "../../src/mocks/index.mjs";
6
6
  const workerUrl = import.meta.resolve("#mock-service-worker");
7
7
 
8
8
  export const apimockReady = setupWorker(workerUrl, mocks, {
9
- type: "module",
9
+ /* this format must match `docs/build.mts` */
10
+ type: "classic",
10
11
  });
@@ -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.12.1",
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.5.2",
114
+ "@forsakringskassan/vue-lib-template": "1.6.0",
116
115
  "@html-validate/release-scripts": "7.6.12",
117
- "@types/node": "24.13.6",
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.1",
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 build:docs`** | Build the documentation site into `docs/public/`. |
66
- | **`npm run start:docs`** | Serve the generated documentation site locally at `http://localhost:8080`. |
67
- | **`npm test`** | Run the full test command, including the configured pre-test checks. |
68
- | **`npm run unit`** | Run Vitest without coverage. Useful for a quick unit-test loop. |
69
- | **`npm run lint`** | Run Prettier, ESLint, Stylelint, and HTML validation checks. |
70
- | **`npm run lint:fix`** | Apply available automatic formatting and lint fixes. Review the resulting diff. |
71
- | `npm run prettier:check` | Check formatting without changing files. |
72
- | `npm run prettier:write` | Format supported files. |
73
- | `npm run eslint` | Run ESLint with its cache. |
74
- | `npm run stylelint` | Check styles in `src/**/*.css` and `src/**/*.scss`. |
75
- | `npm run html-validate` | Validate HTML, Vue files, and Markdown examples. |
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:docs
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. Add at least one for every component and verify it through `npm run build:docs` and the local documentation server.
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
 
@@ -2,6 +2,8 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
2
2
  import { catGetById } from "./cat-api";
3
3
 
4
4
  describe("catGetById", () => {
5
+ vi.stubEnv("VITE_CAT_API_URL", "/api/cat");
6
+
5
7
  beforeEach(() => {
6
8
  vi.stubGlobal("fetch", vi.fn());
7
9
  });
@@ -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 response = await fetch(`/api/cat?id=${id}`);
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 };
@@ -0,0 +1,7 @@
1
+ interface ImportMetaEnv {
2
+ readonly VITE_CAT_API_URL: string;
3
+ }
4
+
5
+ interface ImportMeta {
6
+ readonly env: ImportMetaEnv;
7
+ }
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: "d52f8481fc95881263df7af7368e65c192df06f584027f33c50abe8be2f6dbaa",
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.5.2",
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@host/project/repo.git",
218
+ "help": "Format: ssh://user@example.net:project/repo.git",
195
219
  "required": false,
196
220
  "defaultValue": "",
197
221
  "pattern": "ssh://.*.git"