htmlhost-cli 1.0.0 → 1.1.0

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 CHANGED
@@ -5,7 +5,7 @@ Deploy HTML files from the terminal. [htmlhost.co](https://htmlhost.co)
5
5
  ## Install
6
6
 
7
7
  ```bash
8
- npm i -g htmlhost
8
+ npm i -g htmlhost-cli
9
9
  ```
10
10
 
11
11
  ## Quick start
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "htmlhost-cli",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Deploy HTML files from the terminal — htmlhost.co CLI",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli.mjs CHANGED
@@ -4,7 +4,7 @@
4
4
  import { bold, dim, cyan, err } from "./ui.mjs";
5
5
  import { ApiError } from "./api.mjs";
6
6
 
7
- const VERSION = "1.0.0";
7
+ const VERSION = "1.1.0";
8
8
 
9
9
  const HELP = `
10
10
  ${bold("htmlhost")} ${dim(`v${VERSION}`)} — deploy HTML from the terminal
@@ -1,16 +1,26 @@
1
- import { readFileSync, statSync } from "node:fs";
1
+ import { readFileSync, statSync, existsSync } from "node:fs";
2
2
  import { basename, resolve } from "node:path";
3
3
  import { post } from "../api.mjs";
4
4
  import { ok, err, info, cyan, dim, bold, formatBytes } from "../ui.mjs";
5
5
 
6
6
  /**
7
- * htmlhost deploy <file> [--ttl 7d] [--slug existing-slug] [--title "My Site"]
7
+ * htmlhost deploy [file] [--ttl 7d] [--slug existing-slug] [--title "My Site"]
8
+ * Defaults to index.html in the current directory.
8
9
  */
9
10
  export async function deploy(args) {
10
- const file = args.find((a) => !a.startsWith("--"));
11
+ let file = args.find((a) => !a.startsWith("--"));
12
+
13
+ // Default to index.html in the current directory
11
14
  if (!file) {
12
- err("Usage: htmlhost deploy <file.html> [--ttl 7d] [--slug my-site]");
13
- process.exit(1);
15
+ const defaultFile = resolve("index.html");
16
+ if (existsSync(defaultFile)) {
17
+ file = "index.html";
18
+ info(`No file specified, using ${cyan("index.html")}`);
19
+ } else {
20
+ err("No file specified and no index.html found in the current directory.");
21
+ console.log(` ${dim("Usage: htmlhost deploy [file.html] [--ttl 7d] [--slug my-site]")}`);
22
+ process.exit(1);
23
+ }
14
24
  }
15
25
 
16
26
  const ttl = getFlag(args, "--ttl");