@stacksjs/actions 0.75.529 → 0.75.537
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/build/android-config.d.ts +0 -7
- package/dist/build/docs.js +1 -1
- package/dist/build/ios-config.d.ts +10 -7
- package/dist/build/ios-toolchain.d.ts +1 -0
- package/dist/build/native-sensors.d.ts +0 -2
- package/dist/changelog.d.ts +1 -1
- package/dist/dev/dashboard-feature-views.d.ts +24 -0
- package/dist/dev/dashboard-feature-views.js +1 -0
- package/dist/dev/dashboard-proxy.d.ts +8 -1
- package/dist/dev/dashboard-proxy.js +1 -1
- package/dist/dev/dashboard.js +2 -2
- package/dist/github-release.d.ts +1 -1
- package/dist/library/packages.d.ts +1 -0
- package/dist/release-preflight.js +1 -1
- package/dist/serve/dashboard.js +1 -1
- package/package.json +45 -44
|
@@ -18,12 +18,6 @@ export declare function androidRelease(config: Pick<AndroidMobileConfig, 'versio
|
|
|
18
18
|
* not fail a release build.
|
|
19
19
|
*/
|
|
20
20
|
export declare function uploadAndroidMapping(mappingPath: string, host: string, release: string, token: string | undefined, send?: typeof fetch): Promise<{ ok: boolean, message: string }>;
|
|
21
|
-
/**
|
|
22
|
-
* An app's `android.capabilities` names, and the Craft `enable…` flag each
|
|
23
|
-
* sets. Closed, like ios-config.ts's map, and checked against the installed
|
|
24
|
-
* Craft by tests/craft-capability-parity.test.ts.
|
|
25
|
-
*/
|
|
26
|
-
declare const CAPABILITY_KEYS: Partial<Record<keyof MobileCapabilities, `enable${string}`>>;
|
|
27
21
|
/** Craft Android flags no `android.capabilities` name sets, each with why. */
|
|
28
22
|
export declare const ANDROID_UNMAPPED_CRAFT_FLAGS: Readonly<Record<`enable${string}`, string>>;
|
|
29
23
|
/**
|
|
@@ -98,4 +92,3 @@ export declare interface CraftAndroidConfig {
|
|
|
98
92
|
privacyPolicyURL?: string
|
|
99
93
|
}
|
|
100
94
|
export type AndroidCraftFeature = keyof typeof CRAFT_ANDROID_FLOORS;
|
|
101
|
-
export { CAPABILITY_KEYS as ANDROID_CAPABILITY_KEYS };
|
package/dist/build/docs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{projectPath}from"@stacksjs/path";import{runBuildStep}from"./run-build-step";function bunpressCommand(){try{const manifest=Bun.resolveSync("@stacksjs/bunpress/package.json",projectPath());const pkg=require(manifest);const bin=typeof pkg.bin==="string"?pkg.bin:pkg.bin?.bunpress;if(!bin)return"bunpress";return`bun ${manifest.slice(0,manifest.lastIndexOf("/"))}/${bin.replace(/^\.\//,"")}`}catch{return"bunpress"}}await runBuildStep(`${bunpressCommand()} build`,{cwd:projectPath(),describe:"The documentation build"});
|
|
1
|
+
import{projectPath}from"@stacksjs/path";import{runStyleGuide}from"@stacksjs/docs/style-guide";import{runBuildStep}from"./run-build-step";function bunpressCommand(){try{const manifest=Bun.resolveSync("@stacksjs/bunpress/package.json",projectPath());const pkg=require(manifest);const bin=typeof pkg.bin==="string"?pkg.bin:pkg.bin?.bunpress;if(!bin)return"bunpress";return`bun ${manifest.slice(0,manifest.lastIndexOf("/"))}/${bin.replace(/^\.\//,"")}`}catch{return"bunpress"}}await runStyleGuide({root:projectPath(),optional:true});await runBuildStep(`${bunpressCommand()} build`,{cwd:projectPath(),describe:"The documentation build"});
|
|
@@ -72,7 +72,9 @@ export declare const NATIVE_APP_ROUTE: '__app';
|
|
|
72
72
|
* tests/craft-capability-parity.test.ts fails on any flag the installed Craft
|
|
73
73
|
* declares that is neither here nor in {@link IOS_UNMAPPED_CRAFT_FLAGS}.
|
|
74
74
|
*/
|
|
75
|
-
declare const CAPABILITY_KEYS: Partial<Record<keyof MobileCapabilities, `enable${string}
|
|
75
|
+
declare const CAPABILITY_KEYS: Partial<Record<keyof MobileCapabilities, `enable${string}`>>
|
|
76
|
+
|
|
77
|
+
export { CAPABILITY_KEYS as IOS_CAPABILITY_KEYS };
|
|
76
78
|
/** Craft iOS flags no `ios.capabilities` name sets, each with why. */
|
|
77
79
|
export declare const IOS_UNMAPPED_CRAFT_FLAGS: Readonly<Record<`enable${string}`, string>>;
|
|
78
80
|
/**
|
|
@@ -86,7 +88,12 @@ export declare const IOS_UNMAPPED_CRAFT_FLAGS: Readonly<Record<`enable${string}`
|
|
|
86
88
|
* @stacksjs/mobile. Capabilities older than every craft-native Stacks has
|
|
87
89
|
* accepted are not listed.
|
|
88
90
|
*/
|
|
89
|
-
export declare const CRAFT_CAPABILITY_FLOORS: Partial<Record<keyof typeof CAPABILITY_KEYS, string
|
|
91
|
+
export declare const CRAFT_CAPABILITY_FLOORS: Partial<Record<keyof typeof CAPABILITY_KEYS, string>>
|
|
92
|
+
|
|
93
|
+
export interface UnsupportedCraftCapability {
|
|
94
|
+
capability: keyof typeof CRAFT_CAPABILITY_FLOORS
|
|
95
|
+
needs: string
|
|
96
|
+
};
|
|
90
97
|
/** The first craft-native whose iOS and Android shells report crashes (CraftCrashReporter). */
|
|
91
98
|
export declare const CRAFT_CRASH_REPORTING_FLOOR: '0.0.179';
|
|
92
99
|
export declare const CRAFT_NATIVE_FONTS_FLOOR: '0.0.229';
|
|
@@ -137,8 +144,4 @@ export declare interface CraftIosConfig {
|
|
|
137
144
|
orientations?: IosMobileConfig['orientations']
|
|
138
145
|
deviceFamilies?: IosMobileConfig['deviceFamilies']
|
|
139
146
|
}
|
|
140
|
-
export
|
|
141
|
-
capability: keyof typeof CRAFT_CAPABILITY_FLOORS
|
|
142
|
-
needs: string
|
|
143
|
-
}
|
|
144
|
-
export { CAPABILITY_KEYS as IOS_CAPABILITY_KEYS };
|
|
147
|
+
export {};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import type { MobileCapabilities } from '@stacksjs/types';
|
|
2
|
-
/** Only serialize flags the selected builder advertises, including explicit false. */
|
|
3
|
-
export declare function nativeSensorCapabilityKeys(platform: 'ios' | 'android', supported: readonly string[] | undefined): Partial<Record<keyof MobileCapabilities, `enable${string}`>>;
|
|
4
2
|
/** Check the actual builder instead of inventing a version for unreleased support. */
|
|
5
3
|
export declare function assertCraftSupportsNativeSensors(platform: 'ios' | 'android', capabilities: MobileCapabilities | undefined, supported: readonly string[] | undefined): void;
|
package/dist/changelog.d.ts
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** The page directories under `frameworkDashboard` to leave out of serving. */
|
|
2
|
+
export declare function disabledFeatureViews(frameworkDashboard: string, enabled: (feature: DashboardViewFeature) => boolean): string[];
|
|
3
|
+
/**
|
|
4
|
+
* The framework dashboard pages that belong to an optional feature, relative
|
|
5
|
+
* to the framework's `views/dashboard` directory.
|
|
6
|
+
*
|
|
7
|
+
* A feature that is off is off everywhere: its sidebar section, its routes and
|
|
8
|
+
* its tables already follow `feature()`, and so do these. Without them a page
|
|
9
|
+
* like `/commerce/orders` was hidden from the sidebar yet still answered its
|
|
10
|
+
* URL, drawing a full screen of 404s from the API routes the same flag had left
|
|
11
|
+
* unmounted. Excluded, the URL falls through to the dashboard's not-found page.
|
|
12
|
+
*
|
|
13
|
+
* Only the framework's pages are listed. A page an app wrote itself under
|
|
14
|
+
* `resources/views/dashboard/` is the app saying it wants that page, so it is
|
|
15
|
+
* served whatever the flag says.
|
|
16
|
+
*
|
|
17
|
+
* `marketing/abandoned-carts` and `marketing/reviews` read the commerce tables,
|
|
18
|
+
* which is why the sidebar shows them only with commerce on.
|
|
19
|
+
*/
|
|
20
|
+
export declare const FEATURE_DASHBOARD_VIEWS: {
|
|
21
|
+
readonly cms: readonly ['content'];
|
|
22
|
+
readonly commerce: readonly ['commerce', 'analytics/commerce', 'marketing/abandoned-carts', 'marketing/reviews']
|
|
23
|
+
};
|
|
24
|
+
export type DashboardViewFeature = keyof typeof FEATURE_DASHBOARD_VIEWS;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{join}from"node:path";export const FEATURE_DASHBOARD_VIEWS={cms:["content"],commerce:["commerce","analytics/commerce","marketing/abandoned-carts","marketing/reviews"]};export function disabledFeatureViews(frameworkDashboard,enabled){const out=[];for(const feature of Object.keys(FEATURE_DASHBOARD_VIEWS)){if(enabled(feature))continue;for(const relative of FEATURE_DASHBOARD_VIEWS[feature])out.push(join(frameworkDashboard,relative))}return out}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* `dashboard.<host>` for APP_URL's host, or null when the dashboard is only
|
|
3
|
+
* served on localhost: no custom host, or `localhostOnly`, which is
|
|
4
|
+
* `STACKS_DEV_LOCALHOST=1`, the opt-out `buddy dev` already honours. Without
|
|
5
|
+
* it a standalone `buddy dev:dashboard` asked for sudo before it would serve,
|
|
6
|
+
* even when told to stay on localhost.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveDashboardDomain(appUrl: string, localhostOnly?: boolean): string | null;
|
|
2
9
|
export declare function resolveDashboardProxyStrategy(dashboardDomain: string | null, probes: DashboardProxyProbes): Promise<DashboardProxyStrategy>;
|
|
3
10
|
export declare interface DashboardProxyProbes {
|
|
4
11
|
proxyManagedExternally: boolean
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isIP}from"node:net";export function resolveDashboardDomain(appUrl){if(
|
|
1
|
+
import{isIP}from"node:net";export function resolveDashboardDomain(appUrl,localhostOnly=false){if(localhostOnly||!appUrl.trim())return null;try{const value=appUrl.trim();if(!value.includes("://")&&/^[a-z][a-z0-9+.-]*:(?!\d+(?:[/?#]|$))/i.test(value))return null;const url=new URL(value.includes("://")?value:`http://${value}`);if(!["http:","https:"].includes(url.protocol)||url.username||url.password)return null;const hostname=url.hostname.toLowerCase().replace(/\.$/,"");if(hostname==="localhost"||isIP(hostname.replace(/^\[|\]$/g,"")))return null;if(!hostname||!hostname.split(".").every((label)=>/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(label)))return null;return`dashboard.${hostname}`}catch{return null}}export async function resolveDashboardProxyStrategy(dashboardDomain,probes){if(!dashboardDomain)return"origin-only";if(probes.proxyManagedExternally)return"parent-managed";if(await probes.isDaemonRunning()&&await probes.httpsPortAnswers())return"daemon-route";return"own-proxy"}
|
package/dist/dev/dashboard.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import process from"node:process";import{existsSync,mkdirSync}from"node:fs";import{connect}from"node:net";import{bold,cyan,dim,green}from"@stacksjs/cli";import{defaultsPath,projectPath,publicPath,storagePath}from"@stacksjs/path";import{seedCsrfPageResponse,validateDevCsrfRequest}from"./csrf";import{resolveComponentsLibraryRoot}from"./defaults-resources";import{shouldDelegateDashboardRequest}from"./dashboard-request-routing";import{resolveDashboardCraftExecutable}from"./dashboard-native";import{resolveDashboardDomain,resolveDashboardProxyStrategy}from"./dashboard-proxy";import{buildManifest,discoverProjectModels,findAvailablePort,modelsWithEnabledFeatures,waitForServer,writeFileIfChanged}from"./dashboard-utils";import{runDashboardSupervisor}from"./dashboard-supervisor";import{ensureDiscoveredPackages}from"../discover-packages";import{resolveStxSource}from"../stx-source";if(process.env.STACKS_DASHBOARD_WORKER!=="1"){const exitCode=await runDashboardSupervisor(import.meta.path,process.argv.slice(2));process.exit(exitCode)}process.env.STX_DIR=storagePath("framework/runtime/dashboard-stx");const verboseIdx=process.argv.indexOf("--verbose");const verbose=verboseIdx!==-1&&process.argv[verboseIdx+1]!=="false";const startTime=Bun.nanoseconds();const originalConsoleLog=console.log;const originalConsoleWarn=console.warn;const bufferedLogs=[];console.log=(...args)=>{bufferedLogs.push(args.map(String).join(" "))};console.warn=(...args)=>{bufferedLogs.push(args.map(String).join(" "))};const dashboardPath=defaultsPath("views/dashboard");const userDashboardPath=projectPath("resources/views/dashboard");const dashboardComponentsPath=defaultsPath("resources/components/Dashboard");const userDashboardComponentsPath=projectPath("resources/components/Dashboard");const preferredPort=Number(process.env.PORT_ADMIN)||3002;const dashboardPort=await findAvailablePort(preferredPort);const appUrl=process.env.APP_URL||"";const dashboardDomain=resolveDashboardDomain(appUrl);const sslBasePath=`${process.env.HOME}/.stacks/ssl`;function restoreConsole(){console.log=originalConsoleLog;console.warn=(...args)=>{const msg=args.map(String).join(" ");if(msg.includes("[STX] DOM API violation")||msg.includes("unsafe expression"))return;originalConsoleWarn(...args)}}async function startStxServer(){const{overridesReady}=await import("@stacksjs/config");const{autoImportsAreStale,generateAutoImportFiles,injectGlobalAutoImports}=await import("@stacksjs/server");await overridesReady;await ensureDiscoveredPackages();if(!existsSync(storagePath("framework/auto-imports/models.ts"))||autoImportsAreStale())await generateAutoImportFiles();await injectGlobalAutoImports();const serveSource=resolveStxSource({value:process.env.BUN_PLUGIN_STX_SRC});if(serveSource.kind==="missing"){throw new Error(`BUN_PLUGIN_STX_SRC points at ${serveSource.path}, which does not exist. Unset it to use the installed bun-plugin-stx.`)}let serve;if(serveSource.kind==="override"){serve=(await import(serveSource.path)).serve;console.log(`[Dashboard] bun-plugin-stx from ${serveSource.path}`)}else{serve=(await import("bun-plugin-stx/serve")).serve}const stxSource=resolveStxSource({value:process.env.STX_SRC});if(stxSource.kind==="missing"){throw new Error(`STX_SRC points at ${stxSource.path}, which does not exist. Unset it to use the installed @stacksjs/stx.`)}let stxModule;if(stxSource.kind==="override"){stxModule=await import(stxSource.path);console.log(`[Dashboard] stx from ${stxSource.path}`)}const{listConfigFiles,readConfig,updateConfigKeys}=await import(defaultsPath("resources/functions/dashboard/config-io.ts"));const localTsChartsRoot=process.env.TS_CHARTS_SRC;const dependencyBundles=new Map;function resolveTsChartsSource(packageName){const candidates=[...localTsChartsRoot?[`${localTsChartsRoot}/packages/${packageName}/src/index.ts`]:[],projectPath(`node_modules/@ts-charts/${packageName}/src/index.ts`)];return candidates.find(existsSync)||null}const tsChartsEntry=[...localTsChartsRoot?[`${localTsChartsRoot}/packages/ts-charts/src/index.ts`]:[],projectPath("node_modules/ts-charts/src/index.ts")].find(existsSync);async function buildDashboardDependency(entrypoint){const cached=dependencyBundles.get(entrypoint);if(cached)return cached;const build=(async()=>{const result=await Bun.build({entrypoints:[entrypoint],target:"browser",format:"esm",minify:true,plugins:[{name:"dashboard-ts-charts-source",setup(builder){builder.onResolve({filter:/^@ts-charts\/[a-z0-9-]+$/},(args)=>{const packageName=args.path.slice("@ts-charts/".length);const source=resolveTsChartsSource(packageName);if(source)return{path:source};return null})}}]});if(!result.success){const errors=result.logs.filter((log)=>log.level==="error").map((log)=>log.message).join(`
|
|
2
|
-
`);throw new Error(errors||`Failed to bundle ${entrypoint}`)}const output=result.outputs.find((file)=>file.path.endsWith(".js"));if(!output)throw new Error(`No JavaScript output produced for ${entrypoint}`);return output.text()})();dependencyBundles.set(entrypoint,build);return build}function browserDependencyRoute(entrypoint){return async()=>{try{return new Response(await buildDashboardDependency(entrypoint),{headers:{"content-type":"text/javascript; charset=utf-8","cache-control":"no-cache"}})}catch(error){dependencyBundles.delete(entrypoint);return new Response(`throw new Error(${JSON.stringify(error.message)})`,{status:500,headers:{"content-type":"text/javascript; charset=utf-8"}})}}}let dashboardIconCss=null;async function buildDashboardIconCss(){const{generateCss}=await import("@stacksjs/stx");const dirs=[dashboardPath,userDashboardPath,dashboardComponentsPath,userDashboardComponentsPath,projectPath("app/Models"),defaultsPath("app/Models"),defaultsPath("functions"),defaultsPath("resources/functions")];const icons=new Set;for(const dir of dirs){if(!existsSync(dir))continue;const glob=new Bun.Glob("**/*.{stx,ts}");for await(const file of glob.scan({cwd:dir,absolute:true})){const text=await Bun.file(file).text();for(const match of text.matchAll(/\bi-[a-z][a-z0-9]*(?:-[a-z0-9]+)+/g))icons.add(match[0])}}if(icons.size===0)return"";return generateCss(`<div class="${[...icons].join(" ")}"></div>`,process.cwd())}const configRoutes={"/__deps/charts.js":browserDependencyRoute(storagePath("framework/core/charts/src/index.ts")),"/__deps/ts-charts.js":browserDependencyRoute(tsChartsEntry||`${localTsChartsRoot}/packages/ts-charts/src/index.ts`),"/__deps/dashboard-icons.css":async()=>{if(!dashboardIconCss)dashboardIconCss=buildDashboardIconCss();return new Response(await dashboardIconCss,{headers:{"content-type":"text/css; charset=utf-8","cache-control":"no-cache"}})},"/api/config/list":async()=>{try{return Response.json({ok:true,files:listConfigFiles()})}catch(e){return Response.json({ok:false,error:e?.message},{status:500})}},"/api/config/read":async(req)=>{try{const url=new URL(req.url);const name=url.searchParams.get("name")||"";if(!/^[\w-]+$/.test(name))return Response.json({ok:false,error:"Invalid config name"},{status:400});const result=await readConfig(name);if(!result)return Response.json({ok:false,error:"Not found"},{status:404});return Response.json({ok:true,name,fields:result.fields})}catch(e){return Response.json({ok:false,error:e?.message},{status:500})}},"/api/config/source":async(req)=>{try{const url=new URL(req.url);const name=url.searchParams.get("name")||"";if(!/^[\w-]+$/.test(name))return Response.json({ok:false,error:"Invalid config name"},{status:400});const result=await readConfig(name);if(!result)return Response.json({ok:false,error:"Not found"},{status:404});return new Response(result.source,{headers:{"content-type":"text/plain; charset=utf-8"}})}catch(e){return Response.json({ok:false,error:e?.message},{status:500})}},"/api/config/update":async(req)=>{if(req.method!=="POST")return Response.json({ok:false,error:"Method not allowed"},{status:405});try{await validateDevCsrfRequest(req);const body=await req.json();const file=body.file?.replace(/\.ts$/,"");if(!file||!/^[\w-]+$/.test(file))return Response.json({ok:false,error:"Invalid file"},{status:400});const updates=[];if(Array.isArray(body.updates)){for(const u of body.updates){const k=u.key??u.path;if(typeof k==="string")updates.push({key:k,value:u.value})}}else if(body.key){updates.push({key:body.key,value:body.value})}if(updates.length===0)return Response.json({ok:false,error:"No updates supplied"},{status:400});const invalid=updates.find((update)=>!/^[A-Za-z_$][\w$]*$/.test(update.key)||typeof update.value!=="string"&&typeof update.value!=="number"&&typeof update.value!=="boolean"||typeof update.value==="number"&&!Number.isFinite(update.value));if(invalid)return Response.json({ok:false,error:`Invalid value for configuration key "${invalid.key}"`},{status:400});const typedUpdates=updates;try{await updateConfigKeys(file,typedUpdates)}catch(err){const error=err?.message||"Configuration values could not be updated.";const results=typedUpdates.map((update)=>({key:update.key,ok:false,error}));return Response.json({ok:false,file,results,error},{status:422})}const results=typedUpdates.map((update)=>({key:update.key,ok:true,newValue:update.value}));return Response.json({ok:true,file,results})}catch(e){if(e?.status===403)return Response.json({ok:false,error:"Forbidden",message:"CSRF token mismatch"},{status:403});return Response.json({ok:false,error:e?.message},{status:500})}}};const router=await import("@stacksjs/router");await router.loadRoutes(await router.appRouteRegistry());await router.route.register(defaultsPath("routes/dashboard-api.ts"));const stacksRoute=router.route;const serverPromise=serve({root:projectPath("resources"),patterns:[userDashboardPath,dashboardPath],port:dashboardPort,componentsDir:userDashboardComponentsPath,additionalComponentsDirs:[dashboardComponentsPath],fallbackComponentsDir:resolveComponentsLibraryRoot(),layoutsDir:projectPath("resources/views/dashboard/layouts"),fallbackLayoutsDir:defaultsPath("views/dashboard/layouts"),partialsDir:dashboardPath,publicDir:publicPath(),renderCache:true,renderCacheVary:"source",prewarmRenderCache:false,renderCachePersist:true,watchDirs:[projectPath("resources/functions"),defaultsPath("resources/functions"),defaultsPath("functions"),projectPath("config"),storagePath("framework/runtime/dashboard")],quiet:true,routes:configRoutes,onRequest:async(req)=>{const url=new URL(req.url);const pathname=url.pathname;if(shouldDelegateDashboardRequest(pathname,req.method))return stacksRoute.handleRequest(req);return null},onResponse:seedCsrfPageResponse,auth:false,...stxModule&&{stxModule}});serverPromise.catch((err)=>{restoreConsole();console.error(`
|
|
1
|
+
import process from"node:process";import{existsSync,mkdirSync}from"node:fs";import{connect}from"node:net";import{bold,cyan,dim,green}from"@stacksjs/cli";import{defaultsPath,projectPath,publicPath,storagePath}from"@stacksjs/path";import{seedCsrfPageResponse,validateDevCsrfRequest}from"./csrf";import{resolveComponentsLibraryRoot}from"./defaults-resources";import{shouldDelegateDashboardRequest}from"./dashboard-request-routing";import{resolveDashboardCraftExecutable}from"./dashboard-native";import{resolveDashboardDomain,resolveDashboardProxyStrategy}from"./dashboard-proxy";import{buildManifest,discoverProjectModels,findAvailablePort,modelsWithEnabledFeatures,waitForServer,writeFileIfChanged}from"./dashboard-utils";import{runDashboardSupervisor}from"./dashboard-supervisor";import{ensureDiscoveredPackages}from"../discover-packages";import{resolveStxSource}from"../stx-source";if(process.env.STACKS_DASHBOARD_WORKER!=="1"){const exitCode=await runDashboardSupervisor(import.meta.path,process.argv.slice(2));process.exit(exitCode)}process.env.STX_DIR=storagePath("framework/runtime/dashboard-stx");const verboseIdx=process.argv.indexOf("--verbose");const verbose=verboseIdx!==-1&&process.argv[verboseIdx+1]!=="false";const startTime=Bun.nanoseconds();const originalConsoleLog=console.log;const originalConsoleWarn=console.warn;const bufferedLogs=[];console.log=(...args)=>{bufferedLogs.push(args.map(String).join(" "))};console.warn=(...args)=>{bufferedLogs.push(args.map(String).join(" "))};const dashboardPath=defaultsPath("views/dashboard");const userDashboardPath=projectPath("resources/views/dashboard");const dashboardComponentsPath=defaultsPath("resources/components/Dashboard");const userDashboardComponentsPath=projectPath("resources/components/Dashboard");const preferredPort=Number(process.env.PORT_ADMIN)||3002;const dashboardPort=await findAvailablePort(preferredPort);const appUrl=process.env.APP_URL||"";const dashboardDomain=resolveDashboardDomain(appUrl,process.env.STACKS_DEV_LOCALHOST==="1");const sslBasePath=`${process.env.HOME}/.stacks/ssl`;function restoreConsole(){console.log=originalConsoleLog;console.warn=(...args)=>{const msg=args.map(String).join(" ");if(msg.includes("[STX] DOM API violation")||msg.includes("unsafe expression"))return;originalConsoleWarn(...args)}}async function startStxServer(){const{overridesReady}=await import("@stacksjs/config");const{autoImportsAreStale,generateAutoImportFiles,injectGlobalAutoImports}=await import("@stacksjs/server");await overridesReady;await ensureDiscoveredPackages();if(!existsSync(storagePath("framework/auto-imports/models.ts"))||autoImportsAreStale())await generateAutoImportFiles();await injectGlobalAutoImports();const serveSource=resolveStxSource({value:process.env.BUN_PLUGIN_STX_SRC});if(serveSource.kind==="missing"){throw new Error(`BUN_PLUGIN_STX_SRC points at ${serveSource.path}, which does not exist. Unset it to use the installed bun-plugin-stx.`)}let serve;if(serveSource.kind==="override"){serve=(await import(serveSource.path)).serve;console.log(`[Dashboard] bun-plugin-stx from ${serveSource.path}`)}else{serve=(await import("bun-plugin-stx/serve")).serve}const stxSource=resolveStxSource({value:process.env.STX_SRC});if(stxSource.kind==="missing"){throw new Error(`STX_SRC points at ${stxSource.path}, which does not exist. Unset it to use the installed @stacksjs/stx.`)}let stxModule;if(stxSource.kind==="override"){stxModule=await import(stxSource.path);console.log(`[Dashboard] stx from ${stxSource.path}`)}const{listConfigFiles,readConfig,updateConfigKeys}=await import(defaultsPath("resources/functions/dashboard/config-io.ts"));const localTsChartsRoot=process.env.TS_CHARTS_SRC;const dependencyBundles=new Map;function resolveTsChartsSource(packageName){const candidates=[...localTsChartsRoot?[`${localTsChartsRoot}/packages/${packageName}/src/index.ts`]:[],projectPath(`node_modules/@ts-charts/${packageName}/src/index.ts`)];return candidates.find(existsSync)||null}const tsChartsEntry=[...localTsChartsRoot?[`${localTsChartsRoot}/packages/ts-charts/src/index.ts`]:[],projectPath("node_modules/ts-charts/src/index.ts")].find(existsSync);async function buildDashboardDependency(entrypoint){const cached=dependencyBundles.get(entrypoint);if(cached)return cached;const build=(async()=>{const result=await Bun.build({entrypoints:[entrypoint],target:"browser",format:"esm",minify:true,plugins:[{name:"dashboard-ts-charts-source",setup(builder){builder.onResolve({filter:/^@ts-charts\/[a-z0-9-]+$/},(args)=>{const packageName=args.path.slice("@ts-charts/".length);const source=resolveTsChartsSource(packageName);if(source)return{path:source};return null})}}]});if(!result.success){const errors=result.logs.filter((log)=>log.level==="error").map((log)=>log.message).join(`
|
|
2
|
+
`);throw new Error(errors||`Failed to bundle ${entrypoint}`)}const output=result.outputs.find((file)=>file.path.endsWith(".js"));if(!output)throw new Error(`No JavaScript output produced for ${entrypoint}`);return output.text()})();dependencyBundles.set(entrypoint,build);return build}function browserDependencyRoute(entrypoint){return async()=>{try{return new Response(await buildDashboardDependency(entrypoint),{headers:{"content-type":"text/javascript; charset=utf-8","cache-control":"no-cache"}})}catch(error){dependencyBundles.delete(entrypoint);return new Response(`throw new Error(${JSON.stringify(error.message)})`,{status:500,headers:{"content-type":"text/javascript; charset=utf-8"}})}}}let dashboardIconCss=null;async function buildDashboardIconCss(){const{generateCss}=await import("@stacksjs/stx");const dirs=[dashboardPath,userDashboardPath,dashboardComponentsPath,userDashboardComponentsPath,projectPath("app/Models"),defaultsPath("app/Models"),defaultsPath("functions"),defaultsPath("resources/functions")];const icons=new Set;for(const dir of dirs){if(!existsSync(dir))continue;const glob=new Bun.Glob("**/*.{stx,ts}");for await(const file of glob.scan({cwd:dir,absolute:true})){const text=await Bun.file(file).text();for(const match of text.matchAll(/\bi-[a-z][a-z0-9]*(?:-[a-z0-9]+)+/g))icons.add(match[0])}}if(icons.size===0)return"";return generateCss(`<div class="${[...icons].join(" ")}"></div>`,process.cwd())}const configRoutes={"/__deps/charts.js":browserDependencyRoute(storagePath("framework/core/charts/src/index.ts")),"/__deps/ts-charts.js":browserDependencyRoute(tsChartsEntry||`${localTsChartsRoot}/packages/ts-charts/src/index.ts`),"/__deps/dashboard-icons.css":async()=>{if(!dashboardIconCss)dashboardIconCss=buildDashboardIconCss();return new Response(await dashboardIconCss,{headers:{"content-type":"text/css; charset=utf-8","cache-control":"no-cache"}})},"/api/config/list":async()=>{try{return Response.json({ok:true,files:listConfigFiles()})}catch(e){return Response.json({ok:false,error:e?.message},{status:500})}},"/api/config/read":async(req)=>{try{const url=new URL(req.url);const name=url.searchParams.get("name")||"";if(!/^[\w-]+$/.test(name))return Response.json({ok:false,error:"Invalid config name"},{status:400});const result=await readConfig(name);if(!result)return Response.json({ok:false,error:"Not found"},{status:404});return Response.json({ok:true,name,fields:result.fields})}catch(e){return Response.json({ok:false,error:e?.message},{status:500})}},"/api/config/source":async(req)=>{try{const url=new URL(req.url);const name=url.searchParams.get("name")||"";if(!/^[\w-]+$/.test(name))return Response.json({ok:false,error:"Invalid config name"},{status:400});const result=await readConfig(name);if(!result)return Response.json({ok:false,error:"Not found"},{status:404});return new Response(result.source,{headers:{"content-type":"text/plain; charset=utf-8"}})}catch(e){return Response.json({ok:false,error:e?.message},{status:500})}},"/api/config/update":async(req)=>{if(req.method!=="POST")return Response.json({ok:false,error:"Method not allowed"},{status:405});try{await validateDevCsrfRequest(req);const body=await req.json();const file=body.file?.replace(/\.ts$/,"");if(!file||!/^[\w-]+$/.test(file))return Response.json({ok:false,error:"Invalid file"},{status:400});const updates=[];if(Array.isArray(body.updates)){for(const u of body.updates){const k=u.key??u.path;if(typeof k==="string")updates.push({key:k,value:u.value})}}else if(body.key){updates.push({key:body.key,value:body.value})}if(updates.length===0)return Response.json({ok:false,error:"No updates supplied"},{status:400});const invalid=updates.find((update)=>!/^[A-Za-z_$][\w$]*$/.test(update.key)||typeof update.value!=="string"&&typeof update.value!=="number"&&typeof update.value!=="boolean"||typeof update.value==="number"&&!Number.isFinite(update.value));if(invalid)return Response.json({ok:false,error:`Invalid value for configuration key "${invalid.key}"`},{status:400});const typedUpdates=updates;try{await updateConfigKeys(file,typedUpdates)}catch(err){const error=err?.message||"Configuration values could not be updated.";const results=typedUpdates.map((update)=>({key:update.key,ok:false,error}));return Response.json({ok:false,file,results,error},{status:422})}const results=typedUpdates.map((update)=>({key:update.key,ok:true,newValue:update.value}));return Response.json({ok:true,file,results})}catch(e){if(e?.status===403)return Response.json({ok:false,error:"Forbidden",message:"CSRF token mismatch"},{status:403});return Response.json({ok:false,error:e?.message},{status:500})}}};const router=await import("@stacksjs/router");await router.loadRoutes(await router.appRouteRegistry());await router.route.register(defaultsPath("routes/dashboard-api.ts"));const stacksRoute=router.route;const{feature}=await import("@stacksjs/config");const{disabledFeatureViews}=await import("./dashboard-feature-views");const serverPromise=serve({root:projectPath("resources"),patterns:[userDashboardPath,dashboardPath],exclude:disabledFeatureViews(dashboardPath,feature),port:dashboardPort,componentsDir:userDashboardComponentsPath,additionalComponentsDirs:[dashboardComponentsPath],fallbackComponentsDir:resolveComponentsLibraryRoot(),layoutsDir:projectPath("resources/views/dashboard/layouts"),fallbackLayoutsDir:defaultsPath("views/dashboard/layouts"),partialsDir:dashboardPath,publicDir:publicPath(),renderCache:true,renderCacheVary:"source",prewarmRenderCache:false,renderCachePersist:true,watchDirs:[projectPath("resources/functions"),defaultsPath("resources/functions"),defaultsPath("functions"),projectPath("config"),storagePath("framework/runtime/dashboard")],quiet:true,routes:configRoutes,onRequest:async(req)=>{const url=new URL(req.url);const pathname=url.pathname;if(shouldDelegateDashboardRequest(pathname,req.method))return stacksRoute.handleRequest(req);return null},onResponse:seedCsrfPageResponse,auth:false,...stxModule&&{stxModule}});serverPromise.catch((err)=>{restoreConsole();console.error(`
|
|
3
3
|
Failed to start dashboard server: ${err?.message||err}
|
|
4
4
|
`);process.exit(1)})}function portAnswers(port,timeoutMs=800){return new Promise((resolve)=>{const socket=connect({port,host:"127.0.0.1"});const finish=(answered)=>{try{socket.destroy()}catch{}resolve(answered)};socket.once("connect",()=>finish(true));socket.once("error",()=>finish(false));setTimeout(()=>finish(false),timeoutMs).unref?.()})}async function registerWithRpxDaemon(domainToServe){const{writeEntry}=await import("@stacksjs/rpx");await writeEntry({id:`${domainToServe}-dashboard`,from:`localhost:${dashboardPort}`,to:domainToServe,cwd:process.cwd(),createdAt:new Date().toISOString(),pid:process.pid},undefined,verbose);return true}async function startReverseProxy(){if(!dashboardDomain)return false;try{let rpx;const loadRpx=async()=>rpx??=await import("@stacksjs/rpx");const strategy=await resolveDashboardProxyStrategy(dashboardDomain,{proxyManagedExternally:Boolean(process.env.STACKS_PROXY_MANAGED),isDaemonRunning:async()=>(await loadRpx()).isDaemonRunning(),httpsPortAnswers:()=>portAnswers(443)});if(strategy==="origin-only")return false;if(strategy==="parent-managed")return true;if(strategy==="daemon-route")return await registerWithRpxDaemon(dashboardDomain);await(await loadRpx()).startProxies({proxies:[{from:`localhost:${dashboardPort}`,to:dashboardDomain,cleanUrls:false}],https:{basePath:sslBasePath,validityDays:825},regenerateUntrustedCerts:false,verbose});return await portAnswers(443)}catch(error){if(verbose)originalConsoleLog(` ${dim(`Proxy: ${error}`)}`);return false}}const[,allDiscoveredModels]=await Promise.all([startStxServer(),discoverProjectModels()]);const{loadDashboardConfig}=await import(defaultsPath("resources/functions/dashboard/toggles.ts"));const{feature:featureEnabled}=await import("@stacksjs/config");const{toggles:dashboardToggles,nav:dashboardNav}=await loadDashboardConfig(projectPath("config/dashboard.ts"),featureEnabled);const{frameworkModelFeature}=await import("@stacksjs/orm");const discoveredModels=modelsWithEnabledFeatures(allDiscoveredModels,frameworkModelFeature,(name)=>featureEnabled(name));const manifestDir=storagePath("framework/runtime/dashboard");const manifestPath=storagePath("framework/runtime/dashboard/.discovered-models.json");mkdirSync(manifestDir,{recursive:true});const{resolveModelSources}=await import("@stacksjs/database/model-sources");const manifestPayload={models:buildManifest(discoveredModels),schemaModels:(resolveModelSources()?.models??[]).map((model)=>model.name),sections:dashboardToggles,nav:dashboardNav};writeFileIfChanged(manifestPath,JSON.stringify(manifestPayload,null,2));const serverReady=await waitForServer(dashboardPort);restoreConsole();const proxyStarted=await startReverseProxy().catch((err)=>{if(verbose)console.warn("[Dashboard] Reverse proxy failed:",err);return false});const dashboardHttpsUrl=dashboardDomain?`https://${dashboardDomain}`:null;const dashboardLocalUrl=`http://localhost:${dashboardPort}`;const initialUrl=dashboardHttpsUrl&&proxyStarted?`${dashboardHttpsUrl}/`:`${dashboardLocalUrl}/`;const elapsedMs=(Bun.nanoseconds()-startTime)/1e6;console.log();console.log(` ${bold(cyan("stacks dashboard"))}`);console.log();if(dashboardHttpsUrl&&proxyStarted){console.log(` ${green("➜")} ${bold("Local")}: ${cyan(dashboardHttpsUrl)}`);console.log(` ${dim("➜")} ${dim("Origin")}: ${dim(dashboardLocalUrl)}`)}else{console.log(` ${green("➜")} ${bold("Local")}: ${cyan(dashboardLocalUrl)}`);if(dashboardHttpsUrl)console.log(` ${dim("➜")} ${dim("Pretty")}: ${dim(`${dashboardHttpsUrl} needs the rpx proxy - run \`buddy dev\``)}`)}console.log(` ${green("➜")} ${bold("Window")}: ${dim("Stacks Dashboard")} ${dim("1400×900")}`);console.log(` ${green("➜")} ${bold("Models")}: ${dim(`${discoveredModels.length} discovered`)}`);if(dashboardPort!==preferredPort){console.log(` ${dim("➜")} ${dim(`Port ${preferredPort} in use, using ${dashboardPort}`)}`)}if(!serverReady){console.log(` ${dim("⚠")} ${dim("Dev server may not be ready yet")}`)}console.log();console.log(` ${dim(`ready in ${elapsedMs.toFixed(0)} ms`)}`);if(verbose){console.log();console.log(` ${dim("➜")} ${dim("URL")}: ${dim(initialUrl)}`);if(dashboardDomain){console.log(` ${dim("➜")} ${dim("SSL")}: ${dim(sslBasePath)}`);console.log(` ${dim("➜")} ${dim("Proxy")}: ${dim(`localhost:${dashboardPort} → ${dashboardDomain}`)}`)}if(bufferedLogs.length>0){console.log();for(const line of bufferedLogs){console.log(` ${dim(line)}`)}}}console.log();let createApp;let resolveCraftBinary;const nativeDisabled=process.env.STACKS_NO_NATIVE==="1";const explicitCraftSdk=process.env.CRAFT_SDK_SRC;if(!nativeDisabled&&explicitCraftSdk){if(!existsSync(explicitCraftSdk))throw new Error(`CRAFT_SDK_SRC not found: ${explicitCraftSdk}`);try{({createApp,resolveCraftBinary}=await import(explicitCraftSdk));if(!createApp||!resolveCraftBinary)throw new Error("CRAFT_SDK_SRC must export createApp and resolveCraftBinary")}catch(error){throw new Error(`Could not load CRAFT_SDK_SRC ${explicitCraftSdk}: ${error instanceof Error?error.message:String(error)}`)}}if(!nativeDisabled&&!explicitCraftSdk){try{({createApp,resolveCraftBinary}=await import("craft-native"))}catch{}}const craftBinaryPath=createApp&&resolveCraftBinary?resolveDashboardCraftExecutable(resolveCraftBinary):undefined;if(createApp&&craftBinaryPath){const userIconPath=projectPath("resources/assets/images/app-icon.png");const defaultIconPath=defaultsPath("resources/assets/images/app-icon.png");const appIconPath=await Bun.file(userIconPath).exists()?userIconPath:await Bun.file(defaultIconPath).exists()?defaultIconPath:undefined;const app=createApp({url:dashboardLocalUrl,quiet:!verbose,craftPath:craftBinaryPath,window:{title:"Stacks Dashboard",width:1400,height:900,titlebarHidden:true,webSidebarMaterial:true,webSidebarWidth:250,...appIconPath&&{icon:appIconPath}}});process.on("SIGINT",()=>{app.close();process.exit(0)});process.on("SIGTERM",()=>{app.close();process.exit(0)});try{await app.show();process.exit(0)}catch(error){const fallbackUrl=dashboardHttpsUrl||dashboardLocalUrl;console.log(` ${dim("Native Craft window failed:")} ${dim(error instanceof Error?error.message:String(error))}`);console.log(` ${dim("Dashboard available at:")} ${cyan(fallbackUrl)}
|
|
5
5
|
`);await new Promise(()=>{})}}else{const nativeMessage=nativeDisabled?"Native window disabled by STACKS_NO_NATIVE=1. Open the URL above in a browser.":"Native window unavailable. Run pantry install craft, set CRAFT_BIN, or open the URL above in a browser.";console.log(` ${dim(nativeMessage)}
|
package/dist/github-release.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export declare function publishGitHubRelease(options: PublishGitHubReleaseOption
|
|
|
29
29
|
export declare function describeGitHubRelease(tag: string, result: GitHubReleaseResult): string;
|
|
30
30
|
export declare const GITHUB_API_URL: 'https://api.github.com';
|
|
31
31
|
/** GitHub's limit on a release body is 125,000 characters; stay clear of it. */
|
|
32
|
-
export declare const MAX_RELEASE_BODY:
|
|
32
|
+
export declare const MAX_RELEASE_BODY: 120000;
|
|
33
33
|
export declare interface GitHubRepository {
|
|
34
34
|
owner: string
|
|
35
35
|
repo: string
|
|
@@ -88,5 +88,6 @@ export declare interface ResolvedLibraryPackage extends LibraryPackageDefinition
|
|
|
88
88
|
* publish paths can each decide how loud to be — and so it is testable.
|
|
89
89
|
*/
|
|
90
90
|
export declare class LibraryConfigError extends Error {
|
|
91
|
+
/** @defaultValue 'LibraryConfigError' */
|
|
91
92
|
name: string;
|
|
92
93
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{existsSync,readFileSync}from"node:fs";import{join}from"node:path";export const BYPASS_ENV="RELEASE_GATE_BYPASS";export function pinnedCheckScripts(scripts){return Object.keys(scripts).filter((name)=>name==="declarations:check"||/^docs:(?:[\w:-]+:)?check$/.test(name)).sort()}function runsFrameworkDocsTool(command){return typeof command==="string"&&/(?:^|\s)(?:\.\/)?(?:buddy|bud|stacks)\s+docs
|
|
1
|
+
import{existsSync,readFileSync}from"node:fs";import{join}from"node:path";export const BYPASS_ENV="RELEASE_GATE_BYPASS";export function pinnedCheckScripts(scripts){return Object.keys(scripts).filter((name)=>name==="declarations:check"||/^docs:(?:[\w:-]+:)?check$/.test(name)).sort()}function runsFrameworkDocsTool(command){return typeof command==="string"&&/(?:^|\s)(?:\.\/)?(?:buddy|bud|stacks)\s+docs:(?!style-guide(?::|\s|$))/.test(command)}export function readPinnedChecks(cwd){try{const pkg=JSON.parse(readFileSync(join(cwd,"package.json"),"utf8"));const scripts=pkg.scripts??{};const names=pinnedCheckScripts(scripts);if(existsSync(join(cwd,"storage/framework/core/buddy")))return names;return names.filter((name)=>!runsFrameworkDocsTool(scripts[name]))}catch{return[]}}function isBypassed(env){const value=env[BYPASS_ENV];return value==="1"||value==="true"}export async function runPinnedChecks(options={cwd:process.cwd()}){const env=options.env??process.env;if(isBypassed(env))return{ran:[],failures:[],bypassed:true};const scripts=options.scripts??readPinnedChecks(options.cwd);if(scripts.length===0)return{ran:[],failures:[],bypassed:false};const results=await Promise.all(scripts.map(async(script)=>{const proc=Bun.spawn(["bun","run",script],{cwd:options.cwd,stdout:"pipe",stderr:"pipe"});const[stdout,stderr,exitCode]=await Promise.all([new Response(proc.stdout).text(),new Response(proc.stderr).text(),proc.exited]);return{script,exitCode,output:`${stdout}${stderr}`.trim()}}));return{ran:scripts,failures:results.filter((r)=>r.exitCode!==0).map((r)=>({script:r.script,output:r.output})),bypassed:false}}export function formatPreflightFailure(failures){const diagnosticLines=(output)=>output.split(`
|
|
2
2
|
`).map((line)=>line.trim()).filter((line)=>line&&!line.startsWith("[env]")&&!line.startsWith("$ ")&&!line.startsWith("error: script"));const lines=[`Release blocked: ${failures.length} pinned check${failures.length===1?"":"s"} failed.`,""];for(const failure of failures){lines.push(` ${failure.script}`);const informative=diagnosticLines(failure.output.replace(/^\[env-plugin\] Errors: \[\r?\n[\s\S]*?^\][ \t]*\r?$/gm,""));const diagnostics=informative.length?informative:diagnosticLines(failure.output);for(const line of diagnostics.slice(0,4))lines.push(` ${line}`);lines.push("")}lines.push("Nothing was bumped, committed, or tagged.");lines.push(`Regenerate the affected artifacts and retry, or set ${BYPASS_ENV}=1 to release anyway.`);return lines.join(`
|
|
3
3
|
`)}
|
package/dist/serve/dashboard.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync}from"node:fs";import{join}from"node:path";import process from"node:process";import{config}from"@stacksjs/config";import{log}from"@stacksjs/logging";import{projectPath,publicPath}from"@stacksjs/path";import{resolveComponentsLibraryRoot,resolveDefaultsRoot}from"../dev/defaults-resources";import{decideDashboardAccess}from"./dashboard-gate";process.env.APP_ENV||="production";process.env.NODE_ENV||="production";const port=Number(process.env.PORT_DASHBOARD||process.env.PORT)||3002;const defaultsRoot=resolveDefaultsRoot();const frameworkDashboard=join(defaultsRoot,"views/dashboard");const appDashboard=projectPath("resources/views/dashboard");const{authCookieName}=await import("@stacksjs/auth");const authCookie=authCookieName();function readCookie(header,name){if(!header)return;for(const part of header.split(";")){const raw=part.trim();const eq=raw.indexOf("=");if(eq<1)continue;if(raw.slice(0,eq)===name)return decodeURIComponent(raw.slice(eq+1))}return}const{isApiBoundRequest,proxyToBackend,resolveApiBase,resolveApiProxyRules,viewClientAddress}=await import("@stacksjs/server");const apiBase=resolveApiBase(config.ports?.api);const apiProxyRules=resolveApiProxyRules(config.server?.proxy);const{Auth}=await import("@stacksjs/auth");const{registerPeerSource}=await import("@stacksjs/router");const{serve}=await import("bun-plugin-stx/serve");await serve({patterns:[appDashboard,frameworkDashboard].filter((dir)=>existsSync(dir)),port,layoutsDir:join(appDashboard,"layouts"),fallbackLayoutsDir:join(frameworkDashboard,"layouts"),partialsDir:frameworkDashboard,componentsDir:projectPath("resources/components/Dashboard"),additionalComponentsDirs:[join(defaultsRoot,"resources/components/Dashboard")],fallbackComponentsDir:resolveComponentsLibraryRoot(),publicDir:publicPath(),quiet:true,clientAddress:viewClientAddress,onRequest:async(req,server)=>{registerPeerSource(server);const url=new URL(req.url);const decision=await decideDashboardAccess({method:req.method,pathname:url.pathname,token:readCookie(req.headers.get("cookie"),authCookie)},(token)=>Auth.getUserFromToken(token));if(decision.allow){if(isApiBoundRequest(req,url.pathname,apiProxyRules)){if(!apiBase){log.error(`No API target configured for ${url.pathname}. This dashboard 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.`);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})}}return null}const next=encodeURIComponent(url.pathname+url.search);return new Response(null,{status:302,headers:{location:`/login?next=${next}`,"cache-control":"no-store, private"}})}});console.log(`Dashboard server listening on port ${port}`);
|
|
1
|
+
import{existsSync}from"node:fs";import{join}from"node:path";import process from"node:process";import{config,feature,overridesReady}from"@stacksjs/config";import{log}from"@stacksjs/logging";import{projectPath,publicPath}from"@stacksjs/path";import{resolveComponentsLibraryRoot,resolveDefaultsRoot}from"../dev/defaults-resources";import{disabledFeatureViews}from"../dev/dashboard-feature-views";import{decideDashboardAccess}from"./dashboard-gate";process.env.APP_ENV||="production";process.env.NODE_ENV||="production";const port=Number(process.env.PORT_DASHBOARD||process.env.PORT)||3002;const defaultsRoot=resolveDefaultsRoot();const frameworkDashboard=join(defaultsRoot,"views/dashboard");const appDashboard=projectPath("resources/views/dashboard");const{authCookieName}=await import("@stacksjs/auth");const authCookie=authCookieName();function readCookie(header,name){if(!header)return;for(const part of header.split(";")){const raw=part.trim();const eq=raw.indexOf("=");if(eq<1)continue;if(raw.slice(0,eq)===name)return decodeURIComponent(raw.slice(eq+1))}return}const{isApiBoundRequest,proxyToBackend,resolveApiBase,resolveApiProxyRules,viewClientAddress}=await import("@stacksjs/server");const apiBase=resolveApiBase(config.ports?.api);const apiProxyRules=resolveApiProxyRules(config.server?.proxy);const{Auth}=await import("@stacksjs/auth");const{registerPeerSource}=await import("@stacksjs/router");const{serve}=await import("bun-plugin-stx/serve");await overridesReady;await serve({patterns:[appDashboard,frameworkDashboard].filter((dir)=>existsSync(dir)),exclude:disabledFeatureViews(frameworkDashboard,feature),port,layoutsDir:join(appDashboard,"layouts"),fallbackLayoutsDir:join(frameworkDashboard,"layouts"),partialsDir:frameworkDashboard,componentsDir:projectPath("resources/components/Dashboard"),additionalComponentsDirs:[join(defaultsRoot,"resources/components/Dashboard")],fallbackComponentsDir:resolveComponentsLibraryRoot(),publicDir:publicPath(),quiet:true,clientAddress:viewClientAddress,onRequest:async(req,server)=>{registerPeerSource(server);const url=new URL(req.url);const decision=await decideDashboardAccess({method:req.method,pathname:url.pathname,token:readCookie(req.headers.get("cookie"),authCookie)},(token)=>Auth.getUserFromToken(token));if(decision.allow){if(isApiBoundRequest(req,url.pathname,apiProxyRules)){if(!apiBase){log.error(`No API target configured for ${url.pathname}. This dashboard 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.`);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})}}return null}const next=encodeURIComponent(url.pathname+url.search);return new Response(null,{status:302,headers:{location:`/login?next=${next}`,"cache-control":"no-store, private"}})}});console.log(`Dashboard server listening on port ${port}`);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/actions",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.537",
|
|
6
6
|
"description": "The Stacks actions.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -66,58 +66,59 @@
|
|
|
66
66
|
"prepublishOnly": "bun run build"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@stacksjs/action-runner": "0.75.
|
|
70
|
-
"@stacksjs/ai": "0.75.
|
|
71
|
-
"@stacksjs/analytics": "0.75.
|
|
72
|
-
"@stacksjs/api": "0.75.
|
|
73
|
-
"@stacksjs/auth": "0.75.
|
|
74
|
-
"@stacksjs/build": "0.75.
|
|
69
|
+
"@stacksjs/action-runner": "0.75.537",
|
|
70
|
+
"@stacksjs/ai": "0.75.537",
|
|
71
|
+
"@stacksjs/analytics": "0.75.537",
|
|
72
|
+
"@stacksjs/api": "0.75.537",
|
|
73
|
+
"@stacksjs/auth": "0.75.537",
|
|
74
|
+
"@stacksjs/build": "0.75.537",
|
|
75
75
|
"@stacksjs/bumpx": "^0.2.26",
|
|
76
76
|
"@stacksjs/bunpress": "^0.2.15",
|
|
77
|
-
"@stacksjs/cli": "0.75.
|
|
78
|
-
"@stacksjs/cloud": "0.75.
|
|
79
|
-
"@stacksjs/cms": "0.75.
|
|
80
|
-
"@stacksjs/components": "0.2.
|
|
81
|
-
"@stacksjs/config": "0.75.
|
|
82
|
-
"@stacksjs/database": "0.75.
|
|
83
|
-
"@stacksjs/desktop-build": "0.75.
|
|
84
|
-
"@stacksjs/dns": "0.75.
|
|
85
|
-
"@stacksjs/
|
|
86
|
-
"@stacksjs/
|
|
87
|
-
"@stacksjs/
|
|
88
|
-
"@stacksjs/
|
|
77
|
+
"@stacksjs/cli": "0.75.537",
|
|
78
|
+
"@stacksjs/cloud": "0.75.537",
|
|
79
|
+
"@stacksjs/cms": "0.75.537",
|
|
80
|
+
"@stacksjs/components": "0.2.842",
|
|
81
|
+
"@stacksjs/config": "0.75.537",
|
|
82
|
+
"@stacksjs/database": "0.75.537",
|
|
83
|
+
"@stacksjs/desktop-build": "0.75.537",
|
|
84
|
+
"@stacksjs/dns": "0.75.537",
|
|
85
|
+
"@stacksjs/docs": "0.75.537",
|
|
86
|
+
"@stacksjs/enums": "0.75.537",
|
|
87
|
+
"@stacksjs/env": "0.75.537",
|
|
88
|
+
"@stacksjs/error-handling": "0.75.537",
|
|
89
|
+
"@stacksjs/github": "0.75.537",
|
|
89
90
|
"@stacksjs/gitit": "^0.2.5",
|
|
90
|
-
"@stacksjs/i18n": "0.75.
|
|
91
|
-
"@stacksjs/image": "0.75.
|
|
92
|
-
"@stacksjs/logging": "0.75.
|
|
91
|
+
"@stacksjs/i18n": "0.75.537",
|
|
92
|
+
"@stacksjs/image": "0.75.537",
|
|
93
|
+
"@stacksjs/logging": "0.75.537",
|
|
93
94
|
"@stacksjs/logsmith": "^0.2.11",
|
|
94
|
-
"@stacksjs/mobile": "0.75.
|
|
95
|
-
"@stacksjs/orm": "0.75.
|
|
96
|
-
"@stacksjs/path": "0.75.
|
|
97
|
-
"@stacksjs/payments": "0.75.
|
|
98
|
-
"@stacksjs/queue": "0.75.
|
|
99
|
-
"@stacksjs/registry": "0.75.
|
|
100
|
-
"@stacksjs/router": "0.75.
|
|
95
|
+
"@stacksjs/mobile": "0.75.537",
|
|
96
|
+
"@stacksjs/orm": "0.75.537",
|
|
97
|
+
"@stacksjs/path": "0.75.537",
|
|
98
|
+
"@stacksjs/payments": "0.75.537",
|
|
99
|
+
"@stacksjs/queue": "0.75.537",
|
|
100
|
+
"@stacksjs/registry": "0.75.537",
|
|
101
|
+
"@stacksjs/router": "0.75.537",
|
|
101
102
|
"@stacksjs/rpx": "^0.11.54",
|
|
102
|
-
"@stacksjs/scheduler": "0.75.
|
|
103
|
-
"@stacksjs/search-engine": "0.75.
|
|
104
|
-
"@stacksjs/security": "0.75.
|
|
105
|
-
"@stacksjs/server": "0.75.
|
|
106
|
-
"@stacksjs/sites": "0.75.
|
|
107
|
-
"@stacksjs/storage": "0.75.
|
|
108
|
-
"@stacksjs/strings": "0.75.
|
|
109
|
-
"@stacksjs/stx": "0.2.
|
|
103
|
+
"@stacksjs/scheduler": "0.75.537",
|
|
104
|
+
"@stacksjs/search-engine": "0.75.537",
|
|
105
|
+
"@stacksjs/security": "0.75.537",
|
|
106
|
+
"@stacksjs/server": "0.75.537",
|
|
107
|
+
"@stacksjs/sites": "0.75.537",
|
|
108
|
+
"@stacksjs/storage": "0.75.537",
|
|
109
|
+
"@stacksjs/strings": "0.75.537",
|
|
110
|
+
"@stacksjs/stx": "0.2.842",
|
|
110
111
|
"@stacksjs/tlsx": "^0.13.19",
|
|
111
112
|
"@stacksjs/ts-cloud": "^0.16.109",
|
|
112
113
|
"@stacksjs/ts-md": "^0.1.1",
|
|
113
|
-
"@stacksjs/tunnel": "0.75.
|
|
114
|
-
"@stacksjs/types": "0.75.
|
|
115
|
-
"@stacksjs/utils": "0.75.
|
|
116
|
-
"@stacksjs/whois": "0.75.
|
|
117
|
-
"bun-plugin-stx": "0.2.
|
|
114
|
+
"@stacksjs/tunnel": "0.75.537",
|
|
115
|
+
"@stacksjs/types": "0.75.537",
|
|
116
|
+
"@stacksjs/utils": "0.75.537",
|
|
117
|
+
"@stacksjs/whois": "0.75.537",
|
|
118
|
+
"bun-plugin-stx": "0.2.842"
|
|
118
119
|
},
|
|
119
120
|
"peerDependencies": {
|
|
120
|
-
"craft-native": ">=0.0.
|
|
121
|
+
"craft-native": ">=0.0.491",
|
|
121
122
|
"pickier": "^0.1.75"
|
|
122
123
|
},
|
|
123
124
|
"peerDependenciesMeta": {
|
|
@@ -129,7 +130,7 @@
|
|
|
129
130
|
}
|
|
130
131
|
},
|
|
131
132
|
"devDependencies": {
|
|
132
|
-
"@stacksjs/validation": "0.75.
|
|
133
|
+
"@stacksjs/validation": "0.75.537",
|
|
133
134
|
"better-dx": "^0.2.24"
|
|
134
135
|
}
|
|
135
136
|
}
|