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

iwahbe/7858/fix nodejs hypen imports #7993

Merged
merged 6 commits into from
Sep 20, 2021

Conversation

iwahbe
Copy link
Member

@iwahbe iwahbe commented Sep 17, 2021

Description

Encapsulate the creation of external package names (pulumi%s) and convert them to pascal case (correctly handling -).

Fixes #7858

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • Yes, there are changes in this PR that warrants bumping the Pulumi Service API version

@github-actions
Copy link

Diff for pulumi-azuread with merge commit 94e9aa9

@github-actions
Copy link

Diff for pulumi-random with merge commit 94e9aa9

@github-actions
Copy link

Diff for pulumi-random with merge commit 1974ac2

@github-actions
Copy link

Diff for pulumi-azuread with merge commit 1974ac2

@github-actions
Copy link

Diff for pulumi-kubernetes with merge commit 94e9aa9

@github-actions
Copy link

Diff for pulumi-kubernetes with merge commit 1974ac2

@github-actions
Copy link

Diff for pulumi-gcp with merge commit 94e9aa9

@github-actions
Copy link

Diff for pulumi-aws with merge commit 94e9aa9

@github-actions
Copy link

Diff for pulumi-gcp with merge commit 1974ac2

@github-actions
Copy link

Diff for pulumi-aws with merge commit 1974ac2

@github-actions
Copy link

Diff for pulumi-azure with merge commit 1974ac2

@github-actions
Copy link

Diff for pulumi-azure with merge commit 94e9aa9

@iwahbe iwahbe self-assigned this Sep 17, 2021
Comment on lines 48 to 54
// title Capitalizes the first rune in s.
//
// Note: this is expected to work on strings which are not valid identifiers.
// Example:
// "hello" => "Hello"
// "hiAlice" => "HiAlice"
// "hi.Bob" => "Hi.Bob"
Copy link
Member

Choose a reason for hiding this comment

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

❤️

Comment on lines +80 to +95
func pascal(s string) string {
split := [][]rune{{}}
runes := []rune(s)
for _, r := range runes {
if !isLegalIdentifierPart(r) && r != '.' {
split = append(split, []rune{})
} else {
split[len(split)-1] = append(split[len(split)-1], r)
}
}
words := make([]string, len(split))
for i, v := range split {
words[i] = title(string(v))
}
return strings.Join(words, "")
}
Copy link
Member

@komalali komalali Sep 17, 2021

Choose a reason for hiding this comment

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

Since there's already a camel function could pascal just be title(camel(s))?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. I had that thought, but it doesn't work out. camel does conversions like JSONObject to jsonObject. title(camel("JSONObject")) would be JsonObject and we want it to remain unchanged. camel also has no impact on -, which we want pascal to do.

Copy link
Member

Choose a reason for hiding this comment

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

Expanding on the comment for pascal to include what you just said would be awesome!

@github-actions
Copy link

Diff for pulumi-azuread with merge commit 29c605c

@github-actions
Copy link

Diff for pulumi-random with merge commit 29c605c

@github-actions
Copy link

Diff for pulumi-kubernetes with merge commit 29c605c

@github-actions
Copy link

Diff for pulumi-aws with merge commit 29c605c

@github-actions
Copy link

Diff for pulumi-gcp with merge commit 29c605c

@github-actions
Copy link

Diff for pulumi-azure with merge commit 29c605c

@github-actions
Copy link

Diff for pulumi-azuread with merge commit 5b4b883

@github-actions
Copy link

Diff for pulumi-kubernetes with merge commit 5b4b883

@github-actions
Copy link

Diff for pulumi-aws with merge commit 5b4b883

@github-actions
Copy link

Diff for pulumi-gcp with merge commit 5b4b883

@github-actions
Copy link

Diff for pulumi-azure with merge commit 5b4b883

@iwahbe iwahbe merged commit c338876 into master Sep 20, 2021
@pulumi-bot pulumi-bot deleted the iwahbe/7858/fix-nodejs-hypen-imports branch September 20, 2021 17:11
@github-actions
Copy link

Diff for pulumi-aws with merge commit 01b6895

@github-actions
Copy link

Diff for pulumi-azuread with merge commit 01b6895

@github-actions
Copy link

Diff for pulumi-random with merge commit 01b6895

@github-actions
Copy link

Diff for pulumi-kubernetes with merge commit 01b6895

@github-actions
Copy link

Diff for pulumi-gcp with merge commit 01b6895

@github-actions
Copy link

Diff for pulumi-azure with merge commit 01b6895

@emiliza emiliza added kind/engineering Work that is not visible to an external user size/S Estimated effort to complete (1-2 days). labels Sep 21, 2021
@emiliza emiliza added this to the 0.62 milestone Sep 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/engineering Work that is not visible to an external user size/S Estimated effort to complete (1-2 days).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nodejs codegen produces incorrect import syntax for azure-native
3 participants