From cdd44711fae47e29de2a0558a8002c9bf5e6e840 Mon Sep 17 00:00:00 2001 From: Harel M Date: Fri, 3 Sep 2021 10:57:24 +0300 Subject: [PATCH] Removed yarn from the code (#299) * Removed yarn from the code * Convert to es6 --- .github/workflows/analyze.yml | 4 +- .github/workflows/release.yml | 6 +-- CONTRIBUTING.md | 24 +++------ build/check-bundle-size.js | 8 ++- build/generate-struct-arrays.js | 2 +- build/maplibre-gl-js.dockerfile | 37 -------------- build/maplibre-gl.js.flow | 3 -- build/publish-release.sh | 50 ------------------- docs/README.md | 2 +- src/style/style_layer/layer_properties.js.ejs | 2 +- test/browser/README.md | 8 +-- test/integration/README.md | 22 ++++---- 12 files changed, 31 insertions(+), 137 deletions(-) delete mode 100644 build/maplibre-gl-js.dockerfile delete mode 100644 build/maplibre-gl.js.flow delete mode 100755 build/publish-release.sh diff --git a/.github/workflows/analyze.yml b/.github/workflows/analyze.yml index 39cdb778cf..b1b5eeb44f 100644 --- a/.github/workflows/analyze.yml +++ b/.github/workflows/analyze.yml @@ -51,8 +51,8 @@ jobs: name: dist path: before repo: maplibre/maplibre-gl-js - - run: yarn source-map-explorer before/maplibre-gl.js --gzip --json before.json - - run: yarn source-map-explorer after/maplibre-gl.js --gzip --json after.json + - run: npx source-map-explorer before/maplibre-gl.js --gzip --json before.json + - run: npx source-map-explorer after/maplibre-gl.js --gzip --json after.json - name: Build bundle size report run: node build/check-bundle-size.js > comment-body.txt - name: Dump bundle size report diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a1dd11a599..9659357a5e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -163,12 +163,8 @@ jobs: run: | rm -f ${{ steps.prepare_release.outputs.release_notes }} - - name: Update NPM Package Version - run: | - yarn version --non-interactive --no-git-tag-version --new-version ${{ steps.prepare_release.outputs.version }} - - name: Publish NPM package run: | - yarn publish --non-interactive + npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_ORG_TOKEN }} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 21d8560532..3b34f65c24 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,10 +17,6 @@ Install [node.js](https://nodejs.org/) version ^10.15 ( Minimum 10.15 while stic ```bash brew install node ``` -Install [yarn](https://yarnpkg.com/en/) -```bash -brew install yarn -``` Clone the repository ```bash @@ -30,7 +26,7 @@ git clone git@github.com:maplibre/maplibre-gl-js.git Install node module dependencies ```bash cd maplibre-gl-js && -yarn install +npm install ``` ### Linux @@ -51,12 +47,6 @@ Install [Node.js](https://nodejs.org/) ^10.15 nvm install 10.24.1 # latest v10 version that will run the test suite ``` -Install [yarn](https://yarnpkg.com/en/docs/install#linux-tab) -```bash -curl -o- -L https://yarnpkg.com/install.sh | bash -``` -(It is also possible to install yarn from Debian/Ubuntu packages. See [yarn's install instructions](https://yarnpkg.com/en/docs/install#linux-tab)). - Clone the repository ```bash git clone git@github.com:maplibre/maplibre-gl-js.git @@ -65,12 +55,12 @@ git clone git@github.com:maplibre/maplibre-gl-js.git Install node module dependencies ```bash cd maplibre-gl-js && -yarn install +npm install ``` ### Windows -Install [git](https://git-scm.com/), [node.js](https://nodejs.org/) (version ^10.15), [yarn](https://yarnpkg.com/en/docs/install#windows-tab), [npm and node-gyp](https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#compiling-native-addon-modules). +Install [git](https://git-scm.com/), [node.js](https://nodejs.org/) (version ^10.15), [npm and node-gyp](https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#compiling-native-addon-modules). Clone the repository ```bash @@ -81,7 +71,7 @@ git clone git@github.com:maplibre/maplibre-gl-js.git Install node module dependencies ```bash cd maplibre-gl-js -yarn install +npm install ``` Install headless-gl dependencies https://github.com/stackgl/headless-gl#windows @@ -94,7 +84,7 @@ copy node_modules/headless-gl/deps/windows/dll/x64/*.dll c:\windows\system32 Start the debug server ```bash -MAPBOX_ACCESS_TOKEN={YOUR MAPBOX ACCESS TOKEN} yarn run start-debug +MAPBOX_ACCESS_TOKEN={YOUR MAPBOX ACCESS TOKEN} npm run start-debug ``` Open the debug page at [http://localhost:9966/debug](http://localhost:9966/debug) @@ -105,8 +95,8 @@ A standalone build allows you to turn the contents of this repository into `mapb To create a standalone build, run ```bash -yarn run build-prod-min -yarn run build-css +npm run build-prod-min +npm run build-css ``` Once those commands finish, you will have a standalone build at `dist/mapbox-gl.js` and `dist/mapbox-gl.css` diff --git a/build/check-bundle-size.js b/build/check-bundle-size.js index 6a16517af7..10a8edfd81 100755 --- a/build/check-bundle-size.js +++ b/build/check-bundle-size.js @@ -1,10 +1,8 @@ #!/usr/bin/env node -/* eslint-disable */ - -const fs = require("fs"); -const zlib = require("zlib"); -const prettyBytes = require("pretty-bytes"); +import fs from "fs"; +import zlib from "zlib"; +import prettyBytes from "pretty-bytes"; const beforeSourcemap = JSON.parse(fs.readFileSync('./before.json').toString()); const afterSourcemap = JSON.parse(fs.readFileSync('./after.json').toString()); diff --git a/build/generate-struct-arrays.js b/build/generate-struct-arrays.js index 439af9d65b..8cb54f6b16 100644 --- a/build/generate-struct-arrays.js +++ b/build/generate-struct-arrays.js @@ -226,7 +226,7 @@ createStructArrayLayoutType(createLayout([{ const layouts = Object.keys(layoutCache).map(k => layoutCache[k]); fs.writeFileSync('src/data/array_types.js', - `// This file is generated. Edit build/generate-struct-arrays.js, then run \`yarn run codegen\`. + `// This file is generated. Edit build/generate-struct-arrays.js, then run \`npm run codegen\`. // @flow import assert from 'assert'; diff --git a/build/maplibre-gl-js.dockerfile b/build/maplibre-gl-js.dockerfile deleted file mode 100644 index 33f45e69dc..0000000000 --- a/build/maplibre-gl-js.dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -# see: publish-release.sh to build/run this - -FROM node:14 - -ENV DEBIAN_FRONTEND=noninteractive - -RUN \ - # Setup support for HTTPS apt sources - apt update -y && \ - apt install -y apt-transport-https ca-certificates && \ - # Setup Yarn apt source - curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ - echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ - apt update -y - -RUN \ - apt install -y \ - git \ - # Needed for yarn to build gl (see: https://github.com/yarnpkg/yarn/issues/1987) - node-gyp xserver-xorg-dev libxi-dev libxext-dev libpango1.0-dev \ - yarn && \ - # npm-run-all is required to bootstrap existing package.json lines, which use "run-s" - npm install -g npm-run-all && \ - mkdir -p /src - -WORKDIR /src - -ADD . . - -# publish-release-cmd.sh will use `docker run --env NPM_TOKEN` for npm auth -ARG NPM_TOKEN - -# Now setup npm/yarn to find the authToken in ${NPM_TOKEN} at docker run time -# Note the single quotes: this does NOT leak your NPM_TOKEN -RUN echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > ~/.npmrc - -CMD yarn publish diff --git a/build/maplibre-gl.js.flow b/build/maplibre-gl.js.flow deleted file mode 100644 index 9ef358a454..0000000000 --- a/build/maplibre-gl.js.flow +++ /dev/null @@ -1,3 +0,0 @@ -// @flow -/* eslint-disable */ -export * from '../src/index.js'; diff --git a/build/publish-release.sh b/build/publish-release.sh deleted file mode 100755 index 20fd45a4b9..0000000000 --- a/build/publish-release.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - -# Publishes a repeatable release of maplibre-gl to NPM -# -# USAGE: -# 1. Run: ./build/publish-release.sh [command, default is `yarn publish`] -# 2. Yarn will prompt you for a new version, enter it, and it will publish -# 3. Commit the new package.json on your host with the updated version -# 4. Verify: new version is up at https://www.npmjs.com/package/maplibre-gl - -echo "Heads up: this script assumes you only have /one/ NPM registry setup, which is true for most devs." -echo "If you /do/ have more than just registry.npmjs.org in ~/.npmrc, it may not" -echo "try to npm publish with the correct (authorized) npm authToken, and publish will fail to auth" -echo - -cd `dirname ${BASH_SOURCE[0]}` - -set -ex - -docker build \ - -t maplibre-gl-js \ - -f ./maplibre-gl-js.dockerfile \ - .. - -set +x -export NPM_TOKEN=$(cat ~/.npmrc | grep -o '_authToken=.*' | sed 's/_authToken=//g') -export GIT_AUTHOR_NAME=$(git config user.name) -export GIT_AUTHOR_EMAIL=$(git config user.email) -set -x - -docker run -it \ - -v "$(pwd)"/../package.json:/src/package.json \ - -v "$(pwd)"/../.git:/src/.git \ - --env NPM_TOKEN \ - --env GIT_USER_NAME \ - --env GIT_USER_EMAIL \ - maplibre-gl-js \ - ${1:-yarn publish} - -set +x - -cd .. -PACKAGE_VERSION=`node -pe "require('./package.json').version"` -echo -echo -echo "SUCCESS: maplibre-gl@${PACKAGE_VERSION} published to NPM!" -echo -echo "1. package.json was updated with the new version number you entered, please commit and push this" -echo "2. Check https://www.npmjs.com/package/maplibre-gl/v/${PACKAGE_VERSION} to verify your release" -echo diff --git a/docs/README.md b/docs/README.md index 695fb7be33..05c7fde253 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1 +1 @@ -This folder contains developer documentation for MapLibre GL. Put any diagrams you reference in the [diagrams](./diagrams) folder. If you use PlantUML, put the source code in `diagrams/*.plantuml` files and run `yarn build-diagrams` to generate SVG versions of them. There is also a [Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=jebbs.plantuml) for previewing them while you edit. +This folder contains developer documentation for MapLibre GL. Put any diagrams you reference in the [diagrams](./diagrams) folder. If you use PlantUML, put the source code in `diagrams/*.plantuml` files and run `npm run build-diagrams` to generate SVG versions of them. There is also a [Visual Studio Code extension](https://marketplace.visualstudio.com/items?itemName=jebbs.plantuml) for previewing them while you edit. diff --git a/src/style/style_layer/layer_properties.js.ejs b/src/style/style_layer/layer_properties.js.ejs index 497242d7c2..2676fe2b8c 100644 --- a/src/style/style_layer/layer_properties.js.ejs +++ b/src/style/style_layer/layer_properties.js.ejs @@ -3,7 +3,7 @@ const layoutProperties = locals.layoutProperties; const paintProperties = locals.paintProperties; -%> -// This file is generated. Edit build/generate-style-code.js, then run `yarn run codegen`. +// This file is generated. Edit build/generate-style-code.js, then run `npm run codegen`. // @flow /* eslint-disable */ diff --git a/test/browser/README.md b/test/browser/README.md index 6c061fcd38..42e902f62f 100644 --- a/test/browser/README.md +++ b/test/browser/README.md @@ -11,8 +11,8 @@ To run Webdriver, you'll have to install the driver for every browser you want t ## Running -- Run browser tests with `yarn run test-browser`. -- The tests default to Chrome, but it's possible to use a different browser by setting the `SELENIUM_BROWSER` environment variable, e.g. like this: `SELENIUM_BROWSER=firefox yarn run test-browser`. -- To run on iOS Safari, use `SELENIUM_BROWSER=safari::ios yarn run test-browser`. Make sure that the iOS device is in the same local Wifi network as your computer. -- To run on Android Chrome, use `SELENIUM_BROWSER=chrome::android yarn run test-browser`. Make sure that the Android device is in the same local Wifi network as your computer. +- Run browser tests with `npm run test-browser`. +- The tests default to Chrome, but it's possible to use a different browser by setting the `SELENIUM_BROWSER` environment variable, e.g. like this: `SELENIUM_BROWSER=firefox npm run test-browser`. +- To run on iOS Safari, use `SELENIUM_BROWSER=safari::ios npm run test-browser`. Make sure that the iOS device is in the same local Wifi network as your computer. +- To run on Android Chrome, use `SELENIUM_BROWSER=chrome::android npm run test-browser`. Make sure that the Android device is in the same local Wifi network as your computer. - To run individual tests instead of the entire test suite, you can execute a test file with the TAP runner, e.g. by typing `build/run-tap test/browser/zoom.test.js`. diff --git a/test/integration/README.md b/test/integration/README.md index 6046e7c56e..039275e514 100644 --- a/test/integration/README.md +++ b/test/integration/README.md @@ -19,30 +19,30 @@ The contents of vector tile fixtures can be read using the [`vt2geojson`](https: To run the entire integration test suite (both render or query tests), from within the `mapbox-gl-js` directory run the command: ``` -yarn run test-suite +npm run test-suite ``` To run only the render/query tests: ``` -yarn run test-render +npm run test-render ``` or ``` -yarn run test-query-node +npm run test-query-node ``` To run only the expression tests: ``` -yarn run test-expressions +npm run test-expressions ``` ### Running specific tests To run a subset of tests or an individual test, you can pass a specific subdirectory to the `test-render` script. For example, to run all the tests for a given property, e.g. `circle-radius`: ``` -$ yarn run test-render circle-radius +$ npm run test-render circle-radius ... * passed circle-radius/antimeridian * passed circle-radius/default @@ -56,7 +56,7 @@ Done in 2.71s. ``` Or to run a single test: ``` -$ yarn run test-render circle-radius/literal +$ npm run test-render circle-radius/literal ... * passed circle-radius/literal 1 passed (100.0%) @@ -82,16 +82,16 @@ open ./test/integration/query-tests/index.html Query tests can be run in the browser, the server for serving up the test page and test fixtures starts when you run ``` -yarn run start +npm run start ``` OR ``` -yarn run start-debug +npm run start-debug ``` If you want to run only the test server run: ``` -yarn run watch-query +npm run watch-query ``` Then open the following url in the browser of your choice to start running the tests. @@ -128,11 +128,11 @@ To add a new render test: 3. Generate an `expected.png` image from the given style by running the new test with the `UPDATE` flag enabled: ``` - $ UPDATE=1 yarn run test-render / + $ UPDATE=1 npm run test-render / ``` The test will appear to fail, but you'll now see a new `expected.png` in the test directory. -4. Manually inspect `expected.png` to verify it looks as expected, and optionally run the test again without the update flag (`yarn run test-render /`) to watch it pass (enjoy that dopamine kick!) +4. Manually inspect `expected.png` to verify it looks as expected, and optionally run the test again without the update flag (`npm run test-render /`) to watch it pass (enjoy that dopamine kick!) 5. Commit the new `style.json` and `expected.png` :rocket: