1
1
import { execSync } from "child_process"
2
- import fs , { readFileSync , unlinkSync , writeFileSync } from "fs"
2
+ import fs , { unlinkSync , writeFileSync } from "fs"
3
3
import path from "path"
4
4
import { Readable } from "stream"
5
5
import { finished } from "stream/promises"
@@ -9,9 +9,6 @@ import decompress from "decompress"
9
9
10
10
import { INTL_JSON_DIR , TRANSLATIONS_DIR } from "../../../lib/constants"
11
11
12
- import { SUMMARY_PATH } from "./constants"
13
- import { QASummary } from "./types"
14
-
15
12
export const downloadFile = async ( url : string , writePath : string ) => {
16
13
// Get directory from writePath and ensure it exists
17
14
const dir = writePath . substring ( 0 , writePath . lastIndexOf ( "/" ) )
@@ -40,33 +37,6 @@ export const decompressFile = async (filePath: string, targetDir: string) => {
40
37
console . log ( "✅ Decompression complete." )
41
38
}
42
39
43
- const getQAMessage = ( locale : string ) => {
44
- console . log ( "Checking summary path:" , SUMMARY_PATH )
45
- if ( ! fs . existsSync ( SUMMARY_PATH ) ) {
46
- console . error ( "Could not find summary path:" , SUMMARY_PATH )
47
- throw new Error ( "No summary file found." )
48
- }
49
-
50
- const summaryJson : QASummary = JSON . parse ( readFileSync ( SUMMARY_PATH , "utf-8" ) )
51
- const qaResults = summaryJson [ locale ]
52
- ? summaryJson [ locale ] . map ( ( s ) => "- " + s ) . join ( "\n" )
53
- : null
54
-
55
- if ( ! qaResults ) return "No QA issues found"
56
- return `
57
- \`\`\`shell
58
- yarn markdown-checker
59
- \`\`\`
60
-
61
- <details><summary>Unfold for ${ summaryJson [ locale ] . length } result(s)</summary>
62
-
63
- ${ qaResults }
64
- </details>
65
-
66
- @coderabbitai review
67
- `
68
- }
69
-
70
40
export const createLocaleTranslationPR = (
71
41
locale : string ,
72
42
buckets : number [ ]
@@ -88,8 +58,22 @@ export const createLocaleTranslationPR = (
88
58
} ) . trim ( )
89
59
execSync ( `git checkout -b ${ branchName } ` )
90
60
execSync ( "git reset ." )
91
- execSync ( `git add ${ TRANSLATIONS_DIR } /${ locale } ` )
92
- execSync ( `git add ${ INTL_JSON_DIR } /${ locale } ` )
61
+
62
+ // Check if the translations directory exists and contains files
63
+ const translationsDir = path . join ( TRANSLATIONS_DIR , locale )
64
+ if (
65
+ fs . existsSync ( translationsDir ) &&
66
+ fs . readdirSync ( translationsDir ) . length > 0
67
+ ) {
68
+ execSync ( `git add ${ translationsDir } ` )
69
+ }
70
+
71
+ // Check if the intl JSON directory exists and contains files
72
+ const intlJsonDir = path . join ( INTL_JSON_DIR , locale )
73
+ if ( fs . existsSync ( intlJsonDir ) && fs . readdirSync ( intlJsonDir ) . length > 0 ) {
74
+ execSync ( `git add ${ intlJsonDir } ` )
75
+ }
76
+
93
77
execSync ( `git commit -m "${ message } "` )
94
78
execSync ( `git push origin ${ branchName } ` )
95
79
@@ -101,9 +85,6 @@ export const createLocaleTranslationPR = (
101
85
102
86
## Content buckets imported
103
87
${ buckets . sort ( ( a , b ) => a - b ) . join ( ", " ) }
104
-
105
- ## Markdown QA checker alerts
106
- ${ getQAMessage ( locale ) }
107
88
`
108
89
109
90
const bodyWritePath = path . resolve ( process . cwd ( ) , "body.txt" )
0 commit comments