deploy-stack 0.2.6 → 0.2.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deploy-stack",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Provision production-ready AWS infrastructure and CI/CD pipelines in seconds.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -6,7 +6,7 @@ import color from 'picocolors';
6
6
 
7
7
  import { checkDependency } from '../utils/system.js';
8
8
  import { detectFramework } from '../utils/detector.js';
9
- import { trackEvent } from '../core/telemetry.js';
9
+ import { trackEvent, flushTelemetry } from '../core/telemetry.js';
10
10
  import { getFrameworkWarning } from '../utils/warnings.js';
11
11
  import { provisionStateBucket } from '../utils/aws.js';
12
12
  import { generateTemplates } from '../utils/generator.js';
@@ -193,6 +193,7 @@ export async function mainStack() {
193
193
  s.stop('❌ Failed to provision remote state or authenticate with AWS.');
194
194
  console.error(color.red(`AWS Error: ${error.message}`));
195
195
  trackEvent('cli-error', { step: 'aws_provisioning', error_code: error.name || 'UNKNOWN' });
196
+ await flushTelemetry();
196
197
  process.exit(1);
197
198
  }
198
199
 
@@ -251,4 +252,7 @@ export async function mainStack() {
251
252
  ${color.magenta('🚀 Infrastructure ready! Need help or have feedback? Grab 15 mins with Anton:')}
252
253
  ${color.underline('https://calendly.com/anton-codes-iac/15min')}
253
254
  `);
255
+
256
+ // 10.Ensure all analytics are sent before the CLI terminates
257
+ await flushTelemetry();
254
258
  }
@@ -1,9 +1,11 @@
1
1
  import crypto from 'crypto';
2
2
 
3
- const TELEMETRY_ENDPOINT = 'https://app.posthog.com/capture';
3
+ const TELEMETRY_ENDPOINT = 'https://eu.i.posthog.com/capture/';
4
4
 
5
5
  const POSTHOG_API_KEY = 'phc_o2wgA3jVT9rVDiGSDzFAR42zZeiVGhhCY53HXVHUcYGT';
6
6
 
7
+ const pendingRequests = [];
8
+
7
9
  export function trackEvent(eventName, properties) {
8
10
  // 1. Respect privacy standards
9
11
  if (process.env.DO_NOT_TRACK === '1' || process.env.DO_NOT_TRACK === 'true') {
@@ -20,8 +22,8 @@ export function trackEvent(eventName, properties) {
20
22
  const payload = {
21
23
  api_key: POSTHOG_API_KEY,
22
24
  event: eventName,
25
+ distinct_id: anonymousProjectId,
23
26
  properties: {
24
- distinct_id: anonymousProjectId, // Used to count unique projects, not identify them
25
27
  os: process.platform,
26
28
  node_version: process.version,
27
29
  ...properties
@@ -29,11 +31,19 @@ export function trackEvent(eventName, properties) {
29
31
  };
30
32
 
31
33
  // 4. Fire and forget (No 'await' so we don't block the user's terminal)
32
- fetch(TELEMETRY_ENDPOINT, {
34
+ const request = fetch(TELEMETRY_ENDPOINT, {
33
35
  method: 'POST',
34
36
  headers: { 'Content-Type': 'application/json' },
35
37
  body: JSON.stringify(payload),
36
- }).catch(() => {
38
+ }).catch((err) => {
37
39
  // Silently swallow network errors (e.g., user is offline)
38
40
  });
41
+
42
+ pendingRequests.push(request);
43
+ }
44
+
45
+ export async function flushTelemetry() {
46
+ if (pendingRequests.length > 0) {
47
+ await Promise.all(pendingRequests);
48
+ }
39
49
  }
@@ -14,7 +14,11 @@ export function getFrameworkWarning(frameworkId) {
14
14
  color.yellow('\n 1. Ensure your package.json has a "start" script (e.g., "start": "node index.js").') +
15
15
  color.yellow('\n 2. Your app must listen on 0.0.0.0 (not localhost) to receive traffic in Docker.\n\n')
16
16
  );
17
- // Python / FastAPI warnings can be added here easily!
17
+ case 'python':
18
+ return color.yellow(' ⚠️ IMPORTANT: PYTHON SETUP REQUIRED ') +
19
+ color.yellow('\n 1. Ensure your requirements.txt includes your web framework (e.g., fastapi, uvicorn).') +
20
+ color.yellow('\n 2. Your app must listen on 0.0.0.0 (not localhost) to receive traffic in Docker.') +
21
+ color.yellow('\n 3. Ensure your app has a health check route returning 200 OK.\n\n');
18
22
  default:
19
23
  return '';
20
24
  }
@@ -1,7 +1,26 @@
1
1
  FROM python:3.11-slim
2
+
3
+ # Prevent Python from writing .pyc files and buffer stdout for cleaner logs
4
+ ENV PYTHONDONTWRITEBYTECODE=1
5
+ ENV PYTHONUNBUFFERED=1
6
+
2
7
  WORKDIR /app
8
+
9
+ # Create a non-root user for security compliance
10
+ RUN adduser --disabled-password --gecos '' appuser
11
+
12
+ # Install dependencies without caching to keep the image size small
3
13
  COPY requirements.txt .
4
- RUN pip install -r requirements.txt
14
+ RUN pip install --no-cache-dir -r requirements.txt
15
+
5
16
  COPY . .
17
+
18
+ # Secure file permissions
19
+ RUN chown -R appuser:appuser /app
20
+
21
+ # Drop root privileges
22
+ USER appuser
23
+
6
24
  EXPOSE {{PORT}}
25
+
7
26
  CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "{{PORT}}"]
@@ -55,4 +55,8 @@ resource "aws_cloudfront_distribution" "cdn" {
55
55
  output "cloudfront_url" {
56
56
  description = "Your globally cached, HTTPS-secured application URL"
57
57
  value = "https://${aws_cloudfront_distribution.cdn.domain_name}"
58
+ }
59
+
60
+ output "z_NEXT_STEP_REQUIRED" {
61
+ value = "⚠️ Your infrastructure is up, but these URLs will return 503 errors until you push your code to GitHub and the Actions pipeline deploys your container."
58
62
  }