Skip to content

Commit d37b191

Browse files
authored
Merge pull request #11704 from github/repo-sync
repo sync
2 parents 5b45bf0 + efdd7bd commit d37b191

File tree

2 files changed

+59
-3
lines changed

2 files changed

+59
-3
lines changed

Diff for: .github/workflows/staging-build-pr.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,13 @@ jobs:
101101

102102
- name: Delete heavy things we won't need deployed
103103
run: |
104-
# Non-WIP translations we don't support yet.
105-
rm -fr translations/de* translations/ru* translations/ko* translations/ru*
106-
107104
# Not needed to run after having been built.
108105
rm -fr .next/cache
109106
107+
# The dereferenced file is not used in runtime once the
108+
# decorated file has been created from it.
109+
rm -fr lib/rest/static/dereferenced
110+
110111
- name: Create an archive
111112
run: |
112113
tar -c --file=app.tar \

Diff for: script/i18n/prune-stale-files.js

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env node
2+
import fs from 'fs'
3+
import path from 'path'
4+
import walk from 'walk-sync'
5+
import program from 'commander'
6+
import languages from '../../lib/languages.js'
7+
8+
program
9+
.description(
10+
`Removes any file in the translations directory that doesn't have a 1-1 mapping with an English file in the content directory`
11+
)
12+
.option('-d, --dry-run', `List the files that will be deleted, but don't remove them).`)
13+
.parse(process.argv)
14+
15+
const languageDir = Object.keys(languages)
16+
.filter((language) => !languages[language].wip && language !== 'en')
17+
.map((language) => languages[language].dir)
18+
19+
main()
20+
21+
async function main() {
22+
const listOfContentFiles = walk(path.join(process.cwd(), 'content'), {
23+
includeBasePath: false,
24+
directories: false,
25+
})
26+
27+
const translatedFilePaths = []
28+
languageDir.forEach((directory) => {
29+
const listOfFiles = walk(path.join(directory, 'content'), {
30+
includeBasePath: true,
31+
directories: false,
32+
}).map((path) => path.replace(process.cwd(), ''))
33+
translatedFilePaths.push(...listOfFiles)
34+
})
35+
36+
let outOfSyncFilesCount = 0
37+
translatedFilePaths.forEach((translatedFilePath) => {
38+
const translationRelativePath = translatedFilePath.split('/content/')[1]
39+
40+
// If there is a 1:1 mapping of translated file to english file
41+
// we're in sync, don't log
42+
if (listOfContentFiles.includes(translationRelativePath)) {
43+
return
44+
}
45+
46+
outOfSyncFilesCount++
47+
if (!program.opts().dryRun) {
48+
fs.unlinkSync(translatedFilePath)
49+
} else {
50+
console.log(translatedFilePath)
51+
}
52+
})
53+
54+
console.log(`Out of sync file size: ${outOfSyncFilesCount}`)
55+
}

0 commit comments

Comments
 (0)