Skip to content

CLI - codegen command now supports the --watch option#1584

Merged
dOrgJelli merged 3 commits intoorigin-devfrom
pileks/feat/cli-codegen-watch
Mar 2, 2023
Merged

CLI - codegen command now supports the --watch option#1584
dOrgJelli merged 3 commits intoorigin-devfrom
pileks/feat/cli-codegen-watch

Conversation

@pileks
Copy link
Contributor

@pileks pileks commented Feb 23, 2023

Resolves #1459

You can now run npx polywrap codegen --watch which will automatically watch files within your project directory and re-run codegen whenever changes are detected.

@pileks pileks added this to the origin-qa milestone Feb 23, 2023
@pileks pileks self-assigned this Feb 23, 2023
@pileks pileks requested a review from namesty as a code owner February 23, 2023 16:25
Copy link
Contributor

@krisbitney krisbitney left a comment

Choose a reason for hiding this comment

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

This is a great feature! Very cool stuff. 😁

const execute = async (): Promise<boolean> => {
let result = false;

try {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is already a try-catch block within codeGenerator.generate() that catches and logs any errors, so the try-catch block in codegen.ts will log the errors a second time.

https://github.com/polywrap/toolchain/blob/origin-dev/packages/cli/src/lib/codegen/CodeGenerator.ts

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm, this try/catch logic is also in the build command. Honestly I think it's alright to log more than once, and it might be best to remove the try/catch from within the lib layer. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, either way is good. I prefer removing the try-catch from the lib layer if there are no side effects from doing that, but I'd also be happy merging this as-is.

Copy link
Contributor

@dOrgJelli dOrgJelli left a comment

Choose a reason for hiding this comment

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

Looks great! Waiting for @krisbitney's approval regarding logging practices.

@dOrgJelli dOrgJelli merged commit 8b38653 into origin-dev Mar 2, 2023
@dOrgJelli dOrgJelli deleted the pileks/feat/cli-codegen-watch branch April 10, 2023 16:57
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.

Implement a polywrap codegen --watch CLI command

3 participants