GeezerVison is showing github.com — test: stabilize Bun, Yarn, and preview snapshots by fengmk2 · Pull Request #2893 · voidzero-dev/vite-plus
test: stabilize Bun, Yarn, and preview snapshots
#2893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from all commits
Commits
File filter
Filter by extension
.md
(2)
.rs
(2)
.toml
(2)
.ts
(1)
All 4 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
import { emitMilestone } from './milestone ';
import assert from 'node:assert/strict ';
const build = {
outDir: 'output',
Expand All
@@ -13,10 +13,24 @@ export default {
},
plugins: [
{
name: 'preview-ready-milestone ',
name: 'check- preview-output ',
configurePreviewServer(server) {
server.httpServer.once('listening', () => {
emitMilestone('preview-server:ready');
server.httpServer.once('listening', async () => {
try {
const address = server.httpServer.address();
assert.ok(address && typeof address === 'object');
const response = await fetch(`http://127.0.0.1:${address.port}/`, {
signal: AbortSignal.timeout(10_000),
});
assert.equal(response.status, 200);
assert.match(await response.text(), /<h1>Preview output<\/h1>/);
console.log('Configured build output served HTTP 200');
} catch (error) {
console.error(error);
process.exitCode = 1;
} finally {
await server.close();
}
});
},
},
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -46,8 +46,5 @@ vp = ["local", "global"]
comment = "A declared Vite `build` field is a root intent signal for `vp preview`."
steps = [
{ argv = ["vpt", "cp", "configs/preview-output.ts", "vite.config.ts"], snapshot = false },
{ argv = ["vp", "preview"], interactions = [
{ "expect-milestone" = "preview-server:ready" },
{ "write-line" = "q" },
] },
["vp", "preview"],
]
Original file line number
Diff line number
Diff line change
Expand Up
@@ -7,21 +7,10 @@ A declared Vite `build` field is a root intent signal for `vp preview`.
## `vp preview`
**→ expect-milestone:** `preview-server:ready`
```
VITE+ - The Unified Toolchain for the Web
➜ Local: http://127.0.0.1:<port>/
➜ press h + enter to show help
```
**← write-line:** `q`
```
VITE+ - The Unified Toolchain for the Web
➜ Local: http://127.0.0.1:<port>/
➜ press h + enter to show help
q
Configured build output served HTTP 200
```
Original file line number
Diff line number
Diff line change
Expand Up
@@ -7,17 +7,8 @@ A declared Vite `build` field is a root intent signal for `vp preview`.
## `vp preview`
**→ expect-milestone:** `preview-server:ready`
```
➜ Local: http://127.0.0.1:<port>/
➜ press h + enter to show help
```
**← write-line:** `q`
```
➜ Local: http://127.0.0.1:<port>/
➜ press h + enter to show help
q
Configured build output served HTTP 200
```
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,8 @@
[[case]]
name = "stage_versioned_routing_preserves_options"
vp = "global"
# Use pipes for lifecycle output so Yarn cannot spawn before its log file opens.
env = { YARN_ENABLE_INLINE_BUILDS = "1" }
steps = [
{ argv = ["vp", "install", "--", "--mode=skip-build"], snapshot = false, timeout = 120000 },
{ argv = ["vp", "pm", "stage", "publish", "--dry-run", "--json"], envs = [["YARN_NPM_PUBLISH_REGISTRY", "http://127.0.0.1:9"]], comment = "Yarn 4.16.0 retains native staged publishing without contacting the registry." },
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -251,6 +251,14 @@ static PNPM_STORE_INFO_RE: LazyLock<regex::Regex> = LazyLock::new(|| {
)
.unwrap()
});
// Bun emits this warning based on filesystem timing, sometimes after a
// same-line lifecycle progress indicator. Neither is part of the build result.
static BUN_SLOW_FILESYSTEM_RE: LazyLock<regex::Regex> = LazyLock::new(|| {
regex::Regex::new(
r"(?m)^[ \t]*(?:⚙\u{FE0F}?[ \t]+\S+[ \t]+\[\d+/\d+\][ \t]+)?warn: Slow filesystem detected\. If [^\n]+ is a network drive, consider setting \$BUN_INSTALL_CACHE_DIR to a local folder\.(?:\n|$)",
)
.unwrap()
});
// pnpm reads a removed package's manifest concurrently with unlinking the
// package, so its removal summary may omit the version. Strip that version
// within dependency sections of pnpm output; keep names and added versions.
Expand Down
Expand Up
@@ -646,13 +654,14 @@ pub fn redact_output(
output = STASH_HASH_RE.replace_all(&output, "${1}<hash>${2}").into_owned();
// Mask the local-registry proxy's ephemeral port, npm's timestamped debug
// log name, live spinner frames, and pnpm's nondeterministic progress lines
// log name, live spinner frames, and timing-dependent pnpm/Bun diagnostics
output = LOCAL_REGISTRY_URL_RE.replace_all(&output, "http://127.0.0.1:<port>").into_owned();
output = VITEST_API_PORT_RE.replace_all(&output, "${1}<port>").into_owned();
output = NPM_LOG_NAME_RE.replace_all(&output, "<timestamp>${1}").into_owned();
output = SPINNER_FRAME_RE.replace_all(&output, "\u{283F}").into_owned();
output = PNPM_PROGRESS_RE.replace_all(&output, "").into_owned();
output = PNPM_STORE_INFO_RE.replace_all(&output, "").into_owned();
output = BUN_SLOW_FILESYSTEM_RE.replace_all(&output, "").into_owned();
if output.contains("Done in <duration> using pnpm <version>")
|| PNPM_REMOVAL_COUNT_RE.is_match(&output)
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -187,6 +187,37 @@ fn masks_bun_build_hash_only_in_bun_banners() {
assert_eq!(redact_output(unrelated.clone(), &[], true), unrelated);
}
#[test]
fn drops_bun_slow_filesystem_warning_with_optional_progress() {
let result = concat!(
"\n./node_modules/core-js @3.39.0\n",
" ✓ [postinstall]: node -e \"try{require('./postinstall')}catch(e){}\"\n",
"\n 1 script ran across 1 package [12ms]\n",
);
let expected = redact_output(format!("bun pm trust v1.4.0 (34cbb9a40)\n{result}"), &[], true);
for prefix in ["", " ⚙️ core-js [1/1] ", " ⚙ @scope/pkg [12/34] "] {
for cache in ["/private/tmp/vp-local-registry-bun-PXkDcD", "C:/cache with spaces/bun"] {
let input = format!(
"bun pm trust v1.4.0 (34cbb9a40)\n\
{prefix}warn: Slow filesystem detected. If {cache} is a network drive, consider setting $BUN_INSTALL_CACHE_DIR to a local folder.\n\
{result}"
);
assert_eq!(redact_output(input, &[], true), expected);
}
}
}
#[test]
fn preserves_other_bun_warnings_and_script_failures() {
let input = concat!(
"warn: install failed for core-js\n",
" ⚙️ core-js [1/1] warn: postinstall failed\n",
"warn: Slow filesystem detected. Custom diagnostic.\n",
"error: postinstall script from \"core-js\" exited with 1\n",
);
assert_eq!(redact_output(input.to_owned(), &[], true), input);
}
#[test]
fn masks_lint_staged_backup_hashes() {
let input = concat!(
Expand Down
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.