From e3ff438cd9c3ff12fe6113784eac7515efc9c1d0 Mon Sep 17 00:00:00 2001 From: Jennifer Hasegawa Date: Fri, 15 Feb 2019 15:20:17 -0800 Subject: [PATCH] ripplelib qs: update recs --- .../rippleapi_quickstart/browser-demo.html | 4 +- .../rippleapi_quickstart/package.json | 7 +- ...t-started-with-rippleapi-for-javascript.md | 152 ++++++++++-------- .../contribute-code-to-ripple-lib.md | 4 +- 4 files changed, 87 insertions(+), 80 deletions(-) diff --git a/content/_code-samples/rippleapi_quickstart/browser-demo.html b/content/_code-samples/rippleapi_quickstart/browser-demo.html index 893b533a84..7424c7be27 100644 --- a/content/_code-samples/rippleapi_quickstart/browser-demo.html +++ b/content/_code-samples/rippleapi_quickstart/browser-demo.html @@ -1,8 +1,8 @@ - - + + - -(This loads lodash v4.17.11 from CDNJS on Cloudflare and then loads ripple-lib v1.1.2, but you could also download and load a variant of lodash locally.) - -I'm not sure what version(s) of lodash are currently supported; check with Elliot on that.*** - -#### 1. Download a copy of the RippleAPI git repository. +#### 1. Download a copy of the RippleAPI git repository If you have [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) installed, you can clone the repository and check out the **master** branch, which always has the latest official release: @@ -243,31 +251,32 @@ git checkout master Alternatively, you can download an archive (.zip or .tar.gz) of a specific release from the [RippleAPI releases page](https://github.com/ripple/ripple-lib/releases) and extract it. -#### 2. Install dependencies using NPM +#### 2. Install Yarn -You need to have [NPM (Node.js Package Manager) installed](#install-nodejs-and-npm) first. +Use these instructions to [install Yarn](#install-yarn). -Then, from within the `ripple-lib` directory, you can use NPM to install all the necessary dependencies: +#### 3. Install dependencies using Yarn ``` -npm install +yarn ``` -(We recommend _not_ using `npm -g` to install dependencies globally.) - -This can take a while, and may include some warnings. The following warnings are benign and do not indicate a problem: +The install process may end with a few warnings. You may safely ignore the following warnings: ***TODO: necessary to mention? Existing doc surfaced NPM warnings - so thought I'd do the same for yarn?*** ``` -npm WARN optional Skipping failed optional dependency /chokidar/fsevents: -npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.6 +npm WARN lifecycle The node binary used for scripts is /var/folders/gx/5cs0kgzs2f3ccd_lp76sbbh00000gn/T/yarn--1550268394417-0.38463834710857947/node but npm is using /usr/local/Cellar/node@10/10.15.1/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with. + +npm WARN lifecycle The node binary used for scripts is /var/folders/gx/5cs0kgzs2f3ccd_lp76sbbh00000gn/T/yarn--1550268394417-0.38463834710857947/node but npm is using /usr/local/Cellar/node@10/10.15.1/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with. + +npm WARN lifecycle The node binary used for scripts is /var/folders/gx/5cs0kgzs2f3ccd_lp76sbbh00000gn/T/yarn--1550268394417-0.38463834710857947/node but npm is using /usr/local/Cellar/node@10/10.15.1/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with. ``` -#### 3. Use Gulp to build a single JavaScript output +#### 4. Use Gulp to build a single JavaScript output RippleAPI comes with code to use the [gulp](http://gulpjs.com/) package to compile all its source code into browser-compatible JavaScript files. Gulp is automatically installed as one of the dependencies, so all you have to do is run it. RippleAPI's configuration makes this easy: ``` -npm run build +yarn run build ``` Output: @@ -276,29 +285,32 @@ Output: > ripple-lib@0.16.5 build /home/username/ripple-lib > gulp -[15:22:30] Using gulpfile /home/username/ripple-lib/Gulpfile.js -[15:22:30] Starting 'build'... -[15:22:30] Starting 'build-debug'... -[15:22:42] Finished 'build' after 12 s -[15:22:42] Starting 'build-min'... -[15:22:42] Finished 'build-debug' after 12 s -[15:22:51] Finished 'build-min' after 9.83 s -[15:22:51] Starting 'default'... -[15:22:51] Finished 'default' after 4.58 μs +[14:11:02] Using gulpfile /home/username/ripple-lib/gulpfile.js +[14:11:02] Starting 'build'... +[14:11:03] Starting 'build-debug'... +[14:11:03] Starting 'build-min'... +[14:11:18] Finished 'build-debug' after 15 s +[14:11:18] Finished 'build' after 16 s +[14:11:18] Finished 'build-min' after 15 s +[14:11:18] Starting 'default'... +[14:11:18] Finished 'default' after 19 μs ``` This may take a while. At the end, the build process creates a new `build/` folder, which contains the files you want. The file `build/ripple-.js` is a straight export of RippleAPI (whatever version you built) ready to be used in browsers. The file ending in `-min.js` is the same thing, but with the content [minified](https://en.wikipedia.org/wiki/Minification_%28programming%29) for faster loading. -## Example Browser Usage + +### Demo RippleAPI in a Browser The following HTML file demonstrates basic usage of the browser version of RippleAPI to connect to a public `rippled` server and report information about that server. Instead of using Node.js's "require" syntax, the browser version creates a global variable named `ripple`, which contains the `RippleAPI` class. -To use this example, you must first [build RippleAPI](#build-instructions) and then copy one of the resulting output files to the same folder as this HTML file. (You can use either the minified or full-size version.) Change the first `