1+ import { createWeatherPlugin } from "./helpers/weather-plugin.js" ;
12import { createTempDir } from "./helpers/temp-dir.js" ;
23import assert from "node:assert/strict" ;
34import { execFile } from "node:child_process" ;
@@ -10,35 +11,7 @@ import { test } from "node:test";
1011const execFileAsync = promisify ( execFile ) ;
1112
1213test ( "check command runs from a plugin root without fixture config" , async ( t ) => {
13- const rootDir = await createTempDir ( t , "plugin-inspector-cli-root-" ) ;
14- await mkdir ( path . join ( rootDir , "src" ) , { recursive : true } ) ;
15- await writeFile (
16- path . join ( rootDir , "package.json" ) ,
17- `${ JSON . stringify (
18- {
19- name : "@example/openclaw-weather" ,
20- version : "1.0.0" ,
21- type : "module" ,
22- openclaw : {
23- extensions : [ "src/index.js" ] ,
24- compat : { pluginApi : "^1.0.0" } ,
25- } ,
26- } ,
27- null ,
28- 2 ,
29- ) } \n`,
30- "utf8" ,
31- ) ;
32- await writeFile (
33- path . join ( rootDir , "openclaw.plugin.json" ) ,
34- `${ JSON . stringify ( { id : "weather" , name : "Weather" , version : "1.0.0" , contracts : { tools : { } } } , null , 2 ) } \n` ,
35- "utf8" ,
36- ) ;
37- await writeFile (
38- path . join ( rootDir , "src" , "index.js" ) ,
39- 'import { definePluginEntry } from "openclaw/plugin-sdk";\nexport default definePluginEntry((api) => api.registerTool({ name: "weather" }));\n' ,
40- "utf8" ,
41- ) ;
14+ const rootDir = await createWeatherPlugin ( t , "plugin-inspector-cli-root-" ) ;
4215
4316 const cliPath = path . resolve ( "src/cli.js" ) ;
4417 const { stdout } = await execFileAsync ( process . execPath , [ cliPath , "check" , "--out" , "reports" , "--no-openclaw" ] , {
@@ -614,35 +587,7 @@ test("batch command applies author-facing filtering to aggregate summaries", asy
614587} ) ;
615588
616589async function createCliPluginRoot ( t , prefix ) {
617- const rootDir = await createTempDir ( t , prefix ) ;
618- await mkdir ( path . join ( rootDir , "src" ) , { recursive : true } ) ;
619- await writeFile (
620- path . join ( rootDir , "package.json" ) ,
621- `${ JSON . stringify (
622- {
623- name : "@example/openclaw-weather" ,
624- version : "1.0.0" ,
625- type : "module" ,
626- openclaw : {
627- extensions : [ "src/index.js" ] ,
628- compat : { pluginApi : "^1.0.0" } ,
629- } ,
630- } ,
631- null ,
632- 2 ,
633- ) } \n`,
634- "utf8" ,
635- ) ;
636- await writeFile (
637- path . join ( rootDir , "openclaw.plugin.json" ) ,
638- `${ JSON . stringify ( { id : "weather" , name : "Weather" , version : "1.0.0" , contracts : { tools : { } } } , null , 2 ) } \n` ,
639- "utf8" ,
640- ) ;
641- await writeFile (
642- path . join ( rootDir , "src" , "index.js" ) ,
643- 'import { definePluginEntry } from "openclaw/plugin-sdk";\nexport default definePluginEntry((api) => api.registerTool({ name: "weather" }));\n' ,
644- "utf8" ,
645- ) ;
590+ const rootDir = await createWeatherPlugin ( t , prefix ) ;
646591 await writeFile (
647592 path . join ( rootDir , "plugin-inspector.config.json" ) ,
648593 `${ JSON . stringify ( { version : 1 , plugin : { id : "weather" , priority : "high" , sourceRoot : "src" } } , null , 2 ) } \n` ,
0 commit comments