zylaris 1.0.2
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/LICENSE +21 -0
- package/README.md +558 -0
- package/Zylaris.js.png +0 -0
- package/examples/default/index.html +13 -0
- package/examples/default/package.json +23 -0
- package/examples/default/src/app/about/page.tsx +18 -0
- package/examples/default/src/app/counter/page.tsx +22 -0
- package/examples/default/src/app/global.css +225 -0
- package/examples/default/src/app/layout.tsx +33 -0
- package/examples/default/src/app/page.tsx +14 -0
- package/examples/default/src/entry-client.tsx +87 -0
- package/examples/default/src/entry-server.tsx +52 -0
- package/examples/default/src/router.ts +60 -0
- package/examples/default/tsconfig.json +28 -0
- package/examples/default/zylaris.config.ts +24 -0
- package/package.json +34 -0
- package/packages/adapter/package.json +59 -0
- package/packages/adapter/src/adapters/bun.ts +215 -0
- package/packages/adapter/src/adapters/cloudflare.ts +278 -0
- package/packages/adapter/src/adapters/deno.ts +219 -0
- package/packages/adapter/src/adapters/netlify.ts +274 -0
- package/packages/adapter/src/adapters/node.ts +155 -0
- package/packages/adapter/src/adapters/static.ts +134 -0
- package/packages/adapter/src/adapters/vercel.ts +239 -0
- package/packages/adapter/src/index.ts +115 -0
- package/packages/adapter/src/lib/builder.ts +361 -0
- package/packages/adapter/src/types.ts +191 -0
- package/packages/adapter/tsconfig.json +8 -0
- package/packages/cli/package.json +43 -0
- package/packages/cli/src/bin.ts +107 -0
- package/packages/cli/src/commands/build.ts +197 -0
- package/packages/cli/src/commands/create.ts +222 -0
- package/packages/cli/src/commands/deploy.ts +90 -0
- package/packages/cli/src/commands/dev.ts +108 -0
- package/packages/cli/src/index.ts +6 -0
- package/packages/cli/tsconfig.json +9 -0
- package/packages/compiler/package.json +39 -0
- package/packages/compiler/src/index.ts +210 -0
- package/packages/compiler/src/jit.ts +187 -0
- package/packages/compiler/tsconfig.json +9 -0
- package/packages/core/package.json +55 -0
- package/packages/core/src/components.test.ts +125 -0
- package/packages/core/src/components.ts +181 -0
- package/packages/core/src/config.ts +204 -0
- package/packages/core/src/hooks.ts +142 -0
- package/packages/core/src/index.ts +59 -0
- package/packages/core/src/jsx-runtime.ts +46 -0
- package/packages/core/tsconfig.json +16 -0
- package/packages/dev-server/package.json +51 -0
- package/packages/dev-server/src/index.ts +306 -0
- package/packages/dev-server/src/jit-middleware.ts +78 -0
- package/packages/dev-server/tsconfig.json +9 -0
- package/packages/plugins/package.json +44 -0
- package/packages/plugins/src/cdn/loader.ts +275 -0
- package/packages/plugins/src/index.ts +238 -0
- package/packages/plugins/src/loaders/auto-import.ts +219 -0
- package/packages/plugins/src/loaders/external.ts +332 -0
- package/packages/plugins/src/transforms/index.ts +407 -0
- package/packages/plugins/src/types.ts +296 -0
- package/packages/plugins/tsconfig.json +8 -0
- package/packages/reactivity/package.json +36 -0
- package/packages/reactivity/src/computed.d.ts +3 -0
- package/packages/reactivity/src/computed.d.ts.map +1 -0
- package/packages/reactivity/src/computed.js +64 -0
- package/packages/reactivity/src/computed.js.map +1 -0
- package/packages/reactivity/src/computed.test.ts +83 -0
- package/packages/reactivity/src/computed.ts +69 -0
- package/packages/reactivity/src/index.d.ts +6 -0
- package/packages/reactivity/src/index.d.ts.map +1 -0
- package/packages/reactivity/src/index.js +7 -0
- package/packages/reactivity/src/index.js.map +1 -0
- package/packages/reactivity/src/index.ts +18 -0
- package/packages/reactivity/src/resource.d.ts +6 -0
- package/packages/reactivity/src/resource.d.ts.map +1 -0
- package/packages/reactivity/src/resource.js +43 -0
- package/packages/reactivity/src/resource.js.map +1 -0
- package/packages/reactivity/src/resource.test.ts +70 -0
- package/packages/reactivity/src/resource.ts +59 -0
- package/packages/reactivity/src/signal.d.ts +7 -0
- package/packages/reactivity/src/signal.d.ts.map +1 -0
- package/packages/reactivity/src/signal.js +145 -0
- package/packages/reactivity/src/signal.js.map +1 -0
- package/packages/reactivity/src/signal.test.ts +130 -0
- package/packages/reactivity/src/signal.ts +207 -0
- package/packages/reactivity/src/store.d.ts +4 -0
- package/packages/reactivity/src/store.d.ts.map +1 -0
- package/packages/reactivity/src/store.js +62 -0
- package/packages/reactivity/src/store.js.map +1 -0
- package/packages/reactivity/src/store.test.ts +38 -0
- package/packages/reactivity/src/store.ts +111 -0
- package/packages/reactivity/src/types.d.ts +43 -0
- package/packages/reactivity/src/types.d.ts.map +1 -0
- package/packages/reactivity/src/types.js +3 -0
- package/packages/reactivity/src/types.js.map +1 -0
- package/packages/reactivity/src/types.ts +43 -0
- package/packages/reactivity/tsconfig.json +9 -0
- package/packages/router/package.json +44 -0
- package/packages/router/src/components.tsx +150 -0
- package/packages/router/src/fs-router.ts +163 -0
- package/packages/router/src/index.ts +22 -0
- package/packages/router/src/router.test.ts +111 -0
- package/packages/router/src/router.ts +112 -0
- package/packages/router/src/types.ts +69 -0
- package/packages/router/tsconfig.json +10 -0
- package/packages/server/package.json +41 -0
- package/packages/server/src/action.test.ts +102 -0
- package/packages/server/src/action.ts +201 -0
- package/packages/server/src/api.ts +143 -0
- package/packages/server/src/index.ts +18 -0
- package/packages/server/src/types.ts +72 -0
- package/packages/server/tsconfig.json +9 -0
- package/pnpm-workspace.yaml +4 -0
- package/scripts/publish.ps1 +138 -0
- package/scripts/publish.sh +142 -0
- package/tsconfig.json +28 -0
- package/turbo.json +24 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter Types - Universal deployment interface
|
|
3
|
+
* Supports: Static, Node.js, Vercel, Netlify, Cloudflare, Deno, Bun
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { BuildOptions } from 'esbuild';
|
|
7
|
+
|
|
8
|
+
/** Deployment target platforms */
|
|
9
|
+
export type DeploymentTarget =
|
|
10
|
+
| 'static' // GitHub Pages, Surge.sh, etc.
|
|
11
|
+
| 'node' // Node.js server
|
|
12
|
+
| 'vercel' // Vercel (Serverless + Edge)
|
|
13
|
+
| 'netlify' // Netlify (Functions + Edge)
|
|
14
|
+
| 'cloudflare' // Cloudflare Pages/Workers
|
|
15
|
+
| 'deno' // Deno Deploy
|
|
16
|
+
| 'bun'; // Bun runtime
|
|
17
|
+
|
|
18
|
+
/** Output format for generated files */
|
|
19
|
+
export type OutputFormat = 'esm' | 'cjs' | 'iife';
|
|
20
|
+
|
|
21
|
+
/** Serverless/Edge function config */
|
|
22
|
+
export interface FunctionConfig {
|
|
23
|
+
/** Function name */
|
|
24
|
+
name?: string;
|
|
25
|
+
/** Route pattern */
|
|
26
|
+
route?: string;
|
|
27
|
+
/** Memory allocation (MB) */
|
|
28
|
+
memory?: number;
|
|
29
|
+
/** Timeout (seconds) */
|
|
30
|
+
timeout?: number;
|
|
31
|
+
/** Regions to deploy */
|
|
32
|
+
regions?: string[];
|
|
33
|
+
/** Edge function flag */
|
|
34
|
+
edge?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Static generation options */
|
|
38
|
+
export interface StaticOptions {
|
|
39
|
+
/** Routes to pre-render */
|
|
40
|
+
routes?: string[];
|
|
41
|
+
/** 404 page path */
|
|
42
|
+
fallback?: string;
|
|
43
|
+
/** Crawl dynamic routes */
|
|
44
|
+
crawl?: boolean;
|
|
45
|
+
/** Base path for assets */
|
|
46
|
+
base?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Adapter build configuration */
|
|
50
|
+
export interface AdapterConfig {
|
|
51
|
+
/** Target platform */
|
|
52
|
+
target: DeploymentTarget;
|
|
53
|
+
/** Entry point */
|
|
54
|
+
entry?: string;
|
|
55
|
+
/** Output directory */
|
|
56
|
+
outDir?: string;
|
|
57
|
+
/** Static generation options */
|
|
58
|
+
static?: StaticOptions;
|
|
59
|
+
/** Serverless function config */
|
|
60
|
+
function?: FunctionConfig;
|
|
61
|
+
/** esbuild options */
|
|
62
|
+
esbuild?: BuildOptions;
|
|
63
|
+
/** Environment variables to include */
|
|
64
|
+
env?: Record<string, string>;
|
|
65
|
+
/** Headers for HTTP responses */
|
|
66
|
+
headers?: Record<string, string>;
|
|
67
|
+
/** Redirects configuration */
|
|
68
|
+
redirects?: Array<{ from: string; to: string; status?: number }>;
|
|
69
|
+
/** Rewrites configuration */
|
|
70
|
+
rewrites?: Array<{ from: string; to: string }>;
|
|
71
|
+
/** Trailing slash handling */
|
|
72
|
+
trailingSlash?: 'always' | 'never' | 'ignore';
|
|
73
|
+
/** Clean URLs (no .html extension) */
|
|
74
|
+
cleanUrls?: boolean;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Build result for any adapter */
|
|
78
|
+
export interface BuildResult {
|
|
79
|
+
/** Success flag */
|
|
80
|
+
success: boolean;
|
|
81
|
+
/** Output directory */
|
|
82
|
+
outDir: string;
|
|
83
|
+
/** Generated files */
|
|
84
|
+
files: string[];
|
|
85
|
+
/** Warnings */
|
|
86
|
+
warnings: string[];
|
|
87
|
+
/** Errors */
|
|
88
|
+
errors: string[];
|
|
89
|
+
/** Bundle analysis */
|
|
90
|
+
analysis?: {
|
|
91
|
+
/** Total bundle size */
|
|
92
|
+
totalSize: number;
|
|
93
|
+
/** Client bundle size */
|
|
94
|
+
clientSize: number;
|
|
95
|
+
/** Server bundle size */
|
|
96
|
+
serverSize?: number;
|
|
97
|
+
/** Asset sizes */
|
|
98
|
+
assets: Array<{ file: string; size: number; gzip: number }>;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Server entry point handler */
|
|
103
|
+
export type RequestHandler = (
|
|
104
|
+
request: Request,
|
|
105
|
+
context: {
|
|
106
|
+
params: Record<string, string>;
|
|
107
|
+
url: URL;
|
|
108
|
+
headers: Headers;
|
|
109
|
+
cookies: Map<string, string>;
|
|
110
|
+
}
|
|
111
|
+
) => Response | Promise<Response>;
|
|
112
|
+
|
|
113
|
+
/** Adapter interface */
|
|
114
|
+
export interface Adapter {
|
|
115
|
+
/** Adapter name */
|
|
116
|
+
readonly name: string;
|
|
117
|
+
/** Target platform */
|
|
118
|
+
readonly target: DeploymentTarget;
|
|
119
|
+
/** Build for target platform */
|
|
120
|
+
build(config: AdapterConfig): Promise<BuildResult>;
|
|
121
|
+
/** Preview locally */
|
|
122
|
+
preview?(config: AdapterConfig, port?: number): Promise<void>;
|
|
123
|
+
/** Deploy to platform */
|
|
124
|
+
deploy?(config: AdapterConfig): Promise<void>;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Route manifest for static generation */
|
|
128
|
+
export interface RouteManifest {
|
|
129
|
+
/** Route path */
|
|
130
|
+
path: string;
|
|
131
|
+
/** File pattern */
|
|
132
|
+
file: string;
|
|
133
|
+
/** Is dynamic route */
|
|
134
|
+
dynamic?: boolean;
|
|
135
|
+
/** Required params */
|
|
136
|
+
params?: string[];
|
|
137
|
+
/** Preload data */
|
|
138
|
+
data?: unknown;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Manifest for deployment */
|
|
142
|
+
export interface DeploymentManifest {
|
|
143
|
+
/** Framework version */
|
|
144
|
+
version: string;
|
|
145
|
+
/** Build timestamp */
|
|
146
|
+
timestamp: string;
|
|
147
|
+
/** Routes */
|
|
148
|
+
routes: RouteManifest[];
|
|
149
|
+
/** Assets with hashes */
|
|
150
|
+
assets: Record<string, string>;
|
|
151
|
+
/** Entry points */
|
|
152
|
+
entry: {
|
|
153
|
+
client: string;
|
|
154
|
+
server?: string;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** Edge runtime context */
|
|
159
|
+
export interface EdgeContext {
|
|
160
|
+
/** Wait until promise resolves */
|
|
161
|
+
waitUntil(promise: Promise<unknown>): void;
|
|
162
|
+
/** Pass-through cache */
|
|
163
|
+
passThroughOnException(): void;
|
|
164
|
+
/** Environment bindings */
|
|
165
|
+
env: Record<string, unknown>;
|
|
166
|
+
/** Execution context */
|
|
167
|
+
executionCtx?: {
|
|
168
|
+
waitUntil(promise: Promise<unknown>): void;
|
|
169
|
+
passThroughOnException(): void;
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** Platform-specific config files */
|
|
174
|
+
export interface PlatformConfig {
|
|
175
|
+
vercel?: {
|
|
176
|
+
buildCommand?: string;
|
|
177
|
+
outputDirectory?: string;
|
|
178
|
+
framework?: string | null;
|
|
179
|
+
installCommand?: string;
|
|
180
|
+
};
|
|
181
|
+
netlify?: {
|
|
182
|
+
buildCommand?: string;
|
|
183
|
+
publishDirectory?: string;
|
|
184
|
+
functionsDirectory?: string;
|
|
185
|
+
};
|
|
186
|
+
cloudflare?: {
|
|
187
|
+
buildCommand?: string;
|
|
188
|
+
destinationDirectory?: string;
|
|
189
|
+
rootDirectory?: string;
|
|
190
|
+
};
|
|
191
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zylaris/cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLI for Zylaris Framework",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"zylaris": "./dist/bin.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"templates"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"dev": "tsc --watch",
|
|
17
|
+
"typecheck": "tsc --noEmit",
|
|
18
|
+
"clean": "rm -rf dist"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@zylaris/adapter": "workspace:*",
|
|
22
|
+
"@zylaris/compiler": "workspace:*",
|
|
23
|
+
"@zylaris/dev-server": "workspace:*",
|
|
24
|
+
"commander": "^11.1.0",
|
|
25
|
+
"chalk": "^5.3.0",
|
|
26
|
+
"inquirer": "^9.2.12",
|
|
27
|
+
"ora": "^8.0.1",
|
|
28
|
+
"fs-extra": "^11.2.0",
|
|
29
|
+
"glob": "^10.3.10",
|
|
30
|
+
"chokidar": "^3.5.3"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/fs-extra": "^11.0.4",
|
|
34
|
+
"@types/inquirer": "^9.0.7",
|
|
35
|
+
"@types/node": "^20.0.0",
|
|
36
|
+
"typescript": "^5.3.3"
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"cli",
|
|
40
|
+
"zylaris"
|
|
41
|
+
],
|
|
42
|
+
"license": "MIT"
|
|
43
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { program } from 'commander';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { createProject } from './commands/create.js';
|
|
6
|
+
import { devServer } from './commands/dev.js';
|
|
7
|
+
import { buildProject } from './commands/build.js';
|
|
8
|
+
import { deployProject } from './commands/deploy.js';
|
|
9
|
+
|
|
10
|
+
const version = '1.0.0';
|
|
11
|
+
|
|
12
|
+
program
|
|
13
|
+
.name('zylaris')
|
|
14
|
+
.description('Zylaris Framework CLI')
|
|
15
|
+
.version(version);
|
|
16
|
+
|
|
17
|
+
// Create command
|
|
18
|
+
program
|
|
19
|
+
.command('create <name>')
|
|
20
|
+
.description('Create a new Zylaris project')
|
|
21
|
+
.option('-t, --template <template>', 'Project template', 'default')
|
|
22
|
+
.option('--skip-install', 'Skip package installation')
|
|
23
|
+
.action(async (name, options) => {
|
|
24
|
+
console.log(chalk.blue(`Creating Zylaris project: ${name}`));
|
|
25
|
+
await createProject(name, options);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Dev command
|
|
29
|
+
program
|
|
30
|
+
.command('dev')
|
|
31
|
+
.description('Start development server')
|
|
32
|
+
.option('-p, --port <port>', 'Port number', '2727')
|
|
33
|
+
.option('-h, --host <host>', 'Host address', 'localhost')
|
|
34
|
+
.option('--turbo', 'Enable turbo mode')
|
|
35
|
+
.action(async (options) => {
|
|
36
|
+
console.log(chalk.blue('Starting development server...'));
|
|
37
|
+
await devServer(options);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Build command
|
|
41
|
+
program
|
|
42
|
+
.command('build')
|
|
43
|
+
.description('Build for production')
|
|
44
|
+
.option('-a, --adapter <adapter>', 'Deployment adapter (static, node, vercel, netlify, cloudflare, deno, bun)', 'static')
|
|
45
|
+
.option('--analyze', 'Analyze bundle size')
|
|
46
|
+
.option('--static', 'Static export (pre-render pages)')
|
|
47
|
+
.option('--edge', 'Use Edge runtime (for vercel, netlify, cloudflare)')
|
|
48
|
+
.option('--outDir <dir>', 'Output directory', 'dist')
|
|
49
|
+
.option('--memory <mb>', 'Serverless memory (MB)', '1024')
|
|
50
|
+
.option('--timeout <seconds>', 'Function timeout (seconds)', '10')
|
|
51
|
+
.option('--regions <regions>', 'Deployment regions (comma-separated)')
|
|
52
|
+
.action(async (options) => {
|
|
53
|
+
console.log(chalk.blue(`Building for production with ${options.adapter} adapter...`));
|
|
54
|
+
await buildProject(options);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Adapters command
|
|
58
|
+
program
|
|
59
|
+
.command('adapters')
|
|
60
|
+
.description('List available deployment adapters')
|
|
61
|
+
.action(async () => {
|
|
62
|
+
const { printAdapters } = await import('./commands/build.js');
|
|
63
|
+
printAdapters();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Deploy command
|
|
67
|
+
program
|
|
68
|
+
.command('deploy')
|
|
69
|
+
.description('Deploy project')
|
|
70
|
+
.option('--vercel', 'Deploy to Vercel')
|
|
71
|
+
.option('--netlify', 'Deploy to Netlify')
|
|
72
|
+
.option('--cloudflare', 'Deploy to Cloudflare Pages')
|
|
73
|
+
.action(async (options) => {
|
|
74
|
+
console.log(chalk.blue('Deploying...'));
|
|
75
|
+
await deployProject(options);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Test command
|
|
79
|
+
program
|
|
80
|
+
.command('test')
|
|
81
|
+
.description('Run tests')
|
|
82
|
+
.option('--watch', 'Watch mode')
|
|
83
|
+
.option('--coverage', 'Generate coverage report')
|
|
84
|
+
.action(async () => {
|
|
85
|
+
console.log(chalk.blue('Running tests...'));
|
|
86
|
+
// Delegate to test runner
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Lint command
|
|
90
|
+
program
|
|
91
|
+
.command('lint')
|
|
92
|
+
.description('Run ESLint')
|
|
93
|
+
.action(async () => {
|
|
94
|
+
console.log(chalk.blue('Linting...'));
|
|
95
|
+
// Delegate to ESLint
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Type check command
|
|
99
|
+
program
|
|
100
|
+
.command('typecheck')
|
|
101
|
+
.description('Run TypeScript type checking')
|
|
102
|
+
.action(async () => {
|
|
103
|
+
console.log(chalk.blue('Type checking...'));
|
|
104
|
+
// Delegate to TypeScript
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
program.parse();
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import chalk from 'chalk';
|
|
4
|
+
import ora from 'ora';
|
|
5
|
+
import type { AdapterConfig, DeploymentTarget } from '@zylaris/adapter';
|
|
6
|
+
import { getAdapter, listAdapters } from '@zylaris/adapter';
|
|
7
|
+
|
|
8
|
+
interface BuildOptions {
|
|
9
|
+
analyze?: boolean;
|
|
10
|
+
static?: boolean;
|
|
11
|
+
adapter?: DeploymentTarget;
|
|
12
|
+
outDir?: string;
|
|
13
|
+
edge?: boolean;
|
|
14
|
+
memory?: number;
|
|
15
|
+
timeout?: number;
|
|
16
|
+
regions?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function buildProject(options: BuildOptions): Promise<void> {
|
|
20
|
+
const spinner = ora('Building for production...').start();
|
|
21
|
+
const startTime = Date.now();
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
const cwd = process.cwd();
|
|
25
|
+
|
|
26
|
+
// Determine adapter/target
|
|
27
|
+
const target = options.adapter || 'static';
|
|
28
|
+
const adapter = getAdapter(target);
|
|
29
|
+
|
|
30
|
+
spinner.text = `Building with ${adapter.name} adapter...`;
|
|
31
|
+
|
|
32
|
+
// Load config if exists
|
|
33
|
+
const configPath = resolve(cwd, 'zylaris.config.ts');
|
|
34
|
+
let userConfig: Partial<AdapterConfig> = {};
|
|
35
|
+
|
|
36
|
+
if (await fs.pathExists(configPath)) {
|
|
37
|
+
try {
|
|
38
|
+
const configModule = await import(configPath);
|
|
39
|
+
userConfig = configModule.default || configModule;
|
|
40
|
+
} catch {
|
|
41
|
+
// Config is optional
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Build adapter config
|
|
46
|
+
const config: AdapterConfig = {
|
|
47
|
+
target,
|
|
48
|
+
outDir: options.outDir || userConfig.outDir || 'dist',
|
|
49
|
+
static: options.static || userConfig.static ? {
|
|
50
|
+
routes: ['/', '/about', '/contact'], // Auto-detect in real implementation
|
|
51
|
+
...userConfig.static,
|
|
52
|
+
} : undefined,
|
|
53
|
+
function: {
|
|
54
|
+
edge: options.edge ?? userConfig.function?.edge ?? false,
|
|
55
|
+
memory: options.memory ?? userConfig.function?.memory ?? 1024,
|
|
56
|
+
timeout: options.timeout ?? userConfig.function?.timeout ?? 10,
|
|
57
|
+
regions: options.regions?.split(',') ?? userConfig.function?.regions ?? ['iad1'],
|
|
58
|
+
...userConfig.function,
|
|
59
|
+
},
|
|
60
|
+
esbuild: userConfig.esbuild,
|
|
61
|
+
env: userConfig.env,
|
|
62
|
+
headers: {
|
|
63
|
+
'/*': 'X-Frame-Options: DENY\n X-Content-Type-Options: nosniff',
|
|
64
|
+
...userConfig.headers,
|
|
65
|
+
},
|
|
66
|
+
redirects: userConfig.redirects,
|
|
67
|
+
rewrites: userConfig.rewrites,
|
|
68
|
+
trailingSlash: userConfig.trailingSlash ?? 'ignore',
|
|
69
|
+
cleanUrls: userConfig.cleanUrls ?? true,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// Run build
|
|
73
|
+
const result = await adapter.build(config);
|
|
74
|
+
|
|
75
|
+
const duration = ((Date.now() - startTime) / 1000).toFixed(2);
|
|
76
|
+
|
|
77
|
+
if (!result.success) {
|
|
78
|
+
spinner.fail(chalk.red('Build failed'));
|
|
79
|
+
for (const error of result.errors) {
|
|
80
|
+
console.error(chalk.red(` ✗ ${error}`));
|
|
81
|
+
}
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
spinner.succeed(chalk.green(`Build completed in ${duration}s`));
|
|
86
|
+
|
|
87
|
+
// Print summary
|
|
88
|
+
console.log('\n' + chalk.bold('Output:'));
|
|
89
|
+
console.log(chalk.cyan(` ${result.outDir}/`));
|
|
90
|
+
|
|
91
|
+
if (result.files.length > 0) {
|
|
92
|
+
console.log(chalk.gray(` (${result.files.length} files generated)`));
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Print bundle analysis
|
|
96
|
+
if (result.analysis && options.analyze) {
|
|
97
|
+
console.log('\n' + chalk.bold('Bundle Analysis:'));
|
|
98
|
+
console.log(` Total: ${formatSize(result.analysis.totalSize)}`);
|
|
99
|
+
console.log(` Client: ${formatSize(result.analysis.clientSize)}`);
|
|
100
|
+
if (result.analysis.serverSize) {
|
|
101
|
+
console.log(` Server: ${formatSize(result.analysis.serverSize)}`);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
console.log('\n Top Assets:');
|
|
105
|
+
for (const asset of result.analysis.assets.slice(0, 5)) {
|
|
106
|
+
console.log(` ${asset.file}`);
|
|
107
|
+
console.log(` Size: ${formatSize(asset.size)} | Gzipped: ${formatSize(asset.gzip)}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Print deployment info
|
|
112
|
+
console.log('\n' + chalk.bold('Deploy:'));
|
|
113
|
+
printDeployInstructions(target, result.outDir);
|
|
114
|
+
|
|
115
|
+
if (result.warnings.length > 0) {
|
|
116
|
+
console.log('\n' + chalk.yellow('Warnings:'));
|
|
117
|
+
for (const warning of result.warnings) {
|
|
118
|
+
console.log(chalk.yellow(` ⚠ ${warning}`));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
} catch (error) {
|
|
123
|
+
spinner.fail(chalk.red('Build failed'));
|
|
124
|
+
console.error(error);
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Print deployment instructions */
|
|
130
|
+
function printDeployInstructions(target: DeploymentTarget, outDir: string): void {
|
|
131
|
+
const instructions: Record<DeploymentTarget, string[]> = {
|
|
132
|
+
static: [
|
|
133
|
+
' Upload to any static hosting:',
|
|
134
|
+
chalk.gray(` - GitHub Pages: push to gh-pages branch`),
|
|
135
|
+
chalk.gray(` - Netlify: npx netlify deploy --prod --dir=${outDir}`),
|
|
136
|
+
chalk.gray(` - Vercel: npx vercel --prod`),
|
|
137
|
+
chalk.gray(` - Cloudflare Pages: npx wrangler pages deploy ${outDir}`),
|
|
138
|
+
],
|
|
139
|
+
node: [
|
|
140
|
+
' Run the server:',
|
|
141
|
+
chalk.gray(` cd ${outDir}`),
|
|
142
|
+
chalk.gray(` npm install`),
|
|
143
|
+
chalk.gray(` npm start`),
|
|
144
|
+
'',
|
|
145
|
+
' Or with Docker:',
|
|
146
|
+
chalk.gray(` docker build -t zylaris-app .`),
|
|
147
|
+
chalk.gray(` docker run -p 3000:3000 zylaris-app`),
|
|
148
|
+
],
|
|
149
|
+
vercel: [
|
|
150
|
+
' Deploy to Vercel:',
|
|
151
|
+
chalk.gray(` npx vercel --prod`),
|
|
152
|
+
],
|
|
153
|
+
netlify: [
|
|
154
|
+
' Deploy to Netlify:',
|
|
155
|
+
chalk.gray(` npx netlify deploy --prod`),
|
|
156
|
+
],
|
|
157
|
+
cloudflare: [
|
|
158
|
+
' Deploy to Cloudflare:',
|
|
159
|
+
chalk.gray(` npx wrangler pages deploy ${outDir}`),
|
|
160
|
+
chalk.gray(` # or for Workers:`),
|
|
161
|
+
chalk.gray(` npx wrangler deploy`),
|
|
162
|
+
],
|
|
163
|
+
deno: [
|
|
164
|
+
' Deploy to Deno Deploy:',
|
|
165
|
+
chalk.gray(` npx deployctl deploy --project=zylaris-app ${outDir}/server.ts`),
|
|
166
|
+
],
|
|
167
|
+
bun: [
|
|
168
|
+
' Run with Bun:',
|
|
169
|
+
chalk.gray(` bun ${outDir}/server.js`),
|
|
170
|
+
'',
|
|
171
|
+
' Or use Docker for deployment',
|
|
172
|
+
],
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
console.log(instructions[target].join('\n'));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** Format bytes to human readable */
|
|
179
|
+
function formatSize(bytes: number): string {
|
|
180
|
+
if (bytes === 0) return '0 B';
|
|
181
|
+
const k = 1024;
|
|
182
|
+
const sizes = ['B', 'KB', 'MB', 'GB'];
|
|
183
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
184
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** List available adapters */
|
|
188
|
+
export function printAdapters(): void {
|
|
189
|
+
console.log(chalk.bold('\nAvailable Adapters:\n'));
|
|
190
|
+
|
|
191
|
+
for (const { target, name, description } of listAdapters()) {
|
|
192
|
+
console.log(` ${chalk.cyan(target.padEnd(12))} ${chalk.bold(name)}`);
|
|
193
|
+
console.log(` ${''.padEnd(12)} ${chalk.gray(description)}\n`);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
console.log(`Usage: ${chalk.yellow('zylaris build --adapter <target>')}\n`);
|
|
197
|
+
}
|