|
| 1 | +# Contributing |
| 2 | + |
| 3 | +First off, thank you for taking the time to contribute to the Stacks ecosystem ❤️ |
| 4 | + |
| 5 | +> **Note** |
| 6 | +> The likelihood is high that the repo you are working on is either a Stack or Stacks itself. In both cases, you will be exposed to a meshup of technologies, like [Vue][vue], [Vite][vite], [Tauri][tauri], [Nitro][nitro], and [Bun][bun]. |
| 7 | +
|
| 8 | +## 💭 Knowledge |
| 9 | + |
| 10 | +### TypeScript |
| 11 | + |
| 12 | +It's important to note early on that these projects are written with [TypeScript][typescript]. If you're unfamiliar with it (or any strongly typed languages such as Java) then this may feel like a slight roadblock. However, there's never a truly perfect time to start learning it, so ... why not today using well-written codebases as your playground? |
| 13 | + |
| 14 | +_Don't be discouraged. You will get by learning TypeScript on-the-fly as you review some of the examples within the codebase. It's easy to get started—the code is, we hope, very approachable (and readable)._ |
| 15 | + |
| 16 | +### Architecture |
| 17 | + |
| 18 | +An understanding of the framework architecture and design will help if you're looking to contribute long-term, or if you are working on a "more complex" PR. Browse the source and read our documentation to get a better sense of how it is structured. The documentation is very thorough and can be used as your progressive guide as you're learning more about Stacks. |
| 19 | + |
| 20 | +Feel free to ask any question _(Twitter, Discord, or GitHub Discussions)_, we would love to elaborate & collaborate. |
| 21 | + |
| 22 | +### Stacks/Core Setup |
| 23 | + |
| 24 | +Are you interested in contributing to the Stacks codebase? |
| 25 | + |
| 26 | +**Working on your first Pull Request?** You can learn how from this free series [How to Contribute to an Open Source Project on GitHub][pr-beginner-series]. |
| 27 | + |
| 28 | +Head over to the [repository][stacks] on GitHub and click the Fork button in the top right corner. After the project has been forked, run the following commands in your terminal: |
| 29 | + |
| 30 | +```bash |
| 31 | +# Replace {github-username} with your GitHub username. |
| 32 | +git clone https://github.com/{github-username}/stacks --depth=1 |
| 33 | + |
| 34 | +cd stacks |
| 35 | + |
| 36 | +# Create a branch for your PR, replace {issue-no} with the GitHub issue number. |
| 37 | +git checkout -b issue-{issue-no} |
| 38 | +``` |
| 39 | + |
| 40 | +Now it'll help if we keep our `main` branch pointing at the original repository and make |
| 41 | +pull requests from the forked branch. |
| 42 | + |
| 43 | +```bash |
| 44 | +# Add the original repository as a "remote" called "upstream". |
| 45 | +git remote add upstream [email protected]:stacksjs/stacks.git |
| 46 | + |
| 47 | +# Fetch the git information from the remote. |
| 48 | +git fetch upstream |
| 49 | + |
| 50 | +# Set your local main branch to use the upstream main branch whenever you run `git pull`. |
| 51 | +git branch --set-upstream-to=upstream/main main |
| 52 | + |
| 53 | +# Run this when we want to update our version of main. |
| 54 | +git pull |
| 55 | +``` |
| 56 | + |
| 57 | +_You may also use GitHub Desktop or any other GUI—if that is your preference._ |
| 58 | + |
| 59 | +### Buddy Toolkit |
| 60 | + |
| 61 | +The following list of commands is one of the most common ways to interact with the Stacks API. Meet Buddy: |
| 62 | + |
| 63 | +```bash |
| 64 | +buddy install # installs all dependencies |
| 65 | +buddy dev # starts one of the dev servers (components, functions, views, desktop or docs) |
| 66 | +buddy build # follow CLI prompts to select which library (or server) to build |
| 67 | +buddy commit # follow CLI prompts for committing changes |
| 68 | +buddy release # creates the releases of the stack & consequently, publishes them (to npm) |
| 69 | +buddy upgrade # auto-update deps & the Stacks framework |
| 70 | + |
| 71 | +buddy make:component HelloWorld # scaffolds a component |
| 72 | +buddy make:function HelloWorld # scaffolds a function |
| 73 | +buddy make:page hello-world # scaffolds a page (https://my-project.test/hello-world) |
| 74 | + |
| 75 | +buddy help |
| 76 | +``` |
| 77 | + |
| 78 | +<details> |
| 79 | +<summary>View the complete Buddy Toolkit</summary> |
| 80 | + |
| 81 | +```bash |
| 82 | +buddy --help # view help menu |
| 83 | +buddy install # installs your dependencies |
| 84 | +buddy fresh # fresh reinstall of all deps |
| 85 | +buddy update # auto-update deps & the Stacks framework |
| 86 | + |
| 87 | +buddy --version # get the Stacks version |
| 88 | +buddy --help # view help menu |
| 89 | + |
| 90 | +# if you need any more info to any command listed here, you may suffix |
| 91 | +# any of them via the "help option", i.e. `buddy command --help` |
| 92 | + |
| 93 | +buddy dev # starts one of the dev servers (components, functions, views, or docs) |
| 94 | +buddy dev:components # starts local playground dev server |
| 95 | +buddy dev:desktop # starts the Desktop playground |
| 96 | +buddy dev:views # starts local playground views dev server |
| 97 | +buddy dev:functions # stubs local the functions |
| 98 | +buddy dev:docs # starts local docs dev server |
| 99 | + |
| 100 | +# for Laravel folks, `serve` may ring more familiar than the `dev` name. Hence, we aliased it: |
| 101 | +buddy serve # starts one of the dev servers (components, functions, viewsviews, or docs) |
| 102 | +buddy serve:components # starts local playground dev server |
| 103 | +buddy serve:views # starts local playground views dev server |
| 104 | +buddy serve:functions # stubs local the functions |
| 105 | +buddy serve:docs # starts local docs dev server |
| 106 | + |
| 107 | +# sets your application key |
| 108 | +buddy key:generate |
| 109 | + |
| 110 | +buddy make:stack project |
| 111 | +buddy make:component HelloWorld |
| 112 | +buddy make:function hello-world |
| 113 | +buddy make:page hello-world |
| 114 | +buddy make:lang de |
| 115 | +buddy make:database cars |
| 116 | +buddy make:table brands |
| 117 | +buddy make:migration create_cars_table |
| 118 | +buddy make:factory cars |
| 119 | + |
| 120 | +buddy lint # runs linter |
| 121 | +buddy lint:fix # runs linter and fixes issues |
| 122 | + |
| 123 | +buddy commit # follow CLI prompts for committing staged changes |
| 124 | +buddy release # creates the releases for the stack & triggers the Release Action (workflow) |
| 125 | +buddy changelog # generates CHANGELOG.md |
| 126 | + |
| 127 | +# building for production (e.g. npm, Vercel, Netlify, et al.) |
| 128 | +buddy build # select a specific build (follow CLI prompts) |
| 129 | +buddy build:components # builds Vue component library & Web Component library |
| 130 | +buddy build:functions # builds function library |
| 131 | +buddy build:vue-components # builds Vue 2 & 3-ready Component library |
| 132 | +buddy build:web-components # builds framework agnostic Web Component library (i.e. Custom Elements) |
| 133 | +buddy build:views # builds views |
| 134 | + |
| 135 | +# when deploying your app/s |
| 136 | +buddy deploy:docs |
| 137 | +buddy deploy:functions |
| 138 | +buddy deploy:views |
| 139 | + |
| 140 | +# select the example to run (follow CLI prompts) |
| 141 | +buddy example |
| 142 | + |
| 143 | +# test your stack |
| 144 | +buddy test # runs test suite (unit & e2e) |
| 145 | +buddy test:coverage # runs test coverage |
| 146 | +buddy test:types # runs typecheck |
| 147 | +``` |
| 148 | + |
| 149 | +</details> |
| 150 | + |
| 151 | +## 🧪 Testing |
| 152 | + |
| 153 | +All the framework tests are stored within the `./.stacks/tests` project folder. When adding or updating functionality, please ensure it is covered through our test suite. Ensure so by running `buddy test`. |
| 154 | + |
| 155 | +When working on an individual Stack, tests are stored within the `./tests` project folder & it is recommended to write tests (when useful). Bu |
| 156 | + |
| 157 | +## ✍️ Commit |
| 158 | + |
| 159 | +Stacks uses [semantic commit messages][semantic-commit-style] to automate package releases. No worries, you may not be aware what this is or how it works—just let Buddy guide you. Stacks automated the commit process for you, simply run `buddy commit` in your terminal and follow the instructions. |
| 160 | + |
| 161 | +For example, |
| 162 | + |
| 163 | +```bash |
| 164 | +# Add all changes to staging to be committed. |
| 165 | +git add . |
| 166 | + |
| 167 | +# Commit changes. |
| 168 | +buddy commit |
| 169 | + |
| 170 | +# Push changes up to GitHub. |
| 171 | +git push |
| 172 | +``` |
| 173 | + |
| 174 | +_By following these minor steps, Stacks is able to automatically release new versions & generate relating local & remote changelogs._ |
| 175 | + |
| 176 | +## 🎉 Pull Request |
| 177 | + |
| 178 | +When you're all done, head over to the [repository][stacks], and click the big green `Compare & Pull Request` button that should appear after you've pushed changes to your fork. |
| 179 | + |
| 180 | +Don't expect your PR to be accepted immediately or even accepted at all. Give the community time to vet it and see if it should be merged. Please don't be disheartened if it's not accepted. Your contribution is appreciated more than you can imagine, and even a unmerged PR can teach us a lot ❤️ |
| 181 | + |
| 182 | +[typescript]: https://www.typescriptlang.org |
| 183 | +[vue]: https://vuejs.org/ |
| 184 | +[vite]: https://vitejs.dev/ |
| 185 | +[tauri]: https://tauri.app/ |
| 186 | +[nitro]: https://nitro.unjs.io/ |
| 187 | +[bun]: https://bun.sh/ |
| 188 | +[stacks]: https://github.com/stacksjs/stacks |
| 189 | +[semantic-commit-style]: https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716 |
| 190 | +[pr-beginner-series]: https://app.egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github |
0 commit comments