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