@stacksjs/buddy 0.75.561 → 0.75.568
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/hq.d.ts +11 -0
- package/dist/commands/hq.js +1 -0
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.js +1 -1
- package/dist/hq.d.ts +115 -0
- package/dist/hq.js +1 -0
- package/dist/lazy-commands.js +1 -1
- package/package.json +57 -56
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CLI } from '@stacksjs/types';
|
|
2
|
+
/**
|
|
3
|
+
* Write entries to the app's `.env`, and only there.
|
|
4
|
+
*
|
|
5
|
+
* A file that already encrypts its values gets these encrypted too; a plain
|
|
6
|
+
* file stays plain, because encrypting one value would start a keypair the
|
|
7
|
+
* rest of the file does not use. Nothing here prints: `setEnv` answers a
|
|
8
|
+
* summary that names the key, and it is dropped rather than shown.
|
|
9
|
+
*/
|
|
10
|
+
export declare function writeEnvEntries(entries: Record<string, string>, directory: string): Promise<void>;
|
|
11
|
+
export declare function hq(buddy: CLI): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{existsSync,readFileSync}from"node:fs";import{join}from"node:path";import process from"node:process";import{defineCommand}from"@stacksjs/cli";import{HQ_SERVICE_NAMES,resolveHqServices,runHqConnect,runHqStatus}from"../hq";async function hqConfig(){const{config,overridesReady}=await import("@stacksjs/config");await overridesReady.catch(()=>{});return{config:config.services??{},app:String(config.app?.name||"app")}}function browserCommand(url){if(process.platform==="darwin")return["open",url];if(process.platform==="win32")return["cmd","/c","start","",url];return["xdg-open",url]}function openBrowser(url){if(!process.stdout.isTTY||process.env.CI)return;Bun.spawn(browserCommand(url),{stdin:"ignore",stdout:"ignore",stderr:"ignore"}).unref()}function sleep(ms,signal){return new Promise((resolve)=>{if(signal?.aborted)return resolve();const done=()=>{clearTimeout(timer);signal?.removeEventListener("abort",done);resolve()};const timer=setTimeout(done,ms);signal?.addEventListener("abort",done,{once:true})})}export async function writeEnvEntries(entries,directory){const{envHasCiphertext,setEnv}=await import("@stacksjs/env");const file=join(directory,".env");const content=existsSync(file)?readFileSync(file,"utf8"):"";const plain=!envHasCiphertext(content);for(const[key,value]of Object.entries(entries)){const result=setEnv(key,value,{cwd:directory,plain});if(!result.success)throw new Error(result.error??`could not set ${key}`);process.env[key]=value}}function deps(signal){return{fetch:(input,init)=>fetch(input,init),print:(line)=>console.log(line),open:openBrowser,sleep,now:()=>Date.now(),writeEnv:async(entries)=>{const{projectPath}=await import("@stacksjs/path");await writeEnvEntries(entries,projectPath())},signal}}const connect=defineCommand({name:"hq:connect [...services]",description:"Connect this app to HQ services (BugHQ and LogHQ by default) and write their keys to .env",options:{"--no-open":"Print the approve link without opening the browser","--no-verify":"Skip sending a test log and a test error and reading them back","--timeout <seconds>":{description:"How long to wait for each approval",default:600}},examples:["buddy hq:connect","buddy hq:connect loghq","buddy hq:connect bughq loghq --no-open"],handle:async(options,...args)=>{const requested=args.flat().filter((value)=>typeof value==="string");const resolved=resolveHqServices(requested);if("error"in resolved){console.error(resolved.error);process.exit(1)}const flags=options;const seconds=Number(flags.timeout);const{config,app}=await hqConfig();const controller=new AbortController;const cancel=()=>controller.abort();process.once("SIGINT",cancel);try{const result=await runHqConnect(resolved.services,config,{app,open:flags.open!==false,verify:flags.verify!==false,timeoutMs:(Number.isFinite(seconds)&&seconds>0?seconds:600)*1000},deps(controller.signal));process.exit(controller.signal.aborted?130:result.ok?0:1)}finally{process.off("SIGINT",cancel)}}});const status=defineCommand({name:"hq:status",description:"Show usage against the allowance of each connected HQ service",examples:["buddy hq:status"],handle:async()=>{const{config}=await hqConfig();await runHqStatus(config,deps(),HQ_SERVICE_NAMES);process.exit(0)}});export function hq(buddy){connect(buddy);status(buddy)}
|
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"./license";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";
|
|
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"./hq";export*from"./http";export*from"./install";export*from"./key";export*from"./license";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";
|
package/dist/hq.d.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { HqServiceName, HqServicesConfig } from '@stacksjs/types';
|
|
2
|
+
import type { HqUnavailable } from '@stacksjs/hq/client';
|
|
3
|
+
/** Normalise what was typed after `hq:connect` into service names, or say which one is unknown. */
|
|
4
|
+
export declare function resolveHqServices(requested: readonly string[], fallback?: HqServiceName[]): { services: HqServiceName[] } | { error: string };
|
|
5
|
+
/** Why a read came back empty, for the person at the terminal. */
|
|
6
|
+
export declare function describeUnavailable(result: HqUnavailable): string;
|
|
7
|
+
export declare function renderTable(headers: string[], rows: string[][]): string[];
|
|
8
|
+
export declare function connectTable(outcomes: HqConnectOutcome[]): string[];
|
|
9
|
+
/**
|
|
10
|
+
* Connect each service in turn. A service that fails, or has not shipped the
|
|
11
|
+
* contract, never stops the ones after it; only a cancel does.
|
|
12
|
+
*/
|
|
13
|
+
export declare function runHqConnect(services: HqServiceName[], config: HqServicesConfig, options: HqConnectOptions, deps: HqCliDeps): Promise<HqConnectResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Where a ReportsHQ licence stands, without a network call and without
|
|
16
|
+
* showing the key. Shape only: whether a licence is current is a question
|
|
17
|
+
* ReportsHQ deliberately never asks a server.
|
|
18
|
+
*/
|
|
19
|
+
export declare function describeReportsHqLicense(license: string | undefined): string;
|
|
20
|
+
/** Usage against each connected service's allowance. A service with no read key is not connected and is left out. */
|
|
21
|
+
export declare function runHqStatus(config: HqServicesConfig, deps: Pick<HqCliDeps, 'fetch' | 'print'>, services?: HqServiceName[]): Promise<HqStatusRow[]>;
|
|
22
|
+
/**
|
|
23
|
+
* @defaultValue
|
|
24
|
+
* ```ts
|
|
25
|
+
* {
|
|
26
|
+
* bughq: {
|
|
27
|
+
* label: 'BugHQ',
|
|
28
|
+
* env: { key: 'BUGHQ_KEY', readKey: 'BUGHQ_READ_KEY', project: 'BUGHQ_PROJECT_ID' },
|
|
29
|
+
* verify: 'error'
|
|
30
|
+
* },
|
|
31
|
+
* loghq: {
|
|
32
|
+
* label: 'LogHQ',
|
|
33
|
+
* env: { key: 'LOGHQ_KEY', readKey: 'LOGHQ_READ_KEY', project: 'LOGHQ_PROJECT_ID' },
|
|
34
|
+
* verify: 'log'
|
|
35
|
+
* },
|
|
36
|
+
* analyticshq: {
|
|
37
|
+
* label: 'AnalyticsHQ',
|
|
38
|
+
* env: { readKey: 'ANALYTICSHQ_READ_KEY', project: 'ANALYTICSHQ_SITE_ID' }
|
|
39
|
+
* },
|
|
40
|
+
* statushq: {
|
|
41
|
+
* label: 'StatusHQ',
|
|
42
|
+
* env: { key: 'STATUSHQ_KEY', readKey: 'STATUSHQ_READ_KEY' }
|
|
43
|
+
* },
|
|
44
|
+
* commshq: { label: 'CommsHQ', env: { key: 'COMMSHQ_KEY', readKey: 'COMMSHQ_READ_KEY' } },
|
|
45
|
+
* reportshq: { label: 'ReportsHQ', env: { license: 'REPORTSHQ_LICENSE' } }
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare const HQ_SERVICES: Record<HqServiceName, HqServiceDescriptor>;
|
|
50
|
+
export declare const HQ_SERVICE_NAMES: HqServiceName[];
|
|
51
|
+
/** The services `hq:connect` asks when none is named: the two that have shipped the contract. */
|
|
52
|
+
export declare const HQ_DEFAULT_SERVICES: HqServiceName[];
|
|
53
|
+
/**
|
|
54
|
+
* What `buddy hq:connect` and `buddy hq:status` do, kept apart from the
|
|
55
|
+
* command file so it runs against a fake service in tests: everything that
|
|
56
|
+
* touches the network, the browser, the clock, the terminal or `.env` arrives
|
|
57
|
+
* through `HqCliDeps`.
|
|
58
|
+
*
|
|
59
|
+
* One rule governs the output: a key is never printed. Keys go from the
|
|
60
|
+
* service's answer into `writeEnv` and into request headers, and nowhere else.
|
|
61
|
+
*/
|
|
62
|
+
export declare interface HqServiceDescriptor {
|
|
63
|
+
label: string
|
|
64
|
+
env: { key?: string, readKey?: string, project?: string, license?: string }
|
|
65
|
+
verify?: 'log' | 'error'
|
|
66
|
+
}
|
|
67
|
+
export declare interface HqCliDeps {
|
|
68
|
+
fetch: (input: string, init?: RequestInit) => Promise<Response>
|
|
69
|
+
print: (line: string) => void
|
|
70
|
+
open: (url: string) => void | Promise<void>
|
|
71
|
+
sleep: (ms: number, signal?: AbortSignal) => Promise<void>
|
|
72
|
+
now: () => number
|
|
73
|
+
writeEnv: (entries: Record<string, string>) => Promise<void>
|
|
74
|
+
signal?: AbortSignal
|
|
75
|
+
}
|
|
76
|
+
export declare interface HqConnectOptions {
|
|
77
|
+
app: string
|
|
78
|
+
open?: boolean
|
|
79
|
+
verify?: boolean
|
|
80
|
+
timeoutMs?: number
|
|
81
|
+
pollIntervalMs?: number
|
|
82
|
+
readAttempts?: number
|
|
83
|
+
}
|
|
84
|
+
export declare interface HqConnectOutcome {
|
|
85
|
+
service: HqServiceName
|
|
86
|
+
status: HqConnectStatus
|
|
87
|
+
detail?: string
|
|
88
|
+
project?: string
|
|
89
|
+
dashboardUrl?: string
|
|
90
|
+
send: HqCheck
|
|
91
|
+
read: HqCheck
|
|
92
|
+
}
|
|
93
|
+
export declare interface HqConnectResult {
|
|
94
|
+
outcomes: HqConnectOutcome[]
|
|
95
|
+
ok: boolean
|
|
96
|
+
}
|
|
97
|
+
export declare interface HqStatusRow {
|
|
98
|
+
service: HqServiceName
|
|
99
|
+
meter?: string
|
|
100
|
+
used?: number
|
|
101
|
+
limit?: number | null
|
|
102
|
+
period?: string
|
|
103
|
+
state?: string
|
|
104
|
+
upgradeUrl?: string
|
|
105
|
+
unavailable?: string
|
|
106
|
+
}
|
|
107
|
+
export type HqConnectStatus = | 'connected'
|
|
108
|
+
/** The service answered 404 on the connect route: it has not shipped the contract. */
|
|
109
|
+
| 'unavailable'
|
|
110
|
+
| 'unreachable'
|
|
111
|
+
| 'expired'
|
|
112
|
+
| 'timeout'
|
|
113
|
+
| 'cancelled'
|
|
114
|
+
| 'failed';
|
|
115
|
+
export type HqCheck = 'pass' | 'fail' | 'skipped';
|
package/dist/hq.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createHqClient}from"@stacksjs/hq/client";export const HQ_SERVICES={bughq:{label:"BugHQ",env:{key:"BUGHQ_KEY",readKey:"BUGHQ_READ_KEY",project:"BUGHQ_PROJECT_ID"},verify:"error"},loghq:{label:"LogHQ",env:{key:"LOGHQ_KEY",readKey:"LOGHQ_READ_KEY",project:"LOGHQ_PROJECT_ID"},verify:"log"},analyticshq:{label:"AnalyticsHQ",env:{readKey:"ANALYTICSHQ_READ_KEY",project:"ANALYTICSHQ_SITE_ID"}},statushq:{label:"StatusHQ",env:{key:"STATUSHQ_KEY",readKey:"STATUSHQ_READ_KEY"}},commshq:{label:"CommsHQ",env:{key:"COMMSHQ_KEY",readKey:"COMMSHQ_READ_KEY"}},reportshq:{label:"ReportsHQ",env:{license:"REPORTSHQ_LICENSE"}}};export const HQ_SERVICE_NAMES=Object.keys(HQ_SERVICES);export const HQ_DEFAULT_SERVICES=["bughq","loghq"];const REQUEST_TIMEOUT_MS=1e4;function isRecord(value){return typeof value==="object"&&value!==null&&!Array.isArray(value)}function origin(url){return url.replace(/\/+$/,"")}function httpUrl(value,base){if(typeof value!=="string"||!value)return null;try{const url=new URL(value,base);return url.protocol==="https:"||url.protocol==="http:"?url.toString():null}catch{return null}}function toGrant(body,base,licensed){const project=body.project;if(!isRecord(project)||project.id==null)return null;if(licensed){if(typeof body.licenseKey!=="string"||!body.licenseKey)return null;return{project:{id:String(project.id),name:String(project.name??project.id)},ingestKey:"",readKey:"",licenseKey:body.licenseKey,dashboardUrl:httpUrl(body.dashboardUrl,base)??""}}if(typeof body.ingestKey!=="string"||typeof body.readKey!=="string")return null;if(!body.ingestKey||!body.readKey)return null;return{project:{id:String(project.id),name:String(project.name??project.id)},ingestKey:body.ingestKey,readKey:body.readKey,dashboardUrl:httpUrl(body.dashboardUrl,base)??""}}async function request(deps,url,init={}){const signals=[AbortSignal.timeout(REQUEST_TIMEOUT_MS),...deps.signal?[deps.signal]:[]];try{return await deps.fetch(url,{...init,signal:AbortSignal.any(signals)})}catch{return null}}function retryAfterMs(response,fallback){const seconds=Number(response.headers.get("retry-after"));return Number.isFinite(seconds)&&seconds>0?Math.min(seconds,60)*1000:fallback}export function resolveHqServices(requested,fallback=HQ_DEFAULT_SERVICES){const names=requested.map((name)=>name.trim().toLowerCase()).filter(Boolean);if(!names.length)return{services:[...fallback]};const unknown=names.filter((name)=>!(name in HQ_SERVICES));if(unknown.length)return{error:`Unknown service: ${unknown.join(", ")}. Choose from ${HQ_SERVICE_NAMES.join(", ")}.`};return{services:[...new Set(names)]}}async function connectOne(service,url,options,deps){const{label}=HQ_SERVICES[service];const base=origin(url);const outcome=(status,detail)=>({outcome:{service,status,detail,send:"skipped",read:"skipped"}});const started=await request(deps,`${base}/api/cli/connect`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({app:options.app})});if(deps.signal?.aborted)return outcome("cancelled","cancelled");if(!started)return outcome("unreachable",`could not reach ${base}`);if(started.status===404||started.status===405)return outcome("unavailable","not available yet");if(started.status===429)return outcome("failed","too many requests, try again in a minute");if(!started.ok)return outcome("failed",`the service answered ${started.status}`);const body=await started.json().catch(()=>null);const code=isRecord(body)&&typeof body.code==="string"&&/^[\w-]{16,128}$/.test(body.code)?body.code:null;const approveUrl=isRecord(body)?httpUrl(body.approveUrl,base):null;if(!code||!approveUrl)return outcome("failed","the service answered something that is not a connect code");const confirmCode=isRecord(body)&&typeof body.confirmCode==="string"&&/^[\w-]{1,32}$/.test(body.confirmCode)?body.confirmCode:null;deps.print("");deps.print(`${label}: approve this connection in your browser`);deps.print(` ${approveUrl}`);if(confirmCode)deps.print(` Confirmation code: ${confirmCode} (type it on that page)`);deps.print(" If the page asks you to sign in, sign in and open the link again.");deps.print(" Waiting for approval. Press Ctrl+C to cancel.");if(options.open!==false){try{await deps.open(approveUrl)}catch{}}const interval=options.pollIntervalMs??2000;const deadline=deps.now()+(options.timeoutMs??10*60*1000);const pollUrl=`${base}/api/cli/connect/${encodeURIComponent(code)}`;while(true){if(deps.signal?.aborted)return outcome("cancelled","cancelled");if(deps.now()>=deadline)return outcome("timeout","nobody approved it in time");await deps.sleep(Math.min(interval,Math.max(0,deadline-deps.now())),deps.signal);if(deps.signal?.aborted)return outcome("cancelled","cancelled");const polled=await request(deps,pollUrl,{headers:{Accept:"application/json"}});if(!polled)continue;if(polled.status===429){await deps.sleep(retryAfterMs(polled,interval),deps.signal);continue}if(polled.status===404)return outcome("expired","the request expired, run the command again");if(!polled.ok)return outcome("failed",`the service answered ${polled.status}`);const answer=await polled.json().catch(()=>null);if(!isRecord(answer)||answer.status==="pending")continue;if(answer.status==="expired")return outcome("expired","the request expired, run the command again");const grant=toGrant(answer,base,Boolean(HQ_SERVICES[service].env.license));if(!grant)return outcome("failed","the service approved the request without sending keys");return{grant,outcome:{service,status:"connected",project:grant.project.name,dashboardUrl:grant.dashboardUrl||undefined,send:"skipped",read:"skipped"}}}}function envEntries(service,grant){const names=HQ_SERVICES[service].env;const entries={};if(names.license&&grant.licenseKey)return{[names.license]:grant.licenseKey};if(names.key)entries[names.key]=grant.ingestKey;if(names.readKey)entries[names.readKey]=grant.readKey;if(names.project)entries[names.project]=grant.project.id;return entries}async function verify(service,url,grant,options,deps){const kind=HQ_SERVICES[service].verify;if(!kind)return{send:"skipped",read:"skipped"};const base=origin(url);const marker=`hq-connect-${crypto.randomUUID().slice(0,8)}`;const message=`buddy hq:connect test ${marker}`;const timestamp=new Date(deps.now()).toISOString();const sent=kind==="log"?await request(deps,`${base}/logs`,{method:"POST",headers:{"Content-Type":"application/json","X-LogHQ-Key":grant.ingestKey},body:JSON.stringify({logs:[{level:"info",message,timestamp,context:{source:"buddy hq:connect"}}]})}):await request(deps,`${base}/errors`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:grant.ingestKey,type:"HqConnectTest",message,level:"info",environment:"hq-connect",timestamp,sdk:{name:"buddy.hq-connect"}})});if(!sent?.ok)return{send:"fail",read:"skipped",detail:sent?`sending the test ${kind} answered ${sent.status}`:`sending the test ${kind} did not get through`};const receipt=await sent.json().catch(()=>null);if(isRecord(receipt)&&(receipt.sampled===true||receipt.stored===0))return{send:"pass",read:"skipped",detail:`the plan allowance is used up, so the test ${kind} was not kept`};const client=createHqClient({services:{[service]:{url:base,readKey:grant.readKey,project:grant.project.id}},timeoutMs:REQUEST_TIMEOUT_MS,fetch:(input,init)=>deps.fetch(input,init)});let reason=`the test ${kind} was accepted but did not show up`;const attempts=options.readAttempts??5;for(let attempt=0;attempt<attempts;attempt++){if(attempt>0)await deps.sleep(1000,deps.signal);if(deps.signal?.aborted)return{send:"pass",read:"fail",detail:"cancelled"};if(kind==="log"){const page=await client.logs.list({search:marker,limit:5});if(page.ok&&page.data.logs.some((log)=>log.message.includes(marker)))return{send:"pass",read:"pass"};if(!page.ok)reason=describeUnavailable(page)}else{const list=await client.issues.list();if(list.ok&&list.data.some((issue)=>issue.title.includes(marker)))return{send:"pass",read:"pass"};if(!list.ok)reason=describeUnavailable(list)}}return{send:"pass",read:"fail",detail:reason}}export function describeUnavailable(result){switch(result.reason){case"not_configured":return"not connected";case"unauthorized":return"the read key was refused";case"timeout":return"the service did not answer in time";case"network":return"the service could not be reached";case"http":return result.status===404?"not available yet":`the service answered ${result.status}`;case"bad_response":return"the service answered something unexpected"}}export function renderTable(headers,rows){const widths=headers.map((header,column)=>Math.max(header.length,...rows.map((row)=>(row[column]??"").length)));const line=(cells)=>cells.map((cell,column)=>(cell??"").padEnd(widths[column])).join(" ").trimEnd();return[line(headers),line(widths.map((width)=>"-".repeat(width))),...rows.map(line)]}const CONNECT_WORDS={connected:"pass",unavailable:"not available yet",unreachable:"fail",expired:"fail",timeout:"fail",cancelled:"cancelled",failed:"fail"};const CHECK_WORDS={pass:"pass",fail:"fail",skipped:"-"};export function connectTable(outcomes){return renderTable(["Service","Connect","Send","Read back","Note"],outcomes.map((outcome)=>[HQ_SERVICES[outcome.service].label,CONNECT_WORDS[outcome.status],CHECK_WORDS[outcome.send],CHECK_WORDS[outcome.read],outcome.status==="unavailable"?"":outcome.detail??""]))}export async function runHqConnect(services,config,options,deps){const outcomes=[];for(const service of services){const{label}=HQ_SERVICES[service];if(deps.signal?.aborted){outcomes.push({service,status:"cancelled",detail:"cancelled",send:"skipped",read:"skipped"});continue}const url=config[service]?.url;if(!url){outcomes.push({service,status:"failed",detail:"no URL is configured in config/services.ts",send:"skipped",read:"skipped"});continue}const{outcome,grant}=await connectOne(service,url,options,deps);if(!grant){if(outcome.status==="unavailable")deps.print(`${label}: not available yet`);else if(outcome.status!=="cancelled")deps.print(`${label}: not connected (${outcome.detail})`);outcomes.push(outcome);continue}try{await deps.writeEnv(envEntries(service,grant))}catch(error){const why=error instanceof Error?error.message:"unknown error";deps.print(`${label}: approved, but the keys could not be written to .env (${why})`);outcomes.push({...outcome,status:"failed",detail:"the keys could not be written to .env"});continue}deps.print(grant.licenseKey?`${label}: licensed "${grant.project.name}". Licence written to .env.`:`${label}: connected to project "${grant.project.name}". Keys written to .env.`);if(grant.dashboardUrl)deps.print(` Dashboard: ${grant.dashboardUrl}`);if(options.verify===false){outcomes.push(outcome);continue}outcomes.push({...outcome,...await verify(service,url,grant,options,deps)})}if(deps.signal?.aborted)deps.print("Cancelled. Services already connected keep their keys.");deps.print("");for(const line of connectTable(outcomes))deps.print(line);const ok=outcomes.every((outcome)=>outcome.status==="unavailable"||outcome.status==="connected"&&outcome.send!=="fail"&&outcome.read!=="fail");return{outcomes,ok}}const count=(value)=>value.toLocaleString("en-US");const REPORTSHQ_LICENSE=/^rhq_lic_[0-9a-f]{32}$/;export function describeReportsHqLicense(license){if(!license)return"unlicensed. Reports work in full; set REPORTSHQ_LICENSE to remove the notice";return REPORTSHQ_LICENSE.test(license)?"licensed (checked offline, nothing is metered)":"the licence key is not in the expected format. Reports are unaffected"}export async function runHqStatus(config,deps,services=HQ_SERVICE_NAMES){const connected=services.filter((service)=>config[service]?.url&&config[service]?.readKey);const license=services.includes("reportshq")?config.reportshq?.license:undefined;if(!connected.length&&!license){deps.print("No HQ service is connected yet. Run `buddy hq:connect` to connect one.");return[]}const client=createHqClient({services:Object.fromEntries(connected.map((service)=>[service,{url:config[service].url,readKey:config[service].readKey}])),timeoutMs:REQUEST_TIMEOUT_MS,fetch:(input,init)=>deps.fetch(input,init)});const rows=[];for(const[index,usage]of(await Promise.all(connected.map((service)=>client.getUsage(service)))).entries()){const service=connected[index];if(!usage.ok){rows.push({service,unavailable:describeUnavailable(usage)});continue}if(!usage.data.length)rows.push({service,unavailable:"no meters reported"});for(const report of usage.data){const over=report.limit!==null&&report.limit>0&&report.used/report.limit>=0.8;rows.push({service,meter:report.meter,used:report.used,limit:report.limit,period:report.period,state:report.state,...over?{upgradeUrl:report.upgradeUrl}:{}})}}if(license)rows.push({service:"reportshq",unavailable:describeReportsHqLicense(license)});const table=renderTable(["Service","Meter","Used","Limit","Period","State"],rows.map((row)=>row.unavailable?[HQ_SERVICES[row.service].label,row.unavailable]:[HQ_SERVICES[row.service].label,row.meter,count(row.used),row.limit===null?"unlimited":count(row.limit),row.period,row.state]));for(const line of table)deps.print(line);const upgrades=rows.filter((row)=>row.upgradeUrl);if(upgrades.length)deps.print("");for(const row of upgrades){const percent=Math.round(row.used/row.limit*100);deps.print(`${HQ_SERVICES[row.service].label} ${row.meter} is at ${percent}% of its allowance. Upgrade: ${row.upgradeUrl}`)}return rows}
|
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:update:keypair":{path:"./commands/desktop-release.js",load:()=>import("./commands/desktop-release.js"),exportName:"desktopRelease"},"release:desktop":{path:"./commands/desktop-release.js",load:()=>import("./commands/desktop-release.js"),exportName:"desktopRelease"},"desktop:probe":{path:"./commands/desktop-probe.js",load:()=>import("./commands/desktop-probe.js"),exportName:"desktopProbe"},"integrations:probe":{path:"./commands/integrations-probe.js",load:()=>import("./commands/integrations-probe.js"),exportName:"integrationsProbe"},dns:{path:"./commands/dns.js",load:()=>import("./commands/dns.js"),exportName:"dns"},"dns:pull":{path:"./commands/dns.js",load:()=>import("./commands/dns.js"),exportName:"dns"},"dns:diff":{path:"./commands/dns.js",load:()=>import("./commands/dns.js"),exportName:"dns"},"dns:sync":{path:"./commands/dns.js",load:()=>import("./commands/dns.js"),exportName:"dns"},doctor:{path:"./commands/doctor.js",load:()=>import("./commands/doctor.js"),exportName:"doctor"},domains:{path:"./commands/domains.js",load:()=>import("./commands/domains.js"),exportName:"domains"},email:{path:"./commands/email.js",load:()=>import("./commands/email.js"),exportName:"email"},env:{path:"./commands/env.js",load:()=>import("./commands/env.js"),exportName:"env"},"extension:init":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:build":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:package":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:chrome:publish":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:chrome:status":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:firefox:publish":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:safari:init":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:safari:provision":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:safari:app":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:safari:publish":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"dashboard:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"dashboard:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"commerce:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"commerce:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"commerce:import":{path:"./commands/commerce-import.js",load:()=>import("./commands/commerce-import.js"),exportName:"commerceImport"},"cms:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"cms:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"marketing:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"marketing:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"monitoring:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"monitoring:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"realtime:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"realtime:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"queue:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"queue:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"db:backup":{path:"./commands/db.js",load:()=>import("./commands/db.js"),exportName:"db"},"db:backups":{path:"./commands/db.js",load:()=>import("./commands/db.js"),exportName:"db"},"db:restore":{path:"./commands/db.js",load:()=>import("./commands/db.js"),exportName:"db"},"storage:backup":{path:"./commands/storage-backup.js",load:()=>import("./commands/storage-backup.js"),exportName:"storageBackup"},"storage:backups":{path:"./commands/storage-backup.js",load:()=>import("./commands/storage-backup.js"),exportName:"storageBackup"},"storage:restore":{path:"./commands/storage-backup.js",load:()=>import("./commands/storage-backup.js"),exportName:"storageBackup"},"feedback:invite":{path:"./commands/feedback.js",load:()=>import("./commands/feedback.js"),exportName:"feedback"},"feedback:tokens":{path:"./commands/feedback.js",load:()=>import("./commands/feedback.js"),exportName:"feedback"},"feedback:revoke":{path:"./commands/feedback.js",load:()=>import("./commands/feedback.js"),exportName:"feedback"},"socials:identities":{path:"./commands/socials.js",load:()=>import("./commands/socials.js"),exportName:"socials"},"socials:authorize":{path:"./commands/socials.js",load:()=>import("./commands/socials.js"),exportName:"socials"},fresh:{path:"./commands/fresh.js",load:()=>import("./commands/fresh.js"),exportName:"fresh"},generate:{path:"./commands/generate.js",load:()=>import("./commands/generate.js"),exportName:"generate"},"gdpr:export":{path:"./commands/gdpr.js",load:()=>import("./commands/gdpr.js"),exportName:"gdpr"},"gdpr:erase":{path:"./commands/gdpr.js",load:()=>import("./commands/gdpr.js"),exportName:"gdpr"},"gdpr:prune":{path:"./commands/gdpr.js",load:()=>import("./commands/gdpr.js"),exportName:"gdpr"},"gdpr:register":{path:"./commands/gdpr.js",load:()=>import("./commands/gdpr.js"),exportName:"gdpr"},"gdpr:register:check":{path:"./commands/gdpr.js",load:()=>import("./commands/gdpr.js"),exportName:"gdpr"},http:{path:"./commands/http.js",load:()=>import("./commands/http.js"),exportName:"http"},install:{path:"./commands/install.js",load:()=>import("./commands/install.js"),exportName:"install"},key:{path:"./commands/key.js",load:()=>import("./commands/key.js"),exportName:"key"},license:{path:"./commands/license.js",load:()=>import("./commands/license.js"),exportName:"license"},"license:keygen":{path:"./commands/license.js",load:()=>import("./commands/license.js"),exportName:"license"},lint:{path:"./commands/lint.js",load:()=>import("./commands/lint.js"),exportName:"lint"},format:{path:"./commands/lint.js",load:()=>import("./commands/lint.js"),exportName:"lint"},"format:check":{path:"./commands/lint.js",load:()=>import("./commands/lint.js"),exportName:"lint"},libs:{path:"./commands/libs.js",load:()=>import("./commands/libs.js"),exportName:"libs"},libraries:{path:"./commands/libs.js",load:()=>import("./commands/libs.js"),exportName:"libs"},list:{path:"./commands/list.js",load:()=>import("./commands/list.js"),exportName:"list"},mail:{path:"./commands/mail.js",load:()=>import("./commands/mail.js"),exportName:"mailCommands"},"mail:preview":{path:"./commands/mail.js",load:()=>import("./commands/mail.js"),exportName:"mailCommands"},maintenance:{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},down:{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},up:{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},status:{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},"coming-soon":{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},"coming-soon:status":{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},launch:{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},make:{path:"./commands/make.js",load:()=>import("./commands/make.js"),exportName:"make"},"scaffold:crud":{path:"./commands/make.js",load:()=>import("./commands/make.js"),exportName:"make"},migrate:{path:"./commands/migrate.js",load:()=>import("./commands/migrate.js"),exportName:"migrate"},"migrate:fresh":{path:"./commands/migrate.js",load:()=>import("./commands/migrate.js"),exportName:"migrate"},"migrate:switch":{path:"./commands/migrate.js",load:()=>import("./commands/migrate.js"),exportName:"migrate"},"migrate:project":{path:"./commands/migrate-project.js",load:()=>import("./commands/migrate-project.js"),exportName:"migrateProject"},outdated:{path:"./commands/outdated.js",load:()=>import("./commands/outdated.js"),exportName:"outdated"},package:{path:"./commands/package.js",load:()=>import("./commands/package.js"),exportName:"packageCommands"},phone:{path:"./commands/phone.js",load:()=>import("./commands/phone.js"),exportName:"phone"},ports:{path:"./commands/ports.js",load:()=>import("./commands/ports.js"),exportName:"ports"},"security:scan":{path:"./commands/security.js",load:()=>import("./commands/security.js"),exportName:"security"},audit:{path:"./commands/security.js",load:()=>import("./commands/security.js"),exportName:"security"},"server:flash":{path:"./commands/server.js",load:()=>import("./commands/server.js"),exportName:"server"},"server:first-boot":{path:"./commands/server.js",load:()=>import("./commands/server.js"),exportName:"server"},"server:doctor":{path:"./commands/server.js",load:()=>import("./commands/server.js"),exportName:"server"},"server:setup":{path:"./commands/server.js",load:()=>import("./commands/server.js"),exportName:"server"},"server:trust":{path:"./commands/server.js",load:()=>import("./commands/server.js"),exportName:"server"},"link:core":{path:"./commands/link.js",load:()=>import("./commands/link.js"),exportName:"link"},"comments:list":{path:"./commands/comments.js",load:()=>import("./commands/comments.js"),exportName:"commentsCommands"},"comments:approve":{path:"./commands/comments.js",load:()=>import("./commands/comments.js"),exportName:"commentsCommands"},"comments:reject":{path:"./commands/comments.js",load:()=>import("./commands/comments.js"),exportName:"commentsCommands"},"comments:delete":{path:"./commands/comments.js",load:()=>import("./commands/comments.js"),exportName:"commentsCommands"},"user:add":{path:"./commands/user.js",load:()=>import("./commands/user.js"),exportName:"user"},"user:list":{path:"./commands/user.js",load:()=>import("./commands/user.js"),exportName:"user"},"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)}
|
|
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:update:keypair":{path:"./commands/desktop-release.js",load:()=>import("./commands/desktop-release.js"),exportName:"desktopRelease"},"release:desktop":{path:"./commands/desktop-release.js",load:()=>import("./commands/desktop-release.js"),exportName:"desktopRelease"},"desktop:probe":{path:"./commands/desktop-probe.js",load:()=>import("./commands/desktop-probe.js"),exportName:"desktopProbe"},"integrations:probe":{path:"./commands/integrations-probe.js",load:()=>import("./commands/integrations-probe.js"),exportName:"integrationsProbe"},dns:{path:"./commands/dns.js",load:()=>import("./commands/dns.js"),exportName:"dns"},"dns:pull":{path:"./commands/dns.js",load:()=>import("./commands/dns.js"),exportName:"dns"},"dns:diff":{path:"./commands/dns.js",load:()=>import("./commands/dns.js"),exportName:"dns"},"dns:sync":{path:"./commands/dns.js",load:()=>import("./commands/dns.js"),exportName:"dns"},doctor:{path:"./commands/doctor.js",load:()=>import("./commands/doctor.js"),exportName:"doctor"},domains:{path:"./commands/domains.js",load:()=>import("./commands/domains.js"),exportName:"domains"},email:{path:"./commands/email.js",load:()=>import("./commands/email.js"),exportName:"email"},env:{path:"./commands/env.js",load:()=>import("./commands/env.js"),exportName:"env"},"extension:init":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:build":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:package":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:chrome:publish":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:chrome:status":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:firefox:publish":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:safari:init":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:safari:provision":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:safari:app":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"extension:safari:publish":{path:"./commands/extension.js",load:()=>import("./commands/extension.js"),exportName:"extension"},"dashboard:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"dashboard:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"commerce:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"commerce:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"commerce:import":{path:"./commands/commerce-import.js",load:()=>import("./commands/commerce-import.js"),exportName:"commerceImport"},"cms:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"cms:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"marketing:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"marketing:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"monitoring:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"monitoring:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"realtime:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"realtime:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"queue:install":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"queue:uninstall":{path:"./commands/features.js",load:()=>import("./commands/features.js"),exportName:"features"},"db:backup":{path:"./commands/db.js",load:()=>import("./commands/db.js"),exportName:"db"},"db:backups":{path:"./commands/db.js",load:()=>import("./commands/db.js"),exportName:"db"},"db:restore":{path:"./commands/db.js",load:()=>import("./commands/db.js"),exportName:"db"},"storage:backup":{path:"./commands/storage-backup.js",load:()=>import("./commands/storage-backup.js"),exportName:"storageBackup"},"storage:backups":{path:"./commands/storage-backup.js",load:()=>import("./commands/storage-backup.js"),exportName:"storageBackup"},"storage:restore":{path:"./commands/storage-backup.js",load:()=>import("./commands/storage-backup.js"),exportName:"storageBackup"},"feedback:invite":{path:"./commands/feedback.js",load:()=>import("./commands/feedback.js"),exportName:"feedback"},"feedback:tokens":{path:"./commands/feedback.js",load:()=>import("./commands/feedback.js"),exportName:"feedback"},"feedback:revoke":{path:"./commands/feedback.js",load:()=>import("./commands/feedback.js"),exportName:"feedback"},"socials:identities":{path:"./commands/socials.js",load:()=>import("./commands/socials.js"),exportName:"socials"},"socials:authorize":{path:"./commands/socials.js",load:()=>import("./commands/socials.js"),exportName:"socials"},fresh:{path:"./commands/fresh.js",load:()=>import("./commands/fresh.js"),exportName:"fresh"},generate:{path:"./commands/generate.js",load:()=>import("./commands/generate.js"),exportName:"generate"},"gdpr:export":{path:"./commands/gdpr.js",load:()=>import("./commands/gdpr.js"),exportName:"gdpr"},"gdpr:erase":{path:"./commands/gdpr.js",load:()=>import("./commands/gdpr.js"),exportName:"gdpr"},"gdpr:prune":{path:"./commands/gdpr.js",load:()=>import("./commands/gdpr.js"),exportName:"gdpr"},"gdpr:register":{path:"./commands/gdpr.js",load:()=>import("./commands/gdpr.js"),exportName:"gdpr"},"gdpr:register:check":{path:"./commands/gdpr.js",load:()=>import("./commands/gdpr.js"),exportName:"gdpr"},"hq:connect":{path:"./commands/hq.js",load:()=>import("./commands/hq.js"),exportName:"hq"},"hq:status":{path:"./commands/hq.js",load:()=>import("./commands/hq.js"),exportName:"hq"},http:{path:"./commands/http.js",load:()=>import("./commands/http.js"),exportName:"http"},install:{path:"./commands/install.js",load:()=>import("./commands/install.js"),exportName:"install"},key:{path:"./commands/key.js",load:()=>import("./commands/key.js"),exportName:"key"},license:{path:"./commands/license.js",load:()=>import("./commands/license.js"),exportName:"license"},"license:keygen":{path:"./commands/license.js",load:()=>import("./commands/license.js"),exportName:"license"},lint:{path:"./commands/lint.js",load:()=>import("./commands/lint.js"),exportName:"lint"},format:{path:"./commands/lint.js",load:()=>import("./commands/lint.js"),exportName:"lint"},"format:check":{path:"./commands/lint.js",load:()=>import("./commands/lint.js"),exportName:"lint"},libs:{path:"./commands/libs.js",load:()=>import("./commands/libs.js"),exportName:"libs"},libraries:{path:"./commands/libs.js",load:()=>import("./commands/libs.js"),exportName:"libs"},list:{path:"./commands/list.js",load:()=>import("./commands/list.js"),exportName:"list"},mail:{path:"./commands/mail.js",load:()=>import("./commands/mail.js"),exportName:"mailCommands"},"mail:preview":{path:"./commands/mail.js",load:()=>import("./commands/mail.js"),exportName:"mailCommands"},maintenance:{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},down:{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},up:{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},status:{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},"coming-soon":{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},"coming-soon:status":{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},launch:{path:"./commands/maintenance.js",load:()=>import("./commands/maintenance.js"),exportName:"maintenance"},make:{path:"./commands/make.js",load:()=>import("./commands/make.js"),exportName:"make"},"scaffold:crud":{path:"./commands/make.js",load:()=>import("./commands/make.js"),exportName:"make"},migrate:{path:"./commands/migrate.js",load:()=>import("./commands/migrate.js"),exportName:"migrate"},"migrate:fresh":{path:"./commands/migrate.js",load:()=>import("./commands/migrate.js"),exportName:"migrate"},"migrate:switch":{path:"./commands/migrate.js",load:()=>import("./commands/migrate.js"),exportName:"migrate"},"migrate:project":{path:"./commands/migrate-project.js",load:()=>import("./commands/migrate-project.js"),exportName:"migrateProject"},outdated:{path:"./commands/outdated.js",load:()=>import("./commands/outdated.js"),exportName:"outdated"},package:{path:"./commands/package.js",load:()=>import("./commands/package.js"),exportName:"packageCommands"},phone:{path:"./commands/phone.js",load:()=>import("./commands/phone.js"),exportName:"phone"},ports:{path:"./commands/ports.js",load:()=>import("./commands/ports.js"),exportName:"ports"},"security:scan":{path:"./commands/security.js",load:()=>import("./commands/security.js"),exportName:"security"},audit:{path:"./commands/security.js",load:()=>import("./commands/security.js"),exportName:"security"},"server:flash":{path:"./commands/server.js",load:()=>import("./commands/server.js"),exportName:"server"},"server:first-boot":{path:"./commands/server.js",load:()=>import("./commands/server.js"),exportName:"server"},"server:doctor":{path:"./commands/server.js",load:()=>import("./commands/server.js"),exportName:"server"},"server:setup":{path:"./commands/server.js",load:()=>import("./commands/server.js"),exportName:"server"},"server:trust":{path:"./commands/server.js",load:()=>import("./commands/server.js"),exportName:"server"},"link:core":{path:"./commands/link.js",load:()=>import("./commands/link.js"),exportName:"link"},"comments:list":{path:"./commands/comments.js",load:()=>import("./commands/comments.js"),exportName:"commentsCommands"},"comments:approve":{path:"./commands/comments.js",load:()=>import("./commands/comments.js"),exportName:"commentsCommands"},"comments:reject":{path:"./commands/comments.js",load:()=>import("./commands/comments.js"),exportName:"commentsCommands"},"comments:delete":{path:"./commands/comments.js",load:()=>import("./commands/comments.js"),exportName:"commentsCommands"},"user:add":{path:"./commands/user.js",load:()=>import("./commands/user.js"),exportName:"user"},"user:list":{path:"./commands/user.js",load:()=>import("./commands/user.js"),exportName:"user"},"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/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.568",
|
|
6
6
|
"description": "Meet Buddy. The Stacks runtime.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -95,70 +95,71 @@
|
|
|
95
95
|
"prepublishOnly": "bun run build"
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
|
-
"@stacksjs/actions": "0.75.
|
|
99
|
-
"@stacksjs/docs": "0.75.
|
|
100
|
-
"@stacksjs/ai": "0.75.
|
|
101
|
-
"@stacksjs/alias": "0.75.
|
|
102
|
-
"@stacksjs/analytics": "0.75.
|
|
103
|
-
"@stacksjs/api": "0.75.
|
|
104
|
-
"@stacksjs/arrays": "0.75.
|
|
105
|
-
"@stacksjs/auth": "0.75.
|
|
106
|
-
"@stacksjs/browser-extension": "0.75.
|
|
107
|
-
"@stacksjs/build": "0.75.
|
|
98
|
+
"@stacksjs/actions": "0.75.568",
|
|
99
|
+
"@stacksjs/docs": "0.75.568",
|
|
100
|
+
"@stacksjs/ai": "0.75.568",
|
|
101
|
+
"@stacksjs/alias": "0.75.568",
|
|
102
|
+
"@stacksjs/analytics": "0.75.568",
|
|
103
|
+
"@stacksjs/api": "0.75.568",
|
|
104
|
+
"@stacksjs/arrays": "0.75.568",
|
|
105
|
+
"@stacksjs/auth": "0.75.568",
|
|
106
|
+
"@stacksjs/browser-extension": "0.75.568",
|
|
107
|
+
"@stacksjs/build": "0.75.568",
|
|
108
108
|
"@stacksjs/bumpx": "^0.2.26",
|
|
109
|
-
"@stacksjs/cache": "0.75.
|
|
110
|
-
"@stacksjs/chat": "0.75.
|
|
109
|
+
"@stacksjs/cache": "0.75.568",
|
|
110
|
+
"@stacksjs/chat": "0.75.568",
|
|
111
111
|
"@stacksjs/clapp": "^0.2.17",
|
|
112
|
-
"@stacksjs/cli": "0.75.
|
|
113
|
-
"@stacksjs/cloud": "0.75.
|
|
114
|
-
"@stacksjs/cms": "0.75.
|
|
115
|
-
"@stacksjs/collections": "0.75.
|
|
116
|
-
"@stacksjs/commerce": "0.75.
|
|
117
|
-
"@stacksjs/config": "0.75.
|
|
118
|
-
"@stacksjs/database": "0.75.
|
|
119
|
-
"@stacksjs/desktop-build": "0.75.
|
|
120
|
-
"@stacksjs/dns": "0.75.
|
|
112
|
+
"@stacksjs/cli": "0.75.568",
|
|
113
|
+
"@stacksjs/cloud": "0.75.568",
|
|
114
|
+
"@stacksjs/cms": "0.75.568",
|
|
115
|
+
"@stacksjs/collections": "0.75.568",
|
|
116
|
+
"@stacksjs/commerce": "0.75.568",
|
|
117
|
+
"@stacksjs/config": "0.75.568",
|
|
118
|
+
"@stacksjs/database": "0.75.568",
|
|
119
|
+
"@stacksjs/desktop-build": "0.75.568",
|
|
120
|
+
"@stacksjs/dns": "0.75.568",
|
|
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.568",
|
|
123
|
+
"@stacksjs/enums": "0.75.568",
|
|
124
|
+
"@stacksjs/env": "0.75.568",
|
|
125
|
+
"@stacksjs/error-handling": "0.75.568",
|
|
126
|
+
"@stacksjs/events": "0.75.568",
|
|
127
|
+
"@stacksjs/features": "0.75.568",
|
|
128
|
+
"@stacksjs/git": "0.75.568",
|
|
129
129
|
"@stacksjs/gitit": "^0.2.5",
|
|
130
|
-
"@stacksjs/health": "0.75.
|
|
130
|
+
"@stacksjs/health": "0.75.568",
|
|
131
|
+
"@stacksjs/hq": "0.75.568",
|
|
131
132
|
"@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.
|
|
133
|
+
"@stacksjs/image": "0.75.568",
|
|
134
|
+
"@stacksjs/lint": "0.75.568",
|
|
135
|
+
"@stacksjs/logging": "0.75.568",
|
|
136
|
+
"@stacksjs/notifications": "0.75.568",
|
|
137
|
+
"@stacksjs/objects": "0.75.568",
|
|
138
|
+
"@stacksjs/orm": "0.75.568",
|
|
139
|
+
"@stacksjs/path": "0.75.568",
|
|
140
|
+
"@stacksjs/payments": "0.75.568",
|
|
141
|
+
"@stacksjs/realtime": "0.75.568",
|
|
142
|
+
"@stacksjs/router": "0.75.568",
|
|
142
143
|
"@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.
|
|
144
|
+
"@stacksjs/scheduler": "0.75.568",
|
|
145
|
+
"@stacksjs/search-engine": "0.75.568",
|
|
146
|
+
"@stacksjs/security": "0.75.568",
|
|
147
|
+
"@stacksjs/server": "0.75.568",
|
|
148
|
+
"@stacksjs/sites": "0.75.568",
|
|
149
|
+
"@stacksjs/skills": "0.75.568",
|
|
150
|
+
"@stacksjs/socials": "0.75.568",
|
|
151
|
+
"@stacksjs/storage": "0.75.568",
|
|
152
|
+
"@stacksjs/strings": "0.75.568",
|
|
152
153
|
"@stacksjs/stx": "^0.2.864",
|
|
153
|
-
"@stacksjs/testing": "0.75.
|
|
154
|
-
"@stacksjs/tinker": "0.75.
|
|
154
|
+
"@stacksjs/testing": "0.75.568",
|
|
155
|
+
"@stacksjs/tinker": "0.75.568",
|
|
155
156
|
"@stacksjs/tlsx": "^0.13.19",
|
|
156
157
|
"@stacksjs/ts-cloud": "^0.16.126",
|
|
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.
|
|
158
|
+
"@stacksjs/tunnel": "0.75.568",
|
|
159
|
+
"@stacksjs/types": "0.75.568",
|
|
160
|
+
"@stacksjs/ui": "0.75.568",
|
|
161
|
+
"@stacksjs/utils": "0.75.568",
|
|
162
|
+
"@stacksjs/validation": "0.75.568",
|
|
162
163
|
"ajv": "^8.20.0",
|
|
163
164
|
"ajv-formats": "^3.0.1",
|
|
164
165
|
"bun-plugin-stx": "^0.2.864",
|