From 7b5e717a56253d2b63808da654164cb81df70ea4 Mon Sep 17 00:00:00 2001 From: Michael Schramm Date: Mon, 28 Feb 2022 22:51:14 +0100 Subject: [PATCH] add missing dev dependency for locale scripts --- CHANGELOG.md | 4 ++++ locales/missing.ts | 16 ++++++++-------- package.json | 1 + yarn.lock | 5 +++++ 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index baa6fc5..670a7de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ### Changed +- update translations (https://github.com/ohmyform/ui/pull/70) + ### Fixed +- locale scripts were missing dependency + ### Security ## [1.0.0] - 2022-02-28 diff --git a/locales/missing.ts b/locales/missing.ts index ec05ee8..fecb398 100644 --- a/locales/missing.ts +++ b/locales/missing.ts @@ -1,12 +1,12 @@ -const fs = require('fs'); +const { readFileSync } = require('fs'); const glob = require('glob'); const { program } = require('commander'); const merge = require('lodash.merge'); + const dirs: string[] = [] program.version('1.0.0'); -program - .arguments('') +program.arguments('') .action((limit) => { dirs.push( ...limit @@ -21,12 +21,12 @@ let all = {} glob.sync('locales/**/*.json').forEach(file => { try { - const original = JSON.parse(fs.readFileSync(file)) + const original = JSON.parse(readFileSync(file).toString('utf-8')) all = merge( all, { - [file.replace(/^.*\/([a-z]+)\.json$/, '$1')]: original + [file.replace(/^.*\/([a-z]+)\.json$/, '$1')]: original, } ) } 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 aKeys = Object.keys(compareTo) @@ -54,7 +54,7 @@ const compare = (original, compareTo, path, file) => { dirs.forEach(dir => { 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 .keys(all) .filter(file => !existingFiles.includes(file)) @@ -65,7 +65,7 @@ dirs.forEach(dir => { files.forEach(file => { try { compare( - JSON.parse(fs.readFileSync(file)), + JSON.parse(readFileSync(file).toString('utf-8')), all[file.replace(/^.*\/([a-z]+)\.json$/, '$1')], [], file diff --git a/package.json b/package.json index 73ccaba..559d63b 100644 --- a/package.json +++ b/package.json @@ -58,6 +58,7 @@ "@types/swiper": "^6.0.0", "@typescript-eslint/eslint-plugin": "^5.12.1", "@typescript-eslint/parser": "^5.12.1", + "commander": "^9.0.0", "eslint": "^8.10.0", "eslint-config-prettier": "^8.4.0", "eslint-plugin-jsx-a11y": "^6.5.1", diff --git a/yarn.lock b/yarn.lock index 34ada73..4f65765 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1603,6 +1603,11 @@ commander@^2.8.1: resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" 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: version "2.0.15" resolved "https://registry.yarnpkg.com/complex.js/-/complex.js-2.0.15.tgz#7add6848b4c1d12aa9262f7df925ebe7a51a7406"