@capraconsulting/webapp-deploy-lambda 2.5.3 → 2.5.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 +6 -8
- package/dist/webapp_deploy/main.py +14 -13
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -55,18 +55,16 @@ aws lambda invoke \
|
|
|
55
55
|
Testing locally:
|
|
56
56
|
|
|
57
57
|
```bash
|
|
58
|
-
|
|
59
|
-
source .venv/bin/activate
|
|
60
|
-
pip install -r requirements.txt
|
|
58
|
+
$ uv sync
|
|
61
59
|
|
|
62
60
|
# Adjust to your project. See config.py for full list.
|
|
63
|
-
export TARGET_BUCKET_URL=s3://my-website/web
|
|
64
|
-
export EXPIRE_SECONDS=86400
|
|
65
|
-
export DEPLOY_LOG_BUCKET_URL=s3://my-website/deployments.log
|
|
66
|
-
export CF_DISTRIBUTION_ID=EKJ2IPY1KTEAR1
|
|
61
|
+
$ export TARGET_BUCKET_URL=s3://my-website/web
|
|
62
|
+
$ export EXPIRE_SECONDS=86400
|
|
63
|
+
$ export DEPLOY_LOG_BUCKET_URL=s3://my-website/deployments.log
|
|
64
|
+
$ export CF_DISTRIBUTION_ID=EKJ2IPY1KTEAR1
|
|
67
65
|
|
|
68
66
|
# Adjust artifact path.
|
|
69
|
-
python -m webapp_deploy.main s3://my-bucket/my-release.tgz
|
|
67
|
+
$ uv run python -m webapp_deploy.main s3://my-bucket/my-release.tgz
|
|
70
68
|
```
|
|
71
69
|
|
|
72
70
|
## Notes
|
|
@@ -49,7 +49,7 @@ def check_items(items, expiry):
|
|
|
49
49
|
files to be deleted.
|
|
50
50
|
"""
|
|
51
51
|
|
|
52
|
-
deployments = list(
|
|
52
|
+
deployments = list({i.time for i in items})
|
|
53
53
|
deployments_old = sorted([i for i in deployments if i < expiry])
|
|
54
54
|
|
|
55
55
|
if len(deployments_old) <= 1:
|
|
@@ -57,21 +57,24 @@ def check_items(items, expiry):
|
|
|
57
57
|
|
|
58
58
|
delete_older_than = deployments_old[-1]
|
|
59
59
|
|
|
60
|
-
keep_files = list(
|
|
60
|
+
keep_files = list({i.filename for i in items if i.time >= delete_older_than})
|
|
61
61
|
|
|
62
62
|
delete_files = list(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
]
|
|
69
|
-
)
|
|
63
|
+
{
|
|
64
|
+
i.filename
|
|
65
|
+
for i in items
|
|
66
|
+
if i.time < delete_older_than and i.filename not in keep_files
|
|
67
|
+
}
|
|
70
68
|
)
|
|
71
69
|
|
|
72
70
|
return [i for i in items if i.time >= delete_older_than], delete_files
|
|
73
71
|
|
|
74
72
|
|
|
73
|
+
def batch_items(items, batch_size):
|
|
74
|
+
for i in range(0, len(items), batch_size):
|
|
75
|
+
yield items[i : i + batch_size]
|
|
76
|
+
|
|
77
|
+
|
|
75
78
|
def cleanup_delete_files(s3_target, files):
|
|
76
79
|
s3_target_bucket, s3_target_key = parse_s3_url(s3_target)
|
|
77
80
|
|
|
@@ -81,9 +84,7 @@ def cleanup_delete_files(s3_target, files):
|
|
|
81
84
|
objects.append({"Key": os.path.join(s3_target_key, filename)})
|
|
82
85
|
|
|
83
86
|
# S3 delete_objects can only delete 1000 objects at a time
|
|
84
|
-
|
|
85
|
-
for i in range(0, len(objects), batch_size):
|
|
86
|
-
batch = objects[i : i + batch_size]
|
|
87
|
+
for batch in batch_items(objects, 1000):
|
|
87
88
|
result = s3_client.delete_objects(
|
|
88
89
|
Bucket=s3_target_bucket, Delete={"Objects": batch}
|
|
89
90
|
)
|
|
@@ -153,7 +154,7 @@ def extract(artifact_s3_url, source, dest, exclude_pattern):
|
|
|
153
154
|
|
|
154
155
|
def construct_all_files(temp_dir, s3_upload_key_base):
|
|
155
156
|
all_files = []
|
|
156
|
-
for root,
|
|
157
|
+
for root, _dirs, files in os.walk(temp_dir):
|
|
157
158
|
for filename in files:
|
|
158
159
|
local_path = os.path.join(root, filename)
|
|
159
160
|
relpath = os.path.relpath(local_path, temp_dir)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capraconsulting/webapp-deploy-lambda",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.4",
|
|
4
4
|
"description": "CDK construct for deploying a webapp release to S3 and CloudFront",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -11,8 +11,11 @@
|
|
|
11
11
|
"build": "./build.sh && tsc",
|
|
12
12
|
"watch": "tsc -w",
|
|
13
13
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
14
|
+
"test:update": "NODE_OPTIONS=--experimental-vm-modules jest --updateSnapshot",
|
|
14
15
|
"lint": "biome check",
|
|
15
16
|
"lint:fix": "biome check --fix",
|
|
17
|
+
"fmt": "biome format --write",
|
|
18
|
+
"fmt:check": "biome format",
|
|
16
19
|
"prepare": "npm run build && husky",
|
|
17
20
|
"semantic-release": "semantic-release",
|
|
18
21
|
"upgrade-dependencies": "ncu --upgrade --install always --format group",
|
|
@@ -39,11 +42,11 @@
|
|
|
39
42
|
"devDependencies": {
|
|
40
43
|
"@aws-cdk/assert": "2.68.0",
|
|
41
44
|
"@biomejs/biome": "2.3.8",
|
|
42
|
-
"@commitlint/cli": "20.
|
|
43
|
-
"@commitlint/config-conventional": "20.
|
|
45
|
+
"@commitlint/cli": "20.2.0",
|
|
46
|
+
"@commitlint/config-conventional": "20.2.0",
|
|
44
47
|
"@types/jest": "30.0.0",
|
|
45
48
|
"@types/node": "24.10.1",
|
|
46
|
-
"aws-cdk-lib": "2.
|
|
49
|
+
"aws-cdk-lib": "2.232.1",
|
|
47
50
|
"constructs": "10.4.3",
|
|
48
51
|
"husky": "9.1.7",
|
|
49
52
|
"jest": "30.2.0",
|