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 +1 -1
- package/package.json +1 -1
- package/src/cli.mjs +1 -1
- package/src/commands/deploy.mjs +15 -5
package/README.md
CHANGED
package/package.json
CHANGED
package/src/cli.mjs
CHANGED
package/src/commands/deploy.mjs
CHANGED
|
@@ -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
|
|
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
|
-
|
|
11
|
+
let file = args.find((a) => !a.startsWith("--"));
|
|
12
|
+
|
|
13
|
+
// Default to index.html in the current directory
|
|
11
14
|
if (!file) {
|
|
12
|
-
|
|
13
|
-
|
|
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");
|