Skip to content

Commit

Permalink
Publish flow types
Browse files Browse the repository at this point in the history
Closes #6963
  • Loading branch information
Anand Thakker committed Aug 3, 2018
1 parent a7331de commit 29ab46b
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 1 deletion.
1 change: 1 addition & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
.*/node_modules/@mapbox/geojson-types/fixtures/.*
.*/test/unit/style-spec/fixture/invalidjson.input.json
.*/test/integration/render-tests/.*
.*/test/build/downstream-flow-fixture/.*

[version]
0.77.0
3 changes: 3 additions & 0 deletions build/mapbox-gl.js.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @flow
/* eslint-disable */
export * from '../src/index.js';
1 change: 1 addition & 0 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ jobs:
- run: yarn run build-dev
- run: yarn run build-css
- run: yarn run build-style-spec
- run: yarn run build-flow-types
- run: yarn run test-build
- persist_to_workspace:
root: .
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
"build-dev": "rollup -c --environment BUILD:dev",
"watch-dev": "rollup -c --environment BUILD:dev --watch",
"build-min": "rollup -c --environment BUILD:production",
"build-flow-types": "cp build/mapbox-gl.js.flow dist/mapbox-gl.js.flow && cp build/mapbox-gl.js.flow dist/mapbox-gl-dev.js.flow",
"build-css": "postcss -o dist/mapbox-gl.css src/css/mapbox-gl.css",
"build-style-spec": "cd src/style-spec && npm run build && cd ../.. && mkdir -p dist/style-spec && cp src/style-spec/dist/* dist/style-spec",
"watch-css": "postcss --watch -o dist/mapbox-gl.css src/css/mapbox-gl.css",
Expand Down Expand Up @@ -139,7 +140,7 @@
"test-flow": "build/run-node build/generate-flow-typed-style-spec && flow .",
"test-flow-cov": "flow-coverage-report -i 'src/**/*.js' -t html",
"test-cov": "nyc --require=@mapbox/flow-remove-types/register --reporter=text-summary --reporter=lcov --cache run-s test-unit test-expressions test-query test-render",
"prepublishOnly": "run-s build-dev build-min build-css build-style-spec test-build",
"prepublishOnly": "run-s build-flow-types build-dev build-min build-css build-style-spec test-build",
"codegen": "build/run-node build/generate-style-code.js && build/run-node build/generate-struct-arrays.js"
},
"files": [
Expand Down
25 changes: 25 additions & 0 deletions test/build/downstream-flow-fixture/.flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[ignore]
.*/node_modules/@mapbox/jsonlint-lines-primitives/.*
.*/node_modules/stylelint/.*
.*/node_modules/unflowify/.*
.*/node_modules/flow-coverage-report/.*
.*/node_modules/babel-plugin-transform-react-remove-prop-types/.*
.*/node_modules/conventional-changelog-core/.*
.*/node_modules/htmltojsx/.*
.*/node_modules/documentation/.*
.*/node_modules/module-deps/.*
.*/node_modules/@mapbox/geojson-types/fixtures/.*
.*/test/unit/style-spec/fixture/invalidjson.input.json
.*/test/integration/render-tests/.*

[include]
../../..

[libs]
../../../flow-typed

[lints]

[options]

[strict]
5 changes: 5 additions & 0 deletions test/build/downstream-flow-fixture/invalid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// @flow
/* eslint-disable */
import mapboxgl from '../../..';
const Map = mapboxgl.Map;
const map = new Map({});
7 changes: 7 additions & 0 deletions test/build/downstream-flow-fixture/valid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// @flow
/* eslint-disable */
import mapboxgl from '../../..';
const Map = mapboxgl.Map;
const map = new Map({
container: document.getElementById('map')
});
15 changes: 15 additions & 0 deletions test/build/published-flow-types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { test } from 'mapbox-gl-js-test';
import cp from 'child_process';

test('downstream projects can consume published flow types', (t) => {
cp.exec(`${__dirname}/../../node_modules/.bin/flow check --strip-root --json ${__dirname}/downstream-flow-fixture`, {}, (error, stdout) => {
const result = JSON.parse(stdout);
t.equal(result.errors.length, 1);
for (const error of result.errors) {
for (const message of error.message) {
t.notEqual(message.path, 'valid.js');
}
}
t.end();
});
});

0 comments on commit 29ab46b

Please sign in to comment.