@easy-web/swa 1.0.0 → 1.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/LICENSE +21 -0
- package/README.md +73 -73
- package/package.json +51 -52
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Achim Ismaili
|
|
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
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
# @easy-web/swa
|
|
2
|
-
|
|
3
|
-
Astro integration that manages Azure Static Web Apps (SWA) 404 handling via a sentinel-marked sidecar file. Ensures the integration's configuration changes are preserved across rebuilds while respecting user-authored settings.
|
|
4
|
-
|
|
5
|
-
## What it does
|
|
6
|
-
|
|
7
|
-
When you add `easyWebNotFound()` to your Astro config, the integration:
|
|
8
|
-
|
|
9
|
-
1. **Reads** the existing `staticwebapp.config.json` at build time (if present)
|
|
10
|
-
2. **Emits** a global 404 response override (`responseOverrides.404`) that rewrites unmatched routes to `/404.html`
|
|
11
|
-
3. **Tracks ownership** via a sidecar file (`staticwebapp.config.json.easy-web-managed.json`) so future builds know which settings the integration manages
|
|
12
|
-
4. **Preserves** all user-authored settings: `auth`, `globalHeaders`, `navigationFallback`, custom routes, and any other `responseOverrides` the user defined
|
|
13
|
-
|
|
14
|
-
## Usage
|
|
15
|
-
|
|
16
|
-
```ts
|
|
17
|
-
// astro.config.mjs
|
|
18
|
-
import { defineConfig } from 'astro/config';
|
|
19
|
-
import easyWebNotFound from '@easy-web/swa';
|
|
20
|
-
|
|
21
|
-
export default defineConfig({
|
|
22
|
-
integrations: [
|
|
23
|
-
easyWebNotFound(),
|
|
24
|
-
],
|
|
25
|
-
});
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
The integration requires no configuration. The `Options` type (with optional `defaultLocale` and `locales` fields) is retained for API compatibility but has no effect in v0.2.0+.
|
|
29
|
-
|
|
30
|
-
## How it works
|
|
31
|
-
|
|
32
|
-
### The sidecar file
|
|
33
|
-
|
|
34
|
-
SWA's `staticwebapp.config.json` schema uses `additionalProperties: false` at the root, which means the config file cannot store metadata about which keys are managed by which tool. To solve this, the integration maintains a sibling file:
|
|
35
|
-
|
|
36
|
-
```json
|
|
37
|
-
// staticwebapp.config.json.easy-web-managed.json
|
|
38
|
-
{
|
|
39
|
-
"keys": ["responseOverrides.404"],
|
|
40
|
-
"version": "0.2.0",
|
|
41
|
-
"docs": "https://github.com/achimismaili/websites/blob/main/docs/decisions/0013-shared-not-found-primitives.md"
|
|
42
|
-
}
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
On the next build, the integration reads this sidecar to determine which keys it previously claimed. If the sidecar says it owns `responseOverrides.404`, the integration updates it; otherwise, it leaves the user's 404 override untouched.
|
|
46
|
-
|
|
47
|
-
### Single global 404 limitation
|
|
48
|
-
|
|
49
|
-
Azure Static Web Apps supports only **one global 404 response override**. This integration emits a single, locale-agnostic 404 handler. If your site uses i18n:
|
|
50
|
-
|
|
51
|
-
- Unmatched routes in any locale will serve the **default-locale 404 body** (from `/404.html`)
|
|
52
|
-
- Per-locale 404 content is **not supported** by this integration
|
|
53
|
-
- If you need locale-specific 404 pages, you must implement them outside this integration (e.g., via Astro routing or a custom SWA configuration)
|
|
54
|
-
|
|
55
|
-
See [ADR 0013 — Shared Not-Found Primitives](https://github.com/achimismaili/websites/blob/main/docs/decisions/0013-shared-not-found-primitives.md) for the full rationale.
|
|
56
|
-
|
|
57
|
-
## Preservation guarantees
|
|
58
|
-
|
|
59
|
-
The integration **only manages** `responseOverrides.404`. All other settings are preserved exactly as you authored them:
|
|
60
|
-
|
|
61
|
-
- ✅ `auth` — untouched
|
|
62
|
-
- ✅ `globalHeaders` — untouched
|
|
63
|
-
- ✅ `navigationFallback` — untouched
|
|
64
|
-
- ✅ `routes` — untouched
|
|
65
|
-
- ✅ Other `responseOverrides` — untouched
|
|
66
|
-
- ✅ All other root keys — untouched
|
|
67
|
-
|
|
68
|
-
If you define your own `responseOverrides.404` before the integration runs, the integration will detect this and skip managing the 404 override, logging a warning instead.
|
|
69
|
-
|
|
70
|
-
## Compatibility
|
|
71
|
-
|
|
72
|
-
- **Astro:** `>=6.0.0 <8.0.0`
|
|
73
|
-
- **Node.js:** `>=18.0.0`
|
|
1
|
+
# @easy-web/swa
|
|
2
|
+
|
|
3
|
+
Astro integration that manages Azure Static Web Apps (SWA) 404 handling via a sentinel-marked sidecar file. Ensures the integration's configuration changes are preserved across rebuilds while respecting user-authored settings.
|
|
4
|
+
|
|
5
|
+
## What it does
|
|
6
|
+
|
|
7
|
+
When you add `easyWebNotFound()` to your Astro config, the integration:
|
|
8
|
+
|
|
9
|
+
1. **Reads** the existing `staticwebapp.config.json` at build time (if present)
|
|
10
|
+
2. **Emits** a global 404 response override (`responseOverrides.404`) that rewrites unmatched routes to `/404.html`
|
|
11
|
+
3. **Tracks ownership** via a sidecar file (`staticwebapp.config.json.easy-web-managed.json`) so future builds know which settings the integration manages
|
|
12
|
+
4. **Preserves** all user-authored settings: `auth`, `globalHeaders`, `navigationFallback`, custom routes, and any other `responseOverrides` the user defined
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
// astro.config.mjs
|
|
18
|
+
import { defineConfig } from 'astro/config';
|
|
19
|
+
import easyWebNotFound from '@easy-web/swa';
|
|
20
|
+
|
|
21
|
+
export default defineConfig({
|
|
22
|
+
integrations: [
|
|
23
|
+
easyWebNotFound(),
|
|
24
|
+
],
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The integration requires no configuration. The `Options` type (with optional `defaultLocale` and `locales` fields) is retained for API compatibility but has no effect in v0.2.0+.
|
|
29
|
+
|
|
30
|
+
## How it works
|
|
31
|
+
|
|
32
|
+
### The sidecar file
|
|
33
|
+
|
|
34
|
+
SWA's `staticwebapp.config.json` schema uses `additionalProperties: false` at the root, which means the config file cannot store metadata about which keys are managed by which tool. To solve this, the integration maintains a sibling file:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
// staticwebapp.config.json.easy-web-managed.json
|
|
38
|
+
{
|
|
39
|
+
"keys": ["responseOverrides.404"],
|
|
40
|
+
"version": "0.2.0",
|
|
41
|
+
"docs": "https://github.com/achimismaili/websites/blob/main/docs/decisions/0013-shared-not-found-primitives.md"
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
On the next build, the integration reads this sidecar to determine which keys it previously claimed. If the sidecar says it owns `responseOverrides.404`, the integration updates it; otherwise, it leaves the user's 404 override untouched.
|
|
46
|
+
|
|
47
|
+
### Single global 404 limitation
|
|
48
|
+
|
|
49
|
+
Azure Static Web Apps supports only **one global 404 response override**. This integration emits a single, locale-agnostic 404 handler. If your site uses i18n:
|
|
50
|
+
|
|
51
|
+
- Unmatched routes in any locale will serve the **default-locale 404 body** (from `/404.html`)
|
|
52
|
+
- Per-locale 404 content is **not supported** by this integration
|
|
53
|
+
- If you need locale-specific 404 pages, you must implement them outside this integration (e.g., via Astro routing or a custom SWA configuration)
|
|
54
|
+
|
|
55
|
+
See [ADR 0013 — Shared Not-Found Primitives](https://github.com/achimismaili/websites/blob/main/docs/decisions/0013-shared-not-found-primitives.md) for the full rationale.
|
|
56
|
+
|
|
57
|
+
## Preservation guarantees
|
|
58
|
+
|
|
59
|
+
The integration **only manages** `responseOverrides.404`. All other settings are preserved exactly as you authored them:
|
|
60
|
+
|
|
61
|
+
- ✅ `auth` — untouched
|
|
62
|
+
- ✅ `globalHeaders` — untouched
|
|
63
|
+
- ✅ `navigationFallback` — untouched
|
|
64
|
+
- ✅ `routes` — untouched
|
|
65
|
+
- ✅ Other `responseOverrides` — untouched
|
|
66
|
+
- ✅ All other root keys — untouched
|
|
67
|
+
|
|
68
|
+
If you define your own `responseOverrides.404` before the integration runs, the integration will detect this and skip managing the 404 override, logging a warning instead.
|
|
69
|
+
|
|
70
|
+
## Compatibility
|
|
71
|
+
|
|
72
|
+
- **Astro:** `>=6.0.0 <8.0.0`
|
|
73
|
+
- **Node.js:** `>=18.0.0`
|
package/package.json
CHANGED
|
@@ -1,52 +1,51 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@easy-web/swa",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
},
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@easy-web/swa",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "AstroIntegration that merges a sentinel-marked staticwebapp.config.json slice for shared 404 handling on Azure Static Web Apps.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"astro-integration",
|
|
8
|
+
"azure-static-web-apps",
|
|
9
|
+
"swa",
|
|
10
|
+
"staticwebapp",
|
|
11
|
+
"404",
|
|
12
|
+
"not-found"
|
|
13
|
+
],
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"README.md"
|
|
25
|
+
],
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"astro": ">=6.0.0 <8.0.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"astro": "^6.4.0",
|
|
32
|
+
"@types/node": "^22.0.0",
|
|
33
|
+
"typescript": "^5.5.0",
|
|
34
|
+
"vitest": "^3.2.4"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public",
|
|
38
|
+
"provenance": true
|
|
39
|
+
},
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/achimismaili/easy-web.git",
|
|
43
|
+
"directory": "packages/easy-web-swa"
|
|
44
|
+
},
|
|
45
|
+
"license": "MIT",
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsc -p tsconfig.build.json",
|
|
48
|
+
"test": "vitest run",
|
|
49
|
+
"typecheck": "tsc --noEmit"
|
|
50
|
+
}
|
|
51
|
+
}
|