astro-build-manifest 1.0.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/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Velohost
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,142 @@
1
+ # astro-build-manifest
2
+
3
+ Static-first build manifest generation for Astro.
4
+
5
+ `astro-build-manifest` is a minimal Astro integration that outputs a deterministic
6
+ `build-manifest.json` file at build time, describing exactly what pages and assets
7
+ Astro generated.
8
+
9
+ It is designed for **static sites first** and never runs at runtime.
10
+
11
+ ---
12
+
13
+ ## Why this plugin exists
14
+
15
+ After a build, teams often ask:
16
+
17
+ - What routes were actually generated?
18
+ - Did `/about/` build correctly?
19
+ - What files did Astro emit?
20
+ - Why is a page missing in production?
21
+
22
+ Astro already knows this information internally, but does not expose it in a simple,
23
+ machine-readable way.
24
+
25
+ `astro-build-manifest` exposes that data safely and honestly.
26
+
27
+ ---
28
+
29
+ ## What it does (v1)
30
+
31
+ On `astro build`, the plugin writes a file to your output directory:
32
+
33
+ ```
34
+ /build-manifest.json
35
+ ```
36
+
37
+ Example output:
38
+
39
+ ```json
40
+ {
41
+ "pages": [
42
+ "/",
43
+ "/about/"
44
+ ],
45
+ "assets": [
46
+ "/index.html",
47
+ "/about/index.html",
48
+ "/_astro/main.abc123.css"
49
+ ],
50
+ "generatedAt": "2026-01-08T19:08:18.024Z"
51
+ }
52
+ ```
53
+
54
+ ---
55
+
56
+ ## What is included
57
+
58
+ ### Pages
59
+ - All routes Astro generated during the build
60
+ - Normalised with leading and trailing slashes
61
+ - `/` always represents the homepage
62
+
63
+ ### Assets
64
+ - Files emitted by Astro’s build pipeline
65
+ - HTML entrypoints
66
+ - CSS and JavaScript bundles
67
+ - Only public, web-facing paths
68
+
69
+ ---
70
+
71
+ ## What is intentionally excluded
72
+
73
+ - Files in `/public`
74
+ - Environment variables
75
+ - Runtime state
76
+ - Absolute filesystem paths
77
+ - Server or adapter information
78
+
79
+ This keeps the manifest deterministic, portable, and safe to expose publicly.
80
+
81
+ ---
82
+
83
+ ## Installation
84
+
85
+ ```bash
86
+ npm install astro-build-manifest
87
+ ```
88
+
89
+ ---
90
+
91
+ ## Usage
92
+
93
+ Add the integration to your `astro.config.mjs`:
94
+
95
+ ```js
96
+ import { defineConfig } from "astro/config";
97
+ import astroBuildManifest from "astro-build-manifest";
98
+
99
+ export default defineConfig({
100
+ integrations: [
101
+ astroBuildManifest()
102
+ ]
103
+ });
104
+ ```
105
+
106
+ Then run:
107
+
108
+ ```bash
109
+ astro build
110
+ ```
111
+
112
+ ---
113
+
114
+ ## Output guarantees
115
+
116
+ - Static-only
117
+ - Deterministic JSON
118
+ - Public-safe paths only
119
+ - No runtime execution
120
+
121
+ ---
122
+
123
+ ## Versioning
124
+
125
+ - **v1.x** — static build manifest only
126
+ - **v2 (planned)** — optional public directory inclusion and diffing
127
+
128
+ ---
129
+
130
+ ## License
131
+
132
+ MIT
133
+
134
+ ---
135
+
136
+ ## Author
137
+
138
+ Built and maintained by **Velohost**
139
+ https://velohost.co.uk/
140
+
141
+ Project homepage:
142
+ https://velohost.co.uk/plugins/astro-build-manifest/
@@ -0,0 +1,13 @@
1
+ import type { AstroIntegration } from "astro";
2
+ /**
3
+ * astro-build-manifest
4
+ *
5
+ * Static-first build manifest plugin for Astro.
6
+ *
7
+ * v1 behaviour:
8
+ * - Lists generated routes (pages)
9
+ * - Lists build-emitted assets only (JS/CSS/HTML)
10
+ * - Does NOT scan /public
11
+ * - Does NOT expose filesystem paths
12
+ */
13
+ export default function astroBuildManifest(): AstroIntegration;
package/dist/index.js ADDED
@@ -0,0 +1,59 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ /**
4
+ * astro-build-manifest
5
+ *
6
+ * Static-first build manifest plugin for Astro.
7
+ *
8
+ * v1 behaviour:
9
+ * - Lists generated routes (pages)
10
+ * - Lists build-emitted assets only (JS/CSS/HTML)
11
+ * - Does NOT scan /public
12
+ * - Does NOT expose filesystem paths
13
+ */
14
+ export default function astroBuildManifest() {
15
+ return {
16
+ name: "astro-build-manifest",
17
+ hooks: {
18
+ "astro:build:done"({ dir, pages, assets }) {
19
+ const outDir = new URL(dir).pathname;
20
+ if (!fs.existsSync(outDir))
21
+ return;
22
+ const manifestPath = path.join(outDir, "build-manifest.json");
23
+ /**
24
+ * Normalise page paths:
25
+ * - "" -> "/"
26
+ * - ensure single leading + trailing slash
27
+ */
28
+ const pageList = pages.map(p => {
29
+ const raw = p.pathname || "";
30
+ const trimmed = raw.replace(/^\/+|\/+$/g, "");
31
+ return trimmed === "" ? "/" : `/${trimmed}/`;
32
+ });
33
+ /**
34
+ * Extract PUBLIC build-emitted assets only.
35
+ * (/public files are intentionally excluded)
36
+ */
37
+ const assetList = [];
38
+ for (const urls of assets.values()) {
39
+ for (const url of urls) {
40
+ if (url.protocol !== "file:")
41
+ continue;
42
+ const filePath = url.pathname;
43
+ if (!filePath.startsWith(outDir))
44
+ continue;
45
+ const publicPath = "/" + path.relative(outDir, filePath).replace(/\\/g, "/");
46
+ assetList.push(publicPath);
47
+ }
48
+ }
49
+ const payload = {
50
+ pages: Array.from(new Set(pageList)).sort(),
51
+ assets: Array.from(new Set(assetList)).sort(),
52
+ generatedAt: new Date().toISOString()
53
+ };
54
+ fs.writeFileSync(manifestPath, JSON.stringify(payload, null, 2), "utf-8");
55
+ console.log("[astro-build-manifest] wrote /build-manifest.json");
56
+ }
57
+ }
58
+ };
59
+ }
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "astro-build-manifest",
3
+ "version": "1.0.0",
4
+ "description": "Static build manifest of generated pages and assets for Astro sites",
5
+ "homepage": "https://velohost.co.uk/plugins/astro-build-manifest/",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/velohost/astro-build-manifest.git"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/velohost/astro-build-manifest/issues"
12
+ },
13
+ "license": "MIT",
14
+ "type": "module",
15
+ "keywords": [
16
+ "withastro",
17
+ "astro-integration",
18
+ "build",
19
+ "manifest",
20
+ "pages",
21
+ "assets",
22
+ "static-site"
23
+ ],
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "default": "./dist/index.js"
28
+ }
29
+ },
30
+ "files": [
31
+ "dist"
32
+ ],
33
+ "scripts": {
34
+ "build": "tsc"
35
+ },
36
+ "peerDependencies": {
37
+ "astro": "^4.0.0 || ^5.0.0"
38
+ },
39
+ "devDependencies": {
40
+ "@types/node": "^25.0.3",
41
+ "typescript": "^5.0.0"
42
+ }
43
+ }