Skip to content

Commit 4ff4721

Browse files
committed
refactor(core): move report template out of core js output
1 parent dd61ae4 commit 4ff4721

32 files changed

Lines changed: 461 additions & 450 deletions

File tree

.github/workflows/studio-headless-linux.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@ jobs:
9191
- name: Build Studio
9292
run: npx nx run-many --target=build --projects=studio,@midscene/report
9393

94-
- name: Re-inject report template into @midscene/core dist
95-
run: node apps/report/scripts/inject-report-template.mjs
96-
9794
- name: Run Studio startup smoke test
9895
run: xvfb-run -a --server-args="-screen 0 1920x1080x24" pnpm --dir apps/studio run test:smoke
9996
env:

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ cd apps/playground && pnpm run dev
152152
cd apps/chrome-extension && pnpm run dev
153153
```
154154

155-
### `REPLACE_ME_WITH_REPORT_HTML` error in the report file
155+
### Missing report template errors
156156

157157
`apps/report` is not standalone at runtime. Its built `index.html` template is
158-
injected back into `packages/core/dist` during build. If report UI changes do
159-
not show up, or you see `REPLACE_ME_WITH_REPORT_HTML` in the report file, the
160-
template injection is usually stale. Rebuild the entire workspace without Nx
161-
cache to fix it:
158+
synced into `packages/core/dist/report-template/index.html` during build. If
159+
report UI changes do not show up, or the runtime says the Midscene report
160+
template is missing, rebuild the entire workspace without Nx cache to refresh
161+
the synced template:
162162

163163
```sh
164164
# Rebuild the entire project without cache

apps/android-playground/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"react-dom": "18.3.1"
1616
},
1717
"devDependencies": {
18+
"@midscene/report": "workspace:*",
1819
"@rsbuild/core": "^1.6.15",
1920
"@rsbuild/plugin-less": "^1.5.0",
2021
"@rsbuild/plugin-node-polyfill": "1.4.2",

apps/android-playground/rsbuild.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { pluginWorkspaceDev } from 'rsbuild-plugin-workspace-dev';
99
import { version as playgroundVersion } from '../../packages/playground/package.json';
1010
import {
1111
commonIgnoreWarnings,
12+
createCoreReportTemplateReplacementPlugin,
1213
createPlaygroundCopyPlugin,
1314
} from '../../scripts/rsbuild-utils.ts';
1415

@@ -63,6 +64,9 @@ export default defineConfig({
6364
pluginNodePolyfill(),
6465
pluginLess(),
6566
pluginSvgr(),
67+
createCoreReportTemplateReplacementPlugin({
68+
appDir: __dirname,
69+
}),
6670
createPlaygroundCopyPlugin(
6771
path.join(__dirname, 'dist'),
6872
path.join(__dirname, '../../packages/android-playground/static'),

apps/chrome-extension/rsbuild.config.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import { pluginSvgr } from '@rsbuild/plugin-svgr';
77
import { pluginTypeCheck } from '@rsbuild/plugin-type-check';
88
import { pluginWorkspaceDev } from 'rsbuild-plugin-workspace-dev';
99
import { version } from '../../packages/visualizer/package.json';
10-
import { commonIgnoreWarnings } from '../../scripts/rsbuild-utils.ts';
10+
import {
11+
commonIgnoreWarnings,
12+
createCoreReportTemplateReplacementPlugin,
13+
} from '../../scripts/rsbuild-utils.ts';
1114

1215
export default defineConfig({
1316
tools: {
@@ -119,6 +122,9 @@ export default defineConfig({
119122
pluginNodePolyfill(),
120123
pluginLess(),
121124
pluginSvgr(),
125+
createCoreReportTemplateReplacementPlugin({
126+
appDir: __dirname,
127+
}),
122128
pluginTypeCheck(),
123129
pluginWorkspaceDev({
124130
projects: {

apps/computer-playground/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"react-dom": "18.3.1"
1616
},
1717
"devDependencies": {
18+
"@midscene/report": "workspace:*",
1819
"@rsbuild/core": "^1.6.15",
1920
"@rsbuild/plugin-less": "^1.5.0",
2021
"@rsbuild/plugin-node-polyfill": "1.4.2",

apps/computer-playground/rsbuild.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { pluginWorkspaceDev } from 'rsbuild-plugin-workspace-dev';
99
import { version as playgroundVersion } from '../../packages/playground/package.json';
1010
import {
1111
commonIgnoreWarnings,
12+
createCoreReportTemplateReplacementPlugin,
1213
createPlaygroundCopyPlugin,
1314
} from '../../scripts/rsbuild-utils.ts';
1415

@@ -63,6 +64,9 @@ export default defineConfig({
6364
pluginNodePolyfill(),
6465
pluginLess(),
6566
pluginSvgr(),
67+
createCoreReportTemplateReplacementPlugin({
68+
appDir: __dirname,
69+
}),
6670
createPlaygroundCopyPlugin(
6771
path.join(__dirname, 'dist'),
6872
path.join(__dirname, '../../packages/computer-playground/static'),

apps/playground/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"react-dom": "18.3.1"
1919
},
2020
"devDependencies": {
21+
"@midscene/report": "workspace:*",
2122
"@midscene/web": "workspace:*",
2223
"@rsbuild/core": "^1.6.15",
2324
"@rsbuild/plugin-less": "^1.5.0",

apps/playground/rsbuild.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { pluginWorkspaceDev } from 'rsbuild-plugin-workspace-dev';
99
import { version as playgroundVersion } from '../../packages/playground/package.json';
1010
import {
1111
commonIgnoreWarnings,
12+
createCoreReportTemplateReplacementPlugin,
1213
createPlaygroundCopyPlugin,
1314
} from '../../scripts/rsbuild-utils.ts';
1415

@@ -23,6 +24,9 @@ export default defineConfig({
2324
pluginLess(),
2425
pluginNodePolyfill(),
2526
pluginSvgr(),
27+
createCoreReportTemplateReplacementPlugin({
28+
appDir: __dirname,
29+
}),
2630
createPlaygroundCopyPlugin(
2731
path.join(__dirname, 'dist'),
2832
path.join(__dirname, '../../packages/playground/static'),

apps/report/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@
1313
"generate-demo": "node scripts/generate-demo-report.mjs",
1414
"e2e": "node scripts/generate-demo-report.mjs && node ../../packages/cli/bin/midscene ./e2e/"
1515
},
16+
"nx": {
17+
"targets": {
18+
"build": {
19+
"outputs": [
20+
"{projectRoot}/dist",
21+
"{workspaceRoot}/packages/core/dist/report-template"
22+
]
23+
}
24+
}
25+
},
1626
"dependencies": {
1727
"@ant-design/icons": "^5.3.1",
1828
"@midscene/core": "workspace:*",

0 commit comments

Comments
 (0)