@alstar/studio 0.0.0-beta.14 → 0.0.0-beta.15

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.
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env node
2
+ import path from 'node:path'
3
+ import { type SSGPlugin, toSSG } from 'hono/ssg'
4
+ import fs from 'fs/promises'
5
+
6
+ const root = path.resolve('.')
7
+
8
+ let app
9
+
10
+ try {
11
+ app = (await import(path.join(root, 'index.ts'))).default
12
+ } catch (error) {
13
+ console.log(error)
14
+ console.log('Found no app')
15
+ console.log('Main app needs to be the default export in ./index.ts')
16
+ process.exit(1)
17
+ }
18
+
19
+ await existingStaticFolder()
20
+
21
+ const excludeStudioPlugin: SSGPlugin = {
22
+ beforeRequestHook: (req) => {
23
+ if (!req.url.includes('/studio/')) {
24
+ return req
25
+ }
26
+ return false
27
+ },
28
+ }
29
+
30
+ await toSSG(app, fs, { plugins: [excludeStudioPlugin] })
31
+
32
+ await fs.cp(path.join(root, 'public'), path.join(root, 'static'), {
33
+ recursive: true,
34
+ })
35
+
36
+ console.log('🚀 Done generating static build')
37
+
38
+ process.exit(0)
39
+
40
+ async function existingStaticFolder() {
41
+ return fs.rm(path.join(root, 'static'), { recursive: true }).catch(() => {})
42
+ }
package/index.ts CHANGED
@@ -14,6 +14,7 @@ import { getConfig } from './utils/get-config.ts'
14
14
  import startupLog from './utils/startup-log.ts'
15
15
  import { apiRoutes } from './api/index.ts'
16
16
  import { mcpRoutes } from './api/mcp.ts'
17
+ import packageJSON from './package.json' with { type: 'json' }
17
18
 
18
19
  import auth from './utils/auth.ts'
19
20
  import ErrorPage from './pages/error.ts'
@@ -25,6 +26,7 @@ export let rootdir = './node_modules/@alstar/studio'
25
26
  export let studioStructure: types.Structure = {}
26
27
  export let studioConfig: types.StudioConfig = {
27
28
  siteName: '',
29
+ fileBasedRouter: true,
28
30
  port: 3000,
29
31
  structure: {},
30
32
  }
@@ -72,8 +74,10 @@ const createStudio = async (config: types.StudioConfig) => {
72
74
  /**
73
75
  * User pages
74
76
  */
75
- const pages = await fileBasedRouter('./pages')
76
- if (pages) app.route('/', pages)
77
+ if (studioConfig.fileBasedRouter) {
78
+ const pages = await fileBasedRouter('./pages')
79
+ if (pages) app.route('/', pages)
80
+ }
77
81
 
78
82
  /**
79
83
  * Error pages
@@ -95,7 +99,8 @@ const createStudio = async (config: types.StudioConfig) => {
95
99
  '/studio/backups/*',
96
100
  serveStatic({
97
101
  root: './',
98
- rewriteRequestPath: (path) => path.replace(/^\/studio\/backups/, '/backups'),
102
+ rewriteRequestPath: (path) =>
103
+ path.replace(/^\/studio\/backups/, '/backups'),
99
104
  }),
100
105
  )
101
106
 
@@ -141,3 +146,4 @@ export { type RequestContext } from './types.ts'
141
146
  export { createStudio }
142
147
  export { html, type HtmlEscapedString } from './utils/html.ts'
143
148
  export { query } from './queries/index.ts'
149
+ export const version = packageJSON.version
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@alstar/studio",
3
- "version": "0.0.0-beta.14",
3
+ "version": "0.0.0-beta.15",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
+ "bin": {
7
+ "alstar": "./bin/build-ssg.ts"
8
+ },
6
9
  "engines": {
7
10
  "node": ">=23.8"
8
11
  },
@@ -10,9 +13,9 @@
10
13
  "@hono/node-server": "^1.18.1",
11
14
  "@starfederation/datastar-sdk": "1.0.0-RC.1",
12
15
  "hono": "^4.8.12",
16
+ "@alstar/ui": "0.0.0-beta.2",
13
17
  "@alstar/refresher": "0.0.0-beta.3",
14
- "@alstar/db": "0.0.0-beta.1",
15
- "@alstar/ui": "0.0.0-beta.1"
18
+ "@alstar/db": "0.0.0-beta.1"
16
19
  },
17
20
  "devDependencies": {
18
21
  "@types/node": "^24.1.0",
package/types.ts CHANGED
@@ -153,6 +153,7 @@ export type BlockStatus = 'enabled' | 'disabled'
153
153
  export type StudioConfig = {
154
154
  siteName?: string
155
155
  honoConfig?: HonoOptions<BlankEnv>
156
+ fileBasedRouter?: boolean,
156
157
  port?: number
157
158
  structure: Structure
158
159
  }