@friggframework/devtools 2.0.0--canary.461.aa02ace.0 → 2.0.0--canary.461.e09bb34.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.
@@ -170,6 +170,10 @@ class MigrationBuilder extends InfrastructureBuilder {
170
170
 
171
171
  // Add queue URL to environment
172
172
  result.environment.DB_MIGRATION_QUEUE_URL = { Ref: 'DbMigrationQueue' };
173
+
174
+ // Set DB_TYPE so migration handlers don't need to load app definition
175
+ // Migrations are PostgreSQL-only (line 33), so this is always 'postgresql'
176
+ result.environment.DB_TYPE = 'postgresql';
173
177
 
174
178
  console.log(' ✓ Added DB_MIGRATION_QUEUE_URL environment variable');
175
179
 
@@ -1,5 +1,4 @@
1
1
  const fs = require('fs');
2
- const path = require('path');
3
2
  let AWSDiscovery;
4
3
 
5
4
  function loadAWSDiscovery() {
@@ -33,23 +32,28 @@ class BuildTimeDiscovery {
33
32
  async discoverAndCreateConfig(outputPath = './aws-discovery-config.json') {
34
33
  try {
35
34
  console.log('Starting AWS resource discovery for build...');
36
-
35
+
37
36
  const resources = await this.discovery.discoverResources();
38
-
37
+
39
38
  // Create configuration object
40
39
  const config = {
41
40
  awsDiscovery: resources,
42
41
  generatedAt: new Date().toISOString(),
43
- region: this.region
42
+ region: this.region,
44
43
  };
45
-
44
+
46
45
  // Write configuration to file
47
46
  fs.writeFileSync(outputPath, JSON.stringify(config, null, 2));
48
- console.log(`AWS discovery configuration written to: ${outputPath}`);
49
-
47
+ console.log(
48
+ `AWS discovery configuration written to: ${outputPath}`,
49
+ );
50
+
50
51
  return config;
51
52
  } catch (error) {
52
- console.error('Error during AWS resource discovery:', error.message);
53
+ console.error(
54
+ 'Error during AWS resource discovery:',
55
+ error.message,
56
+ );
53
57
  throw error;
54
58
  }
55
59
  }
@@ -62,22 +66,34 @@ class BuildTimeDiscovery {
62
66
  */
63
67
  replaceTemplateVariables(templateContent, discoveredResources) {
64
68
  let updatedContent = templateContent;
65
-
69
+
66
70
  // Replace AWS discovery placeholders
67
71
  const replacements = {
68
- '${self:custom.awsDiscovery.defaultVpcId}': discoveredResources.defaultVpcId,
69
- '${self:custom.awsDiscovery.defaultSecurityGroupId}': discoveredResources.defaultSecurityGroupId,
70
- '${self:custom.awsDiscovery.privateSubnetId1}': discoveredResources.privateSubnetId1,
71
- '${self:custom.awsDiscovery.privateSubnetId2}': discoveredResources.privateSubnetId2,
72
- '${self:custom.awsDiscovery.privateRouteTableId}': discoveredResources.privateRouteTableId,
73
- '${self:custom.awsDiscovery.defaultKmsKeyId}': discoveredResources.defaultKmsKeyId
72
+ '${self:custom.awsDiscovery.defaultVpcId}':
73
+ discoveredResources.defaultVpcId,
74
+ '${self:custom.awsDiscovery.defaultSecurityGroupId}':
75
+ discoveredResources.defaultSecurityGroupId,
76
+ '${self:custom.awsDiscovery.privateSubnetId1}':
77
+ discoveredResources.privateSubnetId1,
78
+ '${self:custom.awsDiscovery.privateSubnetId2}':
79
+ discoveredResources.privateSubnetId2,
80
+ '${self:custom.awsDiscovery.privateRouteTableId}':
81
+ discoveredResources.privateRouteTableId,
82
+ '${self:custom.awsDiscovery.defaultKmsKeyId}':
83
+ discoveredResources.defaultKmsKeyId,
74
84
  };
75
-
85
+
76
86
  for (const [placeholder, value] of Object.entries(replacements)) {
77
87
  // Use a more targeted replacement to avoid replacing similar strings
78
- updatedContent = updatedContent.replace(new RegExp(placeholder.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'), value);
88
+ updatedContent = updatedContent.replace(
89
+ new RegExp(
90
+ placeholder.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'),
91
+ 'g',
92
+ ),
93
+ value,
94
+ );
79
95
  }
80
-
96
+
81
97
  return updatedContent;
82
98
  }
83
99
 
@@ -91,25 +107,33 @@ class BuildTimeDiscovery {
91
107
  async processServerlessConfig(configPath, outputPath = null) {
92
108
  try {
93
109
  console.log(`Processing serverless configuration: ${configPath}`);
94
-
110
+
95
111
  // Read the current serverless configuration
96
112
  const configContent = fs.readFileSync(configPath, 'utf8');
97
-
113
+
98
114
  // Discover AWS resources
99
115
  const resources = await this.discovery.discoverResources();
100
-
116
+
101
117
  // Replace placeholders with discovered values
102
- const updatedContent = this.replaceTemplateVariables(configContent, resources);
103
-
118
+ const updatedContent = this.replaceTemplateVariables(
119
+ configContent,
120
+ resources,
121
+ );
122
+
104
123
  // Write to output file or overwrite original
105
124
  const finalPath = outputPath || configPath;
106
125
  fs.writeFileSync(finalPath, updatedContent);
107
-
108
- console.log(`Updated serverless configuration written to: ${finalPath}`);
109
-
126
+
127
+ console.log(
128
+ `Updated serverless configuration written to: ${finalPath}`,
129
+ );
130
+
110
131
  return resources;
111
132
  } catch (error) {
112
- console.error('Error processing serverless configuration:', error.message);
133
+ console.error(
134
+ 'Error processing serverless configuration:',
135
+ error.message,
136
+ );
113
137
  throw error;
114
138
  }
115
139
  }
@@ -121,7 +145,7 @@ class BuildTimeDiscovery {
121
145
  */
122
146
  generateCustomSection(discoveredResources) {
123
147
  return {
124
- awsDiscovery: discoveredResources
148
+ awsDiscovery: discoveredResources,
125
149
  };
126
150
  }
127
151
 
@@ -135,40 +159,48 @@ class BuildTimeDiscovery {
135
159
  async preBuildHook(appDefinition, region) {
136
160
  try {
137
161
  console.log('Running pre-build AWS discovery hook...');
138
-
162
+
139
163
  // Only run discovery if VPC, KMS, or SSM features are enabled
140
- const needsDiscovery = appDefinition.vpc?.enable ||
141
- appDefinition.encryption?.fieldLevelEncryptionMethod === 'kms' ||
142
- appDefinition.ssm?.enable;
143
-
164
+ const needsDiscovery =
165
+ appDefinition.vpc?.enable ||
166
+ appDefinition.encryption?.fieldLevelEncryptionMethod ===
167
+ 'kms' ||
168
+ appDefinition.ssm?.enable;
169
+
144
170
  if (!needsDiscovery) {
145
171
  console.log('No AWS discovery needed based on app definition');
146
172
  return null;
147
173
  }
148
-
174
+
149
175
  // Create discovery instance with specified region
150
176
  loadAWSDiscovery();
151
177
  const discovery = new AWSDiscovery(region);
152
178
  const resources = await discovery.discoverResources();
153
-
179
+
154
180
  // Create environment variables for serverless
155
181
  const envVars = {
156
182
  AWS_DISCOVERY_VPC_ID: resources.defaultVpcId,
157
- AWS_DISCOVERY_SECURITY_GROUP_ID: resources.defaultSecurityGroupId,
183
+ AWS_DISCOVERY_SECURITY_GROUP_ID:
184
+ resources.defaultSecurityGroupId,
158
185
  AWS_DISCOVERY_SUBNET_ID_1: resources.privateSubnetId1,
159
186
  AWS_DISCOVERY_SUBNET_ID_2: resources.privateSubnetId2,
160
187
  AWS_DISCOVERY_PUBLIC_SUBNET_ID: resources.publicSubnetId,
161
188
  AWS_DISCOVERY_ROUTE_TABLE_ID: resources.privateRouteTableId,
162
- AWS_DISCOVERY_KMS_KEY_ID: resources.defaultKmsKeyId // Keep consistent naming convention (even though it's an ARN)
189
+ AWS_DISCOVERY_KMS_KEY_ID: resources.defaultKmsKeyId, // Keep consistent naming convention (even though it's an ARN)
163
190
  };
164
-
191
+
165
192
  // Set environment variables for serverless to use
166
193
  Object.assign(process.env, envVars);
167
-
168
- console.log('AWS discovery completed and environment variables set');
194
+
195
+ console.log(
196
+ 'AWS discovery completed and environment variables set',
197
+ );
169
198
  return resources;
170
199
  } catch (error) {
171
- console.error('Error in pre-build AWS discovery hook:', error.message);
200
+ console.error(
201
+ 'Error in pre-build AWS discovery hook:',
202
+ error.message,
203
+ );
172
204
  throw error;
173
205
  }
174
206
  }
@@ -186,11 +218,11 @@ async function runBuildTimeDiscovery(options = {}) {
186
218
  const {
187
219
  region = process.env.AWS_REGION || 'us-east-1',
188
220
  outputPath = './aws-discovery-config.json',
189
- configPath = null
221
+ configPath = null,
190
222
  } = options;
191
-
223
+
192
224
  const discovery = new BuildTimeDiscovery(region);
193
-
225
+
194
226
  if (configPath) {
195
227
  // Process existing serverless configuration
196
228
  return await discovery.processServerlessConfig(configPath);
@@ -200,7 +232,7 @@ async function runBuildTimeDiscovery(options = {}) {
200
232
  }
201
233
  }
202
234
 
203
- module.exports = {
204
- BuildTimeDiscovery,
205
- runBuildTimeDiscovery
206
- };
235
+ module.exports = {
236
+ BuildTimeDiscovery,
237
+ runBuildTimeDiscovery,
238
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@friggframework/devtools",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "2.0.0--canary.461.aa02ace.0",
4
+ "version": "2.0.0--canary.461.e09bb34.0",
5
5
  "dependencies": {
6
6
  "@aws-sdk/client-ec2": "^3.835.0",
7
7
  "@aws-sdk/client-kms": "^3.835.0",
@@ -11,8 +11,8 @@
11
11
  "@babel/eslint-parser": "^7.18.9",
12
12
  "@babel/parser": "^7.25.3",
13
13
  "@babel/traverse": "^7.25.3",
14
- "@friggframework/schemas": "2.0.0--canary.461.aa02ace.0",
15
- "@friggframework/test": "2.0.0--canary.461.aa02ace.0",
14
+ "@friggframework/schemas": "2.0.0--canary.461.e09bb34.0",
15
+ "@friggframework/test": "2.0.0--canary.461.e09bb34.0",
16
16
  "@hapi/boom": "^10.0.1",
17
17
  "@inquirer/prompts": "^5.3.8",
18
18
  "axios": "^1.7.2",
@@ -34,8 +34,8 @@
34
34
  "serverless-http": "^2.7.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@friggframework/eslint-config": "2.0.0--canary.461.aa02ace.0",
38
- "@friggframework/prettier-config": "2.0.0--canary.461.aa02ace.0",
37
+ "@friggframework/eslint-config": "2.0.0--canary.461.e09bb34.0",
38
+ "@friggframework/prettier-config": "2.0.0--canary.461.e09bb34.0",
39
39
  "aws-sdk-client-mock": "^4.1.0",
40
40
  "aws-sdk-client-mock-jest": "^4.1.0",
41
41
  "jest": "^30.1.3",
@@ -70,5 +70,5 @@
70
70
  "publishConfig": {
71
71
  "access": "public"
72
72
  },
73
- "gitHead": "aa02ace634ba3b5a59a207891f7012b5b08d9f5e"
73
+ "gitHead": "e09bb34b122c8fc3eb6ab7481b8668e8aa3e3594"
74
74
  }