Skip to content

Commit

Permalink
chore: 🤖 code format
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Oct 30, 2024
1 parent 280826f commit 7ee783f
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 17 deletions.
9 changes: 7 additions & 2 deletions src/commands/functions/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@ type CreateFunctionArgs = {
siteId?: string;
};

const createAction: SdkGuardedFunction<CreateFunctionArgs> = async ({ args, sdk }) => {
const createAction: SdkGuardedFunction<CreateFunctionArgs> = async ({
args,
sdk,
}) => {
const { name, siteId } = args;
const functionName = await getFunctionNameOrPrompt({ name });

if (siteId && !(await isSiteIdValid({ siteId, sdk }))) {
throw new SiteNotFoundError({ site: { id: siteId } });
}

const newFunction = await sdk.functions().create({ name: functionName, siteId });
const newFunction = await sdk
.functions()
.create({ name: functionName, siteId });

output.printNewLine();
output.success(t('commonNameCreateSuccess', { name: 'function' }));
Expand Down
43 changes: 30 additions & 13 deletions src/commands/functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,26 @@ type DeployOptions = {
};

export default (program: Command): Command => {
const cmd = program.command('functions').description(t('functionsDescription'));
const cmd = program
.command('functions')
.description(t('functionsDescription'));

cmd
.command('create')
.option('-n, --name <functionName>', t('functionName'))
.option('--site <siteId>', t('functionsSite'))
.description(t('functionsCreateDescription'))
.action((options: { name?: string; site?: string }) => createActionHandler({ name: options.name, siteId: options.site }));
.action((options: { name?: string; site?: string }) =>
createActionHandler({ name: options.name, siteId: options.site }),
);

cmd
.command('delete')
.description(t('functionsDeleteDescription'))
.option('-n, --name <functionName>', t('functionName'))
.action((options: { name?: string }) => deleteActionHandler({ name: options.name }));
.action((options: { name?: string }) =>
deleteActionHandler({ name: options.name }),
);

cmd
.command('update')
Expand All @@ -42,13 +48,19 @@ export default (program: Command): Command => {
.option('--name <newName>', t('functionName'))
.option('--slug <newSlug>', t('functionSlug'))
.option('--status <newStatus>', t('functionStatus'))
.action((options: { functionName?: string; name?: string; slug?: string; status?: string }) =>
updateActionHandler({
functionName: options.functionName,
name: options.name,
slug: options.slug,
status: options.status,
})
.action(
(options: {
functionName?: string;
name?: string;
slug?: string;
status?: string;
}) =>
updateActionHandler({
functionName: options.functionName,
name: options.name,
slug: options.slug,
status: options.status,
}),
);

cmd
Expand All @@ -61,7 +73,10 @@ export default (program: Command): Command => {
.option('-e, --env <environmentVariables...>', t('environmentVariables'))
.option('--sgx', t('functionsUseSgx'), false)
.option('-a --assets <assetsPath>', t('functionsUseAssets'), false)
.option('--envFile <environmentVariablesFilePath>', t('environmentVariablesFile'))
.option(
'--envFile <environmentVariablesFilePath>',
t('environmentVariablesFile'),
)
.action((options: DeployOptions) =>
deployActionHandler({
filePath: options.path,
Expand All @@ -72,7 +87,7 @@ export default (program: Command): Command => {
envFile: options.envFile,
sgx: options.sgx,
assetsPath: options.assets,
})
}),
);

cmd
Expand All @@ -84,7 +99,9 @@ export default (program: Command): Command => {
.command('deployments')
.option('-n, --name <functionName>', t('functionName'))
.description(t('deploymentsListForSelectedFunction'))
.action((options: { name?: string }) => listDeploymentsActionHandler(options));
.action((options: { name?: string }) =>
listDeploymentsActionHandler(options),
);

return cmd;
};
7 changes: 5 additions & 2 deletions src/commands/functions/utils/isSiteIdValid.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { FleekSdk } from '@fleek-platform/sdk/node';
import type { FleekSdk } from '@fleek-platform/sdk/node';

export const isSiteIdValid = ({ siteId, sdk }: { siteId: string; sdk: FleekSdk }) => {
export const isSiteIdValid = ({
siteId,
sdk,
}: { siteId: string; sdk: FleekSdk }) => {
if (!siteId) return true;

return sdk
Expand Down

0 comments on commit 7ee783f

Please sign in to comment.