@junejs/cli 0.0.3 → 0.0.5
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/bin.mjs +24 -0
- package/package.json +6 -5
- package/src/cli.ts +14 -0
package/bin.mjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The `june` bin launcher. It runs on Node ON PURPOSE: the CLI itself
|
|
3
|
+
// (src/june.ts) runs on Bun, and without this hop an npm user without Bun
|
|
4
|
+
// gets a bare shebang error ("env: bun: No such file or directory") instead
|
|
5
|
+
// of a sentence telling them what to install.
|
|
6
|
+
import { spawnSync } from "node:child_process";
|
|
7
|
+
import { dirname, join } from "node:path";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
|
|
10
|
+
const entry = join(dirname(fileURLToPath(import.meta.url)), "src/june.ts");
|
|
11
|
+
const args = process.argv.slice(2);
|
|
12
|
+
|
|
13
|
+
const probe = spawnSync("bun", ["--version"], { stdio: "ignore", shell: false });
|
|
14
|
+
if (probe.error || probe.status !== 0) {
|
|
15
|
+
console.error(
|
|
16
|
+
"june: the June CLI runs on Bun, which wasn't found on your PATH.\n" +
|
|
17
|
+
" install it: curl -fsSL https://bun.sh/install | bash\n" +
|
|
18
|
+
" (or: brew install oven-sh/bun/bun · https://bun.sh)",
|
|
19
|
+
);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const child = spawnSync("bun", [entry, ...args], { stdio: "inherit", shell: false });
|
|
24
|
+
process.exit(child.status ?? 1);
|
package/package.json
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@junejs/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "The `june` CLI — dev / build / deploy / gen / info. A thin bin over @junejs/server.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://june.build",
|
|
8
8
|
"bin": {
|
|
9
|
-
"june": "./
|
|
9
|
+
"june": "./bin.mjs"
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
12
|
".": "./src/cli.ts"
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
|
-
"src"
|
|
15
|
+
"src",
|
|
16
|
+
"bin.mjs"
|
|
16
17
|
],
|
|
17
18
|
"scripts": {
|
|
18
19
|
"test": "bun test",
|
|
19
20
|
"typecheck": "tsc --noEmit"
|
|
20
21
|
},
|
|
21
22
|
"dependencies": {
|
|
22
|
-
"@junejs/core": "0.0.
|
|
23
|
-
"@junejs/server": "0.0.
|
|
23
|
+
"@junejs/core": "0.0.5",
|
|
24
|
+
"@junejs/server": "0.0.5"
|
|
24
25
|
},
|
|
25
26
|
"repository": {
|
|
26
27
|
"type": "git",
|
package/src/cli.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// @junejs/server. Exposed as run(argv) so it is testable without spawning a
|
|
3
3
|
// process; the bin (june.ts) just forwards process.argv. See docs/cli.md.
|
|
4
4
|
|
|
5
|
+
import { existsSync } from "node:fs";
|
|
5
6
|
import { join, resolve } from "node:path";
|
|
6
7
|
|
|
7
8
|
export type Parsed = {
|
|
@@ -85,6 +86,19 @@ export async function run(argv: string[]): Promise<number | undefined> {
|
|
|
85
86
|
|
|
86
87
|
switch (verb) {
|
|
87
88
|
case "dev": {
|
|
89
|
+
// Validate BEFORE the supervisor: watching a directory that doesn't
|
|
90
|
+
// exist throws a raw ENOENT, and the classic mistake `npm run dev -p
|
|
91
|
+
// 3001` hands us "3001" as the app dir (npm eats the flag).
|
|
92
|
+
if (!existsSync(join(root, "app"))) {
|
|
93
|
+
console.error(`june dev: ${root} doesn't look like a June app (no app/ directory).`);
|
|
94
|
+
if (/^\d+$/.test(positional[0] ?? "")) {
|
|
95
|
+
console.error(
|
|
96
|
+
` to choose a port, use --port: june dev --port ${positional[0]}` +
|
|
97
|
+
` · npm run dev -- --port ${positional[0]}`,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
return 1;
|
|
101
|
+
}
|
|
88
102
|
// A restart is the reload: the watch supervisor respawns the serving
|
|
89
103
|
// child on file change (see watch.ts). Children carry JUNE_DEV_CHILD.
|
|
90
104
|
if (!process.env.JUNE_DEV_CHILD && !flags["no-watch"]) {
|