Skip to content

Commit

Permalink
build(deps-dev): Bump flat from 5.0.2 to 6.0.1 (#1202)
Browse files Browse the repository at this point in the history
* build(deps-dev): Bump flat from 5.0.2 to 6.0.1

Bumps [flat](https://github.com/hughsk/flat) from 5.0.2 to 6.0.1.
- [Release notes](https://github.com/hughsk/flat/releases)
- [Commits](hughsk/flat@5.0.2...v6.0.1)

---
updated-dependencies:
- dependency-name: flat
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* fix: Fixed localization scripts
* chore: migrate node localization scripts to ESM
* chore: remove top-level ESM flag, change scripts extensions to .mjs (#1321)

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Jose Buitron <[email protected]>
Co-authored-by: Igor Bejnarowicz <[email protected]>
  • Loading branch information
3 people authored Nov 27, 2023
1 parent 027d035 commit e9684e4
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 33 deletions.
1 change: 1 addition & 0 deletions .node-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.9.0
11 changes: 7 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@
"test-debug": "npm run generate-types && react-scripts --inspect-brk test --runInBand --no-cache",
"test-coverage": "npm run generate-types && react-scripts test --coverage --changedSince=origin/main --watchAll=falsed",
"analyze": "source-map-explorer 'build/static/js/*.js'",
"localization-to-po": "node scripts/localization/transform-to.js po",
"localization-to-json": "node scripts/localization/transform-to.js json",
"localization-check-missing": "node scripts/localization/missing-check.js",
"localization-to-po": "node scripts/localization/transform-to.mjs po",
"localization-to-json": "node scripts/localization/transform-to.mjs json",
"localization-check-missing": "node scripts/localization/missing-check.mjs",
"eject": "react-scripts eject"
},
"browserslist": [
Expand All @@ -101,7 +101,7 @@
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-lodash-fp": "^2.2.0-a1",
"eslint-plugin-prettier": "^5.0.1",
"flat": "^5.0.2",
"flat": "^6.0.1",
"i18next-conv": "^14.0.0",
"jest-axe": "^8.0.0",
"plausible-tracker": "^0.3.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@
* along with this program. If not, see https://www.gnu.org/licenses/.
*/

const { readFile } = require('fs').promises;
const path = require('path');
const flat = require('flat');
const _ = require('lodash/fp');
import { readFile } from 'fs/promises';
import path from 'path';
import { flatten } from 'flat';
import _ from 'lodash/fp.js';

const { filesInFolder } = require('./utils');
import { filesInFolder } from './utils.mjs';

const SOURCE_LOCALE = 'en-US';

const LOCALE_FILES_FOLDER = path.join(
__dirname,
'../../src/localization/locales/'
const LOCALE_FILES_FOLDER = new URL(
'../../src/localization/locales/',
import.meta.url
);

const getKeys = content => {
const json = JSON.parse(content);
const keys = Object.keys(flat(json));
const keys = Object.keys(flatten(json));
return keys;
};

const checkMissingKeys = () =>
readFile(path.join(LOCALE_FILES_FOLDER, `${SOURCE_LOCALE}.json`))
readFile(new URL(`${SOURCE_LOCALE}.json`, LOCALE_FILES_FOLDER))
// Get source locale keys
.then(sourceContent => getKeys(sourceContent))
// Get all locale files
Expand All @@ -53,7 +53,7 @@ const checkMissingKeys = () =>
return null;
}
console.log(
`Missing keys for ${path.parse(filePath).name}.`,
`Missing keys for ${path.parse(filePath.pathname).name}.`,
'Missing:',
localeDiff
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
* along with this program. If not, see https://www.gnu.org/licenses/.
*/

const path = require('path');
const { readFileSync } = require('fs');
const { writeFile } = require('fs').promises;
const { i18nextToPo, gettextToI18next } = require('i18next-conv');
import { readFileSync } from 'fs';
import { writeFile } from 'fs/promises';
import path from 'path';
import { gettextToI18next, i18nextToPo } from 'i18next-conv';

const { filesInFolder } = require('./utils');
import { filesInFolder } from './utils.mjs';

// Script arguments
const args = process.argv.slice(2);
Expand All @@ -37,14 +37,18 @@ const save = target => result => writeFile(target, result);

// Base transform function
const transform = (process, from, i18Transform) =>
filesInFolder(path.join(__dirname, from))
filesInFolder(new URL(from, import.meta.url))
.then(files => {
console.log(`${process} transform starting.`, 'Files:', files);
console.log(
`${process} transform starting.`,
'Files:',
files.map(f => f.pathname)
);
return files;
})
.then(files =>
files.map(filePath => {
const locale = path.parse(filePath).name;
const locale = path.parse(filePath.pathname).name;
return i18Transform(locale, filePath).then(() => locale);
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
* along with this program. If not, see https://www.gnu.org/licenses/.
*/

const { readdir } = require('fs').promises;
const path = require('path');
import { readdir } from 'fs/promises';

const filesInFolder = dirname =>
export const filesInFolder = dirname =>
readdir(dirname).then(filenames =>
filenames.map(filename => path.join(dirname, filename))
filenames.map(filename => new URL(filename, dirname))
);

module.exports = { filesInFolder };

0 comments on commit e9684e4

Please sign in to comment.