-
Notifications
You must be signed in to change notification settings - Fork 0
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
add basic code to generate the login button #2
Conversation
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.
Took a quick look at code, now going to test it out. A few small comments about setup stuff.
Suggestion: Currently it's not really clear what version of yarn
is being used. The github action uses yarn 1.22.
My suggestion would be to use yarn 4:
- add a nvmrc for Node 20
- after activating,
corepack enable
- run
yarn init -2
- Check the .yarn/ folder.
yarn 4
has some nice improvements IMO. In particular, we no longer need to store the yarn binary. Also, we get node_modules installation by default rather than their other form of package installation. - The one downside to
yarn 4
that I am aware of is that it is a little awkward in github actions. For you moment, I believe you need to do this. Note theSKIP_YARN_COREPACK_CHECK
andcorepack enable
. See also Corepack Support actions/setup-node#531 (comment)
- Check the .yarn/ folder.
index.js
Outdated
) { | ||
const container = document.getElementById(containerId) | ||
const parsedBaseUrl = new URL(baseUrl) | ||
const reconstructedBaseUrl = `${parsedBaseUrl.protocol}//${parsedBaseUrl.hostname}${parsedBaseUrl.port !== "" ? `:${parsedBaseUrl.port}` : ""}` |
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.
Is this the same as parsedBaseUrl.origin
?
package.json
Outdated
"scripts": { | ||
"lint": "eslint './**/*.{js,jsx,ts,tsx}'", | ||
"fmt": "yarn fmt:check --write", | ||
"fmt:check": "LOG_LEVEL= prettier-eslint --list-different './**/*.{js,jsx,ts,tsx,scss}'" |
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.
Strong Suggestion: Don't use prettier-eslint
. Just use eslint, and drop a .pre-commit-config.yaml
file in the 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.
👍 👍 Cool.
Up to you if/when you want to make those suggested changes.
package.json
Outdated
"eslint-plugin-react": "^7.33.2", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"typescript": "^5.3.3", | ||
"typescript-eslint": "^0.0.1-alpha.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.
you don't want this.
(Do you want any typescript right now?)
What are the relevant tickets?
Closes #1
Description (What does it do?)
This is the first PR for this library. First of all, it adds basic boilerplate linting / formatting / github actions CI config. The main purpose of this PR is to get started setting up the primary purpose of the library, which is to generate a login button pointing at an instance of
mit-open
. The library exports a function calledinitLoginButton
, which generates a login button pointing at a providedmit-open
instance and a simple text element showing who is logged in if you already are logged in.Screenshots (if appropriate):
How can this be tested?
mit-open
(https://github.com/mitodl/mit-open) on thecg/login-button-cors-settings
branch. Follow the instructions in themit-open
readme for initial setup, check out the branch and spin it up. You will need an account in your local instance for this to work.ocw-hugo-themes
(https://github.com/mitodl/ocw-hugo-themes) set up locally, running a course usingyarn start course
. Follow the readme there for basic setup instructions and make sure you can start up a course. After you have that working, check out thecg/add-mit-open-login-button
branch. Assuming you have cloned this repo, runyarn add /path/to/mit-open-login-button
to add your local copy of the code for this to your locally runningocw-hugo-themes
. This is necessary because the package is not yet published to NPM.mit-open
mit-open
Logged in as: username
with your username in place ofusername
mit-open