Skip to content

Commit 064a2f3

Browse files
authored
Replace gulp with npm scripts (chartjs#7402)
Gulp removed from toolchain in favour of simpler build process
1 parent 29043f1 commit 064a2f3

File tree

10 files changed

+754
-4019
lines changed

10 files changed

+754
-4019
lines changed

.editorconfig

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ charset = utf-8
99
trim_trailing_whitespace = true
1010
insert_final_newline = true
1111

12-
[gulpfile.js]
13-
indent_style = space
14-
indent_size = 2
15-
1612
[*.yml]
1713
indent_style = space
1814
indent_size = 2

.eslintrc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ plugins: ['html']
2222
rules:
2323
class-methods-use-this: 0
2424
no-empty-function: 0
25+
complexity: [1, 10]
26+
max-statements: [1, 30]

.github/workflows/ci.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ jobs:
2828
Xvfb :99 -screen 0 1024x768x24 &
2929
echo "::set-env name=DISPLAY:::99.0"
3030
if: runner.os == 'Linux'
31-
- name: Install gulp
32-
run: npm install --global gulp
33-
if: runner.os == 'macOS'
3431
- name: Install chrome
3532
run: |
3633
brew update
@@ -45,13 +42,13 @@ jobs:
4542
- name: Build and Test
4643
run: |
4744
npm install
48-
gulp build
49-
gulp test --coverage ${BROWSERS}
45+
npm run build
46+
npm test
5047
- name: Package
5148
run: |
5249
npm run docs
5350
npm run typedoc
54-
gulp package
51+
npm pack
5552
- name: Publish Test Results
5653
run: cat ./coverage/lcov.info | ./node_modules/.bin/coveralls
5754
shell: bash

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ services:
99
- xvfb
1010

1111
script:
12-
- gulp build
13-
- gulp test --coverage
12+
- npm run build
13+
- npm test
1414
- ./scripts/docs-config.sh
1515
- npm run docs
1616
- npm run typedoc
17-
- gulp package
17+
- npm pack
1818
- cat ./coverage/lcov.info | ./node_modules/.bin/coveralls || true
1919

2020
sudo: required

docs/docs/developers/contributing.md

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ New contributions to the library are welcome, but we ask that you please follow
66

77
- Before opening a PR for major additions or changes, please discuss the expected API and/or implementation by [filing an issue](https://github.com/chartjs/Chart.js/issues) or asking about it in the [Chart.js Slack](https://chartjs-slack.herokuapp.com/) #dev channel. This will save you development time by getting feedback upfront and make review faster by giving the maintainers more context and details.
88
- Consider whether your changes are useful for all users, or if creating a Chart.js [plugin](plugins.md) would be more appropriate.
9-
- Check that your code will pass tests and `eslint` code standards. `gulp test` will run both the linter and tests for you.
9+
- Check that your code will pass tests and `eslint` code standards. `npm test` will run both the linter and tests for you.
1010
- Add unit tests and document new functionality (in the `test/` and `docs/` directories respectively).
1111
- Avoid breaking changes unless there is an upcoming major release, which are infrequent. We encourage people to write plugins for most new advanced features, and care a lot about backwards compatibility.
1212
- We strongly prefer new methods to be added as private whenever possible. A method can be made private either by making a top-level `function` outside of a class or by prefixing it with `_` and adding `@private` JSDoc if inside a class. Public APIs take considerable time to review and become locked once implemented as we have limited ability to change them without breaking backwards compatibility. Private APIs allow the flexibility to address unforeseen cases.
@@ -17,40 +17,34 @@ Active committers and contributors are invited to introduce yourself and request
1717

1818
## Building and Testing
1919

20-
Chart.js uses <a href="https://gulpjs.com/" target="_blank">gulp</a> to build the library into a single JavaScript file.
21-
2220
Firstly, we need to ensure development dependencies are installed. With node and npm installed, after cloning the Chart.js repo to a local directory, and navigating to that directory in the command line, we can run the following:
2321

2422
```bash
2523
> npm install
26-
> npm install -g gulp-cli
2724
```
2825

29-
This will install the local development dependencies for Chart.js, along with a CLI for the JavaScript task runner <a href="https://gulpjs.com/" target="_blank">gulp</a>.
26+
This will install the local development dependencies for Chart.js.
3027

3128
The following commands are now available from the repository root:
3229

3330
```bash
34-
> gulp build // build dist files in ./dist
35-
> gulp build --watch // build and watch for changes
36-
> gulp unittest // run tests from ./test/specs
37-
> gulp unittest --watch // run tests and watch for source changes
38-
> gulp unittest --coverage // run tests and generate coverage reports in ./coverage
39-
> gulp lint // perform code linting (ESLint)
40-
> gulp test // perform code linting and run unit tests
41-
> gulp test --browsers ... // test with specified browsers (comma-separated)
31+
> npm run build // build dist files in ./dist
32+
> npm run autobuild // build and watch for source changes
33+
> npm run dev // run tests and watch for source and test changes
34+
> npm run lint // perform code linting (ESLint, tsc)
35+
> npm test // perform code linting and run unit tests with coverage
4236
```
4337

44-
More information can be found in [gulpfile.js](https://github.com/chartjs/Chart.js/blob/master/gulpfile.js).
38+
`npm run dev` and `npm test` can be appended with a string that is used to match the spec filenames. For example: `npm run dev plugins` will start karma in watch mode for `test/specs/**/*plugin*.js`.
4539

4640
### Documentation
4741

4842
We use [Docusaurus v2](https://v2.docusaurus.io/docs/introduction) to manage the docs which are contained as Markdown files in the docs directory. You can run the doc server locally using the commands provided by Docusaurus:
4943

50-
```
51-
$ cd docs
52-
$ npm install
53-
$ npm run start
44+
```bash
45+
> cd docs
46+
> npm install
47+
> npm run start
5448
```
5549

5650
### Image-Based Tests
@@ -60,10 +54,11 @@ Some display-related functionality is difficult to test via typical Jasmine unit
6054
Generated charts in image-based tests should be **as minimal as possible** and focus only on the tested feature to prevent failure if another feature breaks (e.g. disable the title and legend when testing scales).
6155

6256
You can create a new image-based test by following the steps below:
57+
6358
- Create a JS file ([example](https://github.com/chartjs/Chart.js/blob/f7b671006a86201808402c3b6fe2054fe834fd4a/test/fixtures/controller.bubble/radius-scriptable.js)) or JSON file ([example](https://github.com/chartjs/Chart.js/blob/4b421a50bfa17f73ac7aa8db7d077e674dbc148d/test/fixtures/plugin.filler/fill-line-dataset.json)) that defines chart config and generation options.
6459
- Add this file in `test/fixtures/{spec.name}/{feature-name}.json`.
6560
- Add a [describe line](https://github.com/chartjs/Chart.js/blob/4b421a50bfa17f73ac7aa8db7d077e674dbc148d/test/specs/plugin.filler.tests.js#L10) to the beginning of `test/specs/{spec.name}.tests.js` if it doesn't exist yet.
66-
- Run `gulp unittest --watch --inputs=test/specs/{spec.name}.tests.js`.
61+
- Run `npm run dev`.
6762
- Click the *"Debug"* button (top/right): a test should fail with the associated canvas visible.
6863
- Right click on the chart and *"Save image as..."* `test/fixtures/{spec.name}/{feature-name}.png` making sure not to activate the tooltip or any hover functionality
6964
- Refresh the browser page (`CTRL+R`): test should now pass
@@ -81,8 +76,8 @@ Well structured, detailed bug reports are hugely valuable for the project.
8176

8277
Guidelines for reporting bugs:
8378

84-
- Check the issue search to see if it has already been reported
85-
- Isolate the problem to a simple test case
86-
- Please include a demonstration of the bug on a website such as [JS Bin](https://jsbin.com/), [JS Fiddle](https://jsfiddle.net/), or [Codepen](https://codepen.io/pen/). ([Template](https://codepen.io/pen?template=JXVYzq)). If filing a bug against `master`, you may reference the latest code via https://www.chartjs.org/dist/master/Chart.min.js (changing the filename to point at the file you need as appropriate). Do not rely on these files for production purposes as they may be removed at any time.
79+
- Check the issue search to see if it has already been reported
80+
- Isolate the problem to a simple test case
81+
- Please include a demonstration of the bug on a website such as [JS Bin](https://jsbin.com/), [JS Fiddle](https://jsfiddle.net/), or [Codepen](https://codepen.io/pen/). ([Template](https://codepen.io/pen?template=JXVYzq)). If filing a bug against `master`, you may reference the latest code via <https://www.chartjs.org/dist/master/Chart.min.js> (changing the filename to point at the file you need as appropriate). Do not rely on these files for production purposes as they may be removed at any time.
8782

8883
Please provide any additional details associated with the bug, if it's browser or screen density specific, or only happens with a certain configuration or data.

gulpfile.js

Lines changed: 0 additions & 149 deletions
This file was deleted.

karma.conf.js

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@ const json = require('@rollup/plugin-json');
66
const resolve = require('@rollup/plugin-node-resolve');
77
const webWorkerLoader = require('rollup-plugin-web-worker-loader');
88
const builds = require('./rollup.config');
9+
const yargs = require('yargs');
10+
911

1012
module.exports = function(karma) {
11-
const args = karma.args || {};
13+
const args = yargs
14+
.option('verbose', {default: false})
15+
.argv;
16+
17+
const grep = args.grep === true ? '' : args.grep;
18+
const specPattern = 'test/specs/**/*' + grep + '*.js';
1219

1320
// Use the same rollup config as our dist files: when debugging (--watch),
1421
// we will prefer the unminified build which is easier to browse and works
@@ -17,15 +24,17 @@ module.exports = function(karma) {
1724
const regex = args.watch ? /chart\.js$/ : /chart\.min\.js$/;
1825
const build = builds.filter(v => v.output.file.match(regex))[0];
1926

20-
if (args.watch) {
21-
build.output.sourcemap = 'inline';
22-
}
23-
2427
karma.set({
2528
frameworks: ['jasmine'],
2629
reporters: ['progress', 'kjhtml'],
2730
browsers: (args.browsers || 'chrome,firefox').split(','),
28-
logLevel: karma.LOG_WARN,
31+
logLevel: karma.LOG_INFO,
32+
33+
client: {
34+
jasmine: {
35+
failFast: !!karma.autoWatch
36+
}
37+
},
2938

3039
// Explicitly disable hardware acceleration to make image
3140
// diff more stable when ran on Travis and dev machine.
@@ -56,13 +65,14 @@ module.exports = function(karma) {
5665
{pattern: 'test/fixtures/**/*.json', included: false},
5766
{pattern: 'test/fixtures/**/*.png', included: false},
5867
'node_modules/moment/min/moment.min.js',
59-
'test/index.js',
60-
'src/index.js',
61-
'node_modules/chartjs-adapter-moment/dist/chartjs-adapter-moment.js'
62-
].concat((args.inputs || 'test/specs/**/*.js').split(';')),
68+
{pattern: 'test/index.js', watched: false},
69+
{pattern: 'src/index.js', watched: false},
70+
'node_modules/chartjs-adapter-moment/dist/chartjs-adapter-moment.js',
71+
{pattern: specPattern, watched: false}
72+
],
6373

6474
preprocessors: {
65-
'test/specs/**/*.js': ['rollup'],
75+
[specPattern]: ['rollup'],
6676
'test/index.js': ['rollup'],
6777
'src/index.js': ['sources']
6878
},
@@ -77,7 +87,8 @@ module.exports = function(karma) {
7787
],
7888
output: {
7989
name: 'test',
80-
format: 'umd'
90+
format: 'umd',
91+
sourcemap: karma.autoWatch ? 'inline' : false
8192
}
8293
},
8394

0 commit comments

Comments
 (0)