@pracht/cli 1.1.3 → 1.1.5
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/CHANGELOG.md +18 -0
- package/LICENSE +21 -0
- package/lib/build-shared.js +44 -18
- package/lib/commands/build.js +15 -0
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @pracht/cli
|
|
2
2
|
|
|
3
|
+
## 1.1.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`628a3e2`](https://github.com/JoviDeCroock/pracht/commit/628a3e27c78ffd11d8ab3ee34da8e77e5e7a7a3e) Thanks [@JoviDeCroock](https://github.com/JoviDeCroock)! - Add MIT license metadata and LICENSE files to all published packages.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`628a3e2`](https://github.com/JoviDeCroock/pracht/commit/628a3e27c78ffd11d8ab3ee34da8e77e5e7a7a3e)]:
|
|
10
|
+
- @pracht/core@0.2.5
|
|
11
|
+
|
|
12
|
+
## 1.1.4
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#88](https://github.com/JoviDeCroock/pracht/pull/88) [`f36f102`](https://github.com/JoviDeCroock/pracht/commit/f36f102eb9494ec8ea1db3fe20219ad95ccab257) Thanks [@kinngh](https://github.com/kinngh)! - Add shell and route `headers()` exports for page document responses. Headers merge like `head()` metadata, are preserved in prerender output, and are applied to static SSG/ISG HTML served by the built-in adapters.
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`f36f102`](https://github.com/JoviDeCroock/pracht/commit/f36f102eb9494ec8ea1db3fe20219ad95ccab257)]:
|
|
19
|
+
- @pracht/core@0.2.4
|
|
20
|
+
|
|
3
21
|
## 1.1.3
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jovi De Croock
|
|
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/lib/build-shared.js
CHANGED
|
@@ -14,7 +14,14 @@ export function setDefaultSecurityHeaders(res, headers = {}) {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export function writeVercelBuildOutput({
|
|
17
|
+
export function writeVercelBuildOutput({
|
|
18
|
+
functionName,
|
|
19
|
+
headersManifest = {},
|
|
20
|
+
regions,
|
|
21
|
+
root,
|
|
22
|
+
staticRoutes,
|
|
23
|
+
isgRoutes,
|
|
24
|
+
}) {
|
|
18
25
|
const outputDir = join(root, ".vercel/output");
|
|
19
26
|
const staticDir = join(outputDir, "static");
|
|
20
27
|
const functionDir = join(outputDir, "functions", `${functionName || "render"}.func`);
|
|
@@ -26,7 +33,11 @@ export function writeVercelBuildOutput({ functionName, regions, root, staticRout
|
|
|
26
33
|
|
|
27
34
|
writeFileSync(
|
|
28
35
|
join(outputDir, "config.json"),
|
|
29
|
-
`${JSON.stringify(
|
|
36
|
+
`${JSON.stringify(
|
|
37
|
+
createVercelOutputConfig({ functionName, headersManifest, staticRoutes, isgRoutes }),
|
|
38
|
+
null,
|
|
39
|
+
2,
|
|
40
|
+
)}\n`,
|
|
30
41
|
"utf-8",
|
|
31
42
|
);
|
|
32
43
|
writeFileSync(
|
|
@@ -38,7 +49,7 @@ export function writeVercelBuildOutput({ functionName, regions, root, staticRout
|
|
|
38
49
|
return ".vercel/output";
|
|
39
50
|
}
|
|
40
51
|
|
|
41
|
-
function createVercelOutputConfig({ functionName, staticRoutes, isgRoutes }) {
|
|
52
|
+
function createVercelOutputConfig({ functionName, headersManifest, staticRoutes, isgRoutes }) {
|
|
42
53
|
const target = `/${functionName || "render"}`;
|
|
43
54
|
const routes = [
|
|
44
55
|
{
|
|
@@ -65,22 +76,33 @@ function createVercelOutputConfig({ functionName, staticRoutes, isgRoutes }) {
|
|
|
65
76
|
routes.push({ handle: "filesystem" });
|
|
66
77
|
routes.push({ dest: target, src: "/(.*)" });
|
|
67
78
|
|
|
79
|
+
const headers = [
|
|
80
|
+
{
|
|
81
|
+
headers: [
|
|
82
|
+
{
|
|
83
|
+
key: "permissions-policy",
|
|
84
|
+
value:
|
|
85
|
+
"accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()",
|
|
86
|
+
},
|
|
87
|
+
{ key: "referrer-policy", value: "strict-origin-when-cross-origin" },
|
|
88
|
+
{ key: "x-content-type-options", value: "nosniff" },
|
|
89
|
+
{ key: "x-frame-options", value: "SAMEORIGIN" },
|
|
90
|
+
],
|
|
91
|
+
source: "/(.*)",
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
for (const route of sortStaticRoutes(staticRoutes)) {
|
|
96
|
+
const routeHeaders = headersManifest[route];
|
|
97
|
+
if (!routeHeaders) continue;
|
|
98
|
+
headers.push({
|
|
99
|
+
headers: Object.entries(routeHeaders).map(([key, value]) => ({ key, value })),
|
|
100
|
+
source: routeToHeaderSource(route),
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
68
104
|
return {
|
|
69
|
-
headers
|
|
70
|
-
{
|
|
71
|
-
headers: [
|
|
72
|
-
{
|
|
73
|
-
key: "permissions-policy",
|
|
74
|
-
value:
|
|
75
|
-
"accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()",
|
|
76
|
-
},
|
|
77
|
-
{ key: "referrer-policy", value: "strict-origin-when-cross-origin" },
|
|
78
|
-
{ key: "x-content-type-options", value: "nosniff" },
|
|
79
|
-
{ key: "x-frame-options", value: "SAMEORIGIN" },
|
|
80
|
-
],
|
|
81
|
-
source: "/(.*)",
|
|
82
|
-
},
|
|
83
|
-
],
|
|
105
|
+
headers,
|
|
84
106
|
framework: {
|
|
85
107
|
version: VERSION,
|
|
86
108
|
},
|
|
@@ -122,6 +144,10 @@ function routeToStaticHtmlPath(route) {
|
|
|
122
144
|
return `${route}/index.html`;
|
|
123
145
|
}
|
|
124
146
|
|
|
147
|
+
function routeToHeaderSource(route) {
|
|
148
|
+
return route === "/" ? "/" : route;
|
|
149
|
+
}
|
|
150
|
+
|
|
125
151
|
function escapeRegex(value) {
|
|
126
152
|
return value.replace(/[|\\{}()[\]^$+*?.-]/g, "\\$&");
|
|
127
153
|
}
|
package/lib/commands/build.js
CHANGED
|
@@ -60,6 +60,9 @@ export async function buildCommand() {
|
|
|
60
60
|
registry: serverMod.registry,
|
|
61
61
|
withISGManifest: true,
|
|
62
62
|
});
|
|
63
|
+
const headersManifest = Object.fromEntries(
|
|
64
|
+
pages.map((page) => [page.path, page.headers ?? {}]),
|
|
65
|
+
);
|
|
63
66
|
|
|
64
67
|
if (pages.length > 0) {
|
|
65
68
|
console.log(`\n Prerendering ${pages.length} SSG/ISG route(s)...\n`);
|
|
@@ -75,6 +78,17 @@ export async function buildCommand() {
|
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
|
|
81
|
+
if (Object.keys(headersManifest).length > 0) {
|
|
82
|
+
const headersManifestJson = `${JSON.stringify(headersManifest, null, 2)}\n`;
|
|
83
|
+
writeFileSync(
|
|
84
|
+
resolve(root, "dist/server/headers-manifest.json"),
|
|
85
|
+
headersManifestJson,
|
|
86
|
+
"utf-8",
|
|
87
|
+
);
|
|
88
|
+
mkdirSync(resolve(clientDir, "_pracht"), { recursive: true });
|
|
89
|
+
writeFileSync(resolve(clientDir, "_pracht/headers.json"), headersManifestJson, "utf-8");
|
|
90
|
+
}
|
|
91
|
+
|
|
78
92
|
if (Object.keys(isgManifest).length > 0) {
|
|
79
93
|
const isgManifestPath = resolve(root, "dist/server/isg-manifest.json");
|
|
80
94
|
writeFileSync(isgManifestPath, JSON.stringify(isgManifest, null, 2), "utf-8");
|
|
@@ -92,6 +106,7 @@ export async function buildCommand() {
|
|
|
92
106
|
const outputPath = writeVercelBuildOutput({
|
|
93
107
|
functionName: serverMod.vercelFunctionName,
|
|
94
108
|
isgRoutes: Object.keys(isgManifest),
|
|
109
|
+
headersManifest,
|
|
95
110
|
regions: serverMod.vercelRegions,
|
|
96
111
|
root,
|
|
97
112
|
staticRoutes: pages.map((page) => page.path).filter((path) => !(path in isgManifest)),
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pracht/cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
|
+
"license": "MIT",
|
|
4
5
|
"homepage": "https://github.com/JoviDeCroock/pracht/tree/main/packages/cli",
|
|
5
6
|
"bugs": {
|
|
6
7
|
"url": "https://github.com/JoviDeCroock/pracht/issues"
|
|
@@ -18,6 +19,6 @@
|
|
|
18
19
|
"provenance": true
|
|
19
20
|
},
|
|
20
21
|
"dependencies": {
|
|
21
|
-
"@pracht/core": "0.2.
|
|
22
|
+
"@pracht/core": "0.2.5"
|
|
22
23
|
}
|
|
23
24
|
}
|