fg-devkit 1.24.1 → 1.24.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.
package/README.md CHANGED
@@ -98,8 +98,8 @@ pnpm exec fgd setup-ai-rules
98
98
  It enables the `fg-core` and `fg-frontend` plugins in `.claude/settings.json`, adds the `fg` marketplace
99
99
  to Claude Code if it is missing, and installs the plugins once for the user, disabled at user scope. The
100
100
  repo's `.claude/settings.json` then switches them on, so every repo that commits that file gets the rules
101
- and other repos don't. Each developer runs it once on their machine; commit `.claude/settings.json` in
102
- each repo. Needs Claude Code and SSH access to `feelgood/fg-ai-rules`.
101
+ and other repos don't. When `.claude/settings.json` changed it commits that file on its own
102
+ (`chore(repo): enable fg-ai-rules Claude Code plugins`). Each developer runs it once on their machine. Needs Claude Code and SSH access to `feelgood/fg-ai-rules`.
103
103
 
104
104
  Run full consumer setup in one command:
105
105
 
@@ -108,7 +108,7 @@ pnpm exec fgd full-consumer-setup
108
108
  ```
109
109
 
110
110
  It syncs the consumer scripts, Lefthook, configs and dependency policy, runs `pnpm install`, and finishes with
111
- `setup-ai-rules`. Without Claude Code that last step only prints a warning.
111
+ `setup-ai-rules`, which commits `.claude/settings.json`. Without Claude Code that last step only prints a warning.
112
112
 
113
113
  ## Dependency policy update workflow
114
114
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fg-devkit",
3
- "version": "1.24.1",
3
+ "version": "1.24.2",
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.6",
33
33
  "@tanstack/vue-query-devtools": "6.3.3",
34
34
  "@types/node": "22.16.5",
35
- "fg-devkit": "1.24.1",
35
+ "fg-devkit": "1.24.2",
36
36
  "@vitejs/plugin-vue": "6.0.10",
37
37
  "tailwindcss": "4.3.3",
38
38
  "tsx": "4.23.15",
@@ -577,7 +577,7 @@ Commands:
577
577
  sync-vite-plugin-vue-inspector Add/pin vite-plugin-vue-inspector, wire vite.config, install, commit
578
578
  sync-consumer-scripts Enforce standard fgd scripts in consumer package.json
579
579
  setup-lefthook Write lefthook.yml and install the git hooks
580
- setup-ai-rules Enable the fg-ai-rules Claude Code plugins in this repo, install them once per machine
580
+ setup-ai-rules Enable the fg-ai-rules Claude Code plugins in this repo, install them once per machine, commit
581
581
  full-consumer-setup Run: scripts -> lefthook -> step 3 -> step 2 -> pnpm install -> AI rules
582
582
  create-release [release|candidate] [patch|minor|major] [--skip-release-notes]
583
583
  Stable release or candidate (X.Y.Z-rc.N); omit = interactive menu
@@ -1091,14 +1091,14 @@ async function runInteractiveMenu() {
1091
1091
  description: 'Write lefthook.yml and install the git hooks',
1092
1092
  },
1093
1093
  {
1094
- name: 'AI rules',
1094
+ name: autoCommit('AI rules'),
1095
1095
  value: 'ai-rules',
1096
- description: 'Enable the fg-ai-rules plugins in .claude/settings.json and install them for Claude Code',
1096
+ description: 'Enable the fg-ai-rules plugins in .claude/settings.json, install them for Claude Code and commit the file',
1097
1097
  },
1098
1098
  {
1099
1099
  name: 'Full setup',
1100
1100
  value: 'full-consumer-setup',
1101
- description: 'Sync scripts, Lefthook, configs and dependency policy, pnpm install, then set up AI rules',
1101
+ description: 'Sync scripts, Lefthook, configs and dependency policy, pnpm install, then set up AI rules (commits .claude/settings.json)',
1102
1102
  },
1103
1103
  { name: 'Cancel', value: 'cancel' },
1104
1104
  ],
@@ -10,6 +10,8 @@
10
10
  * project-scope install only covers one repo. A user-scope install covers every repo, and
11
11
  * disabling it at user scope leaves the repo's .claude/settings.json to switch it on.
12
12
  *
13
+ * 4. Commit .claude/settings.json when it changed (only that file).
14
+ *
13
15
  * Safe to run again: it only changes what is missing. Once a developer has run it in any repo,
14
16
  * every other repo that commits the same .claude/settings.json works without running it again.
15
17
  *
@@ -21,13 +23,18 @@ import { spawnSync } from 'node:child_process'
21
23
  import fs from 'node:fs'
22
24
  import path from 'node:path'
23
25
 
26
+ import { fileDiffersFromHead, runGit } from './lib/common.mjs'
27
+
24
28
  const TAG = '[setup-ai-rules]'
25
29
  const MARKETPLACE = 'fg'
26
30
  const MARKETPLACE_REPO = 'feelgood/fg-ai-rules'
27
31
  const PLUGINS = ['fg-core', 'fg-frontend']
28
32
 
29
33
  const projectRoot = fs.realpathSync(process.cwd())
30
- const settingsPath = path.join(projectRoot, '.claude', 'settings.json')
34
+ const SETTINGS_FILE = '.claude/settings.json'
35
+ const COMMIT_MESSAGE = 'chore(repo): enable fg-ai-rules Claude Code plugins'
36
+ const settingsPath = path.join(projectRoot, SETTINGS_FILE)
37
+ const GIT = { cwd: projectRoot, tag: TAG }
31
38
 
32
39
  function claude(args, { capture = false } = {}) {
33
40
  const result = spawnSync('claude', args, {
@@ -85,6 +92,20 @@ function updateSettings() {
85
92
  return true
86
93
  }
87
94
 
95
+ /** Commit .claude/settings.json on its own when it differs from HEAD. */
96
+ function commitSettings() {
97
+ if (runGit(['rev-parse', '--is-inside-work-tree'], { ...GIT, capture: true }).status !== 0) {
98
+ console.log(`${TAG} Not a git repository; commit ${SETTINGS_FILE} yourself.`)
99
+ return 0
100
+ }
101
+ if (!fileDiffersFromHead(SETTINGS_FILE, GIT)) return 0
102
+ const status =
103
+ runGit(['add', '--', SETTINGS_FILE], GIT).status ||
104
+ runGit(['commit', '-m', COMMIT_MESSAGE, '--', SETTINGS_FILE], GIT).status
105
+ if (status !== 0) console.error(`${TAG} Could not commit ${SETTINGS_FILE}.`)
106
+ return status
107
+ }
108
+
88
109
  function printManualSteps() {
89
110
  console.log(`${TAG} Run these from the repo root, then restart Claude Code:`)
90
111
  console.log(` claude plugin marketplace add ${MARKETPLACE_REPO}`)
@@ -144,8 +165,8 @@ function main() {
144
165
  return 1
145
166
  }
146
167
 
168
+ if (commitSettings() !== 0) return 1
147
169
  console.log(`${TAG} Done. Restart Claude Code to load the rules.`)
148
- if (settingsChanged) console.log(`${TAG} Commit .claude/settings.json so other repos and teammates get the same plugins.`)
149
170
  return 0
150
171
  }
151
172