Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

Layout L1: the CLI crate back to 2000 lines (component and part's checks in one), workspace_of is shared_of (the loader only wanted shared/, and it duplicated godot_run's nearest_project), and the manual's raea component page (Projects group, --shared and --force described)

shinyobjectzc7e857b2432b
diff --git a/apps/workspace/registry/src/lint.rs b/apps/workspace/registry/src/lint.rs
index 1f977d1f..d7f41a70 100644
--- a/apps/workspace/registry/src/lint.rs
+++ b/apps/workspace/registry/src/lint.rs
@@ -95,7 +95,7 @@ pub(super) fn lint(reg: &Registry, files: &[File], used_by: &BTreeMap<String, BT
// the workspace's shared/ by its name is how a project reaches it (docs/layout.feature LY2)
Some(_) if spec.starts_with(super::SHARED) => {}
Some(to) if !to.starts_with(&reg.dir) => {
- let in_shared = shared.as_ref().and_then(|s| to.strip_prefix(s).ok()).map(|r| r.with_extension("").display().to_string());
+ let in_shared = shared.as_ref().and_then(|s| to.strip_prefix(s).ok()).map(|r| format!("{}", r.with_extension("").display()));
out.push(warn(
&f.rel,
*line,
diff --git a/docs/manual/reference/cli/add.md b/docs/manual/reference/cli/add.md
index a1ae04ad..b1bce44a 100644
--- a/docs/manual/reference/cli/add.md
+++ b/docs/manual/reference/cli/add.md
@@ -1,7 +1,7 @@
---
title: "raea add"
summary: "Add, remove and install npm packages for a project, with no Node or npm: raea.lock and node_modules."
-order: 28
+order: 29
sources: ["io/npm/src/lib.rs"]
---
diff --git a/docs/manual/reference/cli/brand.md b/docs/manual/reference/cli/brand.md
index 81133bbc..4817076d 100644
--- a/docs/manual/reference/cli/brand.md
+++ b/docs/manual/reference/cli/brand.md
@@ -1,7 +1,7 @@
---
title: "raea brand"
summary: "Read a brand kit from a website on this machine: colours, fonts and logos into brand/ and BRAND.md."
-order: 29
+order: 30
sources: ["engine/cli/src/brand.ts", "engine/cli/src/scrape.ts"]
---
diff --git a/docs/manual/reference/cli/component.md b/docs/manual/reference/cli/component.md
new file mode 100644
index 00000000..a26ec2ba
--- /dev/null
+++ b/docs/manual/reference/cli/component.md
@@ -0,0 +1,36 @@
+---
+title: "raea component"
+summary: "Copy a ready-made component or set into the project's components/, or the workspace's shared/components/, to use and change as your own."
+order: 27
+sources: ["engine/cli/src/index.ts", "engine/cli/src/registry.gen.ts"]
+---
+
+Components are ready-made pieces of a composition (captions, lower thirds, end cards and the like) and sets of them.
+`raea component list` shows them; `raea component add` copies one into `components/NAME/`, where it's yours: raea
+never updates or overwrites it unasked. With `--shared` it goes into the workspace's `shared/components/` instead, for
+every project to import as `@shared/components/NAME`. `raea part` is the old name and still works.
+
+```sh
+raea component list
+raea component add captions end-card
+raea component add reel --shared
+```
+
+<!-- generated:begin by tools/manual-ref/cli.ts from `raea help --json`; edit only the flag descriptions -->
+
+## Usage
+
+```sh
+raea component list | raea component add NAME ... [--shared] [--force] | raea part list | raea part add NAME ... [--shared] [--force] (a ready component or set copied into components/, or the workspace's shared/components/ with --shared, yours to change; raea part is its old name)
+```
+
+Headless: it needs nothing running and opens no window. Takes any number of arguments besides its flags.
+
+## Flags
+
+| Flag | Takes | What it does |
+| --- | --- | --- |
+| `--force` | – | Replace a component's files that are already there. Without it, an existing component is left alone and the command stops. |
+| `--shared` | – | Copy into the workspace's `shared/components/` instead, where every project in the workspace imports it as `/components/NAME`. |
+
+<!-- generated:end -->
diff --git a/docs/manual/reference/cli/index.md b/docs/manual/reference/cli/index.md
index ee15c28b..bbf9be0e 100644
--- a/docs/manual/reference/cli/index.md
+++ b/docs/manual/reference/cli/index.md
@@ -51,6 +51,7 @@ The workspace, its projects and what a project holds.
| [`raea project`](project.md) | Make a project in the workspace, list them, or move one between inline and a repository of its own. |
| [`raea controller`](controller.md) | Read and change the workspace's controllers: its settings and workflows, each a TypeScript file. |
| [`raea spec`](spec.md) | Print a spec file's default export as JSON, checked against its schema: briefs, scripts, taste, plans and controllers. |
+| [`raea component`](component.md) | Copy a ready-made component or set into the project's components/, or the workspace's shared/components/, to use and change as your own. |
| [`raea part`](part.md) | Copy a ready-made part into the project's components/, to use and change as your own. |
| [`raea add`](add.md) | Add, remove and install npm packages for a project, with no Node or npm: raea.lock and node_modules. |
| [`raea brand`](brand.md) | Read a brand kit from a website on this machine: colours, fonts and logos into brand/ and BRAND.md. |
diff --git a/docs/manual/reference/cli/library.md b/docs/manual/reference/cli/library.md
index a369df53..0ce93450 100644
--- a/docs/manual/reference/cli/library.md
+++ b/docs/manual/reference/cli/library.md
@@ -1,7 +1,7 @@
---
title: "raea library"
summary: "Search and manage the person's media libraries in the raea app: folders and drives indexed on this machine, searched by meaning."
-order: 30
+order: 31
sources: ["engine/cli/src/library.ts"]
---
diff --git a/docs/manual/reference/cli/part.md b/docs/manual/reference/cli/part.md
index 839ceeb5..adb40fda 100644
--- a/docs/manual/reference/cli/part.md
+++ b/docs/manual/reference/cli/part.md
@@ -1,7 +1,7 @@
---
title: "raea part"
summary: "Copy a ready-made part into the project's components/, to use and change as your own."
-order: 27
+order: 28
sources: ["engine/cli/src/index.ts", "engine/cli/src/registry.gen.ts"]
---
@@ -18,7 +18,7 @@ raea part add captions end-card
## Usage
```sh
-raea part list | raea part add NAME ... [--force] (a ready part copied into components/, yours to change)
+raea component list | raea component add NAME ... [--shared] [--force] | raea part list | raea part add NAME ... [--shared] [--force] (a ready component or set copied into components/, or the workspace's shared/components/ with --shared, yours to change; raea part is its old name)
```
Headless: it needs nothing running and opens no window. Takes any number of arguments besides its flags.
@@ -28,5 +28,6 @@ Headless: it needs nothing running and opens no window. Takes any number of argu
| Flag | Takes | What it does |
| --- | --- | --- |
| `--force` | – | Replace a part's files that are already in `components/`. Without it, an existing part is left alone and the command stops. |
+| `--shared` | – | Copy into the workspace's `shared/components/` instead, where every project in the workspace imports it as `/components/NAME`. |
<!-- generated:end -->
diff --git a/engine/cli/src/tests.rs b/engine/cli/src/tests.rs
index c86f031a..3c788b2a 100644
--- a/engine/cli/src/tests.rs
+++ b/engine/cli/src/tests.rs
@@ -5,12 +5,9 @@ use crate::cli::*;
#[test]
fn shell_runs() {
// engine/cli's handler loads and answers on raea's JavaScriptCore (part list is the shell's own, no host step);
- // `raea help` lists SHELL's verbs (help_lists_every_verb)
- let parts = shell(&["part".to_string(), "list".to_string()]).unwrap();
- assert!(parts.contains("captions"), "{parts}");
- // raea component is its name now (docs/layout.feature LY4); raea part still answers
- let components = shell(&["component".to_string(), "list".to_string()]).unwrap();
- assert!(components.contains("captions") && components.contains("into components/reel/"), "{components}");
+ // `raea help` lists SHELL's verbs (help_lists_every_verb); raea component is part's new name (LY4), part still answers
+ let (parts, components) = (shell(&["part".to_string(), "list".to_string()]).unwrap(), shell(&["component".to_string(), "list".to_string()]).unwrap());
+ assert!(parts.contains("captions") && components.contains("into components/reel/"), "{parts}\n{components}");
}
#[test]
diff --git a/engine/modules/src/lib.rs b/engine/modules/src/lib.rs
index 97221bd6..0b12255f 100644
--- a/engine/modules/src/lib.rs
+++ b/engine/modules/src/lib.rs
@@ -95,9 +95,9 @@ const EXTS: [&str; 5] = ["tsx", "ts", "jsx", "js", "mjs"];
/// The prefix a project imports its workspace's shared files by (docs/layout.feature LY2): @shared/components/desk.
pub const SHARED: &str = "@shared/";
-/// The workspace a folder is in: the nearest folder at or above it holding .raea/workspace.
-fn workspace_of(dir: &Path) -> Option<PathBuf> {
- dir.ancestors().find(|d| d.join(".raea/workspace").is_file()).map(Path::to_path_buf)
+/// The shared/ of the workspace a folder is in: the nearest folder at or above it holding .raea/workspace.
+fn shared_of(dir: &Path) -> Option<PathBuf> {
+ dir.ancestors().find(|d| d.join(".raea/workspace").is_file()).map(|w| w.join("shared"))
}
const MEDIA: [&str; 12] = ["mp4", "mov", "m4v", "webm", "m4a", "mp3", "wav", "aac", "png", "jpg", "jpeg", "svg"];
@@ -151,7 +151,7 @@ impl Loader {
let raw = specifier.strip_prefix("file://").unwrap_or(specifier);
let want = lexical(&if raw.starts_with('/') { PathBuf::from(raw) } else { base.join(raw) });
// inside the space, or inside its workspace's shared/ (a file there imports its neighbours relatively)
- let shared = workspace_of(&self.root).map(|w| w.join("shared"));
+ let shared = shared_of(&self.root);
if !want.starts_with(&self.root) && !shared.as_ref().is_some_and(|s| want.starts_with(s)) {
return Err(Refusal::new(RefusalKind::OutsideSpace, format!("`{specifier}` (imported by {referrer}) is outside the space: import files inside {}, and the workspace's shared files as @shared/<kind>/<name>", self.root.display()), Some(specifier), Some(referrer)));
}
@@ -161,10 +161,9 @@ impl Loader {
/// `@shared/<kind>/<name>`: the workspace's shared/ (docs/layout.feature LY2), found by walking up from the space to
/// the folder holding .raea/workspace, resolved as a relative import is.
fn shared(&self, rest: &str, specifier: &str, referrer: &str) -> Result<ModuleId, Refusal> {
- let Some(ws) = workspace_of(&self.root) else {
+ let Some(dir) = shared_of(&self.root) else {
return Err(Refusal::new(RefusalKind::UnknownLibrary, format!("`{specifier}` (imported by {referrer}) names the workspace's shared/, and {} is in no workspace (no .raea/workspace above it): copy the file into the project, or `raea workspace adopt` the folder", self.root.display()), Some(specifier), Some(referrer)));
};
- let dir = ws.join("shared");
let want = lexical(&dir.join(rest));
if !want.starts_with(&dir) {
return Err(Refusal::new(RefusalKind::OutsideSpace, format!("`{specifier}` (imported by {referrer}) climbs out of the workspace's shared/"), Some(specifier), Some(referrer)));
diff --git a/tools/manual-ref/cli.ts b/tools/manual-ref/cli.ts
index 5200fc09..086b72c9 100644
--- a/tools/manual-ref/cli.ts
+++ b/tools/manual-ref/cli.ts
@@ -26,7 +26,7 @@ const verbs: Verb[] = JSON.parse(run(["help", "--json"])).verbs
// the index's groups, in the order a reader meets them; every verb is in one
const GROUPS: [string, string, string[]][] = [
["Make", "Render, play and package what you wrote.", ["render", "play", "export-game", "export", "bundle", "app", "run"]],
- ["Projects", "The workspace, its projects and what a project holds.", ["init", "workspace", "project", "controller", "spec", "part", "add", "brand", "library"]],
+ ["Projects", "The workspace, its projects and what a project holds.", ["init", "workspace", "project", "controller", "spec", "component", "part", "add", "brand", "library"]],
["Check", "What's wrong before anyone watches it.", ["check", "judge", "findings", "scene", "world", "solid", "next", "doctor", "hook", "traces"]],
["Footage", "Takes, cuts and the camera, from your own media.", ["media", "cut", "frame", "track", "splat", "mezz", "neural"]],
["Sound", "Music read, foley and instruments made on this machine.", ["song", "sounds", "sao", "tokensynth", "setup-audio"]],