|
1 | 1 | # Contribute \[WIP\]
|
2 | 2 |
|
3 |
| -We are very happy about anyone that wants to improve this project! Please make sure to read this guide before starting your work to avoid unnecessary trouble down the road! Always feel welcomed to reach out to us via [Discord](https://discord.gg/c6tQxFG) or mail if you are unsure or need further information. |
| 3 | +We are very happy about anyone that wants to improve this project! Please make sure to read this guide before starting your work to avoid unnecessary trouble down the road! |
4 | 4 |
|
5 |
| -## What to work on |
| 5 | +{% hint style="info" %} |
| 6 | +Always make sure to reach out to us via [Discord ](https://discord.gg/c6tQxFG) or mail \([email protected]\) if you want to start developing features or fixing bugs! It's way easier for you to get going if you get some initial support from the Core Team : \) |
| 7 | +{% endhint %} |
6 | 8 |
|
7 |
| -If you want to contribute and are unsure what to work on, take a look at the [open issues!](https://github.com/matestack/matestack-ui-core/issues) |
| 9 | +Asking questions, creating GitHub Issues, adjusting things through PRs... every kind of community contribution counts: |
8 | 10 |
|
9 |
| -Other case: You plan to built something that you think should be part of the Matestack UI Core \(or you have already built it\)? Great, then open a pull request and we will take a look! |
| 11 | +## Reporting issues |
10 | 12 |
|
11 |
| -## How to contribute |
| 13 | +\[WIP\] |
12 | 14 |
|
13 |
| -Please create a pull request to the `develop` branch with your tested and documented code. Bonus points for using our PR template! |
| 15 | +## Propose features |
14 | 16 |
|
15 |
| -## Documentation |
| 17 | +\[WIP\] |
16 | 18 |
|
17 |
| -Documentation can be found in the `/docs/*` folder. Please make sure to cover basic use cases of your concepts & components for other users! Feel free to take a look at other examples and copy their structure! |
| 19 | +## Adding features or fixing bugs |
18 | 20 |
|
19 |
| -Note: We will not approve pull requests that introduce new concepts or components without documentation. Same goes for existing concepts & components. If you change the behavior of an existing part of this project, make sure to also update the corresponding part of the documentation! |
| 21 | +In order to work on the core code to add features or fix reported bugs, you should clone the repo first: |
20 | 22 |
|
21 |
| -## Dockerized Core Dev |
| 23 | +```bash |
| 24 | +git clone [email protected]:matestack/matestack-ui-core.git |
| 25 | +cd matestack-ui-core |
| 26 | +git checkout -b "your_feature/bugfix_branch_name" |
| 27 | +``` |
22 | 28 |
|
23 |
| -We dockerized the core development in order to make it as convenient as possible to contribute to `matestack-ui-core`. |
| 29 | +We dockerized the core development/testing in order to make it as convenient as possible to contribute to `matestack-ui-core`. |
24 | 30 |
|
25 | 31 | You will need to install docker and docker-compose:
|
26 | 32 |
|
27 | 33 | * [Install Docker on Ubuntu](https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-using-the-convenience-script)
|
28 | 34 | * [Install docker-compose](https://docs.docker.com/compose/install/)
|
29 | 35 |
|
30 |
| -### Setup Database and Yarn Packages |
| 36 | +### Dummy app |
| 37 | + |
| 38 | +#### Setup the dummy app |
31 | 39 |
|
32 |
| -In order to migrate the database and install yarn packages, do: |
| 40 | +In order to migrate the database and install yarn/npm packages, do: |
33 | 41 |
|
34 | 42 | ```text
|
35 |
| -docker-compose run --rm dummy bundle exec rake db:setup |
| 43 | +docker-compose build dummy |
36 | 44 | docker-compose run --rm dummy yarn install
|
37 |
| -docker-compose run --rm dummy sh -c "cd builder && yarn install" |
38 |
| -docker-compose run --rm dummy sh -c "cd spec/dummy && yarn install" |
| 45 | +docker-compose run --rm dummy sh -c "cd spec/dummy && npm install" |
| 46 | +docker-compose run --rm dummy bundle exec rake db:setup SKIP_TEST_DATABASE=true |
39 | 47 | ```
|
40 | 48 |
|
41 |
| -If you already created sqlite files locally in `spec/dummy/db`, the command `docker-compose run --rm dummy bundle exec rake db:migrate` will fail. Please remove the locally created sqlite files and rerun `docker-compose run --rm dummy bundle exec rake db:migrate` |
| 49 | +{% hint style="danger" %} |
| 50 | +The JavaScript packages within the dummy folder have to be resolved via NPM unlike the JavaScript packages within the root directory, which are resolved via YARN. |
| 51 | +{% endhint %} |
42 | 52 |
|
43 |
| -You might need to redo these steps if new migrations or yarn packages are added/updated. |
| 53 | +If you already created sqlite files locally in `spec/dummy/db`, the command `docker-compose run --rm dummy bundle exec rake db:setup SKIP_TEST_DATABASE=true` will fail. Please remove the locally created sqlite files and rerun the command |
44 | 54 |
|
45 |
| -### Run the Dummy App |
| 55 | +{% hint style="info" %} |
| 56 | +You might need to redo these steps if new migrations or yarn/npm packages are added/updated. Always remember to resolve JavaScript packages with NPM within the dummy app rather than using YARN. |
| 57 | +{% endhint %} |
46 | 58 |
|
47 |
| -The dummy app provides a good playground for matestacks core development. The source code can be found and manipulated \(be careful what you commit\) at `spec/dummy`. Run it like seen below: |
| 59 | +#### Run the dummy app |
| 60 | + |
| 61 | +The dummy app provides a good playground for Matestacks core development in order to review effects of core implementation changes hands on in a browser. The source code can be found and manipulated \(be careful what you commit\) at `spec/dummy`. Run it like seen below: |
48 | 62 |
|
49 | 63 | ```text
|
50 | 64 | docker-compose up dummy
|
51 | 65 | ```
|
52 | 66 |
|
53 |
| -Visit `localhost:3000/sandbox/hello` in order to visit the sandbox page. It lives in `spec/dummy/app/matestack/pages/sandbox/hello.rb`. Feel free to modify it and play around with components and concepts. Just don't push your local changes to the remote repo. |
| 67 | +{% hint style="warning" %} |
| 68 | +Be aware that whenever you change any **Ruby** file within the core implementation, you need to restart the dummy app in order to see effects of your changes within the dummy app. Currently the core code, defined in `lib` is not automatically reloaded. We want to fix that soon. |
| 69 | + |
| 70 | +That does not apply for **JavaScript** files as they are compiled via Webpacker automatically without a server restart required. |
| 71 | +{% endhint %} |
54 | 72 |
|
55 |
| -Visit `localhost:3000/my_app/my_first_page` in order to visit some example use cases. The pages live in `spec/dummy/app/matestack/pages/my_app`. |
| 73 | +Visit `localhost:3000` in order to visit the dummy app. Feel free to modify it and play around with components and concepts. Just don't push your local changes to the remote repo. |
56 | 74 |
|
57 |
| -### Run the Webpack Watcher |
| 75 | +The pages/component used in the dummy app live in `spec/dummy/app/matestack`. |
58 | 76 |
|
59 |
| -The builder app located in `builder/` uses webpacker in order build matestacks Javascript based on the source code found in `app/`. During development it can be used to compile the JavaScript when any relevant source code is changed. Run it like seen below: |
| 77 | +### Run the Webpack watcher |
| 78 | + |
| 79 | +During development, the Webpack watcher can be used to compile the JavaScript when any relevant JavaScript source code is changed. Run it in a separate terminal tab like seen below: |
60 | 80 |
|
61 | 81 | ```text
|
62 | 82 | docker-compose up webpack-watcher
|
63 | 83 | ```
|
64 | 84 |
|
65 |
| -### Run bundle/yarn install in a Docker container |
| 85 | +### Rerun bundle/yarn install in a Docker container |
66 | 86 |
|
67 |
| -In order to execute commands such as `bundle install`, `yarn install` you need to run: |
| 87 | +In order to execute commands such as `bundle install`, `yarn install` or `npm install` you need to run: |
68 | 88 |
|
69 | 89 | ```text
|
70 | 90 | docker-compose run --rm dummy bundle install
|
71 | 91 | docker-compose run --rm dummy yarn install
|
72 |
| -docker-compose run --rm dummy sh -c "cd spec/dummy && yarn install" |
| 92 | +docker-compose run --rm dummy sh -c "cd spec/dummy && npm install" |
73 | 93 | ```
|
74 | 94 |
|
75 |
| -### Run commands as your user in a Docker container |
| 95 | +### Optional: run commands as your user in a Docker container |
76 | 96 |
|
77 |
| -When running commands, which generates files, which then are mounted to your host filesystem, you need to tell the Docker container that it should run with your user ID. |
| 97 | +When running commands, which generates files \(e.g. rails generator usage\), which then are mounted to your host filesystem, you need to tell the Docker container that it should run with your user ID. |
78 | 98 |
|
79 | 99 | ```text
|
80 | 100 | CURRENT_UID=$(id -u):$(id -g) docker-compose run --rm dummy bash
|
81 | 101 |
|
82 |
| -#and then your desired command such as: |
| 102 | +# and then your desired command such as: |
83 | 103 |
|
84 |
| -rails generate matestack:core:component div |
| 104 | +rails generate ... |
85 | 105 | ```
|
86 | 106 |
|
87 | 107 | Otherwise the generated files will be owned by the `root` user and are only writeable when applying `sudo`.
|
88 | 108 |
|
89 | 109 | **Note:** `bundle install` and `yarn install` can't be executed inside the Docker container as the current user. `CURRENT_UID=$(id -u):$(id -g) docker-compose run --rm dummy bundle install` will not work.
|
90 | 110 |
|
91 |
| -## Core Components Generator |
| 111 | +### Testing |
92 | 112 |
|
93 |
| -```bash |
94 |
| -CURRENT_UID=$(id -u):$(id -g) docker-compose run --rm dummy bash |
95 |
| -rails generate matestack:core:component div |
96 |
| -``` |
| 113 | +To assure this project is and remains in great condition, we heavily rely on automated tests. Tests are defined in `/spec` folder |
97 | 114 |
|
98 |
| -This will create a component for the HTML `<div>` tag and will generate the following files: |
| 115 | +#### Setup the test ENV |
99 | 116 |
|
100 |
| -```bash |
101 |
| -app/concepts/matestack/ui/core/div/div.haml |
102 |
| -app/concepts/matestack/ui/core/div/div.rb |
103 |
| -spec/usage/components/div_spec.rb |
104 |
| -docs/components/div.md |
| 117 | +```text |
| 118 | +docker-compose build test |
| 119 | +docker-compose run --rm test yarn install |
| 120 | +docker-compose run --rm test sh -c "cd spec/dummy && npm install" |
| 121 | +docker-compose run --rm test bundle exec rake db:setup |
105 | 122 | ```
|
106 | 123 |
|
107 |
| -## Dockerized Test Env |
108 |
| - |
109 |
| -```bash |
110 |
| -bundle install |
111 |
| -yarn install |
112 |
| -cd spec/dummy |
113 |
| -yarn install # dependencies for the dummy app in testing |
114 |
| -cd ../.. |
115 |
| - |
116 |
| -bundle exec rake db:create |
117 |
| -bundle exec rake db:schema:load |
118 |
| -``` |
| 124 | +{% hint style="danger" %} |
| 125 | +The JavaScript packages within the dummy folder have to be resolved via NPM unlike the JavaScript packages within the root directory, which are resolved via YARN. |
| 126 | +{% endhint %} |
119 | 127 |
|
120 |
| -## Tests |
| 128 | +{% hint style="info" %} |
| 129 | +You might need to redo these steps if new migrations or yarn/npm packages are added/updated. Always remember to resolve JavaScript packages with NPM within the dummy app rather than using YARN. |
| 130 | +{% endhint %} |
121 | 131 |
|
122 |
| -To assure this project is and remains in great condition, we heavily rely on automated tests. Tests are defined in `/spec` folder and can be executed by running: |
| 132 | +#### Run the specs |
123 | 133 |
|
124 | 134 | ```bash
|
125 |
| -docker-compose run --rm test bash |
126 |
| -bundle exec rake db:setup #once initially |
127 |
| -bundle exec rspec spec/usage/components |
128 |
| -``` |
129 |
| - |
130 |
| -Tests follow quite the same rules as the documentation: Make sure to either add relevant tests \(when introducing new concepts or components\) or change existing ones to fit your changes \(updating existing concepts and components\). Pull requests that add/change concepts & components and do not come with corresponding tests will not be approved. |
131 |
| - |
132 |
| -## Core Components |
| 135 | +docker-compose run --rm --service-ports test bash |
133 | 136 |
|
134 |
| -Core Components are an essential part of the `matestack-ui-core` gem. If you are planning to contribute to Matestack you can start doing that by creating a core component. To help you getting started you can use the Core Component Generator. |
| 137 | +# and then inside the container: |
135 | 138 |
|
136 |
| -The generator will create a matestack core component to `app/concepts/matestack/ui/core`. |
137 |
| - |
138 |
| -Example: |
139 |
| - |
140 |
| -```bash |
141 |
| -rails generate matestack:core:component div |
142 |
| -``` |
| 139 | +cd spec/dummy |
| 140 | +./bin/webpack # always make sure to have the latest JS assets compiled |
143 | 141 |
|
144 |
| -This will create a component for the HTML `<div>` tag and will generate the following files: |
| 142 | +cd ../.. |
145 | 143 |
|
146 |
| -```bash |
147 |
| -app/concepts/matestack/ui/core/div/div.haml |
148 |
| -app/concepts/matestack/ui/core/div/div.rb |
149 |
| -spec/usage/components/div_spec.rb |
150 |
| -docs/components/div.md |
| 144 | +bundle exec rspec spec/test # run all tests |
| 145 | +bundle exec rspec spec/test/components/xyz.rb(:123) # run a specific test (:line_number) |
151 | 146 | ```
|
152 | 147 |
|
153 |
| -## Release |
| 148 | +{% hint style="info" %} |
| 149 | +Always make sure to compile the JavaScript assets via `./bin/webpack` in the `spec/dummy` folder before running the specs. You can also run `./bin/webpack --watch` in a separate test container \(without `--service-ports`\). The compiled assets are mounted to your filesystem. |
| 150 | +{% endhint %} |
154 | 151 |
|
155 |
| -[Webpacker](https://github.com/rails/webpacker) is used for managing all JS assets. In order to create production-ready assets, run the [task](https://github.com/matestack/matestack-ui-core/blob/master/Rakefile) |
| 152 | +## Documentation & test coverage |
156 | 153 |
|
157 |
| -```text |
158 |
| -docker-compose run --rm webpack-watcher bash |
159 |
| -cd builder |
160 |
| -bundle exec rails webpacker:compile RAILS_ENV=production |
161 |
| -``` |
162 |
| - |
163 |
| -The assets will be exported to [`vendor/assets/javascripts/dist`](https://github.com/matestack/matestack-ui-core/tree/master/vendor/assets/javascripts/dist). |
| 154 | +Documentation can be found in the `/docs/*` folder. Please make sure to cover basic use cases of your concepts & components for other users! Feel free to take a look at other examples and copy their structure! |
164 | 155 |
|
165 |
| -Under the hood, we use a "builder" app in the [`builder`](https://github.com/matestack/matestack-ui-core/tree/master/builder) folder in order to run webpacker and create the assets. Its webpack\(er\) configuration can be found in [`builder/config`](https://github.com/matestack/matestack-ui-core/tree/master/builder/config). |
| 156 | +Note: We will not approve pull requests that introduce new concepts or components without documentation. Same goes for existing concepts & components. If you change the behavior of an existing part of this project, make sure to also update the corresponding part of the documentation! |
166 | 157 |
|
167 |
| -When creating a new matestack-ui-core release, make sure to also change the version number accordingly in [`package.json`](https://github.com/matestack/matestack-ui-core/blob/master/package.json) and to create a corresponding [version tag on github](https://github.com/matestack/matestack-ui-core/tags). |
| 158 | +Tests follow quite the same rules as the documentation: Make sure to either add relevant tests \(when introducing new concepts or components\) or change existing ones to fit your changes \(updating existing concepts and components\). Pull requests that add/change concepts & components and do not come with corresponding tests will not be approved. |
168 | 159 |
|
0 commit comments