-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[NO QA] Call Web-E API to get temporary token in Mapbox setup script #25545
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
Conversation
.eslintignore
Outdated
| **/node_modules/* | ||
| **/dist/* | ||
| .github/actions/**/index.js" | ||
| /scripts/** No newline at end of file |
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.
Do we need to ignore this script? Since its written in TS, it makes sense to lint it as well.
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.
I think because these are node scripts and have different requirements/environment so existing ESLint rules might not make sense so I decided to exclude them from linting for now
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.
I don't think we should ignore them. Node scripts are just like any other JS script and the same formatting and styles should apply to them. We've seen this in the GitHub actions as well. It makes sense that JS code everywhere is consistent, regardless of the platform it's running on.
package.json
Outdated
| "@vercel/ncc": "^0.27.0", | ||
| "@welldone-software/why-did-you-render": "7.0.1", | ||
| "ajv-cli": "^5.0.0", | ||
| "axios": "^1.4.0", |
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.
For a simple call like this plain fetch should be sufficient. No?
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.
ah I didn't know fetch exits in node run time. trying to see if fetch works
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.
You'll need a pollyfill. Ignore this if it requires too much work to add a polyfill!
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.
hayatasuenaga@Hayatas-Work-MBP App % npm run configure-mapbox
> new.expensify@1.3.55-7 configure-mapbox
> ts-node scripts/setup-mapbox-sdk-local.ts
Error: fetch is not defined
Fetch API was apparently introduced in Node 17. App repo somehow still uses node 16 (see the engines field in package.json) 😭 so fetch is not available.
ts-node uses the node that is active in the current terminal session, which is node 16 in the App repo
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.
The other option is to use https module from node but the syntax is kind of verbose (even considering that we only need to make one API call). So, I'm thinking of sticking with axios. What do you think @allroundexperts
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.
Since there is only one API call, I think using https is fine. Yes, it's more verbose, but adding this package just to make one API call is overkill.
scripts/setup-mapbox-sdk.ts
Outdated
|
|
||
| async function main(): Promise<void> { | ||
| try { | ||
| const response = await axios.get(TOKEN_ENDPOINT); |
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.
Since we're doing this in TS, how about typing the response as well?
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.
I'm actually not a huge fun of typing API responses. I like leaving response values as any or undefined to do type narrowing.
I made a change in this commit to add type checking for type narrowing: 5497523
allroundexperts
left a comment
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.
Great job @hayata-suenaga 🎖️ 🎖️ 🎖️
Requested some minor changes.
Reviewer Checklist
Screenshots/VideosWebMobile Web - ChromeMobile Web - SafariDesktopiOSAndroid |
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.
Looking good in terms of Typescript! 💯
|
For this build failure, I apparently selected a wrong branch. I'm re-running the test build with the correct branch here |
|
okay the test builds succeeded 🚀 |
fabioh8010
left a comment
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.
LGTM!
|
Re-running test builds here: https://github.com/Expensify/App/actions/runs/5933032590 |
|
🧪🧪 Use the links below to test this build in android and iOS. Happy testing! 🧪🧪
|
NOTE for myselfFix this: https://expensify.slack.com/archives/C03TQ48KC/p1692745804074509 |
.eslintignore
Outdated
| **/node_modules/* | ||
| **/dist/* | ||
| .github/actions/**/index.js" | ||
| /scripts/** No newline at end of file |
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.
I don't think we should ignore them. Node scripts are just like any other JS script and the same formatting and styles should apply to them. We've seen this in the GitHub actions as well. It makes sense that JS code everywhere is consistent, regardless of the platform it's running on.
package.json
Outdated
| "@vercel/ncc": "^0.27.0", | ||
| "@welldone-software/why-did-you-render": "7.0.1", | ||
| "ajv-cli": "^5.0.0", | ||
| "axios": "^1.4.0", |
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.
Since there is only one API call, I think using https is fine. Yes, it's more verbose, but adding this package just to make one API call is overkill.
|
By the way, this is expected because the new Web-E API command hasn't been deployed yet. |
|
@hayata-suenaga Is this ready for review again? It looks like there are a couple of conflicts. |
|
bump on merge conflicts |
|
thank you for reminding me @grgia we're currently treating this as lower priority so I gonna go back to this PR later this week 🙇 |
|
Changing the priority to LOW because this is not a necessity right now. This mostly improves the setup that new contributors need to do. Because this PR will affect the build process, we want to be sure before merge |
|
@hayata-suenaga What is the plan for this? Should the PR just be closed? |
|
I was originally planning to resume working on and merge this after Money2020 I don't know how much we need this PR. I think it's still nice to have feature. What do you think @tgolen ? |
|
I think I would just close this. If anyone feels it is painful enough to solve, we can reopen at a later time. |
|
according to this comment, I'm closing this for now. |
|
@hayata-suenaga I might be eligible for partial compensation here as I did a review. |
|
sure I'm sorry that I didn't realize that. Asked for the payment to you here |
@neil-marcellini @tgolen
cc: @fabioh8010 @blazejkustra because this PR involves TypeScript code
Details
Most of the context behind this PR is covered in the issue description here.
This PR gets rid of existing bash scripts that I added in this PR. These bash scripts helped contributors
Fixed Issues
$ https://github.com/Expensify/Expensify/issues/309451 (for calling a Web-E endpoint)
$ #25442 (for re-writing bash scripts in node/typescript)
Tests
For engineers:
Check out the branch
hayata-change-mapbox-setup-scriptChange this line as below:
You can skip this step if this issue is closed and both this PR and this PR are merged. Otherwise, this step ensures that the script calls a mock API that I set up temporarily to simulate the response that will be returned once new API command in Web-E is deployed.
Run
npm run configure-mapboxOpen
~/.netrcand confirm that the file includes the content below:Open
~/.gradle/gradle.propertiesand confirm that the file includes the content below:Repeat steps 3 ~ 5 and confirm that there isn't a duplicate entry in
.netrcandgradle.propertiesPR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodWaiting for Copylabel for a copy review on the original GH to get the correct copy.STYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)/** comment above it */thisproperly so there are no scoping issues (i.e. foronClick={this.submit}the methodthis.submitshould be bound tothisin the constructor)thisare necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);ifthis.submitis never passed to a component event handler likeonClick)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Web
Mobile Web - Chrome
Mobile Web - Safari
Desktop
iOS
Android