build-start-rebuild-perf 0.1.0 → 0.2.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 +3 -3
- package/CHANGELOG.md +11 -0
- package/lib/program.js +5 -0
- package/lib/server.js +5 -3
- package/lib/utils.js +12 -0
- package/package.json +1 -1
package/.release-plan.json
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
"solution": {
|
|
3
3
|
"build-start-rebuild-perf": {
|
|
4
4
|
"impact": "minor",
|
|
5
|
-
"oldVersion": "0.0
|
|
6
|
-
"newVersion": "0.
|
|
5
|
+
"oldVersion": "0.1.0",
|
|
6
|
+
"newVersion": "0.2.0",
|
|
7
7
|
"tagName": "latest",
|
|
8
8
|
"constraints": [
|
|
9
9
|
{
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
"pkgJSONPath": "./package.json"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
-
"description": "## Release (2025-08-
|
|
17
|
+
"description": "## Release (2025-08-09)\n\n* build-start-rebuild-perf 0.2.0 (minor)\n\n#### :rocket: Enhancement\n* `build-start-rebuild-perf`\n * [#23](https://github.com/mainmatter/build-start-rebuild-perf/pull/23) Configurable timeout ([@NullVoxPopuli](https://github.com/NullVoxPopuli))\n\n#### Committers: 1\n- [@NullVoxPopuli](https://github.com/NullVoxPopuli)\n"
|
|
18
18
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Release (2025-08-09)
|
|
4
|
+
|
|
5
|
+
* build-start-rebuild-perf 0.2.0 (minor)
|
|
6
|
+
|
|
7
|
+
#### :rocket: Enhancement
|
|
8
|
+
* `build-start-rebuild-perf`
|
|
9
|
+
* [#23](https://github.com/mainmatter/build-start-rebuild-perf/pull/23) Configurable timeout ([@NullVoxPopuli](https://github.com/NullVoxPopuli))
|
|
10
|
+
|
|
11
|
+
#### Committers: 1
|
|
12
|
+
- [@NullVoxPopuli](https://github.com/NullVoxPopuli)
|
|
13
|
+
|
|
3
14
|
## Release (2025-08-08)
|
|
4
15
|
|
|
5
16
|
* build-start-rebuild-perf 0.1.0 (minor)
|
package/lib/program.js
CHANGED
|
@@ -9,6 +9,11 @@ program
|
|
|
9
9
|
.option("-f, --file <path>", "File to touch to trigger a reload")
|
|
10
10
|
.option("-c, --command <cmd>", "Command to start dev server", "pnpm start")
|
|
11
11
|
.option("-w, --wait-for <selector>", "Element selector to wait for", "body")
|
|
12
|
+
.option(
|
|
13
|
+
"-t, --timeout <timeout ms>",
|
|
14
|
+
"number of ms to wait for the server to become ready",
|
|
15
|
+
"120000",
|
|
16
|
+
)
|
|
12
17
|
.addOption(
|
|
13
18
|
new Option("-l, --log-level <level>", "Set the log level", "warn").choices([
|
|
14
19
|
"log",
|
package/lib/server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { execa } from "execa";
|
|
2
2
|
import stripAnsi from "strip-ansi";
|
|
3
3
|
import { log, warn } from "./log.js";
|
|
4
|
-
import { PrefixedTransform } from "./utils.js";
|
|
4
|
+
import { PrefixedTransform, parseNumber } from "./utils.js";
|
|
5
5
|
|
|
6
6
|
let server = null;
|
|
7
7
|
|
|
@@ -30,11 +30,13 @@ export async function startServer(options, extraArgs = "") {
|
|
|
30
30
|
|
|
31
31
|
log("Waiting for server to start...");
|
|
32
32
|
|
|
33
|
+
let timeout = parseNumber(options.timeout);
|
|
34
|
+
|
|
33
35
|
// Wait for server to be ready by watching output
|
|
34
36
|
await new Promise((resolve, reject) => {
|
|
35
37
|
const timeoutId = setTimeout(() => {
|
|
36
|
-
reject(new Error(
|
|
37
|
-
},
|
|
38
|
+
reject(new Error(`Server start timeout ( waited ${timeout}ms )`));
|
|
39
|
+
}, timeout);
|
|
38
40
|
|
|
39
41
|
const urlToMatch = `//${new URL(options.url).host}`;
|
|
40
42
|
const checkOutput = (line) => {
|
package/lib/utils.js
CHANGED
|
@@ -43,3 +43,15 @@ const formatter = Intl.NumberFormat("en-US", {
|
|
|
43
43
|
export function formatMs(timeMs) {
|
|
44
44
|
return formatter.format(Math.round(timeMs));
|
|
45
45
|
}
|
|
46
|
+
|
|
47
|
+
export function parseNumber(maybeNum) {
|
|
48
|
+
if (!maybeNum) return fallback;
|
|
49
|
+
|
|
50
|
+
let result = parseInt(maybeNum, 10);
|
|
51
|
+
|
|
52
|
+
if (Number.isNaN(result)) {
|
|
53
|
+
throw new Error(`Expected ${maybeNum} to be parsable to an integer. Instead received NaN.`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return result;
|
|
57
|
+
}
|