fg-devkit 1.16.0 → 1.16.2

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.
@@ -30,7 +30,7 @@
30
30
  "content-disposition-header": "0.6.0",
31
31
  "date-fns": "4.4.0",
32
32
  "element-plus": "2.14.5",
33
- "fds-vue-core": "8.6.4",
33
+ "fds-vue-core": "8.6.6",
34
34
  "imask": "7.6.1",
35
35
  "leaflet": "1.9.4",
36
36
  "lexical": "0.49.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fg-devkit",
3
- "version": "1.16.0",
3
+ "version": "1.16.2",
4
4
  "description": "Shared configs, scripts, and DX tooling for Vue / TypeScript frontend repos",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -21,7 +21,7 @@
21
21
  "content-disposition-header": "0.6.0",
22
22
  "date-fns": "4.4.0",
23
23
  "dotenv": "16.4.5",
24
- "fds-vue-core": "8.6.4",
24
+ "fds-vue-core": "8.6.6",
25
25
  "pinia": "3.0.4",
26
26
  "qrcode.vue": "3.11.0",
27
27
  "vue": "3.5.42",
@@ -33,7 +33,7 @@
33
33
  "@tanstack/vue-query-devtools": "6.1.48",
34
34
  "@types/node": "22.16.5",
35
35
  "@vitejs/plugin-vue": "6.0.8",
36
- "fg-devkit": "1.16.0",
36
+ "fg-devkit": "1.16.2",
37
37
  "tailwindcss": "4.3.3",
38
38
  "tsx": "4.23.13",
39
39
  "vite": "7.3.5",
@@ -540,7 +540,7 @@ Commands:
540
540
  sync-tooling-configs Tooling sync only (overwrites config files)
541
541
  sync-vscode-settings Copy shared VS Code settings into .vscode/settings.json
542
542
  sync-core-coding-standards Copy .cursor core coding standards with consumer package name
543
- sync-vite-plugin-vue-inspector Add/pin vite-plugin-vue-inspector and wire it in vite.config
543
+ sync-vite-plugin-vue-inspector Add/pin vite-plugin-vue-inspector, wire vite.config, install, commit
544
544
  sync-consumer-scripts Enforce standard fgd scripts in consumer package.json
545
545
  setup-lefthook Setup lefthook and migrate from husky/lint-staged
546
546
  full-consumer-setup Run: scripts -> lefthook -> step 3 -> step 2 -> pnpm install
@@ -4,8 +4,10 @@
4
4
  *
5
5
  * - Adds/pins the package in package.json devDependencies (version from dependency policy)
6
6
  * - Ensures import + Inspector({ launchEditor: 'cursor', toggleComboKey: 'meta-alt' }) in vite.config.*
7
+ * - Runs pnpm install, then commits related files
7
8
  *
8
- * Does not overwrite the rest of vite.config. Idempotent.
9
+ * Does not overwrite the rest of vite.config. Idempotent when already up to date
10
+ * (skips install/commit).
9
11
  *
10
12
  * Usage:
11
13
  * node node_modules/fg-devkit/scripts/sync-vite-plugin-vue-inspector.mjs
@@ -15,6 +17,7 @@
15
17
  import fs from 'node:fs'
16
18
  import path from 'node:path'
17
19
  import { fileURLToPath } from 'node:url'
20
+ import { spawnSync } from 'node:child_process'
18
21
 
19
22
  import { resolveDependencyPolicyPath } from './resolve-dependency-policy-path.mjs'
20
23
 
@@ -24,6 +27,7 @@ const PLUGIN_OPTIONS = {
24
27
  launchEditor: 'cursor',
25
28
  toggleComboKey: 'meta-alt',
26
29
  }
30
+ const COMMIT_MESSAGE = 'dep(vite-plugin-vue-inspector): add dependency and config'
27
31
 
28
32
  const VITE_CONFIG_CANDIDATES = [
29
33
  'vite.config.ts',
@@ -41,6 +45,50 @@ function fail(message) {
41
45
  process.exit(1)
42
46
  }
43
47
 
48
+ function runPnpm(args) {
49
+ const result = spawnSync('pnpm', args, {
50
+ stdio: 'inherit',
51
+ cwd,
52
+ env: process.env,
53
+ })
54
+ if (result.error) {
55
+ fail(result.error.message)
56
+ }
57
+ return result.status ?? 1
58
+ }
59
+
60
+ function runGit(args, options = {}) {
61
+ const result = spawnSync('git', args, {
62
+ stdio: options.capture ? 'pipe' : 'inherit',
63
+ encoding: options.capture ? 'utf8' : undefined,
64
+ cwd,
65
+ env: process.env,
66
+ })
67
+ if (result.error) {
68
+ fail(result.error.message)
69
+ }
70
+ return { status: result.status ?? 1, stdout: result.stdout ?? '' }
71
+ }
72
+
73
+ function fileDiffersFromHead(filePath) {
74
+ const absolutePath = path.join(cwd, filePath)
75
+ if (!fs.existsSync(absolutePath)) return false
76
+
77
+ const tracked = runGit(['ls-files', '--error-unmatch', '--', filePath], { capture: true })
78
+ if (tracked.status !== 0) {
79
+ return true
80
+ }
81
+
82
+ const diff = runGit(['diff', '--quiet', 'HEAD', '--', filePath], { capture: true })
83
+ return diff.status !== 0
84
+ }
85
+
86
+ function stageExistingFiles(files) {
87
+ const existingFiles = files.filter((filePath) => fs.existsSync(path.join(cwd, filePath)))
88
+ if (existingFiles.length === 0) return 0
89
+ return runGit(['add', '--', ...existingFiles]).status
90
+ }
91
+
44
92
  function resolvePluginVersion(policy) {
45
93
  return (
46
94
  policy.managedDependencies?.devDependencies?.[PACKAGE_NAME] ??
@@ -252,10 +300,9 @@ function ensureImport(source) {
252
300
  function isCanonicalInspectorCall(callText) {
253
301
  const launchOk = /launchEditor\s*:\s*['"]cursor['"]/.test(callText)
254
302
  const toggleOk = /toggleComboKey\s*:\s*['"]meta-alt['"]/.test(callText)
255
- const onlyExpectedKeys =
256
- [...callText.matchAll(/(\w+)\s*:/g)].map((m) => m[1]).every((key) =>
257
- ['launchEditor', 'toggleComboKey'].includes(key),
258
- )
303
+ const onlyExpectedKeys = [...callText.matchAll(/(\w+)\s*:/g)]
304
+ .map((m) => m[1])
305
+ .every((key) => ['launchEditor', 'toggleComboKey'].includes(key))
259
306
  return launchOk && toggleOk && onlyExpectedKeys
260
307
  }
261
308
 
@@ -369,7 +416,34 @@ function syncViteConfig(projectRoot) {
369
416
  fs.writeFileSync(viteConfigPath, source, 'utf8')
370
417
  }
371
418
 
372
- return changes
419
+ return { changes, configName }
420
+ }
421
+
422
+ function installAndCommit(viteConfigName) {
423
+ console.log('[sync-vite-plugin-vue-inspector] Running pnpm install…')
424
+ const installExitCode = runPnpm(['install'])
425
+ if (installExitCode !== 0) {
426
+ process.exit(installExitCode)
427
+ }
428
+
429
+ const candidateFiles = ['package.json', 'pnpm-lock.yaml', viteConfigName].filter(Boolean)
430
+ const filesToStage = candidateFiles.filter((filePath) => fileDiffersFromHead(filePath))
431
+ if (filesToStage.length === 0) {
432
+ console.log('[sync-vite-plugin-vue-inspector] No related changes to commit.')
433
+ return
434
+ }
435
+
436
+ const stageExitCode = stageExistingFiles(filesToStage)
437
+ if (stageExitCode !== 0) {
438
+ process.exit(stageExitCode)
439
+ }
440
+
441
+ console.log(`[sync-vite-plugin-vue-inspector] Staged ${filesToStage.length} file(s)`)
442
+ console.log(`[sync-vite-plugin-vue-inspector] Auto-committing: ${COMMIT_MESSAGE}`)
443
+ const commitExitCode = runGit(['commit', '-m', COMMIT_MESSAGE]).status
444
+ if (commitExitCode !== 0) {
445
+ process.exit(commitExitCode)
446
+ }
373
447
  }
374
448
 
375
449
  function main() {
@@ -386,7 +460,7 @@ function main() {
386
460
  }
387
461
 
388
462
  const pkgChanges = syncPackageJson(cwd, version)
389
- const viteChanges = syncViteConfig(cwd)
463
+ const { changes: viteChanges, configName } = syncViteConfig(cwd)
390
464
  const allChanges = [...pkgChanges, ...viteChanges]
391
465
 
392
466
  if (allChanges.length === 0) {
@@ -398,9 +472,8 @@ function main() {
398
472
  for (const change of allChanges) {
399
473
  console.log(` - ${change}`)
400
474
  }
401
- console.log(
402
- '[sync-vite-plugin-vue-inspector] Run pnpm install if the dependency was added or pinned.',
403
- )
475
+
476
+ installAndCommit(configName)
404
477
  }
405
478
 
406
479
  main()