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:
@@ -19,9 +19,11 @@
|
||||
"license": "Apache-2.0",
|
||||
"main": "src/index.ts",
|
||||
"types": "src/index.ts",
|
||||
"bin": "bin/cli-module-build",
|
||||
"files": [
|
||||
"dist",
|
||||
"bin"
|
||||
"bin",
|
||||
"templates"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "backstage-cli package build",
|
||||
@@ -98,6 +100,5 @@
|
||||
"@types/lodash": "^4.14.151",
|
||||
"@types/npm-packlist": "^3.0.0",
|
||||
"@types/shell-quote": "^1.7.5"
|
||||
},
|
||||
"bin": "bin/cli-module-build"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#000000" />
|
||||
<meta
|
||||
name="description"
|
||||
content="Backstage is an open source framework for building developer portals"
|
||||
/>
|
||||
<title>Backstage</title>
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
<!--
|
||||
This HTML file is a template.
|
||||
If you open it directly in the browser, you will see an empty page.
|
||||
|
||||
You can add webfonts, meta tags, or analytics to this file.
|
||||
The build step will place the bundled scripts into the <body> tag.
|
||||
|
||||
To begin the development, run `yarn start`.
|
||||
To create a production bundle, use `yarn build`.
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user