fg-devkit 1.21.5 → 1.23.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.
Files changed (70) hide show
  1. package/README.md +16 -7
  2. package/configs/dependency-policy.vue-workspace.json +27 -27
  3. package/configs/eslint.config.base.d.ts +1 -0
  4. package/configs/eslint.config.base.js +3 -0
  5. package/configs/eslint.sync-stub.js +1 -0
  6. package/package.json +11 -81
  7. package/scaffold/vue/package.json +12 -12
  8. package/scripts/audit-override-commit.mjs +167 -24
  9. package/scripts/bump-node-toolchain.mjs +8 -31
  10. package/scripts/bump-pnpm-toolchain.mjs +8 -29
  11. package/scripts/check-dependency-policy.mjs +10 -35
  12. package/scripts/fg-devkit.mjs +274 -331
  13. package/scripts/fleet-bump-fg-devkit.mjs +4 -5
  14. package/scripts/fleet-git-commit-push-scoped.mjs +6 -26
  15. package/scripts/fleet-git-discard-scoped.mjs +5 -25
  16. package/scripts/fleet-git-pull-scoped.mjs +5 -25
  17. package/scripts/fleet-vulns.mjs +4 -9
  18. package/scripts/generate-release-notes.mjs +1 -1
  19. package/scripts/{audit-fix-plan.mjs → lib/audit-fix-plan.mjs} +77 -4
  20. package/scripts/{audit-fix-plan.test.mjs → lib/audit-fix-plan.test.mjs} +50 -2
  21. package/scripts/lib/common.mjs +95 -0
  22. package/scripts/{dependency-policy-toolchain.mjs → lib/dependency-policy-toolchain.mjs} +3 -35
  23. package/scripts/{git-commit-push-fleet-common.mjs → lib/git-commit-push-fleet-common.mjs} +1 -1
  24. package/scripts/{git-discard-fleet-common.mjs → lib/git-discard-fleet-common.mjs} +1 -1
  25. package/scripts/{git-pull-fleet-common.mjs → lib/git-pull-fleet-common.mjs} +1 -1
  26. package/scripts/{override-changes.mjs → lib/override-changes.mjs} +20 -0
  27. package/scripts/{piwik-dimensions.test.mjs → lib/piwik-dimensions.test.mjs} +0 -5
  28. package/scripts/{release-notes-common.mjs → lib/release-notes-common.mjs} +5 -7
  29. package/scripts/{resolve-dependency-policy-path.mjs → lib/resolve-dependency-policy-path.mjs} +4 -3
  30. package/scripts/piwik.mjs +6 -6
  31. package/scripts/poeditor-download.mjs +1 -1
  32. package/scripts/poeditor-upload.mjs +1 -1
  33. package/scripts/policy-outdated.mjs +3 -8
  34. package/scripts/policy-upgrade-commit.mjs +5 -26
  35. package/scripts/policy-upgrade.mjs +6 -30
  36. package/scripts/policy-vulns.mjs +3 -8
  37. package/scripts/prune-overrides.mjs +5 -16
  38. package/scripts/prune-release-age-exclude.mjs +1 -1
  39. package/scripts/refresh-dependency-policy-from-repos.mjs +5 -7
  40. package/scripts/release.sh +2 -1
  41. package/scripts/scaffold-vue.mjs +1 -3
  42. package/scripts/sync-consumer-lefthook.mjs +7 -24
  43. package/scripts/sync-core-coding-standards.mjs +2 -17
  44. package/scripts/sync-dependency-check-suppressions-commit.mjs +7 -46
  45. package/scripts/sync-dependency-policy-commit.mjs +6 -38
  46. package/scripts/sync-dependency-policy.mjs +9 -35
  47. package/scripts/sync-node-toolchain.mjs +5 -7
  48. package/scripts/sync-pnpm-toolchain.mjs +5 -7
  49. package/scripts/sync-scaffold-vue-deps.mjs +6 -7
  50. package/scripts/sync-tooling-configs.mjs +8 -23
  51. package/scripts/sync-vite-plugin-vue-inspector.mjs +7 -39
  52. package/scripts/verify-release-notes.mjs +1 -1
  53. package/scaffold/vue/.gitignore +0 -13
  54. package/scripts/cz/.cz-config.cjs +0 -29
  55. package/scripts/fleet-git-commit-push.mjs +0 -75
  56. package/scripts/fleet-git-discard.mjs +0 -66
  57. package/scripts/fleet-git-pull.mjs +0 -65
  58. package/scripts/sync-peers-from-dev.mjs +0 -31
  59. package/scripts/vuln-commit.mjs +0 -142
  60. /package/configs/{fallowrc.sync-stub.json → fallowrc.json} +0 -0
  61. /package/scripts/{dependency-policy-pins.mjs → lib/dependency-policy-pins.mjs} +0 -0
  62. /package/scripts/{fleet-project-repos.mjs → lib/fleet-project-repos.mjs} +0 -0
  63. /package/scripts/{fleet-repo-picker.mjs → lib/fleet-repo-picker.mjs} +0 -0
  64. /package/scripts/{fleet-vue-repos.mjs → lib/fleet-vue-repos.mjs} +0 -0
  65. /package/scripts/{git-fleet-common.mjs → lib/git-fleet-common.mjs} +0 -0
  66. /package/scripts/{node-toolchain-sync.mjs → lib/node-toolchain-sync.mjs} +0 -0
  67. /package/scripts/{piwik-common.mjs → lib/piwik-common.mjs} +0 -0
  68. /package/scripts/{piwik-dimensions.mjs → lib/piwik-dimensions.mjs} +0 -0
  69. /package/scripts/{pnpm-toolchain-sync.mjs → lib/pnpm-toolchain-sync.mjs} +0 -0
  70. /package/scripts/{poeditor-common.mjs → lib/poeditor-common.mjs} +0 -0
@@ -6,12 +6,13 @@
6
6
  * pnpm exec fg-devkit sync-deps-commit [policy-file]
7
7
  */
8
8
 
9
- import fs from 'node:fs'
10
9
  import path from 'node:path'
11
10
  import { fileURLToPath } from 'node:url'
12
11
  import { spawnSync } from 'node:child_process'
12
+ import { fileDiffersFromHead, runGit, stageExistingFiles } from './lib/common.mjs'
13
13
 
14
14
  const cwd = process.cwd()
15
+ const GIT = { cwd, tag: '[sync-deps-commit]' }
15
16
  const scriptDir = path.dirname(fileURLToPath(import.meta.url))
16
17
  const syncScriptPath = path.join(scriptDir, 'sync-dependency-policy.mjs')
17
18
  const commitMessage = 'chore(repo): sync dependency policy'
@@ -44,22 +45,8 @@ function runPnpm(args) {
44
45
  return result.status ?? 1
45
46
  }
46
47
 
47
- function runGit(args, options = {}) {
48
- const result = spawnSync('git', args, {
49
- stdio: options.capture ? 'pipe' : 'inherit',
50
- encoding: options.capture ? 'utf8' : undefined,
51
- cwd,
52
- env: process.env,
53
- })
54
- if (result.error) {
55
- console.error('[sync-deps-commit]', result.error.message)
56
- return { status: 1, stdout: '' }
57
- }
58
- return { status: result.status ?? 1, stdout: result.stdout ?? '' }
59
- }
60
-
61
48
  function listTrackedFiles() {
62
- const result = runGit(['ls-files', '-z'], { capture: true })
49
+ const result = runGit(['ls-files', '-z'], { ...GIT, capture: true })
63
50
  if (result.status !== 0) return []
64
51
  return result.stdout.split('\0').filter(Boolean)
65
52
  }
@@ -84,25 +71,6 @@ function isSyncRelatedPath(filePath) {
84
71
  return base.endsWith('.sh')
85
72
  }
86
73
 
87
- function fileDiffersFromHead(filePath) {
88
- const absolutePath = path.join(cwd, filePath)
89
- if (!fs.existsSync(absolutePath)) return false
90
-
91
- const tracked = runGit(['ls-files', '--error-unmatch', '--', filePath], { capture: true })
92
- if (tracked.status !== 0) {
93
- return true
94
- }
95
-
96
- const diff = runGit(['diff', '--quiet', 'HEAD', '--', filePath], { capture: true })
97
- return diff.status !== 0
98
- }
99
-
100
- function stageExistingFiles(files) {
101
- const existingFiles = files.filter((filePath) => fs.existsSync(path.join(cwd, filePath)))
102
- if (existingFiles.length === 0) return 0
103
- return runGit(['add', '--', ...existingFiles]).status
104
- }
105
-
106
74
  function main() {
107
75
  const syncResult = runSync(process.argv.slice(2))
108
76
  if (syncResult.status !== 0) {
@@ -135,20 +103,20 @@ function main() {
135
103
  }
136
104
  }
137
105
 
138
- const filesToStage = [...candidateFiles].filter((filePath) => fileDiffersFromHead(filePath))
106
+ const filesToStage = [...candidateFiles].filter((filePath) => fileDiffersFromHead(filePath, GIT))
139
107
  if (filesToStage.length === 0) {
140
108
  console.log('[sync-deps-commit] No sync-related changes to commit.')
141
109
  process.exit(0)
142
110
  }
143
111
 
144
- const stageExitCode = stageExistingFiles(filesToStage)
112
+ const stageExitCode = stageExistingFiles(filesToStage, GIT)
145
113
  if (stageExitCode !== 0) {
146
114
  process.exit(stageExitCode)
147
115
  }
148
116
 
149
117
  console.log(`[sync-deps-commit] Staged ${filesToStage.length} file(s)`)
150
118
  console.log(`[sync-deps-commit] Auto-committing: ${commitMessage}`)
151
- process.exit(runGit(['commit', '-m', commitMessage]).status)
119
+ process.exit(runGit(['commit', '-m', commitMessage], GIT).status)
152
120
  }
153
121
 
154
122
  main()
@@ -13,24 +13,23 @@
13
13
 
14
14
  import fs from 'node:fs'
15
15
  import path from 'node:path'
16
- import { fileURLToPath } from 'node:url'
17
16
 
18
- import { collectPinViolations } from './dependency-policy-pins.mjs'
17
+ import { collectPinViolations } from './lib/dependency-policy-pins.mjs'
19
18
  import {
20
19
  collectNodeToolchainPolicyViolations,
21
20
  collectToolchainPolicyViolations,
22
21
  resolveExpectedPackageManager,
23
- } from './dependency-policy-toolchain.mjs'
24
- import { syncNodeToolchainInRepo } from './node-toolchain-sync.mjs'
25
- import { syncPnpmToolchainInRepo } from './pnpm-toolchain-sync.mjs'
26
- import { resolveDependencyPolicyPath } from './resolve-dependency-policy-path.mjs'
22
+ } from './lib/dependency-policy-toolchain.mjs'
23
+ import { syncNodeToolchainInRepo } from './lib/node-toolchain-sync.mjs'
24
+ import { syncPnpmToolchainInRepo } from './lib/pnpm-toolchain-sync.mjs'
25
+ import { resolveDependencyPolicyPath } from './lib/resolve-dependency-policy-path.mjs'
26
+ import { getRelevantPolicyOverrides } from './lib/override-changes.mjs'
27
+ import { fgDevkitRoot } from './lib/common.mjs'
27
28
 
28
29
  const cwd = process.cwd()
29
30
  const pkgPath = path.resolve(cwd, 'package.json')
30
31
  const lockfilePath = path.resolve(cwd, 'pnpm-lock.yaml')
31
- const scriptDir = path.dirname(fileURLToPath(import.meta.url))
32
- const fgDevkitRoot = path.resolve(scriptDir, '..')
33
- const policyPath = resolveDependencyPolicyPath(scriptDir, cwd, process.argv)
32
+ const policyPath = resolveDependencyPolicyPath(cwd, process.argv)
34
33
 
35
34
  if (!fs.existsSync(pkgPath)) {
36
35
  console.error('[sync-deps] Could not find package.json in current working directory')
@@ -67,31 +66,6 @@ if (policyErrors.length > 0) {
67
66
  const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
68
67
  const changes = []
69
68
 
70
- function getOverridePackageName(overrideKey) {
71
- const match = overrideKey.match(/^(@[^/]+\/[^@]+|[^@]+)@/)
72
- return match ? match[1] : overrideKey
73
- }
74
-
75
- function getRelevantPolicyOverrides(policyOverrides) {
76
- const entries = Object.entries(policyOverrides ?? {})
77
- if (entries.length === 0) {
78
- return {}
79
- }
80
- if (!fs.existsSync(lockfilePath)) {
81
- return Object.fromEntries(entries)
82
- }
83
- const lockfile = fs.readFileSync(lockfilePath, 'utf8')
84
- const relevant = {}
85
- for (const [name, version] of entries) {
86
- const pkgName = getOverridePackageName(name)
87
- // Conservative: only apply overrides for packages present in lockfile.
88
- if (lockfile.includes(`${pkgName}@`) || lockfile.includes(`/${pkgName}/`)) {
89
- relevant[name] = version
90
- }
91
- }
92
- return relevant
93
- }
94
-
95
69
  // Bump versions for managed dependencies / devDependencies where the key already exists.
96
70
  for (const [section, dependencies] of Object.entries(policy.managedDependencies ?? {})) {
97
71
  pkg[section] ||= {}
@@ -136,7 +110,7 @@ for (const [name, version] of Object.entries(policy.managedAnywhere ?? {})) {
136
110
  }
137
111
 
138
112
  // Apply policy-defined override versions when present in the policy.
139
- const relevantOverrides = getRelevantPolicyOverrides(policy.overrides ?? {})
113
+ const relevantOverrides = getRelevantPolicyOverrides(policy.overrides, lockfilePath)
140
114
  for (const [name, version] of Object.entries(relevantOverrides)) {
141
115
  if (pkg.pnpm?.overrides?.[name] === version) {
142
116
  continue
@@ -14,21 +14,19 @@
14
14
 
15
15
  import fs from 'node:fs'
16
16
  import path from 'node:path'
17
- import { fileURLToPath } from 'node:url'
18
17
 
19
18
  import {
20
19
  collectNodeToolchainPolicyViolations,
21
20
  resolveExpectedNodePolicy,
22
- } from './dependency-policy-toolchain.mjs'
23
- import { syncNodeToolchainInRepo } from './node-toolchain-sync.mjs'
24
- import { resolveDependencyPolicyPath } from './resolve-dependency-policy-path.mjs'
21
+ } from './lib/dependency-policy-toolchain.mjs'
22
+ import { syncNodeToolchainInRepo } from './lib/node-toolchain-sync.mjs'
23
+ import { resolveDependencyPolicyPath } from './lib/resolve-dependency-policy-path.mjs'
24
+ import { fgDevkitRoot } from './lib/common.mjs'
25
25
 
26
26
  const cwd = process.cwd()
27
- const scriptDir = path.dirname(fileURLToPath(import.meta.url))
28
- const fgDevkitRoot = path.resolve(scriptDir, '..')
29
27
  const cliArgs = process.argv.slice(2).filter((a) => a !== '--dry-run')
30
28
  const dryRun = process.argv.includes('--dry-run')
31
- const policyPath = resolveDependencyPolicyPath(scriptDir, cwd, ['node', 'sync-node-toolchain.mjs', ...cliArgs])
29
+ const policyPath = resolveDependencyPolicyPath(cwd, ['node', 'sync-node-toolchain.mjs', ...cliArgs])
32
30
 
33
31
  if (!fs.existsSync(policyPath)) {
34
32
  console.error(`[sync-node-toolchain] Could not find dependency policy: ${policyPath}`)
@@ -8,21 +8,19 @@
8
8
 
9
9
  import fs from 'node:fs'
10
10
  import path from 'node:path'
11
- import { fileURLToPath } from 'node:url'
12
11
 
13
12
  import {
14
13
  collectToolchainPolicyViolations,
15
14
  resolveExpectedPackageManager,
16
- } from './dependency-policy-toolchain.mjs'
17
- import { syncPnpmToolchainInRepo } from './pnpm-toolchain-sync.mjs'
18
- import { resolveDependencyPolicyPath } from './resolve-dependency-policy-path.mjs'
15
+ } from './lib/dependency-policy-toolchain.mjs'
16
+ import { syncPnpmToolchainInRepo } from './lib/pnpm-toolchain-sync.mjs'
17
+ import { resolveDependencyPolicyPath } from './lib/resolve-dependency-policy-path.mjs'
18
+ import { fgDevkitRoot } from './lib/common.mjs'
19
19
 
20
20
  const cwd = process.cwd()
21
- const scriptDir = path.dirname(fileURLToPath(import.meta.url))
22
- const fgDevkitRoot = path.resolve(scriptDir, '..')
23
21
  const cliArgs = process.argv.slice(2).filter((a) => a !== '--dry-run')
24
22
  const dryRun = process.argv.includes('--dry-run')
25
- const policyPath = resolveDependencyPolicyPath(scriptDir, cwd, ['node', 'sync-pnpm-toolchain.mjs', ...cliArgs])
23
+ const policyPath = resolveDependencyPolicyPath(cwd, ['node', 'sync-pnpm-toolchain.mjs', ...cliArgs])
26
24
 
27
25
  if (!fs.existsSync(policyPath)) {
28
26
  console.error(`[sync-pnpm-toolchain] Could not find dependency policy: ${policyPath}`)
@@ -12,15 +12,16 @@ import fs from 'node:fs'
12
12
  import path from 'node:path'
13
13
  import { fileURLToPath } from 'node:url'
14
14
 
15
- import { resolveDependencyPolicyPath } from './resolve-dependency-policy-path.mjs'
15
+ import { resolveDependencyPolicyPath } from './lib/resolve-dependency-policy-path.mjs'
16
16
  import {
17
17
  extractPnpmVersion,
18
18
  resolveExpectedNodePolicy,
19
19
  resolveExpectedPackageManager,
20
20
  syncPolicyToolchainFromFgDevkit,
21
- } from './dependency-policy-toolchain.mjs'
22
- import { syncDockerfileNodeImages } from './node-toolchain-sync.mjs'
23
- import { syncDockerfilePnpmVersion } from './pnpm-toolchain-sync.mjs'
21
+ } from './lib/dependency-policy-toolchain.mjs'
22
+ import { syncDockerfileNodeImages } from './lib/node-toolchain-sync.mjs'
23
+ import { syncDockerfilePnpmVersion } from './lib/pnpm-toolchain-sync.mjs'
24
+ import { fgDevkitRoot } from './lib/common.mjs'
24
25
 
25
26
  /**
26
27
  * @param {{ fgDevkitRoot: string, policyPath: string }} options
@@ -97,12 +98,10 @@ export function syncScaffoldVueDepsFromPolicy(options) {
97
98
  console.log('[sync-scaffold-vue-deps] Updated', scaffoldPkgPath)
98
99
  }
99
100
 
100
- const scriptDir = path.dirname(fileURLToPath(import.meta.url))
101
- const fgDevkitRoot = path.resolve(scriptDir, '..')
102
101
  const invokedPath = path.resolve(process.argv[1] ?? '')
103
102
  const selfPath = path.resolve(fileURLToPath(import.meta.url))
104
103
 
105
104
  if (invokedPath === selfPath) {
106
- const policyPath = resolveDependencyPolicyPath(scriptDir, process.cwd(), process.argv)
105
+ const policyPath = resolveDependencyPolicyPath(process.cwd(), process.argv)
107
106
  syncScaffoldVueDepsFromPolicy({ fgDevkitRoot, policyPath })
108
107
  }
@@ -4,7 +4,9 @@
4
4
  * - prettier.config.js — overwritten from fg-devkit prettier sync template
5
5
  * - eslint.config.js — overwritten from fg-devkit eslint sync template
6
6
  * - tsconfig.json — overwritten from fg-devkit tsconfig app sync template
7
- * - .fallowrc.json — overwritten from fg-devkit fallow sync template
7
+ *
8
+ * .fallowrc.json is not copied: `fgd dead-code` / `fgd fallow` use fg-devkit's config unless
9
+ * the repo has its own.
8
10
  *
9
11
  * This command is intentionally deterministic: each run rewrites files to the shared templates.
10
12
  *
@@ -17,26 +19,11 @@
17
19
 
18
20
  import fs from 'node:fs'
19
21
  import path from 'node:path'
20
- import { fileURLToPath } from 'node:url'
22
+ import { findFgDevkitPackageRoot } from './lib/common.mjs'
21
23
 
22
24
  const projectRoot = process.cwd()
23
- const scriptDir = path.dirname(fileURLToPath(import.meta.url))
24
-
25
- function findFgDevkitPackageRoot() {
26
- const candidates = [
27
- path.resolve(scriptDir, '..'),
28
- path.join(projectRoot, 'node_modules', 'fg-devkit'),
29
- path.join(projectRoot, 'node_modules', 'fds-vue-core', 'node_modules', 'fg-devkit'),
30
- ]
31
- for (const p of candidates) {
32
- if (fs.existsSync(path.join(p, 'package.json'))) {
33
- return p
34
- }
35
- }
36
- return null
37
- }
38
25
 
39
- const fgRoot = findFgDevkitPackageRoot()
26
+ const fgRoot = findFgDevkitPackageRoot(projectRoot)
40
27
  if (!fgRoot) {
41
28
  console.error(
42
29
  '[sync-tooling] Could not find fg-devkit (install fg-devkit or a package that bundles it, e.g. fds-vue-core).',
@@ -47,11 +34,10 @@ if (!fgRoot) {
47
34
  const prettierSrc = path.join(fgRoot, 'configs', 'prettier.sync-stub.js')
48
35
  const eslintStubSrc = path.join(fgRoot, 'configs', 'eslint.sync-stub.js')
49
36
  const tsconfigSrc = path.join(fgRoot, 'configs', 'tsconfig.app.sync.json')
50
- const fallowConfigSrc = path.join(fgRoot, 'configs', 'fallowrc.sync-stub.json')
51
37
 
52
- if (!fs.existsSync(prettierSrc) || !fs.existsSync(eslintStubSrc) || !fs.existsSync(tsconfigSrc) || !fs.existsSync(fallowConfigSrc)) {
38
+ if (!fs.existsSync(prettierSrc) || !fs.existsSync(eslintStubSrc) || !fs.existsSync(tsconfigSrc)) {
53
39
  console.error(
54
- '[sync-tooling] Missing prettier.sync-stub.js, eslint.sync-stub.js, tsconfig.app.sync.json, or fallowrc.sync-stub.json inside fg-devkit package.',
40
+ '[sync-tooling] Missing prettier.sync-stub.js, eslint.sync-stub.js, or tsconfig.app.sync.json inside fg-devkit package.',
55
41
  )
56
42
  process.exit(1)
57
43
  }
@@ -60,8 +46,7 @@ try {
60
46
  fs.copyFileSync(prettierSrc, path.join(projectRoot, 'prettier.config.js'))
61
47
  fs.copyFileSync(eslintStubSrc, path.join(projectRoot, 'eslint.config.js'))
62
48
  fs.copyFileSync(tsconfigSrc, path.join(projectRoot, 'tsconfig.json'))
63
- fs.copyFileSync(fallowConfigSrc, path.join(projectRoot, '.fallowrc.json'))
64
- console.log('[sync-tooling] Updated prettier.config.js, eslint.config.js, tsconfig.json, and .fallowrc.json.')
49
+ console.log('[sync-tooling] Updated prettier.config.js, eslint.config.js, and tsconfig.json.')
65
50
  } catch (err) {
66
51
  console.error(`[sync-tooling] ${err.message}`)
67
52
  process.exit(1)
@@ -16,10 +16,10 @@
16
16
 
17
17
  import fs from 'node:fs'
18
18
  import path from 'node:path'
19
- import { fileURLToPath } from 'node:url'
20
19
  import { spawnSync } from 'node:child_process'
21
20
 
22
- import { resolveDependencyPolicyPath } from './resolve-dependency-policy-path.mjs'
21
+ import { resolveDependencyPolicyPath } from './lib/resolve-dependency-policy-path.mjs'
22
+ import { fileDiffersFromHead, runGit, stageExistingFiles } from './lib/common.mjs'
23
23
 
24
24
  const PACKAGE_NAME = 'vite-plugin-vue-inspector'
25
25
  const IMPORT_LINE = `import Inspector from '${PACKAGE_NAME}'`
@@ -36,9 +36,9 @@ const VITE_CONFIG_CANDIDATES = [
36
36
  'vite.config.mjs',
37
37
  ]
38
38
 
39
- const scriptDir = path.dirname(fileURLToPath(import.meta.url))
40
39
  const cwd = process.cwd()
41
- const policyPath = resolveDependencyPolicyPath(scriptDir, cwd, process.argv)
40
+ const GIT = { cwd, tag: '[sync-vite-plugin-vue-inspector]' }
41
+ const policyPath = resolveDependencyPolicyPath(cwd, process.argv)
42
42
 
43
43
  function fail(message) {
44
44
  console.error(`[sync-vite-plugin-vue-inspector] ${message}`)
@@ -57,38 +57,6 @@ function runPnpm(args) {
57
57
  return result.status ?? 1
58
58
  }
59
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
-
92
60
  function resolvePluginVersion(policy) {
93
61
  return (
94
62
  policy.managedDependencies?.devDependencies?.[PACKAGE_NAME] ??
@@ -427,20 +395,20 @@ function installAndCommit(viteConfigName) {
427
395
  }
428
396
 
429
397
  const candidateFiles = ['package.json', 'pnpm-lock.yaml', viteConfigName].filter(Boolean)
430
- const filesToStage = candidateFiles.filter((filePath) => fileDiffersFromHead(filePath))
398
+ const filesToStage = candidateFiles.filter((filePath) => fileDiffersFromHead(filePath, GIT))
431
399
  if (filesToStage.length === 0) {
432
400
  console.log('[sync-vite-plugin-vue-inspector] No related changes to commit.')
433
401
  return
434
402
  }
435
403
 
436
- const stageExitCode = stageExistingFiles(filesToStage)
404
+ const stageExitCode = stageExistingFiles(filesToStage, GIT)
437
405
  if (stageExitCode !== 0) {
438
406
  process.exit(stageExitCode)
439
407
  }
440
408
 
441
409
  console.log(`[sync-vite-plugin-vue-inspector] Staged ${filesToStage.length} file(s)`)
442
410
  console.log(`[sync-vite-plugin-vue-inspector] Auto-committing: ${COMMIT_MESSAGE}`)
443
- const commitExitCode = runGit(['commit', '-m', COMMIT_MESSAGE]).status
411
+ const commitExitCode = runGit(['commit', '-m', COMMIT_MESSAGE], GIT).status
444
412
  if (commitExitCode !== 0) {
445
413
  process.exit(commitExitCode)
446
414
  }
@@ -18,7 +18,7 @@ import {
18
18
  hasReleaseNotesConfig,
19
19
  readPreviewFiles,
20
20
  runSyncUserChangelog,
21
- } from './release-notes-common.mjs'
21
+ } from './lib/release-notes-common.mjs'
22
22
 
23
23
  const scriptDir = path.dirname(fileURLToPath(import.meta.url))
24
24
  const cwd = process.cwd()
@@ -1,13 +0,0 @@
1
- .DS_Store
2
- node_modules
3
- /dist
4
- pnpm-debug.log*
5
-
6
- .env.local
7
- .env.*.local
8
- *env.local
9
-
10
- .idea
11
- *.sw?
12
-
13
- tsconfig.tsbuildinfo
@@ -1,29 +0,0 @@
1
- /**
2
- * cz-git config used by fg-devkit commit flows.
3
- * Keep this in czrc-compatible shape for `czg --config`.
4
- */
5
- module.exports = {
6
- types: [
7
- { value: 'feat', name: 'feat(scope): Added' },
8
- { value: 'fix', name: 'fix(scope): Fixed' },
9
- { value: 'perf', name: 'perf(scope): Performance' },
10
- { value: 'refactor', name: 'refactor(scope): Changed' },
11
- { value: 'chore', name: 'chore(scope): Changed' },
12
- { value: 'dep', name: 'dep(scope): Dependencies (single package or batch)' },
13
- { value: 'vuln', name: 'vuln(scope): Security dependency update (single package or batch)' },
14
- { value: 'fix(security)', name: 'fix(security): Security' },
15
- ],
16
- allowCustomScopes: true,
17
- allowEmptyScopes: false,
18
- allowBreakingChanges: [],
19
- skipQuestions: ['breaking', 'footer', 'issues', 'issuePrefixes'],
20
- maxSubjectLength: 120,
21
- breaklineChar: '|',
22
- useEmoji: false,
23
- messages: {
24
- type: 'Select the type of change you are committing:',
25
- customScope: 'Packages (for dep/vuln) or scope:',
26
- subject: 'Commit subject (imperative, no trailing period):',
27
- body: "Optional body (use '|' for newline):",
28
- },
29
- }
@@ -1,75 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Maintainer: stage all changes, commit, and push on the current branch for every git repo under projects root.
4
- *
5
- * Usage (from fg-devkit repository root):
6
- * pnpm exec fg-devkit fleet-git-commit-push --message="chore: sync toolchain" [projects-root] [--dry-run]
7
- * pnpm exec fg-devkit fleet-git-commit-push -m "chore: sync toolchain"
8
- */
9
-
10
- import fs from 'node:fs'
11
- import path from 'node:path'
12
- import { fileURLToPath } from 'node:url'
13
-
14
- import { collectFleetGitRepos } from './fleet-project-repos.mjs'
15
- import { filterCommitPushPositionalArgs, resolveCommitMessage } from './git-fleet-common.mjs'
16
- import { runFleetGitCommitPush } from './git-commit-push-fleet-common.mjs'
17
-
18
- const scriptDir = path.dirname(fileURLToPath(import.meta.url))
19
- const fgDevkitRoot = path.resolve(scriptDir, '..')
20
- const fgDevkitPkgPath = path.join(fgDevkitRoot, 'package.json')
21
- const LOG_PREFIX = '[fleet-git-commit-push]'
22
-
23
- const cliArgs = process.argv.slice(2)
24
- const dryRun = cliArgs.includes('--dry-run')
25
- const positionalArgs = filterCommitPushPositionalArgs(cliArgs)
26
- const projectsRootArg = positionalArgs.find((a) => !a.startsWith('-'))
27
- const projectsRoot = projectsRootArg
28
- ? path.resolve(process.cwd(), projectsRootArg)
29
- : path.resolve(fgDevkitRoot, '..')
30
-
31
- function assertFgDevkitMaintainerContext() {
32
- if (path.resolve(process.cwd()) !== fgDevkitRoot) {
33
- console.error(`${LOG_PREFIX} Run from the fg-devkit repository root.`)
34
- process.exit(1)
35
- }
36
- try {
37
- const pkg = JSON.parse(fs.readFileSync(fgDevkitPkgPath, 'utf8'))
38
- if (pkg?.name !== 'fg-devkit') {
39
- console.error(`${LOG_PREFIX} package.json name must be fg-devkit.`)
40
- process.exit(1)
41
- }
42
- } catch {
43
- console.error(`${LOG_PREFIX} Could not read fg-devkit package.json.`)
44
- process.exit(1)
45
- }
46
- }
47
-
48
- async function main() {
49
- assertFgDevkitMaintainerContext()
50
-
51
- if (!fs.existsSync(projectsRoot)) {
52
- console.error(`${LOG_PREFIX} projects root not found: ${projectsRoot}`)
53
- process.exit(1)
54
- }
55
-
56
- const commitMessage = await resolveCommitMessage(cliArgs, LOG_PREFIX)
57
- const repos = collectFleetGitRepos(projectsRoot)
58
-
59
- console.log(`${LOG_PREFIX} projectsRoot=${projectsRoot}`)
60
- console.log(`${LOG_PREFIX} repositories=${repos.length}`)
61
-
62
- const exitCode = runFleetGitCommitPush({
63
- repos,
64
- projectsRoot,
65
- commitMessage,
66
- dryRun,
67
- logPrefix: LOG_PREFIX,
68
- })
69
- process.exit(exitCode)
70
- }
71
-
72
- main().catch((err) => {
73
- console.error(LOG_PREFIX, err)
74
- process.exit(1)
75
- })
@@ -1,66 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Maintainer: discard tracked git changes in every repository under projects root.
4
- *
5
- * Usage (from fg-devkit repository root):
6
- * pnpm exec fg-devkit fleet-git-discard [projects-root] [--dry-run]
7
- */
8
-
9
- import fs from 'node:fs'
10
- import path from 'node:path'
11
- import { fileURLToPath } from 'node:url'
12
-
13
- import { collectFleetGitRepos } from './fleet-project-repos.mjs'
14
- import { runFleetGitDiscard } from './git-discard-fleet-common.mjs'
15
-
16
- const scriptDir = path.dirname(fileURLToPath(import.meta.url))
17
- const fgDevkitRoot = path.resolve(scriptDir, '..')
18
- const fgDevkitPkgPath = path.join(fgDevkitRoot, 'package.json')
19
- const LOG_PREFIX = '[fleet-git-discard]'
20
-
21
- const cliArgs = process.argv.slice(2)
22
- const dryRun = cliArgs.includes('--dry-run')
23
- const projectsRootArg = cliArgs.find((a) => !a.startsWith('-'))
24
- const projectsRoot = projectsRootArg
25
- ? path.resolve(process.cwd(), projectsRootArg)
26
- : path.resolve(fgDevkitRoot, '..')
27
-
28
- function assertFgDevkitMaintainerContext() {
29
- if (path.resolve(process.cwd()) !== fgDevkitRoot) {
30
- console.error(`${LOG_PREFIX} Run from the fg-devkit repository root.`)
31
- process.exit(1)
32
- }
33
- try {
34
- const pkg = JSON.parse(fs.readFileSync(fgDevkitPkgPath, 'utf8'))
35
- if (pkg?.name !== 'fg-devkit') {
36
- console.error(`${LOG_PREFIX} package.json name must be fg-devkit.`)
37
- process.exit(1)
38
- }
39
- } catch {
40
- console.error(`${LOG_PREFIX} Could not read fg-devkit package.json.`)
41
- process.exit(1)
42
- }
43
- }
44
-
45
- function main() {
46
- assertFgDevkitMaintainerContext()
47
-
48
- if (!fs.existsSync(projectsRoot)) {
49
- console.error(`${LOG_PREFIX} projects root not found: ${projectsRoot}`)
50
- process.exit(1)
51
- }
52
-
53
- const repos = collectFleetGitRepos(projectsRoot)
54
- console.log(`${LOG_PREFIX} projectsRoot=${projectsRoot}`)
55
- console.log(`${LOG_PREFIX} repositories=${repos.length}`)
56
-
57
- const exitCode = runFleetGitDiscard({
58
- repos,
59
- projectsRoot,
60
- dryRun,
61
- logPrefix: LOG_PREFIX,
62
- })
63
- process.exit(exitCode)
64
- }
65
-
66
- main()
@@ -1,65 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Maintainer: git pull on the current branch for every git repository under projects root.
4
- *
5
- * Usage (from fg-devkit repository root):
6
- * pnpm exec fg-devkit fleet-git-pull [projects-root] [--dry-run]
7
- */
8
-
9
- import fs from 'node:fs'
10
- import path from 'node:path'
11
- import { fileURLToPath } from 'node:url'
12
-
13
- import { collectFleetGitRepos } from './fleet-project-repos.mjs'
14
- import { runFleetGitPull } from './git-pull-fleet-common.mjs'
15
-
16
- const scriptDir = path.dirname(fileURLToPath(import.meta.url))
17
- const fgDevkitRoot = path.resolve(scriptDir, '..')
18
- const fgDevkitPkgPath = path.join(fgDevkitRoot, 'package.json')
19
-
20
- const cliArgs = process.argv.slice(2)
21
- const dryRun = cliArgs.includes('--dry-run')
22
- const projectsRootArg = cliArgs.find((a) => !a.startsWith('-'))
23
- const projectsRoot = projectsRootArg
24
- ? path.resolve(process.cwd(), projectsRootArg)
25
- : path.resolve(fgDevkitRoot, '..')
26
-
27
- function assertFgDevkitMaintainerContext() {
28
- if (path.resolve(process.cwd()) !== fgDevkitRoot) {
29
- console.error('[fleet-git-pull] Run from the fg-devkit repository root.')
30
- process.exit(1)
31
- }
32
- try {
33
- const pkg = JSON.parse(fs.readFileSync(fgDevkitPkgPath, 'utf8'))
34
- if (pkg?.name !== 'fg-devkit') {
35
- console.error('[fleet-git-pull] package.json name must be fg-devkit.')
36
- process.exit(1)
37
- }
38
- } catch {
39
- console.error('[fleet-git-pull] Could not read fg-devkit package.json.')
40
- process.exit(1)
41
- }
42
- }
43
-
44
- function main() {
45
- assertFgDevkitMaintainerContext()
46
-
47
- if (!fs.existsSync(projectsRoot)) {
48
- console.error(`[fleet-git-pull] projects root not found: ${projectsRoot}`)
49
- process.exit(1)
50
- }
51
-
52
- const repos = collectFleetGitRepos(projectsRoot)
53
- console.log(`[fleet-git-pull] projectsRoot=${projectsRoot}`)
54
- console.log(`[fleet-git-pull] repositories=${repos.length}`)
55
-
56
- const exitCode = runFleetGitPull({
57
- repos,
58
- projectsRoot,
59
- dryRun,
60
- logPrefix: '[fleet-git-pull]',
61
- })
62
- process.exit(exitCode)
63
- }
64
-
65
- main()