@stacksjs/buddy 0.75.638 → 0.75.640
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.
- package/dist/commands/daemon.js +1 -1
- package/dist/commands/test.js +1 -1
- package/dist/generation-approval.d.ts +4 -1
- package/dist/generation-approval.js +3 -5
- package/dist/generation-changes.d.ts +6 -1
- package/dist/generation-changes.js +1 -1
- package/dist/project-generation.js +2 -2
- package/dist/scaffold-package-app.d.ts +1 -1
- package/dist/scaffold-package-app.js +1 -1
- package/dist/scaffold-site.d.ts +1 -1
- package/dist/scaffold-site.js +1 -1
- package/package.json +57 -57
package/dist/commands/daemon.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import{existsSync,readFileSync}from"node:fs";import process from"node:process";import{bold,dim,green,onUnknownSubcommand}from"@stacksjs/cli";import{ExitCode}from"@stacksjs/types";function uptime(since){const minutes=Math.max(0,Math.round((Date.now()-Date.parse(since))/60000));if(minutes<1)return"just now";if(minutes<60)return`${minutes}m`;return`${Math.floor(minutes/60)}h ${minutes%60}m`}function memoryMb(pid){const result=Bun.spawnSync(["ps","-o","rss=","-p",String(pid)],{stdout:"pipe",stderr:"ignore"});const kilobytes=Number(result.stdout.toString().trim());return result.exitCode===0&&kilobytes>0?Math.round(kilobytes/1024):null}export function daemon(buddy){const descriptions={status:"Show whether buddy is running in the background and what it is running",start:"Start buddy in the background",stop:"Stop background generation and the dashboards buddy started",restart:"Restart the background buddy",logs:"Print the background buddy's log",json:"Print the status as JSON"};async function status(options){const{daemonStatus}=await import("@stacksjs/actions/daemon/client");const running=await daemonStatus();if(options.json){process.stdout.write(`${JSON.stringify(running,null,2)}
|
|
2
|
-
`);return}if(!running){console.log(`buddy is not running in the background. ${dim("It starts when something needs it: buddy dashboard")}`);return}const memory=memoryMb(running.pid);console.log(`${green("●")} buddy is running in the background ${dim(`(pid ${running.pid}, up ${uptime(running.startedAt)}${memory?`, ${memory} MB`:""})`)}`);if(running.generation){const{watched,queued,running:active,failures}=running.generation;console.log(` Generation ${watched} watched, ${queued} queued${active?`, running for ${active}`:""}`);for(const failure of failures)console.log(` ${failure.path} ${failure.error}`)}if(running.dashboards.length===0){console.log(dim(" No dashboards running."));return}const width=Math.max(...running.dashboards.map((dashboard)=>dashboard.name.length));for(const dashboard of running.dashboards){const state=dashboard.state==="ready"?dashboard.url:dim("starting");console.log(` ${bold(dashboard.name.padEnd(width))} ${state} ${dim(`up ${uptime(dashboard.startedAt)}`)}`)}}for(const name of["daemon","daemon:status"]){buddy.command(name,descriptions.status).option("--json",descriptions.json,{default:false}).action(async(options)=>{await status(options);process.exit(ExitCode.Success)})}buddy.command("daemon:start",descriptions.start).action(async()=>{const{startDaemon}=await import("@stacksjs/actions/daemon/client");const{status:running,started}=await startDaemon();console.log(started?`${green("●")} buddy is now running in the background ${dim(`(pid ${running.pid})`)}`:`buddy is already running in the background ${dim(`(pid ${running.pid})`)}`);process.exit(ExitCode.Success)});buddy.command("daemon:stop",descriptions.stop).action(async()=>{const{stopDaemon}=await import("@stacksjs/actions/daemon/client");console.log(await stopDaemon()?"Stopped the background buddy.":"buddy was not running in the background.");process.exit(ExitCode.Success)});buddy.command("daemon:restart",descriptions.restart).action(async()=>{const{startDaemon,stopDaemon}=await import("@stacksjs/actions/daemon/client");await stopDaemon();const{status:running}=await startDaemon();console.log(`${green("●")} buddy is running in the background ${dim(`(pid ${running.pid})`)}`);process.exit(ExitCode.Success)});buddy.command("daemon:logs",descriptions.logs).option("--lines <count>","How many lines from the end to print",{default:50}).action(async(options)=>{const{daemonLogFile}=await import("@stacksjs/actions/daemon/paths");const file=daemonLogFile();if(!existsSync(file)){console.log("The background buddy has not written a log yet.");process.exit(ExitCode.Success)}const lines=readFileSync(file,"utf8").trimEnd().split(`
|
|
2
|
+
`);return}if(!running){console.log(`buddy is not running in the background. ${dim("It starts when something needs it: buddy dashboard")}`);return}const memory=memoryMb(running.pid);console.log(`${green("●")} buddy is running in the background ${dim(`(pid ${running.pid}, up ${uptime(running.startedAt)}${memory?`, ${memory} MB`:""})`)}`);if(running.generation){const{watched,queued,running:active,failures}=running.generation;console.log(` Generation ${watched} watched, ${queued} queued${active?`, running for ${active}`:""}`);for(const failure of failures)console.log(` ${failure.path} ${failure.error}`);for(const approval of running.generation.approvals??[])console.log(` Approval ${approval.path} ${approval.files} generated file${approval.files===1?"":"s"} awaiting review`)}if(running.dashboards.length===0){console.log(dim(" No dashboards running."));return}const width=Math.max(...running.dashboards.map((dashboard)=>dashboard.name.length));for(const dashboard of running.dashboards){const state=dashboard.state==="ready"?dashboard.url:dim("starting");console.log(` ${bold(dashboard.name.padEnd(width))} ${state} ${dim(`up ${uptime(dashboard.startedAt)}`)}`)}}for(const name of["daemon","daemon:status"]){buddy.command(name,descriptions.status).option("--json",descriptions.json,{default:false}).action(async(options)=>{await status(options);process.exit(ExitCode.Success)})}buddy.command("daemon:start",descriptions.start).action(async()=>{const{startDaemon}=await import("@stacksjs/actions/daemon/client");const{status:running,started}=await startDaemon();console.log(started?`${green("●")} buddy is now running in the background ${dim(`(pid ${running.pid})`)}`:`buddy is already running in the background ${dim(`(pid ${running.pid})`)}`);process.exit(ExitCode.Success)});buddy.command("daemon:stop",descriptions.stop).action(async()=>{const{stopDaemon}=await import("@stacksjs/actions/daemon/client");console.log(await stopDaemon()?"Stopped the background buddy.":"buddy was not running in the background.");process.exit(ExitCode.Success)});buddy.command("daemon:restart",descriptions.restart).action(async()=>{const{startDaemon,stopDaemon}=await import("@stacksjs/actions/daemon/client");await stopDaemon();const{status:running}=await startDaemon();console.log(`${green("●")} buddy is running in the background ${dim(`(pid ${running.pid})`)}`);process.exit(ExitCode.Success)});buddy.command("daemon:logs",descriptions.logs).option("--lines <count>","How many lines from the end to print",{default:50}).action(async(options)=>{const{daemonLogFile}=await import("@stacksjs/actions/daemon/paths");const file=daemonLogFile();if(!existsSync(file)){console.log("The background buddy has not written a log yet.");process.exit(ExitCode.Success)}const lines=readFileSync(file,"utf8").trimEnd().split(`
|
|
3
3
|
`);process.stdout.write(`${lines.slice(-(Number(options.lines)||50)).join(`
|
|
4
4
|
`)}
|
|
5
5
|
`);process.exit(ExitCode.Success)});onUnknownSubcommand(buddy,"daemon")}
|
package/dist/commands/test.js
CHANGED
|
@@ -1,3 +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}).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:
|
|
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:false});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
2
|
`)}})}}finally{await close()}if(options.json)process.stdout.write(`${JSON.stringify(options.lighthouse?{pages:reports,lighthouse}:reports,null,2)}
|
|
3
3
|
`);process.exit(reports.every(pageAuditClean)&&lighthouse.every((result)=>result.passed)?ExitCode.Success:ExitCode.FatalError)});onUnknownSubcommand(buddy,"test")}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { GenerationFileGuard } from '@stacksjs/path';
|
|
1
2
|
import type { GenerationTask } from '@stacksjs/actions/daemon/generation-config';
|
|
2
|
-
|
|
3
|
+
/** Generation and approved commits share the proposal and its working-tree files. */
|
|
4
|
+
export declare function withApprovalLock<T>(root: string, run: () => T | Promise<T>): Promise<T>;
|
|
5
|
+
export declare function prepareCommitApproval(root: string, task: GenerationTask, enabledTasks: GenerationTask[]): { guard: GenerationFileGuard, finish: (success: boolean) => void } | undefined;
|
|
3
6
|
export declare function reviewGeneratedCommit(root: string, review: (diff: string) => Promise<boolean>): Promise<string | 'empty' | 'pending'>;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import{
|
|
2
|
-
|
|
3
|
-
end run`;const message=`${basename(root)} has ${count} generated ${count===1?"file":"files"} ready for review. Run ./buddy generate:review in the project.`;const result=spawnSync("/usr/bin/osascript",["-e",script,"--",message],{encoding:"utf8",timeout:15000});if(result.status!==0)console.warn(`[buddy:notification] Could not submit the desktop alert. Run ./buddy generate:review in ${root}.`)}export function prepareCommitApproval(root,tasks,enabledTasks,notify=notifyApproval){const revision=generationRevision(root);if(!revision||!revision.includes(`
|
|
4
|
-
refs/heads/`))return;const path=approvalPath(root);const{read,eligible}=generatedChanges(root,enabledTasks,true);const{eligible:selected}=generatedChanges(root,tasks,true);const before=read();const previous=readApproval(path);const owned=new Map(Object.entries(previous?.revision===revision?previous.files:{}));const carried=new Set([...owned].filter(([file,hash])=>before.has(file)&&eligible(file,before.get(file))&&fingerprint(root,file)===hash).map(([file])=>file));return()=>{const current=readApproval(path);if(gitRevision(root)!==revision||JSON.stringify(current)!==JSON.stringify(previous))return;const files=new Map;for(const[file,status]of[...read()].sort(([a],[b])=>a.localeCompare(b))){if(!eligible(file,status)||before.has(file)&&!carried.has(file))continue;const hash=fingerprint(root,file);if(owned.get(file)===hash||selected(file,status))files.set(file,hash)}const proposal={revision,files:Object.fromEntries(files)};if(JSON.stringify(proposal)===JSON.stringify(previous)||files.size===0&&!previous)return;if(files.size===0){rmSync(path,{force:true});return}mkdirSync(dirname(path),{recursive:true,mode:448});const temp=`${path}.${randomUUID()}`;try{writeFileSync(temp,JSON.stringify(proposal),{flag:"wx",mode:384});renameSync(temp,path)}finally{rmSync(temp,{force:true})}notify(root,files.size)}}function commitReviewedTree(root,revision,files,tree,workIndex,validate){const[head,branch]=revision.trim().split(`
|
|
1
|
+
import{createHash}from"node:crypto";import{closeSync,existsSync,fsyncSync,lstatSync,mkdirSync,mkdtempSync,openSync,readFileSync,renameSync,rmSync,writeFileSync}from"node:fs";import{dirname,join,relative}from"node:path";import{approvalPath,readApproval,writeApprovalState}from"@stacksjs/actions/daemon/approval-state";import{readGenerationConfig}from"@stacksjs/actions/daemon/generation-config";import{acquireMigrationLock}from"@stacksjs/database/migration-lock";import{generatedChanges,generationRevision,git,gitCommand,gitRevision}from"./generation-changes";const staleApproval="The proposal changed. Run buddy generate:project and review the current changes again.";const commitMessage="chore: regenerate Stacks artifacts";function fingerprint(root,file){const path=join(root,file);const stat=lstatSync(path,{throwIfNoEntry:false});if(!stat)return;if(!stat.isFile())return"not a regular file";return createHash("sha256").update(`${stat.mode}:`).update(readFileSync(path)).digest("hex")}function branchOf(revision){const branch=revision?.trim().split(`
|
|
2
|
+
`)[1];return branch?.startsWith("refs/heads/")?branch:undefined}export async function withApprovalLock(root,run){const path=approvalPath(root);mkdirSync(dirname(path),{recursive:true,mode:448});const lock=await acquireMigrationLock("sqlite",null,{sqliteLockPath:`${path}.lock`});try{return await run()}finally{await lock.release()}}export function prepareCommitApproval(root,task,enabledTasks){const revision=generationRevision(root);const branch=branchOf(revision);if(!revision)return;const path=approvalPath(root);const{read,eligible}=generatedChanges(root,enabledTasks,true);const selected=generatedChanges(root,[task],true);const before=read();const previous=readApproval(path);const sameBranch=branch!==undefined&&branchOf(previous?.revision)===branch;const pending=new Map(Object.entries(sameBranch?previous?.files??{}:{}));const incomplete=new Map(Object.entries(sameBranch?previous?.incomplete??{}:{}));const expected=new Map([...selected.writable].map((file)=>[file,fingerprint(root,file)]));const writes=new Map;const guard={beforeWrite(path){const file=relative(root,path);if(!selected.writable.has(file))return;const hash=fingerprint(root,file);const status=before.get(file);const owned=hash!==undefined&&(pending.get(file)===hash||incomplete.get(file)===hash||writes.get(file)===hash);if(expected.get(file)!==hash||hash==="not a regular file"||status&&!(owned&&eligible(file,status))){throw new Error(`Local edits in ${file}. Resolve them before Buddy regenerates this file.`)}},afterWrite(path){const file=relative(root,path);const hash=fingerprint(root,file);if(hash&&hash!=="not a regular file"){writes.set(file,hash);expected.set(file,hash)}}};return{guard,finish(success){if(!branch||branchOf(gitRevision(root))!==branch||JSON.stringify(readApproval(path))!==JSON.stringify(previous))return;const files={};const unfinished={};for(const[file,status]of[...read()].sort(([a],[b])=>a.localeCompare(b))){if(!eligible(file,status))continue;const hash=fingerprint(root,file);if(!hash||hash==="not a regular file")continue;if(writes.get(file)===hash||incomplete.get(file)===hash){if(success&&selected.eligible(file,status))files[file]=hash;else unfinished[file]=hash}else if(pending.get(file)===hash){files[file]=hash}}if(Object.keys(files).length+Object.keys(unfinished).length===0){if(previous&&sameBranch)rmSync(path,{force:true});return}const proposal={revision,files,notify:true,...Object.keys(unfinished).length?{incomplete:unfinished}:{}};if(JSON.stringify(proposal)!==JSON.stringify(previous))writeApprovalState(path,proposal)}}}function commitReviewedTree(root,revision,files,tree,workIndex,validate){const[head,branch]=revision.trim().split(`
|
|
5
3
|
`);if(!head||!branch?.startsWith("refs/heads/"))throw new Error(staleApproval);const ongoing=["MERGE_HEAD","CHERRY_PICK_HEAD","REVERT_HEAD","rebase-apply","rebase-merge","sequencer","BISECT_START"];if(ongoing.some((state)=>existsSync(git(root,"rev-parse","--path-format=absolute","--git-path",state).trim())))throw new Error("Finish the current Git operation before approving generated changes.");const index=git(root,"rev-parse","--path-format=absolute","--git-path","index").trim();const indexLock=`${index}.lock`;const fd=openSync(indexLock,"wx",lstatSync(index).mode&511);let installed=false;try{validate();writeFileSync(workIndex,readFileSync(index));const entries=git(root,"ls-tree","-rz",tree,"--",...files);gitCommand(root,["update-index","-z","--index-info"],{env:{...process.env,GIT_INDEX_FILE:workIndex},input:entries});const sign=git(root,"config","--type=bool","--default=false","--get","commit.gpgSign").trim()==="true";const commit=git(root,"commit-tree",tree,"-p",head,"-m",commitMessage,...sign?["-S"]:[]).trim();writeFileSync(fd,readFileSync(workIndex));fsyncSync(fd);validate();git(root,"update-ref","-m",`commit: ${commitMessage}`,branch,commit,head);renameSync(indexLock,index);installed=true;return commit}finally{closeSync(fd);if(!installed)rmSync(indexLock,{force:true})}}export async function reviewGeneratedCommit(root,review){const config=readGenerationConfig(root);if(!config?.commitApproval)throw new Error("Enable generation.commitApproval in config/buddy.json to review generated commits.");const path=approvalPath(root);const proposal=readApproval(path);if(!proposal||Object.keys(proposal.files).length===0)return"empty";const{read,eligible}=generatedChanges(root,config.tasks,true);const files=Object.keys(proposal.files);const validate=()=>{const latest=readGenerationConfig(root);if(!latest?.commitApproval||latest.tasks.join()!==config.tasks.join()||gitRevision(root)!==proposal.revision||!proposal.revision.includes(`
|
|
6
4
|
refs/heads/`)||JSON.stringify(readApproval(path))!==JSON.stringify(proposal))throw new Error(staleApproval);const status=read();for(const file of files){const state=status.get(file);if(!state||!eligible(file,state)||fingerprint(root,file)!==proposal.files[file])throw new Error(staleApproval)}};const workspace=mkdtempSync(join(dirname(path),"review-"));try{const previewIndex=join(workspace,"preview-index");const preview=(...args)=>gitCommand(root,args,{env:{...process.env,GIT_INDEX_FILE:previewIndex}});validate();const[head]=proposal.revision.split(`
|
|
7
|
-
`);preview("read-tree",head);preview("add","--force","--",...files);const tree=preview("write-tree").trim();const diff=git(root,"diff","--binary","--no-ext-diff","--no-textconv","--no-color",head,tree,"--");validate();if(!diff)return"empty";if(!await review(diff))return"pending";const commit=commitReviewedTree(root,proposal.revision,files,tree,join(workspace,"real-index"),validate);if(
|
|
5
|
+
`);preview("read-tree",head);preview("add","--force","--",...files);const tree=preview("write-tree").trim();const diff=git(root,"diff","--binary","--no-ext-diff","--no-textconv","--no-color",head,tree,"--");validate();if(!diff)return"empty";if(!await review(diff))return"pending";return await withApprovalLock(root,()=>{const commit=commitReviewedTree(root,proposal.revision,files,tree,join(workspace,"real-index"),validate);if(proposal.incomplete)writeApprovalState(path,{...proposal,revision:gitRevision(root),files:{}});else rmSync(path,{force:true});return commit})}finally{rmSync(workspace,{recursive:true,force:true})}}
|
|
@@ -6,7 +6,8 @@ export declare function gitRevision(root: string): string;
|
|
|
6
6
|
export declare function generationRevision(root: string): string | undefined;
|
|
7
7
|
export declare function generatedChanges(root: string, tasks: GenerationTask[], includeIgnored?: boolean): {
|
|
8
8
|
read: __dtsx_return_0.__dtsx_return_0_result_0;
|
|
9
|
-
eligible: __dtsx_return_0.__dtsx_return_0_result_1
|
|
9
|
+
eligible: __dtsx_return_0.__dtsx_return_0_result_1;
|
|
10
|
+
writable: __dtsx_return_0.__dtsx_return_0_result_2
|
|
10
11
|
};
|
|
11
12
|
/** Commit only clean-before paths whose contents the requested generators own. */
|
|
12
13
|
export declare function prepareAutomaticCommit(root: string, tasks: GenerationTask[]): (() => void) | undefined;
|
|
@@ -14,16 +15,20 @@ declare namespace __dtsx_return_0 {
|
|
|
14
15
|
/** @defaultValue `[...(tasks.includes('imports') ? importFiles : []), ...(tasks.includes('types') ? typeFiles : [])]` */
|
|
15
16
|
const files: unknown[];
|
|
16
17
|
const migrations: ReturnType<typeof tasks.includes>;
|
|
18
|
+
const writable: Set<any>;
|
|
17
19
|
/** @defaultValue `[...files, ...(migrations ? migrationDirectories : [])]` */
|
|
18
20
|
const scope: ((typeof files)[number] | unknown)[];
|
|
19
21
|
const read: () => Map<any, any>;
|
|
22
|
+
const generatedSql: (file: string) => unknown;
|
|
20
23
|
const eligible: (file: string, status: string) => boolean;
|
|
21
24
|
namespace __dtsx_return_0_scope_0 {
|
|
22
25
|
type __dtsx_return_0_result_0 = typeof read
|
|
23
26
|
type __dtsx_return_0_result_1 = typeof eligible
|
|
27
|
+
type __dtsx_return_0_result_2 = typeof writable
|
|
24
28
|
}
|
|
25
29
|
type __dtsx_return_0_result_0 = __dtsx_return_0_scope_0.__dtsx_return_0_result_0
|
|
26
30
|
type __dtsx_return_0_result_1 = __dtsx_return_0_scope_0.__dtsx_return_0_result_1
|
|
31
|
+
type __dtsx_return_0_result_2 = __dtsx_return_0_scope_0.__dtsx_return_0_result_2
|
|
27
32
|
|
|
28
33
|
}
|
|
29
34
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{spawnSync}from"node:child_process";import{lstatSync}from"node:fs";import{basename,dirname,join}from"node:path";import{isGeneratedMigration}from"@stacksjs/database/generated-migration-marker";const importFiles=["RUNTIME.md","actions.ts","controllers.ts","emails.ts","functions.ts","globals.ts","index.ts","jobs.ts","listeners.ts","middleware.ts","models.ts","policies.ts","sources.json"].map((file)=>`storage/framework/auto-imports/${file}`).concat(["storage/framework/types/browser-auto-imports.d.ts","storage/framework/types/server-auto-imports.d.ts","storage/framework/browser-auto-imports.json","storage/framework/server-auto-imports.json"]);const typeFiles=["storage/framework/auto-imports/routes.ts","database/types.d.ts"];const migrationDirectories=["database/migrations","storage/framework/database"];export function gitCommand(root,args,options){const result=spawnSync("git",["--literal-pathspecs",...args],{cwd:root,encoding:"utf8",timeout:30000,maxBuffer:32*1024*1024,...options});if(result.status!==0)throw new Error(result.error?.message??(result.stderr.trim()||`git ${args[0]} failed`));return result.stdout}export function git(root,...args){return gitCommand(root,args)}export function gitRevision(root){return git(root,"rev-parse","HEAD","--symbolic-full-name","HEAD")}export function generationRevision(root){try{if(!git(root,"rev-parse","--show-prefix").trim())return gitRevision(root)}catch{}}export function generatedChanges(root,tasks,includeIgnored=false){const files=[...tasks.includes("imports")?importFiles:[],...tasks.includes("types")?typeFiles:[]];const migrations=tasks.includes("migrations");const scope=[...files,...migrations?migrationDirectories:[]];const read=()=>{const status=git(root,"--no-optional-locks","status","--porcelain=v1","-z","--no-renames","--untracked-files=all",...includeIgnored&&migrations?["--ignored=traditional"]:[],"--",...scope);return new Map(status.split("\x00").filter(Boolean).map((entry)=>[entry.slice(3),entry.slice(0,2)]))};const
|
|
1
|
+
import{spawnSync}from"node:child_process";import{lstatSync}from"node:fs";import{basename,dirname,join}from"node:path";import{isGeneratedMigration}from"@stacksjs/database/generated-migration-marker";const importFiles=["RUNTIME.md","actions.ts","controllers.ts","emails.ts","functions.ts","globals.ts","index.ts","jobs.ts","listeners.ts","middleware.ts","models.ts","policies.ts","sources.json"].map((file)=>`storage/framework/auto-imports/${file}`).concat(["storage/framework/types/browser-auto-imports.d.ts","storage/framework/types/server-auto-imports.d.ts","storage/framework/browser-auto-imports.json","storage/framework/server-auto-imports.json"]);const typeFiles=["storage/framework/auto-imports/routes.ts","database/types.d.ts"];const migrationDirectories=["database/migrations","storage/framework/database"];const snapshotFiles=["sqlite","mysql","postgres","singlestore","vitess"].map((dialect)=>`storage/framework/database/model-snapshot.${dialect}.json`);export function gitCommand(root,args,options){const result=spawnSync("git",["--literal-pathspecs",...args],{cwd:root,encoding:"utf8",timeout:30000,maxBuffer:32*1024*1024,...options});if(result.status!==0)throw new Error(result.error?.message??(result.stderr.trim()||`git ${args[0]} failed`));return result.stdout}export function git(root,...args){return gitCommand(root,args)}export function gitRevision(root){return git(root,"rev-parse","HEAD","--symbolic-full-name","HEAD")}export function generationRevision(root){try{if(!git(root,"rev-parse","--show-prefix").trim())return gitRevision(root)}catch{}}export function generatedChanges(root,tasks,includeIgnored=false){const files=[...tasks.includes("imports")?importFiles:[],...tasks.includes("types")?typeFiles:[]];const migrations=tasks.includes("migrations");const writable=new Set([...files,...migrations?snapshotFiles:[]]);const scope=[...files,...migrations?migrationDirectories:[]];const read=()=>{const status=git(root,"--no-optional-locks","status","--porcelain=v1","-z","--no-renames","--untracked-files=all",...includeIgnored&&migrations?["--ignored=traditional"]:[],"--",...scope);return new Map(status.split("\x00").filter(Boolean).map((entry)=>[entry.slice(3),entry.slice(0,2)]))};const generatedSql=(file)=>{const fullPath=join(root,file);return migrations&&/^database\/migrations\/(?:[^/]+\/)?\d{10}-.+\.sql$/.test(file)&&isGeneratedMigration(dirname(fullPath),basename(fullPath))};const eligible=(file,status)=>{if(status==="!!"?!generatedSql(file):!writable.has(file)&&!generatedSql(file))return false;return(status===" M"||status==="??"||status==="!!")&&lstatSync(join(root,file),{throwIfNoEntry:false})?.isFile()===true};return{read,eligible,writable}}export function prepareAutomaticCommit(root,tasks){const revision=generationRevision(root);if(!revision)return;const{read,eligible}=generatedChanges(root,tasks);const before=read();return()=>{if(gitRevision(root)!==revision)return;const changes=[...read()].filter(([file,status])=>!before.has(file)&&eligible(file,status));if(changes.length===0)return;const newFiles=changes.filter(([,status])=>status==="??").map(([file])=>file);if(newFiles.length>0)git(root,"add","--intent-to-add","--",...newFiles);git(root,"commit","--only","-m","chore: regenerate Stacks artifacts","--",...changes.map(([file])=>file))}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{generationTasks,readGenerationConfig}from"@stacksjs/actions/daemon/generation-config";import{prepareCommitApproval}from"./generation-approval";import{prepareAutomaticCommit}from"./generation-changes";import{resultError,resultFailed}from"./result";export async function generateProject(root,selection){const config=readGenerationConfig(root);if(!config)return;const requested=new Set(selection.split(","));const tasks=generationTasks.filter((task)=>requested.has(task)&&config.tasks.includes(task));if(tasks.length===0)return;const commit=config.autoCommit?prepareAutomaticCommit(root,tasks):undefined;const
|
|
2
|
-
`));
|
|
1
|
+
import{generationTasks,readGenerationConfig}from"@stacksjs/actions/daemon/generation-config";import{prepareCommitApproval,withApprovalLock}from"./generation-approval";import{prepareAutomaticCommit}from"./generation-changes";import{resultError,resultFailed}from"./result";export async function generateProject(root,selection){const config=readGenerationConfig(root);if(!config)return;const requested=new Set(selection.split(","));const tasks=generationTasks.filter((task)=>requested.has(task)&&config.tasks.includes(task));if(tasks.length===0)return;if(config.commitApproval)await withApprovalLock(root,()=>runGeneration(root,tasks,config));else await runGeneration(root,tasks,config)}async function runGeneration(root,tasks,config){const commit=config.autoCommit?prepareAutomaticCommit(root,tasks):undefined;const failures=[];for(const task of tasks){const firstFailure=failures.length;const approval=config.commitApproval?prepareCommitApproval(root,task,config.tasks):undefined;const guard=approval?.guard;try{if(task==="imports"){const{generateAutoImportFiles}=await import("@stacksjs/server");await generateAutoImportFiles({guard})}else if(task==="migrations"){const{generateMigrations,siblingMigrationDialects}=await import("@stacksjs/database");for(const dialect of[undefined,...await siblingMigrationDialects()]){const result=await generateMigrations({dialect,fromDb:false,allowDestructive:false,trackIgnored:false,guard});if(resultFailed(result))failures.push(`${dialect??"configured dialect"} migrations: ${resultError(result)}`)}}else{const{generateRouteNames}=await import("@stacksjs/actions/generate/action-types");const{buildDatabaseSchema}=await import("@stacksjs/orm");await generateRouteNames({strict:true,guard});const{errors}=await buildDatabaseSchema({strict:true,guard});failures.push(...errors.map((error)=>`${error.file}: ${error.error}`))}}catch(error){failures.push(`${task}: ${error instanceof Error?error.message:String(error)}`)}if(approval){const current=readGenerationConfig(root);approval.finish(failures.length===firstFailure&¤t?.commitApproval===true&¤t.tasks.includes(task))}}if(failures.length>0)throw new Error(failures.join(`
|
|
2
|
+
`));if(readGenerationConfig(root)?.autoCommit)commit?.()}
|
|
@@ -67,7 +67,7 @@ export declare const VENDORED_DEFAULTS: 'storage/framework/defaults';
|
|
|
67
67
|
* `scaffold-package-app.test.ts` fails if one stops existing in the
|
|
68
68
|
* repository, so a moved file cannot quietly start shipping again.
|
|
69
69
|
*/
|
|
70
|
-
export declare const FRAMEWORK_ONLY_PATHS: readonly ['bench', '
|
|
70
|
+
export declare const FRAMEWORK_ONLY_PATHS: readonly ['bench', 'config/changelog.ts', 'storage/framework/tsconfig.framework.json', 'storage/framework/tsconfig.defaults.json', 'storage/framework/tsconfig.type-tests.json', 'storage/framework/docs', 'storage/framework/scripts/fresh', 'storage/framework/scripts/generate-changelog', 'storage/framework/scripts/install', 'storage/framework/scripts/link', 'storage/framework/scripts/lint', 'storage/framework/scripts/move-built-src-files.ts', 'storage/framework/scripts/move-dts-files.ts', 'storage/framework/scripts/normalize-workspace-deps-for-publish', 'storage/framework/scripts/publish', 'storage/framework/scripts/publish-commit', 'storage/framework/scripts/publish-dummy-libs'];
|
|
71
71
|
/**
|
|
72
72
|
* The STX runtime packages, released together at one version: the runtime,
|
|
73
73
|
* its components, its compiler, and the three the runtime itself pulls in.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{appendFileSync,cpSync,existsSync,lstatSync,readdirSync,readFileSync,rmSync,writeFileSync}from"node:fs";import{extname,join,relative}from"node:path";import{linkPackagedDefaults,packagedDefaultsRoot}from"@stacksjs/path";export const VENDORED_DEFAULTS="storage/framework/defaults";export const FRAMEWORK_ONLY_PATHS=["bench","
|
|
1
|
+
import{appendFileSync,cpSync,existsSync,lstatSync,readdirSync,readFileSync,rmSync,writeFileSync}from"node:fs";import{extname,join,relative}from"node:path";import{linkPackagedDefaults,packagedDefaultsRoot}from"@stacksjs/path";export const VENDORED_DEFAULTS="storage/framework/defaults";export const FRAMEWORK_ONLY_PATHS=["bench","config/changelog.ts","storage/framework/tsconfig.framework.json","storage/framework/tsconfig.defaults.json","storage/framework/tsconfig.type-tests.json","storage/framework/docs","storage/framework/scripts/fresh","storage/framework/scripts/generate-changelog","storage/framework/scripts/install","storage/framework/scripts/link","storage/framework/scripts/lint","storage/framework/scripts/move-built-src-files.ts","storage/framework/scripts/move-dts-files.ts","storage/framework/scripts/normalize-workspace-deps-for-publish","storage/framework/scripts/publish","storage/framework/scripts/publish-commit","storage/framework/scripts/publish-dummy-libs"];export function pruneFrameworkOnlyFiles(root){const removed=[];for(const path of[...FRAMEWORK_ONLY_PATHS,"logsmith.config.ts"]){const full=join(root,path);if(!existsSync(full))continue;rmSync(full,{recursive:true,force:true});removed.push(path)}return removed}const FRAMEWORK_ONLY_SCRIPTS=[/^bench(?::|$)/,/^test:bench$/,/^typecheck:(?:bench|framework|type-tests)$/,/^docs:/,/^declarations:check$/,/^deps:lockfile:check$/];const APP_SCRIPTS={buddy:"./buddy",typecheck:"bun run typecheck:app","typecheck:app":"bun x --bun tsc --noEmit -p tsconfig.json --pretty false","typecheck:views":"bun x --bun stx typecheck --lib storage/framework/types/request-context.d.ts --lib storage/framework/types/browser-composables.d.ts 'resources/**/*.stx'","build:reset":"rm -rf node_modules && pantry install && ./buddy generate:types && ./buddy lint:fix"};export function appPackageScripts(scripts){const next={};const removed=[];const rewritten=[];for(const[name,command]of Object.entries(scripts)){if(FRAMEWORK_ONLY_SCRIPTS.some((pattern)=>pattern.test(name))){removed.push(name);continue}const replacement=APP_SCRIPTS[name];if(replacement!==undefined&&replacement!==command){next[name]=replacement;rewritten.push(name);continue}next[name]=command}return{scripts:next,removed,rewritten}}export function applyAppPackageScripts(root){const file=join(root,"package.json");const empty={scripts:{},removed:[],rewritten:[]};if(!existsSync(file))return empty;const pkg=JSON.parse(readFileSync(file,"utf8"));const changes=appPackageScripts(pkg.scripts??{});if(changes.removed.length>0||changes.rewritten.length>0){pkg.scripts=changes.scripts;writeFileSync(file,`${JSON.stringify(pkg,null,2)}
|
|
2
2
|
`)}const frameworkFile=join(root,"storage/framework/package.json");if(existsSync(frameworkFile)){const framework=JSON.parse(readFileSync(frameworkFile,"utf8"));let touched=false;for(const[name,command]of Object.entries(framework.scripts??{})){if(!/\.\/scripts\/publish|\.\/core\b/.test(command))continue;delete framework.scripts[name];touched=true}if(touched)writeFileSync(frameworkFile,`${JSON.stringify(framework,null,2)}
|
|
3
3
|
`)}return changes}export const STX_RUNTIME_PACKAGES=["@stacksjs/stx","@stacksjs/components","bun-plugin-stx","@stacksjs/desktop","@stacksjs/sanitizer","stx-router"];export function appPackageOverrides(overrides){const next={};const removed=[];for(const[name,rule]of Object.entries(overrides)){if(STX_RUNTIME_PACKAGES.includes(name))removed.push(name);else next[name]=rule}return{overrides:next,removed}}export function applyAppPackageOverrides(root){const file=join(root,"package.json");if(!existsSync(file))return[];const pkg=JSON.parse(readFileSync(file,"utf8"));if(!pkg.overrides||typeof pkg.overrides!=="object"||Array.isArray(pkg.overrides))return[];const{overrides,removed}=appPackageOverrides(pkg.overrides);if(removed.length===0)return[];if(Object.keys(overrides).length>0)pkg.overrides=overrides;else delete pkg.overrides;writeFileSync(file,`${JSON.stringify(pkg,null,2)}
|
|
4
4
|
`);return removed}const FRAMEWORK_CREDIT_KEYS=["author","contributors","funding","homepage","repository","bugs"];export function stripFrameworkManifestCredits(root){const framework=join(root,"storage/framework");const manifests=[];const walk=(dir)=>{let entries;try{entries=readdirSync(dir,{withFileTypes:true})}catch{return}for(const entry of entries){const full=join(dir,entry.name);if(entry.isDirectory()&&!["core","defaults","node_modules","dist"].includes(entry.name))walk(full);else if(entry.isFile()&&entry.name==="package.json")manifests.push(full)}};walk(framework);const touched=[];for(const file of manifests){const pkg=JSON.parse(readFileSync(file,"utf8"));const present=FRAMEWORK_CREDIT_KEYS.filter((key)=>(key in pkg));if(present.length===0)continue;for(const key of present)delete pkg[key];writeFileSync(file,`${JSON.stringify(pkg,null,2)}
|
package/dist/scaffold-site.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ export declare const APP_SITE_TEMPLATE: 'storage/framework/defaults/scaffold/res
|
|
|
37
37
|
*
|
|
38
38
|
* `scaffold-site.test.ts` holds this against the repository: a top-level path
|
|
39
39
|
* committed here later is either added to this list, because an app wants it,
|
|
40
|
-
* or to one of the lists that remove it.
|
|
40
|
+
* or to one of the lists that remove it. Host operations and `.reviewos/` reached every
|
|
41
41
|
* new app because nothing asked that question.
|
|
42
42
|
*/
|
|
43
43
|
export declare const APP_TOP_LEVEL: readonly string[];
|
package/dist/scaffold-site.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{cpSync,existsSync,readdirSync,rmSync}from"node:fs";import{join}from"node:path";export const SITE_ONLY_PATHS=["resources/views/index.stx","resources/views/coming-soon.stx","resources/views/compare","resources/views/features","resources/views/use-cases","resources/views/components/FeatureCard.stx","resources/views/layouts/marketing.stx","resources/views/partials/theme.stx","resources/data/assets.ts","resources/data/comparisons.ts","resources/data/features.ts","resources/data/highlight.ts","resources/data/nav.ts","resources/data/stats.ts","resources/data/use-cases.ts","resources/partials/marketing-footer.stx","resources/partials/marketing-head.stx","resources/partials/marketing-nav.stx","resources/partials/marketing-theme-toggle.stx","resources/emails/subscription-confirmation.stx","resources/assets/scripts/site-mode.js","public/assets/styles/home.css","public/assets/styles/marketing.css","public/assets/styles/theme.css","resources/assets/fonts/nps","public/assets/fonts/nps","public/assets/images","resources/assets/images/bg-img.png","resources/assets/images/marketing-park-camp.svg","resources/assets/images/marketing-park-geyser.svg","resources/assets/images/marketing-park-lighthouse.svg","resources/assets/images/marketing-park-trail.svg","resources/assets/images/marketing-park-wing.svg","resources/assets/images/park-ridge.svg","resources/assets/images/river.svg","resources/assets/images/topography.svg","resources/assets/images/wood-sign.svg","docs","content/blog","content/BLOG_STRATEGY.md","public/images/atomic-fx-diagram.png","public/images/atomic-ui-diagram.png","public/images/diagram.png","public/images/og-image.png","public/images/social.png","public/images/background-auth.jpg","public/images/background-features.jpg","public/images/screenshots/expenses.webp","public/images/screenshots/reporting.webp","public/images/screenshots/vat-returns.webp","public/images/logos/amex.jpg","public/images/logos/jcb.svg","public/images/logos/laravel.svg","public/images/logos/logo-dark.svg","public/images/logos/logo-mini.svg","public/images/logos/logo-transparent.svg","public/images/logos/logo-white.png","public/images/logos/logo.png","public/images/logos/logo.svg","public/images/logos/mastercard.svg","public/images/logos/meilisearch.svg","public/images/logos/mirage.svg","public/images/logos/statamic.svg","public/images/logos/statickit.svg","public/images/logos/transistor.svg","public/images/logos/tuple.svg","public/images/logos/visa.png","public/images/logos/visa.svgz","
|
|
1
|
+
import{cpSync,existsSync,readdirSync,rmSync}from"node:fs";import{join}from"node:path";export const SITE_ONLY_PATHS=["resources/views/index.stx","resources/views/coming-soon.stx","resources/views/compare","resources/views/features","resources/views/use-cases","resources/views/components/FeatureCard.stx","resources/views/layouts/marketing.stx","resources/views/partials/theme.stx","resources/data/assets.ts","resources/data/comparisons.ts","resources/data/features.ts","resources/data/highlight.ts","resources/data/nav.ts","resources/data/stats.ts","resources/data/use-cases.ts","resources/partials/marketing-footer.stx","resources/partials/marketing-head.stx","resources/partials/marketing-nav.stx","resources/partials/marketing-theme-toggle.stx","resources/emails/subscription-confirmation.stx","resources/assets/scripts/site-mode.js","public/assets/styles/home.css","public/assets/styles/marketing.css","public/assets/styles/theme.css","resources/assets/fonts/nps","public/assets/fonts/nps","public/assets/images","resources/assets/images/bg-img.png","resources/assets/images/marketing-park-camp.svg","resources/assets/images/marketing-park-geyser.svg","resources/assets/images/marketing-park-lighthouse.svg","resources/assets/images/marketing-park-trail.svg","resources/assets/images/marketing-park-wing.svg","resources/assets/images/park-ridge.svg","resources/assets/images/river.svg","resources/assets/images/topography.svg","resources/assets/images/wood-sign.svg","docs","content/blog","content/BLOG_STRATEGY.md","public/images/atomic-fx-diagram.png","public/images/atomic-ui-diagram.png","public/images/diagram.png","public/images/og-image.png","public/images/social.png","public/images/background-auth.jpg","public/images/background-features.jpg","public/images/screenshots/expenses.webp","public/images/screenshots/reporting.webp","public/images/screenshots/vat-returns.webp","public/images/logos/amex.jpg","public/images/logos/jcb.svg","public/images/logos/laravel.svg","public/images/logos/logo-dark.svg","public/images/logos/logo-mini.svg","public/images/logos/logo-transparent.svg","public/images/logos/logo-white.png","public/images/logos/logo.png","public/images/logos/logo.svg","public/images/logos/mastercard.svg","public/images/logos/meilisearch.svg","public/images/logos/mirage.svg","public/images/logos/statamic.svg","public/images/logos/statickit.svg","public/images/logos/transistor.svg","public/images/logos/tuple.svg","public/images/logos/visa.png","public/images/logos/visa.svgz","cloud/production",".reviewos","resources/assets/scripts/main.ts","resources/assets/styles/main.css","resources/layouts/Desktop.stx","resources/partials/welcome-pdf-content.stx","resources/partials/welcome-pdf-toolbar.stx","resources/components/ContextMenu.stx","resources/components/ContextMenuItem.stx","resources/components/DesktopIcon.stx","resources/components/FeatureButton.stx","resources/components/InputGroup.stx","resources/components/LoginForm.stx","resources/components/LoginScreen.stx","resources/components/NotificationPopup.stx","resources/components/PackageItem.stx","resources/components/StartMenu.stx","resources/components/StartMenuItem.stx","resources/components/Taskbar.stx","resources/components/Window.stx"];export const APP_SITE_TEMPLATE="storage/framework/defaults/scaffold/resources";export function applyAppSiteTemplate(root){const template=join(root,APP_SITE_TEMPLATE);if(!existsSync(template))throw new Error(`No app site template at ${APP_SITE_TEMPLATE}`);const removed=[];for(const relative of[...SITE_ONLY_PATHS,"ops"]){const target=join(root,relative);if(!existsSync(target))continue;rmSync(target,{recursive:true,force:true});removed.push(relative)}for(const relative of removed){let dir=parentOf(relative);while(dir&&!KEPT_ROOTS.has(dir)&&isEmptyDir(join(root,dir))){rmSync(join(root,dir),{recursive:true,force:true});dir=parentOf(dir)}}cpSync(template,join(root,"resources"),{recursive:true});return removed}const KEPT_ROOTS=new Set(["resources","public"]);export const APP_TOP_LEVEL=[".devcontainer",".dockerignore",".editorconfig",".env.example",".gitattributes",".github",".gitignore",".security-ignore.json","AGENTS.md","CHANGELOG.md","README.md","app","bootstrap","buddy","bun.lock","bunfig.toml","cloud","config","database","locales","package.json","pantry.lock","public","resources","routes","storage","tests","tsconfig.json"];export const REMOVED_BY_OTHER_STEPS={".env.development":"install",".env.production":"install",".env.staging":"install","LICENSE.md":"removeFrameworkLicense","deps.yml":"generatePantryDeps"};function parentOf(relative){return relative.includes("/")?relative.slice(0,relative.lastIndexOf("/")):""}function isEmptyDir(dir){return existsSync(dir)&&readdirSync(dir).length===0}
|
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.
|
|
5
|
+
"version": "0.75.640",
|
|
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.
|
|
99
|
-
"@stacksjs/docs": "0.75.
|
|
100
|
-
"@stacksjs/ai": "0.75.
|
|
101
|
-
"@stacksjs/alias": "0.75.
|
|
102
|
-
"@stacksjs/analytics": "0.75.
|
|
103
|
-
"@stacksjs/api": "0.75.
|
|
104
|
-
"@stacksjs/arrays": "0.75.
|
|
105
|
-
"@stacksjs/auth": "0.75.
|
|
106
|
-
"@stacksjs/browser-extension": "0.75.
|
|
107
|
-
"@stacksjs/build": "0.75.
|
|
98
|
+
"@stacksjs/actions": "0.75.640",
|
|
99
|
+
"@stacksjs/docs": "0.75.640",
|
|
100
|
+
"@stacksjs/ai": "0.75.640",
|
|
101
|
+
"@stacksjs/alias": "0.75.640",
|
|
102
|
+
"@stacksjs/analytics": "0.75.640",
|
|
103
|
+
"@stacksjs/api": "0.75.640",
|
|
104
|
+
"@stacksjs/arrays": "0.75.640",
|
|
105
|
+
"@stacksjs/auth": "0.75.640",
|
|
106
|
+
"@stacksjs/browser-extension": "0.75.640",
|
|
107
|
+
"@stacksjs/build": "0.75.640",
|
|
108
108
|
"@stacksjs/bumpx": "^0.2.32",
|
|
109
|
-
"@stacksjs/cache": "0.75.
|
|
110
|
-
"@stacksjs/chat": "0.75.
|
|
109
|
+
"@stacksjs/cache": "0.75.640",
|
|
110
|
+
"@stacksjs/chat": "0.75.640",
|
|
111
111
|
"@stacksjs/clapp": "^0.2.17",
|
|
112
|
-
"@stacksjs/cli": "0.75.
|
|
113
|
-
"@stacksjs/cloud": "0.75.
|
|
114
|
-
"@stacksjs/cms": "0.75.
|
|
115
|
-
"@stacksjs/collections": "0.75.
|
|
116
|
-
"@stacksjs/commerce": "0.75.
|
|
117
|
-
"@stacksjs/config": "0.75.
|
|
118
|
-
"@stacksjs/database": "0.75.
|
|
119
|
-
"@stacksjs/desktop-build": "0.75.
|
|
120
|
-
"@stacksjs/dns": "0.75.
|
|
112
|
+
"@stacksjs/cli": "0.75.640",
|
|
113
|
+
"@stacksjs/cloud": "0.75.640",
|
|
114
|
+
"@stacksjs/cms": "0.75.640",
|
|
115
|
+
"@stacksjs/collections": "0.75.640",
|
|
116
|
+
"@stacksjs/commerce": "0.75.640",
|
|
117
|
+
"@stacksjs/config": "0.75.640",
|
|
118
|
+
"@stacksjs/database": "0.75.640",
|
|
119
|
+
"@stacksjs/desktop-build": "0.75.640",
|
|
120
|
+
"@stacksjs/dns": "0.75.640",
|
|
121
121
|
"@stacksjs/dnsx": "^0.2.3",
|
|
122
|
-
"@stacksjs/email": "0.75.
|
|
123
|
-
"@stacksjs/enums": "0.75.
|
|
124
|
-
"@stacksjs/env": "0.75.
|
|
125
|
-
"@stacksjs/error-handling": "0.75.
|
|
126
|
-
"@stacksjs/events": "0.75.
|
|
127
|
-
"@stacksjs/features": "0.75.
|
|
128
|
-
"@stacksjs/git": "0.75.
|
|
122
|
+
"@stacksjs/email": "0.75.640",
|
|
123
|
+
"@stacksjs/enums": "0.75.640",
|
|
124
|
+
"@stacksjs/env": "0.75.640",
|
|
125
|
+
"@stacksjs/error-handling": "0.75.640",
|
|
126
|
+
"@stacksjs/events": "0.75.640",
|
|
127
|
+
"@stacksjs/features": "0.75.640",
|
|
128
|
+
"@stacksjs/git": "0.75.640",
|
|
129
129
|
"@stacksjs/gitit": "^0.2.5",
|
|
130
|
-
"@stacksjs/health": "0.75.
|
|
131
|
-
"@stacksjs/hq": "0.75.
|
|
130
|
+
"@stacksjs/health": "0.75.640",
|
|
131
|
+
"@stacksjs/hq": "0.75.640",
|
|
132
132
|
"@stacksjs/httx": "^0.1.10",
|
|
133
|
-
"@stacksjs/image": "0.75.
|
|
134
|
-
"@stacksjs/lint": "0.75.
|
|
135
|
-
"@stacksjs/logging": "0.75.
|
|
136
|
-
"@stacksjs/notifications": "0.75.
|
|
137
|
-
"@stacksjs/objects": "0.75.
|
|
138
|
-
"@stacksjs/orm": "0.75.
|
|
139
|
-
"@stacksjs/path": "0.75.
|
|
140
|
-
"@stacksjs/payments": "0.75.
|
|
141
|
-
"@stacksjs/realtime": "0.75.
|
|
142
|
-
"@stacksjs/router": "0.75.
|
|
133
|
+
"@stacksjs/image": "0.75.640",
|
|
134
|
+
"@stacksjs/lint": "0.75.640",
|
|
135
|
+
"@stacksjs/logging": "0.75.640",
|
|
136
|
+
"@stacksjs/notifications": "0.75.640",
|
|
137
|
+
"@stacksjs/objects": "0.75.640",
|
|
138
|
+
"@stacksjs/orm": "0.75.640",
|
|
139
|
+
"@stacksjs/path": "0.75.640",
|
|
140
|
+
"@stacksjs/payments": "0.75.640",
|
|
141
|
+
"@stacksjs/realtime": "0.75.640",
|
|
142
|
+
"@stacksjs/router": "0.75.640",
|
|
143
143
|
"@stacksjs/rpx": "^0.11.54",
|
|
144
|
-
"@stacksjs/scheduler": "0.75.
|
|
145
|
-
"@stacksjs/search-engine": "0.75.
|
|
146
|
-
"@stacksjs/security": "0.75.
|
|
147
|
-
"@stacksjs/server": "0.75.
|
|
148
|
-
"@stacksjs/sites": "0.75.
|
|
149
|
-
"@stacksjs/skills": "0.75.
|
|
150
|
-
"@stacksjs/socials": "0.75.
|
|
151
|
-
"@stacksjs/storage": "0.75.
|
|
152
|
-
"@stacksjs/strings": "0.75.
|
|
144
|
+
"@stacksjs/scheduler": "0.75.640",
|
|
145
|
+
"@stacksjs/search-engine": "0.75.640",
|
|
146
|
+
"@stacksjs/security": "0.75.640",
|
|
147
|
+
"@stacksjs/server": "0.75.640",
|
|
148
|
+
"@stacksjs/sites": "0.75.640",
|
|
149
|
+
"@stacksjs/skills": "0.75.640",
|
|
150
|
+
"@stacksjs/socials": "0.75.640",
|
|
151
|
+
"@stacksjs/storage": "0.75.640",
|
|
152
|
+
"@stacksjs/strings": "0.75.640",
|
|
153
153
|
"@stacksjs/stx": "^0.2.908",
|
|
154
|
-
"@stacksjs/testing": "0.75.
|
|
155
|
-
"@stacksjs/tinker": "0.75.
|
|
154
|
+
"@stacksjs/testing": "0.75.640",
|
|
155
|
+
"@stacksjs/tinker": "0.75.640",
|
|
156
156
|
"@stacksjs/tlsx": "^0.13.19",
|
|
157
157
|
"@stacksjs/ts-cloud": "^0.16.144",
|
|
158
|
-
"@stacksjs/tunnel": "0.75.
|
|
159
|
-
"@stacksjs/types": "0.75.
|
|
160
|
-
"@stacksjs/ui": "0.75.
|
|
161
|
-
"@stacksjs/utils": "0.75.
|
|
162
|
-
"@stacksjs/validation": "0.75.
|
|
158
|
+
"@stacksjs/tunnel": "0.75.640",
|
|
159
|
+
"@stacksjs/types": "0.75.640",
|
|
160
|
+
"@stacksjs/ui": "0.75.640",
|
|
161
|
+
"@stacksjs/utils": "0.75.640",
|
|
162
|
+
"@stacksjs/validation": "0.75.640",
|
|
163
163
|
"ajv": "^8.20.0",
|
|
164
164
|
"ajv-formats": "^3.0.1",
|
|
165
165
|
"bun-plugin-stx": "^0.2.908",
|