mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 12:44:11 -10:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78897a1539 |
No files matched your search
@@ -53,9 +53,9 @@ pub fn resolve_file(spec: &str, dir: &Path, esm: bool) -> Result<PathBuf, String
|
||||
return Ok(f);
|
||||
}
|
||||
}
|
||||
// a package raea ships, imported by a file with no node_modules of its own: raea's (sdk/app), or a project's brief.ts or scene (#278)
|
||||
let own = raea_io_home::home().join("sdk/react/js/node_modules").join(&name);
|
||||
if own.is_dir() {
|
||||
// raea's own file (sdk/app, under `raea goal check`) importing a package raea ships: a release has those in the React runtime's node_modules alone (#278)
|
||||
let (home, own) = (raea_io_home::home(), raea_io_home::home().join("sdk/react/js/node_modules").join(&name));
|
||||
if dir.starts_with(&home) && own.is_dir() {
|
||||
return package_entry(&own, &sub, esm).ok_or_else(|| format!("Cannot find module '{spec}': {} has no {sub}", own.display()));
|
||||
}
|
||||
Err(format!("Cannot find package '{name}' imported from {}", dir.display()))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! A file importing a package raea ships (raea's own, or a project's with no node_modules) finds it in the React runtime's node_modules (#278): a release has
|
||||
//! A file of raea's own importing a package raea ships finds it in the React runtime's node_modules (#278): a release has
|
||||
//! no node_modules above sdk/app, so `raea goal check` ended every render "Cannot find package 'react'". Its own test
|
||||
//! binary: raea's home is read once a process.
|
||||
#![cfg(feature = "modules")]
|
||||
@@ -16,18 +16,7 @@ fn raeas_own_file_finds_the_react_raea_ships() {
|
||||
// SAFETY: the one test here, before anything reads the environment
|
||||
unsafe { std::env::set_var("RAEA_HOME", &home) };
|
||||
assert_eq!(raea_native::node::resolve_file("react", &own, true).unwrap(), pkg.join("index.js"));
|
||||
// a project's file with no node_modules of its own gets the same React (brief.ts, a scene it registers): a release's
|
||||
// render was applied and then failed its checks on "Cannot find package 'react'"
|
||||
fs::create_dir_all(&theirs).unwrap();
|
||||
assert_eq!(raea_native::node::resolve_file("react", &theirs, true).unwrap(), pkg.join("index.js"));
|
||||
// its own copy, when it has one, wins
|
||||
let mine = theirs.join("node_modules/react");
|
||||
fs::create_dir_all(&mine).unwrap();
|
||||
fs::write(mine.join("package.json"), r#"{"name":"react","main":"index.js"}"#).unwrap();
|
||||
fs::write(mine.join("index.js"), "module.exports = {}").unwrap();
|
||||
assert_eq!(raea_native::node::resolve_file("react", &theirs, true).unwrap(), mine.join("index.js"));
|
||||
// and a package raea doesn't ship is still not found
|
||||
assert!(raea_native::node::resolve_file("left-pad", &own, true).unwrap_err().contains("Cannot find package 'left-pad'"));
|
||||
fs::remove_dir_all(&theirs).ok();
|
||||
// a project's own file never reaches into raea's packages
|
||||
assert!(raea_native::node::resolve_file("react", &theirs, true).unwrap_err().contains("Cannot find package 'react'"));
|
||||
fs::remove_dir_all(&home).ok();
|
||||
}
|
||||
@@ -195,14 +195,6 @@ if [ -f "$check/raea/bin/raea.exe" ]; then
|
||||
done
|
||||
"$check/raea/bin/uv.exe" --version 2>&1 | grep -q '^uv ' || fail "bin/uv.exe doesn't run"
|
||||
fi
|
||||
# a project whose brief.ts imports React, as its scenes do, and has no node_modules: a render's own checks load brief.ts,
|
||||
# and a render that was applied ended "Cannot find package 'react'" and "render again" (#278). The checks' verdict on
|
||||
# an empty project isn't the point here: that brief.ts ran is
|
||||
mkdir -p "$check/brief" && cp "$check/p/hello.tsx" "$check/brief/hello.tsx"
|
||||
printf '%s\n' 'import { useMemo } from "react"' 'import { goal } from "raea/goal"' 'export const hook = useMemo' 'export default goal({ title: "Check", make: "one short video" })' > "$check/brief/brief.ts"
|
||||
(cd "$check/brief" && RAEA_NO_TREE=1 "$raea" goal check > check.log 2>&1) || true
|
||||
[ -s "$check/brief/check.log" ] || fail "raea goal check said nothing beside a brief.ts that imports react"
|
||||
! grep -q "Cannot find package\|doesn't run" "$check/brief/check.log" || { tail -20 "$check/brief/check.log" >&2; fail "a brief.ts that imports react doesn't run: a package raea ships wasn't found"; }
|
||||
# RAEA_CHECK_HARD=1 (tools/release-machines.sh, on real machines: a PC's own GPU, the Linux box): what reports from
|
||||
# other systems needed and a runner's one pass doesn't show.
|
||||
if [ "${RAEA_CHECK_HARD:-}" = 1 ]; then
|
||||
|
||||
Reference in new issue
Block a user