esa-pcg-cli 0.1.23-beta.2 → 0.1.23-beta.4
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 +69 -11
- package/dist/_inline-overrides.js +4 -4
- package/dist/adapters/wrappers/node-server.js +2 -2
- package/dist/astro/packaging/artifact-layout.js +2 -17
- package/dist/astro-runtime/cache-provider.mjs +2 -2
- package/dist/bin/cli.js +5 -1
- package/dist/build/prepared-project.d.ts +17 -0
- package/dist/build/prepared-project.js +152 -0
- package/dist/commands/build-astro.d.ts +10 -0
- package/dist/commands/build-astro.js +14 -3
- package/dist/commands/build-next.d.ts +13 -0
- package/dist/commands/build-next.js +90 -73
- package/dist/commands/build-nuxt.d.ts +11 -0
- package/dist/commands/build-nuxt.js +12 -6
- package/dist/commands/build.d.ts +1 -0
- package/dist/commands/build.js +3 -2
- package/dist/commands/package.d.ts +9 -0
- package/dist/commands/package.js +170 -0
- package/dist/commands/prepare.d.ts +11 -0
- package/dist/commands/prepare.js +232 -0
- package/dist/config/default-open-next-config.js +6 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -2
- package/dist/nitro-preset/cache-plugin.mjs +15 -0
- package/dist/nitro-preset/driver.mjs +13 -86
- package/dist/nitro-preset/gateway.mjs +56 -0
- package/dist/nitro-preset/image.mjs +122 -0
- package/dist/nitro-preset/index.mjs +85 -5
- package/dist/nitro-preset/isr.d.mts +6 -0
- package/dist/nitro-preset/isr.mjs +288 -0
- package/dist/nitro-preset/package.json +11 -3
- package/dist/runtime/cdn-purge.d.ts +1 -1
- package/dist/runtime/cdn-purge.js +3 -3
- package/dist/runtime/edge-context.d.ts +1 -1
- package/dist/runtime/edge-context.js +3 -3
- package/dist/runtime/efc-observability.cjs +11 -1
- package/dist/runtime/efc-observability.d.cts +1 -0
- package/package.json +1 -1
- package/dist/astro-runtime/request-header-logger.mjs +0 -68
package/README.md
CHANGED
|
@@ -36,6 +36,50 @@ contract is `node start.mjs`, `process.env.PORT || 3000`, and host `0.0.0.0`.
|
|
|
36
36
|
Relative `--out-dir` values are resolved from `--dir`. The default is
|
|
37
37
|
`.pcg/output`.
|
|
38
38
|
|
|
39
|
+
## Separate CI steps
|
|
40
|
+
|
|
41
|
+
Use a disposable CI working copy to run PCG injection, the project's build
|
|
42
|
+
script, and artifact packaging as separate steps:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npx pcg prepare --framework nextjs --dir .
|
|
46
|
+
npm run build
|
|
47
|
+
npx pcg package --dir . --out-dir .pcg/output
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The same sequence supports `--framework astro` and `--framework nuxt`.
|
|
51
|
+
`package` reads the framework saved by `prepare`; an explicit `--framework`
|
|
52
|
+
must match. All commands must use the same project directory. Install the
|
|
53
|
+
project dependencies and the CLI before preparing, and keep that installation
|
|
54
|
+
available until packaging completes.
|
|
55
|
+
|
|
56
|
+
`prepare` does not build. It writes PCG configuration/runtime files and replaces
|
|
57
|
+
`scripts.build` with a generated runner, preserving the original build command
|
|
58
|
+
in `.pcg/prepared.json`. Next.js runs that command through OpenNext; a custom
|
|
59
|
+
OpenNext `buildCommand` remains authoritative. Astro keeps its original build
|
|
60
|
+
command and loads PCG's config overlay through the project config. Nuxt keeps
|
|
61
|
+
its original command with `NITRO_PRESET=esa-nitro-preset`. The runner supplies
|
|
62
|
+
the framework's required environment variables. npm `prebuild`/`postbuild`
|
|
63
|
+
hooks remain on the outer build script.
|
|
64
|
+
|
|
65
|
+
`prepare` accepts `--config` for Next.js/Astro, `--debug`, and
|
|
66
|
+
`--force-unsupported-next`. For a custom Astro config, pass the same config
|
|
67
|
+
path used by the original build script. The original script must build the
|
|
68
|
+
selected framework; PCG/OpenNext orchestration scripts are rejected to prevent
|
|
69
|
+
recursive builds. Repeating `prepare` with the same options is a no-op;
|
|
70
|
+
different options require a fresh working copy.
|
|
71
|
+
|
|
72
|
+
`package` requires a successful prepared build, performs the existing runtime
|
|
73
|
+
patches, dependency tracing and cache conversion, and validates the complete
|
|
74
|
+
`assets/`, `fc/`, `isr-cache/` layout before replacing the previous artifact.
|
|
75
|
+
It never runs a framework build. Astro packaging still needs the installed
|
|
76
|
+
project dependencies for tracing. Packaging can be repeated without rebuilding.
|
|
77
|
+
|
|
78
|
+
Injection files and modified configuration stay in the supplied CI working
|
|
79
|
+
copy until it is discarded. Do not commit them back to the source repository.
|
|
80
|
+
The existing `pcg build` command remains the one-command build/package flow
|
|
81
|
+
and does not require `prepare`.
|
|
82
|
+
|
|
39
83
|
## Local preview
|
|
40
84
|
|
|
41
85
|
```bash
|
|
@@ -89,7 +133,7 @@ contract as `esa-pcg-cli@0.1.17`.
|
|
|
89
133
|
ESA CDN cache. `PCG_CDN_PURGE_MODE=path` (the default) uses the embedded
|
|
90
134
|
OpenNext tag-to-path manifest and refreshes both route and `/_next/data` URLs;
|
|
91
135
|
`PCG_CDN_PURGE_MODE=tag` sends `cacheTags` directly. The inbound request must
|
|
92
|
-
carry `host` and `
|
|
136
|
+
carry `host` and `ali-esa-origin-site-id`, which the wrapper keeps in request-local
|
|
93
137
|
context. Next.js 16 `use cache` is routed through the composable-cache handler.
|
|
94
138
|
|
|
95
139
|
## Astro integration
|
|
@@ -101,7 +145,7 @@ Route Cache during build, so `isr-cache/` is empty.
|
|
|
101
145
|
|
|
102
146
|
Explicit `Astro.cache.invalidate()` / `context.cache.invalidate()` calls write
|
|
103
147
|
the tag invalidation and call Gateway `/cache/refresh` with the current
|
|
104
|
-
request's `host` and `
|
|
148
|
+
request's `host` and `ali-esa-origin-site-id`. Normal TTL/SWR expiry refreshes the
|
|
105
149
|
runtime object and does not issue an extra purge request. For the injected PCG
|
|
106
150
|
provider, the certified Astro 6/7 artifact patch preserves
|
|
107
151
|
`CDN-Cache-Control` and `Cache-Tag` through the Node adapter so ESA can build
|
|
@@ -112,15 +156,6 @@ is a trusted origin reachable only through ESA, while ESA terminates TLS before
|
|
|
112
156
|
forwarding over HTTP. Deployments that expose EFC directly must provide an
|
|
113
157
|
equivalent CSRF boundary before using this artifact.
|
|
114
158
|
|
|
115
|
-
The temporary ESA-to-EFC diagnostic build appends requests whose pathname ends
|
|
116
|
-
in `/invalidate` as NDJSON to `/tmp/pcg-astro-request-headers.ndjson` without
|
|
117
|
-
requiring an enable flag. Other requests are not logged. Each record includes
|
|
118
|
-
the complete normalized `headers` object and Node.js `rawHeaders` array.
|
|
119
|
-
Override the path with
|
|
120
|
-
`PCG_ASTRO_REQUEST_HEADER_LOG_PATH`. Because the log can contain Cookie,
|
|
121
|
-
Authorization, and other credentials, delete it and remove this temporary
|
|
122
|
-
diagnostic code immediately after diagnosis.
|
|
123
|
-
|
|
124
159
|
## Nuxt integration
|
|
125
160
|
|
|
126
161
|
Nuxt builds use the bundled `esa-nitro-preset`, which extends Nitro's
|
|
@@ -128,6 +163,29 @@ Nuxt builds use the bundled `esa-nitro-preset`, which extends Nitro's
|
|
|
128
163
|
gateway client. The resulting `fc/server` bundle is supported by `pcg serve`;
|
|
129
164
|
Nuxt does not seed `isr-cache/` during build.
|
|
130
165
|
|
|
166
|
+
`routeRules.isr` uses Nitro's SWR response and cache policy. For ISR routes
|
|
167
|
+
using PCG's default `cache` driver, the stored response includes its pathname,
|
|
168
|
+
Nitro cache key and any declared data dependencies. The EFC checks their
|
|
169
|
+
invalidation generations in TableStore before serving the cached response.
|
|
170
|
+
|
|
171
|
+
In server code, import `trackNuxtCacheKey` and `invalidateNuxtCache` from
|
|
172
|
+
`esa-nitro-preset/isr`. Register a shared data key before reading it on any
|
|
173
|
+
render that depends on it. Use its Nitro storage key relative to the `cache`
|
|
174
|
+
mount, such as `nitro:functions:getArticle:123.json`. After updating the data,
|
|
175
|
+
call `invalidateNuxtCache({ key })`. To invalidate every cache variant of a
|
|
176
|
+
pathname, call `invalidateNuxtCache({ path: '/blog/123' })` with `app.baseURL`
|
|
177
|
+
included when configured. The call records the origin invalidation first and
|
|
178
|
+
returns the separate CDN submission status. CDN submission uses the originating
|
|
179
|
+
ESA request's site ID and host, or an explicit `{ hostname, siteId }` second
|
|
180
|
+
argument from a trusted server caller. Use these helpers from server routes or
|
|
181
|
+
server utilities in the PCG build.
|
|
182
|
+
|
|
183
|
+
The production build replaces Nuxt Image's built-in runtime IPX handler with a
|
|
184
|
+
signed Gateway proxy. It supports resize, width, height, quality and format.
|
|
185
|
+
Other IPX transforms, such as custom crop positions and grayscale, return a
|
|
186
|
+
client error. Custom providers and pre-rendered image assets follow Nuxt Image's
|
|
187
|
+
normal behavior.
|
|
188
|
+
|
|
131
189
|
## Other commands
|
|
132
190
|
|
|
133
191
|
`deploy`, `upload-cache`, and `upload-assets` remain legacy/manual commands. The
|