fg-devkit 1.12.1 → 1.12.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fg-devkit",
3
- "version": "1.12.1",
3
+ "version": "1.12.2",
4
4
  "description": "Shared configs, scripts, and DX tooling for Vue / TypeScript frontend repos",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -34,7 +34,7 @@
34
34
  "@tanstack/vue-query-devtools": "6.1.34",
35
35
  "@types/node": "22.16.5",
36
36
  "@vitejs/plugin-vue": "6.0.7",
37
- "fg-devkit": "1.12.1",
37
+ "fg-devkit": "1.12.2",
38
38
  "start-server-and-test": "2.1.3",
39
39
  "tailwindcss": "4.3.1",
40
40
  "tsx": "4.22.4",
@@ -673,11 +673,11 @@ async function runInteractiveMenu() {
673
673
  const releaseMode = await selectPrompt({
674
674
  message: 'Create release',
675
675
  choices: [
676
- { name: 'Release + release notes', value: 'with-notes' },
677
676
  { name: 'Release', value: 'without-notes' },
677
+ { name: 'Release + release notes', value: 'with-notes' },
678
678
  { name: 'Cancel', value: 'cancel' },
679
679
  ],
680
- default: 'with-notes',
680
+ default: 'without-notes',
681
681
  loop: false,
682
682
  })
683
683
  if (releaseMode === 'cancel') continue
@@ -10,7 +10,6 @@
10
10
  import { spawnSync } from 'node:child_process'
11
11
  import path from 'node:path'
12
12
  import {
13
- hasReleaseNotesConfig,
14
13
  resolveCliffConfig,
15
14
  resolveGitCliffBin,
16
15
  runSyncUserChangelog,
@@ -45,13 +44,6 @@ function runGitCliff(configPath, outputPath) {
45
44
  }
46
45
 
47
46
  function main() {
48
- if (!hasReleaseNotesConfig(cwd)) {
49
- console.error(
50
- '[fg-devkit] No release-notes config found. Run "pnpm exec fgd sync-release-notes-config" first.',
51
- )
52
- return 1
53
- }
54
-
55
47
  const technicalConfig = resolveCliffConfig('cliff.toml', cwd)
56
48
  if (!technicalConfig) {
57
49
  console.error('[fg-devkit] Missing cliff.toml in repo and fg-devkit configs.')
@@ -6,11 +6,9 @@
6
6
  import { spawnSync } from 'node:child_process'
7
7
  import fs from 'node:fs'
8
8
  import path from 'node:path'
9
- import { createRequire } from 'node:module'
10
9
  import { fileURLToPath } from 'node:url'
11
10
 
12
11
  const scriptDir = path.dirname(fileURLToPath(import.meta.url))
13
- const require = createRequire(import.meta.url)
14
12
 
15
13
  export const fgRoot = path.resolve(scriptDir, '..')
16
14
 
@@ -38,14 +36,19 @@ export function resolveCliffConfig(name, cwd = process.cwd()) {
38
36
  return null
39
37
  }
40
38
 
41
- export function resolveGitCliffBin() {
42
- const candidates = [
43
- path.join(fgRoot, 'node_modules', 'git-cliff', 'lib', 'cli', 'cli.js'),
44
- path.join(process.cwd(), 'node_modules', 'git-cliff', 'lib', 'cli', 'cli.js'),
45
- path.join(process.cwd(), 'node_modules', 'fg-devkit', 'node_modules', 'git-cliff', 'lib', 'cli', 'cli.js'),
46
- ]
39
+ function findInPnpmStore(baseDir, packageName, relativePath) {
40
+ const pnpmDir = path.join(baseDir, 'node_modules', '.pnpm')
41
+ if (!fs.existsSync(pnpmDir)) {
42
+ return null
43
+ }
44
+
45
+ const prefix = `${packageName}@`
46
+ for (const entry of fs.readdirSync(pnpmDir)) {
47
+ if (!entry.startsWith(prefix)) {
48
+ continue
49
+ }
47
50
 
48
- for (const candidate of candidates) {
51
+ const candidate = path.join(pnpmDir, entry, 'node_modules', packageName, relativePath)
49
52
  if (fs.existsSync(candidate)) {
50
53
  return candidate
51
54
  }
@@ -54,25 +57,47 @@ export function resolveGitCliffBin() {
54
57
  return null
55
58
  }
56
59
 
57
- export function resolveTsxBin() {
58
- const candidates = [
59
- path.join(fgRoot, 'node_modules', 'tsx', 'dist', 'cli.mjs'),
60
- path.join(fgRoot, 'node_modules', 'tsx', 'cli.mjs'),
61
- path.join(process.cwd(), 'node_modules', 'tsx', 'dist', 'cli.mjs'),
62
- path.join(process.cwd(), 'node_modules', 'fg-devkit', 'node_modules', 'tsx', 'dist', 'cli.mjs'),
63
- ]
64
-
65
- for (const candidate of candidates) {
66
- if (fs.existsSync(candidate)) {
67
- return candidate
60
+ function resolvePackageFile(packageName, relativePaths, searchRoots) {
61
+ const roots = [...new Set(searchRoots.map((root) => path.resolve(root)))]
62
+
63
+ for (const root of roots) {
64
+ for (const relativePath of relativePaths) {
65
+ const nested = path.join(root, 'node_modules', packageName, relativePath)
66
+ if (fs.existsSync(nested)) {
67
+ return nested
68
+ }
68
69
  }
69
- }
70
70
 
71
- try {
72
- return require.resolve('tsx/cli.mjs', { paths: [fgRoot, process.cwd()] })
73
- } catch {
74
- return null
71
+ let dir = root
72
+ for (let depth = 0; depth < 8; depth += 1) {
73
+ for (const relativePath of relativePaths) {
74
+ const fromStore = findInPnpmStore(dir, packageName, relativePath)
75
+ if (fromStore) {
76
+ return fromStore
77
+ }
78
+ }
79
+
80
+ const parent = path.dirname(dir)
81
+ if (parent === dir) {
82
+ break
83
+ }
84
+ dir = parent
85
+ }
75
86
  }
87
+
88
+ return null
89
+ }
90
+
91
+ function dependencySearchRoots() {
92
+ return [fgRoot, process.cwd(), path.join(process.cwd(), 'node_modules', 'fg-devkit')]
93
+ }
94
+
95
+ export function resolveGitCliffBin() {
96
+ return resolvePackageFile('git-cliff', ['lib/cli/cli.js'], dependencySearchRoots())
97
+ }
98
+
99
+ export function resolveTsxBin() {
100
+ return resolvePackageFile('tsx', ['dist/cli.mjs', 'cli.mjs'], dependencySearchRoots())
76
101
  }
77
102
 
78
103
  export function runSyncUserChangelog(cwd = process.cwd()) {