Skip to content

Commit

Permalink
Updating the frigg cli for deploy (#374)
Browse files Browse the repository at this point in the history
Added options to commander for stage
  • Loading branch information
seanspeaks authored Feb 17, 2025
2 parents f89c940 + 0e8ccc8 commit e5e8c16
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
12 changes: 9 additions & 3 deletions packages/devtools/frigg-cli/build-command/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
const { spawn } = require('child_process');
const path = require('path');

function buildCommand(...args) {
function buildCommand(options) {
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 serverlessArgs = [
'package',
'--config',
infrastructurePath,
'--stage',
options.stage
];

const childProcess = spawn(command, serverlessArgs, {
cwd: backendPath,
Expand All @@ -22,6 +28,6 @@ function buildCommand(...args) {
console.log(`Child process exited with code ${code}`);
}
});
}
}

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

function deployCommand(...args) {
function deployCommand(options) {
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 serverlessArgs = [
'deploy',
'--config',
infrastructurePath,
'--stage',
options.stage
];

const childProcess = spawn(command, serverlessArgs, {
cwd: backendPath,
Expand Down
3 changes: 3 additions & 0 deletions packages/devtools/frigg-cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,19 @@ program
program
.command('start')
.description('Run the backend and optional frontend')
.option('-s, --stage <stage>', 'deployment stage', 'dev')
.action(startCommand);

program
.command('build')
.description('Build the serverless application')
.option('-s, --stage <stage>', 'deployment stage', 'dev')
.action(buildCommand);

program
.command('deploy')
.description('Deploy the serverless application')
.option('-s, --stage <stage>', 'deployment stage', 'dev')
.action(deployCommand);

program.parse(process.argv);
Expand Down
10 changes: 8 additions & 2 deletions packages/devtools/frigg-cli/start-command/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
const { spawn } = require('child_process');
const path = require('path');

function startCommand() {
function startCommand(options) {
console.log('Starting backend and optional frontend...');
// Suppress AWS SDK warning message about maintenance mode
process.env.AWS_SDK_JS_SUPPRESS_MAINTENANCE_MODE_MESSAGE = 1;
const backendPath = path.resolve(process.cwd());
console.log(`Starting backend in ${backendPath}...`);
const infrastructurePath = 'infrastructure.js';
const command = 'serverless';
const args = ['offline', '--config', infrastructurePath, '--stage=dev'];
const args = [
'offline',
'--config',
infrastructurePath,
'--stage',
options.stage
];

const childProcess = spawn(command, args, {
cwd: backendPath,
Expand Down

0 comments on commit e5e8c16

Please sign in to comment.