ai-localize-aws-cloudfront 2.0.4 → 2.0.6
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 +7 -0
- package/README.md +84 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# ai-localize-aws-cloudfront
|
|
2
|
+
|
|
3
|
+
> AWS S3 asset upload + CloudFront cache invalidation for the [ai-localize-core](https://github.com/ai-localize/ai-localize-core) platform.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/ai-localize-aws-cloudfront)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## What it does
|
|
11
|
+
|
|
12
|
+
- **`S3Uploader`** — uploads static assets to an S3 bucket with content-hash deduplication
|
|
13
|
+
- **`CloudFrontInvalidator`** — invalidates CloudFront distribution paths after upload
|
|
14
|
+
- **`CdnMigrator`** — orchestrates the full CDN migration: upload → replace legacy URLs → invalidate
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install ai-localize-aws-cloudfront
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Configuration
|
|
23
|
+
|
|
24
|
+
Add the `aws` block to `ai-localize.config.json`:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"aws": {
|
|
29
|
+
"region": "us-east-1",
|
|
30
|
+
"bucket": "my-assets-bucket",
|
|
31
|
+
"distributionId": "E1ABCDEFGHIJKL",
|
|
32
|
+
"cdnBaseUrl": "https://d123.cloudfront.net",
|
|
33
|
+
"legacyCdnPattern": "https://old-cdn.company.com",
|
|
34
|
+
"assetsPrefix": "static-assets/v1",
|
|
35
|
+
"profile": "my-aws-profile"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Or via environment variables:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
AWS_S3_BUCKET=my-assets-bucket
|
|
44
|
+
AWS_CF_DISTRIBUTION_ID=E1ABCDEFGHIJKL
|
|
45
|
+
AI_LOCALIZE_CDN_BASE_URL=https://d123.cloudfront.net
|
|
46
|
+
AI_LOCALIZE_LEGACY_CDN_PATTERN=https://old-cdn.company.com
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import { S3Uploader, CloudFrontInvalidator, CdnMigrator } from 'ai-localize-aws-cloudfront';
|
|
53
|
+
|
|
54
|
+
// Upload assets
|
|
55
|
+
const uploader = new S3Uploader(config.aws);
|
|
56
|
+
const uploadedAssets = await uploader.upload('./public');
|
|
57
|
+
|
|
58
|
+
// Invalidate CloudFront
|
|
59
|
+
const invalidator = new CloudFrontInvalidator(config.aws);
|
|
60
|
+
await invalidator.invalidate(uploadedAssets.map(a => '/' + a.s3Key));
|
|
61
|
+
|
|
62
|
+
// Or use the all-in-one migrator
|
|
63
|
+
const migrator = new CdnMigrator(config);
|
|
64
|
+
const result = await migrator.migrate({ assetsDir: './public', invalidate: true });
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## CLI equivalent
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# One-step migration
|
|
71
|
+
npx ai-localize migrate-cdn --assets-dir ./public --invalidate
|
|
72
|
+
|
|
73
|
+
# Separate steps
|
|
74
|
+
npx ai-localize upload-assets --assets-dir ./public --output manifest.json
|
|
75
|
+
npx ai-localize replace-cdn --manifest manifest.json
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Part of ai-localize-core
|
|
81
|
+
|
|
82
|
+
Install the CLI for the complete toolset: `npm install -g ai-localize-cli`
|
|
83
|
+
|
|
84
|
+
MIT © ai-localize-core contributors
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai-localize-aws-cloudfront",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "S3 upload, CloudFront invalidation and CDN URL migration for ai-localize-core",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"@aws-sdk/client-cloudfront": "^3.511.0",
|
|
38
38
|
"@aws-sdk/lib-storage": "^3.511.0",
|
|
39
39
|
"mime-types": "^2.1.35",
|
|
40
|
-
"ai-localize-shared": "2.0.
|
|
41
|
-
"ai-localize-codemods": "2.0.
|
|
40
|
+
"ai-localize-shared": "2.0.6",
|
|
41
|
+
"ai-localize-codemods": "2.0.6"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/mime-types": "^2.1.4",
|