rigspark_cli/
retirement.rs1const BROWSER_SCRIPTS: &[&str] = &[
2 "crates/rigspark-gui/static/calculator-runtime.js",
3 "crates/rigspark-gui/static/calculator-template.js",
4 "crates/rigspark-gui/static/chat.js",
5 "crates/rigspark-gui/static/confirm.js",
6 "crates/rigspark-gui/static/desktop.js",
7 "crates/rigspark-gui/static/engines.js",
8 "crates/rigspark-gui/static/generate.js",
9 "crates/rigspark-gui/static/hf-add.js",
10 "crates/rigspark-gui/static/image-studio.js",
11 "crates/rigspark-gui/static/legal.js",
12 "crates/rigspark-gui/static/markdown.js",
13 "crates/rigspark-gui/static/run-reducer.js",
14 "crates/rigspark-gui/static/sse.js",
15 "crates/rigspark-gui/static/telemetry.js",
16 "crates/rigspark-gui/static/voice.js",
17 "crates/rigspark-gui/static/workspace.js",
18 "apps/desktop/src-tauri/src/dialog-smoke.js",
19 "crates/rigspark-gui/vendor/dompurify.min.js",
20 "crates/rigspark-gui/vendor/katex/contrib/auto-render.min.js",
21 "crates/rigspark-gui/vendor/katex/katex.min.js",
22 "crates/rigspark-gui/vendor/marked.min.js",
23];
24
25fn imports_node_api(text: &str) -> bool {
27 let compact: String = text
28 .chars()
29 .filter(|character| !character.is_whitespace())
30 .collect();
31 ["from", "require(", "import("].iter().any(|loader| {
32 ["\"node:", "'node:", "`node:"]
33 .iter()
34 .any(|quote| compact.contains(&format!("{loader}{quote}")))
35 })
36}
37
38pub fn check_file(path: &str, text: &str) -> Vec<&'static str> {
39 let name = path.rsplit('/').next().unwrap_or(path);
40 let extension = name.rsplit('.').next().unwrap_or("");
41 let mut failures = Vec::new();
42 if path.starts_with("src/") {
43 failures.push("root src directory must be empty after native migration");
44 }
45 let browser = BROWSER_SCRIPTS.contains(&path);
46 if ["ts", "tsx", "jsx", "mjs", "cjs"].contains(&extension) || (extension == "js" && !browser) {
47 failures.push("Node/TypeScript source or unreviewed JavaScript remains");
48 }
49 if [
50 "package.json",
51 "package-lock.json",
52 "npm-shrinkwrap.json",
53 "pnpm-lock.yaml",
54 "pnpm-workspace.yaml",
55 "yarn.lock",
56 "bun.lock",
57 "bun.lockb",
58 ".npmrc",
59 ".yarnrc",
60 ".yarnrc.yml",
61 ".nvmrc",
62 ".node-version",
63 ]
64 .contains(&name)
65 || (name.starts_with("tsconfig") && name.ends_with(".json"))
66 {
67 failures.push("Node package or toolchain configuration remains");
68 }
69 if browser
70 && (imports_node_api(text)
71 || text
72 .lines()
73 .next()
74 .is_some_and(|line| line.starts_with("#!") && line.contains("node")))
75 {
76 failures.push("browser asset invokes a Node runtime or imports Node APIs");
77 }
78 let executable_config = path.starts_with(".github/workflows/")
79 || ["sh", "ps1", "py", "cmd", "bat"].contains(&extension)
80 || ["Makefile", "justfile"].contains(&name)
81 || path == "apps/desktop/src-tauri/tauri.conf.json";
82 if executable_config {
83 let lower = text.to_ascii_lowercase();
84 if path.starts_with(".github/workflows/")
85 && [
86 "actions/checkout@",
87 "actions/configure-pages@",
88 "actions/upload-pages-artifact@",
89 "actions/deploy-pages@",
90 "actions/add-to-project@",
91 "actions/upload-artifact@",
92 "actions/download-artifact@",
93 "actions/cache@",
94 "actions/github-script@",
95 "softprops/action-gh-release@",
96 ]
97 .iter()
98 .any(|action| lower.contains(action))
99 {
100 failures.push("workflow still references a Node-backed action");
101 }
102 let has_command = lower
103 .split(|character: char| {
104 !character.is_ascii_alphanumeric() && character != '-' && character != '_'
105 })
106 .any(|word| {
107 [
108 "node",
109 "nodejs",
110 "npm",
111 "npx",
112 "pnpm",
113 "yarn",
114 "bun",
115 "setup-node",
116 "electron",
117 ]
118 .contains(&word)
119 });
120 if has_command {
121 failures.push("executable configuration still references the Node toolchain");
122 }
123 }
124 failures
125}