fg-devkit 1.1.2 → 1.2.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/README.md CHANGED
@@ -45,6 +45,13 @@ pnpm exec fgd typecheck
45
45
  pnpm exec fgd typecheck-watch
46
46
  ```
47
47
 
48
+ To remove redundant tooling dependencies from a consuming repo:
49
+
50
+ ```bash
51
+ pnpm exec fgd prune-consumer-deps
52
+ pnpm install
53
+ ```
54
+
48
55
  ## tsconfig in consuming repos
49
56
 
50
57
  Use `fgd sync-project-configs` (or `fgd sync-tooling-configs`) to write the local `tsconfig.json` template from `fg-devkit`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fg-devkit",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
4
  "description": "Shared configs, scripts, and DX tooling for Vue / TypeScript frontend repos",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -24,6 +24,7 @@
24
24
  "./scripts/sync-vscode-settings.mjs": "./scripts/sync-vscode-settings.mjs",
25
25
  "./scripts/sync-tooling-configs.mjs": "./scripts/sync-tooling-configs.mjs",
26
26
  "./scripts/sync-project-configs.mjs": "./scripts/sync-project-configs.mjs",
27
+ "./scripts/prune-consumer-deps.mjs": "./scripts/prune-consumer-deps.mjs",
27
28
  "./scripts/check-dependency-policy.mjs": "./scripts/check-dependency-policy.mjs",
28
29
  "./scripts/sync-dependency-policy.mjs": "./scripts/sync-dependency-policy.mjs",
29
30
  "./scripts/resolve-dependency-policy-path.mjs": "./scripts/resolve-dependency-policy-path.mjs",
@@ -8,6 +8,7 @@
8
8
  * pnpm exec fg-devkit sync-project-configs (VS Code + tooling sync; overwrites config files)
9
9
  * pnpm exec fg-devkit sync-tooling-configs (tooling sync only; overwrites config files)
10
10
  * pnpm exec fg-devkit sync-vscode-settings
11
+ * pnpm exec fg-devkit prune-consumer-deps [--dry-run]
11
12
  * pnpm exec fg-devkit create-release [patch|minor|major]
12
13
  * pnpm exec fg-devkit commit [cz-args...] (Commitizen; uses fg-devkit bundled cz adapter)
13
14
  * pnpm exec fg-devkit commit-vuln (staged package.json version bumps → vuln() commit)
@@ -219,6 +220,7 @@ const DIRECT_COMMANDS = {
219
220
  'sync-project-configs': 'sync-project-configs.mjs',
220
221
  'sync-tooling-configs': 'sync-tooling-configs.mjs',
221
222
  'sync-vscode-settings': 'sync-vscode-settings.mjs',
223
+ 'prune-consumer-deps': 'prune-consumer-deps.mjs',
222
224
  }
223
225
 
224
226
  function printHelp() {
@@ -231,6 +233,7 @@ Commands:
231
233
  sync-project-configs VS Code + tooling sync (overwrites config files)
232
234
  sync-tooling-configs Tooling sync only (overwrites config files)
233
235
  sync-vscode-settings Copy shared VS Code settings into .vscode/settings.json
236
+ prune-consumer-deps [--dry-run] Remove consumer tooling deps bundled by fg-devkit
234
237
  create-release [bump] Version bump, git push, GitHub release (patch|minor|major; omit = prompt)
235
238
  (alias: createRelease)
236
239
  commit [args...] Commitizen (git-cz) with fg-devkit bundled adapter
@@ -280,6 +283,11 @@ const MENU = [
280
283
  label: 'Commit vulnerability (Commitizen)',
281
284
  run: () => runCommitizen([], { FG_DEVKIT_CZ_DEFAULT_TYPE: 'vuln' }),
282
285
  },
286
+ {
287
+ key: '7',
288
+ label: 'Remove deps unnecessary deps in package.json',
289
+ run: () => runNode('prune-consumer-deps.mjs'),
290
+ },
283
291
  ]
284
292
 
285
293
  async function runInteractiveMenu() {
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Removes tooling dependencies from a consuming repo that are now bundled by fg-devkit.
4
+ *
5
+ * By default this script edits package.json in the current working directory and removes
6
+ * known ESLint/Prettier/TypeScript/Commitizen packages from dependencies/devDependencies.
7
+ *
8
+ * Usage:
9
+ * node node_modules/fg-devkit/scripts/prune-consumer-deps.mjs
10
+ * pnpm exec fg-devkit prune-consumer-deps
11
+ * pnpm exec fg-devkit prune-consumer-deps --dry-run
12
+ */
13
+
14
+ import fs from 'node:fs'
15
+ import path from 'node:path'
16
+
17
+ const BUNDLED_TOOLING_PACKAGES = new Set([
18
+ '@intlify/eslint-plugin-vue-i18n',
19
+ '@typescript-eslint/eslint-plugin',
20
+ '@typescript-eslint/parser',
21
+ '@vitest/eslint-plugin',
22
+ '@vue/eslint-config-prettier',
23
+ '@vue/tsconfig',
24
+ 'commitizen',
25
+ 'eslint',
26
+ 'eslint-plugin-prettier',
27
+ 'eslint-plugin-vue',
28
+ 'prettier',
29
+ 'typescript',
30
+ 'vue-eslint-parser',
31
+ 'vue-tsc',
32
+ ])
33
+
34
+ function readPackageJson(packageJsonPath) {
35
+ if (!fs.existsSync(packageJsonPath)) {
36
+ console.error(`[prune-consumer-deps] No package.json found at ${packageJsonPath}`)
37
+ process.exit(1)
38
+ }
39
+ try {
40
+ return JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
41
+ } catch (err) {
42
+ console.error(`[prune-consumer-deps] Failed to parse package.json: ${err.message}`)
43
+ process.exit(1)
44
+ }
45
+ }
46
+
47
+ function removeFromSection(pkg, sectionName, removed) {
48
+ const section = pkg[sectionName]
49
+ if (!section || typeof section !== 'object') {
50
+ return
51
+ }
52
+ for (const name of Object.keys(section)) {
53
+ if (BUNDLED_TOOLING_PACKAGES.has(name)) {
54
+ removed.push(`${sectionName}.${name}@${section[name]}`)
55
+ delete section[name]
56
+ }
57
+ }
58
+ if (Object.keys(section).length === 0) {
59
+ delete pkg[sectionName]
60
+ }
61
+ }
62
+
63
+ function main() {
64
+ const dryRun = process.argv.includes('--dry-run')
65
+ const projectRoot = process.cwd()
66
+ const packageJsonPath = path.join(projectRoot, 'package.json')
67
+ const pkg = readPackageJson(packageJsonPath)
68
+
69
+ const removed = []
70
+ removeFromSection(pkg, 'dependencies', removed)
71
+ removeFromSection(pkg, 'devDependencies', removed)
72
+
73
+ if (removed.length === 0) {
74
+ console.log('[prune-consumer-deps] No bundled tooling dependencies found to remove.')
75
+ return
76
+ }
77
+
78
+ console.log('[prune-consumer-deps] Removed entries:')
79
+ for (const line of removed) {
80
+ console.log(` - ${line}`)
81
+ }
82
+
83
+ if (dryRun) {
84
+ console.log('\n[prune-consumer-deps] Dry run only; package.json was not modified.')
85
+ return
86
+ }
87
+
88
+ fs.writeFileSync(packageJsonPath, `${JSON.stringify(pkg, null, 2)}\n`, 'utf8')
89
+ console.log('\n[prune-consumer-deps] Updated package.json. Run pnpm install to refresh lockfile.')
90
+ }
91
+
92
+ main()