Cli: Refactor build and authenticate commands#209
Open
alavarello wants to merge 9 commits intomainfrom
Open
Conversation
4abdc56 to
b4d14be
Compare
lgalende
reviewed
Feb 4, 2026
lgalende
reviewed
Feb 5, 2026
Comment on lines
+52
to
54
| if (!skipBuild) { | ||
| await Build.build(cmd, flags) | ||
| } |
Member
There was a problem hiding this comment.
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 | ||
|
|
| 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' }), |
Member
There was a problem hiding this comment.
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 ./'] |
Member
There was a problem hiding this comment.
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) | ||
| } |
Member
There was a problem hiding this comment.
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) |
Member
There was a problem hiding this comment.
to be consistent
Suggested change
| const absOutputDir = path.resolve(buildDir) | |
| const absBuildDir = path.resolve(buildDir) |
Member
There was a problem hiding this comment.
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 }), |
Member
There was a problem hiding this comment.
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 }) |
Member
There was a problem hiding this comment.
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?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR refactors the following commands:
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