Skip to content

Commit

Permalink
Updating the frigg cli for deploy (#372)
Browse files Browse the repository at this point in the history
### TL;DR
Added build and deploy commands to the Frigg CLI tool and included serverless as a dependency.

### What changed?
- Created new build command that packages serverless applications
- Added deploy command for serverless deployment
- Integrated both commands into the main CLI program
- Added serverless v3.39.0 as a dependency
- Updated tailwindcss from 3.4.7 to 3.4.10

### How to test?
1. Run `frigg build` to package your serverless application
2. Run `frigg deploy` to deploy your serverless application
3. Verify both commands execute successfully with your infrastructure.js configuration
4. Check that the deployment process completes without errors

### Why make this change?
To streamline the development workflow by providing direct CLI commands for building and deploying serverless applications, eliminating the need to run serverless commands manually.
  • Loading branch information
seanspeaks authored Feb 17, 2025
2 parents 494098f + d8313f5 commit 198ac3a
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions packages/devtools/frigg-cli/build-command/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { spawn } = require('child_process');
const path = require('path');

function buildCommand(...args) {
console.log('Building the serverless application...');
const backendPath = path.resolve(process.cwd());
const infrastructurePath = 'infrastructure.js';
const command = 'serverless';
const serverlessArgs = ['package', '--config', infrastructurePath, ...args.filter(arg => arg !== 'build')];

const childProcess = spawn(command, serverlessArgs, {
cwd: backendPath,
stdio: 'inherit',
});

childProcess.on('error', (error) => {
console.error(`Error executing command: ${error.message}`);
});

childProcess.on('close', (code) => {
if (code !== 0) {
console.log(`Child process exited with code ${code}`);
}
});
}

module.exports = { buildCommand };
27 changes: 27 additions & 0 deletions packages/devtools/frigg-cli/deploy-command/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { spawn } = require('child_process');
const path = require('path');

function deployCommand(...args) {
console.log('Deploying the serverless application...');
const backendPath = path.resolve(process.cwd());
const infrastructurePath = 'infrastructure.js';
const command = 'serverless';
const serverlessArgs = ['deploy', '--config', infrastructurePath, ...args.filter(arg => arg !== 'deploy')];

const childProcess = spawn(command, serverlessArgs, {
cwd: backendPath,
stdio: 'inherit',
});

childProcess.on('error', (error) => {
console.error(`Error executing command: ${error.message}`);
});

childProcess.on('close', (code) => {
if (code !== 0) {
console.log(`Child process exited with code ${code}`);
}
});
}

module.exports = { deployCommand };
14 changes: 13 additions & 1 deletion packages/devtools/frigg-cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
const { Command } = require('commander');
const { installCommand } = require('./install-command');
const { startCommand } = require('./start-command'); // Assuming you have a startCommand module
const { buildCommand } = require('./build-command');
const { deployCommand } = require('./deploy-command');

const program = new Command();
program
Expand All @@ -15,6 +17,16 @@ program
.description('Run the backend and optional frontend')
.action(startCommand);

program
.command('build')
.description('Build the serverless application')
.action(buildCommand);

program
.command('deploy')
.description('Deploy the serverless application')
.action(deployCommand);

program.parse(process.argv);

module.exports = { installCommand, startCommand };
module.exports = { installCommand, startCommand, buildCommand, deployCommand };
3 changes: 2 additions & 1 deletion packages/devtools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"serverless-dotenv-plugin": "^6.0.0",
"serverless-offline": "^13.8.0",
"serverless-offline-sqs": "^8.0.0",
"serverless-webpack": "^5.14.1"
"serverless-webpack": "^5.14.1",
"serverless": "3.39.0"
},
"scripts": {
"lint:fix": "prettier --write --loglevel error . && eslint . --fix",
Expand Down

0 comments on commit 198ac3a

Please sign in to comment.