-
Notifications
You must be signed in to change notification settings - Fork 971
chore: generate countries.tsx from Go code #15274
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
10ccce1
feat: expose 30d trial form via CLI
joobisb af7cf3b
remove trial params as env
joobisb 2ed44c8
set first-user-trial to false in deploy-pr workflow
joobisb 411d7d0
fix typo
joobisb bc354f2
Merge remote-tracking branch 'origin/main' into issue#14856
joobisb 10d718f
set first-user-trial to false in develop.sh
joobisb 86e1b92
chore: generate countries.tsx from go code
joobisb 3648021
Merge remote-tracking branch 'origin/main' into issue#15074
joobisb 1702c64
remove unreferenced countries.tsx
joobisb 06fc0c4
feat: combine rbac and country generation scripts
joobisb 06a11f4
fix formatting
joobisb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,259 @@ | ||
package codersdk | ||
|
||
var Countries = []Country{ | ||
{Name: "Afghanistan", Flag: "🇦🇫"}, | ||
{Name: "Åland Islands", Flag: "🇦🇽"}, | ||
{Name: "Albania", Flag: "🇦🇱"}, | ||
{Name: "Algeria", Flag: "🇩🇿"}, | ||
{Name: "American Samoa", Flag: "🇦🇸"}, | ||
{Name: "Andorra", Flag: "🇦🇩"}, | ||
{Name: "Angola", Flag: "🇦🇴"}, | ||
{Name: "Anguilla", Flag: "🇦🇮"}, | ||
{Name: "Antarctica", Flag: "🇦🇶"}, | ||
{Name: "Antigua and Barbuda", Flag: "🇦🇬"}, | ||
{Name: "Argentina", Flag: "🇦🇷"}, | ||
{Name: "Armenia", Flag: "🇦🇲"}, | ||
{Name: "Aruba", Flag: "🇦🇼"}, | ||
{Name: "Australia", Flag: "🇦🇺"}, | ||
{Name: "Austria", Flag: "🇦🇹"}, | ||
{Name: "Azerbaijan", Flag: "🇦🇿"}, | ||
{Name: "Bahamas", Flag: "🇧🇸"}, | ||
{Name: "Bahrain", Flag: "🇧🇭"}, | ||
{Name: "Bangladesh", Flag: "🇧🇩"}, | ||
{Name: "Barbados", Flag: "🇧🇧"}, | ||
{Name: "Belarus", Flag: "🇧🇾"}, | ||
{Name: "Belgium", Flag: "🇧🇪"}, | ||
{Name: "Belize", Flag: "🇧🇿"}, | ||
{Name: "Benin", Flag: "🇧🇯"}, | ||
{Name: "Bermuda", Flag: "🇧🇲"}, | ||
{Name: "Bhutan", Flag: "🇧🇹"}, | ||
{Name: "Bolivia, Plurinational State of", Flag: "🇧🇴"}, | ||
{Name: "Bonaire, Sint Eustatius and Saba", Flag: "🇧🇶"}, | ||
{Name: "Bosnia and Herzegovina", Flag: "🇧🇦"}, | ||
{Name: "Botswana", Flag: "🇧🇼"}, | ||
{Name: "Bouvet Island", Flag: "🇧🇻"}, | ||
{Name: "Brazil", Flag: "🇧🇷"}, | ||
{Name: "British Indian Ocean Territory", Flag: "🇮🇴"}, | ||
{Name: "Brunei Darussalam", Flag: "🇧🇳"}, | ||
{Name: "Bulgaria", Flag: "🇧🇬"}, | ||
{Name: "Burkina Faso", Flag: "🇧🇫"}, | ||
{Name: "Burundi", Flag: "🇧🇮"}, | ||
{Name: "Cambodia", Flag: "🇰🇭"}, | ||
{Name: "Cameroon", Flag: "🇨🇲"}, | ||
{Name: "Canada", Flag: "🇨🇦"}, | ||
{Name: "Cape Verde", Flag: "🇨🇻"}, | ||
{Name: "Cayman Islands", Flag: "🇰🇾"}, | ||
{Name: "Central African Republic", Flag: "🇨🇫"}, | ||
{Name: "Chad", Flag: "🇹🇩"}, | ||
{Name: "Chile", Flag: "🇨🇱"}, | ||
{Name: "China", Flag: "🇨🇳"}, | ||
{Name: "Christmas Island", Flag: "🇨🇽"}, | ||
{Name: "Cocos (Keeling) Islands", Flag: "🇨🇨"}, | ||
{Name: "Colombia", Flag: "🇨🇴"}, | ||
{Name: "Comoros", Flag: "🇰🇲"}, | ||
{Name: "Congo", Flag: "🇨🇬"}, | ||
{Name: "Congo, the Democratic Republic of the", Flag: "🇨🇩"}, | ||
{Name: "Cook Islands", Flag: "🇨🇰"}, | ||
{Name: "Costa Rica", Flag: "🇨🇷"}, | ||
{Name: "Côte d'Ivoire", Flag: "🇨🇮"}, | ||
{Name: "Croatia", Flag: "🇭🇷"}, | ||
{Name: "Cuba", Flag: "🇨🇺"}, | ||
{Name: "Curaçao", Flag: "🇨🇼"}, | ||
{Name: "Cyprus", Flag: "🇨🇾"}, | ||
{Name: "Czech Republic", Flag: "🇨🇿"}, | ||
{Name: "Denmark", Flag: "🇩🇰"}, | ||
{Name: "Djibouti", Flag: "🇩🇯"}, | ||
{Name: "Dominica", Flag: "🇩🇲"}, | ||
{Name: "Dominican Republic", Flag: "🇩🇴"}, | ||
{Name: "Ecuador", Flag: "🇪🇨"}, | ||
{Name: "Egypt", Flag: "🇪🇬"}, | ||
{Name: "El Salvador", Flag: "🇸🇻"}, | ||
{Name: "Equatorial Guinea", Flag: "🇬🇶"}, | ||
{Name: "Eritrea", Flag: "🇪🇷"}, | ||
{Name: "Estonia", Flag: "🇪🇪"}, | ||
{Name: "Ethiopia", Flag: "🇪🇹"}, | ||
{Name: "Falkland Islands (Malvinas)", Flag: "🇫🇰"}, | ||
{Name: "Faroe Islands", Flag: "🇫🇴"}, | ||
{Name: "Fiji", Flag: "🇫🇯"}, | ||
{Name: "Finland", Flag: "🇫🇮"}, | ||
{Name: "France", Flag: "🇫🇷"}, | ||
{Name: "French Guiana", Flag: "🇬🇫"}, | ||
{Name: "French Polynesia", Flag: "🇵🇫"}, | ||
{Name: "French Southern Territories", Flag: "🇹🇫"}, | ||
{Name: "Gabon", Flag: "🇬🇦"}, | ||
{Name: "Gambia", Flag: "🇬🇲"}, | ||
{Name: "Georgia", Flag: "🇬🇪"}, | ||
{Name: "Germany", Flag: "🇩🇪"}, | ||
{Name: "Ghana", Flag: "🇬🇭"}, | ||
{Name: "Gibraltar", Flag: "🇬🇮"}, | ||
{Name: "Greece", Flag: "🇬🇷"}, | ||
{Name: "Greenland", Flag: "🇬🇱"}, | ||
{Name: "Grenada", Flag: "🇬🇩"}, | ||
{Name: "Guadeloupe", Flag: "🇬🇵"}, | ||
{Name: "Guam", Flag: "🇬🇺"}, | ||
{Name: "Guatemala", Flag: "🇬🇹"}, | ||
{Name: "Guernsey", Flag: "🇬🇬"}, | ||
{Name: "Guinea", Flag: "🇬🇳"}, | ||
{Name: "Guinea-Bissau", Flag: "🇬🇼"}, | ||
{Name: "Guyana", Flag: "🇬🇾"}, | ||
{Name: "Haiti", Flag: "🇭🇹"}, | ||
{Name: "Heard Island and McDonald Islands", Flag: "🇭🇲"}, | ||
{Name: "Holy See (Vatican City State)", Flag: "🇻🇦"}, | ||
{Name: "Honduras", Flag: "🇭🇳"}, | ||
{Name: "Hong Kong", Flag: "🇭🇰"}, | ||
{Name: "Hungary", Flag: "🇭🇺"}, | ||
{Name: "Iceland", Flag: "🇮🇸"}, | ||
{Name: "India", Flag: "🇮🇳"}, | ||
{Name: "Indonesia", Flag: "🇮🇩"}, | ||
{Name: "Iran, Islamic Republic of", Flag: "🇮🇷"}, | ||
{Name: "Iraq", Flag: "🇮🇶"}, | ||
{Name: "Ireland", Flag: "🇮🇪"}, | ||
{Name: "Isle of Man", Flag: "🇮🇲"}, | ||
{Name: "Israel", Flag: "🇮🇱"}, | ||
{Name: "Italy", Flag: "🇮🇹"}, | ||
{Name: "Jamaica", Flag: "🇯🇲"}, | ||
{Name: "Japan", Flag: "🇯🇵"}, | ||
{Name: "Jersey", Flag: "🇯🇪"}, | ||
{Name: "Jordan", Flag: "🇯🇴"}, | ||
{Name: "Kazakhstan", Flag: "🇰🇿"}, | ||
{Name: "Kenya", Flag: "🇰🇪"}, | ||
{Name: "Kiribati", Flag: "🇰🇮"}, | ||
{Name: "Korea, Democratic People's Republic of", Flag: "🇰🇵"}, | ||
{Name: "Korea, Republic of", Flag: "🇰🇷"}, | ||
{Name: "Kuwait", Flag: "🇰🇼"}, | ||
{Name: "Kyrgyzstan", Flag: "🇰🇬"}, | ||
{Name: "Lao People's Democratic Republic", Flag: "🇱🇦"}, | ||
{Name: "Latvia", Flag: "🇱🇻"}, | ||
{Name: "Lebanon", Flag: "🇱🇧"}, | ||
{Name: "Lesotho", Flag: "🇱🇸"}, | ||
{Name: "Liberia", Flag: "🇱🇷"}, | ||
{Name: "Libya", Flag: "🇱🇾"}, | ||
{Name: "Liechtenstein", Flag: "🇱🇮"}, | ||
{Name: "Lithuania", Flag: "🇱🇹"}, | ||
{Name: "Luxembourg", Flag: "🇱🇺"}, | ||
{Name: "Macao", Flag: "🇲🇴"}, | ||
{Name: "Macedonia, the Former Yugoslav Republic of", Flag: "🇲🇰"}, | ||
{Name: "Madagascar", Flag: "🇲🇬"}, | ||
{Name: "Malawi", Flag: "🇲🇼"}, | ||
{Name: "Malaysia", Flag: "🇲🇾"}, | ||
{Name: "Maldives", Flag: "🇲🇻"}, | ||
{Name: "Mali", Flag: "🇲🇱"}, | ||
{Name: "Malta", Flag: "🇲🇹"}, | ||
{Name: "Marshall Islands", Flag: "🇲🇭"}, | ||
{Name: "Martinique", Flag: "🇲🇶"}, | ||
{Name: "Mauritania", Flag: "🇲🇷"}, | ||
{Name: "Mauritius", Flag: "🇲🇺"}, | ||
{Name: "Mayotte", Flag: "🇾🇹"}, | ||
{Name: "Mexico", Flag: "🇲🇽"}, | ||
{Name: "Micronesia, Federated States of", Flag: "🇫🇲"}, | ||
{Name: "Moldova, Republic of", Flag: "🇲🇩"}, | ||
{Name: "Monaco", Flag: "🇲🇨"}, | ||
{Name: "Mongolia", Flag: "🇲🇳"}, | ||
{Name: "Montenegro", Flag: "🇲🇪"}, | ||
{Name: "Montserrat", Flag: "🇲🇸"}, | ||
{Name: "Morocco", Flag: "🇲🇦"}, | ||
{Name: "Mozambique", Flag: "🇲🇿"}, | ||
{Name: "Myanmar", Flag: "🇲🇲"}, | ||
{Name: "Namibia", Flag: "🇳🇦"}, | ||
{Name: "Nauru", Flag: "🇳🇷"}, | ||
{Name: "Nepal", Flag: "🇳🇵"}, | ||
{Name: "Netherlands", Flag: "🇳🇱"}, | ||
{Name: "New Caledonia", Flag: "🇳🇨"}, | ||
{Name: "New Zealand", Flag: "🇳🇿"}, | ||
{Name: "Nicaragua", Flag: "🇳🇮"}, | ||
{Name: "Niger", Flag: "🇳🇪"}, | ||
{Name: "Nigeria", Flag: "🇳🇬"}, | ||
{Name: "Niue", Flag: "🇳🇺"}, | ||
{Name: "Norfolk Island", Flag: "🇳🇫"}, | ||
{Name: "Northern Mariana Islands", Flag: "🇲🇵"}, | ||
{Name: "Norway", Flag: "🇳🇴"}, | ||
{Name: "Oman", Flag: "🇴🇲"}, | ||
{Name: "Pakistan", Flag: "🇵🇰"}, | ||
{Name: "Palau", Flag: "🇵🇼"}, | ||
{Name: "Palestine, State of", Flag: "🇵🇸"}, | ||
{Name: "Panama", Flag: "🇵🇦"}, | ||
{Name: "Papua New Guinea", Flag: "🇵🇬"}, | ||
{Name: "Paraguay", Flag: "🇵🇾"}, | ||
{Name: "Peru", Flag: "🇵🇪"}, | ||
{Name: "Philippines", Flag: "🇵🇭"}, | ||
{Name: "Pitcairn", Flag: "🇵🇳"}, | ||
{Name: "Poland", Flag: "🇵🇱"}, | ||
{Name: "Portugal", Flag: "🇵🇹"}, | ||
{Name: "Puerto Rico", Flag: "🇵🇷"}, | ||
{Name: "Qatar", Flag: "🇶🇦"}, | ||
{Name: "Réunion", Flag: "🇷🇪"}, | ||
{Name: "Romania", Flag: "🇷🇴"}, | ||
{Name: "Russian Federation", Flag: "🇷🇺"}, | ||
{Name: "Rwanda", Flag: "🇷🇼"}, | ||
{Name: "Saint Barthélemy", Flag: "🇧🇱"}, | ||
{Name: "Saint Helena, Ascension and Tristan da Cunha", Flag: "🇸🇭"}, | ||
{Name: "Saint Kitts and Nevis", Flag: "🇰🇳"}, | ||
{Name: "Saint Lucia", Flag: "🇱🇨"}, | ||
{Name: "Saint Martin (French part)", Flag: "🇲🇫"}, | ||
{Name: "Saint Pierre and Miquelon", Flag: "🇵🇲"}, | ||
{Name: "Saint Vincent and the Grenadines", Flag: "🇻🇨"}, | ||
{Name: "Samoa", Flag: "🇼🇸"}, | ||
{Name: "San Marino", Flag: "🇸🇲"}, | ||
{Name: "Sao Tome and Principe", Flag: "🇸🇹"}, | ||
{Name: "Saudi Arabia", Flag: "🇸🇦"}, | ||
{Name: "Senegal", Flag: "🇸🇳"}, | ||
{Name: "Serbia", Flag: "🇷🇸"}, | ||
{Name: "Seychelles", Flag: "🇸🇨"}, | ||
{Name: "Sierra Leone", Flag: "🇸🇱"}, | ||
{Name: "Singapore", Flag: "🇸🇬"}, | ||
{Name: "Sint Maarten (Dutch part)", Flag: "🇸🇽"}, | ||
{Name: "Slovakia", Flag: "🇸🇰"}, | ||
{Name: "Slovenia", Flag: "🇸🇮"}, | ||
{Name: "Solomon Islands", Flag: "🇸🇧"}, | ||
{Name: "Somalia", Flag: "🇸🇴"}, | ||
{Name: "South Africa", Flag: "🇿🇦"}, | ||
{Name: "South Georgia and the South Sandwich Islands", Flag: "🇬🇸"}, | ||
{Name: "South Sudan", Flag: "🇸🇸"}, | ||
{Name: "Spain", Flag: "🇪🇸"}, | ||
{Name: "Sri Lanka", Flag: "🇱🇰"}, | ||
{Name: "Sudan", Flag: "🇸🇩"}, | ||
{Name: "Suriname", Flag: "🇸🇷"}, | ||
{Name: "Svalbard and Jan Mayen", Flag: "🇸🇯"}, | ||
{Name: "Swaziland", Flag: "🇸🇿"}, | ||
{Name: "Sweden", Flag: "🇸🇪"}, | ||
{Name: "Switzerland", Flag: "🇨🇭"}, | ||
{Name: "Syrian Arab Republic", Flag: "🇸🇾"}, | ||
{Name: "Taiwan, Province of China", Flag: "🇹🇼"}, | ||
{Name: "Tajikistan", Flag: "🇹🇯"}, | ||
{Name: "Tanzania, United Republic of", Flag: "🇹🇿"}, | ||
{Name: "Thailand", Flag: "🇹🇭"}, | ||
{Name: "Timor-Leste", Flag: "🇹🇱"}, | ||
{Name: "Togo", Flag: "🇹🇬"}, | ||
{Name: "Tokelau", Flag: "🇹🇰"}, | ||
{Name: "Tonga", Flag: "🇹🇴"}, | ||
{Name: "Trinidad and Tobago", Flag: "🇹🇹"}, | ||
{Name: "Tunisia", Flag: "🇹🇳"}, | ||
{Name: "Turkey", Flag: "🇹🇷"}, | ||
{Name: "Turkmenistan", Flag: "🇹🇲"}, | ||
{Name: "Turks and Caicos Islands", Flag: "🇹🇨"}, | ||
{Name: "Tuvalu", Flag: "🇹🇻"}, | ||
{Name: "Uganda", Flag: "🇺🇬"}, | ||
{Name: "Ukraine", Flag: "🇺🇦"}, | ||
{Name: "United Arab Emirates", Flag: "🇦🇪"}, | ||
{Name: "United Kingdom", Flag: "🇬🇧"}, | ||
{Name: "United States", Flag: "🇺🇸"}, | ||
{Name: "United States Minor Outlying Islands", Flag: "🇺🇲"}, | ||
{Name: "Uruguay", Flag: "🇺🇾"}, | ||
{Name: "Uzbekistan", Flag: "🇺🇿"}, | ||
{Name: "Vanuatu", Flag: "🇻🇺"}, | ||
{Name: "Venezuela, Bolivarian Republic of", Flag: "🇻🇪"}, | ||
{Name: "Vietnam", Flag: "🇻🇳"}, | ||
{Name: "Virgin Islands, British", Flag: "🇻🇬"}, | ||
{Name: "Virgin Islands, U.S.", Flag: "🇻🇮"}, | ||
{Name: "Wallis and Futuna", Flag: "🇼🇫"}, | ||
{Name: "Western Sahara", Flag: "🇪🇭"}, | ||
{Name: "Yemen", Flag: "🇾🇪"}, | ||
{Name: "Zambia", Flag: "🇿🇲"}, | ||
{Name: "Zimbabwe", Flag: "🇿🇼"}, | ||
} | ||
|
||
// @typescript-ignore Country | ||
type Country struct { | ||
Name string `json:"name"` | ||
Flag string `json:"flag"` | ||
} |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To do this correctly, we should not have to specify
codersdk.Countries
. We should implement it here:coder/scripts/apitypings/main.go
Lines 458 to 459 in afacb07
I feel a bit apprehensive to import
codersdk
into this tool.We could make it a new generator (:cry:) or actually auto-gen vars from the codersdk package (like
codersdk.Me
).If we do the
vars
, we might want to have some opt-in comment. Idk how many var declarations we haveThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should really have a general autogen tool and pattern for these. When the types are in Go and no package AST parsing is necessary.
rbacgen
is an example.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Emyrk
got it, will implement a general autogen tool. As suggested, I'm thinking of doing it similar to how
rbacgen
is done.So the autogen tool will be under
scripts/valuegen
which containsmain.go
which is the script itself andtypescript.tstmpl
which will be the TS template to which we will convert thecountries.go
coder/codersdk/countries.go
Line 3 in 1702c64
If similar types conversion needs are needed in the future for other types in Go, it can be handled in the script to use the same
typescriptconst.tstmpl
template or a different one based on the need.does that make sense? wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joobisb That all sounds reasonable. It'll probably throw into a different
.ts
file.It would be awesome if
rbacgen
andvaluegen
could be merged into 1 😄There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Emyrk I have updated the scripts and have merged both into a single
typegen
script, please do have a look