Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: initium project type flag #101

Merged
merged 21 commits into from
Oct 19, 2023
Merged

feat: initium project type flag #101

merged 21 commits into from
Oct 19, 2023

Conversation

Pehesi97
Copy link
Contributor

@Pehesi97 Pehesi97 commented Sep 8, 2023

Closes #100.

Testing

initium-cli init config --persist

This should detect the project type and store it on the initium config file. From that moment on, any initium-cli command will work without the need of specifying the project type.

If the CLI doesn't detect the type, the command will fail and the project type will be a required flag / environment variable.

@Pehesi97 Pehesi97 requested a review from a team September 8, 2023 19:31
@Pehesi97 Pehesi97 self-assigned this Sep 8, 2023
src/cli/cli.go Outdated Show resolved Hide resolved
@Pehesi97 Pehesi97 changed the title feat: initium project language flag feat: initium project type flag Oct 18, 2023
@LucaLanziani
Copy link
Member

The logic works as expected, we might improve the error message in the second case

➜  initium-cli git:(chore/issue-100) go run main.go init config
app-name: initium-cli
container-registry: ghcr.io/nearform
default-branch: main
dockerfile-name: null
env-var-file: .env.initium
image-pull-secrets: null
project-type: go
runtime-version: null
➜  initium-cli git:(chore/issue-100) touch package.json        
➜  initium-cli git:(chore/issue-100) ✗ go run main.go init config
2023/10/19 10:23:33 FATA required flags "project-type" not set
exit status 1

var projectType ProjectType
var err error
if proj.Type != "" {
projectType, err = proj.matchType()
Copy link
Member

Choose a reason for hiding this comment

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

Can we use the IsValidProjectType here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Line 120 or 121?
Because the function only returns a bool that indicates whether the project type is valid or not

Copy link
Member

@LucaLanziani LucaLanziani left a comment

Choose a reason for hiding this comment

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

LGTM

@Pehesi97 Pehesi97 merged commit 321141e into main Oct 19, 2023
2 checks passed
@Pehesi97 Pehesi97 deleted the chore/issue-100 branch October 19, 2023 18:25
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.

Fix runtime detection algorithm
2 participants