add missing dev dependency for locale scripts

This commit is contained in:
Michael Schramm 2022-02-28 22:51:14 +01:00
parent 1e90c11f30
commit 7b5e717a56
4 changed files with 18 additions and 8 deletions

View File

@ -11,8 +11,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Changed ### Changed
- update translations (https://github.com/ohmyform/ui/pull/70)
### Fixed ### Fixed
- locale scripts were missing dependency
### Security ### Security
## [1.0.0] - 2022-02-28 ## [1.0.0] - 2022-02-28

View File

@ -1,12 +1,12 @@
const fs = require('fs'); const { readFileSync } = require('fs');
const glob = require('glob'); const glob = require('glob');
const { program } = require('commander'); const { program } = require('commander');
const merge = require('lodash.merge'); const merge = require('lodash.merge');
const dirs: string[] = [] const dirs: string[] = []
program.version('1.0.0'); program.version('1.0.0');
program program.arguments('<limit>')
.arguments('<limit>')
.action((limit) => { .action((limit) => {
dirs.push( dirs.push(
...limit ...limit
@ -21,12 +21,12 @@ let all = {}
glob.sync('locales/**/*.json').forEach(file => { glob.sync('locales/**/*.json').forEach(file => {
try { try {
const original = JSON.parse(fs.readFileSync(file)) const original = JSON.parse(readFileSync(file).toString('utf-8'))
all = merge( all = merge(
all, all,
{ {
[file.replace(/^.*\/([a-z]+)\.json$/, '$1')]: original [file.replace(/^.*\/([a-z]+)\.json$/, '$1')]: original,
} }
) )
} catch (e) { } catch (e) {
@ -34,7 +34,7 @@ glob.sync('locales/**/*.json').forEach(file => {
} }
}) })
const compare = (original, compareTo, path, file) => { const compare = (original, compareTo, path, file: string) => {
const oKeys = Object.keys(original) const oKeys = Object.keys(original)
const aKeys = Object.keys(compareTo) const aKeys = Object.keys(compareTo)
@ -54,7 +54,7 @@ const compare = (original, compareTo, path, file) => {
dirs.forEach(dir => { dirs.forEach(dir => {
const files: string[] = glob.sync(`${dir}*.json`) const files: string[] = glob.sync(`${dir}*.json`)
const existingFiles = files.map(file => file.replace(/^.*\/([a-z]+)\.json$/, '$1')).push('language') const existingFiles: string[] = files.map(file => file.replace(/^.*\/([a-z]+)\.json$/, '$1'))
Object Object
.keys(all) .keys(all)
.filter(file => !existingFiles.includes(file)) .filter(file => !existingFiles.includes(file))
@ -65,7 +65,7 @@ dirs.forEach(dir => {
files.forEach(file => { files.forEach(file => {
try { try {
compare( compare(
JSON.parse(fs.readFileSync(file)), JSON.parse(readFileSync(file).toString('utf-8')),
all[file.replace(/^.*\/([a-z]+)\.json$/, '$1')], all[file.replace(/^.*\/([a-z]+)\.json$/, '$1')],
[], [],
file file

View File

@ -58,6 +58,7 @@
"@types/swiper": "^6.0.0", "@types/swiper": "^6.0.0",
"@typescript-eslint/eslint-plugin": "^5.12.1", "@typescript-eslint/eslint-plugin": "^5.12.1",
"@typescript-eslint/parser": "^5.12.1", "@typescript-eslint/parser": "^5.12.1",
"commander": "^9.0.0",
"eslint": "^8.10.0", "eslint": "^8.10.0",
"eslint-config-prettier": "^8.4.0", "eslint-config-prettier": "^8.4.0",
"eslint-plugin-jsx-a11y": "^6.5.1", "eslint-plugin-jsx-a11y": "^6.5.1",

View File

@ -1603,6 +1603,11 @@ commander@^2.8.1:
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
commander@^9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-9.0.0.tgz#86d58f24ee98126568936bd1d3574e0308a99a40"
integrity sha512-JJfP2saEKbQqvW+FI93OYUB4ByV5cizMpFMiiJI8xDbBvQvSkIk0VvQdn1CZ8mqAO8Loq2h0gYTYtDFUZUeERw==
complex.js@^2.0.15: complex.js@^2.0.15:
version "2.0.15" version "2.0.15"
resolved "https://registry.yarnpkg.com/complex.js/-/complex.js-2.0.15.tgz#7add6848b4c1d12aa9262f7df925ebe7a51a7406" resolved "https://registry.yarnpkg.com/complex.js/-/complex.js-2.0.15.tgz#7add6848b4c1d12aa9262f7df925ebe7a51a7406"