- plugin: *.plugin.js with the store header and start/stop on api.scope, storage, observe, onKey, the UI kit (toast with action, ui.h settings dialog) and api.theme/--wb-* vars; --ts makes a TypeScript project typed by the waybetter package (build keeps the header first) - theme: JSON with "$schema" -> theme.schema.json, palette derived like themeFromColors, font roles (family, tweet), presets - app: Tauri 2 + waybetter-host + runtime + shell models: SiteSpec, SiteAdapter, shell/tab-chrome/ site-tab capabilities, tabs_sync, plugin store, a site-only command; presets for youtube.com, kick.com, twitch.tv with placeholder selectors; host crate via submodule, path or git - tests generate into temp dirs: headers via parse_meta (new plugin_meta example), plugin code against createCorePluginApi's members, themes against the schema, app TS with tsc against the built package, app Rust with cargo metadata/check/test - wired into bun run check (typecheck incl. checkJs, build:packages, test:create) and pack:check Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
1.2 KiB
Rust
32 lines
1.2 KiB
Rust
//! 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
|
|
}
|