edutin-toolkit 1.5.0__py3-none-any.whl

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.
@@ -0,0 +1,3 @@
1
+ """AWS Toolkit — utilidades CLI para Lambda."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,5 @@
1
+ """Enables: python -m aws_toolkit [command] [args]"""
2
+
3
+ from aws_toolkit.cli import main
4
+
5
+ main()
@@ -0,0 +1,7 @@
1
+ import json
2
+
3
+ def lambda_handler(event, context):
4
+ return {
5
+ 'statusCode': 200,
6
+ 'body': json.dumps('Hello from Lambda!')
7
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "runtime": "python3.12",
3
+ "architectures": ["arm64"],
4
+ "timeout": 5,
5
+ "memory_size": 128,
6
+ "ephemeral_storage_size": 512,
7
+ "handler": "main.main",
8
+ "role": "lambda_dynamodb_exec",
9
+ "aliases": ["current", "develop", "legacy"]
10
+ }
aws_toolkit/cli.py ADDED
@@ -0,0 +1,173 @@
1
+ #!/usr/bin/env python3
2
+ """AWS Toolkit – unified CLI dispatcher."""
3
+
4
+ import sys
5
+ import importlib
6
+
7
+ COMMANDS = {
8
+ "init": {
9
+ "desc": "Initialize the current directory as an aws-toolkit project",
10
+ "usage": "etk init [--template <n>] [--lambdas <p>] [--layers <p>] [--dynamo <p>] [--author <n>] [--profile <p>] [--sandbox <l>] [--force] [-ai]",
11
+ "module": "aws_toolkit.commands.init",
12
+ },
13
+ "lambda_explorer": {
14
+ "desc": "Interactive TUI to browse, search and download Lambda functions",
15
+ "usage": "etk lambda_explorer [-ai [query]]",
16
+ "module": "aws_toolkit.commands.lambda_explorer",
17
+ },
18
+ "lambda_download": {
19
+ "desc": "Download a Lambda function by name",
20
+ "usage": "etk lambda_download <function_name> [-ai]",
21
+ "module": "aws_toolkit.commands.lambda_download",
22
+ },
23
+ "lambda_download_all": {
24
+ "desc": "Bulk download every accessible Lambda (idempotent, parallel)",
25
+ "usage": "etk lambda_download_all [--filter <pat>] [--force] [--dry-run] [--workers N] [-ai]",
26
+ "module": "aws_toolkit.commands.lambda_download_all",
27
+ },
28
+ "dynamodb_doc": {
29
+ "desc": "Document DynamoDB table schemas to JSON files",
30
+ "usage": "etk dynamodb_doc [-ai] | etk dynamodb_doc <table_name> [-ai]",
31
+ "module": "aws_toolkit.commands.dynamodb_doc",
32
+ },
33
+ "lambda_create": {
34
+ "desc": "Create a Lambda function from a template",
35
+ "usage": "etk lambda_create <function_name> [--template <name>] [-ai]",
36
+ "module": "aws_toolkit.commands.lambda_create",
37
+ },
38
+ "lambda_deploy": {
39
+ "desc": "Deploy local code and lambda_config.json to AWS",
40
+ "usage": "etk lambda_deploy <function_name> [-ai]",
41
+ "module": "aws_toolkit.commands.lambda_deploy",
42
+ },
43
+ "lambda_test": {
44
+ "desc": "Deploy source lambda to test lambda and invoke it with an event",
45
+ "usage": "etk lambda_test <function_name> <event_name> [-ai]",
46
+ "module": "aws_toolkit.commands.lambda_test",
47
+ },
48
+ "lambda_download_tests": {
49
+ "desc": "Download shareable test events from AWS into event_tests/",
50
+ "usage": "etk lambda_download_tests <function_name> [-ai]",
51
+ "module": "aws_toolkit.commands.lambda_download_tests",
52
+ },
53
+ "lambda_publish_version": {
54
+ "desc": "Publish a new version of a Lambda from $LATEST (optionally aliasing it as `current`)",
55
+ "usage": "etk lambda_publish_version <name> <description> [--prod] [-ai]",
56
+ "module": "aws_toolkit.commands.lambda_publish_version",
57
+ },
58
+ "lambda_layer_doc": {
59
+ "desc": "Download and document Lambda layer versions (top 3 most recent)",
60
+ "usage": "etk lambda_layer_doc [layer_name] [-ai]",
61
+ "module": "aws_toolkit.commands.lambda_layer_doc",
62
+ },
63
+ "config": {
64
+ "desc": "Create / modify toolkit configuration",
65
+ "usage": "etk config [-ai] | etk config set <key> <value> [-ai]",
66
+ "module": "aws_toolkit.commands.config",
67
+ },
68
+ "install_vscode_extension": {
69
+ "desc": "Install the bundled VSCode extension (▶/☁⬆ buttons on lambda files)",
70
+ "usage": "etk install_vscode_extension [-ai]",
71
+ "module": "aws_toolkit.commands.install_vscode_extension",
72
+ },
73
+ }
74
+
75
+ def _make_commands_table(title: str, commands: dict, T, box):
76
+ from rich.table import Table
77
+ tbl = Table(
78
+ show_header=True,
79
+ header_style=T.HEADER_ST,
80
+ border_style=T.BORDER,
81
+ box=box.DOUBLE_EDGE,
82
+ title=title,
83
+ title_style=T.TITLE,
84
+ padding=(0, 2),
85
+ )
86
+ tbl.add_column("COMMAND", style=f"bold {T.NEON_GREEN}", min_width=20)
87
+ tbl.add_column("DESCRIPTION", style=T.NORMAL, min_width=30)
88
+ tbl.add_column("USAGE", style=T.DIM_STYLE, min_width=45)
89
+ for name, info in commands.items():
90
+ tbl.add_row(name, info["desc"], info["usage"])
91
+ return tbl
92
+
93
+
94
+ def show_help():
95
+ from aws_toolkit.commands._shared import console, Theme as T
96
+ from rich.align import Align
97
+ from rich import box
98
+
99
+ console.print()
100
+ console.print(f"[bold {T.CYAN}]AWS TOOLKIT[/bold {T.CYAN}]")
101
+ console.print(f" [{T.DIM_STYLE}]Usage: etk <command> [args][/{T.DIM_STYLE}]")
102
+ console.print()
103
+
104
+ console.print(Align.center(_make_commands_table(
105
+ f"[{T.CYAN}]《 COMMANDS 》[/{T.CYAN}]", COMMANDS, T, box
106
+ )))
107
+
108
+ console.print()
109
+
110
+
111
+ def _check_config(ai_mode: bool) -> None:
112
+ """Force config resolution to surface a clear error before the command runs.
113
+
114
+ ConfigError subclasses (RepoRootNotFound, ProjectConfigMissingField,
115
+ UserConfigMissingField, etc.) are caught by the dispatcher's
116
+ try/except and produce a consistent error code in -ai mode.
117
+ """
118
+ from aws_toolkit.config_resolver import resolve_config
119
+ resolve_config()
120
+
121
+
122
+ def main():
123
+ args = sys.argv[1:]
124
+
125
+ if not args or args[0] in ("--help", "-h", "help"):
126
+ show_help()
127
+ return
128
+
129
+ cmd = args[0]
130
+ rest = args[1:]
131
+ ai_mode = "-ai" in rest
132
+
133
+ if cmd not in COMMANDS:
134
+ from aws_toolkit.commands._shared import die
135
+ die(
136
+ f"Unknown command: [bold]{cmd}[/bold]\n\n"
137
+ f" Run [bold]etk --help[/bold] to see available commands."
138
+ )
139
+
140
+ from aws_toolkit.commands._shared import log_command
141
+ from aws_toolkit.config_resolver import ConfigError
142
+
143
+ entry = COMMANDS[cmd]
144
+
145
+ try:
146
+ mod = importlib.import_module(entry["module"])
147
+
148
+ if cmd not in ("config", "init", "install_vscode_extension"):
149
+ _check_config(ai_mode=ai_mode)
150
+ detail = mod.main(rest) or ""
151
+ log_command(cmd, rest, "SUCCESS", detail)
152
+ except ConfigError as exc:
153
+ log_command(cmd, rest, "ERROR", f"config_error={exc.code}")
154
+ if ai_mode:
155
+ print(f"error\t{exc.code}\t{exc}", file=sys.stderr)
156
+ sys.exit(1)
157
+ else:
158
+ from aws_toolkit.commands._shared import die as _die
159
+ _die(str(exc)) # exits with code 1
160
+ except SystemExit as exc:
161
+ code = exc.code if exc.code is not None else 0
162
+ if code == 0:
163
+ log_command(cmd, rest, "SUCCESS")
164
+ else:
165
+ log_command(cmd, rest, "ERROR", f"exit_code={code}")
166
+ raise
167
+ except Exception as exc:
168
+ log_command(cmd, rest, "ERROR", f"exception={type(exc).__name__}: {exc}")
169
+ raise
170
+
171
+
172
+ if __name__ == "__main__":
173
+ main()
@@ -0,0 +1 @@
1
+ """Subcomandos de la CLI (p. ej. lambda_explorer)."""