You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: contributor_docs/steward_guidelines.md
+49-33Lines changed: 49 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -175,55 +175,68 @@ Dependabot PRs are usually only visible to repo admins so if this does not apply
175
175
176
176
This section will not cover the general build setup nor commands but rather details about what's happening behind the scenes. Please see the [contributor’s guidelines](contributor_guidelines.md#working-on-p5js-codebase) for more detailed build info.
177
177
178
-
The Gruntfile.js file contains the main build definitions for p5.js. Among the different tools used to build the library and documentation includes but not limited to Grunt, Browserify, YUIDoc, ESLint, Babel, Uglify, and Mocha. It may be helpful for us to start with the `default` task and work backward from there. It may be helpful at this point to open up the Gruntfile.js document while going through the explainer below.
178
+
Starting with p5.js version 2.0, the project no longer uses Grunt for task automation. Instead, the build and test processes are handled using modern tools like npm scripts, ESLint, and [Vitest](https://vitest.dev/).
179
179
180
180
181
181
### Main build task
182
182
183
+
To run lint checks and unit tests, simply run:
184
+
183
185
```
184
-
grunt.registerTask('default', ['lint', 'test']);
186
+
npm test
185
187
```
186
188
187
-
When we run `grunt` or the npm script `npm test`, we run the default task consisting of `lint` then `test`.
188
-
189
+
This command will run ESLint to check code style and then execute unit and visual tests using Vitest.
189
190
190
191
#### `lint` Task
191
192
193
+
In p5.js 2.0, ESLint is used directly via npm scripts for all linting tasks.
The `lint` task consists of two sub tasks: `lint:source` and `lint:samples`. `lint:source` is further subdivided into three more sub tasks `eslint:build`, `eslint:source`, and `eslint:test`, which uses ESLint to check the build scripts, the source code, and the test scripts.
201
+
This checks the source files, build scripts, test files, and documentation examples using ESLint.
197
202
198
-
The `lint:samples` task will first run the `yui` task which itself consists of `yuidoc:prod`, `clean:reference`, and `minjson`, which extract the documentation from the source code into a JSON document, remove unused files from the previous step, and minify the generated JSON file into `data.min.json` respectively.
203
+
If you only want to run linting for specific files or directories, you can use ESLint directly:
199
204
200
-
Next in `lint:samples` is `eslint-samples:source`, which is a custom written task whose definition is in [../tasks/build/eslint-samples.js](../tasks/build/eslint-samples.js); it will run ESLint to check the documentation example code to make sure they follow the same coding convention as the rest of p5.js (`yui` is run first here because we need the JSON file to be built first before we can lint the examples).
205
+
```
206
+
npx eslint src/
207
+
npx eslint test/
208
+
```
201
209
210
+
There is no separate sample linter or YUIDoc-based pipeline anymore, as documentation is now managed through simpler, modern tooling.
202
211
203
212
#### `test` Task
204
213
205
-
```js
206
-
grunt.registerTask('test', [
207
-
'build',
208
-
'connect:server',
209
-
'mochaChrome',
210
-
'mochaTest',
211
-
'nyc:report'
212
-
]);
214
+
In p5.js 2.0, the testing system no longer uses Mocha via Grunt. Instead, tests are run using [Vitest](https://vitest.dev/) through npm scripts.
215
+
216
+
To run the full test suite (unit and visual tests), use:
217
+
213
218
```
219
+
npm test
220
+
```
221
+
222
+
This command performs:
223
+
- Linting via ESLint
224
+
- Unit tests using Vitest
225
+
- Visual tests (render-based snapshots)
214
226
215
-
First let's look at the `build` task under `test`.
227
+
Tests are located in the `test/unit` folder, organized to mirror the `src` directory structure. For example, tests for `src/color/p5.Color.js` live in `test/unit/color/p5.Color.js`.
216
228
217
-
```js
218
-
grunt.registerTask('build', [
219
-
'browserify',
220
-
'browserify:min',
221
-
'uglify',
222
-
'browserify:test'
223
-
]);
229
+
To run tests interactively in a browser-like environment (useful for debugging), run:
230
+
231
+
```
232
+
npx vitest --ui
224
233
```
225
234
226
-
Tasks that start with `browserify` are defined in [../tasks/build/browserify.js](../tasks/build/browserify.js). They all have similar steps with minor differences. These are the main steps to build the full p5.js library from its many source code files into one:
235
+
Code coverage is also supported using Vitest's built-in tools. Run:
236
+
237
+
```
238
+
npx vitest run --coverage
239
+
```
227
240
228
241
-`browserify` builds p5.js while `browserify:min` builds an intermediate file to be minified in the next step. The difference between `browserify` and `browserify:min` is that `browserify:min` does not contain data needed for FES to function.
229
242
-`uglify` takes the output file of `browserify:min` and minify it into the final p5.min.js (configuration of this step is in the main Gruntfile.js).
@@ -266,22 +279,25 @@ And that covers the default task in the Gruntfile.js configuration!
266
279
267
280
### Miscellaneous tasks
268
281
269
-
All of the steps can be run directly with `npx grunt [step]`. There are also a few tasks that are not covered above but could be useful in certain cases.
282
+
All of the steps can now be run using npm scripts or directly with Vitest. The Grunt build system and tasks have been removed in the dev-2.0 branch.
283
+
284
+
You can use the equivalent npm script or local development commands (please refer to the package.json scripts section).
285
+
286
+
For testing, run:
270
287
271
288
```
272
-
grunt yui:dev
289
+
npm test
273
290
```
274
291
275
-
This task will run the documentation and library builds described above, followed by spinning up a web server that serves a functionally similar version of the reference page you will find on the website on [http://localhost:9001/docs/reference/](http://localhost:9001/docs/reference/). It will then monitor the source code for changes and rebuild the documentation and library.
276
-
277
-
`grunt``yui:dev` is useful when you are working on the reference in the inline documentation because you don't have to move built files from the p5.js repository to a local p5.js-website repository and rebuild the website each time you make a change, and you can just preview your changes with this slightly simplified version of the reference in your browser. This way, you can also be more confident that the changes you made are likely to show up correctly on the website. Note that this is only meant for modifications to the inline documentation; changes to the reference page itself, including styling and layout, should be made and tested on the website repository.
292
+
For running watchers, use:
278
293
279
294
```
280
-
grunt watch
281
-
grunt watch:main
282
-
grunt watch:quick
295
+
npm run watch
283
296
```
284
297
298
+
Note: The previous `grunt yui:dev` task that served the documentation locally and watched for changes is replaced by modern tooling; please check the updated documentation or package.json for exact commands to serve and watch.
299
+
300
+
285
301
The watch tasks will watch a series of files for changes and run associated tasks to build the reference or the library according to what files have changed. These tasks all do the same thing, with the only difference being the scope.
286
302
287
303
The `watch` task will run all builds and tests similar to running the full default task on detecting changes in the source code.
0 commit comments