@friggframework/devtools 2.0.0--canary.414.b21e7dc.0 → 2.0.0--canary.414.db76eeb.0

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.
@@ -2,6 +2,34 @@ const { spawn, spawnSync } = require('child_process');
2
2
  const path = require('path');
3
3
  const fs = require('fs');
4
4
 
5
+ /**
6
+ * Constructs filtered environment variables for serverless deployment
7
+ * @param {string[]} envVars - Array of environment variable names from app definition
8
+ * @returns {Object} Filtered environment variables object
9
+ */
10
+ function buildFilteredEnvironment(envVars) {
11
+ return {
12
+ // Essential system variables needed to run serverless
13
+ PATH: process.env.PATH,
14
+ HOME: process.env.HOME,
15
+ USER: process.env.USER,
16
+
17
+ // AWS credentials and configuration (all AWS_ prefixed variables)
18
+ ...Object.fromEntries(
19
+ Object.entries(process.env).filter(([key]) =>
20
+ key.startsWith('AWS_')
21
+ )
22
+ ),
23
+
24
+ // App-defined environment variables
25
+ ...Object.fromEntries(
26
+ envVars
27
+ .map((key) => [key, process.env[key]])
28
+ .filter(([_, value]) => value !== undefined)
29
+ ),
30
+ };
31
+ }
32
+
5
33
  async function deployCommand(options) {
6
34
  console.log('Deploying the serverless application...');
7
35
 
@@ -39,7 +67,11 @@ async function deployCommand(options) {
39
67
  !options.skipEnvValidation
40
68
  ) {
41
69
  console.warn(
42
- `⚠️ Warning: Missing ${validation.missing.length} environment variables: ${validation.missing.join(', ')}`
70
+ `⚠️ Warning: Missing ${
71
+ validation.missing.length
72
+ } environment variables: ${validation.missing.join(
73
+ ', '
74
+ )}`
43
75
  );
44
76
  console.warn(
45
77
  ' These variables are optional and deployment will continue'
@@ -50,33 +82,16 @@ async function deployCommand(options) {
50
82
  }
51
83
 
52
84
  // Pass essential system variables + AWS credentials + app-defined environment variables
53
- integrationEnvironmentVariables = {
54
- // Essential system variables needed to run serverless
55
- PATH: process.env.PATH,
56
- HOME: process.env.HOME,
57
- USER: process.env.USER,
58
-
59
- // AWS credentials and configuration (all AWS_ prefixed variables)
60
- ...Object.fromEntries(
61
- Object.entries(process.env)
62
- .filter(([key]) => key.startsWith('AWS_'))
63
- ),
64
-
65
- // App-defined environment variables
66
- ...Object.fromEntries(
67
- envVars
68
- .map((key) => [key, process.env[key]])
69
- .filter(([_, value]) => value !== undefined)
70
- )
71
- };
85
+ integrationEnvironmentVariables =
86
+ buildFilteredEnvironment(envVars);
72
87
  } catch (validatorError) {
73
88
  // Validator not available in current version, just warn
74
89
  const missing = envVars.filter((v) => !process.env[v]);
75
90
  if (missing.length > 0) {
76
91
  console.warn(
77
- `⚠️ Warning: Missing ${missing.length} environment variables: ${missing.join(
78
- ', '
79
- )}`
92
+ `⚠️ Warning: Missing ${
93
+ missing.length
94
+ } environment variables: ${missing.join(', ')}`
80
95
  );
81
96
  console.warn(
82
97
  ' These variables are optional and deployment will continue'
@@ -87,25 +102,8 @@ async function deployCommand(options) {
87
102
  }
88
103
 
89
104
  // Pass essential system variables + AWS credentials + app-defined environment variables
90
- integrationEnvironmentVariables = {
91
- // Essential system variables needed to run serverless
92
- PATH: process.env.PATH,
93
- HOME: process.env.HOME,
94
- USER: process.env.USER,
95
-
96
- // AWS credentials and configuration (all AWS_ prefixed variables)
97
- ...Object.fromEntries(
98
- Object.entries(process.env)
99
- .filter(([key]) => key.startsWith('AWS_'))
100
- ),
101
-
102
- // App-defined environment variables
103
- ...Object.fromEntries(
104
- envVars
105
- .map((key) => [key, process.env[key]])
106
- .filter(([_, value]) => value !== undefined)
107
- )
108
- };
105
+ integrationEnvironmentVariables =
106
+ buildFilteredEnvironment(envVars);
109
107
  }
110
108
  }
111
109
  } catch (error) {
@@ -118,7 +116,7 @@ async function deployCommand(options) {
118
116
  }
119
117
 
120
118
  // AWS discovery is now handled directly in serverless-template.js
121
- console.log('🚀 Deploying serverless application...');
119
+ console.log('🤘🏼 Deploying serverless application...');
122
120
  const backendPath = path.resolve(process.cwd());
123
121
  const infrastructurePath = 'infrastructure.js';
124
122
  const command = 'serverless';
@@ -128,12 +126,13 @@ async function deployCommand(options) {
128
126
  infrastructurePath,
129
127
  '--stage',
130
128
  options.stage,
129
+ options.stage,
131
130
  ];
132
131
 
133
132
  const childProcess = spawn(command, serverlessArgs, {
134
133
  cwd: backendPath,
135
134
  stdio: 'inherit',
136
- env: integrationEnvironmentVariables, // Only pass validated environment variables
135
+ env: integrationEnvironmentVariables,
137
136
  });
138
137
 
139
138
  childProcess.on('error', (error) => {