-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
117 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { dev } from './dev'; | ||
|
||
export async function start() { | ||
await dev(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { error } from '@zely-js/logger'; | ||
import { pathToRegexp } from '@zept/path-regexp'; | ||
|
||
import { performance } from 'node:perf_hooks'; | ||
import { join, relative } from 'node:path'; | ||
|
||
import { readDirectory } from '~/zely-js-core/lib/read-directory'; | ||
import type { UserConfig } from '~/zely-js-core'; | ||
import { transformFilename } from '~/zely-js-core/lib/file-to-path'; | ||
import { removeExtension } from '~/zely-js-core/lib/ext'; | ||
|
||
import { PageCache } from './controller'; | ||
import { filenameToRoute } from './server'; | ||
|
||
export async function productionBuild(options: UserConfig) { | ||
// exit early if no options provided | ||
if (!options) { | ||
error(new Error('config must be provided')); | ||
process.exit(1); | ||
} | ||
|
||
const files = readDirectory(join(options.cwd || process.cwd(), 'pages')); | ||
const pages = new PageCache( | ||
filenameToRoute( | ||
files.map((file) => { | ||
const relativePath = relative(join(options.cwd || process.cwd(), 'pages'), file); | ||
const path = transformFilename(removeExtension(relativePath), true); | ||
|
||
return { | ||
filename: relativePath.replace(/\\/g, '/'), | ||
regex: null, | ||
params: null, | ||
path, | ||
id: performance.now(), | ||
module: { | ||
type: 'unknown', | ||
isLoaded: false, | ||
}, | ||
}; | ||
}) | ||
).map((file) => { | ||
const outregex = pathToRegexp(file.path); | ||
|
||
return { | ||
...file, | ||
regex: outregex.pattern, | ||
params: outregex.params, | ||
}; | ||
}), | ||
options | ||
); | ||
|
||
await pages.productionBuild(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,6 @@ export interface UserConfig { | |
* @default true | ||
*/ | ||
enableReporter?: boolean; | ||
|
||
keepDist?: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
import { ZeptServer } from '@zept/http'; | ||
import { UserConfig } from './config'; | ||
|
||
export function createZelyServer( | ||
options: UserConfig | ||
): Promise<{ | ||
export function createZelyServer(options: UserConfig): Promise<{ | ||
server: ZeptServer; | ||
applyZelyMiddlewares: (serverInstance: ZeptServer) => void; | ||
}>; | ||
export function productionBuild(options: UserConfig): Promise<void>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
"zely-cli": "workspace:*" | ||
}, | ||
"scripts": { | ||
"start": "zely-cli start", | ||
"dev": "zely-cli dev" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters