diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 4855d8b..4f8a1a3 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -41,16 +41,16 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1 + uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0 with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - name: Checkout repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8 + uses: github/codeql-action/init@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -60,7 +60,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8 + uses: github/codeql-action/autobuild@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7 # ℹ️ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -73,6 +73,6 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8 + uses: github/codeql-action/analyze@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index a12bcde..566d3ea 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -17,13 +17,13 @@ jobs: fail-fast: false steps: - name: Harden Runner - uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1 + uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0 with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 + uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: node-version: ${{ matrix.node-version }} - name: Install dependencies diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index f117471..9b406a8 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -32,17 +32,17 @@ jobs: steps: - name: Harden Runner - uses: step-security/harden-runner@eb238b55efaa70779f274895e782ed17c84f2895 # v2.6.1 + uses: step-security/harden-runner@f086349bfa2bd1361f7909c78558e816508cdc10 # v2.8.0 with: egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - name: "Checkout code" - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 with: persist-credentials: false - name: "Run analysis" - uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1 + uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3 with: results_file: results.sarif results_format: sarif @@ -64,7 +64,7 @@ jobs: # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF # format to the repository Actions tab. - name: "Upload artifact" - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 + uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 with: name: SARIF file path: results.sarif @@ -72,6 +72,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@407ffafae6a767df3e0230c3df91b6443ae8df75 # v2.22.8 + uses: github/codeql-action/upload-sarif@f079b8493333aace61c81488f8bd40919487bd9f # v3.25.7 with: sarif_file: results.sarif diff --git a/LICENSE b/LICENSE index 90374c9..0fb1682 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 NodeSecure +Copyright (c) 2021-2024 NodeSecure Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/i18n/cli/english.js b/externalLanguages/cli/english.js similarity index 99% rename from i18n/cli/english.js rename to externalLanguages/cli/english.js index a43b262..cee12a4 100644 --- a/i18n/cli/english.js +++ b/externalLanguages/cli/english.js @@ -1,6 +1,6 @@ /* eslint-disable max-len */ // Import Third-party Dependencies -import { taggedString as tS } from "@nodesecure/i18n"; +import { taggedString as tS } from "../../src/utils.js"; const cli = { executing_at: "Executing node-secure at", diff --git a/i18n/cli/french.js b/externalLanguages/cli/french.js similarity index 99% rename from i18n/cli/french.js rename to externalLanguages/cli/french.js index 489bd77..f26c633 100644 --- a/i18n/cli/french.js +++ b/externalLanguages/cli/french.js @@ -1,6 +1,6 @@ /* eslint-disable max-len */ // Import Third-party Dependencies -import { taggedString as tS } from "@nodesecure/i18n"; +import { taggedString as tS } from "../../src/utils.js"; const cli = { executing_at: "Exécution de node-secure à", diff --git a/i18n/scanner/english.js b/externalLanguages/scanner/english.js similarity index 100% rename from i18n/scanner/english.js rename to externalLanguages/scanner/english.js diff --git a/i18n/scanner/french.js b/externalLanguages/scanner/french.js similarity index 100% rename from i18n/scanner/french.js rename to externalLanguages/scanner/french.js diff --git a/index.d.ts b/index.d.ts index 06e7a7d..d67fb75 100644 --- a/index.d.ts +++ b/index.d.ts @@ -6,7 +6,7 @@ declare namespace i18n { export function getToken(token: string, ...parameters): Promise; export function getTokenSync(token: string, ...parameters): string; export function getLanguages(): Promise; - export function taggedString(str: string, ...keys: any[]): (...keys: any[]) => string; + export function taggedString(str: string | TemplateStringsArray, ...keys: any[]): (...keys: any[]) => string; export function extend(language: string, tokens: Record): void; export function extendFromSystemPath(path: string): Promise; export function getAllTranslations(): Promise; diff --git a/index.js b/index.js index 4636791..cca7a50 100644 --- a/index.js +++ b/index.js @@ -114,6 +114,6 @@ export async function extendFromSystemPath(languagesDirPath) { } } -export async function getAllTranslations(){ +export async function getAllTranslations() { return languages; } diff --git a/languages/english.js b/languages/english.js index 669d9db..e48d224 100644 --- a/languages/english.js +++ b/languages/english.js @@ -1,8 +1,8 @@ /* eslint-disable max-len */ // Require Internal Dependencies -import { cli } from "../i18n/cli/english.js"; -import { scanner } from "../i18n/scanner/english.js"; +import cli from "../externalLanguages/cli/english.js"; +import scanner from "../externalLanguages/scanner/english.js"; import { taggedString as tS } from "../src/utils.js"; const lang = "en"; diff --git a/languages/french.js b/languages/french.js index 30303d3..3380884 100644 --- a/languages/french.js +++ b/languages/french.js @@ -1,8 +1,8 @@ /* eslint-disable max-len */ // Import Internal Dependencies -import { cli } from "../i18n/cli/french.js"; -import { scanner } from "../i18n/scanner/french.js"; +import cli from "../externalLanguages/cli/french.js"; +import scanner from "../externalLanguages/scanner/french.js"; import { taggedString as tS } from "../src/utils.js"; const lang = "fr"; diff --git a/package.json b/package.json index f96cda9..c5dd538 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nodesecure/i18n", - "version": "3.6.0", + "version": "4.0.1", "description": "NodeSecure Internationalization", "exports": "./index.js", "scripts": { @@ -34,8 +34,8 @@ "devDependencies": { "@nodesecure/eslint-config": "^1.8.0", "@nodesecure/github": "^1.2.0", - "c8": "^8.0.1", - "zup": "^0.0.1" + "c8": "^10.1.2", + "zup": "^0.0.2" }, "type": "module", "engines": { diff --git a/scripts/fetchi18n.js b/scripts/fetchi18n.js index 2369c99..0c02520 100644 --- a/scripts/fetchi18n.js +++ b/scripts/fetchi18n.js @@ -16,17 +16,31 @@ const repos = { for (const [repo, i18nFolderPath] of Object.entries(repos)) { const { location } = await github.downloadAndExtract(`NodeSecure.${repo}`, { branch: "master" }); const i18nPath = path.join(location, i18nFolderPath); - + console.log(styleText(["bold", "green"], `[INFO]`), `i18nPath: ${i18nPath}`); const french = fs.readFileSync(path.join(i18nPath, "french.js"), "utf-8"); const english = fs.readFileSync(path.join(i18nPath, "english.js"), "utf-8"); - - const frenchFilePath = path.join(process.cwd(), "i18n", repo, "french.js"); - const englishFilePath = path.join(process.cwd(), "i18n", repo, "english.js"); - fs.writeFileSync(frenchFilePath, french); - fs.writeFileSync(englishFilePath, english); + const frenchFilePath = path.join(process.cwd(), "externalLanguages", repo, "french.js"); + const englishFilePath = path.join(process.cwd(), "externalLanguages", repo, "english.js"); + + fs.mkdirSync(path.dirname(frenchFilePath), { recursive: true }); + fs.mkdirSync(path.dirname(englishFilePath), { recursive: true }); + + if (repo === "cli") { + fs.writeFileSync(frenchFilePath, french.replace( + "import { taggedString as tS } from \"@nodesecure/i18n\";", + "import { taggedString as tS } from \"../../src/utils.js\";" + )), + fs.writeFileSync(englishFilePath, english.replace( + "import { taggedString as tS } from \"@nodesecure/i18n\";", + "import { taggedString as tS } from \"../../src/utils.js\";" + )); + } else { + fs.writeFileSync(frenchFilePath, french); + fs.writeFileSync(englishFilePath, english); + } fs.rmSync(location, { recursive: true, force: true }); }