Skip to content

Commit

Permalink
feat: enhance faas deploy command to support deploying all cloud func…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
anran758 committed Jan 31, 2024
1 parent b6a5ab1 commit 5fc0f8d
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions packages/cli/src/commands/faas/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ async function deployFile({
}

if (status === 404) {
logger.log(`try create new function.`);
if (debug) {
logger.log(`"${functionName}" try create new function.`);
}

await createCloudFunction({
name: functionName,
content: content.toString(),
Expand All @@ -76,7 +79,7 @@ async function deployFile({
throw new Error(message);
});

logger.info(`"${functionName}" created successfully.`);
logger.info(`"${chalk.bold.blue(functionName)}" created successfully.`);
}
} else {
if (debug) {
Expand All @@ -101,9 +104,22 @@ export async function deployFunction({
return result;
} else {
logger.info(
`${chalk.bold.yellow('TODO:')} Preparing to deploy ${chalk.bold(
'all',
)} Cloud Functions from the directory...`,
`Preparing to deploy`,
chalk.bold('all cloud functions'),
`from the directory...\n`,
);

const extension = '.js';
const files = fs
.readdirSync(folderPath)
.filter(file => path.extname(file) === extension);

await Promise.all(
files.map(file => {
const functionName = path.basename(file, extension);

return deployFile({ dir: folderPath, functionName });
}),
);
}
} catch (error) {
Expand Down

0 comments on commit 5fc0f8d

Please sign in to comment.