fg-devkit 1.21.0 → 1.21.1

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 CHANGED
@@ -72,8 +72,7 @@ pnpm exec fgd sync-dependency-check-suppressions-commit --all # every entry in
72
72
 
73
73
  The command runs `pnpm audit` and keeps only the active (not expired) `<suppress>` entries from fg-devkit's shared
74
74
  `configs/dependency-check-suppressions.xml` whose GHSA id is reported in the repo, so each repo accepts exactly the
75
- risks it has. Jenkins `owaspDependencyCheck` reads `dependency-check-suppressions.xml` from the repo root when the
76
- file exists. Add another `<suppress>` element in the shared fg-devkit file for each additional accepted finding.
75
+ risks it has. OWASP Dependency-Check reads the file when it is configured as a suppression file. Add another `<suppress>` element in the shared fg-devkit file for each additional accepted finding.
77
76
  The command overwrites the consumer copy; if nothing applies and the repo has no copy, no file is created.
78
77
 
79
78
  To sync standard consumer scripts to `fgd` commands:
@@ -176,7 +175,7 @@ pnpm exec fgd audit-override-commit --no-commit # leave the changes in the work
176
175
  4. Prunes overrides that no longer change the audit.
177
176
  5. If findings that are still reported have active (not expired) `<suppress>` entries in fg-devkit's shared
178
177
  `configs/dependency-check-suppressions.xml`, writes the repo's `dependency-check-suppressions.xml` with only
179
- those entries, so the Jenkins OWASP scan accepts exactly the risks this repo has. Findings with no patch and
178
+ those entries, so OWASP Dependency-Check accepts exactly the risks this repo has. Findings with no patch and
180
179
  no suppression are listed so you can add one.
181
180
  6. Installs and runs the repo's `lint-check`, `lint:ts`, `test`, `test:unit` and `build` scripts when present.
182
181
  Nothing is committed if a check fails.
@@ -217,9 +216,9 @@ export default {
217
216
 
218
217
  ## Piwik PRO custom dimensions
219
218
 
220
- Compare the local slot map with a Piwik PRO site, then create missing dimensions or rename existing ones. Run it from a consuming repo (`bokningsverktyget-ui`, `webbportalen-ui`, `feelgood-app`, and the same layout in other apps) or from the Electron maintainer UI under **Piwik**.
219
+ Compare the local slot map with a Piwik PRO site, then create missing dimensions or rename existing ones. Run it from a consuming repo.
221
220
 
222
- The local map is `src/analytics/dimensions.ts` (`customDimensions` = event, `sessionDimensions` = session) or `src/util/piwikDimensions.ts` (`CustomDimensions` / `SessionCustomDimensions`). The site defaults to the first non-production entry in `src/config/env.ts`, such as preprod. Pass `--env production` to target production. In the Electron app, Piwik actions show one radio per distinct `piwikId`. Environments that share an id, such as localhost, development, and preprod, appear once as **preprod**.
221
+ The local map is `src/analytics/dimensions.ts` (`customDimensions` = event, `sessionDimensions` = session) or `src/util/piwikDimensions.ts` (`CustomDimensions` / `SessionCustomDimensions`). The site defaults to the first non-production entry in `src/config/env.ts`, such as preprod. Pass `--env production` to target production.
223
222
 
224
223
  ```bash
225
224
  pnpm exec fgd piwik list
@@ -232,7 +231,7 @@ pnpm exec fgd piwik compare --from preprod --to production
232
231
  pnpm exec fgd piwik migrate --from preprod --to production --dry-run
233
232
  ```
234
233
 
235
- `sync` copies the local map up to the selected Piwik site: it creates missing dimensions, then renames existing ones. It does not edit the repo. `pull` copies tracking ids from that site down into the local map for keys with the same name. In the Electron app, **Sync** has From and To radios. **Local map** is the repo. A site as To writes up to Piwik. **Local map** as To writes down into the repo. Two sites migrate between environments.
234
+ `sync` copies the local map up to the selected Piwik site: it creates missing dimensions, then renames existing ones. It does not edit the repo. `pull` copies tracking ids from that site down into the local map for keys with the same name.
236
235
 
237
236
  `compare` checks two sites from `src/config/env.ts` against each other. Event and session dimensions match on `tracking_id`, so a different slot on the other site is still in sync. `migrate` copies names, descriptions, and missing dimensions from `--from` onto `--to`, one create at a time. It stops if Piwik assigns a different `tracking_id`. Dimensions that exist only on the target stay there.
238
237
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fg-devkit",
3
- "version": "1.21.0",
3
+ "version": "1.21.1",
4
4
  "description": "Shared configs, scripts, and DX tooling for Vue / TypeScript frontend repos",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -32,7 +32,7 @@
32
32
  "@intlify/unplugin-vue-i18n": "11.2.5",
33
33
  "@tanstack/vue-query-devtools": "6.3.1",
34
34
  "@types/node": "22.16.5",
35
- "fg-devkit": "1.21.0",
35
+ "fg-devkit": "1.21.1",
36
36
  "@vitejs/plugin-vue": "6.0.9",
37
37
  "tailwindcss": "4.3.3",
38
38
  "tsx": "4.23.15",
@@ -12,7 +12,7 @@
12
12
  * 4. Prune overrides that no longer change the audit (prune-overrides --fix).
13
13
  * 5. If findings that are still reported have active <suppress> entries in fg-devkit's
14
14
  * shared dependency-check-suppressions.xml, write the repo's copy with only those
15
- * entries, so the Jenkins OWASP scan accepts exactly the risks this repo has.
15
+ * entries, so OWASP Dependency-Check accepts exactly the risks this repo has.
16
16
  * 6. Install and run the repo's checks (lint-check, lint:ts, test, test:unit, build).
17
17
  * 7. Commit the refresh, the override changes and the suppressions file separately.
18
18
  *
@@ -33,10 +33,7 @@ import fs from 'node:fs'
33
33
  import path from 'node:path'
34
34
  import { fileURLToPath } from 'node:url'
35
35
 
36
- import {
37
- DEFAULT_NODE_TOOLCHAIN_EXCLUDE,
38
- collectFleetProjectRepos,
39
- } from './fleet-project-repos.mjs'
36
+ import { collectFleetProjectRepos, toolchainExclude } from './fleet-project-repos.mjs'
40
37
  import { parseFleetSelectionFlags, resolveFleetRepos } from './fleet-repo-picker.mjs'
41
38
  import {
42
39
  formatNodeNvmrc,
@@ -213,7 +210,7 @@ async function main() {
213
210
  process.exit(1)
214
211
  }
215
212
 
216
- const allRepos = collectFleetProjectRepos(projectsRoot, { exclude: DEFAULT_NODE_TOOLCHAIN_EXCLUDE })
213
+ const allRepos = collectFleetProjectRepos(projectsRoot, { exclude: toolchainExclude(projectsRoot) })
217
214
  if (allRepos.length === 0) {
218
215
  console.log(`[bump-node-toolchain] No project repositories under ${projectsRoot}`)
219
216
  process.exit(0)
@@ -80,11 +80,31 @@ export function collectFleetGitRepos(projectsRoot) {
80
80
  return repos.sort((a, b) => a.localeCompare(b))
81
81
  }
82
82
 
83
- /** Repos that intentionally maintain multiple Node versions or non-pnpm tooling. */
84
- export const DEFAULT_NODE_TOOLCHAIN_EXCLUDE = new Set(['jenkins-dockerfile', 'vulnerability-test'])
83
+ /** Local config file in the projects root (not part of fg-devkit). */
84
+ export const FLEET_CONFIG_FILE = '.fg-devkit-fleet.json'
85
85
 
86
- /** Repos excluded from fleet-wide pnpm toolchain bumps (non-pnpm or special tooling). */
87
- export const DEFAULT_PNPM_TOOLCHAIN_EXCLUDE = new Set(['jenkins-dockerfile', 'vulnerability-test'])
86
+ /**
87
+ * Repos excluded from fleet-wide Node and pnpm toolchain bumps (for example repos that
88
+ * maintain several Node versions or do not use pnpm). Read from `toolchainExclude` in
89
+ * `<projectsRoot>/.fg-devkit-fleet.json` and the comma-separated `FGD_TOOLCHAIN_EXCLUDE`
90
+ * environment variable.
91
+ *
92
+ * @param {string} projectsRoot
93
+ * @returns {Set<string>}
94
+ */
95
+ export function toolchainExclude(projectsRoot) {
96
+ const names = new Set()
97
+ try {
98
+ const config = JSON.parse(fs.readFileSync(path.join(projectsRoot, FLEET_CONFIG_FILE), 'utf8'))
99
+ for (const name of config?.toolchainExclude ?? []) names.add(String(name))
100
+ } catch {
101
+ // No local config: nothing excluded.
102
+ }
103
+ for (const name of (process.env.FGD_TOOLCHAIN_EXCLUDE ?? '').split(',')) {
104
+ if (name.trim()) names.add(name.trim())
105
+ }
106
+ return names
107
+ }
88
108
 
89
109
  /**
90
110
  * @param {string} dir
@@ -108,7 +128,7 @@ export function isPnpmPackageJsonDir(dir, pkg) {
108
128
  export function collectFleetPnpmRepos(projectsRoot, options = {}) {
109
129
  const exclude = new Set([
110
130
  ...DEFAULT_FLEET_REPO_EXCLUDE,
111
- ...DEFAULT_PNPM_TOOLCHAIN_EXCLUDE,
131
+ ...toolchainExclude(projectsRoot),
112
132
  ...(options.exclude ?? []),
113
133
  ])
114
134
  const { skipScaffoldVue = true } = options
@@ -13,7 +13,7 @@ import {
13
13
  } from './dependency-policy-toolchain.mjs'
14
14
 
15
15
  const DOCKER_FROM_NODE_PATTERN = /FROM node:(v)?(\d+(?:\.\d+)?)(-[a-z0-9-]+)?/gi
16
- const JENKINS_NODE_IMAGE_PATTERN = /(feelgoodsvenska\/jenkins-build:)node\d+/g
16
+ const JENKINS_NODE_IMAGE_PATTERN = /([\w.-]+\/jenkins-build:)node\d+/g
17
17
  const GITHUB_NODE_VERSION_PATTERN = /node-version:\s*['"]?\d+(?:\.\d+)?['"]?/g
18
18
 
19
19
  /**
@@ -323,7 +323,7 @@ export function collectNodeToolchainViolations(repoRoot, policy, fgDevkitRoot) {
323
323
  const expectedJenkins = jenkinsImage ?? deriveJenkinsImageTag(nvmrc)
324
324
  if (fs.existsSync(jenkinsfilePath)) {
325
325
  const jenkinsfile = fs.readFileSync(jenkinsfilePath, 'utf8')
326
- const matches = [...jenkinsfile.matchAll(/feelgoodsvenska\/jenkins-build:(node\d+)/g)]
326
+ const matches = [...jenkinsfile.matchAll(/[\w.-]+\/jenkins-build:(node\d+)/g)]
327
327
  for (const match of matches) {
328
328
  if (match[1] !== expectedJenkins) {
329
329
  violations.push(`Jenkinsfile: expected jenkins-build:${expectedJenkins}, got jenkins-build:${match[1]}`)
@@ -381,20 +381,3 @@ test('pull plans tracking id updates from Piwik into the local map', () => {
381
381
  'export const customDimensions = { active: 46, step: 30 } as const\n',
382
382
  )
383
383
  })
384
-
385
- test('parses the real consumer dimension files when they are checked out beside fg-devkit', () => {
386
- const files = [
387
- ['../../bokningsverktyget-ui/src/analytics/dimensions.ts', 'event', 'rowsBooked', 7],
388
- ['../../webbportalen-ui/src/analytics/dimensions.ts', 'session', 'organizationName', 26],
389
- ['../../feelgood-app/src/util/piwikDimensions.ts', 'event', 'eventTimestamp', 78],
390
- ]
391
- for (const [relative, scope, key, slot] of files) {
392
- const file = path.join(scriptDir, relative)
393
- if (!fs.existsSync(file)) continue
394
- const dimensions = parseDimensionSource(fs.readFileSync(file, 'utf8'), relative)
395
- const found = dimensions.find((item) => item.key === key)
396
- assert.ok(found, `${key} missing in ${relative}`)
397
- assert.equal(found.scope, scope)
398
- assert.equal(found.slot, slot)
399
- }
400
- })
@@ -3,7 +3,7 @@
3
3
  * Write dependency-check-suppressions.xml into the consumer repo and auto-commit.
4
4
  *
5
5
  * Only the active <suppress> entries from fg-devkit's shared file that match a finding
6
- * `pnpm audit` still reports in this repo are written, so the Jenkins OWASP scan accepts
6
+ * `pnpm audit` still reports in this repo are written, so OWASP Dependency-Check accepts
7
7
  * exactly the risks this repo has. Pass --all to copy the whole shared file instead.
8
8
  *
9
9
  * Usage: