hard-way.mdx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. ---
  2. sidebar_position: 3
  3. ---
  4. # ⌨ The hackerman way
  5. :::caution WIP
  6. Guide is mostly complete, but some minute details are missing at the moment.
  7. There is also a lack of consistency in the usage of inline code blocks vs emboldening text that should probably be resolved At Some Point™
  8. :::
  9. Unless you suffer from programmer brain, contributing to the wiki is unfortunately not a very straight forward process. It requires the use of a handful of tools that are made by programmers, for programmers, which makes them a bit of a pain to setup and use for the average person.
  10. :::info
  11. The goal of this contribution guide is to walk you through the entire process step-by-step, while attempting to explain the tools you will be using so you (hopefully) don't feel like you're blindly installing random programs.
  12. :::
  13. ## First steps on GitHub
  14. Since the source code for this wiki is hosted on GitHub, that's where our first few steps begin.
  15. ## The tools you'll need (and why)
  16. - [GitHub Desktop](https://desktop.github.com)
  17. - [NodeJS](https://nodejs.org/en)
  18. - [Visual Studio Code](https://code.visualstudio.com/)
  19. ...ok but like why?
  20. ### Git
  21. **Git** is the tool that enables us to collaborate on this wiki. It lets us save a version history of all our files and sync the changes we make locally to the central repository that's hosted on GitHub. We'll talk more about *how* to use Git and how it works in the chapter about making your changes. For now, let's just focus on getting it set up.
  22. What makes Git a little confusing is that there are a lot of different versions out there. [The OG Git](https://git-scm.com) is actually just a command-line tool, meaning you open up a terminal, type in `git` followed by some commands that tell the program what you want it to do.
  23. ![](img/gitcli.jpg)
  24. And while that's great for a lot of programmers, it's terribly unusable for literally everyone else. That's why third parties have brought it upon themselves to create their own Git clients that actually look like apps that humans might use. For this guide we'll be using [GitHub Desktop](https://desktop.github.com) because it integrates quite smoothly with GitHub itself, which is where we host the source code for this wiki.
  25. :::note
  26. You can of course use other Git clients like [Sublime Merge](https://www.sublimemerge.com/) or [GitKraken](https://www.gitkraken.com/), or even the original [Git](https://git-scm.com) if you hate yourself. They will all do what you need them to do, because we will only be using the *very* fundamental features of Git.
  27. :::
  28. Upon opening GitHub Desktop for the first time, you might get prompted to connect your GitHub Account with the app. If you not, you can do so manually via File > Options, then you should see the 'Sign In' button right at the top of the Accounts tab.
  29. ![](img/ghdoptions.jpg) ![](img/ghdaccounts.jpg)
  30. What we want to do now is `fork` the main repository and then `clone` it onto our local drive.
  31. :::note
  32. You don't actually have to fork the repository first because GitHub Desktop has a button for forking the repo if you try to commit changes to a repository you don't have write access to, but as I (aciidz) have write access to the wiki repository, I can't properly take screenshots of the process in GitHub Desktop without creating another GitHub account, which I'm not about to do for this tutorial. If you're reading this guide and want to fork it from GitHub Desktop, I have full faith that you can figure it out on your own.
  33. :::
  34. So, how to fork the repository: head over to the wiki's repository on GitHub and click the Fork button in the top right as pictured below.
  35. ![](img/ghfork.jpg)
  36. This will take you to a new screen where you can change the name and description if you like.
  37. ![](img/ghconfirmfork.jpg)
  38. You'll probably want to leave the checkbox labeled 'Copy the `master` branch only' ticked, but you are doing no harm either way. Unticking it just means that you're also copying over any other branches we may have made that you probably don't need.
  39. Once you've hit the green button, the fork will be created, and you can now `clone` it.
  40. At the top left of GitHub Desktop, click `File` and then select 'Clone a repository'.
  41. ![](img/ghdcloning1.jpg)
  42. Then, click on the `URL` tab and put `INSERTYOURUSERNAMEHERE/l4dsr-wiki` in the `URL` field, and then click the blue `Clone` button. **In case it is not obvious, replace `INSERTYOURUSERNAMEHERE` with the username of your GitHub account.**
  43. ![](img/ghdcloning2.jpg)
  44. GitHub Desktop will now ask you whether you are planning to use the fork to contribute back to the original project, or for your own purposes. You will want to select `To contribute to the parent project`.
  45. ![](img/ghdforksettings.jpg)
  46. With this done, you can now move on to installing NodeJS.
  47. ### NodeJS
  48. **Node** is . . .
  49. :::caution TODO
  50. explain what node is
  51. :::
  52. The minimum version of NodeJS required to work on this project is 18.0, but I'm currently using 21.x at the time of writing (December 19th 2023).
  53. :::tip
  54. When installing, you don't need to check the box that says something relating to Visual Studio build tools and Chocolatey. (I am too lazy to go find out what it says lol sorry)
  55. :::
  56. After you've installed, open the repo in GitHub Desktop, and click the "Open in Command Prompt" button. You can also navigate to the folder in file explorer, click into the address bar to where you can type, write `cmd`, and hit enter.
  57. Once you have the command prompt open in the repo folder, write `npm install --force`. It will give you some warnings about vulnerabilties - ignore it, this is caused by `mdx-embed` requiring outdated deps, hopefully at some point it will get updated (at which point using `--force` will no longer be necessary).
  58. Once that finishes, you can write `npm start` and hit enter. The site will now compile and a web server will start (& it will open the site in your web browser). Now, any time you save any changes to a file, the site will automatically reload with your changes.
  59. If you want to stop the web server, simply hit ctrl+c and press enter. When you want to start working again, you can simply run `npm start` again.
  60. ### Visual Studio Code (or your preferred text editor with markdown syntax highlighting)
  61. **Visual Studio Code** (henceforth referred to as VSCode) is a multi-platform text editor/IDE from Microsoft that has native support for many programming languages, and through the extension marketplace, it has support for just about anything you could ever want.
  62. It also has lots of useful features, including Git integration, which means you can very easily visualize what changes you've made since the last commit in real time. You can also do pretty much everything you'd need to do with Git entirely within VSCode itself.
  63. VSCode also has native integration with Node, so, for example, any mistakes you make that might cause the site to fail to compile will appear inline in the editor (though my experience with this has been buggy at best, e.g. I make a mistake, fix it, but VSCode fails to recognize the problem was fixed).
  64. As I have no motivation to completely reinstall VSCode for the purpose of writing this guide, I will assume you can work through installing it yourself without my assistance.
  65. :::caution
  66. After installing VSCode, you do have one (minor) problem to solve, which is that VSCode doesn't natively support syntax highlighting for MDX files. You have two options for dealing with this:
  67. :::
  68. 1. Install the MDX extension
  69. 1. Click the 5th icon on the left ("Extensions")
  70. 2. Search for `unifiedjs.vscode-mdx` and install it (it should be(?) the most popular extension for MDX).
  71. 2. Alternatively, tell VSCode to just use normal Markdown syntax highlighting for all MDX files
  72. 1. Open a MDX file
  73. 2. Click `Plain Text` in the bottom right
  74. 3. Click `Configure File Association for '.mdx'...`
  75. 4. Type in Markdown and select it
  76. Being honest, I don't know how much tangible benefit there is to installing the extension over just defaulting mdx to use markdown syntax highlighting, so it's whatever lol
  77. #### Opening the repo in VSCode
  78. The easiest way to open the repo in VSCode is by clicking the `Repository` button at the top of GitHub Desktop, and clicking `Open in Visual Studio Code`.
  79. ![](img/ghdopeningrepoinvsc.jpg)
  80. :::tip
  81. If the option to open it in VSCode is not present, you will have to tell GitHub Desktop to use VSCode by going to `File` > `Options` > `Integrations` > `External Editor` (set to Visual Studio Code)
  82. :::
  83. Alternatively, open VSCode, click the `File` button in the top left, click `Open Folder`, navigate to the location of the repo on your computer, and select that folder.
  84. ## Making changes
  85. Insert your finest shitposts, save the file, bruh momentum
  86. :::caution todo
  87. maybe talk about working in branches here, and perhaps there is other things worth covering here, TBD
  88. :::
  89. ## Committing changes
  90. Once you have some changes you want to commit, you'll see them in GitHub Desktop. For example:
  91. ![](img/ghdchanges1.jpg)
  92. :::caution
  93. Anything that is checked on the left will be included in the commit. Any files you don't want to include in a commit shouldn't be checked. Additionally, if you only want to commit some of the changes you've made in a given file, see the next heading.
  94. :::
  95. From here, you can type in a commit title and a description. In the title, try to explain what you did in 50 characters or less (if you go over, it's not the end of the world). If you want to be nice to people using Git in a terminal, don't let lines in your description exceed 72 characters, but again, this is also ultimately not that important. Focus on writing useful information instead.
  96. Once you click the commit button, the commit will then appear in the `History` tab.
  97. ### Splitting multiple changes from a single file across multiple commits
  98. Sometimes you might make multiple unrelated changes in a single file that you don't want to lump together into one commit.
  99. For example, in the image below, I only want to include the line about Namazaki in the current commit:
  100. ![](img/ghdsplittingcommit1.jpg)
  101. So, to achieve this, you simply click the blue area next to the line you want to deselect.
  102. ![](img/ghdsplittingcommit2.jpg)
  103. After that, the area next to the line will be green, which means it is deselected and won't be included in the next commit you make.
  104. ![](img/ghdsplittingcommit3.jpg)
  105. ### Undoing commits
  106. Sometimes you might make a shitty commit that you don't like or made a mistake in. If you haven't pushed your changes to GitHub, it's very easy to undo them. Simply open the `History` tab, right click on the latest commit, and click `undo`, which will return the changes to the staging area, where you are then free to do as you wish.
  107. If you've already pushed the commits to GitHub, it gets a little more complicated. For now, if this happens, feel free to DM me (aciidz) and I can walk you through it.
  108. :::caution todo
  109. explain this rather than directing people to my DMs lol
  110. :::
  111. ## Pushing commits
  112. Once you're happy with your commit(s), you'll need to `push` them to GitHub in order to be able to open a pull request (or let anyone else see the commits in the first place). Up to this point, everything you've done is local to your computer. In essence, when you push a commit, you are syncing the state of the repo on your computer to GitHub.
  113. To push a commit, simply press this button at the top of GitHub Desktop.
  114. ![](img/ghdpush.jpg)
  115. ## Opening a pull request
  116. Home stretch! This is the final step in the process. The pull request is now the formal step where you make a **request** to the maintainer of the main repository to **pull** the changes you've made on your fork onto the main repository.
  117. To open a pull request, go to the main page of your repository (`github.com/<yourname>/l4dsr-wiki`) and check to see if this bar shows up that reads "This branch is `xyz` commit(s) ahead of l4dsr:master". If you don't see this, that means that you haven't made a commit to your own repository yet.
  118. Click on the dropdown labeled "Contribute" and then on "Open pull request".
  119. ![](img/ghopenpr.jpg)
  120. This will take you to the final page, where you can edit the title of the pull request or add extra comments if you'd like. Then all that's left is to click the big green button labeled "Create pull request".
  121. The main repository will do some automatic checks to see if the site will compile properly. If any checks fail, that's usually a skill issue on my end, so you don't need to worry that you actually broke something.
  122. Congrats, you made it to the end 💀
  123. **If there's anything unclear, confusing, etc. please feel free to message me (aciidz) on Discord with suggestions.**
  124. ## Syncing your repo once changes are merged
  125. So, once your pull request is merged, your repo will fall out of sync with the main repo.
  126. For example, it'll say something like this:
  127. ![](img/ghoutofsync.jpg)
  128. There are a variety of ways to resolve this, but it's simplest to do this through GitHub.
  129. First, click the dropdown. You now have two choices. In most cases, assuming everything you have on the branch has been merged into the main repo, it is preferred (and safe) to click `Discard x commit(s)`. If you have work you want to preserve, you should click `Update branch` instead.
  130. ![](img/ghsyncfork.jpg)
  131. The reason that `Discard x commit(s)` is preferred is that it avoids creating ugly merge commits that ultimately serve no logical purpose for a fork.
  132. The alternative to a merge commit is to `rebase` your changes on top of the actual repo, but I'm not really familiar with how to do this in GitHub Desktop (I'm used to doing this in commandline Git).
  133. :::caution todo
  134. I'll try to write a tutorial for this later.
  135. :::
  136. In general, I would suggest making a new branch whenever you want to make some new changes. After a PR is merged, you can delete the branch the commits originated from and forget about needing to resolve merge conflicts and such on your own.