fg-devkit 1.7.10 → 1.7.12

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
@@ -132,6 +132,12 @@ Upgrade policy versions interactively:
132
132
  pnpm exec fgd policy-upgrade
133
133
  ```
134
134
 
135
+ Upgrade one package.json dependency and auto-commit (`dep(package): bump to version`):
136
+
137
+ ```bash
138
+ pnpm exec fgd policy-upgrade-commit
139
+ ```
140
+
135
141
  ## tsconfig in consuming repos
136
142
 
137
143
  Use `fgd sync-project-configs` (or `fgd sync-tooling-configs`) to write the local `tsconfig.json` template from `fg-devkit`.
@@ -200,7 +206,7 @@ fgd() {
200
206
  EOF
201
207
  ```
202
208
 
203
- 2) Reload shell config:
209
+ 1) Reload shell config:
204
210
 
205
211
  ```bash
206
212
  source ~/.zshrc
@@ -10,5 +10,5 @@
10
10
  "index.html"
11
11
  ],
12
12
  "publicPackages": ["fds-vue-core"],
13
- "ignoreDependencies": ["@intlify/unplugin-vue-i18n"]
13
+ "ignoreDependencies": ["fds-vue-core", "@intlify/unplugin-vue-i18n"]
14
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fg-devkit",
3
- "version": "1.7.10",
3
+ "version": "1.7.12",
4
4
  "description": "Shared configs, scripts, and DX tooling for Vue / TypeScript frontend repos",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -35,6 +35,7 @@
35
35
  "./scripts/fleet-vulns.mjs": "./scripts/fleet-vulns.mjs",
36
36
  "./scripts/fleet-bump-fg-devkit.mjs": "./scripts/fleet-bump-fg-devkit.mjs",
37
37
  "./scripts/policy-upgrade.mjs": "./scripts/policy-upgrade.mjs",
38
+ "./scripts/policy-upgrade-commit.mjs": "./scripts/policy-upgrade-commit.mjs",
38
39
  "./scripts/check-dependency-policy.mjs": "./scripts/check-dependency-policy.mjs",
39
40
  "./scripts/sync-dependency-policy.mjs": "./scripts/sync-dependency-policy.mjs",
40
41
  "./scripts/resolve-dependency-policy-path.mjs": "./scripts/resolve-dependency-policy-path.mjs",
@@ -34,7 +34,7 @@
34
34
  "@tanstack/vue-query-devtools": "6.1.28",
35
35
  "@types/node": "22.16.5",
36
36
  "@vitejs/plugin-vue": "6.0.6",
37
- "fg-devkit": "1.7.10",
37
+ "fg-devkit": "1.7.12",
38
38
  "start-server-and-test": "2.1.3",
39
39
  "tailwindcss": "4.2.4",
40
40
  "tsx": "4.21.0",
@@ -11,6 +11,7 @@
11
11
  * pnpm exec fg-devkit fleet-vulns [projects-root] [--summary-only] [--delay-ms=<ms>]
12
12
  * pnpm exec fg-devkit fleet-bump-fg-devkit [projects-root] [--dry-run]
13
13
  * pnpm exec fg-devkit policy-upgrade [policy-file] [ncu-args...]
14
+ * pnpm exec fg-devkit policy-upgrade-commit [ncu-args...]
14
15
  * pnpm exec fg-devkit sync-project-configs (VS Code + tooling sync; overwrites config files)
15
16
  * pnpm exec fg-devkit sync-tooling-configs (tooling sync only; overwrites config files)
16
17
  * pnpm exec fg-devkit sync-vscode-settings
@@ -164,106 +165,6 @@ function runFullConsumerSetup() {
164
165
  return runPnpmInstall()
165
166
  }
166
167
 
167
- function stageFiles(paths = []) {
168
- const existing = paths.filter((p) => fs.existsSync(path.join(process.cwd(), p)))
169
- if (existing.length === 0) return 0
170
- const r = spawnSync('git', ['add', '--', ...existing], {
171
- stdio: 'inherit',
172
- cwd: process.cwd(),
173
- env: process.env,
174
- })
175
- if (r.error) {
176
- console.error('[fg-devkit]', r.error.message)
177
- return 1
178
- }
179
- return r.status ?? 1
180
- }
181
-
182
- function commitStaged(message) {
183
- const r = spawnSync('git', ['commit', '-m', message], {
184
- stdio: 'inherit',
185
- cwd: process.cwd(),
186
- env: process.env,
187
- })
188
- if (r.error) {
189
- console.error('[fg-devkit]', r.error.message)
190
- return 1
191
- }
192
- return r.status ?? 1
193
- }
194
-
195
- function collectPolicyVersionChanges(beforePolicy, afterPolicy) {
196
- const before = {
197
- ...(beforePolicy.managedDependencies?.dependencies ?? {}),
198
- ...(beforePolicy.managedDependencies?.devDependencies ?? {}),
199
- ...(beforePolicy.managedAnywhere ?? {}),
200
- }
201
- const after = {
202
- ...(afterPolicy.managedDependencies?.dependencies ?? {}),
203
- ...(afterPolicy.managedDependencies?.devDependencies ?? {}),
204
- ...(afterPolicy.managedAnywhere ?? {}),
205
- }
206
- const changed = []
207
- for (const [name, newVersion] of Object.entries(after)) {
208
- const prev = before[name]
209
- if (prev !== undefined && prev !== newVersion) {
210
- changed.push({ name, from: prev, to: newVersion })
211
- }
212
- }
213
- return changed
214
- }
215
-
216
- /** Maintainer flow: run policy-upgrade, stage policy file, then auto-commit dep(package): bump to version. */
217
- function runMaintainerPolicyUpgradeAndCommit() {
218
- const policyPath = path.join(process.cwd(), 'configs', 'dependency-policy.vue-workspace.json')
219
- if (!fs.existsSync(policyPath)) {
220
- console.error('[fg-devkit] Expected policy at configs/dependency-policy.vue-workspace.json')
221
- return 1
222
- }
223
-
224
- let beforePolicy
225
- try {
226
- beforePolicy = JSON.parse(fs.readFileSync(policyPath, 'utf8'))
227
- } catch (err) {
228
- console.error(`[fg-devkit] Failed to read policy before upgrade: ${err.message}`)
229
- return 1
230
- }
231
-
232
- const upgradeCode = runNode('policy-upgrade.mjs')
233
- if (upgradeCode !== 0) return upgradeCode
234
-
235
- let afterPolicy
236
- try {
237
- afterPolicy = JSON.parse(fs.readFileSync(policyPath, 'utf8'))
238
- } catch (err) {
239
- console.error(`[fg-devkit] Failed to read policy after upgrade: ${err.message}`)
240
- return 1
241
- }
242
-
243
- const changed = collectPolicyVersionChanges(beforePolicy, afterPolicy)
244
- if (changed.length === 0) {
245
- console.log('[fg-devkit] No policy package version changes detected; skipping stage and commit flow.')
246
- return 0
247
- }
248
- if (changed.length > 1) {
249
- console.log('[fg-devkit] Multiple package changes detected in policy-upgrade:')
250
- for (const item of changed) {
251
- console.log(` - ${item.name}: ${item.from} -> ${item.to}`)
252
- }
253
- console.log('[fg-devkit] Please commit manually (or rerun and select a single package).')
254
- return 1
255
- }
256
-
257
- const [only] = changed
258
- const stageCode = stageFiles(['configs/dependency-policy.vue-workspace.json', 'scaffold/vue/package.json'])
259
- if (stageCode !== 0) return stageCode
260
-
261
- const commitMessage = `dep(${only.name}): bump to ${only.to}`
262
- console.log(`[fg-devkit] Staged policy change for ${only.name} -> ${only.to}`)
263
- console.log(`[fg-devkit] Auto-committing: ${commitMessage}`)
264
- return commitStaged(commitMessage)
265
- }
266
-
267
168
  /** Maintainer flow: run full repo vulnerability audit in fg-devkit root. */
268
169
  function runMaintainerAuditAll() {
269
170
  return runNode('repo-vulns.mjs')
@@ -462,6 +363,7 @@ const DIRECT_COMMANDS = {
462
363
  'fleet-vulns': 'fleet-vulns.mjs',
463
364
  'fleet-bump-fg-devkit': 'fleet-bump-fg-devkit.mjs',
464
365
  'policy-upgrade': 'policy-upgrade.mjs',
366
+ 'policy-upgrade-commit': 'policy-upgrade-commit.mjs',
465
367
  'sync-project-configs': 'sync-project-configs.mjs',
466
368
  'sync-tooling-configs': 'sync-tooling-configs.mjs',
467
369
  'sync-vscode-settings': 'sync-vscode-settings.mjs',
@@ -490,6 +392,8 @@ Commands:
490
392
  Bump fg-devkit, run sync-deps, then pnpm install across Vue repos
491
393
  policy-upgrade [policy-file] [ncu-args...]
492
394
  Upgrade policy packages via npm-check-updates (default interactive)
395
+ policy-upgrade-commit [ncu-args...]
396
+ Upgrade one consumer package.json package and auto-commit
493
397
  sync-project-configs VS Code + tooling sync (overwrites config files)
494
398
  sync-tooling-configs Tooling sync only (overwrites config files)
495
399
  sync-vscode-settings Copy shared VS Code settings into .vscode/settings.json
@@ -550,6 +454,7 @@ async function runInteractiveMenu() {
550
454
  return 1
551
455
  }
552
456
 
457
+
553
458
  const runSelectedAction = async (action) => {
554
459
  const out = action()
555
460
  if (typeof out === 'object' && out !== null && typeof out.then === 'function') {
@@ -697,15 +602,16 @@ async function runInteractiveMenu() {
697
602
  choices: [
698
603
  { name: 'Check', value: 'check' },
699
604
  { name: 'Sync', value: 'sync' },
605
+ { name: 'Upgrade one package.json package and auto-commit', value: 'upgrade-commit' },
700
606
  { name: 'Cancel', value: 'cancel' },
701
607
  ],
702
608
  default: 'check',
703
609
  loop: false,
704
610
  })
705
611
  if (choice === 'cancel') continue
706
- return runSelectedAction(() =>
707
- runNode(choice === 'check' ? 'check-dependency-policy.mjs' : 'sync-dependency-policy.mjs'),
708
- )
612
+ if (choice === 'check') return runSelectedAction(() => runNode('check-dependency-policy.mjs'))
613
+ if (choice === 'sync') return runSelectedAction(() => runNode('sync-dependency-policy.mjs'))
614
+ return runSelectedAction(() => runNode('policy-upgrade-commit.mjs'))
709
615
  }
710
616
 
711
617
  if (group === 'sync-configs') {
@@ -764,11 +670,10 @@ async function runInteractiveMenu() {
764
670
  { name: 'Show outdated dependency policy packages', value: 'm1' },
765
671
  { name: 'Upgrade dependency policy (interactive)', value: 'm2' },
766
672
  { name: 'Refresh dependency policy from repos (and scaffold/vue package.json)', value: 'm3' },
767
- { name: 'Upgrade one policy package, stage, and auto-commit', value: 'm4' },
768
- { name: 'Check policy vulnerabilities (audit)', value: 'm5' },
769
- { name: 'Check fg-devkit repo vulnerabilities', value: 'm6' },
770
- { name: 'Check vulnerabilities across all Vue repos', value: 'm7' },
771
- { name: 'Bump fg-devkit in all Vue repos, run sync-deps, and pnpm install', value: 'm8' },
673
+ { name: 'Check policy vulnerabilities (audit)', value: 'm4' },
674
+ { name: 'Check fg-devkit repo vulnerabilities', value: 'm5' },
675
+ { name: 'Check vulnerabilities across all Vue repos', value: 'm6' },
676
+ { name: 'Bump fg-devkit in all Vue repos, run sync-deps, and pnpm install', value: 'm7' },
772
677
  { name: 'Cancel', value: 'cancel' },
773
678
  ],
774
679
  default: 'm1',
@@ -780,11 +685,10 @@ async function runInteractiveMenu() {
780
685
  if (choice === 'm1') return runSelectedAction(() => runNode('policy-outdated.mjs'))
781
686
  if (choice === 'm2') return runSelectedAction(() => runNode('policy-upgrade.mjs'))
782
687
  if (choice === 'm3') return runSelectedAction(() => runNode('refresh-dependency-policy-from-repos.mjs'))
783
- if (choice === 'm4') return runSelectedAction(() => runMaintainerPolicyUpgradeAndCommit())
784
- if (choice === 'm5') return runSelectedAction(() => runNode('policy-vulns.mjs'))
785
- if (choice === 'm6') return runSelectedAction(() => runMaintainerAuditAll())
786
- if (choice === 'm7') return runSelectedAction(() => runNode('fleet-vulns.mjs'))
787
- if (choice === 'm8') return runSelectedAction(() => runNode('fleet-bump-fg-devkit.mjs'))
688
+ if (choice === 'm4') return runSelectedAction(() => runNode('policy-vulns.mjs'))
689
+ if (choice === 'm5') return runSelectedAction(() => runMaintainerAuditAll())
690
+ if (choice === 'm6') return runSelectedAction(() => runNode('fleet-vulns.mjs'))
691
+ if (choice === 'm7') return runSelectedAction(() => runNode('fleet-bump-fg-devkit.mjs'))
788
692
  return 1
789
693
  }
790
694
  }
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Runs vulnerability audits across Vue repositories and prints both per-repo
3
+ * Runs vulnerability audits across local repositories and prints both per-repo
4
4
  * pnpm audit output and a combined summary.
5
5
  *
6
6
  * Usage:
@@ -38,8 +38,10 @@ function readJson(p) {
38
38
  return JSON.parse(fs.readFileSync(p, 'utf8'))
39
39
  }
40
40
 
41
- function isVueProject(pkg) {
42
- return Boolean(pkg.dependencies?.vue || pkg.devDependencies?.vue)
41
+ function isPnpmProject(pkg) {
42
+ return (
43
+ typeof pkg.packageManager === 'string' && pkg.packageManager.toLowerCase().startsWith('pnpm@')
44
+ )
43
45
  }
44
46
 
45
47
  function countTotal(severityMap = {}) {
@@ -52,7 +54,7 @@ for (const packageJsonPath of packageJsonFiles) {
52
54
  try {
53
55
  const pkg = readJson(packageJsonPath)
54
56
  const repoDir = path.dirname(packageJsonPath)
55
- if (!isVueProject(pkg)) continue
57
+ if (!isPnpmProject(pkg)) continue
56
58
  if (pkg.name === 'fg-devkit') continue
57
59
  repos.push(repoDir)
58
60
  } catch {
@@ -62,7 +64,7 @@ for (const packageJsonPath of packageJsonFiles) {
62
64
 
63
65
  const uniqueRepos = [...new Set(repos)].sort((a, b) => a.localeCompare(b))
64
66
  if (uniqueRepos.length === 0) {
65
- console.log(`[fleet-vulns] No Vue repositories found under ${projectsRoot}`)
67
+ console.log(`[fleet-vulns] No pnpm repositories found under ${projectsRoot}`)
66
68
  process.exit(0)
67
69
  }
68
70
 
@@ -0,0 +1,137 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Upgrade one package in the consumer package.json, then auto-commit.
4
+ *
5
+ * Usage:
6
+ * pnpm exec fg-devkit policy-upgrade-commit [ncu-args...]
7
+ */
8
+
9
+ import fs from 'node:fs'
10
+ import path from 'node:path'
11
+ import { spawnSync } from 'node:child_process'
12
+ import { createRequire } from 'node:module'
13
+
14
+ const require = createRequire(import.meta.url)
15
+ const packageJsonPath = path.join(process.cwd(), 'package.json')
16
+
17
+ function runNcu(args = []) {
18
+ let ncuBin
19
+ try {
20
+ const ncuPkgPath = require.resolve('npm-check-updates/package.json')
21
+ ncuBin = path.join(path.dirname(ncuPkgPath), 'build', 'cli.js')
22
+ } catch {
23
+ console.error('[policy-upgrade-commit] Could not resolve npm-check-updates binary.')
24
+ return 1
25
+ }
26
+
27
+ const effectiveArgs =
28
+ args.length > 0
29
+ ? args
30
+ : ['--interactive', '--format', 'group', '--upgrade', '--packageManager', 'pnpm', '--install', 'never']
31
+
32
+ const result = spawnSync(process.execPath, [ncuBin, ...effectiveArgs], {
33
+ stdio: 'inherit',
34
+ cwd: process.cwd(),
35
+ env: process.env,
36
+ })
37
+ if (result.error) {
38
+ console.error('[policy-upgrade-commit]', result.error.message)
39
+ return 1
40
+ }
41
+ return result.status ?? 1
42
+ }
43
+
44
+ function runGit(args) {
45
+ const result = spawnSync('git', args, {
46
+ stdio: 'inherit',
47
+ cwd: process.cwd(),
48
+ env: process.env,
49
+ })
50
+ if (result.error) {
51
+ console.error('[policy-upgrade-commit]', result.error.message)
52
+ return 1
53
+ }
54
+ return result.status ?? 1
55
+ }
56
+
57
+ function readJson(jsonPath) {
58
+ return JSON.parse(fs.readFileSync(jsonPath, 'utf8'))
59
+ }
60
+
61
+ function collectPackageVersionChanges(beforePackage, afterPackage) {
62
+ const before = {
63
+ ...(beforePackage.dependencies ?? {}),
64
+ ...(beforePackage.devDependencies ?? {}),
65
+ ...(beforePackage.peerDependencies ?? {}),
66
+ ...(beforePackage.optionalDependencies ?? {}),
67
+ }
68
+ const after = {
69
+ ...(afterPackage.dependencies ?? {}),
70
+ ...(afterPackage.devDependencies ?? {}),
71
+ ...(afterPackage.peerDependencies ?? {}),
72
+ ...(afterPackage.optionalDependencies ?? {}),
73
+ }
74
+ const changed = []
75
+ for (const [name, newVersion] of Object.entries(after)) {
76
+ const previousVersion = before[name]
77
+ if (previousVersion !== undefined && previousVersion !== newVersion) {
78
+ changed.push({ name, from: previousVersion, to: newVersion })
79
+ }
80
+ }
81
+ return changed
82
+ }
83
+
84
+ function main() {
85
+ if (!fs.existsSync(packageJsonPath)) {
86
+ console.error(`[policy-upgrade-commit] package.json not found at ${packageJsonPath}`)
87
+ process.exit(1)
88
+ }
89
+
90
+ let beforePackage
91
+ try {
92
+ beforePackage = readJson(packageJsonPath)
93
+ } catch (err) {
94
+ console.error(`[policy-upgrade-commit] Failed to parse package.json before upgrade: ${err.message}`)
95
+ process.exit(1)
96
+ }
97
+
98
+ const upgradeExitCode = runNcu(process.argv.slice(2))
99
+ if (upgradeExitCode !== 0) {
100
+ process.exit(upgradeExitCode)
101
+ }
102
+
103
+ let afterPackage
104
+ try {
105
+ afterPackage = readJson(packageJsonPath)
106
+ } catch (err) {
107
+ console.error(`[policy-upgrade-commit] Failed to parse package.json after upgrade: ${err.message}`)
108
+ process.exit(1)
109
+ }
110
+
111
+ const changed = collectPackageVersionChanges(beforePackage, afterPackage)
112
+ if (changed.length === 0) {
113
+ console.log('[policy-upgrade-commit] No package version changes detected in package.json.')
114
+ process.exit(0)
115
+ }
116
+ if (changed.length > 1) {
117
+ console.log('[policy-upgrade-commit] Multiple package changes detected in package.json:')
118
+ for (const item of changed) {
119
+ console.log(` - ${item.name}: ${item.from} -> ${item.to}`)
120
+ }
121
+ console.log('[policy-upgrade-commit] Auto-commit supports exactly one changed package. Commit manually.')
122
+ process.exit(1)
123
+ }
124
+
125
+ const [only] = changed
126
+ const stageExitCode = runGit(['add', '--', 'package.json'])
127
+ if (stageExitCode !== 0) {
128
+ process.exit(stageExitCode)
129
+ }
130
+
131
+ const commitMessage = `dep(${only.name}): bump to ${only.to}`
132
+ console.log(`[policy-upgrade-commit] Staged changes for ${only.name} -> ${only.to}`)
133
+ console.log(`[policy-upgrade-commit] Auto-committing: ${commitMessage}`)
134
+ process.exit(runGit(['commit', '-m', commitMessage]))
135
+ }
136
+
137
+ main()