@zenithbuild/cli 0.4.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 +40 -0
- package/bin/zen-build.ts +2 -0
- package/bin/zen-dev.ts +2 -0
- package/bin/zen-preview.ts +2 -0
- package/bin/zenith.ts +2 -0
- package/package.json +63 -0
- package/src/commands/add.ts +37 -0
- package/src/commands/build.ts +36 -0
- package/src/commands/create.ts +702 -0
- package/src/commands/dev.ts +467 -0
- package/src/commands/index.ts +112 -0
- package/src/commands/preview.ts +62 -0
- package/src/commands/remove.ts +33 -0
- package/src/index.ts +10 -0
- package/src/main.ts +101 -0
- package/src/utils/branding.ts +178 -0
- package/src/utils/logger.ts +46 -0
- package/src/utils/plugin-manager.ts +114 -0
- package/src/utils/project.ts +77 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Zenith Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# @zenithbuild/cli ⚡
|
|
2
|
+
|
|
3
|
+
The command-line interface for developing and building Zenith applications.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
`@zenithbuild/cli` provides the toolchain needed to manage Zenith projects. While `create-zenith` is for scaffolding, this CLI is for the daily development loop: serving apps, building for production, and managing plugins.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Dev Server**: Instant HMR (Hot Module Replacement) powered by Bun.
|
|
12
|
+
- **Build System**: optimized production bundling.
|
|
13
|
+
- **Plugin Management**: Easily add and remove Zenith plugins.
|
|
14
|
+
- **Preview**: Test your production builds locally.
|
|
15
|
+
|
|
16
|
+
## Commands
|
|
17
|
+
|
|
18
|
+
### `zenith dev`
|
|
19
|
+
Starts the development server on `localhost:3000`.
|
|
20
|
+
|
|
21
|
+
### `zenith build`
|
|
22
|
+
Compiles and bundles your application for production.
|
|
23
|
+
|
|
24
|
+
### `zenith preview`
|
|
25
|
+
Serves the locally built application for verification.
|
|
26
|
+
|
|
27
|
+
### `zenith add <plugin>`
|
|
28
|
+
Installs and configures a Zenith plugin.
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
Typically installed as a dev dependency in your Zenith project:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
bun add -d @zenithbuild/cli
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## License
|
|
39
|
+
|
|
40
|
+
MIT
|
package/bin/zen-build.ts
ADDED
package/bin/zen-dev.ts
ADDED
package/bin/zenith.ts
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zenithbuild/cli",
|
|
3
|
+
"version": "0.4.2",
|
|
4
|
+
"description": "CLI for Zenith framework - dev server, build tools, and plugin management",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"zenith": "./dist/zenith.js",
|
|
8
|
+
"zen-dev": "./dist/zen-dev.js",
|
|
9
|
+
"zen-build": "./dist/zen-build.js",
|
|
10
|
+
"zen-preview": "./dist/zen-preview.js"
|
|
11
|
+
},
|
|
12
|
+
"main": "./src/index.ts",
|
|
13
|
+
"types": "./src/index.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./src/index.ts",
|
|
17
|
+
"import": "./src/index.ts"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"bin",
|
|
22
|
+
"src"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"dev": "bun run build && bin/zenith.ts dev",
|
|
26
|
+
"build": "bun build bin/zenith.ts bin/zen-dev.ts bin/zen-build.ts bin/zen-preview.ts --outdir dist --target bun --bundle && for f in dist/*.js; do echo '#!/usr/bin/env bun' | cat - \"$f\" > \"$f.tmp\" && mv \"$f.tmp\" \"$f\" && chmod +x \"$f\"; done",
|
|
27
|
+
"start": "bun run build && bun run dev",
|
|
28
|
+
"test": "bun test",
|
|
29
|
+
"release": "bun run scripts/release.ts",
|
|
30
|
+
"release:dry": "bun run scripts/release.ts --dry-run",
|
|
31
|
+
"release:patch": "bun run scripts/release.ts --bump=patch",
|
|
32
|
+
"release:minor": "bun run scripts/release.ts --bump=minor",
|
|
33
|
+
"release:major": "bun run scripts/release.ts --bump=major"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [
|
|
36
|
+
"zenith",
|
|
37
|
+
"cli",
|
|
38
|
+
"framework",
|
|
39
|
+
"ssg",
|
|
40
|
+
"ssr"
|
|
41
|
+
],
|
|
42
|
+
"author": "Zenith Team",
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"repository": {
|
|
45
|
+
"type": "git",
|
|
46
|
+
"url": "git@github.com:zenithbuild/zenith-cli.git"
|
|
47
|
+
},
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
},
|
|
51
|
+
"private": false,
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"@zenithbuild/core": "^1.2.1"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/bun": "latest"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"@zenithbuild/compiler": "1.0.2",
|
|
60
|
+
"@zenithbuild/router": "1.0.1",
|
|
61
|
+
"picocolors": "^1.0.0"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zenithbuild/cli - Add Command
|
|
3
|
+
*
|
|
4
|
+
* Registers a plugin in the project
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { requireProject } from '../utils/project'
|
|
8
|
+
import { addPlugin, hasPlugin } from '../utils/plugin-manager'
|
|
9
|
+
import * as logger from '../utils/logger'
|
|
10
|
+
|
|
11
|
+
export interface AddOptions {
|
|
12
|
+
options?: Record<string, unknown>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function add(pluginName: string, options: AddOptions = {}): Promise<void> {
|
|
16
|
+
requireProject()
|
|
17
|
+
|
|
18
|
+
logger.header('Add Plugin')
|
|
19
|
+
|
|
20
|
+
if (!pluginName) {
|
|
21
|
+
logger.error('Plugin name required. Usage: zenith add <plugin>')
|
|
22
|
+
process.exit(1)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (hasPlugin(pluginName)) {
|
|
26
|
+
logger.warn(`Plugin "${pluginName}" is already registered`)
|
|
27
|
+
return
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const success = addPlugin(pluginName, options.options)
|
|
31
|
+
|
|
32
|
+
if (success) {
|
|
33
|
+
logger.info(`Plugin "${pluginName}" has been registered.`)
|
|
34
|
+
logger.info('Note: You may need to install the package manually:')
|
|
35
|
+
logger.log(` bun add @zenithbuild/plugin-${pluginName}`)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @zenithbuild/cli - Build Command
|
|
3
|
+
*
|
|
4
|
+
* Builds the application for production using SSG.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { requireProject } from '../utils/project'
|
|
8
|
+
import * as logger from '../utils/logger'
|
|
9
|
+
import { buildSSG } from '@zenithbuild/compiler'
|
|
10
|
+
|
|
11
|
+
export interface BuildOptions {
|
|
12
|
+
outDir?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function build(options: BuildOptions = {}): Promise<void> {
|
|
16
|
+
const project = requireProject()
|
|
17
|
+
const outDir = options.outDir || project.distDir
|
|
18
|
+
|
|
19
|
+
logger.header('Zenith Build')
|
|
20
|
+
logger.log(`Source: ${project.pagesDir}`)
|
|
21
|
+
logger.log(`Output: ${outDir}`)
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
buildSSG({
|
|
25
|
+
pagesDir: project.pagesDir,
|
|
26
|
+
outDir: outDir,
|
|
27
|
+
baseDir: project.root
|
|
28
|
+
})
|
|
29
|
+
logger.success('Build complete!')
|
|
30
|
+
|
|
31
|
+
} catch (err: unknown) {
|
|
32
|
+
const message = err instanceof Error ? err.message : String(err)
|
|
33
|
+
logger.error(`Build failed: ${message}`)
|
|
34
|
+
process.exit(1)
|
|
35
|
+
}
|
|
36
|
+
}
|