-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasks.py
More file actions
71 lines (57 loc) · 2.1 KB
/
tasks.py
File metadata and controls
71 lines (57 loc) · 2.1 KB
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
import os
import shlex
import shutil
import subprocess
TERMINATOR = "\x1b[0m"
WARNING = "\x1b[1;33m [WARNING]: "
INFO = "\x1b[1;33m [INFO]: "
HINT = "\x1b[3;33m"
SUCCESS = "\x1b[1;32m [SUCCESS]: "
def run_setup():
print("Performing initial commit.")
subprocess.run(shlex.split("git add ."))
subprocess.run(shlex.split("git commit -m 'Initial commit' --quiet"))
if not shutil.which("sam"):
print("Error: AWS SAM CLI is not installed. Please install it and try again.")
exit(1)
print("Running AWS SAM build and validate...")
subprocess.run(shlex.split("make validate"))
subprocess.run(shlex.split("make build"))
print("AWS Lambda template build and setup complete.")
def init_git_repo():
print(INFO + "Initializing git repository..." + TERMINATOR)
print(INFO + f"Current working directory: {os.getcwd()}" + TERMINATOR)
subprocess.run(shlex.split("git -c init.defaultBranch=main init . --quiet"))
print(SUCCESS + "Git repository initialized." + TERMINATOR)
def configure_git_remote():
repo_url = "{{ copier__repo_url }}"
if repo_url:
print(INFO + f"repo_url: {repo_url}" + TERMINATOR)
command = f"git remote add origin {repo_url}"
subprocess.run(shlex.split(command))
print(SUCCESS + f"Remote origin={repo_url} added." + TERMINATOR)
else:
print(
WARNING
+ "No repo_url provided. Skipping git remote configuration."
+ TERMINATOR
)
def log_next_steps():
print(
HINT
+ "Next steps:"
+ "\n1. Run 'cd {{ copier__project_name }}' to enter the project directory"
+ "\n2. Update the .envrc file with your AWS credentials"
+ "\n3. Run 'make setup' to run dynamodb locally and create the database"
+ "\n4. Then run 'make build' to build the lambda function"
+ "\n5. Then run 'make deploy' to deploy the lambda function"
+ "\nRefer to README.md for more details."
+ TERMINATOR
)
def main():
init_git_repo()
configure_git_remote()
run_setup()
log_next_steps()
if __name__ == "__main__":
main()