ObieSource / obiesource.github.io

The ObieSource Website. Project Leader: Ajai Nelson
https://obiesource.github.io/
2 stars 22 forks source link

Add Prettier to subroutine #18

Closed iosenberg closed 2 years ago

iosenberg commented 2 years ago

pls

iosenberg commented 2 years ago

I fucked up the commits, so this is no longer about updating my info and is now about adding Prettier as a subroutine lol

iosenberg commented 2 years ago

@wknowleskellett Reformatted the code parts so the weird spacing should be fixed now

AjaiKN commented 2 years ago

People usually add the node_modules directory to .gitignore. The package.json and package-lock.json should be enough to recreate the node_modules directory using the npm install command.

AjaiKN commented 2 years ago

Actually, it looks like the package-lock.json doesn't match the package.json. I'm not sure how that would have happened. It also looks like the package-lock.json was created using an old version of npm.

iosenberg commented 2 years ago

@Aurelius333 I can add node_modules to the .gitignore pretty easily. Would that require everyone who forks the repository to also run the npm install command then? Also package-lock.json and package.json probably don't match because I wrote package.json and I don't know what I'm doing lol. Am I required to have two separate docs? or can I just add the info in package.json to the "husky" section of package-lock.json? Not sure what to do about the out of date version either. This is the what was included in the most recent version of Prettier.

AjaiKN commented 2 years ago

I can add node_modules to the .gitignore pretty easily. Would that require everyone who forks the repository to also run the npm install command then?

Yes, they would have to do that to run prettier, but I think they would have to do that anyway to get the git pre-commit hooks to install.

Not sure what to do about the out of date version either. This is the what was included in the most recent version of Prettier.

npm is a package manager, so you use npm to install Prettier, not the other way around.

Also package-lock.json and package.json probably don't match because I wrote package.json and I don't know what I'm doing lol. Am I required to have two separate docs? or can I just add the info in package.json to the "husky" section of package-lock.json?

The idea is that you list what packages you want in your package.json. For example, it might be that you want version 2 of prettier. It doesn't matter to you whether it's version 2.1.0, 2.7.1, or whatever, you just want anything that's part of prettier version 2.

Then, you run npm install. When you do that, npm puts a ridiculous amount of stuff into node_modules. You don't generally commit node_modules because it's huge and creates ridiculous git diffs.

And when you run npm install, npm also automatically creates package-lock.json. That file shows the exact versions of every package, including all the dependencies of your dependencies. So even though you only care about prettier being version 2, package-lock.json records the fact that you have version 2.7.1. You should commit package-lock.json because then, when I run npm install, it'll see the package-json.lock, and I'll get the exact same versions that you have (in order to avoid inconsistencies between us). You shouldn't ever modify the package-lock.json yourself; npm will automatically update it for you.

So you should probably start from scratch by doing something like this:

  1. Update npm if it's not already updated (https://docs.npmjs.com/try-the-latest-stable-version-of-npm)
  2. Delete package-lock.json, since it somehow got out of date.
  3. Run npm install prettier. That'll add prettier to your package.json and also to your package-lock.json.
  4. If there are other packages you need (like husky), run npm install husky or whatever.

I hope that made a little sense. npm can be pretty confusing at first, so it might be easier to just wait until the next meeting.

Also, I think we'll probably want to add Prettier to our GitHub Actions.

iosenberg commented 2 years ago

Remade pull request in a way that works. Closing the cringe one.