Skip to content

Commit 3c5c7f1

Browse files
authored
Merge pull request #198 from Mr0grog/191-contributing-docs-cleanup
Final docs and audit cleanup
2 parents 52a80eb + 9e42005 commit 3c5c7f1

File tree

5 files changed

+126
-92
lines changed

5 files changed

+126
-92
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151
runs-on: ubuntu-latest
5252
strategy:
5353
matrix:
54-
node_version: [8, 10, 12, 14, 16, 18, 20]
54+
node_version: [10, 12, 14, 16, 18, 20]
5555

5656
steps:
5757
- uses: actions/checkout@v4

CONTRIBUTING.md

Lines changed: 59 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ If you're filing a feature request, please remember:
88
* Feature requests significantly expanding the scope of loglevel outside the description in [the readme](https://github.com/pimterry/loglevel/blob/master/README.md) will probably be rejected.
99
* Features that can't be meaningfully implemented in a cross-environment compatible manner won't be implemented.
1010
* Please check the previously opened issues to see if somebody else has suggested it first.
11-
* Consider submitting a pull request to add the feature instead, if you're confident it fits within the above
11+
* Consider submitting a pull request to add the feature instead, if you're confident it fits within the above.
1212

1313
If you're filing a bug, please remember:
1414

15-
* To provide detailed steps to reproduce the behaviour
16-
* If possible, provide a Jasmine test which reproduces the behaviour
17-
* Please specify the exact details of the environment in which it fails: OS + Environment (i.e. Browser or Node) + version
18-
* Consider submitting a pull request to fix the bug instead
15+
* To provide detailed steps to reproduce the behaviour.
16+
* If possible, provide a Jasmine test which reproduces the behaviour.
17+
* Please specify the exact details of the environment in which it fails: OS + Environment (i.e. Browser or Node) + version.
18+
* Consider submitting a pull request to fix the bug instead.
1919

2020
Helping develop loglevel
2121
================================
@@ -26,38 +26,71 @@ Before submitting a pull request to fix a bug or add a new feature, please check
2626

2727
To be more specific, before submitting your pull request please ensure:
2828

29-
* You haven't broken the existing test suite in any obvious browsers (at least check latest IE/FF/Chrome)
30-
* You've added relevant tests for the bug you're fixing/the new feature you're adding/etc, which pass in all the relevant browsers
31-
* JSHint is happy with your new code
32-
* You've updated the API docs (in README.md) to detail any changes you've made to the public interface
33-
* Your change is backward compatible (or you've explicitly said if it's not; this isn't great, but will be considered)
34-
* You haven't changed any files in dist/ (these are auto-generated, and should only be changed on release)
29+
* You haven't broken the existing test suite in any obvious browsers (at least check latest IE/FF/Chrome).
30+
* You've added relevant tests for the bug you're fixing/the new feature you're adding/etc, which pass in all the relevant browsers.
31+
* JSHint is happy with your new code.
32+
* You've updated the API docs (in `README.md`) to detail any changes you've made to the public interface.
33+
* Your change is backward-compatible (or you've explicitly said that it's not; this isn't great, but will be considered).
34+
* You haven't changed any files in `dist/` (these are auto-generated, and should only be changed on release).
35+
36+
Compatibility and JavaScript Runtimes
37+
-------------------------------------
38+
39+
loglevel aims to stay compatible with browsers, Node.js versions, and other JS runtimes that may be fairly old at this point! Please take care to match existing conventions and JavaScript language features wherever possible. For example, loglevel uses `var` instead of the newer `let` and `const` keywords to define variables, uses old-style `for` loops instead of the newer `for...of` loop, and so on.
40+
41+
That said, loglevel's *test and development tools* utilize newer JavaScript and Node.js features. To run most tests or build releases, you will need a newer version of Node.js than is required at runtime (see details below in ["how to make your change…"](#how-to-make-your-change-and-submit-it)). Using newer features or making breaking changes to the *dev tools* is OK.
3542

3643
Project structure
3744
-----------------
3845

39-
The core project code is all in lib/loglevel.js, and this should be the only file you need to touch for functional changes themselves.
46+
The core project code is all in [`lib/loglevel.js`](./lib/loglevel.js), and this should be the only file you need to touch for functional changes themselves.
4047

41-
The released code is in dist/*.js, and should not be touched by anything except releases
48+
The released code is in `dist/*.js`, and should not be touched by anything except releases (pull requests should *not* update these files).
4249

43-
The test suite is entirely in test/*.js:
50+
The test suite is entirely in `test/*.js`:
4451

45-
* Every file ending in '-test.js' is a unit test, is written in RequireJS, and should pass in any environment
46-
* global-integration.js and node-integration.js are quick integration smoke tests for node and for browser global usage
47-
* test-helpers.js contains some test utilities
48-
* manual-test.html is a test page which includes the current loglevel build, so you can manually check it works in a given browser
52+
* Every file ending in `-test.js` is a unit test, is written in RequireJS, and should pass in any environment.
53+
* `global-integration.js` and `node-integration.js` are quick integration smoke tests for node and for browser global usage.
54+
* `test-helpers.js` contains some test utilities.
55+
* `manual-test.html` is a test page which includes the current loglevel build, so you can manually check that it works in a given browser.
4956

5057
How to make your change and submit it
5158
-------------------------------------
5259

53-
1. Fork loglevel
54-
2. Clone your fork locally
55-
3. Create a branch from master for your change
56-
4. Write some tests in /test for your change, as relevant
57-
5. Make your code changes in /lib/loglevel.js
58-
6. Check your code all passes (run `grunt`) - if you have any issues try running `grunt jasmine:requirejs:src:build` (or a different test build instead of 'requirejs': see the jasmine config in Gruntfile.js) and debugging the generated _SpecRunner.html in a browser
59-
7. Commit your changes
60-
8. Open a pull request back to master in loglevel
60+
1. Ensure you have Node.js v14 or later (some tests can run on earlier versions, but the full suite requires this version).
61+
2. Fork loglevel.
62+
3. Clone your fork locally.
63+
4. Create a branch from `master` for your change.
64+
5. Write some tests in `test/` for your change, as relevant.
65+
6. Make your code changes in `lib/loglevel.js`.
66+
7. Check your code all passes (run `npm test`). If you have issues and need to debug the tests, see the details on ["running tests"](#running-tests) below.
67+
8. Commit your changes.
68+
9. Open a pull request back to `master` in loglevel.
69+
70+
Running Tests
71+
-------------
72+
73+
There are several types of tests and test tools that loglevel uses to verify different types of support in different environments. When you run `npm test`, *all* of these tests are run automatically. However, you may want to run individual types of tests during development, or run some tests manually to debug them.
74+
75+
Test commands (see `"scripts"` in `package.json` for a complete list of tools):
76+
- `npm test` — Runs all the below tests.
77+
- `npm run test-browser` — Runs detailed tests in a headless browser. There are actually 3 sub-groups here:
78+
- `npx grunt jasmine:global` — Tests general usage of the global `log` variable.
79+
- `npx grunt test-browser-context` — Tests usage when loglevel is injected into an anonymous function instead of included as a regular script on the page.
80+
- `npx grunt jasmine:requirejs` — Tests the main test suite via Jasmine & RequireJS.
81+
- `npm run test-node` — Runs tests that check loglevel in Node.js.
82+
- `npm run test-types` — Runs tests of the TypeScript type definitions for loglevel.
83+
84+
Alternatively, you might want to run tests manually in your browser in order to use debugging tools to step through the code:
85+
1. Run `npx grunt integration-test` to start a test server on port `8000`.
86+
2. Your default browser should open the tests automatically, but if not, open `http://127.0.0.1:8000/_SpecRunner.html` in any browser.
87+
3. Open your browser's dev tools and place breakpoints where you'd like to debug a test.
88+
4. Reload the page to re-run the tests and pause on breakpoints.
89+
90+
You can also open a blank webpage with loglevel pre-loaded to experiment in your browser's console:
91+
1. Run `npx grunt integration-test` to start a test server on port `8000`.
92+
2. In whatever browser you want to test, open `http://127.0.0.1:8000/test/manual-test.html`.
93+
3. Play around with the global `log` object in the browser's dev console.
6194

6295
Reporting security issues
6396
-------------------------

Gruntfile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ module.exports = function (grunt) {
153153

154154
// Check everything is good
155155
grunt.registerTask('test', ['jshint', 'test-browser', 'test-node']);
156-
grunt.registerTask('test-browser', ['jasmine:global', 'preprocess', 'jasmine:context', 'clean:test', 'jasmine:requirejs']);
156+
grunt.registerTask('test-browser', ['jasmine:global', 'test-browser-context', 'jasmine:requirejs']);
157+
grunt.registerTask('test-browser-context', ['preprocess', 'jasmine:context', 'clean:test']);
157158
grunt.registerTask('test-node', ['jasmine_node']);
158159

159160
// Test with a live server and an actual browser

0 commit comments

Comments
 (0)