58 lines
1.2 KiB
JavaScript
58 lines
1.2 KiB
JavaScript
import { stdin as input, stdout as output } from "node:process"
|
|
import * as readline from "node:readline/promises"
|
|
|
|
import { config } from "dotenv"
|
|
|
|
const rl = readline.createInterface({ input, output })
|
|
|
|
config({ path: `${process.cwd()}/.env.local` })
|
|
|
|
function diffArray(json1, json2) {
|
|
const diff = []
|
|
const keys1 = Object.keys(json1)
|
|
const keys2 = Object.keys(json2)
|
|
|
|
keys1.forEach((key) => {
|
|
if (!keys2.includes(key)) {
|
|
diff.push(key)
|
|
}
|
|
})
|
|
|
|
return diff
|
|
}
|
|
|
|
async function main() {
|
|
const answer = await rl.question(
|
|
"To make sure we use the latest data for the diff, have you run i18n:download AND i18n:extract BEFORE running this? Type yes or no "
|
|
)
|
|
|
|
if (answer !== "yes") {
|
|
console.log("")
|
|
console.warn(
|
|
"Please run i18n:download AND i18n:extract BEFORE running this."
|
|
)
|
|
rl.close()
|
|
process.exit(1)
|
|
}
|
|
rl.close()
|
|
|
|
const allLokalise = await import("./translations-all/en.json", {
|
|
with: {
|
|
type: "json",
|
|
},
|
|
})
|
|
const fromCodebase = await import("./extracted.json", {
|
|
with: {
|
|
type: "json",
|
|
},
|
|
})
|
|
|
|
const labelsToRemove = diffArray(allLokalise, fromCodebase)
|
|
|
|
const { deleteBulk } = await import("./lokalise")
|
|
|
|
await deleteBulk(labelsToRemove)
|
|
}
|
|
|
|
main()
|