Skip to content

Conversation

jeffrifwaldsmartcontract
Copy link
Collaborator

  • Adds shared build command for deploy/simulate workflows.

ernest-nowacki
ernest-nowacki previously approved these changes Sep 26, 2025

// Gets a build command for either Golang or Typescript based on the filename
func GetBuildCmd(inputFile string, outputFile string, rootFolder string) *exec.Cmd {
isTypescriptWorkflow := strings.HasSuffix(inputFile, ".ts")
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not safe after this change: https://github.com/smartcontractkit/cre-cli/pull/36/files#r2382877260

cc @timothyF95 who is working on providing a path instead of the main.go.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jeffrifwaldsmartcontract for typescipt, do we have to specify the x.ts file or it is okay to just give the path of the workflow directory where the x.ts lives? Relevant ticket: https://smartcontract-it.atlassian.net/browse/DEVSVCS-2420

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can adapt this to however Go wants to ultimately address figuring out what the input file is. Right now the inputFile is read from the command line, so examining that filename is the easiest.

Looking at the proposals, maybe we can instead just read the directory and see if main.go or main.ts exists in the folder.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let me know if you think this is OK for now or if we want to wait on this until those other tickets are resolved.

Copy link
Contributor

Choose a reason for hiding this comment

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

if we go with the directory approach, what if there are multiple ts files in the directory? For go, it compiles and build the whole directory, so it doesnt matter. I am not sure about TS.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think I'll need to see how the Go compile command will ultimately be utilized. It is certainly possible to scan a directory tree for ts files, but is there something inherently special about the file name main.go or main.ts in those directories?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Basically, how do we figure out the workflow entry point when dealing with a directory? I might have a bunch of scripts sitting around with .ts extensions that I don't want compiled.

Copy link
Contributor

@shileiwill shileiwill left a comment

Choose a reason for hiding this comment

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

The refactor LG. I left a minor comment on naming, and one for confirmation.


// Gets a build command for either Golang or Typescript based on the filename
func GetBuildCmd(inputFile string, outputFile string, rootFolder string) *exec.Cmd {
isTypescriptWorkflow := strings.HasSuffix(inputFile, ".ts")
Copy link
Contributor

Choose a reason for hiding this comment

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

@jeffrifwaldsmartcontract for typescipt, do we have to specify the x.ts file or it is okay to just give the path of the workflow directory where the x.ts lives? Relevant ticket: https://smartcontract-it.atlassian.net/browse/DEVSVCS-2420

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.

3 participants