@cloudwerk/cli 0.13.0 → 0.15.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/dist/index.js +1835 -18
- package/dist/ssg-DR2ZOVQ7.js +512 -0
- package/package.json +5 -4
|
@@ -0,0 +1,512 @@
|
|
|
1
|
+
// ../../node_modules/.pnpm/hono@4.11.5/node_modules/hono/dist/client/utils.js
|
|
2
|
+
var replaceUrlParam = (urlString, params) => {
|
|
3
|
+
for (const [k, v] of Object.entries(params)) {
|
|
4
|
+
const reg = new RegExp("/:" + k + "(?:{[^/]+})?\\??");
|
|
5
|
+
urlString = urlString.replace(reg, v ? `/${v}` : "");
|
|
6
|
+
}
|
|
7
|
+
return urlString;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// ../../node_modules/.pnpm/hono@4.11.5/node_modules/hono/dist/utils/concurrent.js
|
|
11
|
+
var DEFAULT_CONCURRENCY = 1024;
|
|
12
|
+
var createPool = ({
|
|
13
|
+
concurrency,
|
|
14
|
+
interval
|
|
15
|
+
} = {}) => {
|
|
16
|
+
concurrency ||= DEFAULT_CONCURRENCY;
|
|
17
|
+
if (concurrency === Infinity) {
|
|
18
|
+
return {
|
|
19
|
+
run: async (fn) => fn()
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const pool = /* @__PURE__ */ new Set();
|
|
23
|
+
const run = async (fn, promise, resolve) => {
|
|
24
|
+
if (pool.size >= concurrency) {
|
|
25
|
+
promise ||= new Promise((r) => resolve = r);
|
|
26
|
+
setTimeout(() => run(fn, promise, resolve));
|
|
27
|
+
return promise;
|
|
28
|
+
}
|
|
29
|
+
const marker = {};
|
|
30
|
+
pool.add(marker);
|
|
31
|
+
const result = await fn();
|
|
32
|
+
if (interval) {
|
|
33
|
+
setTimeout(() => pool.delete(marker), interval);
|
|
34
|
+
} else {
|
|
35
|
+
pool.delete(marker);
|
|
36
|
+
}
|
|
37
|
+
if (resolve) {
|
|
38
|
+
resolve(result);
|
|
39
|
+
return promise;
|
|
40
|
+
} else {
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
return { run };
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// ../../node_modules/.pnpm/hono@4.11.5/node_modules/hono/dist/utils/mime.js
|
|
48
|
+
var getExtension = (mimeType) => {
|
|
49
|
+
for (const ext in baseMimes) {
|
|
50
|
+
if (baseMimes[ext] === mimeType) {
|
|
51
|
+
return ext;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var _baseMimes = {
|
|
56
|
+
aac: "audio/aac",
|
|
57
|
+
avi: "video/x-msvideo",
|
|
58
|
+
avif: "image/avif",
|
|
59
|
+
av1: "video/av1",
|
|
60
|
+
bin: "application/octet-stream",
|
|
61
|
+
bmp: "image/bmp",
|
|
62
|
+
css: "text/css",
|
|
63
|
+
csv: "text/csv",
|
|
64
|
+
eot: "application/vnd.ms-fontobject",
|
|
65
|
+
epub: "application/epub+zip",
|
|
66
|
+
gif: "image/gif",
|
|
67
|
+
gz: "application/gzip",
|
|
68
|
+
htm: "text/html",
|
|
69
|
+
html: "text/html",
|
|
70
|
+
ico: "image/x-icon",
|
|
71
|
+
ics: "text/calendar",
|
|
72
|
+
jpeg: "image/jpeg",
|
|
73
|
+
jpg: "image/jpeg",
|
|
74
|
+
js: "text/javascript",
|
|
75
|
+
json: "application/json",
|
|
76
|
+
jsonld: "application/ld+json",
|
|
77
|
+
map: "application/json",
|
|
78
|
+
mid: "audio/x-midi",
|
|
79
|
+
midi: "audio/x-midi",
|
|
80
|
+
mjs: "text/javascript",
|
|
81
|
+
mp3: "audio/mpeg",
|
|
82
|
+
mp4: "video/mp4",
|
|
83
|
+
mpeg: "video/mpeg",
|
|
84
|
+
oga: "audio/ogg",
|
|
85
|
+
ogv: "video/ogg",
|
|
86
|
+
ogx: "application/ogg",
|
|
87
|
+
opus: "audio/opus",
|
|
88
|
+
otf: "font/otf",
|
|
89
|
+
pdf: "application/pdf",
|
|
90
|
+
png: "image/png",
|
|
91
|
+
rtf: "application/rtf",
|
|
92
|
+
svg: "image/svg+xml",
|
|
93
|
+
tif: "image/tiff",
|
|
94
|
+
tiff: "image/tiff",
|
|
95
|
+
ts: "video/mp2t",
|
|
96
|
+
ttf: "font/ttf",
|
|
97
|
+
txt: "text/plain",
|
|
98
|
+
wasm: "application/wasm",
|
|
99
|
+
webm: "video/webm",
|
|
100
|
+
weba: "audio/webm",
|
|
101
|
+
webmanifest: "application/manifest+json",
|
|
102
|
+
webp: "image/webp",
|
|
103
|
+
woff: "font/woff",
|
|
104
|
+
woff2: "font/woff2",
|
|
105
|
+
xhtml: "application/xhtml+xml",
|
|
106
|
+
xml: "application/xml",
|
|
107
|
+
zip: "application/zip",
|
|
108
|
+
"3gp": "video/3gpp",
|
|
109
|
+
"3g2": "video/3gpp2",
|
|
110
|
+
gltf: "model/gltf+json",
|
|
111
|
+
glb: "model/gltf-binary"
|
|
112
|
+
};
|
|
113
|
+
var baseMimes = _baseMimes;
|
|
114
|
+
|
|
115
|
+
// ../../node_modules/.pnpm/hono@4.11.5/node_modules/hono/dist/router.js
|
|
116
|
+
var METHOD_NAME_ALL = "ALL";
|
|
117
|
+
|
|
118
|
+
// ../../node_modules/.pnpm/hono@4.11.5/node_modules/hono/dist/utils/constants.js
|
|
119
|
+
var COMPOSED_HANDLER = "__COMPOSED_HANDLER";
|
|
120
|
+
|
|
121
|
+
// ../../node_modules/.pnpm/hono@4.11.5/node_modules/hono/dist/utils/handler.js
|
|
122
|
+
var isMiddleware = (handler) => handler.length > 1;
|
|
123
|
+
var findTargetHandler = (handler) => {
|
|
124
|
+
return handler[COMPOSED_HANDLER] ? (
|
|
125
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
126
|
+
findTargetHandler(handler[COMPOSED_HANDLER])
|
|
127
|
+
) : handler;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// ../../node_modules/.pnpm/hono@4.11.5/node_modules/hono/dist/helper/ssg/utils.js
|
|
131
|
+
var dirname = (path) => {
|
|
132
|
+
const separatedPath = path.split(/[\/\\]/);
|
|
133
|
+
return separatedPath.slice(0, -1).join("/");
|
|
134
|
+
};
|
|
135
|
+
var normalizePath = (path) => {
|
|
136
|
+
return path.replace(/(\\)/g, "/").replace(/\/$/g, "");
|
|
137
|
+
};
|
|
138
|
+
var handleParent = (resultPaths, beforeParentFlag) => {
|
|
139
|
+
if (resultPaths.length === 0 || beforeParentFlag) {
|
|
140
|
+
resultPaths.push("..");
|
|
141
|
+
} else {
|
|
142
|
+
resultPaths.pop();
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
var handleNonDot = (path, resultPaths) => {
|
|
146
|
+
path = path.replace(/^\.(?!.)/, "");
|
|
147
|
+
if (path !== "") {
|
|
148
|
+
resultPaths.push(path);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
var handleSegments = (paths, resultPaths) => {
|
|
152
|
+
let beforeParentFlag = false;
|
|
153
|
+
for (const path of paths) {
|
|
154
|
+
if (path === "..") {
|
|
155
|
+
handleParent(resultPaths, beforeParentFlag);
|
|
156
|
+
beforeParentFlag = true;
|
|
157
|
+
} else {
|
|
158
|
+
handleNonDot(path, resultPaths);
|
|
159
|
+
beforeParentFlag = false;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
var joinPaths = (...paths) => {
|
|
164
|
+
paths = paths.map(normalizePath);
|
|
165
|
+
const resultPaths = [];
|
|
166
|
+
handleSegments(paths.join("/").split("/"), resultPaths);
|
|
167
|
+
return (paths[0][0] === "/" ? "/" : "") + resultPaths.join("/");
|
|
168
|
+
};
|
|
169
|
+
var filterStaticGenerateRoutes = (hono) => {
|
|
170
|
+
return hono.routes.reduce((acc, { method, handler, path }) => {
|
|
171
|
+
const targetHandler = findTargetHandler(handler);
|
|
172
|
+
if (["GET", METHOD_NAME_ALL].includes(method) && !isMiddleware(targetHandler)) {
|
|
173
|
+
acc.push({ path });
|
|
174
|
+
}
|
|
175
|
+
return acc;
|
|
176
|
+
}, []);
|
|
177
|
+
};
|
|
178
|
+
var isDynamicRoute = (path) => {
|
|
179
|
+
return path.split("/").some((segment) => segment.startsWith(":") || segment.includes("*"));
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
// ../../node_modules/.pnpm/hono@4.11.5/node_modules/hono/dist/helper/ssg/middleware.js
|
|
183
|
+
var SSG_CONTEXT = "HONO_SSG_CONTEXT";
|
|
184
|
+
var X_HONO_DISABLE_SSG_HEADER_KEY = "x-hono-disable-ssg";
|
|
185
|
+
var SSG_DISABLED_RESPONSE = (() => {
|
|
186
|
+
try {
|
|
187
|
+
return new Response("SSG is disabled", {
|
|
188
|
+
status: 404,
|
|
189
|
+
headers: { [X_HONO_DISABLE_SSG_HEADER_KEY]: "true" }
|
|
190
|
+
});
|
|
191
|
+
} catch {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
})();
|
|
195
|
+
var ssgParams = (params) => async (c, next) => {
|
|
196
|
+
if (isDynamicRoute(c.req.path)) {
|
|
197
|
+
;
|
|
198
|
+
c.req.raw.ssgParams = Array.isArray(params) ? params : await params(c);
|
|
199
|
+
return c.notFound();
|
|
200
|
+
}
|
|
201
|
+
await next();
|
|
202
|
+
};
|
|
203
|
+
var isSSGContext = (c) => !!c.env?.[SSG_CONTEXT];
|
|
204
|
+
var disableSSG = () => async function disableSSG2(c, next) {
|
|
205
|
+
if (isSSGContext(c)) {
|
|
206
|
+
c.header(X_HONO_DISABLE_SSG_HEADER_KEY, "true");
|
|
207
|
+
return c.notFound();
|
|
208
|
+
}
|
|
209
|
+
await next();
|
|
210
|
+
};
|
|
211
|
+
var onlySSG = () => async function onlySSG2(c, next) {
|
|
212
|
+
if (!isSSGContext(c)) {
|
|
213
|
+
return c.notFound();
|
|
214
|
+
}
|
|
215
|
+
await next();
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// ../../node_modules/.pnpm/hono@4.11.5/node_modules/hono/dist/helper/ssg/ssg.js
|
|
219
|
+
var DEFAULT_CONCURRENCY2 = 2;
|
|
220
|
+
var DEFAULT_CONTENT_TYPE = "text/plain";
|
|
221
|
+
var DEFAULT_OUTPUT_DIR = "./static";
|
|
222
|
+
var generateFilePath = (routePath, outDir, mimeType, extensionMap) => {
|
|
223
|
+
const extension = determineExtension(mimeType, extensionMap);
|
|
224
|
+
if (routePath.endsWith(`.${extension}`)) {
|
|
225
|
+
return joinPaths(outDir, routePath);
|
|
226
|
+
}
|
|
227
|
+
if (routePath === "/") {
|
|
228
|
+
return joinPaths(outDir, `index.${extension}`);
|
|
229
|
+
}
|
|
230
|
+
if (routePath.endsWith("/")) {
|
|
231
|
+
return joinPaths(outDir, routePath, `index.${extension}`);
|
|
232
|
+
}
|
|
233
|
+
return joinPaths(outDir, `${routePath}.${extension}`);
|
|
234
|
+
};
|
|
235
|
+
var parseResponseContent = async (response) => {
|
|
236
|
+
const contentType = response.headers.get("Content-Type");
|
|
237
|
+
try {
|
|
238
|
+
if (contentType?.includes("text") || contentType?.includes("json")) {
|
|
239
|
+
return await response.text();
|
|
240
|
+
} else {
|
|
241
|
+
return await response.arrayBuffer();
|
|
242
|
+
}
|
|
243
|
+
} catch (error) {
|
|
244
|
+
throw new Error(
|
|
245
|
+
`Error processing response: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
var defaultExtensionMap = {
|
|
250
|
+
"text/html": "html",
|
|
251
|
+
"text/xml": "xml",
|
|
252
|
+
"application/xml": "xml",
|
|
253
|
+
"application/yaml": "yaml"
|
|
254
|
+
};
|
|
255
|
+
var determineExtension = (mimeType, userExtensionMap) => {
|
|
256
|
+
const extensionMap = userExtensionMap || defaultExtensionMap;
|
|
257
|
+
if (mimeType in extensionMap) {
|
|
258
|
+
return extensionMap[mimeType];
|
|
259
|
+
}
|
|
260
|
+
return getExtension(mimeType) || "html";
|
|
261
|
+
};
|
|
262
|
+
var combineBeforeRequestHooks = (hooks) => {
|
|
263
|
+
if (!Array.isArray(hooks)) {
|
|
264
|
+
return hooks;
|
|
265
|
+
}
|
|
266
|
+
return async (req) => {
|
|
267
|
+
let currentReq = req;
|
|
268
|
+
for (const hook of hooks) {
|
|
269
|
+
const result = await hook(currentReq);
|
|
270
|
+
if (result === false) {
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
if (result instanceof Request) {
|
|
274
|
+
currentReq = result;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return currentReq;
|
|
278
|
+
};
|
|
279
|
+
};
|
|
280
|
+
var combineAfterResponseHooks = (hooks) => {
|
|
281
|
+
if (!Array.isArray(hooks)) {
|
|
282
|
+
return hooks;
|
|
283
|
+
}
|
|
284
|
+
return async (res) => {
|
|
285
|
+
let currentRes = res;
|
|
286
|
+
for (const hook of hooks) {
|
|
287
|
+
const result = await hook(currentRes);
|
|
288
|
+
if (result === false) {
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
if (result instanceof Response) {
|
|
292
|
+
currentRes = result;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
return currentRes;
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
var combineAfterGenerateHooks = (hooks, fsModule, options) => {
|
|
299
|
+
if (!Array.isArray(hooks)) {
|
|
300
|
+
return hooks;
|
|
301
|
+
}
|
|
302
|
+
return async (result) => {
|
|
303
|
+
for (const hook of hooks) {
|
|
304
|
+
await hook(result, fsModule, options);
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
};
|
|
308
|
+
var fetchRoutesContent = function* (app, beforeRequestHook, afterResponseHook, concurrency) {
|
|
309
|
+
const baseURL = "http://localhost";
|
|
310
|
+
const pool = createPool({ concurrency });
|
|
311
|
+
for (const route of filterStaticGenerateRoutes(app)) {
|
|
312
|
+
const thisRouteBaseURL = new URL(route.path, baseURL).toString();
|
|
313
|
+
let forGetInfoURLRequest = new Request(thisRouteBaseURL);
|
|
314
|
+
yield new Promise(async (resolveGetInfo, rejectGetInfo) => {
|
|
315
|
+
try {
|
|
316
|
+
if (beforeRequestHook) {
|
|
317
|
+
const maybeRequest = await beforeRequestHook(forGetInfoURLRequest);
|
|
318
|
+
if (!maybeRequest) {
|
|
319
|
+
resolveGetInfo(void 0);
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
forGetInfoURLRequest = maybeRequest;
|
|
323
|
+
}
|
|
324
|
+
await pool.run(() => app.fetch(forGetInfoURLRequest));
|
|
325
|
+
if (!forGetInfoURLRequest.ssgParams) {
|
|
326
|
+
if (isDynamicRoute(route.path)) {
|
|
327
|
+
resolveGetInfo(void 0);
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
forGetInfoURLRequest.ssgParams = [{}];
|
|
331
|
+
}
|
|
332
|
+
const requestInit = {
|
|
333
|
+
method: forGetInfoURLRequest.method,
|
|
334
|
+
headers: forGetInfoURLRequest.headers
|
|
335
|
+
};
|
|
336
|
+
resolveGetInfo(
|
|
337
|
+
(function* () {
|
|
338
|
+
for (const param of forGetInfoURLRequest.ssgParams) {
|
|
339
|
+
yield new Promise(async (resolveReq, rejectReq) => {
|
|
340
|
+
try {
|
|
341
|
+
const replacedUrlParam = replaceUrlParam(route.path, param);
|
|
342
|
+
let response = await pool.run(
|
|
343
|
+
() => app.request(replacedUrlParam, requestInit, {
|
|
344
|
+
[SSG_CONTEXT]: true
|
|
345
|
+
})
|
|
346
|
+
);
|
|
347
|
+
if (response.headers.get(X_HONO_DISABLE_SSG_HEADER_KEY)) {
|
|
348
|
+
resolveReq(void 0);
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
if (afterResponseHook) {
|
|
352
|
+
const maybeResponse = await afterResponseHook(response);
|
|
353
|
+
if (!maybeResponse) {
|
|
354
|
+
resolveReq(void 0);
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
response = maybeResponse;
|
|
358
|
+
}
|
|
359
|
+
const mimeType = response.headers.get("Content-Type")?.split(";")[0] || DEFAULT_CONTENT_TYPE;
|
|
360
|
+
const content = await parseResponseContent(response);
|
|
361
|
+
resolveReq({
|
|
362
|
+
routePath: replacedUrlParam,
|
|
363
|
+
mimeType,
|
|
364
|
+
content
|
|
365
|
+
});
|
|
366
|
+
} catch (error) {
|
|
367
|
+
rejectReq(error);
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
})()
|
|
372
|
+
);
|
|
373
|
+
} catch (error) {
|
|
374
|
+
rejectGetInfo(error);
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
var createdDirs = /* @__PURE__ */ new Set();
|
|
380
|
+
var saveContentToFile = async (data, fsModule, outDir, extensionMap) => {
|
|
381
|
+
const awaitedData = await data;
|
|
382
|
+
if (!awaitedData) {
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
const { routePath, content, mimeType } = awaitedData;
|
|
386
|
+
const filePath = generateFilePath(routePath, outDir, mimeType, extensionMap);
|
|
387
|
+
const dirPath = dirname(filePath);
|
|
388
|
+
if (!createdDirs.has(dirPath)) {
|
|
389
|
+
await fsModule.mkdir(dirPath, { recursive: true });
|
|
390
|
+
createdDirs.add(dirPath);
|
|
391
|
+
}
|
|
392
|
+
if (typeof content === "string") {
|
|
393
|
+
await fsModule.writeFile(filePath, content);
|
|
394
|
+
} else if (content instanceof ArrayBuffer) {
|
|
395
|
+
await fsModule.writeFile(filePath, new Uint8Array(content));
|
|
396
|
+
}
|
|
397
|
+
return filePath;
|
|
398
|
+
};
|
|
399
|
+
var defaultPlugin = {
|
|
400
|
+
afterResponseHook: (res) => {
|
|
401
|
+
if (res.status !== 200) {
|
|
402
|
+
return false;
|
|
403
|
+
}
|
|
404
|
+
return res;
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
var toSSG = async (app, fs, options) => {
|
|
408
|
+
let result;
|
|
409
|
+
const getInfoPromises = [];
|
|
410
|
+
const savePromises = [];
|
|
411
|
+
const plugins = options?.plugins || [defaultPlugin];
|
|
412
|
+
const beforeRequestHooks = [];
|
|
413
|
+
const afterResponseHooks = [];
|
|
414
|
+
const afterGenerateHooks = [];
|
|
415
|
+
if (options?.beforeRequestHook) {
|
|
416
|
+
beforeRequestHooks.push(
|
|
417
|
+
...Array.isArray(options.beforeRequestHook) ? options.beforeRequestHook : [options.beforeRequestHook]
|
|
418
|
+
);
|
|
419
|
+
}
|
|
420
|
+
if (options?.afterResponseHook) {
|
|
421
|
+
afterResponseHooks.push(
|
|
422
|
+
...Array.isArray(options.afterResponseHook) ? options.afterResponseHook : [options.afterResponseHook]
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
if (options?.afterGenerateHook) {
|
|
426
|
+
afterGenerateHooks.push(
|
|
427
|
+
...Array.isArray(options.afterGenerateHook) ? options.afterGenerateHook : [options.afterGenerateHook]
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
for (const plugin of plugins) {
|
|
431
|
+
if (plugin.beforeRequestHook) {
|
|
432
|
+
beforeRequestHooks.push(
|
|
433
|
+
...Array.isArray(plugin.beforeRequestHook) ? plugin.beforeRequestHook : [plugin.beforeRequestHook]
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
if (plugin.afterResponseHook) {
|
|
437
|
+
afterResponseHooks.push(
|
|
438
|
+
...Array.isArray(plugin.afterResponseHook) ? plugin.afterResponseHook : [plugin.afterResponseHook]
|
|
439
|
+
);
|
|
440
|
+
}
|
|
441
|
+
if (plugin.afterGenerateHook) {
|
|
442
|
+
afterGenerateHooks.push(
|
|
443
|
+
...Array.isArray(plugin.afterGenerateHook) ? plugin.afterGenerateHook : [plugin.afterGenerateHook]
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
try {
|
|
448
|
+
const outputDir = options?.dir ?? DEFAULT_OUTPUT_DIR;
|
|
449
|
+
const concurrency = options?.concurrency ?? DEFAULT_CONCURRENCY2;
|
|
450
|
+
const combinedBeforeRequestHook = combineBeforeRequestHooks(
|
|
451
|
+
beforeRequestHooks.length > 0 ? beforeRequestHooks : [(req) => req]
|
|
452
|
+
);
|
|
453
|
+
const combinedAfterResponseHook = combineAfterResponseHooks(
|
|
454
|
+
afterResponseHooks.length > 0 ? afterResponseHooks : [(req) => req]
|
|
455
|
+
);
|
|
456
|
+
const getInfoGen = fetchRoutesContent(
|
|
457
|
+
app,
|
|
458
|
+
combinedBeforeRequestHook,
|
|
459
|
+
combinedAfterResponseHook,
|
|
460
|
+
concurrency
|
|
461
|
+
);
|
|
462
|
+
for (const getInfo of getInfoGen) {
|
|
463
|
+
getInfoPromises.push(
|
|
464
|
+
getInfo.then((getContentGen) => {
|
|
465
|
+
if (!getContentGen) {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
for (const content of getContentGen) {
|
|
469
|
+
savePromises.push(
|
|
470
|
+
saveContentToFile(content, fs, outputDir, options?.extensionMap).catch((e) => e)
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
})
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
await Promise.all(getInfoPromises);
|
|
477
|
+
const files = [];
|
|
478
|
+
for (const savePromise of savePromises) {
|
|
479
|
+
const fileOrError = await savePromise;
|
|
480
|
+
if (typeof fileOrError === "string") {
|
|
481
|
+
files.push(fileOrError);
|
|
482
|
+
} else if (fileOrError) {
|
|
483
|
+
throw fileOrError;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
result = { success: true, files };
|
|
487
|
+
} catch (error) {
|
|
488
|
+
const errorObj = error instanceof Error ? error : new Error(String(error));
|
|
489
|
+
result = { success: false, files: [], error: errorObj };
|
|
490
|
+
}
|
|
491
|
+
if (afterGenerateHooks.length > 0) {
|
|
492
|
+
const combinedAfterGenerateHooks = combineAfterGenerateHooks(afterGenerateHooks, fs, options);
|
|
493
|
+
await combinedAfterGenerateHooks(result, fs, options);
|
|
494
|
+
}
|
|
495
|
+
return result;
|
|
496
|
+
};
|
|
497
|
+
export {
|
|
498
|
+
DEFAULT_OUTPUT_DIR,
|
|
499
|
+
X_HONO_DISABLE_SSG_HEADER_KEY,
|
|
500
|
+
combineAfterGenerateHooks,
|
|
501
|
+
combineAfterResponseHooks,
|
|
502
|
+
combineBeforeRequestHooks,
|
|
503
|
+
defaultExtensionMap,
|
|
504
|
+
defaultPlugin,
|
|
505
|
+
disableSSG,
|
|
506
|
+
fetchRoutesContent,
|
|
507
|
+
isSSGContext,
|
|
508
|
+
onlySSG,
|
|
509
|
+
saveContentToFile,
|
|
510
|
+
ssgParams,
|
|
511
|
+
toSSG
|
|
512
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudwerk/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Dev server, build, deploy commands for Cloudwerk",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -29,10 +29,11 @@
|
|
|
29
29
|
"commander": "^12.1.0",
|
|
30
30
|
"esbuild": "^0.25.0",
|
|
31
31
|
"picocolors": "^1.1.0",
|
|
32
|
+
"wrangler": "^4.0.0",
|
|
32
33
|
"vite": "^6.0.0",
|
|
33
|
-
"@cloudwerk/core": "^0.
|
|
34
|
-
"@cloudwerk/
|
|
35
|
-
"@cloudwerk/
|
|
34
|
+
"@cloudwerk/core": "^0.15.0",
|
|
35
|
+
"@cloudwerk/vite-plugin": "^0.6.2",
|
|
36
|
+
"@cloudwerk/ui": "^0.15.0"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@types/node": "^20.0.0",
|