fg-devkit 1.6.3 → 1.6.6

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.6.3",
3
+ "version": "1.6.6",
4
4
  "description": "Shared configs, scripts, and DX tooling for Vue / TypeScript frontend repos",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -12,7 +12,7 @@
12
12
  "lint-check": "pnpm exec fgd lint .",
13
13
  "lint:all": "pnpm lint && pnpm lint:ts",
14
14
  "poeditor:download": "pnpm exec fg-devkit poeditor-download --format json",
15
- "poeditor:upload": "pnpm exec fg-devkit poeditor-upload --language sv --file ./src/lang/sv.json"
15
+ "poeditor:upload": "pnpm exec fg-devkit poeditor-upload"
16
16
  },
17
17
  "dependencies": {
18
18
  "@tailwindcss/postcss": "4.2.4",
@@ -34,7 +34,7 @@
34
34
  "@tanstack/vue-query-devtools": "6.1.24",
35
35
  "@types/node": "22.16.5",
36
36
  "@vitejs/plugin-vue": "6.0.6",
37
- "fg-devkit": "1.6.2",
37
+ "fg-devkit": "1.6.6",
38
38
  "start-server-and-test": "2.1.3",
39
39
  "tailwindcss": "4.2.4",
40
40
  "tsx": "4.21.0",
@@ -4,5 +4,8 @@
4
4
  "languages": ["sv", "en"],
5
5
  "defaultLanguage": "sv",
6
6
  "defaultFormat": "json",
7
- "uploadFile": "./src/lang/sv.json"
7
+ "uploadFiles": {
8
+ "sv": "./src/lang/sv.json",
9
+ "en": "./src/lang/en.json"
10
+ }
8
11
  }
@@ -518,6 +518,16 @@ const MENU = [
518
518
  label: 'Setup lefthook (migrate from husky/lint-staged)',
519
519
  run: () => runSetupLefthook(),
520
520
  },
521
+ {
522
+ key: '10',
523
+ label: 'PoEditor: Download translations',
524
+ run: () => runNode('poeditor-download.mjs'),
525
+ },
526
+ {
527
+ key: '11',
528
+ label: 'PoEditor: Upload translations',
529
+ run: () => runNode('poeditor-upload.mjs'),
530
+ },
521
531
  ]
522
532
 
523
533
  const MAINTAINER_MENU = [
@@ -17,6 +17,14 @@ const dryRun = cliArgs.includes('--dry-run')
17
17
  const projectsRootArg = cliArgs.find((a) => !a.startsWith('-'))
18
18
  const projectsRoot = projectsRootArg ? path.resolve(process.cwd(), projectsRootArg) : path.resolve(scriptDir, '../..')
19
19
 
20
+ function shouldSkipPackageJsonDir(relDir) {
21
+ const normalized = relDir.split(path.sep).join('/')
22
+ if (normalized === 'scaffold/vue' || normalized.endsWith('/scaffold/vue')) {
23
+ return true
24
+ }
25
+ return false
26
+ }
27
+
20
28
  function walk(dir, acc = []) {
21
29
  for (const item of fs.readdirSync(dir, { withFileTypes: true })) {
22
30
  if (item.name === 'node_modules' || item.name === '.git') continue
@@ -47,6 +55,8 @@ const packageJsonFiles = walk(projectsRoot)
47
55
  const repos = []
48
56
  for (const packageJsonPath of packageJsonFiles) {
49
57
  try {
58
+ const relDir = path.relative(projectsRoot, path.dirname(packageJsonPath))
59
+ if (shouldSkipPackageJsonDir(relDir)) continue
50
60
  const pkg = readJson(packageJsonPath)
51
61
  if (!isVueProject(pkg)) continue
52
62
  if (isFgDevkitRepo(pkg)) continue
@@ -33,6 +33,15 @@ function resolveLegacyConfig(raw) {
33
33
  function resolveObjectConfig(raw) {
34
34
  if (!raw || typeof raw !== 'object') return null
35
35
  if (typeof raw.projectId !== 'string') return null
36
+ const uploadFiles =
37
+ raw.uploadFiles && typeof raw.uploadFiles === 'object'
38
+ ? Object.entries(raw.uploadFiles).reduce((acc, [language, file]) => {
39
+ if (typeof language === 'string' && language.trim() !== '' && typeof file === 'string' && file.trim() !== '') {
40
+ acc[language] = file
41
+ }
42
+ return acc
43
+ }, {})
44
+ : undefined
36
45
  return {
37
46
  projectId: raw.projectId,
38
47
  downloadPath: typeof raw.downloadPath === 'string' ? raw.downloadPath : './src/lang/',
@@ -40,6 +49,7 @@ function resolveObjectConfig(raw) {
40
49
  defaultLanguage: typeof raw.defaultLanguage === 'string' ? raw.defaultLanguage : 'sv',
41
50
  defaultFormat: typeof raw.defaultFormat === 'string' ? raw.defaultFormat : 'json',
42
51
  uploadFile: typeof raw.uploadFile === 'string' ? raw.uploadFile : './src/lang/sv.json',
52
+ uploadFiles,
43
53
  }
44
54
  }
45
55
 
@@ -94,6 +104,7 @@ export function loadPoeditorConfig(flags) {
94
104
  defaultLanguage: resolved.defaultLanguage ?? 'sv',
95
105
  defaultFormat: resolved.defaultFormat ?? 'json',
96
106
  uploadFile: resolved.uploadFile ?? './src/lang/sv.json',
107
+ uploadFiles: resolved.uploadFiles ?? undefined,
97
108
  }
98
109
  }
99
110
 
@@ -44,12 +44,33 @@ async function main() {
44
44
  }
45
45
 
46
46
  const projectId = getFlagValue(flags, 'project-id', cfg.projectId)
47
- const language = getFlagValue(flags, 'language', cfg.defaultLanguage)
48
- const filePath = resolvePathFromCwd(getFlagValue(flags, 'file', cfg.uploadFile))
49
- const updating = fs.readFileSync(filePath, 'utf8')
47
+ const hasExplicitLanguage = flags.has('language')
48
+ const hasExplicitFile = flags.has('file')
49
+ if (hasExplicitLanguage || hasExplicitFile) {
50
+ const language = getFlagValue(flags, 'language', cfg.defaultLanguage)
51
+ const filePath = resolvePathFromCwd(getFlagValue(flags, 'file', cfg.uploadFile))
52
+ const updating = fs.readFileSync(filePath, 'utf8')
53
+ await uploadFile({ token, projectId, language, updating })
54
+ console.log(`[poeditor-upload] Upload completed for ${language}: ${filePath}`)
55
+ return
56
+ }
50
57
 
58
+ const uploads = cfg.uploadFiles && typeof cfg.uploadFiles === 'object' ? Object.entries(cfg.uploadFiles) : []
59
+ if (uploads.length > 0) {
60
+ for (const [language, file] of uploads) {
61
+ const filePath = resolvePathFromCwd(file)
62
+ const updating = fs.readFileSync(filePath, 'utf8')
63
+ await uploadFile({ token, projectId, language, updating })
64
+ console.log(`[poeditor-upload] Upload completed for ${language}: ${filePath}`)
65
+ }
66
+ return
67
+ }
68
+
69
+ const language = cfg.defaultLanguage
70
+ const filePath = resolvePathFromCwd(cfg.uploadFile)
71
+ const updating = fs.readFileSync(filePath, 'utf8')
51
72
  await uploadFile({ token, projectId, language, updating })
52
- console.log(`[poeditor-upload] Upload completed for ${filePath}`)
73
+ console.log(`[poeditor-upload] Upload completed for ${language}: ${filePath}`)
53
74
  }
54
75
 
55
76
  main().catch((err) => {
@@ -50,11 +50,25 @@ fi
50
50
 
51
51
  previous_tag="$(git describe --tags --abbrev=0 2>/dev/null || true)"
52
52
 
53
- pnpm version "$bump_type"
53
+ pnpm version "$bump_type" --no-git-tag-version
54
54
 
55
55
  new_version="$(node -p "require('./package.json').version")"
56
56
  new_tag="v${new_version}"
57
57
 
58
+ is_fg_devkit_repo="$(
59
+ node -e "const fs=require('fs'); try { const p=JSON.parse(fs.readFileSync('./package.json','utf8')); process.stdout.write(p.name==='fg-devkit' ? 'yes' : 'no'); } catch { process.stdout.write('no'); }"
60
+ )"
61
+
62
+ if [[ "$is_fg_devkit_repo" == "yes" && -f "./scripts/sync-scaffold-vue-deps.mjs" && -f "./scaffold/vue/package.json" ]]; then
63
+ node ./scripts/sync-scaffold-vue-deps.mjs
64
+ git add package.json scaffold/vue/package.json
65
+ else
66
+ git add package.json
67
+ fi
68
+
69
+ git commit -m "${new_tag}"
70
+ git tag "${new_tag}"
71
+
58
72
  git push
59
73
  git push --tags
60
74