@stacksjs/buddy 0.75.538 → 0.75.541
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/create.js +1 -1
- package/dist/commands/doctor.d.ts +0 -8
- package/dist/commands/doctor.js +1 -1
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.js +1 -1
- package/dist/commands/screenshot.d.ts +66 -0
- package/dist/commands/screenshot.js +1 -0
- package/dist/commands/tinker.js +1 -1
- package/dist/lazy-commands.js +1 -1
- package/dist/mail-users.d.ts +12 -1
- package/dist/production-server.js +1 -1
- package/dist/scaffold-git.d.ts +15 -0
- package/dist/scaffold-git.js +2 -0
- package/dist/scaffold-package-app.d.ts +21 -0
- package/dist/scaffold-package-app.js +2 -1
- package/dist/scaffold-site.d.ts +16 -0
- package/dist/scaffold-site.js +1 -1
- package/dist/stx-copies.d.ts +23 -0
- package/dist/stx-copies.js +1 -0
- package/package.json +58 -58
package/dist/commands/create.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{chmodSync,cpSync,existsSync,readFileSync,readdirSync,rmSync,writeFileSync}from"node:fs";import process from"node:process";import{runAction}from"@stacksjs/actions";import{bold,cyan,dim,intro,log,onUnknownSubcommand,runCommand}from"@stacksjs/cli";import{Action}from"@stacksjs/enums";import{isCompiledBinary,relative,resolve}from"@stacksjs/path";import{isFolder}from"@stacksjs/storage";import{ExitCode}from"@stacksjs/types";import{uninstallAllFeatures}from"./features";import{attemptPantryDependencies,optimizePantryDeps}from"./setup";import{resultFailed}from"../result";import{appIdentity,applyAppAgentsTemplate,applyAppChangelogTemplate,applyAppEnvTemplate,applyAppPackageTemplate,removeFrameworkLicense,renderTemplate}from"../scaffold-app";import{applyAppSiteTemplate}from"../scaffold-site";import{adoptPackagedDefaults,applyAppPackageScripts,applyPackageAppTsconfig,pruneFrameworkOnlyFiles,rewriteCoreContentPaths,stripFrameworkManifestCredits}from"../scaffold-package-app";import{fetchPublishedVersions}from"../registry";import{ensureAuthRoutesEnv}from"../minimal-routes";import{scaffoldDesktopApp}from"../scaffold-desktop";import{bunExecutable,failureReason,installScaffoldDependencies}from"../scaffold-dependencies";export function create(buddy){const descriptions={name:"The name of the project",command:"Create a new Stacks project",ui:"Are you building a UI?",components:"Are you building UI components?",webComponents:"Automagically built optimized custom elements/web components?",views:"How about views?",functions:"Are you developing functions/composables?",api:"Are you building an API?",database:"Do you need a database?",notifications:"Do you need notifications? e.g. email, SMS, push or chat notifications",cache:"Do you need caching?",email:"Do you need email?",project:"Target a specific project",minimal:"Skip optional feature bundles (cms, commerce, dashboard, marketing, monitoring, realtime, queue) - bare-bones API/SPA starter that can re-add them later via `./buddy <feature>:install`.",withCore:"Keep the framework vendored in `storage/framework/core` as a Bun workspace, for working ON Stacks. Apps that only work WITH Stacks want the default, which resolves every @stacksjs/* package from npm.",vendorDefaults:"Commit a copy of the framework defaults in `storage/framework/defaults` instead of linking it to node_modules/@stacksjs/defaults. Implied by --with-core.",verbose:"Enable verbose output"};buddy.command("new [name]",descriptions.command).alias("create").option("-n, --name [name]",descriptions.name,{default:false}).option("-u, --ui",descriptions.ui,{default:true}).option("-c, --components",descriptions.components,{default:true}).option("-w, --web-components",descriptions.webComponents,{default:true}).option("-p, --views",descriptions.views,{default:true}).option("-f, --functions",descriptions.functions,{default:true}).option("-a, --api",descriptions.api,{default:true}).option("-d, --database",descriptions.database,{default:true}).option("-ca, --cache",descriptions.cache,{default:false}).option("-e, --email",descriptions.email,{default:false}).option("-P, --project [project]",descriptions.project,{default:false}).option("-m, --minimal",descriptions.minimal,{default:false}).option("--native","Create a minimal offline Craft desktop app",{default:false}).option("--desktop","Also make it a native Mac app: stx screens drawn by AppKit, with the API running inside the app (config/desktop.ts, macos.agent)",{default:false}).option("--adopt","Integrate an existing native app without replacing its source (requires --native)",{default:false}).option("--with-core",descriptions.withCore,{default:false}).option("--vendor-defaults",descriptions.vendorDefaults,{default:false}).option("--no-provision","Install JavaScript dependencies without provisioning system packages").option("--verbose",descriptions.verbose,{default:false}).action(async(name,options)=>{log.debug("Running `buddy new <name>` ...",options);const startTime=await intro("buddy new");name=name??options.name;const path=resolve(process.cwd(),name??".");if(options.adopt&&!options.native)throw new Error("--adopt requires --native");if(options.desktop&&options.native)throw new Error("--desktop makes a Stacks app with a native Mac app; --native makes a standalone Craft app. Choose one.");if(options.native){const{scaffoldNativeProject}=await import("../native-project");const{version}=await import("../../package.json");const{latest}=await fetchPublishedVersions("@stacksjs/stx");if(!latest)throw new Error("The registry has no published stx version.");scaffoldNativeProject(path,{adopt:options.adopt,buddyVersion:version,stxVersion:latest});const installed=await runCommand(["bun","install"],{cwd:path});if(resultFailed(installed))throw installed.error;log.success(`Native app ready at ${path}. Run ./buddy dev to launch.`);await log.flush();return}isFolderCheck(path);await onlineCheck();const result=await download(name,path,options);if(resultFailed(result)){await log.error(result.error);process.exit(ExitCode.FatalError)}ensureExecutableScripts(path);applyAppVcsTemplate(path);applyAppConfigTemplate(path);applyAppEnv(path);applyAppPackage(path);applyAppReadme(path);applyAppAgents(path);replaceFrameworkSite(path);removeFrameworkTests(path);await generatePantryDeps(path);const missingSystemDependencies=await ensureEnv(path,options);if(options.minimal)await stripFeatures(path);await install(path,options);if(!options.withCore){trimFrameworkOnlyFiles(path);await unvendorCore(path,options,missingSystemDependencies!==null);applyPackageAppTsconfig(path);if(!options.vendorDefaults)linkFrameworkDefaults(path)}if(options.minimal||!options.withCore&&!options.vendorDefaults)await regenerateAutoImports(path,options);if(options.desktop){const written=scaffoldDesktopApp(path,appIdentity(path));log.success(`Added the Mac app (${written.join(", ")}). Run ${cyan("bun run dev:desktop")} to open it.`)}if(missingSystemDependencies!==null){log.warn(`The app is scaffolded at ${path}, but Pantry could not install its system dependencies: ${missingSystemDependencies}`);log.warn(`Finish with: ${cyan(`cd ${name??"."} && pantry install`)}`);log.warn(`Its JavaScript packages were installed with ${cyan("bun install")} instead, so everything else is ready.`);await log.flush();process.exit(ExitCode.FatalError)}if(startTime){const time=performance.now()-startTime;log.success(dim(`[${time.toFixed(2)}ms] Completed`))}log.info(bold("Welcome to the Stacks Framework! ⚛️"));log.info(`Get started: ${cyan(`cd ${name}`)} and then ${cyan("./buddy dev")}`);log.info(`Run ${cyan("./buddy doctor")} anytime to check your setup`);log.info("To learn more, visit https://stacksjs.com");await log.flush();process.exit(ExitCode.Success)});onUnknownSubcommand(buddy,"new")}export function scaffoldTargetOccupants(path){if(!isFolder(path))return[];return readdirSync(path).filter((entry)=>entry!==".git")}function isFolderCheck(path){if(scaffoldTargetOccupants(path).length===0)return;console.error(`Path ${path} already exists`);process.exit(ExitCode.FatalError)}async function onlineCheck(){const offline=await offlineReason();if(!offline)return;log.info(`It appears you are disconnected from the internet (github.com: ${offline}).`);log.info("Creating a new project requires a brief internet connection to download the template and install dependencies.");await log.flush();process.exit(ExitCode.FatalError)}export async function offlineReason(fetcher=fetch){try{await fetcher("https://github.com",{method:"HEAD",signal:AbortSignal.timeout(3000)});return null}catch(error){return error instanceof Error?error.message:String(error)}}export async function templateRef(fetchVersions=fetchPublishedVersions){try{const{latest}=await fetchVersions("stacks");return latest?`v${latest}`:null}catch{return null}}export function templateSpec(ref){return ref?`gh:stacksjs/stacks#${ref}`:"gh:stacksjs/stacks"}async function download(name,path,_options){log.info("Setting up your stack.");const ref=await templateRef();try{const{downloadTemplate}=await import("@stacksjs/gitit");try{await downloadTemplate(templateSpec(ref),{dir:name,force:true})}catch(error){if(!ref)throw error;log.warn(`No ${ref} tag to scaffold from (${error instanceof Error?error.message:String(error)}).`);log.info("Falling back to the default branch. If this app does not typecheck, that gap is why.");await downloadTemplate(templateSpec(null),{dir:name,force:true})}log.success(`Successfully scaffolded your project at ${cyan(path)}`);return{isErr:false}}catch(error){return{isErr:true,error:error instanceof Error?error.message:String(error)}}}function applyAppVcsTemplate(path){const source=resolve(path,"storage/framework/defaults/vcs/github");const destination=resolve(path,".github");if(!existsSync(source)){log.warn("No app CI template found at storage/framework/defaults/vcs/github - leaving .github as downloaded.");return}log.info("Installing app-shaped GitHub workflows...");try{rmSync(destination,{recursive:true,force:true});cpSync(source,destination,{recursive:true});log.success("App CI installed")}catch(error){log.warn(`Could not install the app CI template: ${error instanceof Error?error.message:String(error)}`)}}function applyAppConfigTemplate(path){const source=resolve(path,"storage/framework/defaults/scaffold/config");const destination=resolve(path,"config");if(!existsSync(source)){log.warn("No app config template found at storage/framework/defaults/scaffold/config - leaving config as downloaded.");return}const identity=appIdentity(path);log.info("Installing app-safe infrastructure configuration...");try{for(const file of readdirSync(source)){if(!file.endsWith(".ts"))continue;const template=readFileSync(resolve(source,file),"utf8");writeFileSync(resolve(destination,file),renderTemplate(template,identity))}log.success("App-safe infrastructure configuration installed")}catch(error){log.warn(`Could not install the app config template: ${error instanceof Error?error.message:String(error)}`)}}function applyAppEnv(path){try{const changed=applyAppEnvTemplate(path,appIdentity(path));if(changed.length>0)log.success(`Named the app in .env.example (${changed.join(", ")})`)}catch(error){log.warn(`Could not name the app in .env.example: ${error instanceof Error?error.message:String(error)}`)}}function applyAppPackage(path){try{const identity=appIdentity(path);const changed=applyAppPackageTemplate(path,identity);if(changed.length>0)log.success(`Named the app in package.json (${changed.join(", ")})`);if(applyAppChangelogTemplate(path,identity))log.success("Started the app its own CHANGELOG.md");if(removeFrameworkLicense(path))log.success("Removed the framework's LICENSE.md - choose the app's own licence")}catch(error){log.warn(`Could not name the app in package.json: ${error instanceof Error?error.message:String(error)}`)}}function applyAppAgents(path){try{if(applyAppAgentsTemplate(path))log.success("AGENTS.md no longer tells agents to publish as the framework's author")}catch(error){log.warn(`Could not update AGENTS.md: ${error instanceof Error?error.message:String(error)}`)}}function applyAppReadme(path){const source=resolve(path,"storage/framework/defaults/scaffold/README.md");if(!existsSync(source))return;try{writeFileSync(resolve(path,"README.md"),renderTemplate(readFileSync(source,"utf8"),appIdentity(path)))}catch(error){log.warn(`Could not write the app README: ${error instanceof Error?error.message:String(error)}`)}}function replaceFrameworkSite(path){log.info("Replacing the stacksjs.com site with a starter page...");try{const removed=applyAppSiteTemplate(path);log.success(`Starter page installed (${removed.length} stacksjs.com path${removed.length===1?"":"s"} removed)`)}catch(error){log.warn(`Could not install the starter page: ${error instanceof Error?error.message:String(error)}`)}}function removeFrameworkTests(path){const tests=resolve(path,"tests");if(!existsSync(tests))return;log.info("Removing the framework's own test suite...");for(const entry of readdirSync(tests)){if(entry==="setup.ts")continue;rmSync(resolve(tests,entry),{recursive:true,force:true})}log.success("App starts with a clean test suite")}function ensureExecutableScripts(path){for(const script of["buddy","bootstrap"]){try{chmodSync(resolve(path,script),493)}catch{}}}async function ensureEnv(path,options){log.info("Ensuring your environment is ready...");if(options.provision===false){const installed=await runCommand(["bun","install"],{cwd:path});if(resultFailed(installed))throw installed.error;log.success("JavaScript dependencies installed; system provisioning skipped");return null}const outcome=await installScaffoldDependencies({pantry:async()=>{const failure=await attemptPantryDependencies(path);return failure===null?null:failureReason(failure.error)},hasNodeModules:()=>existsSync(resolve(path,"node_modules")),bunInstall:async()=>{const bun=bunExecutable(Bun.which("bun"),process.execPath,isCompiledBinary());if(bun===null)return"Bun is not on PATH, and this buddy is a compiled binary, so it cannot run Bun itself.";log.info("Installing the JavaScript packages with Bun...");const result=await runCommand([bun,"install"],{cwd:path});return resultFailed(result)?failureReason(result.error):null}});if(outcome.status==="complete"){log.success("Environment is ready");return null}if(outcome.status==="system-dependencies-missing"){log.warn(`Pantry could not install the system dependencies (${outcome.pantryFailure}). Continuing with the JavaScript packages Bun installed.`);return outcome.pantryFailure}if(outcome.pantryFailure!==null)await log.error(`Pantry could not install the dependencies: ${outcome.pantryFailure}`);await log.error(`Bun could not install the JavaScript packages either: ${outcome.bunFailure}`);await log.error(`${path} is only partly scaffolded. Delete it and run \`buddy new\` again once the installers can reach their registries.`);process.exit(ExitCode.FatalError)}async function install(path,options){log.info("Installing & setting up Stacks");log.info("Copying .env.example → .env");let result=await runCommand("cp .env.example .env",{...options,cwd:path});if(resultFailed(result)){await log.error(result.error);process.exit(ExitCode.FatalError)}log.info("Removing template-encrypted env files...");const{rm}=await import("node:fs/promises");for(const stale of[".env.development",".env.staging",".env.production",".env.keys"])await rm(`${path}/${stale}`,{force:true});log.info("Generating application key...");const keyResult=await runAction(Action.KeyGenerate,{...options,cwd:path});if(resultFailed(keyResult)){await log.error(keyResult.error);process.exit(ExitCode.FatalError)}if(existsSync(resolve(path,".git"))){log.info("Existing git repository detected, skipping git init")}else{log.info("Initializing git repository...");result=await runCommand("git init",{...options,cwd:path});if(resultFailed(result)){await log.error(result.error);process.exit(ExitCode.FatalError)}}log.success("Installed & set-up \uD83D\uDE80")}async function unvendorCore(path,options,withBun){log.info("Resolving the framework from npm (pass --with-core to keep it vendored)...");const command=withBun?"./buddy unpublish:core --all --force --installer bun":"./buddy unpublish:core --all --force";const result=await runCommand(command,{...options,cwd:path});if(resultFailed(result)){const reason=result.error instanceof Error?result.error.stack??result.error.message:String(result.error??"").trim();log.error("Could not resolve the framework from npm.");log.error(reason.length>0?reason:"The step failed without reporting a reason.");log.error("");log.error(`The project at ${path} is half converted: the vendored framework has been`);log.error("removed and the published packages are not in place yet, so ./buddy cannot");log.error("boot there. Finish it by hand with:");log.error("");await log.error(` cd ${path} && rm -f node_modules/stacks && bun install`);await log.error("");await log.error("Or start over with `--with-core` to keep the framework vendored.");process.exit(ExitCode.FatalError)}log.success("Framework resolved from npm")}async function generatePantryDeps(path){try{if(await optimizePantryDeps(path))rmSync(resolve(path,"deps.yml"),{force:true})}catch(error){log.warn(`Could not generate deps.yaml from config/deps.ts, keeping the template's deps.yml: ${error instanceof Error?error.message:String(error)}`)}}function trimFrameworkOnlyFiles(path){try{const removed=pruneFrameworkOnlyFiles(path);const scripts=applyAppPackageScripts(path);rewriteCoreContentPaths(path);stripFrameworkManifestCredits(path);log.success(`Removed ${removed.length} framework-only path${removed.length===1?"":"s"} and ${scripts.removed.length} framework-only script${scripts.removed.length===1?"":"s"}`)}catch(error){log.warn(`Could not remove the framework-only files: ${error instanceof Error?error.message:String(error)}`)}}function linkFrameworkDefaults(path){log.info("Linking the framework defaults from node_modules (pass --vendor-defaults to commit a copy)...");try{const adopted=adoptPackagedDefaults(path);log.success(`storage/framework/defaults now links to ${relative(path,adopted.packageRoot)}`)}catch(error){log.warn(`Could not move the framework defaults to node_modules: ${error instanceof Error?error.message:String(error)}`)}}async function regenerateAutoImports(path,options){const result=await runCommand("./buddy generate --types",{...options,cwd:path});if(resultFailed(result))log.warn("Could not regenerate the auto-import barrels. Run `./buddy generate --types` in the project before `./buddy dev`.")}async function stripFeatures(path){log.info("Stripping optional feature bundles (--minimal)...");const results=await uninstallAllFeatures({root:path});const authEnv=ensureAuthRoutesEnv(path);if(authEnv.length>0)log.info(` - kept the auth routes mounted (STACKS_DEFAULT_ROUTES=auth in ${authEnv.join(", ")})`);let strippedAny=false;for(const{feature,configOutcome,filesRemoved}of results){if(configOutcome==="flipped"||filesRemoved.length>0){strippedAny=true;const fileSummary=filesRemoved.length>0?` (${filesRemoved.length} path${filesRemoved.length===1?"":"s"})`:"";log.info(` - ${feature}${fileSummary}`)}}if(!strippedAny)log.info(" → no feature scaffolding present; nothing to strip.");else log.success("Minimal skeleton ready - run `./buddy <feature>:install` to add features back.")}
|
|
1
|
+
import{chmodSync,cpSync,existsSync,readFileSync,readdirSync,rmSync,writeFileSync}from"node:fs";import process from"node:process";import{runAction}from"@stacksjs/actions";import{bold,cyan,dim,intro,log,onUnknownSubcommand,runCommand}from"@stacksjs/cli";import{Action}from"@stacksjs/enums";import{isCompiledBinary,relative,resolve}from"@stacksjs/path";import{isFolder}from"@stacksjs/storage";import{ExitCode}from"@stacksjs/types";import{uninstallAllFeatures}from"./features";import{attemptPantryDependencies,optimizePantryDeps}from"./setup";import{resultFailed}from"../result";import{appIdentity,applyAppAgentsTemplate,applyAppChangelogTemplate,applyAppEnvTemplate,applyAppPackageTemplate,removeFrameworkLicense,renderTemplate}from"../scaffold-app";import{applyAppSiteTemplate}from"../scaffold-site";import{adoptPackagedDefaults,applyAppPackageOverrides,applyAppPackageScripts,applyPackageAppTsconfig,pruneFrameworkOnlyFiles,rewriteCoreContentPaths,stripFrameworkManifestCredits}from"../scaffold-package-app";import{fetchPublishedVersions}from"../registry";import{ensureAuthRoutesEnv}from"../minimal-routes";import{scaffoldDesktopApp}from"../scaffold-desktop";import{commitScaffold}from"../scaffold-git";import{bunExecutable,failureReason,installScaffoldDependencies}from"../scaffold-dependencies";export function create(buddy){const descriptions={name:"The name of the project",command:"Create a new Stacks project",minimal:"Skip optional feature bundles (cms, commerce, dashboard, marketing, monitoring, realtime, queue) - bare-bones API/SPA starter that can re-add them later via `./buddy <feature>:install`.",withCore:"Keep the framework vendored in `storage/framework/core` as a Bun workspace, for working ON Stacks. Apps that only work WITH Stacks want the default, which resolves every @stacksjs/* package from npm.",vendorDefaults:"Commit a copy of the framework defaults in `storage/framework/defaults` instead of linking it to node_modules/@stacksjs/defaults. Implied by --with-core.",verbose:"Enable verbose output"};buddy.command("new [name]",descriptions.command).alias("create").option("-n, --name [name]",descriptions.name,{default:false}).option("-m, --minimal",descriptions.minimal,{default:false}).option("--native","Create a minimal offline Craft desktop app",{default:false}).option("--desktop","Also make it a native Mac app: stx screens drawn by AppKit, with the API running inside the app (config/desktop.ts, macos.agent)",{default:false}).option("--adopt","Integrate an existing native app without replacing its source (requires --native)",{default:false}).option("--with-core",descriptions.withCore,{default:false}).option("--vendor-defaults",descriptions.vendorDefaults,{default:false}).option("--no-provision","Install JavaScript dependencies without provisioning system packages").option("--verbose",descriptions.verbose,{default:false}).action(async(name,options)=>{log.debug("Running `buddy new <name>` ...",options);const startTime=await intro("buddy new");name=name??options.name;const path=resolve(process.cwd(),name??".");if(options.adopt&&!options.native)throw new Error("--adopt requires --native");if(options.desktop&&options.native)throw new Error("--desktop makes a Stacks app with a native Mac app; --native makes a standalone Craft app. Choose one.");if(options.native){const{scaffoldNativeProject}=await import("../native-project");const{version}=await import("../../package.json");const{latest}=await fetchPublishedVersions("@stacksjs/stx");if(!latest)throw new Error("The registry has no published stx version.");scaffoldNativeProject(path,{adopt:options.adopt,buddyVersion:version,stxVersion:latest});const installed=await runCommand(["bun","install"],{cwd:path});if(resultFailed(installed))throw installed.error;log.success(`Native app ready at ${path}. Run ./buddy dev to launch.`);await log.flush();return}isFolderCheck(path);await onlineCheck();const result=await download(name,path,options);if(resultFailed(result)){await log.error(result.error);process.exit(ExitCode.FatalError)}ensureExecutableScripts(path);applyAppVcsTemplate(path);applyAppConfigTemplate(path);applyAppEnv(path);applyAppPackage(path);applyAppReadme(path);applyAppAgents(path);replaceFrameworkSite(path);removeFrameworkTests(path);await generatePantryDeps(path);const missingSystemDependencies=await ensureEnv(path,options);if(options.minimal)await stripFeatures(path);const createdRepository=await install(path,options);if(!options.withCore){trimFrameworkOnlyFiles(path);await unvendorCore(path,options,missingSystemDependencies!==null);applyPackageAppTsconfig(path);if(!options.vendorDefaults)linkFrameworkDefaults(path)}if(options.minimal||!options.withCore&&!options.vendorDefaults)await regenerateAutoImports(path,options);if(options.desktop){const written=scaffoldDesktopApp(path,appIdentity(path));log.success(`Added the Mac app (${written.join(", ")}). Run ${cyan("bun run dev:desktop")} to open it.`)}if(createdRepository)recordScaffold(path);if(missingSystemDependencies!==null){log.warn(`The app is scaffolded at ${path}, but Pantry could not install its system dependencies: ${missingSystemDependencies}`);log.warn(`Finish with: ${cyan(`cd ${name??"."} && pantry install`)}`);log.warn(`Its JavaScript packages were installed with ${cyan("bun install")} instead, so everything else is ready.`);await log.flush();process.exit(ExitCode.FatalError)}if(startTime){const time=performance.now()-startTime;log.success(dim(`[${time.toFixed(2)}ms] Completed`))}log.info(bold("Welcome to the Stacks Framework! ⚛️"));log.info(`Get started: ${cyan(`cd ${name}`)} and then ${cyan("./buddy dev")}`);log.info(`Run ${cyan("./buddy doctor")} anytime to check your setup`);log.info("To learn more, visit https://stacksjs.com");await log.flush();process.exit(ExitCode.Success)});onUnknownSubcommand(buddy,"new")}export function scaffoldTargetOccupants(path){if(!isFolder(path))return[];return readdirSync(path).filter((entry)=>entry!==".git")}function isFolderCheck(path){if(scaffoldTargetOccupants(path).length===0)return;console.error(`Path ${path} already exists`);process.exit(ExitCode.FatalError)}async function onlineCheck(){const offline=await offlineReason();if(!offline)return;log.info(`It appears you are disconnected from the internet (github.com: ${offline}).`);log.info("Creating a new project requires a brief internet connection to download the template and install dependencies.");await log.flush();process.exit(ExitCode.FatalError)}export async function offlineReason(fetcher=fetch){try{await fetcher("https://github.com",{method:"HEAD",signal:AbortSignal.timeout(3000)});return null}catch(error){return error instanceof Error?error.message:String(error)}}export async function templateRef(fetchVersions=fetchPublishedVersions){try{const{latest}=await fetchVersions("stacks");return latest?`v${latest}`:null}catch{return null}}export function templateSpec(ref){return ref?`gh:stacksjs/stacks#${ref}`:"gh:stacksjs/stacks"}async function download(name,path,_options){log.info("Setting up your stack.");const ref=await templateRef();try{const{downloadTemplate}=await import("@stacksjs/gitit");try{await downloadTemplate(templateSpec(ref),{dir:name,force:true})}catch(error){if(!ref)throw error;log.warn(`No ${ref} tag to scaffold from (${error instanceof Error?error.message:String(error)}).`);log.info("Falling back to the default branch. If this app does not typecheck, that gap is why.");await downloadTemplate(templateSpec(null),{dir:name,force:true})}log.success(`Successfully scaffolded your project at ${cyan(path)}`);return{isErr:false}}catch(error){return{isErr:true,error:error instanceof Error?error.message:String(error)}}}function applyAppVcsTemplate(path){const source=resolve(path,"storage/framework/defaults/vcs/github");const destination=resolve(path,".github");if(!existsSync(source)){log.warn("No app CI template found at storage/framework/defaults/vcs/github - leaving .github as downloaded.");return}log.info("Installing app-shaped GitHub workflows...");try{rmSync(destination,{recursive:true,force:true});cpSync(source,destination,{recursive:true});log.success("App CI installed")}catch(error){log.warn(`Could not install the app CI template: ${error instanceof Error?error.message:String(error)}`)}}function applyAppConfigTemplate(path){const source=resolve(path,"storage/framework/defaults/scaffold/config");const destination=resolve(path,"config");if(!existsSync(source)){log.warn("No app config template found at storage/framework/defaults/scaffold/config - leaving config as downloaded.");return}const identity=appIdentity(path);log.info("Installing app-safe infrastructure configuration...");try{for(const file of readdirSync(source)){if(!file.endsWith(".ts"))continue;const template=readFileSync(resolve(source,file),"utf8");writeFileSync(resolve(destination,file),renderTemplate(template,identity))}log.success("App-safe infrastructure configuration installed")}catch(error){log.warn(`Could not install the app config template: ${error instanceof Error?error.message:String(error)}`)}}function applyAppEnv(path){try{const changed=applyAppEnvTemplate(path,appIdentity(path));if(changed.length>0)log.success(`Named the app in .env.example (${changed.join(", ")})`)}catch(error){log.warn(`Could not name the app in .env.example: ${error instanceof Error?error.message:String(error)}`)}}function applyAppPackage(path){try{const identity=appIdentity(path);const changed=applyAppPackageTemplate(path,identity);if(changed.length>0)log.success(`Named the app in package.json (${changed.join(", ")})`);if(applyAppChangelogTemplate(path,identity))log.success("Started the app its own CHANGELOG.md");if(removeFrameworkLicense(path))log.success("Removed the framework's LICENSE.md - choose the app's own licence")}catch(error){log.warn(`Could not name the app in package.json: ${error instanceof Error?error.message:String(error)}`)}}function applyAppAgents(path){try{if(applyAppAgentsTemplate(path))log.success("AGENTS.md no longer tells agents to publish as the framework's author")}catch(error){log.warn(`Could not update AGENTS.md: ${error instanceof Error?error.message:String(error)}`)}}function applyAppReadme(path){const source=resolve(path,"storage/framework/defaults/scaffold/README.md");if(!existsSync(source))return;try{writeFileSync(resolve(path,"README.md"),renderTemplate(readFileSync(source,"utf8"),appIdentity(path)))}catch(error){log.warn(`Could not write the app README: ${error instanceof Error?error.message:String(error)}`)}}function replaceFrameworkSite(path){log.info("Replacing the stacksjs.com site with a starter page...");try{const removed=applyAppSiteTemplate(path);log.success(`Starter page installed (${removed.length} stacksjs.com path${removed.length===1?"":"s"} removed)`)}catch(error){log.warn(`Could not install the starter page: ${error instanceof Error?error.message:String(error)}`)}}function removeFrameworkTests(path){const tests=resolve(path,"tests");if(!existsSync(tests))return;log.info("Removing the framework's own test suite...");for(const entry of readdirSync(tests)){if(entry==="setup.ts")continue;rmSync(resolve(tests,entry),{recursive:true,force:true})}log.success("App starts with a clean test suite")}function recordScaffold(path){const reason=commitScaffold(path,appIdentity(path).displayName);if(reason===null)log.success("Committed the generated app");else log.warn(`Left the generated app uncommitted (${reason}). Make the first commit yourself.`)}function ensureExecutableScripts(path){for(const script of["buddy","bootstrap"]){try{chmodSync(resolve(path,script),493)}catch{}}}async function ensureEnv(path,options){log.info("Ensuring your environment is ready...");if(options.provision===false){const installed=await runCommand(["bun","install"],{cwd:path});if(resultFailed(installed))throw installed.error;log.success("JavaScript dependencies installed; system provisioning skipped");return null}const outcome=await installScaffoldDependencies({pantry:async()=>{const failure=await attemptPantryDependencies(path);return failure===null?null:failureReason(failure.error)},hasNodeModules:()=>existsSync(resolve(path,"node_modules")),bunInstall:async()=>{const bun=bunExecutable(Bun.which("bun"),process.execPath,isCompiledBinary());if(bun===null)return"Bun is not on PATH, and this buddy is a compiled binary, so it cannot run Bun itself.";log.info("Installing the JavaScript packages with Bun...");const result=await runCommand([bun,"install"],{cwd:path});return resultFailed(result)?failureReason(result.error):null}});if(outcome.status==="complete"){log.success("Environment is ready");return null}if(outcome.status==="system-dependencies-missing"){log.warn(`Pantry could not install the system dependencies (${outcome.pantryFailure}). Continuing with the JavaScript packages Bun installed.`);return outcome.pantryFailure}if(outcome.pantryFailure!==null)await log.error(`Pantry could not install the dependencies: ${outcome.pantryFailure}`);await log.error(`Bun could not install the JavaScript packages either: ${outcome.bunFailure}`);await log.error(`${path} is only partly scaffolded. Delete it and run \`buddy new\` again once the installers can reach their registries.`);process.exit(ExitCode.FatalError)}async function install(path,options){log.info("Installing & setting up Stacks");log.info("Copying .env.example → .env");let result=await runCommand("cp .env.example .env",{...options,cwd:path});if(resultFailed(result)){await log.error(result.error);process.exit(ExitCode.FatalError)}log.info("Removing template-encrypted env files...");const{rm}=await import("node:fs/promises");for(const stale of[".env.development",".env.staging",".env.production",".env.keys"])await rm(`${path}/${stale}`,{force:true});log.info("Generating application key...");const keyResult=await runAction(Action.KeyGenerate,{...options,cwd:path});if(resultFailed(keyResult)){await log.error(keyResult.error);process.exit(ExitCode.FatalError)}const createdRepository=!existsSync(resolve(path,".git"));if(!createdRepository){log.info("Existing git repository detected, skipping git init")}else{log.info("Initializing git repository...");result=await runCommand("git init",{...options,cwd:path});if(resultFailed(result)){await log.error(result.error);process.exit(ExitCode.FatalError)}}log.success("Installed & set-up \uD83D\uDE80");return createdRepository}async function unvendorCore(path,options,withBun){log.info("Resolving the framework from npm (pass --with-core to keep it vendored)...");const command=withBun?"./buddy unpublish:core --all --force --installer bun":"./buddy unpublish:core --all --force";const result=await runCommand(command,{...options,cwd:path});if(resultFailed(result)){const reason=result.error instanceof Error?result.error.stack??result.error.message:String(result.error??"").trim();log.error("Could not resolve the framework from npm.");log.error(reason.length>0?reason:"The step failed without reporting a reason.");log.error("");log.error(`The project at ${path} is half converted: the vendored framework has been`);log.error("removed and the published packages are not in place yet, so ./buddy cannot");log.error("boot there. Finish it by hand with:");log.error("");await log.error(` cd ${path} && rm -f node_modules/stacks && bun install`);await log.error("");await log.error("Or start over with `--with-core` to keep the framework vendored.");process.exit(ExitCode.FatalError)}log.success("Framework resolved from npm")}async function generatePantryDeps(path){try{if(await optimizePantryDeps(path))rmSync(resolve(path,"deps.yml"),{force:true})}catch(error){log.warn(`Could not generate deps.yaml from config/deps.ts, keeping the template's deps.yml: ${error instanceof Error?error.message:String(error)}`)}}function trimFrameworkOnlyFiles(path){try{const removed=pruneFrameworkOnlyFiles(path);const scripts=applyAppPackageScripts(path);applyAppPackageOverrides(path);rewriteCoreContentPaths(path);stripFrameworkManifestCredits(path);log.success(`Removed ${removed.length} framework-only path${removed.length===1?"":"s"} and ${scripts.removed.length} framework-only script${scripts.removed.length===1?"":"s"}`)}catch(error){log.warn(`Could not remove the framework-only files: ${error instanceof Error?error.message:String(error)}`)}}function linkFrameworkDefaults(path){log.info("Linking the framework defaults from node_modules (pass --vendor-defaults to commit a copy)...");try{const adopted=adoptPackagedDefaults(path);log.success(`storage/framework/defaults now links to ${relative(path,adopted.packageRoot)}`)}catch(error){log.warn(`Could not move the framework defaults to node_modules: ${error instanceof Error?error.message:String(error)}`)}}async function regenerateAutoImports(path,options){const result=await runCommand("./buddy generate --types",{...options,cwd:path});if(resultFailed(result))log.warn("Could not regenerate the auto-import barrels. Run `./buddy generate --types` in the project before `./buddy dev`.")}async function stripFeatures(path){log.info("Stripping optional feature bundles (--minimal)...");const results=await uninstallAllFeatures({root:path});const authEnv=ensureAuthRoutesEnv(path);if(authEnv.length>0)log.info(` - kept the auth routes mounted (STACKS_DEFAULT_ROUTES=auth in ${authEnv.join(", ")})`);let strippedAny=false;for(const{feature,configOutcome,filesRemoved}of results){if(configOutcome==="flipped"||filesRemoved.length>0){strippedAny=true;const fileSummary=filesRemoved.length>0?` (${filesRemoved.length} path${filesRemoved.length===1?"":"s"})`:"";log.info(` - ${feature}${fileSummary}`)}}if(!strippedAny)log.info(" → no feature scaffolding present; nothing to strip.");else log.success("Minimal skeleton ready - run `./buddy <feature>:install` to add features back.")}
|
|
@@ -1,10 +1,2 @@
|
|
|
1
1
|
import type { CLI } from '@stacksjs/types';
|
|
2
2
|
export declare function doctor(buddy: CLI): void;
|
|
3
|
-
/**
|
|
4
|
-
* Throw inside a probe fn to record a warning instead of a failure.
|
|
5
|
-
* Used when a check cannot run to completion (e.g. the driver exposes
|
|
6
|
-
* no raw query method, so there is nothing to probe with) or when the
|
|
7
|
-
* finding is advisory rather than fatal (e.g. a busy dev port).
|
|
8
|
-
*/
|
|
9
|
-
declare class ProbeWarning extends Error {}
|
|
10
|
-
export {};
|
package/dist/commands/doctor.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{existsSync,lstatSync,readFileSync,readlinkSync}from"node:fs";import{resolve}from"node:path";import process from"node:process";import{bold,dim,green,intro,log,onUnknownSubcommand,red,yellow}from"@stacksjs/cli";import{feature}from"@stacksjs/config";import{inspectDefaultsProvenance,installedDefaultsVersion,path,usesVendoredDefaults}from"@stacksjs/path";import{storage}from"@stacksjs/storage";import{isSupportedBunVersion,isVersionGreaterThanOrEqual,minimumBunVersion}from"@stacksjs/utils";import{FEATURE_NAMES,featurePathsPresent}from"./features";const minimumSqliteVersion="3.47.2";class ProbeWarning extends Error{}async function probe(checks,name,fn,timeoutMs=2000){const start=Date.now();const ac=new AbortController;const timer=setTimeout(()=>ac.abort(),timeoutMs);try{const message=await Promise.race([fn(),new Promise((_,rej)=>ac.signal.addEventListener("abort",()=>rej(new Error(`timed out (>${Math.round(timeoutMs/1000)}s)`))))]);checks.push({name,status:"pass",message:`${message} (${Date.now()-start}ms)`})}catch(err){checks.push({name,status:err instanceof ProbeWarning?"warn":"fail",message:err instanceof Error?err.message:String(err)})}finally{clearTimeout(timer)}}async function mailDnsChecks(){const{hasExplicitEmailConfig,declaredDnsProvider,loadTsCloudConfig}=await import("./deploy");if(!hasExplicitEmailConfig())return[{name:"Mail DNS",status:"pass",message:"No config/email.ts (skipped)"}];const{email}=await import("@stacksjs/config");const cfg=email??{};if(cfg.server?.enabled!==true)return[{name:"Mail DNS",status:"pass",message:"email.server.enabled is off (skipped)"}];const{describeMailDnsProvider,describeMailDnsRecords,describePostmaster,gatherMailDnsFacts,mailDomainFromConfig}=await import("../mail-dns-health");const{envFileForEnvironment,envFileKeys}=await import("../dns-credentials");const domain=mailDomainFromConfig(cfg);if(!domain)return[{name:"Mail DNS",status:"warn",message:"email.server.enabled is on but config/email.ts names no domain (set `domain` or a from-address)"}];const fs=await import("node:fs");const envFile=envFileForEnvironment("production");const envPath=resolve(process.cwd(),envFile);const fileKeys=fs.existsSync(envPath)?envFileKeys(fs.readFileSync(envPath,"utf8")):new Set;const dkimSelector="mail";const[declared,facts]=await Promise.all([loadTsCloudConfig("production").then(declaredDnsProvider).catch(()=>{return}),gatherMailDnsFacts(domain,dkimSelector)]);return[{name:"Mail DNS provider",...describeMailDnsProvider({domain,zone:facts.zone,nameservers:facts.nameservers,declared,fileKeys,envFile})},{name:"Mail DNS records",...describeMailDnsRecords({domain,records:facts.records,dkimSelector,dmarcPolicy:cfg.server?.dmarc?.policy,mxAddresses:facts.mxAddresses})},{name:"Postmaster Tools",...describePostmaster(domain,cfg.server?.postmaster,facts.records.filter((record)=>record.type==="TXT"&&record.name===domain).map((record)=>record.content))}]}export function doctor(buddy){buddy.command("doctor","Run health checks on your Stacks installation").option("--no-fail","Print results but always exit 0 (CI ramp-up)").action(async(options)=>{log.debug("Running `buddy doctor` ...");await intro("buddy doctor");const checks=[];const modulesPath=resolve(process.cwd(),"node_modules");try{if(lstatSync(modulesPath).isSymbolicLink()){const target=resolve(process.cwd(),readlinkSync(modulesPath));const insideProject=target.startsWith(`${resolve(process.cwd())}/`);checks.push({name:"Dependency tree",status:insideProject?"warn":"fail",message:insideProject?`node_modules is a symlink to ${target}`:`node_modules is a symlink to ${target}, which belongs to another project - installs here mutate it, and what runs locally is not what the lockfile resolves. Remove the link and run \`bun install\`.`})}else{checks.push({name:"Dependency tree",status:"pass",message:"node_modules is this project's own"})}}catch{checks.push({name:"Dependency tree",status:"warn",message:"node_modules is missing - run `bun install`"})}const depsPath=resolve(process.cwd(),"config/deps.ts");if(existsSync(depsPath)){const{describeSystemDependencies}=await import("../system-dependencies");checks.push({name:"System dependencies",...describeSystemDependencies(readFileSync(depsPath,"utf8"))})}await probe(checks,"Framework defaults",async()=>{const{measureDefaultsDrift,summarizeStructureChanges}=await import("@stacksjs/actions");const root=resolve(process.cwd());const skew=inspectDefaultsProvenance(root);if(skew.status==="not-applicable"){if(!usesVendoredDefaults(root)&&installedDefaultsVersion(root))return`Runs @stacksjs/defaults ${installedDefaultsVersion(root)} from node_modules (not vendored)`;return"Not a package-managed project (nothing to compare)"}const drift=measureDefaultsDrift(root)??[];const synced=skew.syncedAt?`, synced ${skew.syncedAt.slice(0,10)}`:"";if(drift.length===0)return`Vendored tree matches @stacksjs/defaults ${skew.installed}${synced}. \`buddy unpublish:defaults\` drops the copy from the repository and runs the package instead`;const counts=summarizeStructureChanges(drift);if(skew.status==="stale"){throw new ProbeWarning(`storage/framework/defaults is from ${skew.vendored} while @stacksjs/defaults ${skew.installed} is installed (${counts}). Boot resolves the package, so the tree on disk is not what runs. Run \`buddy upgrade\` to sync it.`)}throw new ProbeWarning(`storage/framework/defaults differs from the installed @stacksjs/defaults ${skew.installed} (${counts}), and carries no record of what it was synced from. The app runs the vendored copy. Run \`buddy upgrade\` to sync it.`)},8000);await probe(checks,"Route actions",async()=>{const{describeDanglingRouteActions,findDanglingRouteActions}=await import("@stacksjs/actions");const dangling=findDanglingRouteActions(resolve(process.cwd()));if(dangling.length===0)return"Every action a route names exists";throw new ProbeWarning(`${describeDanglingRouteActions(dangling).split(`
|
|
1
|
+
import{existsSync,lstatSync,readFileSync,readlinkSync}from"node:fs";import{resolve}from"node:path";import process from"node:process";import{bold,dim,green,intro,log,onUnknownSubcommand,red,yellow}from"@stacksjs/cli";import{feature}from"@stacksjs/config";import{inspectDefaultsProvenance,installedDefaultsVersion,path,usesVendoredDefaults}from"@stacksjs/path";import{storage}from"@stacksjs/storage";import{isSupportedBunVersion,isVersionGreaterThanOrEqual,minimumBunVersion}from"@stacksjs/utils";import{FEATURE_NAMES,featurePathsPresent}from"./features";const minimumSqliteVersion="3.47.2";class ProbeWarning extends Error{}async function probe(checks,name,fn,timeoutMs=2000){const start=Date.now();const ac=new AbortController;const timer=setTimeout(()=>ac.abort(),timeoutMs);try{const message=await Promise.race([fn(),new Promise((_,rej)=>ac.signal.addEventListener("abort",()=>rej(new Error(`timed out (>${Math.round(timeoutMs/1000)}s)`))))]);checks.push({name,status:"pass",message:`${message} (${Date.now()-start}ms)`})}catch(err){checks.push({name,status:err instanceof ProbeWarning?"warn":"fail",message:err instanceof Error?err.message:String(err)})}finally{clearTimeout(timer)}}async function mailDnsChecks(){const{hasExplicitEmailConfig,declaredDnsProvider,loadTsCloudConfig}=await import("./deploy");if(!hasExplicitEmailConfig())return[{name:"Mail DNS",status:"pass",message:"No config/email.ts (skipped)"}];const{email}=await import("@stacksjs/config");const cfg=email??{};if(cfg.server?.enabled!==true)return[{name:"Mail DNS",status:"pass",message:"email.server.enabled is off (skipped)"}];const{describeMailDnsProvider,describeMailDnsRecords,describePostmaster,gatherMailDnsFacts,mailDomainFromConfig}=await import("../mail-dns-health");const{envFileForEnvironment,envFileKeys}=await import("../dns-credentials");const domain=mailDomainFromConfig(cfg);if(!domain)return[{name:"Mail DNS",status:"warn",message:"email.server.enabled is on but config/email.ts names no domain (set `domain` or a from-address)"}];const fs=await import("node:fs");const envFile=envFileForEnvironment("production");const envPath=resolve(process.cwd(),envFile);const fileKeys=fs.existsSync(envPath)?envFileKeys(fs.readFileSync(envPath,"utf8")):new Set;const dkimSelector="mail";const[declared,facts]=await Promise.all([loadTsCloudConfig("production").then(declaredDnsProvider).catch(()=>{return}),gatherMailDnsFacts(domain,dkimSelector)]);return[{name:"Mail DNS provider",...describeMailDnsProvider({domain,zone:facts.zone,nameservers:facts.nameservers,declared,fileKeys,envFile})},{name:"Mail DNS records",...describeMailDnsRecords({domain,records:facts.records,dkimSelector,dmarcPolicy:cfg.server?.dmarc?.policy,mxAddresses:facts.mxAddresses})},{name:"Postmaster Tools",...describePostmaster(domain,cfg.server?.postmaster,facts.records.filter((record)=>record.type==="TXT"&&record.name===domain).map((record)=>record.content))}]}export function doctor(buddy){buddy.command("doctor","Run health checks on your Stacks installation").option("--no-fail","Print results but always exit 0 (CI ramp-up)").action(async(options)=>{log.debug("Running `buddy doctor` ...");await intro("buddy doctor");const checks=[];const modulesPath=resolve(process.cwd(),"node_modules");try{if(lstatSync(modulesPath).isSymbolicLink()){const target=resolve(process.cwd(),readlinkSync(modulesPath));const insideProject=target.startsWith(`${resolve(process.cwd())}/`);checks.push({name:"Dependency tree",status:insideProject?"warn":"fail",message:insideProject?`node_modules is a symlink to ${target}`:`node_modules is a symlink to ${target}, which belongs to another project - installs here mutate it, and what runs locally is not what the lockfile resolves. Remove the link and run \`bun install\`.`})}else{checks.push({name:"Dependency tree",status:"pass",message:"node_modules is this project's own"})}}catch{checks.push({name:"Dependency tree",status:"warn",message:"node_modules is missing - run `bun install`"})}{const{describeStxCopies,findStxCopies}=await import("../stx-copies");const report=describeStxCopies(findStxCopies(resolve(process.cwd())));if(report)checks.push({name:"STX packages",...report})}const depsPath=resolve(process.cwd(),"config/deps.ts");if(existsSync(depsPath)){const{describeSystemDependencies}=await import("../system-dependencies");checks.push({name:"System dependencies",...describeSystemDependencies(readFileSync(depsPath,"utf8"))})}await probe(checks,"Framework defaults",async()=>{const{measureDefaultsDrift,summarizeStructureChanges}=await import("@stacksjs/actions");const root=resolve(process.cwd());const skew=inspectDefaultsProvenance(root);if(skew.status==="not-applicable"){if(!usesVendoredDefaults(root)&&installedDefaultsVersion(root))return`Runs @stacksjs/defaults ${installedDefaultsVersion(root)} from node_modules (not vendored)`;return"Not a package-managed project (nothing to compare)"}const drift=measureDefaultsDrift(root)??[];const synced=skew.syncedAt?`, synced ${skew.syncedAt.slice(0,10)}`:"";if(drift.length===0)return`Vendored tree matches @stacksjs/defaults ${skew.installed}${synced}. \`buddy unpublish:defaults\` drops the copy from the repository and runs the package instead`;const counts=summarizeStructureChanges(drift);if(skew.status==="stale"){throw new ProbeWarning(`storage/framework/defaults is from ${skew.vendored} while @stacksjs/defaults ${skew.installed} is installed (${counts}). Boot resolves the package, so the tree on disk is not what runs. Run \`buddy upgrade\` to sync it.`)}throw new ProbeWarning(`storage/framework/defaults differs from the installed @stacksjs/defaults ${skew.installed} (${counts}), and carries no record of what it was synced from. The app runs the vendored copy. Run \`buddy upgrade\` to sync it.`)},8000);await probe(checks,"Route actions",async()=>{const{describeDanglingRouteActions,findDanglingRouteActions}=await import("@stacksjs/actions");const dangling=findDanglingRouteActions(resolve(process.cwd()));if(dangling.length===0)return"Every action a route names exists";throw new ProbeWarning(`${describeDanglingRouteActions(dangling).split(`
|
|
2
2
|
`).join("; ")}. Point each route at an action that exists, or delete it. \`buddy upgrade\` removes the ones the scaffold wrote.`)});await probe(checks,"Security overrides",async()=>{const{findShadowedSecurityDefaults,frameworkDefaultsDir,SHADOWED_DEFAULT_REVIEW_MARKER}=await import("@stacksjs/server");const defaultsDir=frameworkDefaultsDir("app");if(!defaultsDir)return"No framework defaults to compare against";const shadowed=findShadowedSecurityDefaults(path.appPath(),defaultsDir);if(shadowed.length===0)return"No app/ file shadows a framework security default";const identical=shadowed.filter((entry)=>entry.kind==="identical").map((entry)=>`app/${entry.path}`);const modified=shadowed.filter((entry)=>entry.kind==="modified").map((entry)=>`app/${entry.path} (${SHADOWED_DEFAULT_REVIEW_MARKER} ${entry.fingerprint})`);throw new ProbeWarning([identical.length?`Unchanged copies, delete to receive security fixes: ${identical.join(", ")}.`:"",modified.length?`Differ from the current default, review and mark reviewed: ${modified.join(", ")}.`:""].filter(Boolean).join(" "))});const bunVersion=process.versions.bun;if(bunVersion&&isSupportedBunVersion(bunVersion)){checks.push({name:"Bun Runtime",status:"pass",message:`v${bunVersion}`})}else if(bunVersion){checks.push({name:"Bun Runtime",status:"fail",message:`v${bunVersion} (requires v${minimumBunVersion} or later, run: bun upgrade)`})}else{checks.push({name:"Bun Runtime",status:"fail",message:"Not found"})}try{const pinnedBun=(await storage.readPackageJson("./package.json")).engines?.bun;if(pinnedBun&&bunVersion&&bunVersion!==pinnedBun){checks.push({name:"Pinned Bun",status:"warn",message:`v${bunVersion} is not the pinned v${pinnedBun} (engines.bun). Installing rewrites bun.lock - use \`./pantry/.bin/bun install\`, the pinned toolchain this checkout already carries, and \`git checkout -- bun.lock\` if it already changed.`})}else if(pinnedBun&&bunVersion){checks.push({name:"Pinned Bun",status:"pass",message:`v${bunVersion} matches engines.bun`})}}catch{}const nodeVersion=process.versions.node;if(nodeVersion){const nodeMajor=Number.parseInt(nodeVersion.split(".")[0]||"0",10);if(nodeMajor>=18){checks.push({name:"Node.js",status:"pass",message:`v${nodeVersion}`})}else{checks.push({name:"Node.js",status:"warn",message:`v${nodeVersion} (v18+ recommended)`})}}try{const pkg=await storage.readPackageJson("./package.json");if(pkg.name){checks.push({name:"package.json",status:"pass",message:`Found: ${pkg.name}`})}}catch{checks.push({name:"package.json",status:"fail",message:"Not found in current directory"})}try{await storage.readTextFile(".env");checks.push({name:".env file",status:"pass",message:"Found"})}catch{checks.push({name:".env file",status:"warn",message:"Not found (optional)"})}const appKey=process.env.APP_KEY;if(appKey&&appKey.length>0){checks.push({name:"APP_KEY",status:appKey.length>=32?"pass":"warn",message:appKey.length>=32?"Set (≥32 chars)":`Set but short (${appKey.length} chars; ≥32 recommended)`})}else{checks.push({name:"APP_KEY",status:"fail",message:"Not set - features that depend on it (encrypted columns, signed URLs, env decryption) will refuse to run. Run `buddy key:generate`."})}await probe(checks,"SQLite Engine",async()=>{const{Database}=await import("bun:sqlite");const memory=new Database(":memory:");let version;try{const row=memory.query("SELECT sqlite_version() AS version").get();if(typeof row?.version==="string")version=row.version}finally{memory.close()}if(!version)throw new ProbeWarning("could not read sqlite_version() (skipped)");if(!isVersionGreaterThanOrEqual(version,minimumSqliteVersion))throw new Error(`v${version} is below the required v${minimumSqliteVersion} (system.sqlite in package.json); upgrade Bun for a newer bundled SQLite`);return`v${version}`});await probe(checks,"Database",async()=>{const{db}=await import("@stacksjs/database");const unsafe=db.unsafe;if(typeof unsafe!=="function")throw new ProbeWarning("driver exposes no raw query method (skipped)");const statement=unsafe("SELECT 1");if(!statement||typeof statement.then!=="function"&&typeof statement.execute!=="function")throw new ProbeWarning("driver returned a non-executable statement (skipped)");const result=typeof statement.execute==="function"?await statement.execute():await statement;if(result===undefined||result===null)throw new Error("probe query returned no result");if(Array.isArray(result)&&result.length===0)throw new Error("probe query returned no rows");return"Reachable"});await probe(checks,"Database FKs",async()=>{const{auditForeignKeys}=await import("@stacksjs/database");const result=await auditForeignKeys();if(result.declared.length===0)return"No belongsTo declarations";const skipped=result.absentTable.length>0?`, ${result.absentTable.length} on tables not migrated`:"";if(result.missing.length===0)return`${result.declared.length} declared FKs all present${skipped}`;const sample=result.missing.slice(0,5).map((fk)=>`${fk.fromTable}.${fk.fromColumn} → ${fk.toTable}.${fk.toColumn}`).join(", ");const more=result.missing.length>5?` (+${result.missing.length-5} more)`:"";throw new Error(`${result.missing.length}/${result.declared.length} declared FKs missing from live schema: ${sample}${more}${skipped}. Run \`buddy migrate:fresh\` (will reset data) or \`buddy migrate\` against a clean DB.`)});await probe(checks,"Unique indexes",async()=>{const{auditUniqueIndexes}=await import("@stacksjs/database");const result=await auditUniqueIndexes();if(!result.supported)return"Dialect not audited (skipped)";const skipped=result.skippedTables.length>0?`, ${result.skippedTables.length} tables skipped (not migrated)`:"";if(result.missing.length===0)return`${result.declared.length} declared unique constraints all indexed${skipped}`;const sample=result.missing.slice(0,5).map((u)=>`${u.table}.${u.columns.join("+")}`).join(", ");const more=result.missing.length>5?` (+${result.missing.length-5} more)`:"";const first=result.missing[0];if(!first)throw new Error("Unique-index audit reported missing entries without details");const example=`CREATE UNIQUE INDEX IF NOT EXISTS "${first.table}_${first.columns.join("_")}_unique" ON "${first.table}" ("${first.columns.join('", "')}")`;throw new Error(`${result.missing.length}/${result.declared.length} declared unique constraints have no UNIQUE index: ${sample}${more}. Run \`buddy migrate\` (re-queues missing unique-index migrations, #1952) - dedupe duplicate rows first or migrate hard-fails; if no migration file exists run \`buddy generate:migrations\`, or create manually: ${example}`)},1e4);await probe(checks,"Migration ledger",async()=>{const{auditMigrationLedger}=await import("@stacksjs/database");const result=await auditMigrationLedger();if(!result.supported)return"Dialect not audited (skipped)";if(result.entries.length===0)return"No migration files";const{counts,orphans}=result;if(!result.drift)return`${result.entries.length} migrations, ledger consistent with the schema`;const parts=[];if(counts.stranded>0)parts.push(`${counts.stranded} applied but unrecorded (would re-run)`);if(counts.partial>0)parts.push(`${counts.partial} half-applied`);if(counts.reverted>0)parts.push(`${counts.reverted} recorded but missing from the schema`);if(orphans.length>0)parts.push(`${orphans.length} ledger row(s) with no file on disk`);const needsReapply=counts.reverted+counts.partial;const repair=needsReapply>0?`\`buddy migrate:status --reconcile\` cannot repair ${needsReapply} of these - it never runs migration SQL, so it skips anything the schema is missing. Those need re-applying: \`buddy migrate:fresh\` (rebuilds from the corpus, RESETS DATA), or restore the database and re-run the missing files by hand.`:`Repair with \`buddy migrate:status --reconcile\`.`;throw new Error(`Migration ledger has drifted: ${parts.join(", ")}. Inspect with \`buddy migrate:status\`. ${repair}`)},1e4);await probe(checks,"FK orphans",async()=>{const{findFkOrphans}=await import("@stacksjs/database");const result=await findFkOrphans();if(!result.supported)return"Dialect not audited (skipped)";if(result.total===0)return"No orphan rows (PRAGMA foreign_key_check clean)";const sample=result.orphans.slice(0,5).map((o)=>`${o.table}.${o.column} → ${o.parent} (${o.count})`).join(", ");const more=result.orphans.length>5?` (+${result.orphans.length-5} more)`:"";const first=result.orphans[0];if(!first)throw new Error("Foreign-key audit reported orphan rows without details");throw new Error(`${result.total} orphan rows violate FKs: ${sample}${more}. Legacy rows written under foreign_keys=OFF (#1951). Review and clean manually, e.g. DELETE FROM ${first.table} WHERE ${first.column} IS NOT NULL AND ${first.column} NOT IN (SELECT id FROM ${first.parent}) - doctor never deletes data.`)},1e4);await probe(checks,"Cache",async()=>{const{cache}=await import("@stacksjs/cache");const k=`__doctor_${Date.now()}`;await cache.set(k,1,5);const v=await cache.get(k);await cache.del(k);if(v!==1)throw new Error("round-trip failed");return"Round-trip ok"});await probe(checks,"Queue driver",async()=>{const{config}=await import("@stacksjs/config");const driver=config.queue?.default??"sync";return`Driver: ${driver}`});await probe(checks,"Mail driver",async()=>{const{config}=await import("@stacksjs/config");const driver=config.email?.default??"log";return`Driver: ${driver}`});{const budget=new Promise((resolve)=>setTimeout(()=>resolve([{name:"Mail DNS",status:"warn",message:"DNS lookups timed out (>6s) (skipped)"}]),6000).unref?.());checks.push(...await Promise.race([mailDnsChecks(),budget]).catch((err)=>[{name:"Mail DNS",status:"warn",message:`Could not audit mail DNS: ${err instanceof Error?err.message:String(err)}`}]))}{const{ensureRuntimeDirectories,projectPath}=await import("@stacksjs/path");const leftover=ensureRuntimeDirectories().filter((entry)=>!entry.cleared);checks.push(leftover.length===0?{name:"Runtime directories",status:"pass",message:"All under storage/"}:{name:"Runtime directories",status:"warn",message:`Still in the project root: ${leftover.map((entry)=>entry.legacy.slice(projectPath().length+1)).join(", ")} - remove them so state stays under storage/`})}const hasAwsCreds=Boolean(process.env.AWS_ACCESS_KEY_ID&&process.env.AWS_SECRET_ACCESS_KEY);const hasAwsRole=Boolean(process.env.AWS_PROFILE)||Boolean(process.env.AWS_ROLE_ARN);if(hasAwsCreds||hasAwsRole){checks.push({name:"AWS credentials",status:"pass",message:hasAwsCreds?"Static keys in env":"IAM role configured"})}else{checks.push({name:"AWS credentials",status:"warn",message:"Not configured (cloud / SES / S3 commands will fail)"})}await probe(checks,"Database backups",async()=>{const fs=await import("node:fs");const cloudConfig=resolve(process.cwd(),"config/cloud.ts");if(!fs.existsSync(cloudConfig))return"No config/cloud.ts (skipped)";const{findUnbackedManagedServices,hasOffsiteBackupDestination,unbackedDataMessage}=await import("../unbacked-data");let tsCloud;try{tsCloud=(await import(cloudConfig)).tsCloud}catch{throw new ProbeWarning("could not read config/cloud.ts (skipped)")}const unbacked=findUnbackedManagedServices(tsCloud,await hasOffsiteBackupDestination());if(unbacked.length===0)return"No unbacked managed data services";throw new ProbeWarning(unbackedDataMessage(unbacked))});await probe(checks,".env decryption",async()=>{const fs=await import("node:fs");if(!fs.existsSync(".env"))return"No .env (skipped)";const content=fs.readFileSync(".env","utf8");if(!/(?:^|=)(?:enc|encrypted):/m.test(content))return"No encrypted values";const privateKey=process.env.DOTENV_PRIVATE_KEY;if(!privateKey)throw new Error("Encrypted values present but DOTENV_PRIVATE_KEY is unset");const{parse}=await import("@stacksjs/env");const{errors}=parse(content,{privateKey});if(errors.length>0)throw new Error(errors.join("; "));return"All encrypted values decrypt cleanly"});try{const{filesystems}=await import("@stacksjs/config");const driver=filesystems.driver??"local";if(driver==="s3"){const bucket=process.env.S3_BUCKET??filesystems.s3?.bucket;const accessKeyId=process.env.AWS_ACCESS_KEY_ID;const secretAccessKey=process.env.AWS_SECRET_ACCESS_KEY;const missing=[];if(!bucket)missing.push("S3_BUCKET");if(!accessKeyId)missing.push("AWS_ACCESS_KEY_ID");if(!secretAccessKey)missing.push("AWS_SECRET_ACCESS_KEY");if(missing.length>0){checks.push({name:"Storage credentials",status:"warn",message:`Default disk is 's3' but missing: ${missing.join(", ")}. Uploads will throw on first use.`})}else{checks.push({name:"Storage credentials",status:"pass",message:"s3 default disk has bucket + AWS credentials"})}}else{checks.push({name:"Storage credentials",status:"pass",message:`Default disk is '${driver}' (no remote credentials required)`})}}catch(err){checks.push({name:"Storage credentials",status:"warn",message:`Could not audit storage config: ${err instanceof Error?err.message:String(err)}`})}try{if(process.platform!=="darwin"){checks.push({name:"Dev domains (rpx)",status:"pass",message:"Not macOS (skipped)"})}else{const fs=await import("node:fs");const os=await import("node:os");const path=await import("node:path");const isAlive=(pid)=>{try{process.kill(pid,0);return true}catch(err){return err.code==="EPERM"}};const registryDir=path.join(os.homedir(),".stacks","rpx","registry.d");const registered=new Set;const deadRegistryFiles=[];if(fs.existsSync(registryDir)){for(const file of fs.readdirSync(registryDir)){if(!file.endsWith(".json"))continue;try{const entry=JSON.parse(fs.readFileSync(path.join(registryDir,file),"utf8"));if(entry.to&&(entry.pid===undefined||isAlive(entry.pid)))registered.add(entry.to.toLowerCase());if(typeof entry.pid==="number"&&!isAlive(entry.pid))deadRegistryFiles.push(file)}catch{}}}const staleHosts=new Set;const staleResolvers=[];const hostsPath="/etc/hosts";const hostsLines=fs.existsSync(hostsPath)?fs.readFileSync(hostsPath,"utf8").split(`
|
|
3
3
|
`):[];for(let i=0;i<hostsLines.length;i++){const line=hostsLines[i];if(line.trim()==="# Added by rpx"){for(let j=i+1;j<hostsLines.length;j++){const blockLine=hostsLines[j].trim();if(blockLine===""||blockLine.startsWith("#"))break;const names=blockLine.split("#")[0]?.trim().split(/\s+/).slice(1)??[];for(const name of names){if(!registered.has(name.toLowerCase()))staleHosts.add(name)}}continue}const hash=line.indexOf("#");if(hash===-1)continue;const marker=/^rpx(?::pid=(\d+))?$/.exec(line.slice(hash+1).trim());if(!marker)continue;const names=line.slice(0,hash).trim().split(/\s+/).slice(1);const pid=marker[1]?Number.parseInt(marker[1],10):null;const stale=pid!==null?!isAlive(pid):names.every((n)=>!registered.has(n.toLowerCase()));if(stale){for(const name of names)staleHosts.add(name)}}const resolverDir="/etc/resolver";if(fs.existsSync(resolverDir)){for(const file of fs.readdirSync(resolverDir)){try{const content=fs.readFileSync(path.join(resolverDir,file),"utf8");if(!content.includes("127.0.0.1")||!content.includes("15353"))continue;const domain=file.toLowerCase();const claimed=[...registered].some((host)=>host===domain||host.endsWith(`.${domain}`));if(!claimed)staleResolvers.push(file)}catch{}}}if(staleHosts.size>0||staleResolvers.length>0||deadRegistryFiles.length>0){const parts=[];if(staleHosts.size>0)parts.push(`hosts(${[...staleHosts].join(", ")})`);if(staleResolvers.length>0)parts.push(`resolver(${staleResolvers.join(", ")})`);if(deadRegistryFiles.length>0)parts.push(`registry(${deadRegistryFiles.join(", ")})`);checks.push({name:"Dev domains (rpx)",status:"warn",message:`Stale loopback overrides from dead dev sessions: ${parts.join(" ")}. These keep pointing the domain at 127.0.0.1. Remove with: sudo nano /etc/hosts; sudo rm /etc/resolver/<name>; rm ~/.stacks/rpx/registry.d/<file>. Updating @stacksjs/rpx lets the daemon sweep pid-stamped entries automatically.`})}else{checks.push({name:"Dev domains (rpx)",status:"pass",message:"No stale dev-domain overrides"})}}}catch(err){checks.push({name:"Dev domains (rpx)",status:"warn",message:`Could not audit dev-domain overrides: ${err instanceof Error?err.message:String(err)}`})}await probe(checks,"Dev ports",async()=>{const net=await import("node:net");const{config}=await import("@stacksjs/config");const configured=config.ports??{};const targets=[{name:"frontend",key:"frontend",envVar:"PORT",fallback:3000},{name:"api",key:"api",envVar:"PORT_API",fallback:3008},{name:"docs",key:"docs",envVar:"PORT_DOCS",fallback:3006},{name:"dashboard",key:"admin",envVar:"PORT_ADMIN",fallback:3002}].map((t)=>({...t,port:Number(configured[t.key])||t.fallback}));const canConnect=(port,host)=>new Promise((resolve)=>{const socket=net.createConnection({port,host});socket.setTimeout(400);const done=(occupied)=>{socket.destroy();resolve(occupied)};socket.once("connect",()=>done(true));socket.once("timeout",()=>done(false));socket.once("error",()=>done(false))});const occupied=new Set;await Promise.all([...new Set(targets.map((t)=>t.port))].map(async(port)=>{if(await canConnect(port,"127.0.0.1")||await canConnect(port,"::1"))occupied.add(port)}));const busy=targets.filter((t)=>occupied.has(t.port));if(busy.length>0){const list=busy.map((t)=>`${t.name} :${t.port} (${t.envVar})`).join(", ");throw new ProbeWarning(`in use: ${list}. buddy dev will fail to bind; stop the process holding the port or set the override env var`)}return`All free: ${targets.map((t)=>`${t.name} :${t.port}`).join(", ")}`});try{const orphans=[];for(const name of FEATURE_NAMES){if(feature(name))continue;const present=featurePathsPresent(name);if(present.length>0)orphans.push({feature:name,count:present.length})}if(orphans.length>0){const summary=orphans.map((o)=>`${o.feature} (${o.count} path${o.count===1?"":"s"})`).join(", ");checks.push({name:"Feature scaffolding",status:"warn",message:`Stamped files remain for disabled features: ${summary}. Run \`./buddy <feature>:uninstall\` to remove or \`<feature>:install\` to re-enable.`})}else{checks.push({name:"Feature scaffolding",status:"pass",message:"No orphan files for disabled features"})}}catch(err){checks.push({name:"Feature scaffolding",status:"warn",message:`Could not audit feature scaffolding: ${err instanceof Error?err.message:String(err)}`})}log.info("");log.info(bold("Health Check Results:"));log.info(dim("─".repeat(60)));log.info("");let hasFailures=false;let hasWarnings=false;for(const check of checks){let statusIcon="";let statusColor=(text)=>text;if(check.status==="pass"){statusIcon="✓";statusColor=green}else if(check.status==="warn"){statusIcon="⚠";statusColor=yellow;hasWarnings=true}else{statusIcon="✗";statusColor=red;hasFailures=true}log.info(`${statusColor(statusIcon)} ${bold(check.name.padEnd(20))} ${dim(check.message)}`)}log.info("");log.info(dim("─".repeat(60)));log.info("");if(hasFailures){log.error("Some critical checks failed. Please address the issues above.");if(options?.fail!==false){await log.flush();process.exit(1)}}else if(hasWarnings){log.info(yellow("Some checks have warnings. Your system should work but may have issues."))}else{log.success(green("All checks passed! Your Stacks installation looks healthy."))}log.info("")});onUnknownSubcommand(buddy,"doctor")}
|
package/dist/commands/index.d.ts
CHANGED
package/dist/commands/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./about";export*from"./auth";export*from"./build";export*from"./cd";export*from"./changelog";export*from"./clean";export*from"./cloud";export*from"./comments";export*from"./commerce-import";export*from"./commit";export*from"./completion";export*from"./config-migrate";export*from"./configure";export*from"./create";export*from"./db";export*from"./storage-backup";export*from"./deploy";export*from"./deploy-preview";export*from"./dev";export*from"./dns";export*from"./docs";export*from"./doctor";export*from"./domains";export*from"./email";export*from"./env";export*from"./features";export*from"./feedback";export*from"./fresh";export*from"./gdpr";export*from"./generate";export*from"./http";export*from"./install";export*from"./key";export*from"./libs";export*from"./lint";export*from"./list";export*from"./mail";export*from"./make";export*from"./migrate";export*from"./migrate-project";export*from"./outdated";export*from"./phone";export*from"./ports";export*from"./server";export*from"./link";export*from"./user";export*from"./prepublish";export*from"./projects";export*from"./publish";export*from"./queue";export*from"./release";export*from"./route";export*from"./saas";export*from"./schedule";export*from"./search";export*from"./seed";export*from"./security";export*from"./serve";export*from"./setup";export*from"./sms";export*from"./socials";export*from"./telemetry";export*from"./test";export*from"./tinker";export*from"./types";export*from"./upgrade";export*from"./version";
|
|
1
|
+
export*from"./about";export*from"./auth";export*from"./build";export*from"./cd";export*from"./changelog";export*from"./clean";export*from"./cloud";export*from"./comments";export*from"./commerce-import";export*from"./commit";export*from"./completion";export*from"./config-migrate";export*from"./configure";export*from"./create";export*from"./db";export*from"./storage-backup";export*from"./deploy";export*from"./deploy-preview";export*from"./dev";export*from"./dns";export*from"./docs";export*from"./doctor";export*from"./domains";export*from"./email";export*from"./env";export*from"./features";export*from"./feedback";export*from"./fresh";export*from"./gdpr";export*from"./generate";export*from"./http";export*from"./install";export*from"./key";export*from"./libs";export*from"./lint";export*from"./list";export*from"./mail";export*from"./make";export*from"./migrate";export*from"./migrate-project";export*from"./outdated";export*from"./phone";export*from"./ports";export*from"./server";export*from"./link";export*from"./user";export*from"./prepublish";export*from"./projects";export*from"./publish";export*from"./queue";export*from"./release";export*from"./route";export*from"./saas";export*from"./schedule";export*from"./search";export*from"./screenshot";export*from"./seed";export*from"./security";export*from"./serve";export*from"./setup";export*from"./sms";export*from"./socials";export*from"./telemetry";export*from"./test";export*from"./tinker";export*from"./types";export*from"./upgrade";export*from"./version";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { CLI } from '@stacksjs/types';
|
|
2
|
+
/**
|
|
3
|
+
* `mobile,tablet,1280x720` as viewports, in the order given and without
|
|
4
|
+
* repeats. Throws on a name it does not know or a size outside what a view can
|
|
5
|
+
* be, rather than photographing something else quietly.
|
|
6
|
+
*/
|
|
7
|
+
export declare function parseViewports(value: string | undefined): Viewport[];
|
|
8
|
+
/**
|
|
9
|
+
* Where one viewport's picture goes. A single viewport is the path as given;
|
|
10
|
+
* several put the viewport's name before the extension (`home.png` becomes
|
|
11
|
+
* `home-mobile.png`), so one run never overwrites its own pictures.
|
|
12
|
+
*/
|
|
13
|
+
export declare function screenshotPath(out: string | undefined, viewport: Viewport, many: boolean): string;
|
|
14
|
+
/** `localhost:3000/pricing` is a page too; anything that is not http(s) is a scheme, not a page. */
|
|
15
|
+
export declare function pageUrl(value: string): string | null;
|
|
16
|
+
/** A count of milliseconds from an option, within bounds; the fallback when it is not a number. */
|
|
17
|
+
export declare function boundedMs(value: unknown, fallback: number, max?: number): number;
|
|
18
|
+
export declare function screenshot(buddy: CLI): void;
|
|
19
|
+
/**
|
|
20
|
+
* The sizes worth checking by name: a current phone, a tablet in portrait and
|
|
21
|
+
// a laptop. Anything else is given as WIDTHxHEIGHT.
|
|
22
|
+
* @defaultValue
|
|
23
|
+
* ```ts
|
|
24
|
+
* {
|
|
25
|
+
* mobile: { width: 390, height: 844 },
|
|
26
|
+
* tablet: { width: 820, height: 1180 },
|
|
27
|
+
* desktop: { width: 1440, height: 900 }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const VIEWPORTS: Record<string, Omit<Viewport, 'name'>>;
|
|
32
|
+
// A picture of a page, as a command.
|
|
33
|
+
//
|
|
34
|
+
// Looking at what a change did is the step that gets skipped, because the
|
|
35
|
+
// honest way to do it has been a browser somebody has to have installed, a
|
|
36
|
+
// driver for it, and a script written for the occasion. Bun carries a browser
|
|
37
|
+
// view of its own (`Bun.WebView`): the system's WebKit on a Mac, an installed
|
|
38
|
+
// Chrome elsewhere. `buddy screenshot <url>` is that view pointed at a page:
|
|
39
|
+
// load it, let it settle, photograph it at each size asked for.
|
|
40
|
+
//
|
|
41
|
+
// It photographs one page. Journeys - click this, then that - belong in
|
|
42
|
+
// `@stacksjs/testing/browser`, which keeps a browser open across steps. What
|
|
43
|
+
// this adds to a bare screenshot is the handful of things that make one
|
|
44
|
+
// trustworthy: a settle time and a selector to wait for (a page photographed
|
|
45
|
+
// before its data arrives is a picture of a spinner), several viewports in one
|
|
46
|
+
// run (a layout is only checked when its phone and desktop are both looked
|
|
47
|
+
// at), and a kept profile, so a page behind a sign-in can be photographed
|
|
48
|
+
// after signing in once with `--eval`.
|
|
49
|
+
//
|
|
50
|
+
// Line comments rather than block comments inside function bodies, as in
|
|
51
|
+
// simulator.ts.
|
|
52
|
+
export declare interface Viewport {
|
|
53
|
+
name: string
|
|
54
|
+
width: number
|
|
55
|
+
height: number
|
|
56
|
+
}
|
|
57
|
+
declare interface PageView {
|
|
58
|
+
navigate: (url: string) => Promise<unknown>
|
|
59
|
+
evaluate: (script: string) => Promise<unknown>
|
|
60
|
+
screenshot: () => Promise<Uint8Array | ArrayBuffer | Blob>
|
|
61
|
+
resize?: (width: number, height: number) => Promise<unknown> | unknown
|
|
62
|
+
close?: () => Promise<unknown> | unknown
|
|
63
|
+
}
|
|
64
|
+
// eslint-disable-next-line pickier/no-unused-vars
|
|
65
|
+
declare type PageViewConstructor = new (options: Record<string, unknown>) => PageView;
|
|
66
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mkdirSync}from"node:fs";import{dirname,extname,resolve}from"node:path";import process from"node:process";export const VIEWPORTS={mobile:{width:390,height:844},tablet:{width:820,height:1180},desktop:{width:1440,height:900}};export function parseViewports(value){const parts=String(value||"desktop").split(",").map((part)=>part.trim().toLowerCase()).filter(Boolean);const seen=new Set;const viewports=[];for(const part of parts.length>0?parts:["desktop"]){const named=VIEWPORTS[part];const sized=/^(\d{2,5})x(\d{2,5})$/.exec(part);if(!named&&!sized)throw new Error(`Unknown viewport "${part}". Use ${Object.keys(VIEWPORTS).join(", ")} or WIDTHxHEIGHT.`);const viewport=named?{name:part,...named}:{name:part,width:Number(sized[1]),height:Number(sized[2])};if(viewport.width<200||viewport.width>7680||viewport.height<200||viewport.height>7680)throw new Error(`Viewport ${part} is outside 200 to 7680 pixels a side.`);if(seen.has(viewport.name))continue;seen.add(viewport.name);viewports.push(viewport)}return viewports}export function screenshotPath(out,viewport,many){const wanted=String(out||"screenshot.png");const extension=extname(wanted);const base=extension?wanted.slice(0,-extension.length):wanted;const suffix=extension.toLowerCase()===".png"?extension:".png";return resolve(many?`${base}-${viewport.name}${suffix}`:`${base}${suffix}`)}export function pageUrl(value){const text=String(value||"").trim();const candidate=/^[a-z][a-z\d+.-]*:\/\//i.test(text)?text:/^(?:localhost|127\.0\.0\.1|\[::1\]|[\w-]+(?:\.[\w-]+)+)(?::\d+)?(?:[/?#]|$)/i.test(text)?`http://${text}`:"";try{const url=new URL(candidate);return url.protocol==="http:"||url.protocol==="https:"?url.href:null}catch{return null}}export function boundedMs(value,fallback,max=120000){const ms=Number(value);return Number.isFinite(ms)&&ms>=0?Math.min(max,Math.round(ms)):fallback}function pageView(){const view=Bun.WebView;return typeof view==="function"?view:null}async function photograph(View,url,viewport,path,options){const backend=options.backend||(process.platform==="darwin"?"webkit":"chrome");const view=new View({width:viewport.width,height:viewport.height,backend,...options.profile?{dataStore:{directory:resolve(options.profile)}}:{}});try{await view.navigate(url);const timeout=boundedMs(options.timeout,15000);const selector=String(options.waitFor||"");if(selector){const found=await view.evaluate(`(async () => { const until = Date.now() + ${timeout}; while (Date.now() < until) { if (document.querySelector(${JSON.stringify(selector)})) return true; await new Promise(done => setTimeout(done, 100)) } return false })()`);if(found!==true)throw new Error(`Nothing matched ${selector} within ${Math.round(timeout/1000)}s.`)}await Bun.sleep(boundedMs(options.wait,1500));if(options.eval){const result=await view.evaluate(options.eval);if(result!==undefined&&result!==null)console.log(typeof result==="string"?result:JSON.stringify(result))}const scroll=Number(options.scroll);if(Number.isFinite(scroll)&&scroll>0){await view.evaluate(`window.scrollTo(0, ${Math.round(scroll)})`);await Bun.sleep(400)}const picture=await view.screenshot();mkdirSync(dirname(path),{recursive:true});await Bun.write(path,picture)}finally{await view.close?.()}}export function screenshot(buddy){buddy.command("screenshot <url>","Photograph a page at one or more viewport sizes, with Bun's own browser view").option("--out <path>","Where the PNG goes. With several viewports, each name is added before the extension.",{default:"screenshot.png"}).option("--viewport <list>","mobile, tablet, desktop or WIDTHxHEIGHT, comma-separated",{default:"desktop"}).option("--wait <ms>","How long to let the page settle after it loads",{default:1500}).option("--wait-for <selector>","Wait until this CSS selector matches before photographing",{default:""}).option("--timeout <ms>","How long --wait-for may take",{default:15000}).option("--scroll <pixels>","Scroll down this far before photographing",{default:0}).option("--eval <script>","Run this in the page before photographing, and print what it returns",{default:""}).option("--profile <directory>","Keep cookies and storage here between runs, so a signed-in page can be photographed",{default:""}).option("--backend <name>","webkit or chrome. Defaults to webkit on a Mac and chrome elsewhere.",{default:""}).example("buddy screenshot localhost:3000 --viewport mobile,desktop --out storage/screenshots/home.png").example("buddy screenshot https://example.com/pricing --wait-for main --wait 500").action(async(target,options)=>{const url=pageUrl(target);if(!url){console.error(" Only http and https pages. Anything else is a scheme, not a page.");process.exit(1);return}const View=pageView();if(!View){console.error(` This Bun (${Bun.version}) has no browser view. \`buddy upgrade:bun\` gets one that does.`);process.exit(1);return}let viewports;try{viewports=parseViewports(options.viewport)}catch(error){console.error(` ${error.message}`);process.exit(1);return}for(const viewport of viewports){const path=screenshotPath(options.out,viewport,viewports.length>1);try{await photograph(View,url,viewport,path,options)}catch(error){console.error(` could not photograph ${url} at ${viewport.width}x${viewport.height}: ${error.message}`);if(process.platform!=="darwin"&&!options.backend)console.error(" Off a Mac this needs an installed Chrome.");process.exit(1);return}console.error(` ${viewport.name.padEnd(9)} ${viewport.width}x${viewport.height} ${path}`)}})}
|
package/dist/commands/tinker.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import process from"node:process";import{intro,log,onUnknownSubcommand,outro}from"@stacksjs/cli";import{ExitCode}from"@stacksjs/types";export function tinker(buddy){const descriptions={tinker:"Interactive REPL with Stacks framework preloaded",eval:"Evaluate a single expression and exit",print:"Evaluate, print, and exit",noBanner:"Skip the welcome banner",preload:"Additional modules to preload (comma-separated)",project:"
|
|
1
|
+
import process from"node:process";import{intro,log,onUnknownSubcommand,outro}from"@stacksjs/cli";import{ExitCode}from"@stacksjs/types";export function tinker(buddy){const descriptions={tinker:"Interactive REPL with Stacks framework preloaded",eval:"Evaluate a single expression and exit",print:"Evaluate, print, and exit",noBanner:"Skip the welcome banner",preload:"Additional modules to preload (comma-separated)",project:"Run in this project directory instead of the current one",serve:"Speak the frame protocol on stdio (JSON requests in, frames out) for tools that drive a session",bare:"Do not boot the app: a plain Bun session",verbose:"Enable verbose output"};buddy.command("tinker",descriptions.tinker).option("-e, --eval [expression]",descriptions.eval,{default:""}).option("--print [expression]",descriptions.print,{default:""}).option("--no-banner",descriptions.noBanner).option("--preload [modules]",descriptions.preload,{default:""}).option("--project [path]",descriptions.project,{default:""}).option("--serve",descriptions.serve,{default:false}).option("--bare",descriptions.bare,{default:false}).option("--verbose",descriptions.verbose,{default:false}).action(async(options)=>{if(options.serve===true){const{startTinker}=await import("@stacksjs/tinker");const once=typeof options.print==="string"&&options.print?options.print:typeof options.eval==="string"&&options.eval?options.eval:undefined;const result=await startTinker({serve:true,eval:once,cwd:typeof options.project==="string"&&options.project?options.project:undefined,stacksPreload:options.bare!==true});process.exit(result.exitCode===0?ExitCode.Success:ExitCode.FatalError)}log.debug("Running `buddy tinker` ...",options);const perf=await intro("buddy tinker");try{const{startTinker}=await import("@stacksjs/tinker");const preloadModules=typeof options.preload==="string"&&options.preload?options.preload.split(",").map((m)=>m.trim()):undefined;const result=await startTinker({eval:typeof options.eval==="string"&&options.eval?options.eval:undefined,print:typeof options.print==="string"&&options.print?options.print:undefined,banner:options.banner!==false,preload:preloadModules,verbose:options.verbose===true,cwd:typeof options.project==="string"&&options.project?options.project:undefined,stacksPreload:options.bare!==true});if(result.exitCode!==0){await outro("Tinker session ended with errors",{startTime:perf,useSeconds:true,type:"error"});process.exit(ExitCode.FatalError)}await outro("Tinker session ended.",{startTime:perf,useSeconds:true});process.exit(ExitCode.Success)}catch(error){await outro("While running the tinker command, there was an issue",{startTime:perf,useSeconds:true},error instanceof Error?error:undefined);process.exit(ExitCode.FatalError)}});onUnknownSubcommand(buddy,"tinker")}
|
package/dist/lazy-commands.js
CHANGED
|
@@ -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"},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: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"},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"},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"},"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"},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"},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: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"},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: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"},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"},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"},"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"},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: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)}
|
package/dist/mail-users.d.ts
CHANGED
|
@@ -3,10 +3,21 @@ import type { MailboxUserBackend } from '@stacksjs/types';
|
|
|
3
3
|
export declare function resolveMailUserBackend(settings?: MailboxUserBackend): { table: string, region: string };
|
|
4
4
|
export declare function mailUserClient(settings?: MailboxUserBackend, factory?: ClientFactory): Promise<{
|
|
5
5
|
client: ReturnType<ClientFactory>;
|
|
6
|
-
table:
|
|
6
|
+
table: __dtsx_return_0.__dtsx_return_0_result_0
|
|
7
7
|
}>;
|
|
8
8
|
export declare function parseMailUserPassword(input: string): string;
|
|
9
9
|
export declare function addMailUser(email: string, input: string, settings?: MailboxUserBackend, factory?: ClientFactory): Promise<void>;
|
|
10
10
|
declare type MailUserClient = Pick<DynamoDBClient, 'putItem' | 'scan' | 'deleteItem'>;
|
|
11
11
|
declare type ClientFactory = (region: string) => Promise<MailUserClient>;
|
|
12
|
+
declare namespace __dtsx_return_0 {
|
|
13
|
+
const __dtsx_binding_0: ReturnType<typeof resolveMailUserBackend>;
|
|
14
|
+
function __dtsx_binding_3({ table: __dtsx_binding_1, region: __dtsx_binding_2 }: typeof __dtsx_binding_0): [typeof __dtsx_binding_1, typeof __dtsx_binding_2];
|
|
15
|
+
type __dtsx_binding_4 = (typeof __dtsx_binding_3) extends (...args: never[]) => infer __dtsx_binding_5 ? __dtsx_binding_5 : never;
|
|
16
|
+
const table: __dtsx_binding_4[0];
|
|
17
|
+
namespace __dtsx_return_0_scope_0 {
|
|
18
|
+
type __dtsx_return_0_result_0 = typeof table
|
|
19
|
+
}
|
|
20
|
+
type __dtsx_return_0_result_0 = __dtsx_return_0_scope_0.__dtsx_return_0_result_0
|
|
21
|
+
|
|
22
|
+
}
|
|
12
23
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync}from"node:fs";import{join}from"node:path";import process from"node:process";import{enterRequestScope,installRequestScope}from"@stacksjs/config";import{log}from"@stacksjs/logging";import{siteConfigPath}from"@stacksjs/path";import{ExitCode}from"@stacksjs/types";import{resolveStxSource}from"@stacksjs/actions";import{serverRequestBodyOptions}from"@stacksjs/server/request-body";import{beginRequestCapture,finishRequestCapture}from"@stacksjs/router/request-capture";installRequestScope();export function resolveUserPartialsPath(cwd=process.cwd(),configuredDir){if(configuredDir){const configured=[join(cwd,"resources",configuredDir),join(cwd,configuredDir)].find((candidate)=>existsSync(candidate));if(configured)return configured}const candidates=["resources/partials","resources/views/partials","partials","resources/components"];const existing=candidates.filter((candidate)=>existsSync(join(cwd,candidate)));if(existing.length===0)return;const populated=existing.find((candidate)=>containsTemplates(join(cwd,candidate)));return join(cwd,populated??existing[0])}function containsTemplates(dir){try{return[...new Bun.Glob("**/*.stx").scanSync({cwd:dir,onlyFiles:true})].length>0}catch{return false}}export async function loadStxPartialsDir(cwd=process.cwd()){for(const name of["stx","ui"]){const configPath=join(cwd,`config/${name}.ts`);if(!existsSync(configPath))continue;try{const mod=await import(configPath);const dir=mod.default?.partialsDir;if(typeof dir==="string"&&dir.length>0)return dir}catch{}}return}function resolveCsrfMiddlewarePath(){const rel="app/Middleware/Csrf.ts";const vendored=join(process.cwd(),"storage/framework/defaults",rel);if(existsSync(vendored))return vendored;try{const pkgJson=Bun.resolveSync("@stacksjs/defaults/package.json",process.cwd());return`${pkgJson.slice(0,pkgJson.lastIndexOf("/"))}/${rel}`}catch{return vendored}}export async function startProductionServer(options){if(options?.port)process.env.PORT=String(options.port);process.env.APP_ENV=process.env.APP_ENV||"production";const port=Number(process.env.PORT)||3000;const{config,feature,overridesReady,resolveViewPatterns}=await import("@stacksjs/config");await overridesReady;const{ensureDiscoveredPackages}=await import("@stacksjs/actions");await ensureDiscoveredPackages();const{applyResponseHeaders,applyViewSecurityHeaders,describeApiProxyRules,describeRedirectRules,describeRewriteRules,injectGlobalAutoImports,loadRouteRedirects,resolveApiBase,resolveApiProxyRules,resolveEmbeddableRules,resolveRedirectRules,resolveRewriteRules,viewClientAddress}=await import("@stacksjs/server");const{resolveDefaultsResources}=await import("@stacksjs/actions/dev/defaults-resources");const{stxPageAuthMiddleware}=await import("@stacksjs/auth");const{enhanceRequest,loadMiddlewareHandlers,registerPeerSource}=await import("@stacksjs/router");const pageMiddleware=await loadMiddlewareHandlers();try{const{autoImportsAreStale,generateAutoImportFiles}=await import("@stacksjs/server");if(autoImportsAreStale()){log.info("[server] Installed packages moved since the auto-import barrel was written; rebuilding it.");await generateAutoImportFiles({declarations:false})}}catch(error){log.warn(`[server] Could not refresh the auto-import barrel: ${error instanceof Error?error.message:String(error)}`)}await injectGlobalAutoImports();let stxServe;const serveSource=resolveStxSource({value:process.env.BUN_PLUGIN_STX_SRC});if(serveSource.kind==="missing"){await log.exit(`BUN_PLUGIN_STX_SRC points at ${serveSource.path}, which does not exist. Unset it to use the installed bun-plugin-stx.`,ExitCode.FatalError)}if(serveSource.kind==="override"){({serve:stxServe}=await import(serveSource.path));log.warn(`Serving views through ${serveSource.path} instead of the installed bun-plugin-stx.`)}else{({serve:stxServe}=await import("bun-plugin-stx/serve"))}log.debug(`stx serve implementation: ${serveSource.kind==="override"?serveSource.path:"bun-plugin-stx/serve"}`);const stxModule=await resolveVendoredStxModule();const{site:siteConfig,i18n:i18nConfig}=await loadStxSiteConfig();const userViewsPath="resources/views";const defaultsResources=resolveDefaultsResources();const defaultViewsPath=join(defaultsResources,"views");const userLayoutsPath=existsSync("resources/views/layouts")?"resources/views/layouts":"resources/layouts";const userComponentsPath=existsSync("resources/views/components")?"resources/views/components":"resources/components";const userPartialsPath=resolveUserPartialsPath(process.cwd(),await loadStxPartialsDir());const apiBase=resolveApiBase(config.ports?.api);const{mountedDefaultRouteBundles}=await import("@stacksjs/router");const viewPatterns=resolveViewPatterns(userViewsPath,defaultViewsPath,config?.ui?.defaultViews,undefined,undefined,mountedDefaultRouteBundles(feature));for(const name of viewPatterns.missing)log.warn(`ui.defaultViews lists "${name}", which does not exist under ${defaultViewsPath} - ignoring.`);if(viewPatterns.withheld.length>0)log.info(`Default views without a mounted route bundle behind them, not served: ${viewPatterns.withheld.join(", ")}`);const apiProxyRules=resolveApiProxyRules(config.server?.proxy);if(apiProxyRules.paths.length>0||apiProxyRules.prefixes.length>1)log.info(`API proxy: ${describeApiProxyRules(apiProxyRules)}`);const redirectRules=resolveRedirectRules({...await loadRouteRedirects(),...config.server?.redirects});if(redirectRules.size>0)log.info(`Redirects: ${describeRedirectRules(redirectRules)}`);const rewriteRules=resolveRewriteRules(config.server?.rewrites);if(rewriteRules.size>0)log.info(`Rewrites: ${describeRewriteRules(rewriteRules)}`);const{createSiteSeoHandler,describeSeoAtBoot}=await import("@stacksjs/actions/seo");const seoOptions={root:process.cwd(),seo:config.app?.seo,appUrl:config.app?.url};const siteSeo=createSiteSeoHandler({...seoOptions,cacheTtlMs:600000});for(const note of await describeSeoAtBoot(seoOptions).catch(()=>[]))log.warn(note);const cacheConfig=config.server?.cache;const documentCacheControl=buildDocumentCacheControl(cacheConfig?.documents);if(cacheConfig?.renders)log.info(`Render cache: on, keyed by ${cacheConfig.renderVary??"request"}${cacheConfig.prewarm?", prewarmed":""}`);if(documentCacheControl)log.info(`Document cache: ${documentCacheControl}`);const embeddableRules=resolveEmbeddableRules(config.server?.security?.embeddable);if(embeddableRules.paths.length>0||embeddableRules.prefixes.length>0)log.info(`Frameable by other origins: ${[...embeddableRules.paths,...embeddableRules.prefixes].join(" ")}`);log.info(`Starting production server on port ${port}...`);await stxServe({...serverRequestBodyOptions(config.server?.maxRequestBodySize),patterns:viewPatterns.patterns,exclude:viewPatterns.exclude,port,autoIncrementPort:false,reusePort:["production","staging","development"].includes((process.env.APP_ENV||"").toLowerCase()),componentsDir:userComponentsPath,fallbackComponentsDir:join(defaultsResources,"components"),layoutsDir:userLayoutsPath,...userPartialsPath&&{partialsDir:userPartialsPath},fallbackLayoutsDir:join(defaultsResources,"layouts"),fallbackPartialsDir:defaultViewsPath,quiet:options?.verbose!==true,...cacheConfig?.renders&&{renderCache:true,renderCacheVary:cacheConfig.renderVary??"request",...cacheConfig.prewarm&&{prewarmRenderCache:true}},...stxModule&&{stxModule},...i18nConfig&&{i18n:i18nConfig},...siteConfig?.url&&{site:siteConfig},...config.server?.domains&&{domains:config.server.domains},middleware:{...pageMiddleware,...stxPageAuthMiddleware()},prepareMiddlewareRequest:(request)=>enhanceRequest(request),clientAddress:viewClientAddress,onRequest:async(req,server)=>{beginRequestCapture(req);const snapshot=enterRequestScope(req);registerPeerSource(server);const{maintenanceGate,isApiBoundRequest:isApiBound,proxyToBackend,resolveRedirect,resolveRewrite}=await import("@stacksjs/server");const gated=await maintenanceGate(req);if(gated)return gated;const url=new URL(req.url);const redirected=resolveRedirect(url,redirectRules);if(redirected)return redirected;const rewritten=resolveRewrite(url.pathname,rewriteRules);if(rewritten){if(!apiBase){log.error(`No API target configured for ${url.pathname} (rewritten to ${rewritten}); refusing to proxy.`);return new Response("Bad Gateway",{status:502})}try{const target=new URL(`${rewritten}${url.search}`,url.origin);return await proxyToBackend(new Request(target,req),apiBase,undefined,req)}catch(error){log.error(`Rewrite of ${url.pathname} to ${rewritten} failed: ${error.message}`);return new Response("Bad Gateway",{status:502})}}const seoFile=await siteSeo(req);if(seoFile)return seoFile;if(isApiBound(req,url.pathname,apiProxyRules)){if(!apiBase){log.error(`No API target configured for ${url.pathname}. This app shares its host with other deployments, so there is no safe default port to guess - refusing to proxy. Set PORT_API (or API_URL) for this site, and deploy an \`api\` site on its own port.`);return new Response("Bad Gateway",{status:502})}try{return await proxyToBackend(req,apiBase)}catch(error){log.error(`API proxy to ${apiBase} failed: ${error.message}`);return new Response("Bad Gateway",{status:502})}}if(existsSync(join(process.cwd(),"resources/views/blog.stx"))){const{renderBlogFeed}=await import("@stacksjs/actions/blog");const feed=await renderBlogFeed(req);if(feed)return feed}if(config.analytics?.capturePageviews){import("@stacksjs/analytics").then(({recordPageview})=>recordPageview(req)).catch(()=>{})}if(config.sites?.enabled){const sites=await import("@stacksjs/sites");const resolved=await sites.resolveSiteByHost(sites.requestHost(req.headers,sites.sitesOptions()));sites.setCurrentSite(resolved);snapshot.site=sites.toSiteSnapshot(resolved)}return},onResponse:async(req,response)=>{const securityResponse=applyViewSecurityHeaders(req,response,embeddableRules);const secured=applyResponseHeaders(req,securityResponse??response,config.server?.headers)??securityResponse;const method=req.method.toUpperCase();if(method!=="GET"&&method!=="HEAD"){finishRequestCapture(req,secured??response);return secured}const baseline=secured??response;let current=baseline;if(current.status===404&&config.sites?.enabled){try{const{cmsNotFoundFallback}=await import("@stacksjs/cms");const cmsResponse=await cmsNotFoundFallback(req);if(cmsResponse)current=cmsResponse}catch(error){log.debug(`CMS fallback skipped: ${error.message}`)}}let finished;try{const{seedCsrfCookieIfMissing}=await import(resolveCsrfMiddlewarePath());finished=await seedCsrfCookieIfMissing(req,current)??(current===baseline?secured:current)}catch(error){log.debug(`CSRF cookie seeding skipped: ${error.message}`);finished=current===baseline?secured:current}if(!documentCacheControl){finishRequestCapture(req,finished??response);return finished}const cached=applyDocumentCacheControl(req,finished??response,documentCacheControl);finishRequestCapture(req,cached??finished??response);return cached}});log.success(`Production server listening on http://0.0.0.0:${port}`)}export function buildDocumentCacheControl(documents){if(!documents)return;const maxAge=Number(documents.maxAge??0);if(!Number.isFinite(maxAge)||maxAge<=0)return;const stale=Number(documents.staleWhileRevalidate??0);const parts=[`public`,`max-age=${Math.floor(maxAge)}`];if(Number.isFinite(stale)&&stale>0)parts.push(`stale-while-revalidate=${Math.floor(stale)}`);return parts.join(", ")}export function isAuthenticatedRequest(request){if(request.headers.get("authorization"))return true;const cookie=request.headers.get("cookie")||"";if(!cookie)return false;return cookie.split(";").map((part)=>part.trim().split("=")[0]?.toLowerCase()??"").some((name)=>name!==""&&!name.includes("csrf")&&/session|auth|token|remember/.test(name))}const SPA_NAV_REQUEST_HEADER="X-STX-Router";const SPA_NAV_FRAGMENT_HEADER="X-STX-Fragment";export function isSpaFragmentExchange(request,response){return request.headers.get(SPA_NAV_REQUEST_HEADER)==="true"||response.headers.get(SPA_NAV_FRAGMENT_HEADER)==="true"}export function applyDocumentCacheControl(request,response,cacheControl){if(!cacheControl)return response;const contentType=response.headers.get("content-type")||"";if(response.status!==200||!contentType.startsWith("text/html"))return response;if(isSpaFragmentExchange(request,response))return response;if(response.headers.getSetCookie().length>0)return response;if(isAuthenticatedRequest(request))return response;const headers=new Headers(response.headers);headers.set("cache-control",cacheControl);return new Response(response.body,{status:response.status,statusText:response.statusText,headers})}async function resolveVendoredStxModule(){const source=resolveStxSource({value:process.env.STACKS_STX_SRC});if(source.kind==="missing"){await log.exit(`STACKS_STX_SRC points at ${source.path}, which does not exist. Unset it to use the installed @stacksjs/stx.`,ExitCode.FatalError)}if(source.kind==="override"){log.warn(`Rendering through ${source.path} instead of the installed @stacksjs/stx.`);return await import(source.path)}try{return await import("@stacksjs/stx")}catch{}return}function fallbackI18nFromSite(site){const locales=site.i18n.locales;const defaultLocale=site.i18n.defaultLocale??locales[0];return{locales,defaultLocale,labels:site.i18n.labels??Object.fromEntries(locales.map((c)=>[c,c.toUpperCase()])),translations:{},pickerSelector:site.i18n.pickerSelector??"#lang-picker"}}async function resolveSiteI18n(site){try{const resolved=await resolveVendoredStxModule();if(typeof resolved?.resolveI18n==="function"){const i18n=resolved.resolveI18n(site,process.cwd());if(i18n)return i18n}}catch{}return fallbackI18nFromSite(site)}async function loadStxSiteConfig(){const sitePath=siteConfigPath();if(!existsSync(sitePath))return{};try{const mod=await import(sitePath);const site=mod.default??mod.site??mod.config;if(!site)return{};if(!site.i18n)return{site};const i18n=await resolveSiteI18n(site);return{site,i18n}}catch{}return{}}
|
|
1
|
+
import{existsSync}from"node:fs";import{join}from"node:path";import process from"node:process";import{enterRequestScope,feature,installRequestScope}from"@stacksjs/config";import{log}from"@stacksjs/logging";import{siteConfigPath}from"@stacksjs/path";import{ExitCode}from"@stacksjs/types";import{resolveStxSource}from"@stacksjs/actions";import{serverRequestBodyOptions}from"@stacksjs/server/request-body";import{beginRequestCapture,finishRequestCapture}from"@stacksjs/router/request-capture";installRequestScope();export function resolveUserPartialsPath(cwd=process.cwd(),configuredDir){if(configuredDir){const configured=[join(cwd,"resources",configuredDir),join(cwd,configuredDir)].find((candidate)=>existsSync(candidate));if(configured)return configured}const candidates=["resources/partials","resources/views/partials","partials","resources/components"];const existing=candidates.filter((candidate)=>existsSync(join(cwd,candidate)));if(existing.length===0)return;const populated=existing.find((candidate)=>containsTemplates(join(cwd,candidate)));return join(cwd,populated??existing[0])}function containsTemplates(dir){try{return[...new Bun.Glob("**/*.stx").scanSync({cwd:dir,onlyFiles:true})].length>0}catch{return false}}export async function loadStxPartialsDir(cwd=process.cwd()){for(const name of["stx","ui"]){const configPath=join(cwd,`config/${name}.ts`);if(!existsSync(configPath))continue;try{const mod=await import(configPath);const dir=mod.default?.partialsDir;if(typeof dir==="string"&&dir.length>0)return dir}catch{}}return}function resolveCsrfMiddlewarePath(){const rel="app/Middleware/Csrf.ts";const vendored=join(process.cwd(),"storage/framework/defaults",rel);if(existsSync(vendored))return vendored;try{const pkgJson=Bun.resolveSync("@stacksjs/defaults/package.json",process.cwd());return`${pkgJson.slice(0,pkgJson.lastIndexOf("/"))}/${rel}`}catch{return vendored}}export async function startProductionServer(options){if(options?.port)process.env.PORT=String(options.port);process.env.APP_ENV=process.env.APP_ENV||"production";const port=Number(process.env.PORT)||3000;const{config,feature,overridesReady,resolveViewPatterns}=await import("@stacksjs/config");await overridesReady;const{ensureDiscoveredPackages}=await import("@stacksjs/actions");await ensureDiscoveredPackages();const{applyResponseHeaders,applyViewSecurityHeaders,describeApiProxyRules,describeRedirectRules,describeRewriteRules,injectGlobalAutoImports,loadRouteRedirects,resolveApiBase,resolveApiProxyRules,resolveEmbeddableRules,resolveRedirectRules,resolveRewriteRules,viewClientAddress}=await import("@stacksjs/server");const{resolveDefaultsResources}=await import("@stacksjs/actions/dev/defaults-resources");const{stxPageAuthMiddleware}=await import("@stacksjs/auth");const{enhanceRequest,loadMiddlewareHandlers,registerPeerSource}=await import("@stacksjs/router");const pageMiddleware=await loadMiddlewareHandlers();try{const{autoImportsAreStale,generateAutoImportFiles}=await import("@stacksjs/server");if(autoImportsAreStale()){log.info("[server] Installed packages moved since the auto-import barrel was written; rebuilding it.");await generateAutoImportFiles({declarations:false})}}catch(error){log.warn(`[server] Could not refresh the auto-import barrel: ${error instanceof Error?error.message:String(error)}`)}await injectGlobalAutoImports();let stxServe;const serveSource=resolveStxSource({value:process.env.BUN_PLUGIN_STX_SRC});if(serveSource.kind==="missing"){await log.exit(`BUN_PLUGIN_STX_SRC points at ${serveSource.path}, which does not exist. Unset it to use the installed bun-plugin-stx.`,ExitCode.FatalError)}if(serveSource.kind==="override"){({serve:stxServe}=await import(serveSource.path));log.warn(`Serving views through ${serveSource.path} instead of the installed bun-plugin-stx.`)}else{({serve:stxServe}=await import("bun-plugin-stx/serve"))}log.debug(`stx serve implementation: ${serveSource.kind==="override"?serveSource.path:"bun-plugin-stx/serve"}`);const stxModule=await resolveVendoredStxModule();const{site:siteConfig,i18n:i18nConfig}=await loadStxSiteConfig();const userViewsPath="resources/views";const defaultsResources=resolveDefaultsResources();const defaultViewsPath=join(defaultsResources,"views");const userLayoutsPath=existsSync("resources/views/layouts")?"resources/views/layouts":"resources/layouts";const userComponentsPath=existsSync("resources/views/components")?"resources/views/components":"resources/components";const userPartialsPath=resolveUserPartialsPath(process.cwd(),await loadStxPartialsDir());const apiBase=resolveApiBase(config.ports?.api);const{mountedDefaultRouteBundles}=await import("@stacksjs/router");const viewPatterns=resolveViewPatterns(userViewsPath,defaultViewsPath,config?.ui?.defaultViews,undefined,undefined,mountedDefaultRouteBundles(feature));for(const name of viewPatterns.missing)log.warn(`ui.defaultViews lists "${name}", which does not exist under ${defaultViewsPath} - ignoring.`);if(viewPatterns.withheld.length>0)log.info(`Default views without a mounted route bundle behind them, not served: ${viewPatterns.withheld.join(", ")}`);const apiProxyRules=resolveApiProxyRules(config.server?.proxy);if(apiProxyRules.paths.length>0||apiProxyRules.prefixes.length>1)log.info(`API proxy: ${describeApiProxyRules(apiProxyRules)}`);const redirectRules=resolveRedirectRules({...await loadRouteRedirects(),...config.server?.redirects});if(redirectRules.size>0)log.info(`Redirects: ${describeRedirectRules(redirectRules)}`);const rewriteRules=resolveRewriteRules(config.server?.rewrites);if(rewriteRules.size>0)log.info(`Rewrites: ${describeRewriteRules(rewriteRules)}`);const{createSiteSeoHandler,describeSeoAtBoot}=await import("@stacksjs/actions/seo");const seoOptions={root:process.cwd(),seo:config.app?.seo,appUrl:config.app?.url};const siteSeo=createSiteSeoHandler({...seoOptions,cacheTtlMs:600000});for(const note of await describeSeoAtBoot(seoOptions).catch(()=>[]))log.warn(note);const cacheConfig=config.server?.cache;const documentCacheControl=buildDocumentCacheControl(cacheConfig?.documents);if(cacheConfig?.renders)log.info(`Render cache: on, keyed by ${cacheConfig.renderVary??"request"}${cacheConfig.prewarm?", prewarmed":""}`);if(documentCacheControl)log.info(`Document cache: ${documentCacheControl}`);const embeddableRules=resolveEmbeddableRules(config.server?.security?.embeddable);if(embeddableRules.paths.length>0||embeddableRules.prefixes.length>0)log.info(`Frameable by other origins: ${[...embeddableRules.paths,...embeddableRules.prefixes].join(" ")}`);log.info(`Starting production server on port ${port}...`);await stxServe({...serverRequestBodyOptions(config.server?.maxRequestBodySize),patterns:viewPatterns.patterns,exclude:viewPatterns.exclude,port,autoIncrementPort:false,reusePort:["production","staging","development"].includes((process.env.APP_ENV||"").toLowerCase()),componentsDir:userComponentsPath,fallbackComponentsDir:join(defaultsResources,"components"),layoutsDir:userLayoutsPath,...userPartialsPath&&{partialsDir:userPartialsPath},fallbackLayoutsDir:join(defaultsResources,"layouts"),fallbackPartialsDir:defaultViewsPath,quiet:options?.verbose!==true,...cacheConfig?.renders&&{renderCache:true,renderCacheVary:cacheConfig.renderVary??"request",...cacheConfig.prewarm&&{prewarmRenderCache:true}},...stxModule&&{stxModule},...i18nConfig&&{i18n:i18nConfig},...siteConfig?.url&&{site:siteConfig},...config.server?.domains&&{domains:config.server.domains},middleware:{...pageMiddleware,...stxPageAuthMiddleware()},prepareMiddlewareRequest:(request)=>enhanceRequest(request),clientAddress:viewClientAddress,onRequest:async(req,server)=>{beginRequestCapture(req);const snapshot=enterRequestScope(req);registerPeerSource(server);const{maintenanceGate,isApiBoundRequest:isApiBound,proxyToBackend,resolveRedirect,resolveRewrite}=await import("@stacksjs/server");const gated=await maintenanceGate(req);if(gated)return gated;const url=new URL(req.url);const redirected=resolveRedirect(url,redirectRules);if(redirected)return redirected;const rewritten=resolveRewrite(url.pathname,rewriteRules);if(rewritten){if(!apiBase){log.error(`No API target configured for ${url.pathname} (rewritten to ${rewritten}); refusing to proxy.`);return new Response("Bad Gateway",{status:502})}try{const target=new URL(`${rewritten}${url.search}`,url.origin);return await proxyToBackend(new Request(target,req),apiBase,undefined,req)}catch(error){log.error(`Rewrite of ${url.pathname} to ${rewritten} failed: ${error.message}`);return new Response("Bad Gateway",{status:502})}}const seoFile=await siteSeo(req);if(seoFile)return seoFile;if(isApiBound(req,url.pathname,apiProxyRules)){if(!apiBase){log.error(`No API target configured for ${url.pathname}. This app shares its host with other deployments, so there is no safe default port to guess - refusing to proxy. Set PORT_API (or API_URL) for this site, and deploy an \`api\` site on its own port.`);return new Response("Bad Gateway",{status:502})}try{return await proxyToBackend(req,apiBase)}catch(error){log.error(`API proxy to ${apiBase} failed: ${error.message}`);return new Response("Bad Gateway",{status:502})}}if(existsSync(join(process.cwd(),"resources/views/blog.stx"))){const{renderBlogFeed}=await import("@stacksjs/actions/blog");const feed=await renderBlogFeed(req);if(feed)return feed}if(config.analytics?.capturePageviews){import("@stacksjs/analytics").then(({recordPageview})=>recordPageview(req)).catch(()=>{})}if(config.sites?.enabled){const sites=await import("@stacksjs/sites");const resolved=await sites.resolveSiteByHost(sites.requestHost(req.headers,sites.sitesOptions()));sites.setCurrentSite(resolved);snapshot.site=sites.toSiteSnapshot(resolved)}return},onResponse:async(req,response)=>{const securityResponse=applyViewSecurityHeaders(req,response,embeddableRules);const secured=applyResponseHeaders(req,securityResponse??response,config.server?.headers)??securityResponse;const method=req.method.toUpperCase();if(method!=="GET"&&method!=="HEAD"){finishRequestCapture(req,secured??response);return secured}const baseline=secured??response;let current=baseline;if(current.status===404&&config.sites?.enabled&&feature("cms")){try{const{cmsNotFoundFallback}=await import("@stacksjs/cms");const cmsResponse=await cmsNotFoundFallback(req);if(cmsResponse)current=cmsResponse}catch(error){log.debug(`CMS fallback skipped: ${error.message}`)}}let finished;try{const{seedCsrfCookieIfMissing}=await import(resolveCsrfMiddlewarePath());finished=await seedCsrfCookieIfMissing(req,current)??(current===baseline?secured:current)}catch(error){log.debug(`CSRF cookie seeding skipped: ${error.message}`);finished=current===baseline?secured:current}if(!documentCacheControl){finishRequestCapture(req,finished??response);return finished}const cached=applyDocumentCacheControl(req,finished??response,documentCacheControl);finishRequestCapture(req,cached??finished??response);return cached}});log.success(`Production server listening on http://0.0.0.0:${port}`)}export function buildDocumentCacheControl(documents){if(!documents)return;const maxAge=Number(documents.maxAge??0);if(!Number.isFinite(maxAge)||maxAge<=0)return;const stale=Number(documents.staleWhileRevalidate??0);const parts=[`public`,`max-age=${Math.floor(maxAge)}`];if(Number.isFinite(stale)&&stale>0)parts.push(`stale-while-revalidate=${Math.floor(stale)}`);return parts.join(", ")}export function isAuthenticatedRequest(request){if(request.headers.get("authorization"))return true;const cookie=request.headers.get("cookie")||"";if(!cookie)return false;return cookie.split(";").map((part)=>part.trim().split("=")[0]?.toLowerCase()??"").some((name)=>name!==""&&!name.includes("csrf")&&/session|auth|token|remember/.test(name))}const SPA_NAV_REQUEST_HEADER="X-STX-Router";const SPA_NAV_FRAGMENT_HEADER="X-STX-Fragment";export function isSpaFragmentExchange(request,response){return request.headers.get(SPA_NAV_REQUEST_HEADER)==="true"||response.headers.get(SPA_NAV_FRAGMENT_HEADER)==="true"}export function applyDocumentCacheControl(request,response,cacheControl){if(!cacheControl)return response;const contentType=response.headers.get("content-type")||"";if(response.status!==200||!contentType.startsWith("text/html"))return response;if(isSpaFragmentExchange(request,response))return response;if(response.headers.getSetCookie().length>0)return response;if(isAuthenticatedRequest(request))return response;const headers=new Headers(response.headers);headers.set("cache-control",cacheControl);return new Response(response.body,{status:response.status,statusText:response.statusText,headers})}async function resolveVendoredStxModule(){const source=resolveStxSource({value:process.env.STACKS_STX_SRC});if(source.kind==="missing"){await log.exit(`STACKS_STX_SRC points at ${source.path}, which does not exist. Unset it to use the installed @stacksjs/stx.`,ExitCode.FatalError)}if(source.kind==="override"){log.warn(`Rendering through ${source.path} instead of the installed @stacksjs/stx.`);return await import(source.path)}try{return await import("@stacksjs/stx")}catch{}return}function fallbackI18nFromSite(site){const locales=site.i18n.locales;const defaultLocale=site.i18n.defaultLocale??locales[0];return{locales,defaultLocale,labels:site.i18n.labels??Object.fromEntries(locales.map((c)=>[c,c.toUpperCase()])),translations:{},pickerSelector:site.i18n.pickerSelector??"#lang-picker"}}async function resolveSiteI18n(site){try{const resolved=await resolveVendoredStxModule();if(typeof resolved?.resolveI18n==="function"){const i18n=resolved.resolveI18n(site,process.cwd());if(i18n)return i18n}}catch{}return fallbackI18nFromSite(site)}async function loadStxSiteConfig(){const sitePath=siteConfigPath();if(!existsSync(sitePath))return{};try{const mod=await import(sitePath);const site=mod.default??mod.site??mod.config;if(!site)return{};if(!site.i18n)return{site};const i18n=await resolveSiteI18n(site);return{site,i18n}}catch{}return{}}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** The subject of the commit `buddy new` leaves behind. Conventional, since the app's own gitlint hook expects it. */
|
|
2
|
+
export declare function scaffoldCommitMessage(appName: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* Commit everything in `root` that git does not ignore, as one commit.
|
|
5
|
+
*
|
|
6
|
+
* Resolves to `null` once the commit exists, or to why it does not: `root` is
|
|
7
|
+
* not a repository, the repository already has a history (it is somebody's,
|
|
8
|
+
* and this must not add to it), or git refused, which on a new machine means
|
|
9
|
+
* no `user.name` and `user.email`.
|
|
10
|
+
*
|
|
11
|
+
* `--no-verify` because the hooks belong to the app's own later commits. This
|
|
12
|
+
* one holds only generated files, and a lint finding in a template is not a
|
|
13
|
+
* reason to leave a new app with no history at all.
|
|
14
|
+
*/
|
|
15
|
+
export declare function commitScaffold(root: string, appName: string): string | null;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import process from"node:process";export function scaffoldCommitMessage(appName){return`chore: scaffold ${appName} with buddy new`}function git(cwd,args){const result=Bun.spawnSync(["git",...args],{cwd,env:process.env,stdout:"pipe",stderr:"pipe"});return{ok:result.exitCode===0,output:`${result.stdout.toString()}${result.stderr.toString()}`.trim()}}export function commitScaffold(root,appName){if(!git(root,["rev-parse","--git-dir"]).ok)return"not a git repository";if(git(root,["rev-parse","--verify","--quiet","HEAD"]).ok)return"the repository already has commits";const staged=git(root,["add","--all"]);if(!staged.ok)return staged.output||"git add failed";const committed=git(root,["commit","--no-verify","--quiet","-m",scaffoldCommitMessage(appName)]);if(!committed.ok)return firstLine(committed.output)||"git commit failed";return null}function firstLine(text){return text.split(`
|
|
2
|
+
`).find((line)=>line.trim().length>0)?.trim()??""}
|
|
@@ -6,6 +6,22 @@ export declare function appPackageScripts(scripts: Record<string, string>): Scri
|
|
|
6
6
|
* scripts in `storage/framework/package.json` that publish the framework.
|
|
7
7
|
*/
|
|
8
8
|
export declare function applyAppPackageScripts(root: string): ScriptChanges;
|
|
9
|
+
/**
|
|
10
|
+
* The `overrides` an app keeps from the template: all but the framework's
|
|
11
|
+
* hold on the STX packages.
|
|
12
|
+
*
|
|
13
|
+
* The framework repository overrides those to one release because it is a
|
|
14
|
+
* workspace: on a fresh install each of its packages would otherwise resolve
|
|
15
|
+
* its own range of STX, and they would not agree. An app has no such
|
|
16
|
+
* workspace. It declares the STX packages it wants as ordinary dependencies,
|
|
17
|
+
* and the framework's packages, which ask for that release or newer, resolve
|
|
18
|
+
* to the same copy. Carried into an app, the override does one thing: it stops
|
|
19
|
+
* the app choosing a newer STX without also editing the override
|
|
20
|
+
* (stacksjs/stacks#3260).
|
|
21
|
+
*/
|
|
22
|
+
export declare function appPackageOverrides(overrides: Record<string, unknown>): { overrides: Record<string, unknown>, removed: string[] };
|
|
23
|
+
/** Apply {@link appPackageOverrides} to the root package.json. Returns what was removed. */
|
|
24
|
+
export declare function applyAppPackageOverrides(root: string): string[];
|
|
9
25
|
/**
|
|
10
26
|
* Strip the framework's author, sponsor link and repository from the
|
|
11
27
|
* workspace manifests an app keeps under `storage/framework` (the root one,
|
|
@@ -52,6 +68,11 @@ export declare const VENDORED_DEFAULTS: 'storage/framework/defaults';
|
|
|
52
68
|
* repository, so a moved file cannot quietly start shipping again.
|
|
53
69
|
*/
|
|
54
70
|
export declare const FRAMEWORK_ONLY_PATHS: readonly ['bench', 'logsmith.config.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
|
+
/**
|
|
72
|
+
* The STX runtime packages, released together at one version: the runtime,
|
|
73
|
+
* its components, its compiler, and the three the runtime itself pulls in.
|
|
74
|
+
*/
|
|
75
|
+
export declare const STX_RUNTIME_PACKAGES: readonly string[];
|
|
55
76
|
export declare interface ScriptChanges {
|
|
56
77
|
scripts: Record<string, string>
|
|
57
78
|
removed: string[]
|
|
@@ -1,6 +1,7 @@
|
|
|
1
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","logsmith.config.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){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
|
-
`)}return changes}const
|
|
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
|
+
`);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)}
|
|
4
5
|
`);touched.push(relative(root,file))}return touched}const CORE_CONTENT_PATHS=[{file:"config/css.ts",from:"'./storage/framework/core/error-handling/src/views/**/*.{stx,html}'",to:"'./node_modules/@stacksjs/error-handling/dist/views/**/*.{stx,html}'"}];export function rewriteCoreContentPaths(root){const touched=[];for(const{file,from,to}of CORE_CONTENT_PATHS){const full=join(root,file);if(!existsSync(full))continue;const raw=readFileSync(full,"utf8");if(!raw.includes(from))continue;writeFileSync(full,raw.replaceAll(from,to));touched.push(file)}return touched}export function applyPackageAppTsconfig(root){const source=join(root,"storage/framework/tsconfig.package-app.json");if(!existsSync(source))return false;cpSync(source,join(root,"storage/framework/tsconfig.app.json"));rmSync(source);return true}const SKIPPED_DIRECTORIES=new Set(["node_modules","pantry","dist","storage","public",".git",".cache",".stx","coverage"]);const SCANNED_EXTENSIONS=new Set([".ts",".tsx",".js",".mjs",".cjs",".stx"]);function projectSources(dir){let entries;try{entries=readdirSync(dir,{withFileTypes:true})}catch{return[]}return entries.flatMap((entry)=>{const full=join(dir,entry.name);if(entry.isDirectory())return SKIPPED_DIRECTORIES.has(entry.name)?[]:projectSources(full);return entry.isFile()&&SCANNED_EXTENSIONS.has(extname(entry.name))?[full]:[]})}const DEFAULTS_IMPORT=/(\bfrom\s+|\bimport\s*\(\s*|\brequire\s*\(\s*|^\s*import\s+)(['"])(?:~\/|(?:\.{1,2}\/)+)storage\/framework\/defaults\/([^'"]+)\2/gm;export function defaultsSpecifier(rest,hasFile=()=>false){if(!extname(rest)&&hasFile(`${rest}.ts`))return`@stacksjs/defaults/${rest}.ts`;return`@stacksjs/defaults/${rest}`}export function rewriteDefaultsImports(root,hasFile){const touched=[];for(const file of projectSources(root)){const raw=readFileSync(file,"utf8");if(!raw.includes("storage/framework/defaults/"))continue;const fileExists=file.endsWith(".stx")?()=>false:hasFile;const next=raw.replace(DEFAULTS_IMPORT,(_match,lead,quote,rest)=>`${lead}${quote}${defaultsSpecifier(rest,fileExists)}${quote}`);if(next!==raw){writeFileSync(file,next);touched.push(relative(root,file))}}return touched}const TS=".ts";const DEFAULTS_MODULE_PATHS=[{file:"bunfig.toml",from:`"./storage/framework/defaults/resources/plugins/preloader${TS}"`,to:'"@stacksjs/defaults/resources/plugins/preloader"'},{file:"config/ui.ts",from:`'./storage/framework/defaults/stx-components-plugin${TS}'`,to:`'@stacksjs/defaults/stx-components-plugin${TS}'`}];export function rewriteDefaultsModulePaths(root){const touched=[];for(const{file,from,to}of DEFAULTS_MODULE_PATHS){const full=join(root,file);if(!existsSync(full))continue;const raw=readFileSync(full,"utf8");if(!raw.includes(from))continue;writeFileSync(full,raw.replaceAll(from,to));touched.push(file)}return touched}const GITIGNORE_ENTRY=`/${VENDORED_DEFAULTS}`;const GITIGNORE_BLOCK=`
|
|
5
6
|
# The framework defaults: a link to node_modules/@stacksjs/defaults, made on
|
|
6
7
|
# boot. \`buddy publish:defaults\` replaces it with a copy you commit instead.
|
package/dist/scaffold-site.d.ts
CHANGED
|
@@ -31,3 +31,19 @@ export declare function applyAppSiteTemplate(root: string): string[];
|
|
|
31
31
|
export declare const SITE_ONLY_PATHS: readonly string[];
|
|
32
32
|
/** Where the app's own starter files live in the template, relative to the project root. */
|
|
33
33
|
export declare const APP_SITE_TEMPLATE: 'storage/framework/defaults/scaffold/resources';
|
|
34
|
+
/**
|
|
35
|
+
* What a new app keeps of the template's top level, with the reason for the
|
|
36
|
+
* entries that look like the framework's own.
|
|
37
|
+
*
|
|
38
|
+
* `scaffold-site.test.ts` holds this against the repository: a top-level path
|
|
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. `ops/` and `.reviewos/` reached every
|
|
41
|
+
* new app because nothing asked that question.
|
|
42
|
+
*/
|
|
43
|
+
export declare const APP_TOP_LEVEL: readonly string[];
|
|
44
|
+
/**
|
|
45
|
+
* Top-level paths `buddy new` deletes outside this module and
|
|
46
|
+
* `FRAMEWORK_ONLY_PATHS`, each named by the step in `commands/create.ts` that
|
|
47
|
+
* does it.
|
|
48
|
+
*/
|
|
49
|
+
export declare const REMOVED_BY_OTHER_STEPS: Readonly<Record<string, 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","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){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"]);function parentOf(relative){return relative.includes("/")?relative.slice(0,relative.lastIndexOf("/")):""}function isEmptyDir(dir){return existsSync(dir)&&readdirSync(dir).length===0}
|
|
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","ops",".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){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}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every installed copy of an STX package under `root/node_modules`, nested
|
|
3
|
+
* ones included, each real directory counted once.
|
|
4
|
+
*/
|
|
5
|
+
export declare function findStxCopies(root: string): StxCopy[];
|
|
6
|
+
/**
|
|
7
|
+
* What `buddy doctor` says about them. Null when STX is not installed at
|
|
8
|
+
* all, which is not this check's to report.
|
|
9
|
+
*/
|
|
10
|
+
export declare function describeStxCopies(copies: StxCopy[]): StxCopiesReport | null;
|
|
11
|
+
/** The STX packages, released together at one version. */
|
|
12
|
+
export declare const STX_PACKAGES: readonly string[];
|
|
13
|
+
/** The three an app declares; the rest follow the runtime. */
|
|
14
|
+
export declare const STX_DECLARED_PACKAGES: readonly string[];
|
|
15
|
+
export declare interface StxCopy {
|
|
16
|
+
name: string
|
|
17
|
+
version: string
|
|
18
|
+
path: string
|
|
19
|
+
}
|
|
20
|
+
export declare interface StxCopiesReport {
|
|
21
|
+
status: 'pass' | 'fail'
|
|
22
|
+
message: string
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync,readdirSync,readFileSync,realpathSync}from"node:fs";import{join}from"node:path";export const STX_PACKAGES=["@stacksjs/stx","@stacksjs/components","bun-plugin-stx","stx-router","@stacksjs/desktop","@stacksjs/sanitizer"];export const STX_DECLARED_PACKAGES=["@stacksjs/stx","@stacksjs/components","bun-plugin-stx"];function packagesIn(modules){let entries;try{entries=readdirSync(modules)}catch{return[]}const found=[];for(const entry of entries){if(entry===".bin"||entry===".cache")continue;const dir=join(modules,entry);if(entry.startsWith("@")){for(const scoped of packagesIn(dir))found.push({name:`${entry}/${scoped.name}`,dir:scoped.dir})}else{found.push({name:entry,dir})}}return found}export function findStxCopies(root){const copies=[];const seen=new Set;const visit=(modules)=>{for(const{name,dir}of packagesIn(modules)){let real;try{real=realpathSync(dir)}catch{continue}if(seen.has(real))continue;seen.add(real);if(name===".bun"){for(const stored of packagesIn(dir))visit(join(stored.dir,"node_modules"));continue}if(STX_PACKAGES.includes(name)){try{const manifest=JSON.parse(readFileSync(join(dir,"package.json"),"utf8"));if(manifest.name===name&&typeof manifest.version==="string")copies.push({name,version:manifest.version,path:dir.slice(root.length+1)})}catch{}}const nested=join(dir,"node_modules");if(existsSync(nested))visit(nested)}};visit(join(root,"node_modules"));return copies.sort((left,right)=>left.name.localeCompare(right.name)||left.version.localeCompare(right.version,undefined,{numeric:true}))}export function describeStxCopies(copies){if(copies.length===0)return null;const versions=[...new Set(copies.map((copy)=>copy.version))].sort((left,right)=>left.localeCompare(right,undefined,{numeric:true}));if(versions.length===1)return{status:"pass",message:`one copy, ${versions[0]}`};const split=STX_PACKAGES.map((name)=>({name,versions:[...new Set(copies.filter((copy)=>copy.name===name).map((copy)=>copy.version))]})).filter((entry)=>entry.versions.length>0).map((entry)=>`${entry.name} ${entry.versions.join(" and ")}`);return{status:"fail",message:`${versions.length} versions are installed (${split.join("; ")}). Two copies do not share routes or components, so pages can render with none. `+`Declare ${STX_DECLARED_PACKAGES.join(", ")} at one version in package.json, remove any override of them, and reinstall.`}}
|
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.541",
|
|
6
6
|
"description": "Meet Buddy. The Stacks runtime.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -95,73 +95,73 @@
|
|
|
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.541",
|
|
99
|
+
"@stacksjs/docs": "0.75.541",
|
|
100
|
+
"@stacksjs/ai": "0.75.541",
|
|
101
|
+
"@stacksjs/alias": "0.75.541",
|
|
102
|
+
"@stacksjs/analytics": "0.75.541",
|
|
103
|
+
"@stacksjs/api": "0.75.541",
|
|
104
|
+
"@stacksjs/arrays": "0.75.541",
|
|
105
|
+
"@stacksjs/auth": "0.75.541",
|
|
106
|
+
"@stacksjs/browser-extension": "0.75.541",
|
|
107
|
+
"@stacksjs/build": "0.75.541",
|
|
108
108
|
"@stacksjs/bumpx": "^0.2.26",
|
|
109
|
-
"@stacksjs/cache": "0.75.
|
|
110
|
-
"@stacksjs/chat": "0.75.
|
|
109
|
+
"@stacksjs/cache": "0.75.541",
|
|
110
|
+
"@stacksjs/chat": "0.75.541",
|
|
111
111
|
"@stacksjs/clapp": "^0.2.16",
|
|
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.541",
|
|
113
|
+
"@stacksjs/cloud": "0.75.541",
|
|
114
|
+
"@stacksjs/cms": "0.75.541",
|
|
115
|
+
"@stacksjs/collections": "0.75.541",
|
|
116
|
+
"@stacksjs/commerce": "0.75.541",
|
|
117
|
+
"@stacksjs/config": "0.75.541",
|
|
118
|
+
"@stacksjs/database": "0.75.541",
|
|
119
|
+
"@stacksjs/desktop-build": "0.75.541",
|
|
120
|
+
"@stacksjs/dns": "0.75.541",
|
|
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.541",
|
|
123
|
+
"@stacksjs/enums": "0.75.541",
|
|
124
|
+
"@stacksjs/env": "0.75.541",
|
|
125
|
+
"@stacksjs/error-handling": "0.75.541",
|
|
126
|
+
"@stacksjs/events": "0.75.541",
|
|
127
|
+
"@stacksjs/features": "0.75.541",
|
|
128
|
+
"@stacksjs/git": "0.75.541",
|
|
129
129
|
"@stacksjs/gitit": "^0.2.5",
|
|
130
|
-
"@stacksjs/health": "0.75.
|
|
130
|
+
"@stacksjs/health": "0.75.541",
|
|
131
131
|
"@stacksjs/httx": "^0.1.10",
|
|
132
|
-
"@stacksjs/image": "0.75.
|
|
133
|
-
"@stacksjs/lint": "0.75.
|
|
134
|
-
"@stacksjs/logging": "0.75.
|
|
135
|
-
"@stacksjs/notifications": "0.75.
|
|
136
|
-
"@stacksjs/objects": "0.75.
|
|
137
|
-
"@stacksjs/orm": "0.75.
|
|
138
|
-
"@stacksjs/path": "0.75.
|
|
139
|
-
"@stacksjs/payments": "0.75.
|
|
140
|
-
"@stacksjs/realtime": "0.75.
|
|
141
|
-
"@stacksjs/router": "0.75.
|
|
132
|
+
"@stacksjs/image": "0.75.541",
|
|
133
|
+
"@stacksjs/lint": "0.75.541",
|
|
134
|
+
"@stacksjs/logging": "0.75.541",
|
|
135
|
+
"@stacksjs/notifications": "0.75.541",
|
|
136
|
+
"@stacksjs/objects": "0.75.541",
|
|
137
|
+
"@stacksjs/orm": "0.75.541",
|
|
138
|
+
"@stacksjs/path": "0.75.541",
|
|
139
|
+
"@stacksjs/payments": "0.75.541",
|
|
140
|
+
"@stacksjs/realtime": "0.75.541",
|
|
141
|
+
"@stacksjs/router": "0.75.541",
|
|
142
142
|
"@stacksjs/rpx": "^0.11.54",
|
|
143
|
-
"@stacksjs/scheduler": "0.75.
|
|
144
|
-
"@stacksjs/search-engine": "0.75.
|
|
145
|
-
"@stacksjs/security": "0.75.
|
|
146
|
-
"@stacksjs/server": "0.75.
|
|
147
|
-
"@stacksjs/sites": "0.75.
|
|
148
|
-
"@stacksjs/skills": "0.75.
|
|
149
|
-
"@stacksjs/socials": "0.75.
|
|
150
|
-
"@stacksjs/storage": "0.75.
|
|
151
|
-
"@stacksjs/strings": "0.75.
|
|
152
|
-
"@stacksjs/stx": "0.2.842",
|
|
153
|
-
"@stacksjs/testing": "0.75.
|
|
154
|
-
"@stacksjs/tinker": "0.75.
|
|
143
|
+
"@stacksjs/scheduler": "0.75.541",
|
|
144
|
+
"@stacksjs/search-engine": "0.75.541",
|
|
145
|
+
"@stacksjs/security": "0.75.541",
|
|
146
|
+
"@stacksjs/server": "0.75.541",
|
|
147
|
+
"@stacksjs/sites": "0.75.541",
|
|
148
|
+
"@stacksjs/skills": "0.75.541",
|
|
149
|
+
"@stacksjs/socials": "0.75.541",
|
|
150
|
+
"@stacksjs/storage": "0.75.541",
|
|
151
|
+
"@stacksjs/strings": "0.75.541",
|
|
152
|
+
"@stacksjs/stx": "^0.2.842",
|
|
153
|
+
"@stacksjs/testing": "0.75.541",
|
|
154
|
+
"@stacksjs/tinker": "0.75.541",
|
|
155
155
|
"@stacksjs/tlsx": "^0.13.19",
|
|
156
156
|
"@stacksjs/ts-cloud": "^0.16.109",
|
|
157
|
-
"@stacksjs/tunnel": "0.75.
|
|
158
|
-
"@stacksjs/types": "0.75.
|
|
159
|
-
"@stacksjs/ui": "0.75.
|
|
160
|
-
"@stacksjs/utils": "0.75.
|
|
161
|
-
"@stacksjs/validation": "0.75.
|
|
157
|
+
"@stacksjs/tunnel": "0.75.541",
|
|
158
|
+
"@stacksjs/types": "0.75.541",
|
|
159
|
+
"@stacksjs/ui": "0.75.541",
|
|
160
|
+
"@stacksjs/utils": "0.75.541",
|
|
161
|
+
"@stacksjs/validation": "0.75.541",
|
|
162
162
|
"ajv": "^8.20.0",
|
|
163
163
|
"ajv-formats": "^3.0.1",
|
|
164
|
-
"bun-plugin-stx": "0.2.842",
|
|
164
|
+
"bun-plugin-stx": "^0.2.842",
|
|
165
165
|
"ts-pantry": "^0.11.184"
|
|
166
166
|
},
|
|
167
167
|
"devDependencies": {
|