Skip to content

Commit 1cad883

Browse files
authored
Update: Upgrade Node.js from 18 to 22 (#2711)
### Changes Updated Node.js version from 18 to 22 in: - `.github/workflows/release.yml` - `github/workflows/test.yml` ### Checklist * [ ] I have read the [Auth0 general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md) * [ ] I have read the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md) * [ ] All code quality tools/guidelines have been run/followed * [ ] All relevant assets have been compiled
1 parent beea72a commit 1cad883

File tree

4 files changed

+24
-19
lines changed

4 files changed

+24
-19
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
release:
1919
uses: ./.github/workflows/npm-release.yml
2020
with:
21-
node-version: 18
21+
node-version: 22
2222
require-build: true
2323
secrets:
2424
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Setup Node
3333
uses: actions/setup-node@v6
3434
with:
35-
node-version: 18
35+
node-version: 22
3636
cache: 'npm'
3737

3838
- name: Install dependencies

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"publish:cdn": "ccu --trace",
3838
"i18n:translate": "grunt dist && node scripts/complete-translations.js && npm run i18n:prettier && npm run build",
3939
"i18n:prettier": "prettier --write src/i18n/*",
40-
"i18n:validate": "node -r esm scripts/lang-audit.js"
40+
"i18n:validate": "node scripts/lang-audit.mjs"
4141
},
4242
"devDependencies": {
4343
"@auth0/component-cdn-uploader": "^2.4.2",
Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
const path_module = require('path');
2-
const emojic = require('emojic');
3-
const chalk = require('chalk');
4-
const glob = require('glob');
5-
const directory = path_module.join(__dirname, '..', 'src', 'i18n');
1+
import path from 'path';
2+
import { fileURLToPath } from 'url';
3+
import emojic from 'emojic';
4+
import chalk from 'chalk';
5+
import glob from 'glob';
6+
7+
const __filename = fileURLToPath(import.meta.url);
8+
const __dirname = path.dirname(__filename);
9+
10+
const directory = path.join(__dirname, '..', 'src', 'i18n');
611

712
/**
813
* Flattens an object recursively so that any nested objects are referred to on the root object using
@@ -30,7 +35,7 @@ const directory = path_module.join(__dirname, '..', 'src', 'i18n');
3035
const flattenObject = (obj, cumulative = []) => {
3136
let keys = {};
3237

33-
for (key of Object.keys(obj)) {
38+
for (const key of Object.keys(obj)) {
3439
if (typeof obj[key] === 'object') {
3540
const subKeys = flattenObject(obj[key], cumulative.concat(key));
3641
keys = { ...keys, ...subKeys };
@@ -56,7 +61,7 @@ const compareKeys = (obj1, obj2) => {
5661
total: Object.keys(obj1).length
5762
};
5863

59-
for (key of Object.keys(obj1)) {
64+
for (const key of Object.keys(obj1)) {
6065
if (!(key in obj2)) {
6166
result.missing.push({ key, text: obj1[key] });
6267
} else {
@@ -72,22 +77,22 @@ const compareKeys = (obj1, obj2) => {
7277
* @param {string} reference The reference object. A lang file that has been loaded and flattened.
7378
* @param {string} path The full module path of the module to compare to the reference.
7479
*/
75-
const validateLangFile = async (reference, path, verbose) => {
76-
console.log(`Processing ${chalk.green(path_module.relative(process.cwd(), path))}`);
80+
const validateLangFile = async (reference, filePath, verbose) => {
81+
console.log(`Processing ${chalk.green(path.relative(process.cwd(), filePath))}`);
7782

7883
const stats = {
7984
coverage: 0,
8085
total: 0,
8186
missing: 0
8287
};
8388

84-
const lang = await import(path);
89+
const lang = await import(filePath);
8590
const langFlattened = flattenObject(lang.default);
8691

8792
const result = compareKeys(reference, langFlattened);
8893

8994
if (verbose) {
90-
for (key of Object.keys(reference)) {
95+
for (const key of Object.keys(reference)) {
9196
if (key in langFlattened) {
9297
console.log(chalk.green(`${key}: ${langFlattened[key]}`));
9398
} else {
@@ -103,10 +108,10 @@ const validateLangFile = async (reference, path, verbose) => {
103108
if (result.missing.length) {
104109
console.log(`${emojic.x} Found ${result.missing.length} missing keys`);
105110

106-
for (missing of result.missing) {
111+
for (const missing of result.missing) {
107112
console.log(
108113
chalk.red(
109-
`Missing translation for ${path_module.basename(path)} -> ${missing.key} = "${
114+
`Missing translation for ${path.basename(filePath)} -> ${missing.key} = "${
110115
missing.text
111116
}"`
112117
)
@@ -123,7 +128,7 @@ const validateLangFile = async (reference, path, verbose) => {
123128

124129
const run = async () => {
125130
// Load the 'en' lang file to act as the reference for all others
126-
const en = await import(path_module.join(directory, 'en.js'));
131+
const en = await import(path.join(directory, 'en.js'));
127132
const enBenchmark = flattenObject(en.default, []);
128133

129134
const args = process.argv.slice(2);
@@ -132,13 +137,13 @@ const run = async () => {
132137
const verbose = args.includes('-v');
133138

134139
// Grab all the module files we want to compare to
135-
const modules = glob.sync(path_module.join(__dirname, '..', 'src', 'i18n', filePattern));
140+
const modules = glob.sync(path.join(__dirname, '..', 'src', 'i18n', filePattern));
136141
let files = 0;
137142
let coverage = 0;
138143
let total = 0;
139144
let missing = 0;
140145

141-
for (file of modules) {
146+
for (const file of modules) {
142147
const stats = await validateLangFile(enBenchmark, file, verbose);
143148
console.log('');
144149

0 commit comments

Comments
 (0)