Skip to content

Latest commit

 

History

History
211 lines (136 loc) · 3.68 KB

BUILD.md

File metadata and controls

211 lines (136 loc) · 3.68 KB

Opencage Geosearch javascript client library developer documentation

As ususal, please clone the repo first.

We use lerna in addition to yarn workspaces

The prerequisites are :

We would recommend installing globally serve. To serve the examples

yarn global add serve
# or
npm i -g serve

Getting started

To set up the environment, once:

# install the dependencies
yarn

Create .env file containing your personal Key

yarn dotenv <YOUR-GEOSEARCH-KEY>

this will create a .env file in :

Create the symbolic links

yarn symlinks

This will create symbolic links, so the examples can use the locally built version of the packages.

Build and watch

to build the packages run the command

yarn build

to run a continuous build, use the command

yarn watch

Playground

The playground is the React example which allows checking the built core package.

Start the playground with the command

yarn playground:start

Others examples

So far other examples are provided:

simple example

It uses the bundle version of the package for an effortless integration in your website.

serve -S examples/simple-example

Advanced example

it uses the core version of the package and demonstrates the different options on the geosearch

serve -S examples/advanced-example

Multisources examples

Two examples how to use the plugin and other sources in the same autocomplete input.

serve -S examples/multiple-sources

check the examples:

1- open http://localhost:3000/ : adding your own data, a set of place in this example 2- open http://localhost:3000/index2.html: adding a aynch request, a query to wikipedia in this example

Leaflet's plugin example

it uses the bundle version along with the dedicated Leaflet's plugin

serve -S examples/leaflet-plugin-example

check the examples:

1- open http://localhost:3000/ 2- open http://localhost:3000/index-with-custom-marker

OpenLayers library example

it uses the bundle version along with the dedicated OpenLayers's plugin

serve -S examples/openlayers-library-example

1- open http://localhost:3000/

linter

We use the airnnb config with eslint

yarn lint

unit tests

yarn test

coverage

yarn test:coverage

the open your browser with open ./packages/geosearch-core/coverage/index.html

Clean build packages

run the command

yarn build:clean

Remove node_modules folders

yarn clean

Publish to npmjs.com

# LOGIN on npmjs
npm login
# DO NOT FORGET TO BUILD FIRST
yarn build
# Let's publish
lerna publish --no-private

after publishing, run

yarn

yarn outdated

update the deps for the examples:

Package                  Current Wanted Latest Workspace
@opencage/geosearch-core 0.0.19  0.0.19 0.0.20 @opencage/nodejs-example
@opencage/geosearch-core 0.0.19  0.0.19 0.0.20 @opencage/geosearch-react-example

update the yarn lock file with

yarn

and finally commit with a post publish message:

git commit -am "post publish updates"

Audit

Sometimes yarn audit fails. An alternative is

yarn audit --groups "dependencies"