From 38c8a85cbaecf37883ec65973a716a5d26f14f20 Mon Sep 17 00:00:00 2001 From: Tibor Blenessy Date: Fri, 29 Nov 2024 11:15:43 +0100 Subject: [PATCH] Fix typedoc: Migrate to ESM --- .github/workflows/typedoc.yml | 2 +- .../{index.js => index.mjs} | 6 +++--- typedoc/searchable-parameters-plugin/package.json | 4 ++-- .../{setup.js => setup.mjs} | 13 +++++++++---- 4 files changed, 15 insertions(+), 10 deletions(-) rename typedoc/searchable-parameters-plugin/{index.js => index.mjs} (96%) rename typedoc/searchable-parameters-plugin/{setup.js => setup.mjs} (79%) diff --git a/.github/workflows/typedoc.yml b/.github/workflows/typedoc.yml index f0251e83f5d..0bd88b97657 100644 --- a/.github/workflows/typedoc.yml +++ b/.github/workflows/typedoc.yml @@ -16,7 +16,7 @@ jobs: ARTIFACTORY_URL: https://repox.jfrog.io/artifactory steps: - name: Checkout 🛎️ - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Get vault secrets id: secrets uses: SonarSource/vault-action-wrapper@v3 diff --git a/typedoc/searchable-parameters-plugin/index.js b/typedoc/searchable-parameters-plugin/index.mjs similarity index 96% rename from typedoc/searchable-parameters-plugin/index.js rename to typedoc/searchable-parameters-plugin/index.mjs index 831b11ff4ac..6947f35cbaf 100644 --- a/typedoc/searchable-parameters-plugin/index.js +++ b/typedoc/searchable-parameters-plugin/index.mjs @@ -14,9 +14,9 @@ * You should have received a copy of the Sonar Source-Available License * along with this program; if not, see https://sonarsource.com/license/ssal/ */ -const { Renderer } = require('typedoc'); +import { Renderer } from 'typedoc'; -module.exports.load = function load(app) { +export function load(app) { app.renderer.on(Renderer.EVENT_PREPARE_INDEX, event => { for (const [index, result] of event.searchResults.entries()) { // To see what is available on a event.searchResults element, see the reflections.json in the generated files @@ -34,7 +34,7 @@ module.exports.load = function load(app) { // https://github.com/TypeStrong/typedoc/blob/56813c0cb201f0c248a0cc43ef6e7578d680191c/src/lib/output/plugins/JavascriptIndexPlugin.ts#L89 event.searchFieldWeights.parameters = 5; }); -}; +} /** * Initialises object[propName] to '' diff --git a/typedoc/searchable-parameters-plugin/package.json b/typedoc/searchable-parameters-plugin/package.json index 553b929734a..032b2ddd647 100644 --- a/typedoc/searchable-parameters-plugin/package.json +++ b/typedoc/searchable-parameters-plugin/package.json @@ -2,9 +2,9 @@ "name": "searchable-parameters-plugin", "version": "1.0.0", "description": "Plugin for Typedoc that makes functions searchable by parameter types", - "main": "index.js", + "main": "index.mjs", "scripts": { - "setup": "node setup.js" + "setup": "node setup.mjs" }, "keywords": [ "typedoc-plugin" diff --git a/typedoc/searchable-parameters-plugin/setup.js b/typedoc/searchable-parameters-plugin/setup.mjs similarity index 79% rename from typedoc/searchable-parameters-plugin/setup.js rename to typedoc/searchable-parameters-plugin/setup.mjs index 15a20904498..c8eeb79e635 100644 --- a/typedoc/searchable-parameters-plugin/setup.js +++ b/typedoc/searchable-parameters-plugin/setup.mjs @@ -16,11 +16,16 @@ */ // typedoc looks for plugins in node_modules/, therefore we create a symlink to this folder in node_modules/ -const fs = require('fs'); -const path = require('path'); +import fs from 'fs'; +import path from 'path'; +import url from 'url'; + +// Directory name of the current module +const __dirname = path.dirname(url.fileURLToPath(import.meta.url)); const linkPath = path.join(__dirname, '..', '..', 'node_modules', 'searchable-parameters-plugin'); const targetPath = path.join(__dirname); -if (fs.existsSync(linkPath)) return; -fs.symlinkSync(targetPath, linkPath); +if (!fs.existsSync(linkPath)) { + fs.symlinkSync(targetPath, linkPath); +}