-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathcrt_size_check.py
77 lines (57 loc) · 2.43 KB
/
crt_size_check.py
1
2
3
4
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"""
Test to insure package size does not exceed limits
"""
import Builder
import os
class CrtSizeCheck(Builder.Action):
def run(self, env):
# Maximum package size (for current platform) in bytes
# NOTE: if you increase this, you might also need to increase the
# limit in continuous-delivery/pack.sh
max_size = 9_000_000
# size of current folder
folder_size = 0
# total size in bytes
total_size = 0
for root, dirs, files in os.walk(os.path.join(env.project.path, 'dist/bin')):
for f in files:
if 'aws-crt-nodejs.node' == f:
fp = os.path.join(root, f)
print(
f"{fp} file size: {os.stat(fp).st_size}")
fp = os.path.join(root, f)
folder_size += os.path.getsize(fp)
print(f"dist/bin files size: {folder_size} bytes")
total_size += folder_size
folder_size = 0
for root, dirs, files in os.walk(os.path.join(env.project.path, 'dist/browser')):
for f in files:
fp = os.path.join(root, f)
folder_size += os.path.getsize(fp)
print(f"dist/browser files size: {folder_size} bytes")
total_size += folder_size
folder_size = 0
for root, dirs, files in os.walk(os.path.join(env.project.path, 'dist/common')):
for f in files:
fp = os.path.join(root, f)
folder_size += os.path.getsize(fp)
print(f"dist/common files size: {folder_size} bytes")
total_size += folder_size
folder_size = 0
for root, dirs, files in os.walk(os.path.join(env.project.path, 'dist/native')):
for f in files:
fp = os.path.join(root, f)
folder_size += os.path.getsize(fp)
print(f"dist/native files size: {folder_size} bytes")
total_size += folder_size
folder_size = 0
# source too
for root, dirs, files in os.walk(os.path.join(env.project.path, 'lib')):
for f in files:
fp = os.path.join(root, f)
folder_size += os.path.getsize(fp)
print(f"lib files size: {folder_size} bytes")
total_size += folder_size
print(f"Total NPM package file size: {total_size} bytes")
if total_size > max_size:
raise Exception(f'NPM package exceeds size limit of {max_size} bytes.')