From d1887280d99823a55be887d635c1c4b2a9b89785 Mon Sep 17 00:00:00 2001 From: patroswastik Date: Thu, 27 Feb 2025 16:19:31 -0600 Subject: [PATCH 1/6] add specific check for @deprecated tag in router files Signed-off-by: patroswastik --- .../lint-legacy-backend-exports.ts | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/packages/repo-tools/src/commands/lint-legacy-backend-exports/lint-legacy-backend-exports.ts b/packages/repo-tools/src/commands/lint-legacy-backend-exports/lint-legacy-backend-exports.ts index 6025defe31..0ebc7088e3 100644 --- a/packages/repo-tools/src/commands/lint-legacy-backend-exports/lint-legacy-backend-exports.ts +++ b/packages/repo-tools/src/commands/lint-legacy-backend-exports/lint-legacy-backend-exports.ts @@ -46,10 +46,15 @@ function verifyIndex(pkg: string, packageJson?: BackstagePackageJson) { console.log(`Verifying ${pkg}`); const tsPath = path.join(pkg, 'src/index.ts'); const sourceFile = project.getSourceFile(tsPath); + + const tsRouterPath = path.join(pkg, 'src/service/router.ts'); + const routerFile = project.getSourceFile(tsRouterPath); + if (!sourceFile) { console.log(`Could not find ${tsPath}`); process.exit(1); } + const symbols = sourceFile?.getExportSymbols(); const exportCount = symbols?.length || 0; @@ -75,9 +80,23 @@ function verifyIndex(pkg: string, packageJson?: BackstagePackageJson) { .find(tag => tag.getName() === 'deprecated'); } + let routerCreateRouterDeprecated = undefined; + if (routerFile) { + const routerSymbols = routerFile?.getExportSymbols(); + const routerCreateRouterExport = routerSymbols?.find( + symbol => symbol.getName() === 'createRouter', + ); + + if (routerCreateRouterExport) { + routerCreateRouterDeprecated = routerCreateRouterExport + .getJsDocTags() + .find(tag => tag.getName() === 'deprecated'); + } + } + if (createRouterExport) { console.log(' ❌ createRouter is exported'); - if (!createRouterDeprecated) + if (!createRouterDeprecated && !routerCreateRouterDeprecated) console.log(' ❌ createRouter is NOT deprecated'); } From 18ce51c5b6d88720d131dbdbb022ce6bec4506cb Mon Sep 17 00:00:00 2001 From: patroswastik Date: Thu, 27 Feb 2025 17:20:24 -0600 Subject: [PATCH 2/6] Changeset added as per guide Signed-off-by: patroswastik --- .changeset/rich-phones-whisper.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/rich-phones-whisper.md diff --git a/.changeset/rich-phones-whisper.md b/.changeset/rich-phones-whisper.md new file mode 100644 index 0000000000..c27b6de2f8 --- /dev/null +++ b/.changeset/rich-phones-whisper.md @@ -0,0 +1,5 @@ +--- +'@backstage/repo-tools': minor +--- + +Checking through router.ts files of the packages if they exist and looking for deprecated tag inside it. If exists then only the message will appear From 4b8db95f4f5f97839bbb0246d15c8582f204e5f4 Mon Sep 17 00:00:00 2001 From: patroswastik Date: Sun, 13 Apr 2025 06:08:41 -0500 Subject: [PATCH 3/6] went up the tree to locate createRouter and found deprecated over there Signed-off-by: patroswastik --- .../lint-legacy-backend-exports.ts | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/packages/repo-tools/src/commands/lint-legacy-backend-exports/lint-legacy-backend-exports.ts b/packages/repo-tools/src/commands/lint-legacy-backend-exports/lint-legacy-backend-exports.ts index 0ebc7088e3..29fb4e7b20 100644 --- a/packages/repo-tools/src/commands/lint-legacy-backend-exports/lint-legacy-backend-exports.ts +++ b/packages/repo-tools/src/commands/lint-legacy-backend-exports/lint-legacy-backend-exports.ts @@ -47,9 +47,6 @@ function verifyIndex(pkg: string, packageJson?: BackstagePackageJson) { const tsPath = path.join(pkg, 'src/index.ts'); const sourceFile = project.getSourceFile(tsPath); - const tsRouterPath = path.join(pkg, 'src/service/router.ts'); - const routerFile = project.getSourceFile(tsRouterPath); - if (!sourceFile) { console.log(`Could not find ${tsPath}`); process.exit(1); @@ -74,23 +71,28 @@ function verifyIndex(pkg: string, packageJson?: BackstagePackageJson) { console.log(' ❌ Missing default export'); } let createRouterDeprecated = undefined; + let routerCreateRouterDeprecated = undefined; if (createRouterExport) { createRouterDeprecated = createRouterExport .getJsDocTags() .find(tag => tag.getName() === 'deprecated'); - } - let routerCreateRouterDeprecated = undefined; - if (routerFile) { - const routerSymbols = routerFile?.getExportSymbols(); - const routerCreateRouterExport = routerSymbols?.find( - symbol => symbol.getName() === 'createRouter', - ); - - if (routerCreateRouterExport) { - routerCreateRouterDeprecated = routerCreateRouterExport - .getJsDocTags() - .find(tag => tag.getName() === 'deprecated'); + const declarations = createRouterExport?.getDeclarations(); + const firstDeclaration = declarations?.[0]; + let resolvedSymbol = undefined; + if (firstDeclaration) { + // Try resolving to the definition directly + resolvedSymbol = createRouterExport.getAliasedSymbol(); + if (resolvedSymbol) { + const resolvedDeclarations = resolvedSymbol.getDeclarations(); + const resolvedDeclaration = resolvedDeclarations?.[0]; + if (resolvedDeclaration) { + routerCreateRouterDeprecated = resolvedDeclaration + .getSymbol() + ?.getJsDocTags() + .find(tag => tag.getName() === 'deprecated'); + } + } } } From 7d0bd52f7ac6ede005fc57edd23e33fea564f5f4 Mon Sep 17 00:00:00 2001 From: patroswastik Date: Sun, 13 Apr 2025 06:43:39 -0500 Subject: [PATCH 4/6] Changeset updated with relevant description of the fix Signed-off-by: patroswastik --- .changeset/rich-phones-whisper.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/rich-phones-whisper.md b/.changeset/rich-phones-whisper.md index c27b6de2f8..31d4bdb57f 100644 --- a/.changeset/rich-phones-whisper.md +++ b/.changeset/rich-phones-whisper.md @@ -2,4 +2,4 @@ '@backstage/repo-tools': minor --- -Checking through router.ts files of the packages if they exist and looking for deprecated tag inside it. If exists then only the message will appear +Checking up the files where createRouter has been declared and check if @deprecated tag exists. If it does not exist then only the message will appear. From 06aa4bdc69e0958215f668f66058f1815cdfd636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Mon, 14 Apr 2025 10:59:36 +0200 Subject: [PATCH 5/6] Update .changeset/rich-phones-whisper.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/rich-phones-whisper.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/rich-phones-whisper.md b/.changeset/rich-phones-whisper.md index 31d4bdb57f..3f3c226690 100644 --- a/.changeset/rich-phones-whisper.md +++ b/.changeset/rich-phones-whisper.md @@ -2,4 +2,4 @@ '@backstage/repo-tools': minor --- -Checking up the files where createRouter has been declared and check if @deprecated tag exists. If it does not exist then only the message will appear. +Checking up the files where `createRouter` has been declared and check if `@deprecated` tag exists. If it does not exist then only the message will appear. From 9663a04fcde1cb9bc05ef06f7239f85c6fb4625d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Adel=C3=B6w?= Date: Mon, 14 Apr 2025 10:59:41 +0200 Subject: [PATCH 6/6] Update .changeset/rich-phones-whisper.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fredrik Adelöw --- .changeset/rich-phones-whisper.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/rich-phones-whisper.md b/.changeset/rich-phones-whisper.md index 3f3c226690..75f0fc0c35 100644 --- a/.changeset/rich-phones-whisper.md +++ b/.changeset/rich-phones-whisper.md @@ -1,5 +1,5 @@ --- -'@backstage/repo-tools': minor +'@backstage/repo-tools': patch --- Checking up the files where `createRouter` has been declared and check if `@deprecated` tag exists. If it does not exist then only the message will appear.