//! Prints what the plugin store reads from `*.plugin.js` files, one JSON object per line: //! `parse_meta` (name, description, version, author) and `valid_file_name`. create-waybetter's //! tests run it on generated plugins so they are checked with the store's own rules. //! //! cargo run --example plugin_meta -- path/to/one.plugin.js [more.plugin.js ...] use std::{env, fs, path::Path, process::ExitCode}; use waybetter_host::plugins::{parse_meta, valid_file_name}; fn main() -> ExitCode { for arg in env::args().skip(1) { let path = Path::new(&arg); let file = path.file_name().and_then(|name| name.to_str()).unwrap_or_default(); let Ok(source) = fs::read_to_string(path) else { eprintln!("cannot read {arg}"); return ExitCode::FAILURE; }; let meta = parse_meta(file, &source); println!( "{}", serde_json::json!({ "file": meta.file, "name": meta.name, "description": meta.description, "version": meta.version, "author": meta.author, "validFileName": valid_file_name(file), }) ); } ExitCode::SUCCESS }