@stacksjs/buddy 0.75.36 → 0.75.37

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/cli.js CHANGED
@@ -4,4 +4,4 @@ import{writeSync}from"node:fs";import process from"node:process";import{register
4
4
  [buddy] ${label}: ${error?.stack??String(error)}
5
5
  `)}catch{}log.error(error);return process.exit(1)};process.on("uncaughtException",(error)=>reportFatal("uncaughtException",error));process.on("unhandledRejection",(error)=>reportFatal("unhandledRejection",error))}async function main(){const buddy=cli("buddy");registerGlobalOptions(buddy,{version:requestedCommand!=="upgrade"&&requestedCommand!=="update"});const configPath="./buddy.config.js";try{await Bun.file(configPath).text();const{applyBuddyConfig}=await import("./config.js");await applyBuddyConfig(buddy)}catch{}if(needsFullSetup){p.ensureRuntimeDirectories();const{loadCommands,getCommandsToLoad,markLoaded}=await import("./lazy-commands.js"),{setup}=await import("./commands/setup.js");setup(buddy);markLoaded(buddy,"setup");if(!skipAppKeyCheck){const{runAction}=await import("@stacksjs/actions"),{Action}=await import("@stacksjs/enums"),{ensureProjectIsInitialized}=await import("@stacksjs/utils");if(!await ensureProjectIsInitialized()){log.info("Your `APP_KEY` is not yet set");log.info("Generating application key...");const result=await runAction(Action.KeyGenerate);if(resultFailed(result)){await log.error("Failed to set random application key.",result.error);process.exit(1)}}}const commandsToLoad=getCommandsToLoad(args);await loadCommands(commandsToLoad,buddy);await dynamicImports(buddy)}else{const{loadCommand}=await import("./lazy-commands.js");await loadCommand("version",buddy)}buddy.help();if(args.length===0&&process.stdin.isTTY&&!buddy.isNoInteraction)await showInteractiveMenu(buddy);else await parseOrExit(buddy)}async function showInteractiveMenu(buddy){const{bold,green,intro}=await import("@stacksjs/cli"),{select}=await import("@stacksjs/cli");await intro("buddy");console.log(bold(green("What would you like to do?")));console.log("");const choice=await select({message:"Select a command:",choices:[{value:"dev",label:"Start development server"},{value:"build",label:"Build for production"},{value:"test",label:"Run tests"},{value:"list",label:"List all commands"},{value:"doctor",label:"Run health checks"},{value:"about",label:"Show system information"},{value:"help",label:"Show help"},{value:"exit",label:"Exit"}],initial:0});console.log("");if(choice==="exit")process.exit(0);else if(choice==="help")buddy.outputHelp();else{process.argv=["bun","buddy",choice];await parseOrExit(buddy)}}async function parseOrExit(buddy){try{await buddy.parse()}catch(error){if(!(error?.name==="ClappError"||error?.isUsageError===!0))throw error;process.stderr.write(`${error.message}
6
6
  `);if(error.usage)process.stderr.write(`${error.usage}
7
- `);process.exit(typeof error.exitCode==="number"?error.exitCode:2)}}await main();export function applyAliases(cli,signature,aliases){const name=signature.trim().split(/\s+/)[0],command=cli?.commands?.find((candidate)=>candidate.name===name);if(!command||typeof command.alias!=="function")return!1;for(const alias of aliases)command.alias(alias);return!0}async function dynamicImports(buddy){const{loadCommands}=await import("@stacksjs/cli");await loadCommands(buddy,{commandsDir:p.appPath("Commands"),registryPath:p.appPath("Commands.ts"),onError:(message,error)=>log.error(`${message}:`,error),onDebug:(message)=>log.debug(message)});try{const listenerImport=await import(p.listenersPath("Console.ts"));if(typeof listenerImport.default==="function")listenerImport.default(buddy)}catch{}}
7
+ `);process.exit(typeof error.exitCode==="number"?error.exitCode:2)}}await main();export function applyAliases(cli,signature,aliases){const name=signature.trim().split(/\s+/)[0],command=cli?.commands?.find((candidate)=>candidate.name===name);if(!command||typeof command.alias!=="function")return!1;for(const alias of aliases)command.alias(alias);return!0}async function dynamicImports(buddy){const{loadCommands}=await import("@stacksjs/cli"),commands=()=>buddy.commands??[],before=commands().length;await loadCommands(buddy,{commandsDir:p.appPath("Commands"),registryPath:p.appPath("Commands.ts"),onError:(message,error)=>log.error(`${message}:`,error),onDebug:(message)=>log.debug(message)});if(new Set(commands().slice(before).flatMap((command)=>[command.name??"",...command.aliasNames??[]])).has(requestedCommand)){const{injectGlobalAutoImports}=await import("@stacksjs/server");await injectGlobalAutoImports()}try{const listenerImport=await import(p.listenersPath("Console.ts"));if(typeof listenerImport.default==="function")listenerImport.default(buddy)}catch{}}
@@ -1 +1 @@
1
- import process from"node:process";import{runAction}from"@stacksjs/actions";import{intro,log,outro}from"@stacksjs/cli";import{Action}from"@stacksjs/enums";import{ExitCode}from"@stacksjs/types";import{resultFailed}from"../result";export function schedule(buddy){const descriptions={project:"Target a specific project",schedule:"Run the scheduler",verbose:"Enable verbose output",list:"List all registered scheduled tasks with their next run time",status:"Show currently-held overlap locks (this-process only)",runOne:"Run one registered scheduled task immediately",enable:"Resume a paused scheduled task",disable:"Pause a scheduled task without editing source"};buddy.command("schedule:run",descriptions.schedule).option("-p, --project [project]",descriptions.project,{default:!1}).option("--verbose",descriptions.verbose,{default:!1}).action(async(options)=>{log.debug("Running `buddy schedule:run` ...",options);const perf=await intro("buddy schedule:run"),result=await runAction(Action.ScheduleRun,options);if(resultFailed(result)){await outro("While running the schedule:run command, there was an issue",{startTime:perf,useSeconds:!0},result.error);process.exit(ExitCode.FatalError)}process.exit(ExitCode.Success)});buddy.command("schedule:list",descriptions.list).option("--json","Print a machine-readable schedule registry",{default:!1}).action(async(options)=>{try{const{runScheduler,Schedule}=await import("@stacksjs/scheduler");await runScheduler();await Promise.resolve();const jobs=Schedule.listJobs();if(options.json){console.log(`STACKS_SCHEDULE_JSON=${JSON.stringify({jobs,locks:Schedule.listLocks()})}`);await Schedule.gracefulShutdown();process.exit(ExitCode.Success)}if(jobs.length===0){log.info("No scheduled tasks registered.");await Schedule.gracefulShutdown();process.exit(ExitCode.Success)}const nameWidth=Math.max(4,...jobs.map((j)=>j.name.length)),patternWidth=Math.max(7,...jobs.map((j)=>(j.pattern??"").length));log.info(`${"NAME".padEnd(nameWidth)} ${"PATTERN".padEnd(patternWidth)} STATUS TIMEZONE NEXT RUN (UTC)`);for(const j of jobs){const next=j.nextRun?j.nextRun.toISOString():"-";log.info(`${j.name.padEnd(nameWidth)} ${(j.pattern??"").padEnd(patternWidth)} ${(j.enabled?"active":"paused").padEnd(6)} ${(j.timezone??"UTC").padEnd(25)} ${next}`)}await Schedule.gracefulShutdown();process.exit(ExitCode.Success)}catch(err){await log.error(`[schedule:list] failed: ${err instanceof Error?err.message:String(err)}`);process.exit(ExitCode.FatalError)}});buddy.command("schedule:status",descriptions.status).option("--json","Print machine-readable scheduler status",{default:!1}).action(async(options)=>{try{const{Schedule}=await import("@stacksjs/scheduler"),held=Schedule.listLocks();if(options.json){console.log(`STACKS_SCHEDULE_STATUS_JSON=${JSON.stringify({locks:held})}`);process.exit(ExitCode.Success)}if(held.length===0)log.info("No in-process scheduler locks held.");else{log.info(`Held locks (${held.length}):`);for(const name of held)log.info(` \u2022 ${name}`)}await log.flush();process.exit(ExitCode.Success)}catch(err){await log.error(`[schedule:status] failed: ${err instanceof Error?err.message:String(err)}`);process.exit(ExitCode.FatalError)}});buddy.command("schedule:run-one <name>",descriptions.runOne).action(async(name)=>{try{const{runScheduler,Schedule}=await import("@stacksjs/scheduler");await runScheduler();await Promise.resolve();await Schedule.runNow(name);await Schedule.gracefulShutdown();log.success(`Scheduled task ${name} completed.`);await log.flush();process.exit(ExitCode.Success)}catch(err){await log.error(`[schedule:run-one] failed: ${err instanceof Error?err.message:String(err)}`);process.exit(ExitCode.FatalError)}});for(const[command,enabled,description]of[["schedule:enable",!0,descriptions.enable],["schedule:disable",!1,descriptions.disable]])buddy.command(`${command} <name>`,description).action(async(name)=>{try{const{runScheduler,Schedule}=await import("@stacksjs/scheduler");await runScheduler();await Promise.resolve();const exists=Schedule.listJobs().some((job)=>job.name===name);await Schedule.gracefulShutdown();if(!exists)throw Error(`Scheduled task "${name}" was not found.`);Schedule.setEnabled(name,enabled);log.success(`Scheduled task ${name} ${enabled?"resumed":"paused"}.`);await log.flush();process.exit(ExitCode.Success)}catch(err){await log.error(`[${command}] failed: ${err instanceof Error?err.message:String(err)}`);process.exit(ExitCode.FatalError)}})}
1
+ import process from"node:process";import{runAction}from"@stacksjs/actions";import{intro,log,outro}from"@stacksjs/cli";import{Action}from"@stacksjs/enums";import{ExitCode}from"@stacksjs/types";import{resultFailed}from"../result";export function schedule(buddy){const descriptions={project:"Target a specific project",schedule:"Run the scheduler",verbose:"Enable verbose output",list:"List all registered scheduled tasks with their next run time",status:"Show currently-held overlap locks (this-process only)",runOne:"Run one registered scheduled task immediately",enable:"Resume a paused scheduled task",disable:"Pause a scheduled task without editing source"};buddy.command("schedule:run",descriptions.schedule).option("-p, --project [project]",descriptions.project,{default:!1}).option("--verbose",descriptions.verbose,{default:!1}).action(async(options)=>{log.debug("Running `buddy schedule:run` ...",options);const perf=await intro("buddy schedule:run"),result=await runAction(Action.ScheduleRun,options);if(resultFailed(result)){await outro("While running the schedule:run command, there was an issue",{startTime:perf,useSeconds:!0},result.error);process.exit(ExitCode.FatalError)}process.exit(ExitCode.Success)});buddy.command("schedule:list",descriptions.list).option("--json","Print a machine-readable schedule registry",{default:!1}).action(async(options)=>{try{const{runScheduler,Schedule}=await import("@stacksjs/scheduler");await runScheduler();await Promise.resolve();const jobs=Schedule.listJobs();if(options.json){console.log(`STACKS_SCHEDULE_JSON=${JSON.stringify({jobs,locks:Schedule.listLocks()})}`);await Schedule.gracefulShutdown();process.exit(ExitCode.Success)}if(jobs.length===0){log.info("No scheduled tasks registered.");await Schedule.gracefulShutdown();process.exit(ExitCode.Success)}const nameWidth=Math.max(4,...jobs.map((j)=>j.name.length)),patternWidth=Math.max(7,...jobs.map((j)=>(j.pattern??"").length));log.info(`${"NAME".padEnd(nameWidth)} ${"PATTERN".padEnd(patternWidth)} STATUS TIMEZONE NEXT RUN (UTC)`);for(const j of jobs){const next=j.nextRun?j.nextRun.toISOString():"-";log.info(`${j.name.padEnd(nameWidth)} ${(j.pattern??"").padEnd(patternWidth)} ${(j.enabled?"active":"paused").padEnd(6)} ${(j.timezone??"UTC").padEnd(25)} ${next}`)}await Schedule.gracefulShutdown();process.exit(ExitCode.Success)}catch(err){await log.error(`[schedule:list] failed: ${err instanceof Error?err.message:String(err)}`);process.exit(ExitCode.FatalError)}});buddy.command("schedule:status",descriptions.status).option("--json","Print machine-readable scheduler status",{default:!1}).action(async(options)=>{try{const{Schedule}=await import("@stacksjs/scheduler"),held=Schedule.listLocks();if(options.json){console.log(`STACKS_SCHEDULE_STATUS_JSON=${JSON.stringify({locks:held})}`);process.exit(ExitCode.Success)}if(held.length===0)log.info("No in-process scheduler locks held.");else{log.info(`Held locks (${held.length}):`);for(const name of held)log.info(` \u2022 ${name}`)}await log.flush();process.exit(ExitCode.Success)}catch(err){await log.error(`[schedule:status] failed: ${err instanceof Error?err.message:String(err)}`);process.exit(ExitCode.FatalError)}});buddy.command("schedule:run-one <name>",descriptions.runOne).action(async(name)=>{try{const{injectGlobalAutoImports}=await import("@stacksjs/server");await injectGlobalAutoImports();const{runScheduler,Schedule}=await import("@stacksjs/scheduler");await runScheduler();await Promise.resolve();await Schedule.runNow(name);await Schedule.gracefulShutdown();log.success(`Scheduled task ${name} completed.`);await log.flush();process.exit(ExitCode.Success)}catch(err){await log.error(`[schedule:run-one] failed: ${err instanceof Error?err.message:String(err)}`);process.exit(ExitCode.FatalError)}});for(const[command,enabled,description]of[["schedule:enable",!0,descriptions.enable],["schedule:disable",!1,descriptions.disable]])buddy.command(`${command} <name>`,description).action(async(name)=>{try{const{runScheduler,Schedule}=await import("@stacksjs/scheduler");await runScheduler();await Promise.resolve();const exists=Schedule.listJobs().some((job)=>job.name===name);await Schedule.gracefulShutdown();if(!exists)throw Error(`Scheduled task "${name}" was not found.`);Schedule.setEnabled(name,enabled);log.success(`Scheduled task ${name} ${enabled?"resumed":"paused"}.`);await log.flush();process.exit(ExitCode.Success)}catch(err){await log.error(`[${command}] failed: ${err instanceof Error?err.message:String(err)}`);process.exit(ExitCode.FatalError)}})}
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.36",
5
+ "version": "0.75.37",
6
6
  "description": "Meet Buddy. The Stacks runtime.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -95,66 +95,66 @@
95
95
  "prepublishOnly": "bun run build"
96
96
  },
97
97
  "dependencies": {
98
- "@stacksjs/actions": "^0.75.36",
99
- "@stacksjs/ai": "^0.75.36",
100
- "@stacksjs/alias": "^0.75.36",
101
- "@stacksjs/analytics": "^0.75.36",
102
- "@stacksjs/api": "^0.75.36",
103
- "@stacksjs/arrays": "^0.75.36",
104
- "@stacksjs/auth": "^0.75.36",
105
- "@stacksjs/browser-extension": "^0.75.36",
106
- "@stacksjs/build": "^0.75.36",
107
- "@stacksjs/cache": "^0.75.36",
108
- "@stacksjs/chat": "^0.75.36",
98
+ "@stacksjs/actions": "^0.75.37",
99
+ "@stacksjs/ai": "^0.75.37",
100
+ "@stacksjs/alias": "^0.75.37",
101
+ "@stacksjs/analytics": "^0.75.37",
102
+ "@stacksjs/api": "^0.75.37",
103
+ "@stacksjs/arrays": "^0.75.37",
104
+ "@stacksjs/auth": "^0.75.37",
105
+ "@stacksjs/browser-extension": "^0.75.37",
106
+ "@stacksjs/build": "^0.75.37",
107
+ "@stacksjs/cache": "^0.75.37",
108
+ "@stacksjs/chat": "^0.75.37",
109
109
  "@stacksjs/clapp": "^0.2.12",
110
- "@stacksjs/cli": "^0.75.36",
111
- "@stacksjs/cloud": "^0.75.36",
112
- "@stacksjs/cms": "^0.75.36",
113
- "@stacksjs/collections": "^0.75.36",
114
- "@stacksjs/config": "^0.75.36",
115
- "@stacksjs/database": "^0.75.36",
116
- "@stacksjs/desktop-build": "^0.75.36",
117
- "@stacksjs/dns": "^0.75.36",
110
+ "@stacksjs/cli": "^0.75.37",
111
+ "@stacksjs/cloud": "^0.75.37",
112
+ "@stacksjs/cms": "^0.75.37",
113
+ "@stacksjs/collections": "^0.75.37",
114
+ "@stacksjs/config": "^0.75.37",
115
+ "@stacksjs/database": "^0.75.37",
116
+ "@stacksjs/desktop-build": "^0.75.37",
117
+ "@stacksjs/dns": "^0.75.37",
118
118
  "@stacksjs/dnsx": "^0.2.3",
119
- "@stacksjs/email": "^0.75.36",
120
- "@stacksjs/enums": "^0.75.36",
121
- "@stacksjs/env": "^0.75.36",
122
- "@stacksjs/error-handling": "^0.75.36",
123
- "@stacksjs/events": "^0.75.36",
124
- "@stacksjs/features": "^0.75.36",
125
- "@stacksjs/git": "^0.75.36",
119
+ "@stacksjs/email": "^0.75.37",
120
+ "@stacksjs/enums": "^0.75.37",
121
+ "@stacksjs/env": "^0.75.37",
122
+ "@stacksjs/error-handling": "^0.75.37",
123
+ "@stacksjs/events": "^0.75.37",
124
+ "@stacksjs/features": "^0.75.37",
125
+ "@stacksjs/git": "^0.75.37",
126
126
  "@stacksjs/gitit": "^0.2.5",
127
- "@stacksjs/health": "^0.75.36",
127
+ "@stacksjs/health": "^0.75.37",
128
128
  "@stacksjs/httx": "^0.1.10",
129
- "@stacksjs/image": "^0.75.36",
130
- "@stacksjs/lint": "^0.75.36",
131
- "@stacksjs/logging": "^0.75.36",
132
- "@stacksjs/notifications": "^0.75.36",
133
- "@stacksjs/objects": "^0.75.36",
134
- "@stacksjs/orm": "^0.75.36",
135
- "@stacksjs/path": "^0.75.36",
136
- "@stacksjs/payments": "^0.75.36",
137
- "@stacksjs/realtime": "^0.75.36",
138
- "@stacksjs/router": "^0.75.36",
129
+ "@stacksjs/image": "^0.75.37",
130
+ "@stacksjs/lint": "^0.75.37",
131
+ "@stacksjs/logging": "^0.75.37",
132
+ "@stacksjs/notifications": "^0.75.37",
133
+ "@stacksjs/objects": "^0.75.37",
134
+ "@stacksjs/orm": "^0.75.37",
135
+ "@stacksjs/path": "^0.75.37",
136
+ "@stacksjs/payments": "^0.75.37",
137
+ "@stacksjs/realtime": "^0.75.37",
138
+ "@stacksjs/router": "^0.75.37",
139
139
  "@stacksjs/rpx": "^0.11.54",
140
- "@stacksjs/scheduler": "^0.75.36",
141
- "@stacksjs/search-engine": "^0.75.36",
142
- "@stacksjs/security": "^0.75.36",
143
- "@stacksjs/server": "^0.75.36",
144
- "@stacksjs/sites": "^0.75.36",
145
- "@stacksjs/skills": "^0.75.36",
146
- "@stacksjs/storage": "^0.75.36",
147
- "@stacksjs/strings": "^0.75.36",
140
+ "@stacksjs/scheduler": "^0.75.37",
141
+ "@stacksjs/search-engine": "^0.75.37",
142
+ "@stacksjs/security": "^0.75.37",
143
+ "@stacksjs/server": "^0.75.37",
144
+ "@stacksjs/sites": "^0.75.37",
145
+ "@stacksjs/skills": "^0.75.37",
146
+ "@stacksjs/storage": "^0.75.37",
147
+ "@stacksjs/strings": "^0.75.37",
148
148
  "@stacksjs/stx": "^0.2.343",
149
- "@stacksjs/testing": "^0.75.36",
150
- "@stacksjs/tinker": "^0.75.36",
149
+ "@stacksjs/testing": "^0.75.37",
150
+ "@stacksjs/tinker": "^0.75.37",
151
151
  "@stacksjs/tlsx": "^0.13.19",
152
152
  "@stacksjs/ts-cloud": "^0.16.15",
153
- "@stacksjs/tunnel": "^0.75.36",
154
- "@stacksjs/types": "^0.75.36",
155
- "@stacksjs/ui": "^0.75.36",
156
- "@stacksjs/utils": "^0.75.36",
157
- "@stacksjs/validation": "^0.75.36",
153
+ "@stacksjs/tunnel": "^0.75.37",
154
+ "@stacksjs/types": "^0.75.37",
155
+ "@stacksjs/ui": "^0.75.37",
156
+ "@stacksjs/utils": "^0.75.37",
157
+ "@stacksjs/validation": "^0.75.37",
158
158
  "ajv": "^8.20.0",
159
159
  "ajv-formats": "^3.0.1",
160
160
  "bun-plugin-stx": "^0.2.343",