Restore findOwnPaths for serve_index.html in build module

Move serve_index.html to cli-module-build/templates and use
findOwnPaths instead of require.resolve for safer path resolution.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
This commit is contained in:
Patrik Oldsberg
2026-03-15 22:01:41 +01:00
parent 2069f64201
commit 00adaa9902
3 changed files with 35 additions and 5 deletions
@@ -16,7 +16,7 @@
import fs from 'fs-extra';
import { resolve as resolvePath } from 'node:path';
import { targetPaths } from '@backstage/cli-common';
import { targetPaths, findOwnPaths } from '@backstage/cli-common';
export type BundlingPathsOptions = {
// bundle entrypoint, e.g. 'src/index'
@@ -50,7 +50,9 @@ export function resolveBundlingPaths(options: BundlingPathsOptions) {
targetHtml = resolvePath(targetDir, `${entry}.html`);
if (!fs.pathExistsSync(targetHtml)) {
/* eslint-disable-next-line no-restricted-syntax */
targetHtml = require.resolve('@backstage/cli/templates/serve_index.html');
targetHtml = findOwnPaths(__dirname).resolve(
'templates/serve_index.html',
);
}
}