htmlhost-cli 2.1.1 → 2.1.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/package.json +1 -1
- package/src/assets.mjs +7 -5
- package/src/cli.mjs +1 -1
- package/src/commands/login.mjs +17 -1
package/package.json
CHANGED
package/src/assets.mjs
CHANGED
|
@@ -301,8 +301,9 @@ export async function processAssets(html, baseDir, sharedCache, persistedCache)
|
|
|
301
301
|
// Check persisted cache (from .htmlhost, across deploys)
|
|
302
302
|
if (persistedCache && persistedCache.has(asset.filePath)) {
|
|
303
303
|
const cached = persistedCache.get(asset.filePath);
|
|
304
|
-
// Invalidate cache if file size changed (file was modified)
|
|
305
|
-
|
|
304
|
+
// Invalidate cache if file size or mtime changed (file was modified)
|
|
305
|
+
const mtime = statSync(asset.filePath).mtimeMs;
|
|
306
|
+
if (cached.size === asset.size && cached.mtime === mtime) {
|
|
306
307
|
urlMap.set(ref, cached.url);
|
|
307
308
|
if (sharedCache) sharedCache.set(asset.filePath, cached.url);
|
|
308
309
|
ok(`${cyan(ref)} ${dim("(previously uploaded)")}`);
|
|
@@ -345,7 +346,7 @@ export async function processAssets(html, baseDir, sharedCache, persistedCache)
|
|
|
345
346
|
const hostedUrl = `${api}${data.url}`;
|
|
346
347
|
urlMap.set(ref, hostedUrl);
|
|
347
348
|
if (sharedCache) sharedCache.set(asset.filePath, hostedUrl);
|
|
348
|
-
if (persistedCache) persistedCache.set(asset.filePath, { url: hostedUrl, size: asset.size });
|
|
349
|
+
if (persistedCache) persistedCache.set(asset.filePath, { url: hostedUrl, size: asset.size, mtime: statSync(asset.filePath).mtimeMs });
|
|
349
350
|
uploadCount++;
|
|
350
351
|
ok(`${cyan(ref)} ${dim(`(${formatBytes(asset.size)})`)} → ${hostedUrl}`);
|
|
351
352
|
} catch (e) {
|
|
@@ -418,8 +419,9 @@ export async function processAssets(html, baseDir, sharedCache, persistedCache)
|
|
|
418
419
|
for (const [ref, hostedUrl] of urlMap) {
|
|
419
420
|
const asset = resolveAsset(baseDir, ref);
|
|
420
421
|
if (asset.filePath && !resolvedCache.has(asset.filePath)) {
|
|
421
|
-
// Only add entries not already set (upload path sets {url, size} directly)
|
|
422
|
-
|
|
422
|
+
// Only add entries not already set (upload path sets {url, size, mtime} directly)
|
|
423
|
+
const mtime = asset.filePath ? ((() => { try { return statSync(asset.filePath).mtimeMs; } catch { return 0; } })()) : 0;
|
|
424
|
+
resolvedCache.set(asset.filePath, { url: hostedUrl, size: asset.size || 0, mtime });
|
|
423
425
|
}
|
|
424
426
|
}
|
|
425
427
|
|
package/src/cli.mjs
CHANGED
package/src/commands/login.mjs
CHANGED
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import { writeConfig, getApi } from "../config.mjs";
|
|
2
2
|
import { ok, err, info, dim, cyan, bold } from "../ui.mjs";
|
|
3
3
|
import { createInterface } from "node:readline";
|
|
4
|
+
import { exec } from "node:child_process";
|
|
4
5
|
|
|
5
6
|
export async function login() {
|
|
7
|
+
const settingsUrl = `${getApi()}/settings#keys`;
|
|
8
|
+
|
|
6
9
|
console.log("");
|
|
7
10
|
info(`Log in to ${cyan(bold("htmlhost.co"))}`);
|
|
8
|
-
|
|
11
|
+
|
|
12
|
+
// Auto-open the browser; fall back to showing the URL if it fails
|
|
13
|
+
const browserCmd =
|
|
14
|
+
process.platform === "darwin" ? "open" :
|
|
15
|
+
process.platform === "win32" ? "start" :
|
|
16
|
+
"xdg-open";
|
|
17
|
+
|
|
18
|
+
exec(`${browserCmd} ${settingsUrl}`, (error) => {
|
|
19
|
+
if (error) {
|
|
20
|
+
console.log(`${dim(" Generate a token at")} ${settingsUrl}`);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
console.log(`${dim(" Opening")} ${cyan(settingsUrl)}${dim(" in your browser…")}`);
|
|
9
25
|
console.log("");
|
|
10
26
|
|
|
11
27
|
const token = await new Promise((resolve) => {
|