Skip to content

Cli: Refactor build and authenticate commands#209

Open
alavarello wants to merge 9 commits intomainfrom
cli/refactor-build-authenticate-commands
Open

Cli: Refactor build and authenticate commands#209
alavarello wants to merge 9 commits intomainfrom
cli/refactor-build-authenticate-commands

Conversation

@alavarello
Copy link
Member

@alavarello alavarello commented Feb 3, 2026

This PR refactors the following commands:

  • authenticate
  • build
  • codegen
  • compile
  • deploy
  • init

I separated the commands logic from the parsing of arguments so we can call a command from another command

I changed skip-compile for skip-build and instead of using the codegen and compile I use the build directly with all the arguments

@alavarello alavarello force-pushed the cli/refactor-build-authenticate-commands branch from 4abdc56 to b4d14be Compare February 3, 2026 20:37
@alavarello alavarello requested a review from lgalende February 3, 2026 20:48
@alavarello alavarello self-assigned this Feb 3, 2026
@alavarello alavarello requested a review from lgalende February 4, 2026 17:36
Comment on lines +52 to 54
if (!skipBuild) {
await Build.build(cmd, flags)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
if (!skipBuild) {
await Build.build(cmd, flags)
}
if (!skipBuild) await Build.build(cmd, flags)

public async run(): Promise<void> {
const { flags } = await this.parse(Build)
const { manifest, function: functionFile, output, types, clean } = flags

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change

directory: Flags.string({ char: 'd', description: 'function directory', default: './' }),
'skip-compile': Flags.boolean({ description: 'skip codegen and compile steps' }),
...Build.flags,
directory: Flags.string({ char: 'd', description: 'Path to the testing directory', default: 'tests' }),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually use ./ for folders

Suggested change
directory: Flags.string({ char: 'd', description: 'Path to the testing directory', default: 'tests' }),
directory: Flags.string({ char: 'd', description: 'Path to the testing directory', default: './tests' }),

export default class Test extends Command {
static override description = 'Runs function tests'

static override examples = ['<%= config.bin %> <%= command.id %> --directory ./']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static override examples = ['<%= config.bin %> <%= command.id %> --directory ./']
static override examples = ['<%= config.bin %> <%= command.id %> --directory ./tests']

Comment on lines +32 to 34
if (!skipBuild) {
await Build.build(this, flags)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
if (!skipBuild) {
await Build.build(this, flags)
}
if (!skipBuild) await Build.build(this, flags)

{ function: functionDir, 'build-directory': buildDir, manifest: manifestDir }: CompileFlags
): Promise<void> {
const absFunctionFile = path.resolve(functionDir)
const absOutputDir = path.resolve(buildDir)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be consistent

Suggested change
const absOutputDir = path.resolve(buildDir)
const absBuildDir = path.resolve(buildDir)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, let's choose between abs and full as prefix. In deploy it's called fullBuildDir.

'skip-compile': Flags.boolean({ description: 'skip codegen and compile steps' }),
...Build.flags,
directory: Flags.string({ char: 'd', description: 'Path to the testing directory', default: 'tests' }),
'skip-build': Flags.boolean({ description: 'Skip codegen and compile steps before uploading', default: false }),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'skip-build': Flags.boolean({ description: 'Skip codegen and compile steps before uploading', default: false }),
'skip-build': Flags.boolean({ description: 'Skip codegen and compile steps before testing', default: false }),

})

const neededFiles = ['manifest.json', 'function.wasm'].map((file) => join(fullInputDir, file))
if (!fs.existsSync(fullBuildDir)) fs.mkdirSync(fullBuildDir, { recursive: true })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can only be true if skipBuild is true. But in that case, the previous if will also be true, so this line will never be reached.
Right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants