@stacksjs/ts-cloud 0.1.1

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.
Files changed (117) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +321 -0
  3. package/bin/cli.ts +133 -0
  4. package/bin/commands/analytics.ts +328 -0
  5. package/bin/commands/api.ts +379 -0
  6. package/bin/commands/assets.ts +221 -0
  7. package/bin/commands/audit.ts +501 -0
  8. package/bin/commands/backup.ts +682 -0
  9. package/bin/commands/cache.ts +294 -0
  10. package/bin/commands/cdn.ts +281 -0
  11. package/bin/commands/config.ts +202 -0
  12. package/bin/commands/container.ts +105 -0
  13. package/bin/commands/cost.ts +208 -0
  14. package/bin/commands/database.ts +401 -0
  15. package/bin/commands/deploy.ts +674 -0
  16. package/bin/commands/domain.ts +397 -0
  17. package/bin/commands/email.ts +423 -0
  18. package/bin/commands/environment.ts +285 -0
  19. package/bin/commands/events.ts +424 -0
  20. package/bin/commands/firewall.ts +145 -0
  21. package/bin/commands/function.ts +116 -0
  22. package/bin/commands/generate.ts +280 -0
  23. package/bin/commands/git.ts +139 -0
  24. package/bin/commands/iam.ts +464 -0
  25. package/bin/commands/index.ts +48 -0
  26. package/bin/commands/init.ts +120 -0
  27. package/bin/commands/logs.ts +148 -0
  28. package/bin/commands/network.ts +579 -0
  29. package/bin/commands/notify.ts +489 -0
  30. package/bin/commands/queue.ts +407 -0
  31. package/bin/commands/scheduler.ts +370 -0
  32. package/bin/commands/secrets.ts +54 -0
  33. package/bin/commands/server.ts +629 -0
  34. package/bin/commands/shared.ts +97 -0
  35. package/bin/commands/ssl.ts +138 -0
  36. package/bin/commands/stack.ts +325 -0
  37. package/bin/commands/status.ts +385 -0
  38. package/bin/commands/storage.ts +450 -0
  39. package/bin/commands/team.ts +96 -0
  40. package/bin/commands/tunnel.ts +489 -0
  41. package/bin/commands/utils.ts +202 -0
  42. package/build.ts +15 -0
  43. package/cloud +2 -0
  44. package/package.json +99 -0
  45. package/src/aws/acm.ts +768 -0
  46. package/src/aws/application-autoscaling.ts +845 -0
  47. package/src/aws/bedrock.ts +4074 -0
  48. package/src/aws/client.ts +878 -0
  49. package/src/aws/cloudformation.ts +896 -0
  50. package/src/aws/cloudfront.ts +1531 -0
  51. package/src/aws/cloudwatch-logs.ts +154 -0
  52. package/src/aws/comprehend.ts +839 -0
  53. package/src/aws/connect.ts +1056 -0
  54. package/src/aws/deploy-imap.ts +384 -0
  55. package/src/aws/dynamodb.ts +340 -0
  56. package/src/aws/ec2.ts +1385 -0
  57. package/src/aws/ecr.ts +621 -0
  58. package/src/aws/ecs.ts +615 -0
  59. package/src/aws/elasticache.ts +301 -0
  60. package/src/aws/elbv2.ts +942 -0
  61. package/src/aws/email.ts +928 -0
  62. package/src/aws/eventbridge.ts +248 -0
  63. package/src/aws/iam.ts +1689 -0
  64. package/src/aws/imap-server.ts +2100 -0
  65. package/src/aws/index.ts +213 -0
  66. package/src/aws/kendra.ts +1097 -0
  67. package/src/aws/lambda.ts +786 -0
  68. package/src/aws/opensearch.ts +158 -0
  69. package/src/aws/personalize.ts +977 -0
  70. package/src/aws/polly.ts +559 -0
  71. package/src/aws/rds.ts +888 -0
  72. package/src/aws/rekognition.ts +846 -0
  73. package/src/aws/route53-domains.ts +359 -0
  74. package/src/aws/route53.ts +1046 -0
  75. package/src/aws/s3.ts +2318 -0
  76. package/src/aws/scheduler.ts +571 -0
  77. package/src/aws/secrets-manager.ts +769 -0
  78. package/src/aws/ses.ts +1081 -0
  79. package/src/aws/setup-phone.ts +104 -0
  80. package/src/aws/setup-sms.ts +580 -0
  81. package/src/aws/sms.ts +1735 -0
  82. package/src/aws/smtp-server.ts +531 -0
  83. package/src/aws/sns.ts +758 -0
  84. package/src/aws/sqs.ts +382 -0
  85. package/src/aws/ssm.ts +807 -0
  86. package/src/aws/sts.ts +92 -0
  87. package/src/aws/support.ts +391 -0
  88. package/src/aws/test-imap.ts +86 -0
  89. package/src/aws/textract.ts +780 -0
  90. package/src/aws/transcribe.ts +108 -0
  91. package/src/aws/translate.ts +641 -0
  92. package/src/aws/voice.ts +1379 -0
  93. package/src/config.ts +35 -0
  94. package/src/deploy/index.ts +7 -0
  95. package/src/deploy/static-site-external-dns.ts +906 -0
  96. package/src/deploy/static-site.ts +1125 -0
  97. package/src/dns/godaddy.ts +412 -0
  98. package/src/dns/index.ts +183 -0
  99. package/src/dns/porkbun.ts +362 -0
  100. package/src/dns/route53-adapter.ts +414 -0
  101. package/src/dns/types.ts +114 -0
  102. package/src/dns/validator.ts +369 -0
  103. package/src/generators/index.ts +5 -0
  104. package/src/generators/infrastructure.ts +1660 -0
  105. package/src/index.ts +163 -0
  106. package/src/push/apns.ts +452 -0
  107. package/src/push/fcm.ts +506 -0
  108. package/src/push/index.ts +58 -0
  109. package/src/ssl/acme-client.ts +478 -0
  110. package/src/ssl/index.ts +7 -0
  111. package/src/ssl/letsencrypt.ts +747 -0
  112. package/src/types.ts +2 -0
  113. package/src/utils/cli.ts +398 -0
  114. package/src/validation/index.ts +5 -0
  115. package/src/validation/template.ts +405 -0
  116. package/test/index.test.ts +128 -0
  117. package/tsconfig.json +18 -0
@@ -0,0 +1,148 @@
1
+ import type { CLI } from '@stacksjs/clapp'
2
+ import * as cli from '../../src/utils/cli'
3
+
4
+ export function registerLogsCommands(app: CLI): void {
5
+ app
6
+ .command('logs', 'Stream all application logs')
7
+ .option('--tail', 'Tail logs in real-time')
8
+ .option('--filter <pattern>', 'Filter logs by pattern')
9
+ .option('--since <duration>', 'Show logs since duration (e.g., 1h, 30m)')
10
+ .action(async (options?: { tail?: boolean, filter?: string, since?: string }) => {
11
+ cli.header('Application Logs')
12
+
13
+ if (options?.tail) {
14
+ cli.info('Tailing logs... (Ctrl+C to stop)')
15
+ }
16
+
17
+ // TODO: Implement log streaming
18
+ cli.info('2025-01-15 10:30:45 [INFO] Application started')
19
+ cli.info('2025-01-15 10:30:46 [INFO] Connected to database')
20
+ })
21
+
22
+ app
23
+ .command('logs:server <name>', 'View server-specific logs')
24
+ .option('--tail', 'Tail logs in real-time')
25
+ .option('--since <duration>', 'Show logs since duration (e.g., 1h, 30m)')
26
+ .action(async (name: string, options?: { tail?: boolean, since?: string }) => {
27
+ cli.header(`Server Logs: ${name}`)
28
+
29
+ const since = options?.since || '1h'
30
+
31
+ cli.info(`Fetching logs from the last ${since}...`)
32
+
33
+ if (options?.tail) {
34
+ cli.info('Tailing logs... (Ctrl+C to stop)\n')
35
+ }
36
+
37
+ // TODO: Fetch server logs from CloudWatch
38
+ cli.info('[2025-01-15 10:30:45] Server started')
39
+ cli.info('[2025-01-15 10:30:46] Listening on port 3000')
40
+ cli.info('[2025-01-15 10:30:47] Connected to database')
41
+ })
42
+
43
+ app
44
+ .command('logs:function <name>', 'View function-specific logs')
45
+ .option('--tail', 'Tail logs in real-time')
46
+ .option('--since <duration>', 'Show logs since duration (e.g., 1h, 30m)')
47
+ .action(async (name: string, options?: { tail?: boolean, since?: string }) => {
48
+ cli.header(`Function Logs: ${name}`)
49
+
50
+ const since = options?.since || '1h'
51
+
52
+ cli.info(`Fetching logs from the last ${since}...`)
53
+
54
+ if (options?.tail) {
55
+ cli.info('Tailing logs... (Ctrl+C to stop)\n')
56
+ }
57
+
58
+ // TODO: Fetch Lambda logs from CloudWatch
59
+ cli.info('[2025-01-15 10:30:45] START RequestId: abc123')
60
+ cli.info('[2025-01-15 10:30:46] Processing event...')
61
+ cli.info('[2025-01-15 10:30:47] END RequestId: abc123')
62
+ })
63
+
64
+ app
65
+ .command('metrics', 'View key metrics')
66
+ .action(async () => {
67
+ cli.header('Metrics Dashboard')
68
+
69
+ cli.info('CPU Usage: 45%')
70
+ cli.info('Memory Usage: 62%')
71
+ cli.info('Requests/min: 1,234')
72
+ cli.info('Error Rate: 0.02%')
73
+
74
+ // TODO: Fetch real metrics from CloudWatch
75
+ })
76
+
77
+ app
78
+ .command('metrics:dashboard', 'Open CloudWatch dashboard')
79
+ .option('--env <environment>', 'Environment (production, staging, development)')
80
+ .action(async (options?: { env?: string }) => {
81
+ cli.header('Opening CloudWatch Dashboard')
82
+
83
+ const environment = options?.env || 'production'
84
+
85
+ const spinner = new cli.Spinner('Generating dashboard URL...')
86
+ spinner.start()
87
+
88
+ // TODO: Generate CloudWatch dashboard URL
89
+ await new Promise(resolve => setTimeout(resolve, 1000))
90
+
91
+ spinner.succeed('Dashboard URL generated')
92
+
93
+ cli.success('\nOpening dashboard in browser...')
94
+ cli.info('\nDashboard URL:')
95
+ cli.info(' https://console.aws.amazon.com/cloudwatch/home?region=us-east-1#dashboards:name=my-app-production')
96
+ })
97
+
98
+ app
99
+ .command('alarms', 'List all alarms')
100
+ .action(async () => {
101
+ cli.header('CloudWatch Alarms')
102
+
103
+ const alarms = [
104
+ ['high-cpu', 'OK', 'CPU > 80%', 'production'],
105
+ ['high-memory', 'ALARM', 'Memory > 90%', 'production'],
106
+ ]
107
+
108
+ cli.table(
109
+ ['Name', 'Status', 'Condition', 'Environment'],
110
+ alarms,
111
+ )
112
+ })
113
+
114
+ app
115
+ .command('alarms:create', 'Create a new alarm')
116
+ .option('--name <name>', 'Alarm name')
117
+ .option('--metric <metric>', 'Metric to monitor (CPU, Memory, etc.)')
118
+ .option('--threshold <value>', 'Threshold value')
119
+ .option('--comparison <op>', 'Comparison operator (>, <, >=, <=)', { default: '>' })
120
+ .action(async (options?: { name?: string, metric?: string, threshold?: string, comparison?: string }) => {
121
+ cli.header('Creating CloudWatch Alarm')
122
+
123
+ if (!options?.name || !options?.metric || !options?.threshold) {
124
+ cli.error('Missing required options: --name, --metric, --threshold')
125
+ return
126
+ }
127
+
128
+ const name = options.name
129
+ const metric = options.metric
130
+ const threshold = options.threshold
131
+ const comparison = options.comparison || '>'
132
+
133
+ cli.info(`Alarm: ${name}`)
134
+ cli.info(`Metric: ${metric}`)
135
+ cli.info(`Condition: ${metric} ${comparison} ${threshold}`)
136
+
137
+ const spinner = new cli.Spinner('Creating alarm...')
138
+ spinner.start()
139
+
140
+ // TODO: Create CloudWatch alarm
141
+ await new Promise(resolve => setTimeout(resolve, 2000))
142
+
143
+ spinner.succeed('Alarm created successfully')
144
+
145
+ cli.success('\nAlarm is now active!')
146
+ cli.info('\nYou will be notified when the condition is met')
147
+ })
148
+ }