htmlhost-cli 1.5.0 → 1.5.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/package.json +1 -1
- package/src/commands/deploy.mjs +34 -8
package/package.json
CHANGED
package/src/commands/deploy.mjs
CHANGED
|
@@ -101,13 +101,31 @@ export async function deploy(args) {
|
|
|
101
101
|
async function deploySingleFile(file, { ttl, title, forceNew, skipAssets, slug }) {
|
|
102
102
|
const filePath = resolve(file);
|
|
103
103
|
const projectDir = dirname(filePath);
|
|
104
|
+
const fileName = basename(filePath);
|
|
104
105
|
|
|
105
106
|
let isLinked = false;
|
|
106
107
|
|
|
107
108
|
if (!slug && !forceNew) {
|
|
108
109
|
const link = readLink(projectDir);
|
|
109
|
-
|
|
110
|
-
if (link?.
|
|
110
|
+
|
|
111
|
+
if (link?.sites) {
|
|
112
|
+
// Multi-file format — warn that only one file is being deployed
|
|
113
|
+
const siteCount = Object.keys(link.sites).length;
|
|
114
|
+
if (siteCount > 1) {
|
|
115
|
+
console.log("");
|
|
116
|
+
console.log(` ${yellow("⚠")} This project has ${bold(String(siteCount))} linked sites but you're deploying only ${cyan(fileName)}.`);
|
|
117
|
+
console.log(` ${dim(`To deploy all files, run: ${bold("htmlhost deploy .")}`)}`);
|
|
118
|
+
console.log("");
|
|
119
|
+
}
|
|
120
|
+
// Look up this file's entry in the sites map
|
|
121
|
+
const entry = link.sites[fileName];
|
|
122
|
+
if (entry?.slug) {
|
|
123
|
+
slug = entry.slug;
|
|
124
|
+
isLinked = true;
|
|
125
|
+
info(`Linked to ${cyan(slug)} ${dim(`(via .htmlhost sites map)`)}`);
|
|
126
|
+
}
|
|
127
|
+
} else if (link?.slug) {
|
|
128
|
+
// Single-file format (has slug at top level, no sites map)
|
|
111
129
|
if (link.onRedeploy === "overwrite") {
|
|
112
130
|
slug = link.slug;
|
|
113
131
|
isLinked = true;
|
|
@@ -186,13 +204,21 @@ async function deploySingleFile(file, { ttl, title, forceNew, skipAssets, slug }
|
|
|
186
204
|
|
|
187
205
|
const data = await post("/api/sites", body);
|
|
188
206
|
|
|
189
|
-
// Save/update the link
|
|
207
|
+
// Save/update the link — merge into existing .htmlhost instead of clobbering
|
|
190
208
|
const existingLink = readLink(projectDir);
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
209
|
+
|
|
210
|
+
if (existingLink?.sites) {
|
|
211
|
+
// Multi-file format: merge this file's entry into the existing sites map
|
|
212
|
+
existingLink.sites[fileName] = { slug: data.slug, url: data.url };
|
|
213
|
+
writeLink(projectDir, existingLink);
|
|
214
|
+
} else {
|
|
215
|
+
// Single-file format: write the flat slug/url (preserve onRedeploy preference)
|
|
216
|
+
writeLink(projectDir, {
|
|
217
|
+
slug: data.slug,
|
|
218
|
+
url: data.url,
|
|
219
|
+
...(existingLink?.onRedeploy ? { onRedeploy: existingLink.onRedeploy } : {}),
|
|
220
|
+
});
|
|
221
|
+
}
|
|
196
222
|
|
|
197
223
|
console.log("");
|
|
198
224
|
ok(`${bold("Live")} at ${cyan(`https://${data.url}`)}`);
|