getfilepress 0.1.24 → 0.1.25
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 +3 -2
- package/scripts/assert-no-genie.mjs +52 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "getfilepress",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.25",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "FilePress — file-based Markdown blog engine. Link this package from a content-only site (config + posts), then run `filepress build`.",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"scripts/new-post.ts",
|
|
38
38
|
"scripts/preview.mjs",
|
|
39
39
|
"scripts/copy-path-mounts.mjs",
|
|
40
|
+
"scripts/assert-no-genie.mjs",
|
|
40
41
|
"scripts/create-site.mjs",
|
|
41
42
|
"scripts/ensure-lease.mjs",
|
|
42
43
|
"scripts/postinstall.mjs",
|
|
@@ -51,7 +52,7 @@
|
|
|
51
52
|
"scripts": {
|
|
52
53
|
"postinstall": "node scripts/postinstall.mjs",
|
|
53
54
|
"filepress": "node scripts/filepress.mjs",
|
|
54
|
-
"test": "pnpm --filter @filepress/core test && pnpm --filter @filepress/import test && pnpm --filter @filepress/app test && tsx --test scripts/sync-sibling-sites.test.ts scripts/siblings/discover.test.ts scripts/new-post.test.ts scripts/preview.test.ts scripts/assert-no-genie.test.ts",
|
|
55
|
+
"test": "pnpm --filter @filepress/core test && pnpm --filter @filepress/import test && pnpm --filter @filepress/app test && tsx --test scripts/sync-sibling-sites.test.ts scripts/siblings/discover.test.ts scripts/new-post.test.ts scripts/preview.test.ts scripts/assert-no-genie.test.ts scripts/published-files.test.ts",
|
|
55
56
|
"check": "pnpm filepress check --site demo",
|
|
56
57
|
"build": "pnpm filepress build --site demo",
|
|
57
58
|
"build:demo": "pnpm filepress build --site demo",
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fail a FilePress `build/` if Genie leaked into the static output.
|
|
3
|
+
* Genie is serve-only (`filepress dev`). Production must not ship the panel,
|
|
4
|
+
* its CSS/JS chunk names, or `/__filepress/genie` calls.
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
7
|
+
import { extname, join, relative } from 'node:path';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
|
|
10
|
+
const MARKERS = ['GeniePanel', 'GenieHost', 'genie-fab', '/__filepress/genie'];
|
|
11
|
+
const TEXT_EXT = new Set(['.html', '.js', '.css', '.json', '.txt', '.svg', '.xml']);
|
|
12
|
+
|
|
13
|
+
export function assertNoGenieInBuild(buildDir) {
|
|
14
|
+
if (!existsSync(buildDir)) {
|
|
15
|
+
throw new Error(`filepress: Genie leak check skipped — missing build dir ${buildDir}`);
|
|
16
|
+
}
|
|
17
|
+
const hits = [];
|
|
18
|
+
walk(buildDir, (file) => {
|
|
19
|
+
if (!TEXT_EXT.has(extname(file).toLowerCase())) return;
|
|
20
|
+
const text = readFileSync(file, 'utf8');
|
|
21
|
+
for (const marker of MARKERS) {
|
|
22
|
+
if (text.includes(marker)) {
|
|
23
|
+
hits.push(`${relative(buildDir, file)}: ${marker}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
if (hits.length > 0) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`filepress: Genie leaked into the static build (dev-only).\n` +
|
|
30
|
+
hits.map((h) => ` ${h}`).join('\n')
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function walk(dir, visit) {
|
|
36
|
+
for (const name of readdirSync(dir)) {
|
|
37
|
+
const abs = join(dir, name);
|
|
38
|
+
if (statSync(abs).isDirectory()) walk(abs, visit);
|
|
39
|
+
else visit(abs);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const isMain =
|
|
44
|
+
Boolean(process.argv[1]) && fileURLToPath(import.meta.url) === process.argv[1];
|
|
45
|
+
if (isMain) {
|
|
46
|
+
try {
|
|
47
|
+
assertNoGenieInBuild(process.argv[2] ?? '');
|
|
48
|
+
} catch (err) {
|
|
49
|
+
console.error(err instanceof Error ? err.message : err);
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
}
|