@stacksjs/buddy 0.75.633 → 0.75.635

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{run as runAgentCounts}from"./docs/agent-counts";import{run as runArtifacts}from"./docs/generated-artifacts";import{run as runBuddyDocs}from"./docs/buddy-commands";import{run as runCapabilities}from"./docs/capabilities";import{run as runSnippets}from"./docs/snippets";import{run as runDesktopMatrix}from"./docs/desktop-matrix";import{run as runLinks}from"./docs/links";import{run as runNativeSkills}from"./docs/native-skills";import{runTool}from"./run-tool";export function docs(buddy){buddy.command("docs:screenshots","Capture and verify an explicit UI inventory with Bun WebView").option("--config <path>","Screenshot configuration path",{default:"config/screenshots.ts"}).option("--out <directory>","Override the output directory").option("--only <ids>","Comma-separated screen ids to capture").option("--viewport <names>","Comma-separated configured viewport names").option("--list","Validate screen coverage without opening a browser",{default:false}).option("--check","Verify the complete saved inventory and image hashes",{default:false}).option("--json","Print the inventory, model plan and capture report as JSON",{default:false}).example("buddy docs:screenshots --list").example("buddy docs:screenshots --only welcome,calendar --viewport mobile").action(async(options)=>{const{captureScreenshots}=await import("@stacksjs/docs/screenshots");const report=await captureScreenshots({config:options.config,outDir:options.out,only:options.only?.split(",").map((value)=>value.trim()).filter(Boolean),viewports:options.viewport?.split(",").map((value)=>value.trim()).filter(Boolean),list:options.list,check:options.check,onProgress:(result)=>{if(!options.json)console.log(`${result.status} ${result.id}/${result.profile}/${result.viewport.name}`)}});if(options.json){console.log(JSON.stringify(report,null,2));if(report.results.some((result)=>result.status==="failed"))process.exitCode=1;return}if(options.list)for(const screen of report.inventory)console.log(`${screen.id} ${screen.path}${screen.skip?` [excluded: ${screen.skip}]`:""}`);if(options.list)for(const model of report.models.models)console.log(`${model.name} (${model.table||"table inferred"}, key ${model.primaryKey}): ${model.factoryFields.length} factories, seeder count ${model.seederCount??"not declared"}, parents ${model.parents.join(", ")||"none"}, required overrides ${model.requiredWithoutFactory.join(", ")||"none"}, sensitive fields ${model.sensitiveFields.join(", ")||"none"}, states ${model.suggestedStates.join(", ")}`);if(options.list&&report.models.cycles.length)console.log(`Cyclic model dependencies: ${report.models.cycles.join(", ")}`);if(options.list&&report.models.externalParents.length)console.log(`Parent fixtures outside this model set: ${report.models.externalParents.join(", ")}`);const failed=report.results.filter((result)=>result.status==="failed");for(const result of failed)console.error(`${result.id}/${result.profile}/${result.viewport.name}: ${result.error}`);console.log(options.list?"Screenshot configuration and template coverage verified.":`${report.results.filter((result)=>result.status==="captured").length} captures, ${failed.length} failed, ${report.results.filter((result)=>result.status==="skipped").length} explained exclusions.`);if(failed.length)process.exitCode=1});for(const check of[false,true]){buddy.command(check?"docs:style-guide:check":"docs:style-guide",check?"Verify generated application style guide freshness":"Generate a branded application component style guide").option("--config <path>","Style guide configuration path",{default:"config/style-guide.ts"}).action(async(options)=>{const{runStyleGuide}=await import("@stacksjs/docs/style-guide");const result=await runStyleGuide({config:options.config,check});console.log(`${check?"Verified":"Generated"} style guide: ${result.components} components, ${result.stories} stories, ${result.variants} variants.`)})}buddy.command("docs:native-skills","Regenerate native skill package coverage and driver evidence").action(async()=>{await runTool(runNativeSkills,"--write")});buddy.command("docs:native-skills:check","Verify native skills cover current packages and driver capabilities").action(async()=>{await runTool(runNativeSkills,"--check")});buddy.command("docs:buddy","Regenerate the buddy command reference doc").action(async()=>{await runTool(runBuddyDocs,"--write")});buddy.command("docs:buddy:check","Verify the buddy command reference doc is current").action(async()=>{await runTool(runBuddyDocs,"--check")});buddy.command("docs:artifacts","Regenerate the generated API artifacts (OpenAPI + types)").action(async()=>{await runTool(runArtifacts,"--write")});buddy.command("docs:artifacts:check","Verify the generated API artifacts are current").action(async()=>{await runTool(runArtifacts,"--check")});buddy.command("docs:agent-counts","Rewrite the counts AGENTS.md and the skills state, from the tree").action(async()=>{await runTool(runAgentCounts,"--write")});buddy.command("docs:agent-counts:check","Verify the counts AGENTS.md and the skills state are current").action(async()=>{await runTool(runAgentCounts,"--check")});buddy.command("docs:capabilities","Regenerate the driver capability matrix in docs/features/capabilities.md").action(async()=>{await runTool(runCapabilities,"--write")});buddy.command("docs:capabilities:check","Verify the published capability matrix matches its registry").action(async()=>{await runTool(runCapabilities,"--check")});buddy.command("docs:desktop-matrix","Regenerate the desktop support matrix in docs/packages/desktop.md").action(async()=>{await runTool(runDesktopMatrix,"--write")});buddy.command("docs:desktop-matrix:check","Verify the published desktop support matrix matches its source").action(async()=>{await runTool(runDesktopMatrix,"--check")});buddy.command("docs:snippets","Record the documented imports that do not compile, as the baseline").action(async()=>{await runTool(runSnippets,"--write")});buddy.command("docs:snippets:check","Verify no NEW documented import fails to compile").action(async()=>{await runTool(runSnippets,"--check")});buddy.command("docs:links","Report internal documentation links").action(async()=>{await runTool(runLinks)});buddy.command("docs:links:check","Verify internal documentation links resolve").action(async()=>{await runTool(runLinks,"--check")})}
1
+ import{run as runAgentCounts}from"./docs/agent-counts";import{run as runArtifacts}from"./docs/generated-artifacts";import{run as runBuddyDocs}from"./docs/buddy-commands";import{run as runCapabilities}from"./docs/capabilities";import{run as runSnippets}from"./docs/snippets";import{run as runDesktopMatrix}from"./docs/desktop-matrix";import{run as runLinks}from"./docs/links";import{run as runNativeSkills}from"./docs/native-skills";import{runTool}from"./run-tool";export function docs(buddy){buddy.command("docs:stories","Record browser and native user stories with video, scene screenshots and docs").option("--config <path>","Story configuration path",{default:"config/stories.ts"}).option("--out <directory>","Generated documentation and media directory").option("--only <ids>","Comma-separated story ids").option("--list","Validate and list stories without starting drivers",{default:false}).option("--check","Verify complete recordings, configuration and artifact hashes",{default:false}).option("--json","Print the story report as JSON",{default:false}).example("buddy docs:stories").example("buddy docs:stories --only checkout-ios,checkout-android").example("buddy docs:stories --check").action(async(options)=>{const{recordStories}=await import("@stacksjs/docs/stories");const report=await recordStories({config:options.config,outDir:options.out,only:options.only?.split(",").map((value)=>value.trim()).filter(Boolean),list:options.list,check:options.check,onProgress:(result)=>{if(!options.json)console.log(`${result.status} ${result.id} (${result.platform})`)}});if(options.json)console.log(JSON.stringify(report,null,2));else if(options.list)for(const story of report.inventory)console.log(`${story.id} (${story.platform}): ${story.scenes.map((scene)=>scene.id).join(", ")}`);else console.log(`Story documentation: ${report.outDir}/index.md`);if(!options.list&&report.results.some((result)=>result.status!=="passed"))process.exitCode=1});buddy.command("docs:screenshots","Capture and verify an explicit UI inventory with Bun WebView").option("--config <path>","Screenshot configuration path",{default:"config/screenshots.ts"}).option("--out <directory>","Override the output directory").option("--only <ids>","Comma-separated screen ids to capture").option("--viewport <names>","Comma-separated configured viewport names").option("--list","Validate screen coverage without opening a browser",{default:false}).option("--check","Verify the complete saved inventory and image hashes",{default:false}).option("--json","Print the inventory, model plan and capture report as JSON",{default:false}).example("buddy docs:screenshots --list").example("buddy docs:screenshots --only welcome,calendar --viewport mobile").action(async(options)=>{const{captureScreenshots}=await import("@stacksjs/docs/screenshots");const report=await captureScreenshots({config:options.config,outDir:options.out,only:options.only?.split(",").map((value)=>value.trim()).filter(Boolean),viewports:options.viewport?.split(",").map((value)=>value.trim()).filter(Boolean),list:options.list,check:options.check,onProgress:(result)=>{if(!options.json)console.log(`${result.status} ${result.id}/${result.profile}/${result.viewport.name}`)}});if(options.json){console.log(JSON.stringify(report,null,2));if(report.results.some((result)=>result.status==="failed"))process.exitCode=1;return}if(options.list)for(const screen of report.inventory)console.log(`${screen.id} ${screen.path}${screen.skip?` [excluded: ${screen.skip}]`:""}`);if(options.list)for(const model of report.models.models)console.log(`${model.name} (${model.table||"table inferred"}, key ${model.primaryKey}): ${model.factoryFields.length} factories, seeder count ${model.seederCount??"not declared"}, parents ${model.parents.join(", ")||"none"}, required overrides ${model.requiredWithoutFactory.join(", ")||"none"}, sensitive fields ${model.sensitiveFields.join(", ")||"none"}, states ${model.suggestedStates.join(", ")}`);if(options.list&&report.models.cycles.length)console.log(`Cyclic model dependencies: ${report.models.cycles.join(", ")}`);if(options.list&&report.models.externalParents.length)console.log(`Parent fixtures outside this model set: ${report.models.externalParents.join(", ")}`);const failed=report.results.filter((result)=>result.status==="failed");for(const result of failed)console.error(`${result.id}/${result.profile}/${result.viewport.name}: ${result.error}`);console.log(options.list?"Screenshot configuration and template coverage verified.":`${report.results.filter((result)=>result.status==="captured").length} captures, ${failed.length} failed, ${report.results.filter((result)=>result.status==="skipped").length} explained exclusions.`);if(failed.length)process.exitCode=1});for(const check of[false,true]){buddy.command(check?"docs:style-guide:check":"docs:style-guide",check?"Verify generated application style guide freshness":"Generate a branded application component style guide").option("--config <path>","Style guide configuration path",{default:"config/style-guide.ts"}).action(async(options)=>{const{runStyleGuide}=await import("@stacksjs/docs/style-guide");const result=await runStyleGuide({config:options.config,check});console.log(`${check?"Verified":"Generated"} style guide: ${result.components} components, ${result.stories} stories, ${result.variants} variants.`)})}buddy.command("docs:native-skills","Regenerate native skill package coverage and driver evidence").action(async()=>{await runTool(runNativeSkills,"--write")});buddy.command("docs:native-skills:check","Verify native skills cover current packages and driver capabilities").action(async()=>{await runTool(runNativeSkills,"--check")});buddy.command("docs:buddy","Regenerate the buddy command reference doc").action(async()=>{await runTool(runBuddyDocs,"--write")});buddy.command("docs:buddy:check","Verify the buddy command reference doc is current").action(async()=>{await runTool(runBuddyDocs,"--check")});buddy.command("docs:artifacts","Regenerate the generated API artifacts (OpenAPI + types)").action(async()=>{await runTool(runArtifacts,"--write")});buddy.command("docs:artifacts:check","Verify the generated API artifacts are current").action(async()=>{await runTool(runArtifacts,"--check")});buddy.command("docs:agent-counts","Rewrite the counts AGENTS.md and the skills state, from the tree").action(async()=>{await runTool(runAgentCounts,"--write")});buddy.command("docs:agent-counts:check","Verify the counts AGENTS.md and the skills state are current").action(async()=>{await runTool(runAgentCounts,"--check")});buddy.command("docs:capabilities","Regenerate the driver capability matrix in docs/features/capabilities.md").action(async()=>{await runTool(runCapabilities,"--write")});buddy.command("docs:capabilities:check","Verify the published capability matrix matches its registry").action(async()=>{await runTool(runCapabilities,"--check")});buddy.command("docs:desktop-matrix","Regenerate the desktop support matrix in docs/packages/desktop.md").action(async()=>{await runTool(runDesktopMatrix,"--write")});buddy.command("docs:desktop-matrix:check","Verify the published desktop support matrix matches its source").action(async()=>{await runTool(runDesktopMatrix,"--check")});buddy.command("docs:snippets","Record the documented imports that do not compile, as the baseline").action(async()=>{await runTool(runSnippets,"--write")});buddy.command("docs:snippets:check","Verify no NEW documented import fails to compile").action(async()=>{await runTool(runSnippets,"--check")});buddy.command("docs:links","Report internal documentation links").action(async()=>{await runTool(runLinks)});buddy.command("docs:links:check","Verify internal documentation links resolve").action(async()=>{await runTool(runLinks,"--check")})}
@@ -1,2 +1,3 @@
1
- import process from"node:process";import{runAction}from"@stacksjs/actions/run-action";import{intro,log,onUnknownSubcommand,outro}from"@stacksjs/cli";import{Action}from"@stacksjs/enums";import{projectPath}from"@stacksjs/path";import{ExitCode}from"@stacksjs/types";import{resultFailed}from"../result";function testPathEnv(paths){return paths?.length?{STACKS_TEST_PATHS:JSON.stringify(paths)}:undefined}function scopedTests(label,paths){if(!paths?.length)return label;return`${label} for ${paths.length===1?paths[0]:`${paths.length} paths`}`}export function test(buddy){const descriptions={command:"Runs your test suite",types:"Typechecks your codebase",coverage:"Generates a test coverage report",ui:"Runs your test suite in the browser",unit:"Runs your unit tests",feature:"Runs your feature tests",showReport:"Show the test report",project:"Target a specific project",verbose:"Enable verbose output"};buddy.command("test [...paths]",descriptions.command).option("-f, --feature",descriptions.feature,{default:false}).option("-u, --unit",descriptions.unit,{default:false}).option("-p, --project [project]",descriptions.project,{default:false}).option("--verbose",descriptions.verbose,{default:true}).example("buddy test").example("buddy test tests/unit/auth.test.ts").example("buddy test storage/framework/core/scheduler/tests").action(async(paths,options)=>{const perf=await intro("buddy test");const env=testPathEnv(paths);if(options.feature&&options.unit){const result=await runAction(Action.Test,{...options,cwd:projectPath(),env});if(resultFailed(result)){await outro("While running `buddy test`, there was an issue",{startTime:perf,useSeconds:true},result.error);process.exit(ExitCode.FatalError)}}if(options.feature&&!options.unit){log.info("Running Feature tests...");const result=await runAction(Action.TestFeature,{...options,cwd:projectPath(),env});if(resultFailed(result)){await outro("While running `buddy test`, there was an issue",{startTime:perf,useSeconds:true},result.error);process.exit(ExitCode.FatalError)}}if(!options.feature&&options.unit){log.info("Running Unit tests...");const result=await runAction(Action.TestUnit,{...options,cwd:projectPath(),env});if(resultFailed(result)){await outro("While running `buddy test`, there was an issue",{startTime:perf,useSeconds:true},result.error);process.exit(ExitCode.FatalError)}}if(!options.feature&&!options.unit){const result=await runAction(Action.Test,{...options,cwd:projectPath(),env});if(resultFailed(result)){await outro("While running `buddy test`, there was an issue",{startTime:perf,useSeconds:true},result.error);process.exit(ExitCode.FatalError)}}await outro(scopedTests("Finished running tests",paths),{startTime:perf,useSeconds:true});process.exit(ExitCode.Success)});buddy.command("test:unit [...paths]",descriptions.unit).option("--verbose",descriptions.verbose,{default:false}).example("buddy test:unit").example("buddy test:unit tests/unit/auth.test.ts").action(async(paths,options)=>{const perf=await intro("buddy test:unit");const result=await runAction(Action.TestUnit,{...options,verbose:true,cwd:projectPath(),env:testPathEnv(paths)});if(resultFailed(result)){await outro("While running `buddy test:unit`, there was an issue",{startTime:perf,useSeconds:true},result.error);process.exit(ExitCode.FatalError)}await outro(scopedTests("Finished running unit tests",paths),{startTime:perf,useSeconds:true})});buddy.command("test:feature [...paths]",descriptions.feature).option("--verbose",descriptions.verbose,{default:false}).example("buddy test:feature").example("buddy test:feature tests/feature/login.test.ts").action(async(paths,options)=>{const perf=await intro("buddy test:feature");const result=await runAction(Action.TestFeature,{...options,verbose:true,cwd:projectPath(),env:testPathEnv(paths)});if(resultFailed(result)){await outro("While running `buddy test:feature`, there was an issue",{startTime:perf,useSeconds:true},result.error);process.exit(ExitCode.FatalError)}await outro(scopedTests("Finished running feature tests",paths),{startTime:perf,useSeconds:true})});buddy.command("test:ui",descriptions.command).option("--verbose",descriptions.verbose,{default:false}).action(async(options)=>{const perf=await intro("buddy test:ui");const result=await runAction(Action.TestUi,{...options,verbose:true,cwd:projectPath()});if(resultFailed(result)){await outro("While running `buddy test:ui`, there was an issue",{startTime:perf,useSeconds:true},result.error);process.exit(ExitCode.FatalError)}await outro("Finished running tests in the browser",{startTime:perf,useSeconds:true})});buddy.command("test:types",descriptions.types).alias("typecheck").option("--verbose",descriptions.verbose,{default:false}).action(async(options)=>{const perf=await intro("buddy test:types");const result=await runAction(Action.Typecheck,{...options,verbose:true,cwd:projectPath()});if(resultFailed(result)){await outro("While running `buddy test:types`, there was an issue",{startTime:perf,useSeconds:true},result.error);process.exit(ExitCode.FatalError)}await outro("Finished running typecheck",{startTime:perf,useSeconds:true})});buddy.command("test:page-audit","Loads pages in headless Chrome and reports duplicate API requests, failed requests and console errors").option("--url <urls>","Page URLs to audit, comma-separated (paths resolve against --base)").option("--base [base]","Origin that paths in --url resolve against",{default:"http://localhost:3000"}).option("--quiet-ms [ms]","How long the network must stay quiet before a page counts as loaded",{default:1000}).option("--timeout [ms]","Give up waiting for a page to settle after this long",{default:15000}).option("--mobile","Audit at a 390px phone viewport instead of 1440px",{default:false}).option("--json","Print the reports as JSON",{default:false}).example("buddy test:page-audit --url /,/dashboard --base http://localhost:3000").example("buddy test:page-audit --url http://localhost:3000/pricing --json").action(async(options)=>{const targets=String(options.url??"").split(",").map((url)=>url.trim()).filter(Boolean);if(!targets.length){await log.error("Pass the pages to audit with --url (comma-separated URLs or paths)");process.exit(ExitCode.InvalidArgument)}const{auditPage,formatPageAudit,launch,pageAuditClean}=await import("@stacksjs/testing/browser");const viewport=options.mobile?{width:390,height:844,mobile:true,deviceScaleFactor:2}:{width:1440,height:900};const{cdp,close}=await launch({viewport});const reports=[];try{for(const target of targets){const url=new URL(target,options.base||"http://localhost:3000").href;const report=await auditPage(url,{cdp,quietMs:Number(options.quietMs)||1000,timeoutMs:Number(options.timeout)||15000});reports.push(report);if(!options.json)await log.info(formatPageAudit(report))}}finally{await close()}if(options.json)process.stdout.write(`${JSON.stringify(reports,null,2)}
2
- `);process.exit(reports.every(pageAuditClean)?ExitCode.Success:ExitCode.FatalError)});onUnknownSubcommand(buddy,"test")}
1
+ import process from"node:process";import{runAction}from"@stacksjs/actions/run-action";import{intro,log,onUnknownSubcommand,outro}from"@stacksjs/cli";import{Action}from"@stacksjs/enums";import{projectPath}from"@stacksjs/path";import{ExitCode}from"@stacksjs/types";import{resultFailed}from"../result";function testPathEnv(paths){return paths?.length?{STACKS_TEST_PATHS:JSON.stringify(paths)}:undefined}function scopedTests(label,paths){if(!paths?.length)return label;return`${label} for ${paths.length===1?paths[0]:`${paths.length} paths`}`}export function test(buddy){const descriptions={command:"Runs your test suite",types:"Typechecks your codebase",coverage:"Generates a test coverage report",ui:"Runs your test suite in the browser",unit:"Runs your unit tests",feature:"Runs your feature tests",showReport:"Show the test report",project:"Target a specific project",verbose:"Enable verbose output"};buddy.command("test [...paths]",descriptions.command).option("-f, --feature",descriptions.feature,{default:false}).option("-u, --unit",descriptions.unit,{default:false}).option("-p, --project [project]",descriptions.project,{default:false}).option("--verbose",descriptions.verbose,{default:true}).example("buddy test").example("buddy test tests/unit/auth.test.ts").example("buddy test storage/framework/core/scheduler/tests").action(async(paths,options)=>{const perf=await intro("buddy test");const env=testPathEnv(paths);if(options.feature&&options.unit){const result=await runAction(Action.Test,{...options,cwd:projectPath(),env});if(resultFailed(result)){await outro("While running `buddy test`, there was an issue",{startTime:perf,useSeconds:true},result.error);process.exit(ExitCode.FatalError)}}if(options.feature&&!options.unit){log.info("Running Feature tests...");const result=await runAction(Action.TestFeature,{...options,cwd:projectPath(),env});if(resultFailed(result)){await outro("While running `buddy test`, there was an issue",{startTime:perf,useSeconds:true},result.error);process.exit(ExitCode.FatalError)}}if(!options.feature&&options.unit){log.info("Running Unit tests...");const result=await runAction(Action.TestUnit,{...options,cwd:projectPath(),env});if(resultFailed(result)){await outro("While running `buddy test`, there was an issue",{startTime:perf,useSeconds:true},result.error);process.exit(ExitCode.FatalError)}}if(!options.feature&&!options.unit){const result=await runAction(Action.Test,{...options,cwd:projectPath(),env});if(resultFailed(result)){await outro("While running `buddy test`, there was an issue",{startTime:perf,useSeconds:true},result.error);process.exit(ExitCode.FatalError)}}await outro(scopedTests("Finished running tests",paths),{startTime:perf,useSeconds:true});process.exit(ExitCode.Success)});buddy.command("test:unit [...paths]",descriptions.unit).option("--verbose",descriptions.verbose,{default:false}).example("buddy test:unit").example("buddy test:unit tests/unit/auth.test.ts").action(async(paths,options)=>{const perf=await intro("buddy test:unit");const result=await runAction(Action.TestUnit,{...options,verbose:true,cwd:projectPath(),env:testPathEnv(paths)});if(resultFailed(result)){await outro("While running `buddy test:unit`, there was an issue",{startTime:perf,useSeconds:true},result.error);process.exit(ExitCode.FatalError)}await outro(scopedTests("Finished running unit tests",paths),{startTime:perf,useSeconds:true})});buddy.command("test:feature [...paths]",descriptions.feature).option("--verbose",descriptions.verbose,{default:false}).example("buddy test:feature").example("buddy test:feature tests/feature/login.test.ts").action(async(paths,options)=>{const perf=await intro("buddy test:feature");const result=await runAction(Action.TestFeature,{...options,verbose:true,cwd:projectPath(),env:testPathEnv(paths)});if(resultFailed(result)){await outro("While running `buddy test:feature`, there was an issue",{startTime:perf,useSeconds:true},result.error);process.exit(ExitCode.FatalError)}await outro(scopedTests("Finished running feature tests",paths),{startTime:perf,useSeconds:true})});buddy.command("test:ui",descriptions.command).option("--verbose",descriptions.verbose,{default:false}).action(async(options)=>{const perf=await intro("buddy test:ui");const result=await runAction(Action.TestUi,{...options,verbose:true,cwd:projectPath()});if(resultFailed(result)){await outro("While running `buddy test:ui`, there was an issue",{startTime:perf,useSeconds:true},result.error);process.exit(ExitCode.FatalError)}await outro("Finished running tests in the browser",{startTime:perf,useSeconds:true})});buddy.command("test:types",descriptions.types).alias("typecheck").option("--verbose",descriptions.verbose,{default:false}).action(async(options)=>{const perf=await intro("buddy test:types");const result=await runAction(Action.Typecheck,{...options,verbose:true,cwd:projectPath()});if(resultFailed(result)){await outro("While running `buddy test:types`, there was an issue",{startTime:perf,useSeconds:true},result.error);process.exit(ExitCode.FatalError)}await outro("Finished running typecheck",{startTime:perf,useSeconds:true})});buddy.command("test:page-audit","Loads pages in headless Chrome and reports duplicate API requests, failed requests and console errors").option("--url <urls>","Page URLs to audit, comma-separated (paths resolve against --base)").option("--base [base]","Origin that paths in --url resolve against",{default:"http://localhost:3000"}).option("--quiet-ms [ms]","How long the network must stay quiet before a page counts as loaded",{default:1000}).option("--timeout [ms]","Give up waiting for a page to settle after this long",{default:15000}).option("--mobile","Audit at a 390px phone viewport instead of 1440px",{default:false}).option("--json","Print the reports as JSON",{default:false}).option("--lighthouse","Also measure Performance, Accessibility, Best Practices and SEO with Lighthouse",{default:false}).option("--sitemap <file>","Audit every page in a local sitemap on --base").option("--device <device>","Lighthouse profile: mobile, desktop or both",{default:"both"}).option("--basic-auth","Authenticate on --base using STACKS_AUDIT_USERNAME and STACKS_AUDIT_PASSWORD",{default:false}).option("--min-score <score>","Required Lighthouse score in every category, from 0 to 100",{default:100}).option("--output <directory>","Directory for Lighthouse JSON, HTML and summary reports",{default:"storage/framework/testing/lighthouse"}).example("buddy test:page-audit --url /,/dashboard --base http://localhost:3000").example("buddy test:page-audit --url http://localhost:3000/pricing --json").example("buddy test:page-audit --lighthouse --sitemap public/sitemap.xml --base http://localhost:3000 --min-score 100").action(async(options)=>{const{auditLighthouse,basicAuditOrigin,formatLighthouseResult,lighthouseTargets}=await import("@stacksjs/testing/lighthouse");const base=options.base||"http://localhost:3000";const username=process.env.STACKS_AUDIT_USERNAME;const password=process.env.STACKS_AUDIT_PASSWORD;let targets;let authOrigin;try{targets=await lighthouseTargets(options);if(options.basicAuth){authOrigin=basicAuditOrigin(base,targets);if(!username||!password)throw new TypeError("Set STACKS_AUDIT_USERNAME and STACKS_AUDIT_PASSWORD for --basic-auth");delete process.env.STACKS_AUDIT_USERNAME;delete process.env.STACKS_AUDIT_PASSWORD}if(options.lighthouse){if(!["mobile","desktop","both"].includes(options.device||"both"))throw new TypeError("Choose mobile, desktop or both");const minimum=Number(options.minScore??100);if(!Number.isFinite(minimum)||minimum<0||minimum>100)throw new TypeError("Minimum score must be between 0 and 100")}}catch(error){await log.error(error instanceof Error?error.message:String(error));process.exit(ExitCode.InvalidArgument)}const{auditPage,formatPageAudit,installBasicAuth,launch,pageAuditClean}=await import("@stacksjs/testing/browser");const viewport=options.mobile?{width:390,height:844,mobile:true,deviceScaleFactor:2}:{width:1440,height:900};const{cdp,close,port}=await launch({viewport,shared:authOrigin?false:undefined});const reports=[];let lighthouse=[];try{if(authOrigin)await installBasicAuth(cdp,authOrigin,username,password);for(const target of targets){const url=new URL(target,base).href;const report=await auditPage(url,{cdp,quietMs:Number(options.quietMs)||1000,timeoutMs:Number(options.timeout)||15000});reports.push(report);if(!options.json)await log.info(formatPageAudit(report))}if(!authOrigin)await close();if(options.lighthouse){if(authOrigin)await cdp.send("Page.navigate",{url:"about:blank"});lighthouse=await auditLighthouse({urls:targets,outputDir:options.output||projectPath("storage/framework/testing/lighthouse"),device:options.device,minimum:Number(options.minScore??100),chromePort:authOrigin?port:undefined,onResult:(result)=>{if(!options.json)process.stdout.write(`${formatLighthouseResult(result)}
2
+ `)}})}}finally{await close()}if(options.json)process.stdout.write(`${JSON.stringify(options.lighthouse?{pages:reports,lighthouse}:reports,null,2)}
3
+ `);process.exit(reports.every(pageAuditClean)&&lighthouse.every((result)=>result.passed)?ExitCode.Success:ExitCode.FatalError)});onUnknownSubcommand(buddy,"test")}
@@ -1 +1 @@
1
- import{existsSync,readFileSync}from"node:fs";import{join}from"node:path";import{projectWorkflowClient}from"../workflow-client";import{loadWorkflowConfig,runWorkflowStep,writeProjectWorkflow,writeWorkflowReleaseState}from"../workflow-project";export function workflow(buddy){buddy.command("workflow:setup","Generate the normal Stacks workflow from config/workflows.ts").option("--force","Replace a reviewed existing custom workflow",{default:false}).option("--check","Verify committed workflow bytes without changing them",{default:false}).action(async(options)=>{const root=process.cwd();const config=await loadWorkflowConfig(root);if(options.check){const{renderReviewOsWorkflow}=await import("../workflow-template");const file=join(root,".reviewos/workflows/ci.yml");if(!existsSync(file)||readFileSync(file,"utf8")!==renderReviewOsWorkflow(config))throw new Error("Regenerate the workflow with buddy workflow:setup")}else console.log(writeProjectWorkflow(root,config,options.force))});buddy.command("workflow:step <step>","Run one declared application step through Stacks").action(async(step)=>{await runWorkflowStep(process.cwd(),step)});buddy.command("workflow:release-state","Verify the committed release identity and set its upload output").action(async()=>{await writeWorkflowReleaseState(process.cwd())});buddy.command("workflow:runs [file]","Read the exact-source workflow run history").option("--sha <sha>","Filter by the full source commit").action(async(file,options)=>{const config=await loadWorkflowConfig(process.cwd());console.log(JSON.stringify(await projectWorkflowClient(config).runs(file??"ci.yml",{branch:config.branch??"main",sha:options.sha})))});buddy.command("workflow:show <number>","Read actual workflow job and step execution").action(async(number)=>{console.log(JSON.stringify(await projectWorkflowClient(await loadWorkflowConfig(process.cwd())).run(Number(number))))});buddy.command("workflow:run [file]","Start a configured workflow using its normal API").option("--ref <ref>","Source branch or revision").option("--inputs <json>","Workflow input values as JSON, without credentials").action(async(file,options)=>{const config=await loadWorkflowConfig(process.cwd());const inputs=options.inputs?JSON.parse(options.inputs):{};console.log(JSON.stringify(await projectWorkflowClient(config).dispatch(file??"ci.yml",options.ref??config.branch??"main",inputs)))});buddy.command("workflow:artifacts <number>","Read retained artifact identities and digests").action(async(number)=>{console.log(JSON.stringify(await projectWorkflowClient(await loadWorkflowConfig(process.cwd())).artifacts(Number(number))))})}
1
+ import{print}from"@stacksjs/cli/output";import{existsSync,readFileSync}from"node:fs";import{join}from"node:path";import{projectWorkflowClient}from"../workflow-client";import{checkNativeWorkflowCredentials,loadWorkflowConfig,runWorkflowStep,writeProjectWorkflow,writeWorkflowReleaseState}from"../workflow-project";export function workflow(buddy){buddy.command("workflow:setup","Generate the normal Stacks workflow from config/workflows.ts").option("--force","Replace a reviewed existing custom workflow",{default:false}).option("--check","Verify committed workflow bytes without changing them",{default:false}).action(async(options)=>{const root=process.cwd();const config=await loadWorkflowConfig(root);if(options.check){const{renderReviewOsWorkflow}=await import("../workflow-template");const file=join(root,".reviewos/workflows/ci.yml");if(!existsSync(file)||readFileSync(file,"utf8")!==renderReviewOsWorkflow(config))throw new Error("Regenerate the workflow with buddy workflow:setup")}else console.log(writeProjectWorkflow(root,config,options.force))});buddy.command("workflow:step <step>","Run one declared application step through Stacks").action(async(step)=>{await runWorkflowStep(process.cwd(),step)});buddy.command("workflow:check-credentials <phase>","Check native-accept or native-release inputs without printing credentials").action(async(phase)=>{await checkNativeWorkflowCredentials(process.cwd(),phase);print(`Workflow ${phase} credentials are configured.`)});buddy.command("workflow:release-state","Verify the committed release identity and set its upload output").action(async()=>{await writeWorkflowReleaseState(process.cwd())});buddy.command("workflow:runs [file]","Read the exact-source workflow run history").option("--sha <sha>","Filter by the full source commit").action(async(file,options)=>{const config=await loadWorkflowConfig(process.cwd());console.log(JSON.stringify(await projectWorkflowClient(config).runs(file??"ci.yml",{branch:config.branch??"main",sha:options.sha})))});buddy.command("workflow:show <number>","Read actual workflow job and step execution").action(async(number)=>{console.log(JSON.stringify(await projectWorkflowClient(await loadWorkflowConfig(process.cwd())).run(Number(number))))});buddy.command("workflow:run [file]","Start a configured workflow using its normal API").option("--ref <ref>","Source branch or revision").option("--inputs <json>","Workflow input values as JSON, without credentials").action(async(file,options)=>{const config=await loadWorkflowConfig(process.cwd());const inputs=options.inputs?JSON.parse(options.inputs):{};console.log(JSON.stringify(await projectWorkflowClient(config).dispatch(file??"ci.yml",options.ref??config.branch??"main",inputs)))});buddy.command("workflow:artifacts <number>","Read retained artifact identities and digests").action(async(number)=>{console.log(JSON.stringify(await projectWorkflowClient(await loadWorkflowConfig(process.cwd())).artifacts(Number(number))))})}
@@ -1 +1 @@
1
- export async function withTimeout(work,ms){let timeoutId;const deadline=new Promise((_,reject)=>{timeoutId=setTimeout(()=>reject(new Error("timeout")),ms)});try{return await Promise.race([work,deadline])}finally{if(timeoutId!==undefined)clearTimeout(timeoutId)}}const commandRegistry={about:{path:"./commands/about.js",load:()=>import("./commands/about.js"),exportName:"about"},add:{path:"./commands/add.js",load:()=>import("./commands/add.js"),exportName:"add"},"ai:access":{path:"./commands/ai-access.js",load:()=>import("./commands/ai-access.js"),exportName:"aiAccess"},"ai:context":{path:"./commands/ai-context.js",load:()=>import("./commands/ai-context.js"),exportName:"aiContext"},auth:{path:"./commands/auth.js",load:()=>import("./commands/auth.js"),exportName:"auth"},build:{path:"./commands/build.js",load:()=>import("./commands/build.js"),exportName:"build"},cd:{path:"./commands/cd.js",load:()=>import("./commands/cd.js"),exportName:"cd"},daemon:{path:"./commands/daemon.js",load:()=>import("./commands/daemon.js"),exportName:"daemon"},dashboard:{path:"./commands/dashboard.js",load:()=>import("./commands/dashboard.js"),exportName:"dashboard"},changelog:{path:"./commands/changelog.js",load:()=>import("./commands/changelog.js"),exportName:"changelog"},clean:{path:"./commands/clean.js",load:()=>import("./commands/clean.js"),exportName:"clean"},cloud:{path:"./commands/cloud.js",load:()=>import("./commands/cloud.js"),exportName:"cloud"},commit:{path:"./commands/commit.js",load:()=>import("./commands/commit.js"),exportName:"commit"},completion:{path:"./commands/completion.js",load:()=>import("./commands/completion.js"),exportName:"completion"},"config:migrate":{path:"./commands/config-migrate.js",load:()=>import("./commands/config-migrate.js"),exportName:"configMigrate"},configure:{path:"./commands/configure.js",load:()=>import("./commands/configure.js"),exportName:"configure"},create:{path:"./commands/create.js",load:()=>import("./commands/create.js"),exportName:"create"},new:{path:"./commands/create.js",load:()=>import("./commands/create.js"),exportName:"create"},deploy:{path:"./commands/deploy.js",load:()=>import("./commands/deploy.js"),exportName:"deploy"},"deploy:rollback":{path:"./commands/deploy.js",load:()=>import("./commands/deploy.js"),exportName:"deploy"},dev:{path:"./commands/dev.js",load:()=>import("./commands/dev.js"),exportName:"dev"},"desktop:apple:doctor":{path:"./commands/desktop-apple.js",load:()=>import("./commands/desktop-apple.js"),exportName:"desktopApple"},"desktop:apple:csr":{path:"./commands/desktop-apple.js",load:()=>import("./commands/desktop-apple.js"),exportName:"desktopApple"},"desktop:apple:init":{path:"./commands/desktop-apple.js",load:()=>import("./commands/desktop-apple.js"),exportName:"desktopApple"},"desktop:apple:package":{path:"./commands/desktop-apple.js",load:()=>import("./commands/desktop-apple.js"),exportName:"desktopApple"},"desktop:apple:provision":{path:"./commands/desktop-apple.js",load:()=>import("./commands/desktop-apple.js"),exportName:"desktopApple"},"desktop:apple:publish":{path:"./commands/desktop-apple.js",load:()=>import("./commands/desktop-apple.js"),exportName:"desktopApple"},"desktop:update:keypair":{path:"./commands/desktop-release.js",load:()=>import("./commands/desktop-release.js"),exportName:"desktopRelease"},"release:desktop":{path:"./commands/desktop-release.js",load:()=>import("./commands/desktop-release.js"),exportName:"desktopRelease"},"desktop:probe":{path:"./commands/desktop-probe.js",load:()=>import("./commands/desktop-probe.js"),exportName:"desktopProbe"},"integrations:probe":{path:"./commands/integrations-probe.js",load:()=>import("./commands/integrations-probe.js"),exportName:"integrationsProbe"},dns:{path:"./commands/dns.js",load:()=>import("./commands/dns.js"),exportName:"dns"},"dns:pull":{path:"./commands/dns.js",load:()=>import("./commands/dns.js"),exportName:"dns"},"dns:diff":{path:"./commands/dns.js",load:()=>import("./commands/dns.js"),exportName:"dns"},"dns:sync":{path:"./commands/dns.js",load:()=>import("./commands/dns.js"),exportName:"dns"},doctor:{path:"./commands/doctor.js",load:()=>import("./commands/doctor.js"),exportName:"doctor"},domains:{path:"./commands/domains.js",load:()=>import("./commands/domains.js"),exportName:"domains"},email:{path:"./commands/email.js",load:()=>import("./commands/email.js"),exportName:"email"},env:{path:"./commands/env.js",load:()=>import("./commands/env.js"),exportName:"env"},"extension:init":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:build":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:package":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:chrome:publish":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:chrome:status":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:firefox:publish":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:safari:init":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:safari:provision":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:safari:app":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:safari:publish":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"dashboard:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"dashboard:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"commerce:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"commerce:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"commerce:import":{path:"./commands/commerce-import.js",load:()=>import("./commands/commerce-import.js"),exportName:"commerceImport"},"cms:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"cms:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"marketing:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"marketing:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"monitoring:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"monitoring:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"realtime:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"realtime:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"queue:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"queue:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"db:backup":{path:"./commands/db.js",load:()=>import("./commands/db.js"),exportName:"db"},"db:backups":{path:"./commands/db.js",load:()=>import("./commands/db.js"),exportName:"db"},"db:restore":{path:"./commands/db.js",load:()=>import("./commands/db.js"),exportName:"db"},"storage:backup":{path:"./commands/storage-backup.js",load:()=>import("./commands/storage-backup.js"),exportName:"storageBackup"},"storage:backups":{path:"./commands/storage-backup.js",load:()=>import("./commands/storage-backup.js"),exportName:"storageBackup"},"storage:restore":{path:"./commands/storage-backup.js",load:()=>import("./commands/storage-backup.js"),exportName:"storageBackup"},"feedback:invite":{path:"./commands/feedback.js",load:()=>import("./commands/feedback.js"),exportName:"feedback"},"feedback:tokens":{path:"./commands/feedback.js",load:()=>import("./commands/feedback.js"),exportName:"feedback"},"feedback:revoke":{path:"./commands/feedback.js",load:()=>import("./commands/feedback.js"),exportName:"feedback"},"socials:identities":{path:"./commands/socials.js",load:()=>import("./commands/socials.js"),exportName:"socials"},"socials:authorize":{path:"./commands/socials.js",load:()=>import("./commands/socials.js"),exportName:"socials"},fresh:{path:"./commands/fresh.js",load:()=>import("./commands/fresh.js"),exportName:"fresh"},generate:{path:"./commands/generate.js",load:()=>import("./commands/generate.js"),exportName:"generate"},"gdpr:export":{path:"./commands/gdpr.js",load:()=>import("./commands/gdpr.js"),exportName:"gdpr"},"gdpr:erase":{path:"./commands/gdpr.js",load:()=>import("./commands/gdpr.js"),exportName:"gdpr"},"gdpr:prune":{path:"./commands/gdpr.js",load:()=>import("./commands/gdpr.js"),exportName:"gdpr"},"gdpr:register":{path:"./commands/gdpr.js",load:()=>import("./commands/gdpr.js"),exportName:"gdpr"},"gdpr:register:check":{path:"./commands/gdpr.js",load:()=>import("./commands/gdpr.js"),exportName:"gdpr"},"hq:connect":{path:"./commands/hq.js",load:()=>import("./commands/hq.js"),exportName:"hq"},"support:install":{path:"./commands/hq.js",load:()=>import("./commands/hq.js"),exportName:"hq"},"support:doctor":{path:"./commands/hq.js",load:()=>import("./commands/hq.js"),exportName:"hq"},"hq:status":{path:"./commands/hq.js",load:()=>import("./commands/hq.js"),exportName:"hq"},"hq:sync":{path:"./commands/hq.js",load:()=>import("./commands/hq.js"),exportName:"hq"},http:{path:"./commands/http.js",load:()=>import("./commands/http.js"),exportName:"http"},install:{path:"./commands/install.js",load:()=>import("./commands/install.js"),exportName:"install"},key:{path:"./commands/key.js",load:()=>import("./commands/key.js"),exportName:"key"},license:{path:"./commands/license.js",load:()=>import("./commands/license.js"),exportName:"license"},"license:keygen":{path:"./commands/license.js",load:()=>import("./commands/license.js"),exportName:"license"},lint:{path:"./commands/lint.js",load:()=>import("./commands/lint.js"),exportName:"lint"},format:{path:"./commands/lint.js",load:()=>import("./commands/lint.js"),exportName:"lint"},"format:check":{path:"./commands/lint.js",load:()=>import("./commands/lint.js"),exportName:"lint"},libs:{path:"./commands/libs.js",load:()=>import("./commands/libs.js"),exportName:"libs"},libraries:{path:"./commands/libs.js",load:()=>import("./commands/libs.js"),exportName:"libs"},list:{path:"./commands/list.js",load:()=>import("./commands/list.js"),exportName:"list"},mail:{path:"./commands/mail.js",load:()=>import("./commands/mail.js"),exportName:"mailCommands"},"mail:preview":{path:"./commands/mail.js",load:()=>import("./commands/mail.js"),exportName:"mailCommands"},maintenance:{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},down:{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},up:{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},status:{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},"coming-soon":{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},"coming-soon:status":{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},launch:{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},make:{path:"./commands/make.js",load:()=>import("./commands/make.js"),exportName:"make"},"scaffold:crud":{path:"./commands/make.js",load:()=>import("./commands/make.js"),exportName:"make"},migrate:{path:"./commands/migrate.js",load:()=>import("./commands/migrate.js"),exportName:"migrate"},"migrate:fresh":{path:"./commands/migrate.js",load:()=>import("./commands/migrate.js"),exportName:"migrate"},"migrate:switch":{path:"./commands/migrate.js",load:()=>import("./commands/migrate.js"),exportName:"migrate"},"migrate:project":{path:"./commands/migrate-project.js",load:()=>import("./commands/migrate-project.js"),exportName:"migrateProject"},outdated:{path:"./commands/outdated.js",load:()=>import("./commands/outdated.js"),exportName:"outdated"},package:{path:"./commands/package.js",load:()=>import("./commands/package.js"),exportName:"packageCommands"},phone:{path:"./commands/phone.js",load:()=>import("./commands/phone.js"),exportName:"phone"},ports:{path:"./commands/ports.js",load:()=>import("./commands/ports.js"),exportName:"ports"},"security:scan":{path:"./commands/security.js",load:()=>import("./commands/security.js"),exportName:"security"},audit:{path:"./commands/security.js",load:()=>import("./commands/security.js"),exportName:"security"},"server:flash":{path:"./commands/server.js",load:()=>import("./commands/server.js"),exportName:"server"},"server:first-boot":{path:"./commands/server.js",load:()=>import("./commands/server.js"),exportName:"server"},"server:doctor":{path:"./commands/server.js",load:()=>import("./commands/server.js"),exportName:"server"},"server:setup":{path:"./commands/server.js",load:()=>import("./commands/server.js"),exportName:"server"},"server:trust":{path:"./commands/server.js",load:()=>import("./commands/server.js"),exportName:"server"},"link:core":{path:"./commands/link.js",load:()=>import("./commands/link.js"),exportName:"link"},"comments:list":{path:"./commands/comments.js",load:()=>import("./commands/comments.js"),exportName:"commentsCommands"},"comments:approve":{path:"./commands/comments.js",load:()=>import("./commands/comments.js"),exportName:"commentsCommands"},"comments:reject":{path:"./commands/comments.js",load:()=>import("./commands/comments.js"),exportName:"commentsCommands"},"comments:delete":{path:"./commands/comments.js",load:()=>import("./commands/comments.js"),exportName:"commentsCommands"},"user:add":{path:"./commands/user.js",load:()=>import("./commands/user.js"),exportName:"user"},"user:list":{path:"./commands/user.js",load:()=>import("./commands/user.js"),exportName:"user"},"user:audit":{path:"./commands/user.js",load:()=>import("./commands/user.js"),exportName:"user"},"unlink:core":{path:"./commands/link.js",load:()=>import("./commands/link.js"),exportName:"link"},prepublish:{path:"./commands/prepublish.js",load:()=>import("./commands/prepublish.js"),exportName:"prepublish"},projects:{path:"./commands/projects.js",load:()=>import("./commands/projects.js"),exportName:"projects"},publish:{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},"publish:model":{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},"publish:controller":{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},"publish:middleware":{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},"publish:action":{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},"publish:component":{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},"publish:view":{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},"publish:core":{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},"core:status":{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},"publish:defaults":{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},unpublish:{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},queue:{path:"./commands/queue.js",load:()=>import("./commands/queue.js"),exportName:"queue"},release:{path:"./commands/release.js",load:()=>import("./commands/release.js"),exportName:"release"},route:{path:"./commands/route.js",load:()=>import("./commands/route.js"),exportName:"route"},saas:{path:"./commands/saas.js",load:()=>import("./commands/saas.js"),exportName:"saas"},"stripe:setup":{path:"./commands/saas.js",load:()=>import("./commands/saas.js"),exportName:"saas"},schedule:{path:"./commands/schedule.js",load:()=>import("./commands/schedule.js"),exportName:"schedule"},search:{path:"./commands/search.js",load:()=>import("./commands/search.js"),exportName:"search"},"search-engine:update":{path:"./commands/search.js",load:()=>import("./commands/search.js"),exportName:"search"},"search-engine:settings":{path:"./commands/search.js",load:()=>import("./commands/search.js"),exportName:"search"},screenshot:{path:"./commands/screenshot.js",load:()=>import("./commands/screenshot.js"),exportName:"screenshot"},seed:{path:"./commands/seed.js",load:()=>import("./commands/seed.js"),exportName:"seed"},"seed:roles":{path:"./commands/seed.js",load:()=>import("./commands/seed.js"),exportName:"seed"},"roles:seed":{path:"./commands/seed.js",load:()=>import("./commands/seed.js"),exportName:"seed"},"seed:admins":{path:"./commands/seed.js",load:()=>import("./commands/seed.js"),exportName:"seed"},"admins:seed":{path:"./commands/seed.js",load:()=>import("./commands/seed.js"),exportName:"seed"},preview:{path:"./commands/serve.js",load:()=>import("./commands/serve.js"),exportName:"preview"},serve:{path:"./commands/serve.js",load:()=>import("./commands/serve.js"),exportName:"serve"},"serve:api":{path:"./commands/serve.js",load:()=>import("./commands/serve.js"),exportName:"serveApi"},"workflow:setup":{path:"./commands/workflow.js",load:()=>import("./commands/workflow.js"),exportName:"workflow"},"workflow:step":{path:"./commands/workflow.js",load:()=>import("./commands/workflow.js"),exportName:"workflow"},"workflow:release-state":{path:"./commands/workflow.js",load:()=>import("./commands/workflow.js"),exportName:"workflow"},"workflow:runs":{path:"./commands/workflow.js",load:()=>import("./commands/workflow.js"),exportName:"workflow"},"workflow:show":{path:"./commands/workflow.js",load:()=>import("./commands/workflow.js"),exportName:"workflow"},"workflow:run":{path:"./commands/workflow.js",load:()=>import("./commands/workflow.js"),exportName:"workflow"},"workflow:artifacts":{path:"./commands/workflow.js",load:()=>import("./commands/workflow.js"),exportName:"workflow"},setup:{path:"./commands/setup.js",load:()=>import("./commands/setup.js"),exportName:"setup"},ensure:{path:"./commands/setup.js",load:()=>import("./commands/setup.js"),exportName:"setup"},"setup:ai":{path:"./commands/setup.js",load:()=>import("./commands/setup.js"),exportName:"setup"},"setup:ssl":{path:"./commands/setup.js",load:()=>import("./commands/setup.js"),exportName:"setup"},"setup:ios":{path:"./commands/setup.js",load:()=>import("./commands/setup.js"),exportName:"setup"},"setup:oh-my-zsh":{path:"./commands/setup.js",load:()=>import("./commands/setup.js"),exportName:"setup"},"ai:setup":{path:"./commands/setup.js",load:()=>import("./commands/setup.js"),exportName:"setup"},share:{path:"./commands/share.js",load:()=>import("./commands/share.js"),exportName:"share"},"simulator:doctor":{path:"./commands/simulator.js",load:()=>import("./commands/simulator.js"),exportName:"simulator"},"simulator:open":{path:"./commands/simulator.js",load:()=>import("./commands/simulator.js"),exportName:"simulator"},stack:{path:"./commands/stacks.js",load:()=>import("./commands/stacks.js"),exportName:"stacks"},sms:{path:"./commands/sms.js",load:()=>import("./commands/sms.js"),exportName:"sms"},telemetry:{path:"./commands/telemetry.js",load:()=>import("./commands/telemetry.js"),exportName:"telemetryCommand"},test:{path:"./commands/test.js",load:()=>import("./commands/test.js"),exportName:"test"},tinker:{path:"./commands/tinker.js",load:()=>import("./commands/tinker.js"),exportName:"tinker"},types:{path:"./commands/types.js",load:()=>import("./commands/types.js"),exportName:"types"},undeploy:{path:"./commands/cloud.js",load:()=>import("./commands/cloud.js"),exportName:"cloud"},upgrade:{path:"./commands/upgrade.js",load:()=>import("./commands/upgrade.js"),exportName:"upgrade"},version:{path:"./commands/version.js",load:()=>import("./commands/version.js"),exportName:"version"},"docs:screenshots":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"},"docs:style-guide":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"},"docs:style-guide:check":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"},"docs:buddy":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"},"docs:native-skills":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"},"docs:native-skills:check":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"},"docs:buddy:check":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"},"docs:artifacts":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"},"docs:artifacts:check":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"},"docs:links":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"},"docs:links:check":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"}};const commandGroups={minimal:["version","help"],development:["dev","build","test","lint"],database:["migrate","seed","fresh"],scaffolding:["make","generate"],deployment:["deploy","release","cloud","server"],info:["about","doctor","list"]};const loadedRegistrars=new WeakMap;function loaderKey(loader){return`${loader.path}#${loader.exportName}`}export function markLoaded(buddy,commandName){const loader=commandRegistry[commandName];if(!loader)return;let set=loadedRegistrars.get(buddy);if(!set){set=new Set;loadedRegistrars.set(buddy,set)}set.add(loaderKey(loader))}export async function loadCommand(commandName,buddy){const loader=commandRegistry[commandName];if(!loader){return false}let set=loadedRegistrars.get(buddy);if(!set){set=new Set;loadedRegistrars.set(buddy,set)}const key=loaderKey(loader);if(set.has(key))return true;set.add(key);try{const module=await loader.load();const commandFunction=module[loader.exportName];if(typeof commandFunction==="function"){commandFunction(buddy);return true}else{return false}}catch{return false}}export async function loadCommands(commandNames,buddy){const seen=new Set;const unique=[];for(const name of commandNames){const loader=commandRegistry[name];const key=loader?`${loader.path}#${loader.exportName}`:`name:${name}`;if(seen.has(key))continue;seen.add(key);unique.push(name)}await Promise.all(unique.map(async(name)=>{try{await withTimeout(loadCommand(name,buddy),5000)}catch{}}))}export async function loadCommandGroup(groupName,buddy){const commands=commandGroups[groupName];if(commands){await loadCommands(commands,buddy)}}export async function loadAllCommands(buddy){const allCommands=Object.keys(commandRegistry);await loadCommands(allCommands,buddy)}export function getCommandNames(){return Object.keys(commandRegistry)}export function getCommandsToLoad(args){const requestedCommand=args[0];const isVersionFlag=requestedCommand==="--version"||requestedCommand==="-v";const isHelpFlag=requestedCommand==="--help"||requestedCommand==="-h";const isHelpWord=requestedCommand==="help";if(isVersionFlag)return["version"];if(!requestedCommand||isHelpFlag||isHelpWord)return Object.keys(commandRegistry);const baseCommand=requestedCommand.split(":")[0];if(baseCommand==="list"){return["list",...Object.keys(commandRegistry).filter((k)=>k!=="list")]}if(commandRegistry[requestedCommand]){return[requestedCommand]}if(commandRegistry[baseCommand]){return[baseCommand]}return Object.keys(commandRegistry)}
1
+ export async function withTimeout(work,ms){let timeoutId;const deadline=new Promise((_,reject)=>{timeoutId=setTimeout(()=>reject(new Error("timeout")),ms)});try{return await Promise.race([work,deadline])}finally{if(timeoutId!==undefined)clearTimeout(timeoutId)}}const commandRegistry={about:{path:"./commands/about.js",load:()=>import("./commands/about.js"),exportName:"about"},add:{path:"./commands/add.js",load:()=>import("./commands/add.js"),exportName:"add"},"ai:access":{path:"./commands/ai-access.js",load:()=>import("./commands/ai-access.js"),exportName:"aiAccess"},"ai:context":{path:"./commands/ai-context.js",load:()=>import("./commands/ai-context.js"),exportName:"aiContext"},auth:{path:"./commands/auth.js",load:()=>import("./commands/auth.js"),exportName:"auth"},build:{path:"./commands/build.js",load:()=>import("./commands/build.js"),exportName:"build"},cd:{path:"./commands/cd.js",load:()=>import("./commands/cd.js"),exportName:"cd"},daemon:{path:"./commands/daemon.js",load:()=>import("./commands/daemon.js"),exportName:"daemon"},dashboard:{path:"./commands/dashboard.js",load:()=>import("./commands/dashboard.js"),exportName:"dashboard"},changelog:{path:"./commands/changelog.js",load:()=>import("./commands/changelog.js"),exportName:"changelog"},clean:{path:"./commands/clean.js",load:()=>import("./commands/clean.js"),exportName:"clean"},cloud:{path:"./commands/cloud.js",load:()=>import("./commands/cloud.js"),exportName:"cloud"},commit:{path:"./commands/commit.js",load:()=>import("./commands/commit.js"),exportName:"commit"},completion:{path:"./commands/completion.js",load:()=>import("./commands/completion.js"),exportName:"completion"},"config:migrate":{path:"./commands/config-migrate.js",load:()=>import("./commands/config-migrate.js"),exportName:"configMigrate"},configure:{path:"./commands/configure.js",load:()=>import("./commands/configure.js"),exportName:"configure"},create:{path:"./commands/create.js",load:()=>import("./commands/create.js"),exportName:"create"},new:{path:"./commands/create.js",load:()=>import("./commands/create.js"),exportName:"create"},deploy:{path:"./commands/deploy.js",load:()=>import("./commands/deploy.js"),exportName:"deploy"},"deploy:rollback":{path:"./commands/deploy.js",load:()=>import("./commands/deploy.js"),exportName:"deploy"},dev:{path:"./commands/dev.js",load:()=>import("./commands/dev.js"),exportName:"dev"},"desktop:apple:doctor":{path:"./commands/desktop-apple.js",load:()=>import("./commands/desktop-apple.js"),exportName:"desktopApple"},"desktop:apple:csr":{path:"./commands/desktop-apple.js",load:()=>import("./commands/desktop-apple.js"),exportName:"desktopApple"},"desktop:apple:init":{path:"./commands/desktop-apple.js",load:()=>import("./commands/desktop-apple.js"),exportName:"desktopApple"},"desktop:apple:package":{path:"./commands/desktop-apple.js",load:()=>import("./commands/desktop-apple.js"),exportName:"desktopApple"},"desktop:apple:provision":{path:"./commands/desktop-apple.js",load:()=>import("./commands/desktop-apple.js"),exportName:"desktopApple"},"desktop:apple:publish":{path:"./commands/desktop-apple.js",load:()=>import("./commands/desktop-apple.js"),exportName:"desktopApple"},"desktop:update:keypair":{path:"./commands/desktop-release.js",load:()=>import("./commands/desktop-release.js"),exportName:"desktopRelease"},"release:desktop":{path:"./commands/desktop-release.js",load:()=>import("./commands/desktop-release.js"),exportName:"desktopRelease"},"desktop:probe":{path:"./commands/desktop-probe.js",load:()=>import("./commands/desktop-probe.js"),exportName:"desktopProbe"},"integrations:probe":{path:"./commands/integrations-probe.js",load:()=>import("./commands/integrations-probe.js"),exportName:"integrationsProbe"},dns:{path:"./commands/dns.js",load:()=>import("./commands/dns.js"),exportName:"dns"},"dns:pull":{path:"./commands/dns.js",load:()=>import("./commands/dns.js"),exportName:"dns"},"dns:diff":{path:"./commands/dns.js",load:()=>import("./commands/dns.js"),exportName:"dns"},"dns:sync":{path:"./commands/dns.js",load:()=>import("./commands/dns.js"),exportName:"dns"},doctor:{path:"./commands/doctor.js",load:()=>import("./commands/doctor.js"),exportName:"doctor"},domains:{path:"./commands/domains.js",load:()=>import("./commands/domains.js"),exportName:"domains"},email:{path:"./commands/email.js",load:()=>import("./commands/email.js"),exportName:"email"},env:{path:"./commands/env.js",load:()=>import("./commands/env.js"),exportName:"env"},"extension:init":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:build":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:package":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:chrome:publish":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:chrome:status":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:firefox:publish":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:safari:init":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:safari:provision":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:safari:app":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:safari:publish":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"dashboard:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"dashboard:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"commerce:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"commerce:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"commerce:import":{path:"./commands/commerce-import.js",load:()=>import("./commands/commerce-import.js"),exportName:"commerceImport"},"cms:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"cms:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"marketing:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"marketing:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"monitoring:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"monitoring:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"realtime:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"realtime:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"queue:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"queue:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"db:backup":{path:"./commands/db.js",load:()=>import("./commands/db.js"),exportName:"db"},"db:backups":{path:"./commands/db.js",load:()=>import("./commands/db.js"),exportName:"db"},"db:restore":{path:"./commands/db.js",load:()=>import("./commands/db.js"),exportName:"db"},"storage:backup":{path:"./commands/storage-backup.js",load:()=>import("./commands/storage-backup.js"),exportName:"storageBackup"},"storage:backups":{path:"./commands/storage-backup.js",load:()=>import("./commands/storage-backup.js"),exportName:"storageBackup"},"storage:restore":{path:"./commands/storage-backup.js",load:()=>import("./commands/storage-backup.js"),exportName:"storageBackup"},"feedback:invite":{path:"./commands/feedback.js",load:()=>import("./commands/feedback.js"),exportName:"feedback"},"feedback:tokens":{path:"./commands/feedback.js",load:()=>import("./commands/feedback.js"),exportName:"feedback"},"feedback:revoke":{path:"./commands/feedback.js",load:()=>import("./commands/feedback.js"),exportName:"feedback"},"socials:identities":{path:"./commands/socials.js",load:()=>import("./commands/socials.js"),exportName:"socials"},"socials:authorize":{path:"./commands/socials.js",load:()=>import("./commands/socials.js"),exportName:"socials"},fresh:{path:"./commands/fresh.js",load:()=>import("./commands/fresh.js"),exportName:"fresh"},generate:{path:"./commands/generate.js",load:()=>import("./commands/generate.js"),exportName:"generate"},"gdpr:export":{path:"./commands/gdpr.js",load:()=>import("./commands/gdpr.js"),exportName:"gdpr"},"gdpr:erase":{path:"./commands/gdpr.js",load:()=>import("./commands/gdpr.js"),exportName:"gdpr"},"gdpr:prune":{path:"./commands/gdpr.js",load:()=>import("./commands/gdpr.js"),exportName:"gdpr"},"gdpr:register":{path:"./commands/gdpr.js",load:()=>import("./commands/gdpr.js"),exportName:"gdpr"},"gdpr:register:check":{path:"./commands/gdpr.js",load:()=>import("./commands/gdpr.js"),exportName:"gdpr"},"hq:connect":{path:"./commands/hq.js",load:()=>import("./commands/hq.js"),exportName:"hq"},"support:install":{path:"./commands/hq.js",load:()=>import("./commands/hq.js"),exportName:"hq"},"support:doctor":{path:"./commands/hq.js",load:()=>import("./commands/hq.js"),exportName:"hq"},"hq:status":{path:"./commands/hq.js",load:()=>import("./commands/hq.js"),exportName:"hq"},"hq:sync":{path:"./commands/hq.js",load:()=>import("./commands/hq.js"),exportName:"hq"},http:{path:"./commands/http.js",load:()=>import("./commands/http.js"),exportName:"http"},install:{path:"./commands/install.js",load:()=>import("./commands/install.js"),exportName:"install"},key:{path:"./commands/key.js",load:()=>import("./commands/key.js"),exportName:"key"},license:{path:"./commands/license.js",load:()=>import("./commands/license.js"),exportName:"license"},"license:keygen":{path:"./commands/license.js",load:()=>import("./commands/license.js"),exportName:"license"},lint:{path:"./commands/lint.js",load:()=>import("./commands/lint.js"),exportName:"lint"},format:{path:"./commands/lint.js",load:()=>import("./commands/lint.js"),exportName:"lint"},"format:check":{path:"./commands/lint.js",load:()=>import("./commands/lint.js"),exportName:"lint"},libs:{path:"./commands/libs.js",load:()=>import("./commands/libs.js"),exportName:"libs"},libraries:{path:"./commands/libs.js",load:()=>import("./commands/libs.js"),exportName:"libs"},list:{path:"./commands/list.js",load:()=>import("./commands/list.js"),exportName:"list"},mail:{path:"./commands/mail.js",load:()=>import("./commands/mail.js"),exportName:"mailCommands"},"mail:preview":{path:"./commands/mail.js",load:()=>import("./commands/mail.js"),exportName:"mailCommands"},maintenance:{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},down:{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},up:{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},status:{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},"coming-soon":{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},"coming-soon:status":{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},launch:{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},make:{path:"./commands/make.js",load:()=>import("./commands/make.js"),exportName:"make"},"scaffold:crud":{path:"./commands/make.js",load:()=>import("./commands/make.js"),exportName:"make"},migrate:{path:"./commands/migrate.js",load:()=>import("./commands/migrate.js"),exportName:"migrate"},"migrate:fresh":{path:"./commands/migrate.js",load:()=>import("./commands/migrate.js"),exportName:"migrate"},"migrate:switch":{path:"./commands/migrate.js",load:()=>import("./commands/migrate.js"),exportName:"migrate"},"migrate:project":{path:"./commands/migrate-project.js",load:()=>import("./commands/migrate-project.js"),exportName:"migrateProject"},outdated:{path:"./commands/outdated.js",load:()=>import("./commands/outdated.js"),exportName:"outdated"},package:{path:"./commands/package.js",load:()=>import("./commands/package.js"),exportName:"packageCommands"},phone:{path:"./commands/phone.js",load:()=>import("./commands/phone.js"),exportName:"phone"},ports:{path:"./commands/ports.js",load:()=>import("./commands/ports.js"),exportName:"ports"},"security:scan":{path:"./commands/security.js",load:()=>import("./commands/security.js"),exportName:"security"},audit:{path:"./commands/security.js",load:()=>import("./commands/security.js"),exportName:"security"},"server:flash":{path:"./commands/server.js",load:()=>import("./commands/server.js"),exportName:"server"},"server:first-boot":{path:"./commands/server.js",load:()=>import("./commands/server.js"),exportName:"server"},"server:doctor":{path:"./commands/server.js",load:()=>import("./commands/server.js"),exportName:"server"},"server:setup":{path:"./commands/server.js",load:()=>import("./commands/server.js"),exportName:"server"},"server:trust":{path:"./commands/server.js",load:()=>import("./commands/server.js"),exportName:"server"},"link:core":{path:"./commands/link.js",load:()=>import("./commands/link.js"),exportName:"link"},"comments:list":{path:"./commands/comments.js",load:()=>import("./commands/comments.js"),exportName:"commentsCommands"},"comments:approve":{path:"./commands/comments.js",load:()=>import("./commands/comments.js"),exportName:"commentsCommands"},"comments:reject":{path:"./commands/comments.js",load:()=>import("./commands/comments.js"),exportName:"commentsCommands"},"comments:delete":{path:"./commands/comments.js",load:()=>import("./commands/comments.js"),exportName:"commentsCommands"},"user:add":{path:"./commands/user.js",load:()=>import("./commands/user.js"),exportName:"user"},"user:list":{path:"./commands/user.js",load:()=>import("./commands/user.js"),exportName:"user"},"user:audit":{path:"./commands/user.js",load:()=>import("./commands/user.js"),exportName:"user"},"unlink:core":{path:"./commands/link.js",load:()=>import("./commands/link.js"),exportName:"link"},prepublish:{path:"./commands/prepublish.js",load:()=>import("./commands/prepublish.js"),exportName:"prepublish"},projects:{path:"./commands/projects.js",load:()=>import("./commands/projects.js"),exportName:"projects"},publish:{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},"publish:model":{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},"publish:controller":{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},"publish:middleware":{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},"publish:action":{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},"publish:component":{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},"publish:view":{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},"publish:core":{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},"core:status":{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},"publish:defaults":{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},unpublish:{path:"./commands/publish.js",load:()=>import("./commands/publish.js"),exportName:"publish"},queue:{path:"./commands/queue.js",load:()=>import("./commands/queue.js"),exportName:"queue"},release:{path:"./commands/release.js",load:()=>import("./commands/release.js"),exportName:"release"},route:{path:"./commands/route.js",load:()=>import("./commands/route.js"),exportName:"route"},saas:{path:"./commands/saas.js",load:()=>import("./commands/saas.js"),exportName:"saas"},"stripe:setup":{path:"./commands/saas.js",load:()=>import("./commands/saas.js"),exportName:"saas"},schedule:{path:"./commands/schedule.js",load:()=>import("./commands/schedule.js"),exportName:"schedule"},search:{path:"./commands/search.js",load:()=>import("./commands/search.js"),exportName:"search"},"search-engine:update":{path:"./commands/search.js",load:()=>import("./commands/search.js"),exportName:"search"},"search-engine:settings":{path:"./commands/search.js",load:()=>import("./commands/search.js"),exportName:"search"},screenshot:{path:"./commands/screenshot.js",load:()=>import("./commands/screenshot.js"),exportName:"screenshot"},seed:{path:"./commands/seed.js",load:()=>import("./commands/seed.js"),exportName:"seed"},"seed:roles":{path:"./commands/seed.js",load:()=>import("./commands/seed.js"),exportName:"seed"},"roles:seed":{path:"./commands/seed.js",load:()=>import("./commands/seed.js"),exportName:"seed"},"seed:admins":{path:"./commands/seed.js",load:()=>import("./commands/seed.js"),exportName:"seed"},"admins:seed":{path:"./commands/seed.js",load:()=>import("./commands/seed.js"),exportName:"seed"},preview:{path:"./commands/serve.js",load:()=>import("./commands/serve.js"),exportName:"preview"},serve:{path:"./commands/serve.js",load:()=>import("./commands/serve.js"),exportName:"serve"},"serve:api":{path:"./commands/serve.js",load:()=>import("./commands/serve.js"),exportName:"serveApi"},"workflow:setup":{path:"./commands/workflow.js",load:()=>import("./commands/workflow.js"),exportName:"workflow"},"workflow:step":{path:"./commands/workflow.js",load:()=>import("./commands/workflow.js"),exportName:"workflow"},"workflow:release-state":{path:"./commands/workflow.js",load:()=>import("./commands/workflow.js"),exportName:"workflow"},"workflow:runs":{path:"./commands/workflow.js",load:()=>import("./commands/workflow.js"),exportName:"workflow"},"workflow:show":{path:"./commands/workflow.js",load:()=>import("./commands/workflow.js"),exportName:"workflow"},"workflow:run":{path:"./commands/workflow.js",load:()=>import("./commands/workflow.js"),exportName:"workflow"},"workflow:artifacts":{path:"./commands/workflow.js",load:()=>import("./commands/workflow.js"),exportName:"workflow"},setup:{path:"./commands/setup.js",load:()=>import("./commands/setup.js"),exportName:"setup"},ensure:{path:"./commands/setup.js",load:()=>import("./commands/setup.js"),exportName:"setup"},"setup:ai":{path:"./commands/setup.js",load:()=>import("./commands/setup.js"),exportName:"setup"},"setup:ssl":{path:"./commands/setup.js",load:()=>import("./commands/setup.js"),exportName:"setup"},"setup:ios":{path:"./commands/setup.js",load:()=>import("./commands/setup.js"),exportName:"setup"},"setup:oh-my-zsh":{path:"./commands/setup.js",load:()=>import("./commands/setup.js"),exportName:"setup"},"ai:setup":{path:"./commands/setup.js",load:()=>import("./commands/setup.js"),exportName:"setup"},share:{path:"./commands/share.js",load:()=>import("./commands/share.js"),exportName:"share"},"simulator:doctor":{path:"./commands/simulator.js",load:()=>import("./commands/simulator.js"),exportName:"simulator"},"simulator:open":{path:"./commands/simulator.js",load:()=>import("./commands/simulator.js"),exportName:"simulator"},stack:{path:"./commands/stacks.js",load:()=>import("./commands/stacks.js"),exportName:"stacks"},sms:{path:"./commands/sms.js",load:()=>import("./commands/sms.js"),exportName:"sms"},telemetry:{path:"./commands/telemetry.js",load:()=>import("./commands/telemetry.js"),exportName:"telemetryCommand"},test:{path:"./commands/test.js",load:()=>import("./commands/test.js"),exportName:"test"},tinker:{path:"./commands/tinker.js",load:()=>import("./commands/tinker.js"),exportName:"tinker"},types:{path:"./commands/types.js",load:()=>import("./commands/types.js"),exportName:"types"},undeploy:{path:"./commands/cloud.js",load:()=>import("./commands/cloud.js"),exportName:"cloud"},upgrade:{path:"./commands/upgrade.js",load:()=>import("./commands/upgrade.js"),exportName:"upgrade"},version:{path:"./commands/version.js",load:()=>import("./commands/version.js"),exportName:"version"},"docs:screenshots":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"},"docs:stories":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"},"docs:style-guide":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"},"docs:style-guide:check":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"},"docs:buddy":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"},"docs:native-skills":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"},"docs:native-skills:check":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"},"docs:buddy:check":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"},"docs:artifacts":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"},"docs:artifacts:check":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"},"docs:links":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"},"docs:links:check":{path:"./commands/docs.js",load:()=>import("./commands/docs.js"),exportName:"docs"}};const commandGroups={minimal:["version","help"],development:["dev","build","test","lint"],database:["migrate","seed","fresh"],scaffolding:["make","generate"],deployment:["deploy","release","cloud","server"],info:["about","doctor","list"]};const loadedRegistrars=new WeakMap;function loaderKey(loader){return`${loader.path}#${loader.exportName}`}export function markLoaded(buddy,commandName){const loader=commandRegistry[commandName];if(!loader)return;let set=loadedRegistrars.get(buddy);if(!set){set=new Set;loadedRegistrars.set(buddy,set)}set.add(loaderKey(loader))}export async function loadCommand(commandName,buddy){const loader=commandRegistry[commandName];if(!loader){return false}let set=loadedRegistrars.get(buddy);if(!set){set=new Set;loadedRegistrars.set(buddy,set)}const key=loaderKey(loader);if(set.has(key))return true;set.add(key);try{const module=await loader.load();const commandFunction=module[loader.exportName];if(typeof commandFunction==="function"){commandFunction(buddy);return true}else{return false}}catch{return false}}export async function loadCommands(commandNames,buddy){const seen=new Set;const unique=[];for(const name of commandNames){const loader=commandRegistry[name];const key=loader?`${loader.path}#${loader.exportName}`:`name:${name}`;if(seen.has(key))continue;seen.add(key);unique.push(name)}await Promise.all(unique.map(async(name)=>{try{await withTimeout(loadCommand(name,buddy),5000)}catch{}}))}export async function loadCommandGroup(groupName,buddy){const commands=commandGroups[groupName];if(commands){await loadCommands(commands,buddy)}}export async function loadAllCommands(buddy){const allCommands=Object.keys(commandRegistry);await loadCommands(allCommands,buddy)}export function getCommandNames(){return Object.keys(commandRegistry)}export function getCommandsToLoad(args){const requestedCommand=args[0];const isVersionFlag=requestedCommand==="--version"||requestedCommand==="-v";const isHelpFlag=requestedCommand==="--help"||requestedCommand==="-h";const isHelpWord=requestedCommand==="help";if(isVersionFlag)return["version"];if(!requestedCommand||isHelpFlag||isHelpWord)return Object.keys(commandRegistry);const baseCommand=requestedCommand.split(":")[0];if(baseCommand==="list"){return["list",...Object.keys(commandRegistry).filter((k)=>k!=="list")]}if(commandRegistry[requestedCommand]){return[requestedCommand]}if(commandRegistry[baseCommand]){return[baseCommand]}return Object.keys(commandRegistry)}
@@ -1,5 +1,7 @@
1
1
  import type { WorkflowConfig, WorkflowStep } from '@stacksjs/types';
2
2
  export declare function loadWorkflowConfig(root: string): Promise<WorkflowConfig>;
3
+ /** Check scoped inputs before expensive native builds, without revealing values. */
4
+ export declare function checkNativeWorkflowCredentials(root: string, phase: string, env?: Record<string, string | undefined>): Promise<void>;
3
5
  export declare function workflowReleaseIdentity(root: string, config: NonNullable<WorkflowConfig['release']>): { version: string, build: number, tag: string };
4
6
  export declare function writeProjectWorkflow(root: string, config: WorkflowConfig, force?: boolean): string;
5
7
  /** Execute argv directly; an artifact path or a title is never shell code. */
@@ -1,2 +1,2 @@
1
- import{execFileSync}from"node:child_process";import{appendFileSync,existsSync,lstatSync,mkdirSync,readFileSync,realpathSync,writeFileSync}from"node:fs";import{dirname,isAbsolute,join,relative,resolve,sep}from"node:path";import{pathToFileURL}from"node:url";import{renderReviewOsWorkflow,validateWorkflowConfig}from"./workflow-template";export async function loadWorkflowConfig(root){const file=join(root,"config/workflows.ts");if(!existsSync(file))throw new Error("Configure config/workflows.ts before running a workflow");const config=(await import(pathToFileURL(file).href)).default;validateWorkflowConfig(config);return config}function ownedFile(root,file){const path=resolve(root,file);const child=relative(realpathSync(root),realpathSync(path));if(!child||isAbsolute(child)||child===".."||child.startsWith(`..${sep}`)||lstatSync(path).isSymbolicLink()||!lstatSync(path).isFile())throw new Error("Workflow inputs must be regular files inside the project");return path}export function workflowReleaseIdentity(root,config){const manifest=JSON.parse(readFileSync(ownedFile(root,config.versionFile),"utf8"));const version=manifest[config.versionField??"version"];const build=manifest[config.buildField??"build"];if(typeof version!=="string"||!/^\d+\.\d+\.\d+$/.test(version)||!Number.isSafeInteger(build)||build<=0)throw new Error("The release manifest needs a semantic version and a positive integer build");return{version,build,tag:`v${version}-build.${build}`}}export function writeProjectWorkflow(root,config,force=false){const file=join(root,".reviewos/workflows/ci.yml");const source=renderReviewOsWorkflow(config);if(existsSync(file)&&!readFileSync(file,"utf8").startsWith("# Generated by buddy workflow:setup")&&!force)throw new Error("The workflow already exists. Review it before replacing it with --force");mkdirSync(dirname(file),{recursive:true});writeFileSync(file,source);return file}function downloadedArtifact(root,config){if(!config.native)throw new Error("Configure the native artifact before acceptance");const directory=resolve(root,config.native.downloadDirectory);const files=[...new Bun.Glob(config.native.archivePattern).scanSync({cwd:directory,absolute:true,onlyFiles:true,followSymlinks:false})];if(files.length!==1)throw new Error("Native acceptance needs exactly one downloaded application archive");return ownedFile(root,files[0])}export async function runWorkflowStep(root,step){const config=await loadWorkflowConfig(root);if(!["prepare","lint","typecheck","test","build","deploy","after-deploy","native-build","native-accept","native-sign","native-upload","native-verify","native-cleanup"].includes(step))throw new Error("Unknown workflow step");const defaults={prepare:existsSync(join(root,"pantry.lock"))?[["pantry","ci"]]:[],lint:[["./buddy","lint"]],typecheck:[["./buddy","typecheck"]],test:[["./buddy","test"]],build:[[process.execPath,"run","build"]],deploy:[["./buddy","deploy","--prod","--yes"]]};const commands=config.commands?.[step]??defaults[step];if(!commands&&!(step==="native-cleanup"&&!config.release))throw new Error(`Configure the ${step} workflow command`);for(const command of commands??[]){const argv=command.map((value)=>value==="{artifact}"?downloadedArtifact(root,config):value);const child=Bun.spawn(argv,{cwd:root,env:process.env,stdout:"inherit",stderr:"inherit",stdin:"ignore"});const code=await child.exited;if(code!==0)throw new Error(`The ${step} workflow command exited ${code}`)}}export async function writeWorkflowReleaseState(root){const config=await loadWorkflowConfig(root);const git=(...args)=>execFileSync("git",args,{cwd:root,encoding:"utf8"}).trim();const requested=process.env.WORKFLOW_UPLOAD_REQUESTED==="true";const release=git("log","-1","--format=%s").startsWith("chore(release): v");let upload=false;if(requested||release){if(!config.release)throw new Error("Configure release metadata before uploading");const identity=workflowReleaseIdentity(root,config.release);const branch=config.branch??"main";const main=process.env.GITHUB_REF?process.env.GITHUB_REF===`refs/heads/${branch}`:git("branch","--show-current")===branch;let tagged=false;try{tagged=git("rev-parse","--verify","--quiet",`${identity.tag}^{commit}`)===git("rev-parse","HEAD")}catch{}if(!main||!tagged)throw new Error("An upload needs its actual release tag on the configured main branch");if(git("status","--porcelain","--untracked-files=no"))throw new Error("An upload needs the unchanged release checkout");upload=true}if(!process.env.GITHUB_OUTPUT)throw new Error("The workflow must provide its step output file");appendFileSync(process.env.GITHUB_OUTPUT,`upload=${upload}
1
+ import{execFileSync}from"node:child_process";import{appendFileSync,existsSync,lstatSync,mkdirSync,readFileSync,realpathSync,writeFileSync}from"node:fs";import{dirname,isAbsolute,join,relative,resolve,sep}from"node:path";import{pathToFileURL}from"node:url";import{nativeReleaseSecretNames,nativeWorkflowSecretNames,renderReviewOsWorkflow,validateWorkflowConfig}from"./workflow-template";export async function loadWorkflowConfig(root){const file=join(root,"config/workflows.ts");if(!existsSync(file))throw new Error("Configure config/workflows.ts before running a workflow");const config=(await import(pathToFileURL(file).href)).default;validateWorkflowConfig(config);return config}function requireWorkflowSecrets(names,phase,env){const missing=[...new Set(names)].filter((name)=>!env[name]?.trim());if(missing.length)throw new Error(`Missing workflow credentials for ${phase}: ${missing.join(", ")}. Configure these names in the ios-testflight environment. Values are never printed.`)}export async function checkNativeWorkflowCredentials(root,phase,env=process.env){if(!["native-accept","native-release"].includes(phase))throw new Error("Choose native-accept or native-release credentials");const config=await loadWorkflowConfig(root);if(!config.native)throw new Error("Configure a native workflow before checking its credentials");if(phase==="native-release"&&!config.release)throw new Error("Configure native release metadata before checking release credentials");requireWorkflowSecrets(phase==="native-release"?nativeReleaseSecretNames(config):nativeWorkflowSecretNames(config,"native-accept"),phase,env)}function ownedFile(root,file){const path=resolve(root,file);const child=relative(realpathSync(root),realpathSync(path));if(!child||isAbsolute(child)||child===".."||child.startsWith(`..${sep}`)||lstatSync(path).isSymbolicLink()||!lstatSync(path).isFile())throw new Error("Workflow inputs must be regular files inside the project");return path}export function workflowReleaseIdentity(root,config){const manifest=JSON.parse(readFileSync(ownedFile(root,config.versionFile),"utf8"));const version=manifest[config.versionField??"version"];const build=manifest[config.buildField??"build"];if(typeof version!=="string"||!/^\d+\.\d+\.\d+$/.test(version)||!Number.isSafeInteger(build)||build<=0)throw new Error("The release manifest needs a semantic version and a positive integer build");return{version,build,tag:`v${version}-build.${build}`}}export function writeProjectWorkflow(root,config,force=false){const file=join(root,".reviewos/workflows/ci.yml");const source=renderReviewOsWorkflow(config);if(existsSync(file)&&!readFileSync(file,"utf8").startsWith("# Generated by buddy workflow:setup")&&!force)throw new Error("The workflow already exists. Review it before replacing it with --force");mkdirSync(dirname(file),{recursive:true});writeFileSync(file,source);return file}function downloadedArtifact(root,config){if(!config.native)throw new Error("Configure the native artifact before acceptance");const directory=resolve(root,config.native.downloadDirectory);const files=[...new Bun.Glob(config.native.archivePattern).scanSync({cwd:directory,absolute:true,onlyFiles:true,followSymlinks:false})];if(files.length!==1)throw new Error("Native acceptance needs exactly one downloaded application archive");return ownedFile(root,files[0])}export async function runWorkflowStep(root,step){const config=await loadWorkflowConfig(root);if(!["prepare","lint","typecheck","test","build","deploy","after-deploy","native-build","native-accept","native-sign","native-upload","native-verify","native-cleanup"].includes(step))throw new Error("Unknown workflow step");requireWorkflowSecrets(nativeWorkflowSecretNames(config,step),step,process.env);const defaults={prepare:existsSync(join(root,"pantry.lock"))?[["pantry","ci"]]:[],lint:[["./buddy","lint"]],typecheck:[["./buddy","typecheck"]],test:[["./buddy","test"]],build:[[process.execPath,"run","build"]],deploy:[["./buddy","deploy","--prod","--yes"]]};const commands=config.commands?.[step]??defaults[step];if(!commands&&!(step==="native-cleanup"&&!config.release))throw new Error(`Configure the ${step} workflow command`);for(const command of commands??[]){const argv=command.map((value)=>value==="{artifact}"?downloadedArtifact(root,config):value);const child=Bun.spawn(argv,{cwd:root,env:process.env,stdout:"inherit",stderr:"inherit",stdin:"ignore"});const code=await child.exited;if(code!==0)throw new Error(`The ${step} workflow command exited ${code}`)}}export async function writeWorkflowReleaseState(root){const config=await loadWorkflowConfig(root);const git=(...args)=>execFileSync("git",args,{cwd:root,encoding:"utf8"}).trim();const requested=process.env.WORKFLOW_UPLOAD_REQUESTED==="true";const release=git("log","-1","--format=%s").startsWith("chore(release): v");let upload=false;if(requested||release){if(!config.release)throw new Error("Configure release metadata before uploading");const identity=workflowReleaseIdentity(root,config.release);const branch=config.branch??"main";const main=process.env.GITHUB_REF?process.env.GITHUB_REF===`refs/heads/${branch}`:git("branch","--show-current")===branch;let tagged=false;try{tagged=git("rev-parse","--verify","--quiet",`${identity.tag}^{commit}`)===git("rev-parse","HEAD")}catch{}if(!main||!tagged)throw new Error("An upload needs its actual release tag on the configured main branch");if(git("status","--porcelain","--untracked-files=no"))throw new Error("An upload needs the unchanged release checkout");upload=true}if(!process.env.GITHUB_OUTPUT)throw new Error("The workflow must provide its step output file");appendFileSync(process.env.GITHUB_OUTPUT,`upload=${upload}
2
2
  `);return upload}
@@ -1,4 +1,6 @@
1
- import type { WorkflowConfig } from '@stacksjs/types';
1
+ import type { WorkflowConfig, WorkflowStep } from '@stacksjs/types';
2
+ export declare function nativeWorkflowSecretNames(config: WorkflowConfig, step: WorkflowStep): string[];
3
+ export declare function nativeReleaseSecretNames(config: WorkflowConfig): string[];
2
4
  export declare function validateWorkflowConfig(config: WorkflowConfig): void;
3
5
  /** A single ordered pipeline keeps deployment fixed for its native acceptance. */
4
6
  export declare function renderReviewOsWorkflow(config: WorkflowConfig): string;
@@ -1,4 +1,4 @@
1
- function relativePath(value){return typeof value==="string"&&!!value&&!/^[A-Za-z]:|^[\\/]|[\\\r\n\x00]/.test(value)&&!value.split("/").some((segment)=>segment==="."||segment==="..")}export function validateWorkflowConfig(config){const origin=new URL(config.origin);if(config.provider!=="reviewos"||origin.protocol!=="https:"||origin.username||origin.password||origin.pathname!=="/"||origin.search||origin.hash||!/^[\w.-]+\/[\w.-]+$/.test(config.repository)||config.repository.split("/").some((part)=>part==="."||part===".."))throw new Error("Configure a canonical ReviewOS origin and owner/repository");for(const group of["checks",...config.deploy?["deploy"]:[],...config.native?["ios"]:[]]){const labels=config.runners[group];if(!Array.isArray(labels)||!labels.includes("self-hosted")||labels.some((label)=>!/^[\w.-]+$/.test(label)))throw new Error(`Declare the owned ${group} runner labels`)}if(config.priorities!==undefined&&(!config.priorities||typeof config.priorities!=="object"||Array.isArray(config.priorities)||Object.entries(config.priorities).some(([stage,value])=>!["checks","deploy","ios"].includes(stage)||!Number.isInteger(value)||value<-1000||value>1000)))throw new Error("Workflow priorities must name checks, deploy or ios with integer values from -1000 to 1000");for(const values of Object.values(config.env??{})){if(!values||typeof values!=="object"||Array.isArray(values)||Object.entries(values).some(([name,value])=>!/^[A-Z_][A-Z0-9_]*$/.test(name)||typeof value!=="string"||value.includes("\x00")))throw new Error("Workflow environment settings must be named string values")}for(const names of Object.values(config.secrets??{})){if(!Array.isArray(names)||names.some((name)=>!/^[A-Z_][A-Z0-9_]*$/.test(name)))throw new Error("Workflow secrets must be environment variable names")}for(const[step,names]of Object.entries(config.stepSecrets??{})){if(!["native-build","native-accept","native-sign","native-upload","native-verify","native-cleanup"].includes(step)||!Array.isArray(names)||names.some((name)=>!config.secrets?.ios?.includes(name)))throw new Error("Step credentials must name declared native secrets")}if(config.native&&(!config.native.artifacts.length||![...config.native.artifacts,config.native.downloadDirectory,config.native.archivePattern,...config.native.evidence??[],...config.native.releaseArtifacts??[]].every(relativePath)))throw new Error("Native artifacts must stay inside the workspace");if(config.deploy&&!config.commands?.["after-deploy"]?.length)throw new Error("Configure deployed application verification");if(config.native&&["native-build","native-accept"].some((step)=>!config.commands?.[step]?.length))throw new Error("Configure native build and downloaded acceptance commands");if(config.release&&(!config.native||["native-sign","native-upload","native-verify","native-cleanup"].some((step)=>!config.commands?.[step]?.length)))throw new Error("Configure native signing, upload, verification and cleanup before releasing");if(config.release&&(!relativePath(config.release.versionFile)||config.release.notesDirectory!==undefined&&!relativePath(config.release.notesDirectory)||config.release.locales?.some((locale)=>!/^[a-z]{2}(?:-[A-Z]{2})?$/.test(locale))))throw new Error("Release files and locales must stay inside the workspace");for(const commands of Object.values(config.commands??{})){if(!Array.isArray(commands)||commands.some((argv)=>!Array.isArray(argv)||!argv.length||argv.some((arg)=>typeof arg!=="string"||arg.includes("\x00"))))throw new Error("Workflow commands must be nonempty argv arrays")}}export function renderReviewOsWorkflow(config){validateWorkflowConfig(config);const branch=config.branch??"main";if(!/^[\w./-]+$/.test(branch)||branch.includes(".."))throw new Error("Configure a branch name");const main=`github.ref == 'refs/heads/${branch}' && github.event_name != 'pull_request'`;const upload="steps.release.outputs.upload == 'true'";const secretEnv=(group)=>Object.fromEntries((config.secrets?.[group]??[]).map((name)=>[name,"${{ secrets."+name+" }}"]));const nativeSecrets=(step)=>{const names=config.stepSecrets?.[step]??(step==="native-sign"?config.secrets?.ios??[]:[]);return names.length?{env:Object.fromEntries(names.map((name)=>[name,"${{ secrets."+name+" }}"]))}:{}};const bootstrap=()=>[{name:"Checkout the exact source",uses:"actions/checkout@11d5960a326750d5838078e36cf38b85af677262",with:{"fetch-depth":0,"persist-credentials":false}},{name:"Set up the pinned tools",uses:"pantry-pm/pantry/packages/action@624cd6674f8c5c2d4e4204c11ece62a00d7fac0a",with:{version:config.pantry??"0.11.199",install:"false",packages:`bun.sh@${config.bun??"1.4.4"}`}},{name:"Install the frozen application dependencies",run:"bun install --frozen-lockfile"},{name:"Prepare declared application inputs",run:"./buddy workflow:step prepare"}];const jobPriority=(stage)=>{const value=config.priorities?.[stage];return value===undefined?{}:{priority:value}};const jobs={};for(const name of["lint","typecheck","test","build"])jobs[name]={"runs-on":config.runners.checks,"timeout-minutes":name==="test"?90:30,reviewos:{...jobPriority("checks"),secrets:config.secrets?.checks??[]},env:{...config.env?.checks,...secretEnv("checks")},steps:[...bootstrap(),{name:`Run ${name}`,run:`./buddy workflow:step ${name}`}]};if(config.deploy)jobs.deploy={needs:["lint","typecheck","test","build"],if:main,"runs-on":config.runners.deploy,"timeout-minutes":60,environment:"production",reviewos:{...jobPriority("deploy"),secrets:[...config.secrets?.checks??[],...config.secrets?.deploy??[]]},env:{...config.env?.checks,...config.env?.deploy,...secretEnv("checks"),...secretEnv("deploy")},steps:[...bootstrap(),{name:"Deploy the qualified source",run:"./buddy workflow:step deploy"},{name:"Verify the deployed application",run:"./buddy workflow:step after-deploy"}]};if(config.native)jobs.native={needs:config.deploy?["deploy"]:["lint","typecheck","test","build"],if:main,"runs-on":config.runners.ios,"timeout-minutes":90,environment:"ios-testflight",reviewos:{...jobPriority("ios"),secrets:[...config.secrets?.checks??[],...config.secrets?.ios??[]]},env:{...config.env?.checks,...config.env?.ios,...secretEnv("checks")},steps:[...bootstrap(),{name:"Read the committed release identity",id:"release",run:"./buddy workflow:release-state",env:{WORKFLOW_UPLOAD_REQUESTED:"${{ inputs.upload && 'true' || 'false' }}"}},{name:"Build the simulator application",run:"./buddy workflow:step native-build",...nativeSecrets("native-build")},{name:"Publish the simulator application",uses:"actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02",with:{name:"native-simulator-${{ github.run_id }}-${{ github.run_attempt }}",path:config.native.artifacts.join(`
2
- `),"if-no-files-found":"error","retention-days":7}},{name:"Download the published application",uses:"actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093",with:{name:"native-simulator-${{ github.run_id }}-${{ github.run_attempt }}",path:config.native.downloadDirectory}},{name:"Accept the downloaded application",run:"./buddy workflow:step native-accept",...nativeSecrets("native-accept")},{name:"Prepare temporary signing material",if:upload,run:"./buddy workflow:step native-sign",...nativeSecrets("native-sign")},{name:"Upload the accepted application",if:upload,run:"./buddy workflow:step native-upload",...nativeSecrets("native-upload")},{name:"Verify tester availability",if:upload,run:"./buddy workflow:step native-verify",...nativeSecrets("native-verify")},{name:"Remove temporary signing material",if:"always()",run:"./buddy workflow:step native-cleanup",...nativeSecrets("native-cleanup")},...[...config.native.evidence??[],...config.native.releaseArtifacts??[]].length?[{name:"Preserve acceptance and release receipts",if:"always()",uses:"actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02",with:{name:"native-evidence-${{ github.run_id }}-${{ github.run_attempt }}",path:[...config.native.evidence??[],...config.native.releaseArtifacts??[]].join(`
1
+ export function nativeWorkflowSecretNames(config,step){switch(step){case"native-build":case"native-accept":case"native-sign":case"native-upload":case"native-verify":case"native-cleanup":return config.stepSecrets?.[step]??(step==="native-sign"?config.secrets?.ios??[]:[]);default:return[]}}export function nativeReleaseSecretNames(config){return[...new Set(["native-sign","native-upload","native-verify","native-cleanup"].flatMap((step)=>nativeWorkflowSecretNames(config,step)))]}function relativePath(value){return typeof value==="string"&&!!value&&!/^[A-Za-z]:|^[\\/]|[\\\r\n\x00]/.test(value)&&!value.split("/").some((segment)=>segment==="."||segment==="..")}export function validateWorkflowConfig(config){const origin=new URL(config.origin);if(config.provider!=="reviewos"||origin.protocol!=="https:"||origin.username||origin.password||origin.pathname!=="/"||origin.search||origin.hash||!/^[\w.-]+\/[\w.-]+$/.test(config.repository)||config.repository.split("/").some((part)=>part==="."||part===".."))throw new Error("Configure a canonical ReviewOS origin and owner/repository");for(const group of["checks",...config.deploy?["deploy"]:[],...config.native?["ios"]:[]]){const labels=config.runners[group];if(!Array.isArray(labels)||!labels.includes("self-hosted")||labels.some((label)=>!/^[\w.-]+$/.test(label)))throw new Error(`Declare the owned ${group} runner labels`)}if(config.priorities!==undefined&&(!config.priorities||typeof config.priorities!=="object"||Array.isArray(config.priorities)||Object.entries(config.priorities).some(([stage,value])=>!["checks","deploy","ios"].includes(stage)||!Number.isInteger(value)||value<-1000||value>1000)))throw new Error("Workflow priorities must name checks, deploy or ios with integer values from -1000 to 1000");for(const values of Object.values(config.env??{})){if(!values||typeof values!=="object"||Array.isArray(values)||Object.entries(values).some(([name,value])=>!/^[A-Z_][A-Z0-9_]*$/.test(name)||typeof value!=="string"||value.includes("\x00")))throw new Error("Workflow environment settings must be named string values")}for(const names of Object.values(config.secrets??{})){if(!Array.isArray(names)||names.some((name)=>!/^[A-Z_][A-Z0-9_]*$/.test(name)))throw new Error("Workflow secrets must be environment variable names")}for(const[step,names]of Object.entries(config.stepSecrets??{})){if(!["native-build","native-accept","native-sign","native-upload","native-verify","native-cleanup"].includes(step)||!Array.isArray(names)||names.some((name)=>!config.secrets?.ios?.includes(name)))throw new Error("Step credentials must name declared native secrets")}if(config.native&&(!config.native.artifacts.length||![...config.native.artifacts,config.native.downloadDirectory,config.native.archivePattern,...config.native.evidence??[],...config.native.releaseArtifacts??[]].every(relativePath)))throw new Error("Native artifacts must stay inside the workspace");if(config.deploy&&!config.commands?.["after-deploy"]?.length)throw new Error("Configure deployed application verification");if(config.native&&["native-build","native-accept"].some((step)=>!config.commands?.[step]?.length))throw new Error("Configure native build and downloaded acceptance commands");if(config.release&&(!config.native||["native-sign","native-upload","native-verify","native-cleanup"].some((step)=>!config.commands?.[step]?.length)))throw new Error("Configure native signing, upload, verification and cleanup before releasing");if(config.release&&(!relativePath(config.release.versionFile)||config.release.notesDirectory!==undefined&&!relativePath(config.release.notesDirectory)||config.release.locales?.some((locale)=>!/^[a-z]{2}(?:-[A-Z]{2})?$/.test(locale))))throw new Error("Release files and locales must stay inside the workspace");for(const commands of Object.values(config.commands??{})){if(!Array.isArray(commands)||commands.some((argv)=>!Array.isArray(argv)||!argv.length||argv.some((arg)=>typeof arg!=="string"||arg.includes("\x00"))))throw new Error("Workflow commands must be nonempty argv arrays")}}export function renderReviewOsWorkflow(config){validateWorkflowConfig(config);const branch=config.branch??"main";if(!/^[\w./-]+$/.test(branch)||branch.includes(".."))throw new Error("Configure a branch name");const main=`github.ref == 'refs/heads/${branch}' && github.event_name != 'pull_request'`;const upload="steps.release.outputs.upload == 'true'";const secretEnv=(group)=>Object.fromEntries((config.secrets?.[group]??[]).map((name)=>[name,"${{ secrets."+name+" }}"]));const nativeSecrets=(step)=>{const names=nativeWorkflowSecretNames(config,step);return names.length?{env:Object.fromEntries(names.map((name)=>[name,"${{ secrets."+name+" }}"]))}:{}};const bootstrap=()=>[{name:"Checkout the exact source",uses:"actions/checkout@11d5960a326750d5838078e36cf38b85af677262",with:{"fetch-depth":0,"persist-credentials":false}},{name:"Set up the pinned tools",uses:"pantry-pm/pantry/packages/action@624cd6674f8c5c2d4e4204c11ece62a00d7fac0a",with:{version:config.pantry??"0.11.199",install:"false",packages:`bun.sh@${config.bun??"1.4.4"}`}},{name:"Install the frozen application dependencies",run:"bun install --frozen-lockfile"},{name:"Prepare declared application inputs",run:"./buddy workflow:step prepare"}];const jobPriority=(stage)=>{const value=config.priorities?.[stage];return value===undefined?{}:{priority:value}};const jobs={};for(const name of["lint","typecheck","test","build"])jobs[name]={"runs-on":config.runners.checks,"timeout-minutes":name==="test"?90:30,reviewos:{...jobPriority("checks"),secrets:config.secrets?.checks??[]},env:{...config.env?.checks,...secretEnv("checks")},steps:[...bootstrap(),{name:`Run ${name}`,run:`./buddy workflow:step ${name}`}]};if(config.deploy)jobs.deploy={needs:["lint","typecheck","test","build"],if:main,"runs-on":config.runners.deploy,"timeout-minutes":60,environment:"production",reviewos:{...jobPriority("deploy"),secrets:[...config.secrets?.checks??[],...config.secrets?.deploy??[]]},env:{...config.env?.checks,...config.env?.deploy,...secretEnv("checks"),...secretEnv("deploy")},steps:[...bootstrap(),{name:"Deploy the qualified source",run:"./buddy workflow:step deploy"},{name:"Verify the deployed application",run:"./buddy workflow:step after-deploy"}]};if(config.native)jobs.native={needs:config.deploy?["deploy"]:["lint","typecheck","test","build"],if:main,"runs-on":config.runners.ios,"timeout-minutes":90,environment:"ios-testflight",reviewos:{...jobPriority("ios"),secrets:[...config.secrets?.checks??[],...config.secrets?.ios??[]]},env:{...config.env?.checks,...config.env?.ios,...secretEnv("checks")},steps:[...bootstrap(),{name:"Read the committed release identity",id:"release",run:"./buddy workflow:release-state",env:{WORKFLOW_UPLOAD_REQUESTED:"${{ inputs.upload }}"}},{name:"Validate native acceptance credentials",run:"./buddy workflow:check-credentials native-accept",...nativeSecrets("native-accept")},...config.release?[{name:"Validate release credentials",if:upload,run:"./buddy workflow:check-credentials native-release",...nativeReleaseSecretNames(config).length?{env:Object.fromEntries(nativeReleaseSecretNames(config).map((name)=>[name,"${{ secrets."+name+" }}"]))}:{}}]:[],{name:"Build the simulator application",run:"./buddy workflow:step native-build",...nativeSecrets("native-build")},{name:"Publish the simulator application",uses:"actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02",with:{name:"native-simulator-${{ github.run_id }}-${{ github.run_attempt }}-${{ reviewos.job_attempt }}",path:config.native.artifacts.join(`
2
+ `),"if-no-files-found":"error","retention-days":7}},{name:"Download the published application",uses:"actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093",with:{name:"native-simulator-${{ github.run_id }}-${{ github.run_attempt }}-${{ reviewos.job_attempt }}",path:config.native.downloadDirectory}},{name:"Accept the downloaded application",run:"./buddy workflow:step native-accept",...nativeSecrets("native-accept")},{name:"Prepare temporary signing material",if:upload,run:"./buddy workflow:step native-sign",...nativeSecrets("native-sign")},{name:"Upload the accepted application",if:upload,run:"./buddy workflow:step native-upload",...nativeSecrets("native-upload")},{name:"Verify tester availability",if:upload,run:"./buddy workflow:step native-verify",...nativeSecrets("native-verify")},{name:"Remove temporary signing material",if:"always()",run:"./buddy workflow:step native-cleanup",...nativeSecrets("native-cleanup")},...[...config.native.evidence??[],...config.native.releaseArtifacts??[]].length?[{name:"Preserve acceptance and release receipts",if:"always()",uses:"actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02",with:{name:"native-evidence-${{ github.run_id }}-${{ github.run_attempt }}-${{ reviewos.job_attempt }}",path:[...config.native.evidence??[],...config.native.releaseArtifacts??[]].join(`
3
3
  `),"if-no-files-found":"warn","retention-days":7}}]:[]]};return`# Generated by buddy workflow:setup from config/workflows.ts.
4
4
  `+Bun.YAML.stringify({name:"CI",on:{push:{branches:[branch]},pull_request:{branches:[branch]},workflow_dispatch:{inputs:{upload:{type:"boolean",default:false,description:"Upload a committed release after native acceptance"}}}},concurrency:{group:"stacks-app-${{ github.ref }}","cancel-in-progress":`\${{ github.ref != 'refs/heads/${branch}' }}`},permissions:{contents:"read"},jobs},null,2)}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/buddy",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.75.633",
5
+ "version": "0.75.635",
6
6
  "description": "Meet Buddy. The Stacks runtime.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -95,71 +95,71 @@
95
95
  "prepublishOnly": "bun run build"
96
96
  },
97
97
  "dependencies": {
98
- "@stacksjs/actions": "0.75.633",
99
- "@stacksjs/docs": "0.75.633",
100
- "@stacksjs/ai": "0.75.633",
101
- "@stacksjs/alias": "0.75.633",
102
- "@stacksjs/analytics": "0.75.633",
103
- "@stacksjs/api": "0.75.633",
104
- "@stacksjs/arrays": "0.75.633",
105
- "@stacksjs/auth": "0.75.633",
106
- "@stacksjs/browser-extension": "0.75.633",
107
- "@stacksjs/build": "0.75.633",
98
+ "@stacksjs/actions": "0.75.635",
99
+ "@stacksjs/docs": "0.75.635",
100
+ "@stacksjs/ai": "0.75.635",
101
+ "@stacksjs/alias": "0.75.635",
102
+ "@stacksjs/analytics": "0.75.635",
103
+ "@stacksjs/api": "0.75.635",
104
+ "@stacksjs/arrays": "0.75.635",
105
+ "@stacksjs/auth": "0.75.635",
106
+ "@stacksjs/browser-extension": "0.75.635",
107
+ "@stacksjs/build": "0.75.635",
108
108
  "@stacksjs/bumpx": "^0.2.32",
109
- "@stacksjs/cache": "0.75.633",
110
- "@stacksjs/chat": "0.75.633",
109
+ "@stacksjs/cache": "0.75.635",
110
+ "@stacksjs/chat": "0.75.635",
111
111
  "@stacksjs/clapp": "^0.2.17",
112
- "@stacksjs/cli": "0.75.633",
113
- "@stacksjs/cloud": "0.75.633",
114
- "@stacksjs/cms": "0.75.633",
115
- "@stacksjs/collections": "0.75.633",
116
- "@stacksjs/commerce": "0.75.633",
117
- "@stacksjs/config": "0.75.633",
118
- "@stacksjs/database": "0.75.633",
119
- "@stacksjs/desktop-build": "0.75.633",
120
- "@stacksjs/dns": "0.75.633",
112
+ "@stacksjs/cli": "0.75.635",
113
+ "@stacksjs/cloud": "0.75.635",
114
+ "@stacksjs/cms": "0.75.635",
115
+ "@stacksjs/collections": "0.75.635",
116
+ "@stacksjs/commerce": "0.75.635",
117
+ "@stacksjs/config": "0.75.635",
118
+ "@stacksjs/database": "0.75.635",
119
+ "@stacksjs/desktop-build": "0.75.635",
120
+ "@stacksjs/dns": "0.75.635",
121
121
  "@stacksjs/dnsx": "^0.2.3",
122
- "@stacksjs/email": "0.75.633",
123
- "@stacksjs/enums": "0.75.633",
124
- "@stacksjs/env": "0.75.633",
125
- "@stacksjs/error-handling": "0.75.633",
126
- "@stacksjs/events": "0.75.633",
127
- "@stacksjs/features": "0.75.633",
128
- "@stacksjs/git": "0.75.633",
122
+ "@stacksjs/email": "0.75.635",
123
+ "@stacksjs/enums": "0.75.635",
124
+ "@stacksjs/env": "0.75.635",
125
+ "@stacksjs/error-handling": "0.75.635",
126
+ "@stacksjs/events": "0.75.635",
127
+ "@stacksjs/features": "0.75.635",
128
+ "@stacksjs/git": "0.75.635",
129
129
  "@stacksjs/gitit": "^0.2.5",
130
- "@stacksjs/health": "0.75.633",
131
- "@stacksjs/hq": "0.75.633",
130
+ "@stacksjs/health": "0.75.635",
131
+ "@stacksjs/hq": "0.75.635",
132
132
  "@stacksjs/httx": "^0.1.10",
133
- "@stacksjs/image": "0.75.633",
134
- "@stacksjs/lint": "0.75.633",
135
- "@stacksjs/logging": "0.75.633",
136
- "@stacksjs/notifications": "0.75.633",
137
- "@stacksjs/objects": "0.75.633",
138
- "@stacksjs/orm": "0.75.633",
139
- "@stacksjs/path": "0.75.633",
140
- "@stacksjs/payments": "0.75.633",
141
- "@stacksjs/realtime": "0.75.633",
142
- "@stacksjs/router": "0.75.633",
133
+ "@stacksjs/image": "0.75.635",
134
+ "@stacksjs/lint": "0.75.635",
135
+ "@stacksjs/logging": "0.75.635",
136
+ "@stacksjs/notifications": "0.75.635",
137
+ "@stacksjs/objects": "0.75.635",
138
+ "@stacksjs/orm": "0.75.635",
139
+ "@stacksjs/path": "0.75.635",
140
+ "@stacksjs/payments": "0.75.635",
141
+ "@stacksjs/realtime": "0.75.635",
142
+ "@stacksjs/router": "0.75.635",
143
143
  "@stacksjs/rpx": "^0.11.54",
144
- "@stacksjs/scheduler": "0.75.633",
145
- "@stacksjs/search-engine": "0.75.633",
146
- "@stacksjs/security": "0.75.633",
147
- "@stacksjs/server": "0.75.633",
148
- "@stacksjs/sites": "0.75.633",
149
- "@stacksjs/skills": "0.75.633",
150
- "@stacksjs/socials": "0.75.633",
151
- "@stacksjs/storage": "0.75.633",
152
- "@stacksjs/strings": "0.75.633",
144
+ "@stacksjs/scheduler": "0.75.635",
145
+ "@stacksjs/search-engine": "0.75.635",
146
+ "@stacksjs/security": "0.75.635",
147
+ "@stacksjs/server": "0.75.635",
148
+ "@stacksjs/sites": "0.75.635",
149
+ "@stacksjs/skills": "0.75.635",
150
+ "@stacksjs/socials": "0.75.635",
151
+ "@stacksjs/storage": "0.75.635",
152
+ "@stacksjs/strings": "0.75.635",
153
153
  "@stacksjs/stx": "^0.2.908",
154
- "@stacksjs/testing": "0.75.633",
155
- "@stacksjs/tinker": "0.75.633",
154
+ "@stacksjs/testing": "0.75.635",
155
+ "@stacksjs/tinker": "0.75.635",
156
156
  "@stacksjs/tlsx": "^0.13.19",
157
157
  "@stacksjs/ts-cloud": "^0.16.144",
158
- "@stacksjs/tunnel": "0.75.633",
159
- "@stacksjs/types": "0.75.633",
160
- "@stacksjs/ui": "0.75.633",
161
- "@stacksjs/utils": "0.75.633",
162
- "@stacksjs/validation": "0.75.633",
158
+ "@stacksjs/tunnel": "0.75.635",
159
+ "@stacksjs/types": "0.75.635",
160
+ "@stacksjs/ui": "0.75.635",
161
+ "@stacksjs/utils": "0.75.635",
162
+ "@stacksjs/validation": "0.75.635",
163
163
  "ajv": "^8.20.0",
164
164
  "ajv-formats": "^3.0.1",
165
165
  "bun-plugin-stx": "^0.2.908",