@friggframework/devtools 2.0.0-next.4 → 2.0.0-next.6
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.
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const { spawn } = require('child_process');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
function buildCommand(...args) {
|
|
5
|
+
console.log('Building the serverless application...');
|
|
6
|
+
const backendPath = path.resolve(process.cwd());
|
|
7
|
+
const infrastructurePath = 'infrastructure.js';
|
|
8
|
+
const command = 'serverless';
|
|
9
|
+
const serverlessArgs = ['package', '--config', infrastructurePath, ...args.filter(arg => arg !== 'build')];
|
|
10
|
+
|
|
11
|
+
const childProcess = spawn(command, serverlessArgs, {
|
|
12
|
+
cwd: backendPath,
|
|
13
|
+
stdio: 'inherit',
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
childProcess.on('error', (error) => {
|
|
17
|
+
console.error(`Error executing command: ${error.message}`);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
childProcess.on('close', (code) => {
|
|
21
|
+
if (code !== 0) {
|
|
22
|
+
console.log(`Child process exited with code ${code}`);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = { buildCommand };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const { spawn } = require('child_process');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
function deployCommand(...args) {
|
|
5
|
+
console.log('Deploying the serverless application...');
|
|
6
|
+
const backendPath = path.resolve(process.cwd());
|
|
7
|
+
const infrastructurePath = 'infrastructure.js';
|
|
8
|
+
const command = 'serverless';
|
|
9
|
+
const serverlessArgs = ['deploy', '--config', infrastructurePath, ...args.filter(arg => arg !== 'deploy')];
|
|
10
|
+
|
|
11
|
+
const childProcess = spawn(command, serverlessArgs, {
|
|
12
|
+
cwd: backendPath,
|
|
13
|
+
stdio: 'inherit',
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
childProcess.on('error', (error) => {
|
|
17
|
+
console.error(`Error executing command: ${error.message}`);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
childProcess.on('close', (code) => {
|
|
21
|
+
if (code !== 0) {
|
|
22
|
+
console.log(`Child process exited with code ${code}`);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = { deployCommand };
|
package/frigg-cli/index.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
const { Command } = require('commander');
|
|
4
4
|
const { installCommand } = require('./install-command');
|
|
5
5
|
const { startCommand } = require('./start-command'); // Assuming you have a startCommand module
|
|
6
|
+
const { buildCommand } = require('./build-command');
|
|
7
|
+
const { deployCommand } = require('./deploy-command');
|
|
6
8
|
|
|
7
9
|
const program = new Command();
|
|
8
10
|
program
|
|
@@ -15,6 +17,16 @@ program
|
|
|
15
17
|
.description('Run the backend and optional frontend')
|
|
16
18
|
.action(startCommand);
|
|
17
19
|
|
|
20
|
+
program
|
|
21
|
+
.command('build')
|
|
22
|
+
.description('Build the serverless application')
|
|
23
|
+
.action(buildCommand);
|
|
24
|
+
|
|
25
|
+
program
|
|
26
|
+
.command('deploy')
|
|
27
|
+
.description('Deploy the serverless application')
|
|
28
|
+
.action(deployCommand);
|
|
29
|
+
|
|
18
30
|
program.parse(process.argv);
|
|
19
31
|
|
|
20
|
-
module.exports = { installCommand, startCommand };
|
|
32
|
+
module.exports = { installCommand, startCommand, buildCommand, deployCommand };
|
|
@@ -2,7 +2,7 @@ const { createFriggBackend, Worker } = require('@friggframework/core');
|
|
|
2
2
|
const {
|
|
3
3
|
findNearestBackendPackageJson,
|
|
4
4
|
} = require('../frigg-cli/utils/backend-path');
|
|
5
|
-
const path = require('path');
|
|
5
|
+
const path = require('node:path');
|
|
6
6
|
const fs = require('fs-extra');
|
|
7
7
|
|
|
8
8
|
const backendPath = findNearestBackendPackageJson();
|
|
@@ -32,7 +32,7 @@ const loadRouterFromObject = (IntegrationClass, routerObject) => {
|
|
|
32
32
|
const integration = new IntegrationClass({});
|
|
33
33
|
await integration.loadModules();
|
|
34
34
|
await integration.registerEventHandlers();
|
|
35
|
-
const result = await integration.send(event, req
|
|
35
|
+
const result = await integration.send(event, {req, res, next});
|
|
36
36
|
res.json(result);
|
|
37
37
|
} catch (error) {
|
|
38
38
|
next(error);
|
|
@@ -43,9 +43,6 @@ const loadRouterFromObject = (IntegrationClass, routerObject) => {
|
|
|
43
43
|
};
|
|
44
44
|
const createQueueWorker = (integrationClass) => {
|
|
45
45
|
class QueueWorker extends Worker {
|
|
46
|
-
constructor(params) {
|
|
47
|
-
super(params);
|
|
48
|
-
}
|
|
49
46
|
async _run(params, context) {
|
|
50
47
|
try {
|
|
51
48
|
let instance;
|
|
@@ -1,30 +1,35 @@
|
|
|
1
|
-
const { createIntegrationRouter } = require('@friggframework/core');
|
|
2
1
|
const { createAppHandler } = require('./../app-handler-helpers');
|
|
3
|
-
const { requireLoggedInUser } = require('./middleware/requireLoggedInUser');
|
|
4
2
|
const {
|
|
5
|
-
moduleFactory,
|
|
6
3
|
integrationFactory,
|
|
7
|
-
IntegrationHelper,
|
|
8
4
|
loadRouterFromObject,
|
|
9
5
|
} = require('./../backend-utils');
|
|
10
6
|
const { Router } = require('express');
|
|
11
7
|
|
|
12
8
|
const handlers = {};
|
|
13
|
-
integrationFactory.integrationClasses
|
|
9
|
+
for (const IntegrationClass of integrationFactory.integrationClasses) {
|
|
14
10
|
const router = Router();
|
|
15
11
|
const basePath = `/api/${IntegrationClass.Definition.name}-integration`;
|
|
16
|
-
|
|
12
|
+
|
|
13
|
+
console.log(`\n│ Configuring routes for ${IntegrationClass.Definition.name} Integration:`);
|
|
14
|
+
|
|
15
|
+
for (const routeDef of IntegrationClass.Definition.routes) {
|
|
17
16
|
if (typeof routeDef === 'function') {
|
|
18
17
|
router.use(basePath, routeDef(IntegrationClass));
|
|
18
|
+
console.log(`│ ANY ${basePath}/* (function handler)`);
|
|
19
19
|
} else if (typeof routeDef === 'object') {
|
|
20
20
|
router.use(
|
|
21
21
|
basePath,
|
|
22
22
|
loadRouterFromObject(IntegrationClass, routeDef)
|
|
23
23
|
);
|
|
24
|
+
const method = (routeDef.method || 'ANY').toUpperCase();
|
|
25
|
+
const fullPath = `${basePath}${routeDef.path}`;
|
|
26
|
+
console.log(`│ ${method} ${fullPath}`);
|
|
24
27
|
} else if (routeDef instanceof express.Router) {
|
|
25
28
|
router.use(basePath, routeDef);
|
|
29
|
+
console.log(`│ ANY ${basePath}/* (express router)`);
|
|
26
30
|
}
|
|
27
|
-
}
|
|
31
|
+
}
|
|
32
|
+
console.log('│');
|
|
28
33
|
|
|
29
34
|
handlers[`${IntegrationClass.Definition.name}`] = {
|
|
30
35
|
handler: createAppHandler(
|
|
@@ -32,6 +37,6 @@ integrationFactory.integrationClasses.forEach((IntegrationClass) => {
|
|
|
32
37
|
router
|
|
33
38
|
),
|
|
34
39
|
};
|
|
35
|
-
}
|
|
40
|
+
}
|
|
36
41
|
|
|
37
42
|
module.exports = { handlers };
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/devtools",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0-next.
|
|
4
|
+
"version": "2.0.0-next.6",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@babel/eslint-parser": "^7.18.9",
|
|
7
7
|
"@babel/parser": "^7.25.3",
|
|
8
8
|
"@babel/traverse": "^7.25.3",
|
|
9
|
-
"@friggframework/core": "2.0.0-next.
|
|
10
|
-
"@friggframework/test": "2.0.0-next.
|
|
9
|
+
"@friggframework/core": "2.0.0-next.6",
|
|
10
|
+
"@friggframework/test": "2.0.0-next.6",
|
|
11
11
|
"@hapi/boom": "^7.4.11",
|
|
12
12
|
"@inquirer/prompts": "^5.3.8",
|
|
13
13
|
"axios": "^1.7.2",
|
|
@@ -28,8 +28,9 @@
|
|
|
28
28
|
"serverless-http": "^2.7.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@friggframework/eslint-config": "2.0.0-next.
|
|
32
|
-
"@friggframework/prettier-config": "2.0.0-next.
|
|
31
|
+
"@friggframework/eslint-config": "2.0.0-next.6",
|
|
32
|
+
"@friggframework/prettier-config": "2.0.0-next.6",
|
|
33
|
+
"serverless": "3.39.0",
|
|
33
34
|
"serverless-dotenv-plugin": "^6.0.0",
|
|
34
35
|
"serverless-offline": "^13.8.0",
|
|
35
36
|
"serverless-offline-sqs": "^8.0.0",
|
|
@@ -57,5 +58,5 @@
|
|
|
57
58
|
"publishConfig": {
|
|
58
59
|
"access": "public"
|
|
59
60
|
},
|
|
60
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "14d7f856430f95bc0367246089713540e1c23a86"
|
|
61
62
|
}
|