@gravito/constellation 3.0.1 → 3.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 +96 -251
- package/README.zh-TW.md +130 -13
- package/dist/{DiskSitemapStorage-7ZZMGC4K.js → DiskSitemapStorage-VLN5I24C.js} +1 -1
- package/dist/chunk-3IZTXYU7.js +166 -0
- package/dist/index.cjs +1893 -196
- package/dist/index.d.cts +1597 -171
- package/dist/index.d.ts +1597 -171
- package/dist/index.js +1774 -199
- package/package.json +7 -5
- package/dist/chunk-7WHLC3OJ.js +0 -56
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravito/constellation",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Powerful sitemap generation for Gravito applications with dynamic/static support, sharding, and caching.",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -21,9 +21,11 @@
|
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "bun run build.ts",
|
|
23
23
|
"typecheck": "bun tsc -p tsconfig.json --noEmit --skipLibCheck",
|
|
24
|
-
"test": "bun test",
|
|
25
|
-
"test:coverage": "bun test --coverage --coverage-
|
|
26
|
-
"test:ci": "bun test --coverage --coverage-
|
|
24
|
+
"test": "bun test --timeout=10000",
|
|
25
|
+
"test:coverage": "bun test --timeout=10000 --coverage --coverage-reporter=lcov --coverage-dir coverage && bun run --bun scripts/check-coverage.ts",
|
|
26
|
+
"test:ci": "bun test --timeout=10000 --coverage --coverage-reporter=lcov --coverage-dir coverage && bun run --bun scripts/check-coverage.ts",
|
|
27
|
+
"test:unit": "bun test tests/ --timeout=10000",
|
|
28
|
+
"test:integration": "test $(find tests -name '*.integration.test.ts' 2>/dev/null | wc -l) -gt 0 && find tests -name '*.integration.test.ts' -print0 | xargs -0 bun test --timeout=10000 || echo 'No integration tests found'"
|
|
27
29
|
},
|
|
28
30
|
"peerDependencies": {
|
|
29
31
|
"@gravito/core": "workspace:*"
|
|
@@ -56,4 +58,4 @@
|
|
|
56
58
|
"license": "MIT",
|
|
57
59
|
"author": "Carl Lee <carllee0520@gmail.com>",
|
|
58
60
|
"homepage": "https://github.com/gravito-framework/gravito#readme"
|
|
59
|
-
}
|
|
61
|
+
}
|
package/dist/chunk-7WHLC3OJ.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
// src/storage/DiskSitemapStorage.ts
|
|
2
|
-
import fs from "fs/promises";
|
|
3
|
-
import path from "path";
|
|
4
|
-
function sanitizeFilename(filename) {
|
|
5
|
-
if (!filename) {
|
|
6
|
-
throw new Error("Invalid sitemap filename.");
|
|
7
|
-
}
|
|
8
|
-
if (filename.includes("\0")) {
|
|
9
|
-
throw new Error("Invalid sitemap filename.");
|
|
10
|
-
}
|
|
11
|
-
if (filename.includes("/") || filename.includes("\\")) {
|
|
12
|
-
throw new Error("Invalid sitemap filename.");
|
|
13
|
-
}
|
|
14
|
-
if (filename.includes("..")) {
|
|
15
|
-
throw new Error("Invalid sitemap filename.");
|
|
16
|
-
}
|
|
17
|
-
return filename;
|
|
18
|
-
}
|
|
19
|
-
var DiskSitemapStorage = class {
|
|
20
|
-
constructor(outDir, baseUrl) {
|
|
21
|
-
this.outDir = outDir;
|
|
22
|
-
this.baseUrl = baseUrl;
|
|
23
|
-
}
|
|
24
|
-
async write(filename, content) {
|
|
25
|
-
const safeName = sanitizeFilename(filename);
|
|
26
|
-
await fs.mkdir(this.outDir, { recursive: true });
|
|
27
|
-
await fs.writeFile(path.join(this.outDir, safeName), content);
|
|
28
|
-
}
|
|
29
|
-
async read(filename) {
|
|
30
|
-
try {
|
|
31
|
-
const safeName = sanitizeFilename(filename);
|
|
32
|
-
return await fs.readFile(path.join(this.outDir, safeName), "utf-8");
|
|
33
|
-
} catch {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
async exists(filename) {
|
|
38
|
-
try {
|
|
39
|
-
const safeName = sanitizeFilename(filename);
|
|
40
|
-
await fs.access(path.join(this.outDir, safeName));
|
|
41
|
-
return true;
|
|
42
|
-
} catch {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
getUrl(filename) {
|
|
47
|
-
const safeName = sanitizeFilename(filename);
|
|
48
|
-
const base = this.baseUrl.endsWith("/") ? this.baseUrl.slice(0, -1) : this.baseUrl;
|
|
49
|
-
const file = safeName.startsWith("/") ? safeName.slice(1) : safeName;
|
|
50
|
-
return `${base}/${file}`;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export {
|
|
55
|
-
DiskSitemapStorage
|
|
56
|
-
};
|