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
@@ -30,11 +30,11 @@ const EXTS: &[&str] = &["", ".ts", ".tsx", ".mts", ".js", ".mjs", ".cjs", ".json
|
||||
/// `spec` imported from a file in `dir` (`esm`: an import, else a require), to the file it names
|
||||
pub fn resolve_file(spec: &str, dir: &Path, esm: bool) -> Result<PathBuf, String> {
|
||||
let raw = spec.strip_prefix("file://").unwrap_or(spec);
|
||||
// (a path whole on Windows too, `D:\..`: the React raea ships, found, was asked for again by its path and read as a package's name, #278)
|
||||
if raw.starts_with("./") || raw.starts_with("../") || raw.starts_with('/') || raw == "." || raw == ".." || Path::new(raw).is_absolute() {
|
||||
let want = if raw.starts_with('/') || Path::new(raw).is_absolute() { PathBuf::from(raw) } else { dir.join(raw) };
|
||||
if raw.starts_with("./") || raw.starts_with("../") || raw.starts_with('/') || raw == "." || raw == ".." {
|
||||
let want = if raw.starts_with('/') { PathBuf::from(raw) } else { dir.join(raw) };
|
||||
return as_file(&want).ok_or_else(|| format!("Cannot find module '{spec}' from {}", dir.display()));
|
||||
}
|
||||
// a package: its name (a scope takes two parts) and the subpath after it
|
||||
let mut parts = raw.splitn(if raw.starts_with('@') { 3 } else { 2 }, '/');
|
||||
let name = if raw.starts_with('@') { format!("{}/{}", parts.next().unwrap_or(""), parts.next().unwrap_or("")) } else { parts.next().unwrap_or("").to_string() };
|
||||
let sub = parts.next().map(|s| format!("./{s}")).unwrap_or_else(|| ".".into());
|
||||
@@ -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,21 +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"));
|
||||
// a file asked for by its whole path is that file, on Windows too (`D:\..` was read as a package's name)
|
||||
let whole = pkg.join("index.js");
|
||||
assert_eq!(raea_native::node::resolve_file(whole.to_str().unwrap(), &theirs, true).unwrap(), whole);
|
||||
// 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();
|
||||
}
|
||||
@@ -86,8 +86,7 @@ up)
|
||||
# rebuilds anyway (raea cloud then resumes the cut-off runs, projects.ts resumeRequest).
|
||||
if [ "${RAEA_BOX_FORCE:-}" != 1 ]; then
|
||||
for i in $(seq 1 90); do
|
||||
# (a Sprite just made has no server yet: curl's own exit ended this script, 12-01)
|
||||
n=$(x ". ~/.raea-cloud.env 2>/dev/null; curl -fsS -m 5 -H \"authorization: Bearer \$RAEA_CLOUD_TOKEN\" localhost:8080/v1/health 2>/dev/null || true" | python3 -c 'import json,sys
|
||||
n=$(x ". ~/.raea-cloud.env 2>/dev/null; curl -fsS -m 5 -H \"authorization: Bearer \$RAEA_CLOUD_TOKEN\" localhost:8080/v1/health 2>/dev/null" | python3 -c 'import json,sys
|
||||
try: print(json.load(sys.stdin).get("running", "unknown"))
|
||||
except Exception: print("down")')
|
||||
# down: nothing to cut off; unknown: a server too old to say, so it isn't rebuilt blind
|
||||
|
||||
@@ -21,11 +21,6 @@ say packages
|
||||
sudo -E apt-get update -qq
|
||||
sudo -E apt-get install -y -qq --no-install-recommends ca-certificates curl git git-lfs zstd xz-utils procps ripgrep \
|
||||
libasound2t64 libfontconfig1 libvulkan1 mesa-vulkan-drivers vulkan-tools > /dev/null
|
||||
# faces an ad is set in (12-01: a box had Liberation and DejaVu alone, so every cut fell back to Liberation Sans): the
|
||||
# open families brands are closest to, each taken when this Ubuntu has it
|
||||
for f in fonts-inter fonts-roboto fonts-open-sans fonts-lato fonts-montserrat fonts-noto-core fonts-ibm-plex fonts-bebas-neue fonts-urw-base35 fonts-liberation2; do
|
||||
dpkg -s "$f" > /dev/null 2>&1 || sudo -E apt-get install -y -qq --no-install-recommends "$f" > /dev/null 2>&1 || say "no $f here"
|
||||
done
|
||||
node -v 2> /dev/null | grep -q '^v24' || {
|
||||
say "node $NODE"
|
||||
curl -fsSL "https://nodejs.org/dist/v$NODE/node-v$NODE-linux-x64.tar.xz" | sudo tar -xJ -C /opt
|
||||
|
||||
@@ -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