build-start-rebuild-perf 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.release-plan.json +6 -6
- package/CHANGELOG.md +11 -0
- package/README.md +8 -6
- package/lib/browser.js +2 -2
- package/lib/measure.js +5 -1
- package/lib/program.js +5 -0
- package/package.json +1 -1
- package/test/cli.test.js +33 -18
package/.release-plan.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"solution": {
|
|
3
3
|
"build-start-rebuild-perf": {
|
|
4
|
-
"impact": "
|
|
5
|
-
"oldVersion": "0.2.
|
|
6
|
-
"newVersion": "0.
|
|
4
|
+
"impact": "minor",
|
|
5
|
+
"oldVersion": "0.2.3",
|
|
6
|
+
"newVersion": "0.3.0",
|
|
7
7
|
"tagName": "latest",
|
|
8
8
|
"constraints": [
|
|
9
9
|
{
|
|
10
|
-
"impact": "
|
|
11
|
-
"reason": "Appears in changelog section :
|
|
10
|
+
"impact": "minor",
|
|
11
|
+
"reason": "Appears in changelog section :rocket: Enhancement"
|
|
12
12
|
}
|
|
13
13
|
],
|
|
14
14
|
"pkgJSONPath": "./package.json"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
-
"description": "## Release (2025-08-
|
|
17
|
+
"description": "## Release (2025-08-25)\n\n* build-start-rebuild-perf 0.3.0 (minor)\n\n#### :rocket: Enhancement\n* `build-start-rebuild-perf`\n * [#41](https://github.com/mainmatter/build-start-rebuild-perf/pull/41) add option to have a custom page-load-timeout ([@mansona](https://github.com/mansona))\n\n#### Committers: 1\n- Chris Manson ([@mansona](https://github.com/mansona))\n"
|
|
18
18
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Release (2025-08-25)
|
|
4
|
+
|
|
5
|
+
* build-start-rebuild-perf 0.3.0 (minor)
|
|
6
|
+
|
|
7
|
+
#### :rocket: Enhancement
|
|
8
|
+
* `build-start-rebuild-perf`
|
|
9
|
+
* [#41](https://github.com/mainmatter/build-start-rebuild-perf/pull/41) add option to have a custom page-load-timeout ([@mansona](https://github.com/mansona))
|
|
10
|
+
|
|
11
|
+
#### Committers: 1
|
|
12
|
+
- Chris Manson ([@mansona](https://github.com/mansona))
|
|
13
|
+
|
|
3
14
|
## Release (2025-08-13)
|
|
4
15
|
|
|
5
16
|
* build-start-rebuild-perf 0.2.3 (patch)
|
package/README.md
CHANGED
|
@@ -24,12 +24,14 @@ pnpm dlx build-start-rebuild-perf --file "app/router.js" --wait-for ".logo"
|
|
|
24
24
|
## Options
|
|
25
25
|
|
|
26
26
|
```
|
|
27
|
-
-u, --url <url>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
-u, --url <url> URL to load (default: "http://localhost:4200")
|
|
28
|
+
-f, --file <path> File to touch to trigger a reload (no default, but app/router.js is an option)
|
|
29
|
+
-c, --command <cmd> Command to start dev server (default: "pnpm start")
|
|
30
|
+
-w, --wait-for <selector> Element selector to wait for (default: "body")
|
|
31
|
+
-t, --timeout <timeout ms> number of ms to wait for the server to become ready (default: "120000")
|
|
32
|
+
--page-load-timeout <timeout ms> number of ms to wait in the browser for the pageload event (default: "60000")
|
|
33
|
+
-l, --log-level <level> Set the log level (choices: "log", "warn", "error")
|
|
34
|
+
-h, --help display help for command
|
|
33
35
|
```
|
|
34
36
|
|
|
35
37
|
## Example Output
|
package/lib/browser.js
CHANGED
|
@@ -49,11 +49,11 @@ export async function initBrowser() {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
export async function measurePageLoad(url, waitForSelector = "body") {
|
|
52
|
+
export async function measurePageLoad(url, waitForSelector = "body", pageLoadTimeout = 60_000) {
|
|
53
53
|
log(`Loading page: ${url}`);
|
|
54
54
|
|
|
55
55
|
const response = await page.goto(url, {
|
|
56
|
-
timeout:
|
|
56
|
+
timeout: pageLoadTimeout,
|
|
57
57
|
waitUntil: "load",
|
|
58
58
|
});
|
|
59
59
|
|
package/lib/measure.js
CHANGED
|
@@ -28,7 +28,11 @@ export async function measure(options) {
|
|
|
28
28
|
const atStart = performance.now();
|
|
29
29
|
const serverURL = await startServer(options);
|
|
30
30
|
const atServerUp = performance.now();
|
|
31
|
-
const pageLoadMetrics = await measurePageLoad(
|
|
31
|
+
const pageLoadMetrics = await measurePageLoad(
|
|
32
|
+
serverURL,
|
|
33
|
+
options.waitFor,
|
|
34
|
+
options.pageLoadTimeout,
|
|
35
|
+
);
|
|
32
36
|
const reloadMetrics = await measureFileReload(options.file);
|
|
33
37
|
await terminateServer();
|
|
34
38
|
|
package/lib/program.js
CHANGED
|
@@ -14,6 +14,11 @@ program
|
|
|
14
14
|
"number of ms to wait for the server to become ready",
|
|
15
15
|
"120000",
|
|
16
16
|
)
|
|
17
|
+
.option(
|
|
18
|
+
"--page-load-timeout <timeout ms>",
|
|
19
|
+
"number of ms to wait in the browser for the pageload event",
|
|
20
|
+
"60000",
|
|
21
|
+
)
|
|
17
22
|
.addOption(
|
|
18
23
|
new Option("-l, --log-level <level>", "Set the log level", "warn").choices([
|
|
19
24
|
"log",
|
package/package.json
CHANGED
package/test/cli.test.js
CHANGED
|
@@ -2,9 +2,23 @@ import { resolve } from "node:path";
|
|
|
2
2
|
import { execa } from "execa";
|
|
3
3
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {string[]} extraArgs an array of args to pass to the script
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
function runCommand(extraArgs) {
|
|
11
|
+
return execa("node", ["../bin/cli.js", "--command", "pnpm start", ...extraArgs], {
|
|
12
|
+
cwd: resolve(import.meta.dirname, "..", "test-ember-app"),
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
5
16
|
describe("CLI Tests", () => {
|
|
6
17
|
describe(
|
|
7
18
|
"Returns result for an Ember CLI app",
|
|
19
|
+
{
|
|
20
|
+
timeout: 120000,
|
|
21
|
+
},
|
|
8
22
|
() => {
|
|
9
23
|
const killStrays = async () => {
|
|
10
24
|
try {
|
|
@@ -17,21 +31,7 @@ describe("CLI Tests", () => {
|
|
|
17
31
|
afterEach(killStrays);
|
|
18
32
|
|
|
19
33
|
it("should return measurements", async () => {
|
|
20
|
-
const cmd = await
|
|
21
|
-
"node",
|
|
22
|
-
[
|
|
23
|
-
"../bin/cli.js",
|
|
24
|
-
"--command",
|
|
25
|
-
"pnpm start",
|
|
26
|
-
"--wait-for",
|
|
27
|
-
"h1",
|
|
28
|
-
"--file",
|
|
29
|
-
"./app/router.js",
|
|
30
|
-
],
|
|
31
|
-
{
|
|
32
|
-
cwd: resolve(import.meta.dirname, "..", "test-ember-app"),
|
|
33
|
-
},
|
|
34
|
-
);
|
|
34
|
+
const cmd = await runCommand(["--wait-for", "h1", "--file", "./app/router.js"]);
|
|
35
35
|
|
|
36
36
|
console.log(cmd.stdout);
|
|
37
37
|
console.error(cmd.stderr);
|
|
@@ -42,9 +42,24 @@ describe("CLI Tests", () => {
|
|
|
42
42
|
"| Dev Server Ready | First Paint | App Loaded | Reload after change |",
|
|
43
43
|
);
|
|
44
44
|
});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
|
|
46
|
+
it("should throw an error if --page-load-timeout is passed as something very low", async () => {
|
|
47
|
+
let cmd;
|
|
48
|
+
try {
|
|
49
|
+
cmd = await runCommand([
|
|
50
|
+
"--wait-for",
|
|
51
|
+
"h1",
|
|
52
|
+
"--file",
|
|
53
|
+
"./app/router.js",
|
|
54
|
+
"--page-load-timeout",
|
|
55
|
+
"100",
|
|
56
|
+
]);
|
|
57
|
+
} catch (err) {
|
|
58
|
+
expect(err.stderr).toContain(`TimeoutError: Navigation timeout of 100 ms exceeded`);
|
|
59
|
+
}
|
|
60
|
+
// we expect the runCommand to throw. This is to make sure that we go into the catch block and don't "accidentally succeed"
|
|
61
|
+
expect(cmd).to.be.undefined;
|
|
62
|
+
});
|
|
48
63
|
},
|
|
49
64
|
);
|
|
50
65
|
});
|