@friggframework/devtools 2.0.0--canary.545.a2a8f01.0 → 2.0.0--canary.545.302ab9b.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.
|
@@ -23,6 +23,77 @@ function isProcessRunning(pid) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Build for a non-AWS provider.
|
|
28
|
+
*
|
|
29
|
+
* When infrastructure.js is invoked (e.g. `node infrastructure.js package`),
|
|
30
|
+
* but the appDefinition specifies a non-AWS provider, we skip the entire
|
|
31
|
+
* serverless/CloudFormation pipeline and instead:
|
|
32
|
+
* 1. Validate the appDefinition against the provider
|
|
33
|
+
* 2. Generate the provider-specific config (e.g. netlify.toml)
|
|
34
|
+
* 3. Generate function entry points
|
|
35
|
+
*
|
|
36
|
+
* This mirrors what the CLI's buildCommand does for non-AWS providers,
|
|
37
|
+
* but works when invoked directly via `node infrastructure.js package`.
|
|
38
|
+
*/
|
|
39
|
+
async function buildWithProvider(appDefinition, providerName, backendDir) {
|
|
40
|
+
const { resolveProvider } = require('@friggframework/core/providers/resolve-provider');
|
|
41
|
+
const provider = resolveProvider(appDefinition);
|
|
42
|
+
|
|
43
|
+
console.log(`Building for ${providerName} provider (skipping AWS infrastructure)...`);
|
|
44
|
+
|
|
45
|
+
// 1. Validate
|
|
46
|
+
if (typeof provider.validate === 'function') {
|
|
47
|
+
const validation = provider.validate(appDefinition);
|
|
48
|
+
if (validation.errors?.length > 0) {
|
|
49
|
+
console.error(`\nValidation errors for ${providerName}:`);
|
|
50
|
+
for (const error of validation.errors) {
|
|
51
|
+
console.error(` - ${error}`);
|
|
52
|
+
}
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
if (validation.warnings?.length > 0) {
|
|
56
|
+
for (const warning of validation.warnings) {
|
|
57
|
+
console.warn(` Warning: ${warning}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 2. Generate platform config (e.g. netlify.toml)
|
|
63
|
+
// Written to the project root (one level up from backend/)
|
|
64
|
+
const projectDir = path.dirname(backendDir);
|
|
65
|
+
if (typeof provider.generateConfig === 'function') {
|
|
66
|
+
const config = provider.generateConfig(appDefinition);
|
|
67
|
+
const configFileNames = { netlify: 'netlify.toml' };
|
|
68
|
+
const configFileName = configFileNames[providerName] || `${providerName}.config`;
|
|
69
|
+
const configPath = path.join(projectDir, configFileName);
|
|
70
|
+
|
|
71
|
+
fs.writeFileSync(configPath, config, 'utf-8');
|
|
72
|
+
console.log(` Written ${configFileName}`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 3. Generate function entry points
|
|
76
|
+
if (typeof provider.getFunctionEntryPoints === 'function') {
|
|
77
|
+
const entryPoints = provider.getFunctionEntryPoints(appDefinition);
|
|
78
|
+
const functionsDir = path.join(projectDir, 'netlify', 'functions');
|
|
79
|
+
|
|
80
|
+
fs.mkdirSync(functionsDir, { recursive: true });
|
|
81
|
+
|
|
82
|
+
for (const [filename, content] of Object.entries(entryPoints)) {
|
|
83
|
+
const filePath = path.join(functionsDir, filename);
|
|
84
|
+
fs.writeFileSync(filePath, content, 'utf-8');
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
console.log(` Generated ${Object.keys(entryPoints).length} function entry points`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
console.log(`\nBuild complete for ${providerName}.`);
|
|
91
|
+
|
|
92
|
+
// Return an empty serverless definition — osls will see no functions
|
|
93
|
+
// and effectively no-op. The real deployment is handled by the provider.
|
|
94
|
+
return {};
|
|
95
|
+
}
|
|
96
|
+
|
|
26
97
|
async function createFriggInfrastructure() {
|
|
27
98
|
const backendPath = findNearestBackendPackageJson();
|
|
28
99
|
if (!backendPath) {
|
|
@@ -104,6 +175,13 @@ async function createFriggInfrastructure() {
|
|
|
104
175
|
const backend = require(backendFilePath);
|
|
105
176
|
const appDefinition = backend.Definition;
|
|
106
177
|
|
|
178
|
+
// Check if a non-AWS provider is configured.
|
|
179
|
+
// If so, run the provider's build pipeline instead of AWS CloudFormation.
|
|
180
|
+
const providerName = appDefinition.provider || 'aws';
|
|
181
|
+
if (providerName !== 'aws') {
|
|
182
|
+
return buildWithProvider(appDefinition, providerName, backendDir);
|
|
183
|
+
}
|
|
184
|
+
|
|
107
185
|
const definition = await composeServerlessDefinition(
|
|
108
186
|
appDefinition,
|
|
109
187
|
);
|
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.545.
|
|
4
|
+
"version": "2.0.0--canary.545.302ab9b.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"frigg": "./frigg-cli/index.js"
|
|
7
7
|
},
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"@babel/eslint-parser": "^7.18.9",
|
|
26
26
|
"@babel/parser": "^7.25.3",
|
|
27
27
|
"@babel/traverse": "^7.25.3",
|
|
28
|
-
"@friggframework/core": "2.0.0--canary.545.
|
|
29
|
-
"@friggframework/schemas": "2.0.0--canary.545.
|
|
30
|
-
"@friggframework/test": "2.0.0--canary.545.
|
|
28
|
+
"@friggframework/core": "2.0.0--canary.545.302ab9b.0",
|
|
29
|
+
"@friggframework/schemas": "2.0.0--canary.545.302ab9b.0",
|
|
30
|
+
"@friggframework/test": "2.0.0--canary.545.302ab9b.0",
|
|
31
31
|
"@hapi/boom": "^10.0.1",
|
|
32
32
|
"@inquirer/prompts": "^5.3.8",
|
|
33
33
|
"axios": "^1.7.2",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"validate-npm-package-name": "^5.0.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@friggframework/eslint-config": "2.0.0--canary.545.
|
|
59
|
-
"@friggframework/prettier-config": "2.0.0--canary.545.
|
|
58
|
+
"@friggframework/eslint-config": "2.0.0--canary.545.302ab9b.0",
|
|
59
|
+
"@friggframework/prettier-config": "2.0.0--canary.545.302ab9b.0",
|
|
60
60
|
"aws-sdk-client-mock": "^4.1.0",
|
|
61
61
|
"aws-sdk-client-mock-jest": "^4.1.0",
|
|
62
62
|
"exit-x": "^0.2.2",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"publishConfig": {
|
|
90
90
|
"access": "public"
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "302ab9baf3116458ee080f854fab184814c053a4"
|
|
93
93
|
}
|