@hono/cli 0.0.1
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/README.md +79 -0
- package/dist/cli.js +86 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Hono CLI
|
|
2
|
+
|
|
3
|
+
CLI for Hono
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @hono/cli
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Show help
|
|
15
|
+
hono --help
|
|
16
|
+
|
|
17
|
+
# Create a new Hono project
|
|
18
|
+
hono create
|
|
19
|
+
|
|
20
|
+
# Open documentation
|
|
21
|
+
hono docs
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Commands
|
|
25
|
+
|
|
26
|
+
- `create [target]` - Create a new Hono project
|
|
27
|
+
- `docs` - Open Hono documentation in browser
|
|
28
|
+
|
|
29
|
+
### `create`
|
|
30
|
+
|
|
31
|
+
Create a new Hono project using [create-hono](https://github.com/honojs/create-hono).
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
hono create [target] [options]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Arguments:**
|
|
38
|
+
|
|
39
|
+
- `target` - Target directory (optional)
|
|
40
|
+
|
|
41
|
+
**Options:**
|
|
42
|
+
|
|
43
|
+
- `-t, --template <template>` - Template to use (aws-lambda, bun, cloudflare-workers, cloudflare-workers+vite, deno, fastly, lambda-edge, netlify, nextjs, nodejs, vercel, cloudflare-pages, x-basic)
|
|
44
|
+
- `-i, --install` - Install dependencies
|
|
45
|
+
- `-p, --pm <pm>` - Package manager to use (npm, bun, deno, pnpm, yarn)
|
|
46
|
+
- `-o, --offline` - Use offline mode
|
|
47
|
+
|
|
48
|
+
**Examples:**
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Interactive project creation
|
|
52
|
+
hono create
|
|
53
|
+
|
|
54
|
+
# Create project in specific directory
|
|
55
|
+
hono create my-app
|
|
56
|
+
|
|
57
|
+
# Create with Cloudflare Workers template
|
|
58
|
+
hono create my-app --template cloudflare-workers
|
|
59
|
+
|
|
60
|
+
# Create and install dependencies with Bun
|
|
61
|
+
hono create my-app --pm bun --install
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### `docs`
|
|
65
|
+
|
|
66
|
+
Open Hono documentation in your default browser.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
hono docs
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Authors
|
|
73
|
+
|
|
74
|
+
- Yusuke Wada https://github.com/yusukebe
|
|
75
|
+
- Taku Amano https://github.com/usualoma
|
|
76
|
+
|
|
77
|
+
## License
|
|
78
|
+
|
|
79
|
+
MIT
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli.ts
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
import { readFileSync } from "fs";
|
|
6
|
+
import { dirname, join } from "path";
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
8
|
+
|
|
9
|
+
// src/commands/create/index.ts
|
|
10
|
+
import { spawn } from "child_process";
|
|
11
|
+
function createCommand(program2) {
|
|
12
|
+
program2.command("create").description("Create a new Hono project").argument("[target]", "target directory").option(
|
|
13
|
+
"-t, --template <template>",
|
|
14
|
+
"Template to use (aws-lambda, bun, cloudflare-workers, cloudflare-workers+vite, deno, fastly, lambda-edge, netlify, nextjs, nodejs, vercel, cloudflare-pages, x-basic)"
|
|
15
|
+
).option("-i, --install", "Install dependencies").option("-p, --pm <pm>", "Package manager to use (npm, bun, deno, pnpm, yarn)").option("-o, --offline", "Use offline mode").action(
|
|
16
|
+
(target, options) => {
|
|
17
|
+
const args = ["create", "hono@latest"];
|
|
18
|
+
if (target) {
|
|
19
|
+
args.push(target);
|
|
20
|
+
}
|
|
21
|
+
if (options.template) {
|
|
22
|
+
args.push("--template", options.template);
|
|
23
|
+
}
|
|
24
|
+
if (options.install) {
|
|
25
|
+
args.push("--install");
|
|
26
|
+
}
|
|
27
|
+
if (options.pm) {
|
|
28
|
+
args.push("--pm", options.pm);
|
|
29
|
+
}
|
|
30
|
+
if (options.offline) {
|
|
31
|
+
args.push("--offline");
|
|
32
|
+
}
|
|
33
|
+
const npm = spawn("npm", args, {
|
|
34
|
+
stdio: "inherit"
|
|
35
|
+
});
|
|
36
|
+
npm.on("error", (error) => {
|
|
37
|
+
console.error(`Failed to execute npm: ${error.message}`);
|
|
38
|
+
throw new Error(`Failed to execute npm: ${error.message}`);
|
|
39
|
+
});
|
|
40
|
+
npm.on("exit", (code) => {
|
|
41
|
+
if (code !== 0) {
|
|
42
|
+
throw new Error(`npm create hono@latest exited with code ${code}`);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// src/commands/docs/index.ts
|
|
50
|
+
import { exec } from "child_process";
|
|
51
|
+
import { platform } from "os";
|
|
52
|
+
function docsCommand(program2) {
|
|
53
|
+
program2.command("docs").description("Open Hono documentation in browser").action(() => {
|
|
54
|
+
const url = "https://hono.dev";
|
|
55
|
+
let openCommand;
|
|
56
|
+
switch (platform()) {
|
|
57
|
+
case "darwin":
|
|
58
|
+
openCommand = "open";
|
|
59
|
+
break;
|
|
60
|
+
case "win32":
|
|
61
|
+
openCommand = "start";
|
|
62
|
+
break;
|
|
63
|
+
default:
|
|
64
|
+
openCommand = "xdg-open";
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
exec(`${openCommand} ${url}`, (error) => {
|
|
68
|
+
if (error) {
|
|
69
|
+
console.error(`Failed to open browser: ${error.message}`);
|
|
70
|
+
console.log(`Please visit: ${url}`);
|
|
71
|
+
} else {
|
|
72
|
+
console.log(`Opening ${url} in your browser...`);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// src/cli.ts
|
|
79
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
80
|
+
var __dirname = dirname(__filename);
|
|
81
|
+
var packageJson = JSON.parse(readFileSync(join(__dirname, "../package.json"), "utf-8"));
|
|
82
|
+
var program = new Command();
|
|
83
|
+
program.name("hono").description("CLI for Hono").version(packageJson.version, "-v, --version", "display version number");
|
|
84
|
+
createCommand(program);
|
|
85
|
+
docsCommand(program);
|
|
86
|
+
program.parse();
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hono/cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"bin": {
|
|
6
|
+
"hono": "dist/cli.js"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsup",
|
|
10
|
+
"watch": "tsup --watch",
|
|
11
|
+
"test": "vitest",
|
|
12
|
+
"test:run": "vitest run",
|
|
13
|
+
"test:watch": "vitest watch",
|
|
14
|
+
"lint": "eslint --ext js,ts src",
|
|
15
|
+
"lint:fix": "eslint --ext js,ts src --fix",
|
|
16
|
+
"format": "prettier src --check",
|
|
17
|
+
"format:fix": "prettier src --write",
|
|
18
|
+
"postbuild": "publint",
|
|
19
|
+
"release": "np"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"author": "Yusuke Wada <yusuke@kamawada.com> (https://github.com/yusukebe)",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/honojs/cli.git"
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"registry": "https://registry.npmjs.org",
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://hono.dev",
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"commander": "^14.0.1"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@hono/eslint-config": "^1.1.1",
|
|
40
|
+
"@types/node": "^24.7.0",
|
|
41
|
+
"eslint": "^9.37.0",
|
|
42
|
+
"hono": "4.4.13",
|
|
43
|
+
"np": "^10.2.0",
|
|
44
|
+
"prettier": "^3.6.2",
|
|
45
|
+
"publint": "^0.3.14",
|
|
46
|
+
"tsup": "^8.5.0",
|
|
47
|
+
"typescript": "^5.9.3",
|
|
48
|
+
"vitest": "^3.2.4"
|
|
49
|
+
},
|
|
50
|
+
"packageManager": "bun@1.2.20"
|
|
51
|
+
}
|