mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2026-02-01 17:26:34 +00:00
Fix integration tests on Windows (#14824)
This PR fixes Windows related path issues after merging #14820 --------- Co-authored-by: Jordan Pittman <jordan@cryptica.me>
This commit is contained in:
parent
e52bf2eca8
commit
f3786253f2
3
crates/node/npm/win32-arm64-msvc/README.md
Normal file
3
crates/node/npm/win32-arm64-msvc/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# `@tailwindcss/oxide-win32-arm64-msvc`
|
||||
|
||||
This is the **arm64-pc-windows-msvc** binary for `@tailwindcss/oxide`
|
||||
27
crates/node/npm/win32-arm64-msvc/package.json
Normal file
27
crates/node/npm/win32-arm64-msvc/package.json
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "@tailwindcss/oxide-win32-arm64-msvc",
|
||||
"version": "4.0.0-alpha.30",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/tailwindlabs/tailwindcss.git",
|
||||
"directory": "crates/node/npm/win32-arm64-msvc"
|
||||
},
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"main": "tailwindcss-oxide.win32-arm64-msvc.node",
|
||||
"files": [
|
||||
"tailwindcss-oxide.win32-arm64-msvc.node"
|
||||
],
|
||||
"publishConfig": {
|
||||
"provenance": true,
|
||||
"access": "public"
|
||||
},
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
}
|
||||
}
|
||||
@ -20,7 +20,8 @@
|
||||
"armv7-unknown-linux-gnueabihf",
|
||||
"x86_64-unknown-linux-musl",
|
||||
"x86_64-unknown-freebsd",
|
||||
"i686-pc-windows-msvc"
|
||||
"i686-pc-windows-msvc",
|
||||
"aarch64-pc-windows-msvc"
|
||||
]
|
||||
}
|
||||
},
|
||||
@ -56,6 +57,7 @@
|
||||
"@tailwindcss/oxide-linux-arm64-musl": "workspace:*",
|
||||
"@tailwindcss/oxide-linux-x64-gnu": "workspace:*",
|
||||
"@tailwindcss/oxide-linux-x64-musl": "workspace:*",
|
||||
"@tailwindcss/oxide-win32-x64-msvc": "workspace:*"
|
||||
"@tailwindcss/oxide-win32-x64-msvc": "workspace:*",
|
||||
"@tailwindcss/oxide-win32-arm64-msvc": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,15 +237,18 @@ mod tests {
|
||||
|
||||
let optimized_sources = optimize_patterns(&sources);
|
||||
|
||||
let parent_dir = format!("{}", fs::canonicalize(base).unwrap().display());
|
||||
let parent_dir =
|
||||
format!("{}{}", dunce::canonicalize(base).unwrap().display(), "/").replace('\\', "/");
|
||||
|
||||
// Remove the temporary directory from the base
|
||||
optimized_sources
|
||||
.into_iter()
|
||||
.map(|source| GlobEntry {
|
||||
// Normalize paths to use unix style separators
|
||||
base: source.base.replace(&parent_dir, "").replace('\\', "/"),
|
||||
pattern: source.pattern,
|
||||
.map(|source| {
|
||||
GlobEntry {
|
||||
// Normalize paths to use unix style separators
|
||||
base: source.base.replace('\\', "/").replace(&parent_dir, "/"),
|
||||
pattern: source.pattern,
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ use bstr::ByteSlice;
|
||||
use fxhash::{FxHashMap, FxHashSet};
|
||||
use glob::optimize_patterns;
|
||||
use glob_match::glob_match;
|
||||
use paths::Path;
|
||||
use rayon::prelude::*;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
@ -18,6 +19,7 @@ pub mod cursor;
|
||||
pub mod fast_skip;
|
||||
pub mod glob;
|
||||
pub mod parser;
|
||||
pub mod paths;
|
||||
pub mod scanner;
|
||||
|
||||
static SHOULD_TRACE: sync::LazyLock<bool> = sync::LazyLock::new(
|
||||
@ -151,7 +153,8 @@ impl Scanner {
|
||||
|
||||
self.files
|
||||
.iter()
|
||||
.map(|x| x.to_string_lossy().into())
|
||||
.filter_map(|x| Path::from(x.clone()).canonicalize().ok())
|
||||
.map(|x| x.to_string())
|
||||
.collect()
|
||||
}
|
||||
|
||||
@ -257,9 +260,18 @@ impl Scanner {
|
||||
false
|
||||
});
|
||||
|
||||
fn join_paths(a: &str, b: &str) -> PathBuf {
|
||||
let mut tmp = a.to_owned();
|
||||
|
||||
tmp += "/";
|
||||
tmp += b.trim_end_matches("**/*").trim_end_matches('/');
|
||||
|
||||
PathBuf::from(&tmp)
|
||||
}
|
||||
|
||||
for path in auto_sources
|
||||
.iter()
|
||||
.map(|source| PathBuf::from(&source.base).join(source.pattern.trim_end_matches("**/*")))
|
||||
.map(|source| join_paths(&source.base, &source.pattern))
|
||||
{
|
||||
// Insert a glob for the base path, so we can see new files/folders in the directory itself.
|
||||
self.globs.push(GlobEntry {
|
||||
@ -292,7 +304,8 @@ impl Scanner {
|
||||
// match as well.
|
||||
//
|
||||
// Instead we combine the base and the pattern as a single glob pattern.
|
||||
let mut full_pattern = source.base.clone();
|
||||
let mut full_pattern = source.base.clone().replace('\\', "/");
|
||||
|
||||
if !source.pattern.is_empty() {
|
||||
full_pattern.push('/');
|
||||
full_pattern.push_str(&source.pattern);
|
||||
@ -314,7 +327,9 @@ impl Scanner {
|
||||
continue;
|
||||
};
|
||||
|
||||
if glob_match(&full_pattern, file_path_str) {
|
||||
let file_path_str = file_path_str.replace('\\', "/");
|
||||
|
||||
if glob_match(&full_pattern, &file_path_str) {
|
||||
self.files.push(file_path);
|
||||
}
|
||||
}
|
||||
|
||||
65
crates/oxide/src/paths.rs
Normal file
65
crates/oxide/src/paths.rs
Normal file
@ -0,0 +1,65 @@
|
||||
use std::fmt::Display;
|
||||
use std::io;
|
||||
use std::path;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Path {
|
||||
inner: path::PathBuf,
|
||||
}
|
||||
|
||||
impl From<path::PathBuf> for Path {
|
||||
fn from(value: path::PathBuf) -> Self {
|
||||
Self { inner: value }
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for Path {
|
||||
fn from(value: String) -> Self {
|
||||
Self {
|
||||
inner: value.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&str> for Path {
|
||||
fn from(value: &str) -> Self {
|
||||
Self {
|
||||
inner: value.into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Path {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"{}",
|
||||
format!("{}", self.inner.display()).replace('\\', "/")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl Path {
|
||||
pub fn trim_prefix(&self, prefix: String) -> Self {
|
||||
let prefix = prefix.replace('\\', "/");
|
||||
let my_path = self.to_string();
|
||||
|
||||
if let Some(str) = my_path.strip_prefix(&prefix) {
|
||||
return str.into();
|
||||
}
|
||||
|
||||
my_path.into()
|
||||
}
|
||||
|
||||
pub fn join(&self, component: &str) -> Self {
|
||||
if component.is_empty() {
|
||||
return self.clone();
|
||||
}
|
||||
|
||||
self.inner.join(component).into()
|
||||
}
|
||||
|
||||
pub fn canonicalize(&self) -> io::Result<Self> {
|
||||
Ok(dunce::canonicalize(&self.inner)?.into())
|
||||
}
|
||||
}
|
||||
@ -31,7 +31,7 @@ mod scanner {
|
||||
}
|
||||
}
|
||||
|
||||
let base = format!("{}", dir.display());
|
||||
let base = format!("{}", dir.display()).replace('\\', "/");
|
||||
|
||||
// Resolve all content paths for the (temporary) current working directory
|
||||
let mut sources: Vec<GlobEntry> = globs
|
||||
@ -51,31 +51,20 @@ mod scanner {
|
||||
|
||||
let candidates = scanner.scan();
|
||||
|
||||
let mut paths: Vec<_> = scanner
|
||||
.get_files()
|
||||
.into_iter()
|
||||
.map(|x| x.replace(&format!("{}{}", &base, path::MAIN_SEPARATOR), ""))
|
||||
.collect();
|
||||
let mut paths: Vec<_> = scanner.get_files();
|
||||
|
||||
for glob in scanner.get_globs() {
|
||||
paths.push(format!(
|
||||
"{}{}{}",
|
||||
glob.base,
|
||||
path::MAIN_SEPARATOR,
|
||||
glob.pattern
|
||||
));
|
||||
paths.push(format!("{}{}{}", glob.base, "/", glob.pattern));
|
||||
}
|
||||
|
||||
let parent_dir = format!(
|
||||
"{}{}",
|
||||
fs::canonicalize(&base).unwrap().display(),
|
||||
path::MAIN_SEPARATOR
|
||||
);
|
||||
let parent_dir =
|
||||
format!("{}{}", dunce::canonicalize(&base).unwrap().display(), "/").replace('\\', "/");
|
||||
|
||||
paths = paths
|
||||
.into_iter()
|
||||
.map(|x| {
|
||||
x.replace(&parent_dir, "").replace('\\', "/") // Normalize paths to use unix style separators
|
||||
// Normalize paths to use unix style separators
|
||||
x.replace('\\', "/").replace(&parent_dir, "")
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
"@parcel/watcher-linux-x64-musl": "^2.4.2-alpha.0",
|
||||
"@parcel/watcher-win32-x64": "^2.4.2-alpha.0",
|
||||
"@types/bun": "^1.1.11",
|
||||
"bun": "^1.1.29",
|
||||
"bun": "1.1.29",
|
||||
"lightningcss-darwin-arm64": "^1.25.1",
|
||||
"lightningcss-darwin-x64": "^1.25.1",
|
||||
"lightningcss-linux-arm64-gnu": "^1.25.1",
|
||||
|
||||
@ -431,7 +431,7 @@ class Root {
|
||||
let root = this.compiler.root
|
||||
|
||||
if (root !== 'none' && root !== null) {
|
||||
let basePath = path.posix.resolve(root.base, root.pattern)
|
||||
let basePath = normalizePath(path.resolve(root.base, root.pattern))
|
||||
|
||||
let isDir = await fs.stat(basePath).then(
|
||||
(stats) => stats.isDirectory(),
|
||||
@ -463,14 +463,22 @@ class Root {
|
||||
if (!this.compiler) return new Set()
|
||||
if (this.compiler.root === 'none') return new Set()
|
||||
|
||||
const HAS_DRIVE_LETTER = /^[A-Z]:/
|
||||
|
||||
let shouldIncludeCandidatesFrom = (id: string) => {
|
||||
if (this.basePath === null) return true
|
||||
|
||||
// This a virtual module that's not on the file system
|
||||
// TODO: What should we do here?
|
||||
if (id.startsWith(this.basePath)) return true
|
||||
|
||||
// This is a windows absolute path that doesn't match so return false
|
||||
if (HAS_DRIVE_LETTER.test(id)) return false
|
||||
|
||||
// We've got a path that's not absolute and not on Windows
|
||||
// TODO: this is probably a virtual module -- not sure if we need to scan it
|
||||
if (!id.startsWith('/')) return true
|
||||
|
||||
return id.startsWith(this.basePath)
|
||||
// This is an absolute path on POSIX and it does not match
|
||||
return false
|
||||
}
|
||||
|
||||
let shared = new Set<string>()
|
||||
|
||||
7
pnpm-lock.yaml
generated
7
pnpm-lock.yaml
generated
@ -91,6 +91,9 @@ importers:
|
||||
'@tailwindcss/oxide-linux-x64-musl':
|
||||
specifier: workspace:*
|
||||
version: link:npm/linux-x64-musl
|
||||
'@tailwindcss/oxide-win32-arm64-msvc':
|
||||
specifier: workspace:*
|
||||
version: link:npm/win32-arm64-msvc
|
||||
'@tailwindcss/oxide-win32-x64-msvc':
|
||||
specifier: workspace:*
|
||||
version: link:npm/win32-x64-msvc
|
||||
@ -119,6 +122,8 @@ importers:
|
||||
|
||||
crates/node/npm/linux-x64-musl: {}
|
||||
|
||||
crates/node/npm/win32-arm64-msvc: {}
|
||||
|
||||
crates/node/npm/win32-x64-msvc: {}
|
||||
|
||||
integrations:
|
||||
@ -247,7 +252,7 @@ importers:
|
||||
specifier: ^1.1.11
|
||||
version: 1.1.11
|
||||
bun:
|
||||
specifier: ^1.1.29
|
||||
specifier: 1.1.29
|
||||
version: 1.1.29
|
||||
lightningcss-darwin-arm64:
|
||||
specifier: ^1.25.1
|
||||
|
||||
@ -28,6 +28,7 @@ const syncedWorkspaces = new Map([
|
||||
'crates/node/npm/linux-x64-gnu',
|
||||
'crates/node/npm/linux-x64-musl',
|
||||
'crates/node/npm/win32-x64-msvc',
|
||||
'crates/node/npm/win32-arm64-msvc',
|
||||
],
|
||||
],
|
||||
['@tailwindcss/cli', ['packages/@tailwindcss-standalone']],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user