Skip to content
This repository has been archived by the owner on Mar 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #277 from cloudant/prepare-2.0.2-release
Browse files Browse the repository at this point in the history
Update require references to scoped package
  • Loading branch information
smithsz authored Feb 14, 2018
2 parents de382c2 + d8a0d20 commit ac4eccc
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 36 deletions.
4 changes: 3 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# 2.0.2 (UNRELEASED)
# 2.0.2 (2018-02-14)
- [FIXED] Updated `require` references to use newly scoped package
`@cloudant/cloudant`.

# 2.0.1 (2018-02-14)
- [NEW] Added API for upcoming IBM Cloud Identity and Access Management support
Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ This is the official Cloudant library for Node.js.

The best way to use the Cloudant client is to begin with your own Node.js project, and define this work as your dependency. In other words, put me in your package.json dependencies. The `npm` tool can do this for you, from the command line:

$ npm install --save cloudant
$ npm install --save @cloudant/cloudant

Notice that your package.json will now reflect this package. Everything is working if you can run this command with no errors:

$ node -e 'require("cloudant"); console.log("Cloudant works");'
$ node -e 'require("@cloudant/cloudant"); console.log("Cloudant works");'
Cloudant works

### Getting Started
Expand All @@ -53,7 +53,7 @@ Initialize your Cloudant connection by supplying your *account* and *password*,

~~~ js
// Load the Cloudant library.
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');

var me = 'nodejs'; // Set this to your own account
var password = process.env.cloudant_password;
Expand Down Expand Up @@ -89,7 +89,7 @@ Here is simple but complete example of working with data:
require('dotenv').load();

// Load the Cloudant library.
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');

// Initialize Cloudant with settings from .env
var username = process.env.cloudant_username || "nodejs";
Expand Down Expand Up @@ -129,7 +129,7 @@ You can find a further CRUD example in the [example](https://github.com/cloudant

### Initialization

To use Cloudant, add `require('cloudant')` in your code. In general, the common style is that `Cloudant` (upper-case) is the **package** you load; whereas `cloudant` (lower-case) is your connection to your database (i.e. the result of calling `Cloudant()`).
To use Cloudant, add `require('@cloudant/cloudant')` in your code. In general, the common style is that `Cloudant` (upper-case) is the **package** you load; whereas `cloudant` (lower-case) is your connection to your database (i.e. the result of calling `Cloudant()`).

You can initialize your client in _one_ of the following ways:

Expand All @@ -138,7 +138,7 @@ You can initialize your client in _one_ of the following ways:
You can initialize Cloudant with a URL:

~~~ js
var Cloudant = require('cloudant')
var Cloudant = require('@cloudant/cloudant')
var cloudant = Cloudant("http://MYUSERNAME:MYPASSWORD@localhost:5984");
~~~

Expand All @@ -149,14 +149,14 @@ var cloudant = Cloudant("http://MYUSERNAME:MYPASSWORD@localhost:5984");
You can just pass your account name and password (see the [security note](#security-note) about placing your password into your source code).

~~~ js
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');
var cloudant = Cloudant({account:me, password:password});
~~~

By default, when you connect to your cloudant account (i.e. "me.cloudant.com"), you authenticate as the account owner (i.e. "me"). However, you can use Cloudant with any username and password. Just provide an additional "username" option when you initialize Cloudant. This will connect to your account, but using the username as the authenticated user. (And of course, use the appropriate password.)

~~~ js
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');
var me = "nodejs"; // Substitute with your Cloudant user account.
var otherUsername = "jhs"; // Substitute with some other Cloudant user account.
var otherPassword = process.env.other_cloudant_password;
Expand Down Expand Up @@ -188,7 +188,7 @@ Cloudant({url:"companycloudant.local", username:"somebody", password:"somebody's
You can initialize Cloudant directly from the `VCAP_SERVICES` environment variable. Just pass `vcapServices` and your `vcapInstanceName` (or alias `instanceName`) in the client configuration:

~~~ js
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');
var cloudant = Cloudant({ vcapInstanceName: 'foo', vcapServices: JSON.parse(process.env.VCAP_SERVICES) });
~~~

Expand All @@ -203,7 +203,7 @@ You can optionally provide a callback to the Cloudant initialization function. T
Here is a simple example of initializing asynchronously, using its optional callback parameter:

~~~ js
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');
var me = 'nodejs'; // Replace with your account.
var password = process.env.cloudant_password;

Expand Down Expand Up @@ -391,7 +391,7 @@ Use the authorization feature to generate new API keys to access your data. An A
### Generate an API key
~~~ js
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');
var me = 'nodejs'; // Replace with your account.
var password = process.env.cloudant_password;
var cloudant = Cloudant({account:me, password:password});
Expand Down Expand Up @@ -458,7 +458,7 @@ See the [Authorization] documentation for further details.
To use an API key, initialize a new Cloudant connection, and provide an additional "key" option when you initialize Cloudant. This will connect to your account, but using the "key" as the authenticated user. (And of course, use the appropriate password associated with the API key.)
~~~ js
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');
var cloudant = Cloudant({account:"me", key:api.key, password:api.password});
~~~
Expand Down Expand Up @@ -804,7 +804,7 @@ var options =
, "password" : "secret"
, "requestDefaults": { "proxy": "http://localhost:8080" }
}
var cloudant = require('cloudant')(opts);
var cloudant = require('@cloudant/cloudant')(opts);
// Now using the HTTP proxy...
~~~
Expand All @@ -831,7 +831,7 @@ var myagent = new HttpsAgent({
maxKeepAliveRequests: 0,
maxKeepAliveTime: 30000
});
var cloudant = require('cloudant')({account:"me", password:"secret", requestDefaults:{agent:myagent}});
var cloudant = require('@cloudant/cloudant')({account:"me", password:"secret", requestDefaults:{agent:myagent}});
// Using Cloudant with myagent...
~~~
Expand Down Expand Up @@ -929,7 +929,7 @@ Now your project has the dependency in place, however you can work on both of th
Here is simple but complete example of working with data:
~~~ js
var Cloudant = require('cloudant')
var Cloudant = require('@cloudant/cloudant')
var me = 'nodejs' // Set this to your own account
var password = process.env.cloudant_password
Expand Down
2 changes: 1 addition & 1 deletion example/crud.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if (!process.env.CLOUDANT_URL) {

// load the Cloudant library
var async = require('async');
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');
var cloudant = Cloudant({url: process.env.CLOUDANT_URL});
var dbname = 'crud';
var db = null;
Expand Down
4 changes: 2 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"async": "^1.5.0",
"cloudant": "^1.3.0"
"@cloudant/cloudant": "^2.0.1"
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"type": "git",
"url": "[email protected]:cloudant/nodejs-cloudant.git"
},
"version": "2.0.2-SNAPSHOT",
"version": "2.0.2",
"author": {
"name": "IBM Cloudant",
"email": "[email protected]"
Expand Down
32 changes: 16 additions & 16 deletions test/legacy/readme-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var SERVER = 'https://' + ME + '.cloudant.com';

var real_require = require;
require = function(module) {
return (module == 'cloudant')
return (module == '@cloudant/cloudant')
? real_require('../../cloudant.js')
: real_require.apply(this, arguments);
};
Expand All @@ -47,7 +47,7 @@ var console = { log: function() {} };
describe('Getting Started', function() {
var mocks;
after(function(done) {
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');
var cloudant = Cloudant({account: ME, password: PASSWORD, plugins: 'retry'});
cloudant.db.destroy('alice', function(er, d) {
should(er).equal(null);
Expand All @@ -70,7 +70,7 @@ describe('Getting Started', function() {

it('Example 1', function(done) {
// Load the Cloudant library.
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');

var me = ME; // Set this to your own account
var password = process.env.cloudant_password || 'sjedon';
Expand All @@ -87,7 +87,7 @@ describe('Getting Started', function() {

it('Example 2', function(done) {
// Load the Cloudant library.
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');

// Initialize Cloudant with settings from .env
var username = ME;
Expand Down Expand Up @@ -132,7 +132,7 @@ describe('Initialization', function() {
});

it('Example 1', function(done) {
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');
var me = ME; // Replace with your account.
var password = process.env.cloudant_password || 'sjedon';

Expand Down Expand Up @@ -168,7 +168,7 @@ describe('Password authentication', function() {
});

it('Example 1', function(done) {
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');

Cloudant({account: ME, username: ME, password: PASSWORD}, function(er, cloudant, reply) {
if (er) {
Expand Down Expand Up @@ -205,7 +205,7 @@ describe('Authorization and API Keys', function() {
});

it('Example 1', function(done) {
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');
var me = ME; // Replace with your account.
var password = process.env.cloudant_password || 'sjedon';
var cloudant = Cloudant({account: me, password: password, plugins: 'retry'});
Expand Down Expand Up @@ -272,7 +272,7 @@ describe('CORS', function() {

var cloudant;
before(function() {
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');
cloudant = Cloudant({account: ME, password: process.env.cloudant_password, plugins: 'retry'});
});

Expand Down Expand Up @@ -327,7 +327,7 @@ describe('Virtual Hosts', function() {

var cloudant;
before(function() {
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');
cloudant = Cloudant({account: ME, password: process.env.cloudant_password, plugins: 'retry'});
});

Expand Down Expand Up @@ -383,7 +383,7 @@ describe('Cloudant Query', function() {

var cloudant, db;
before(function(done) {
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');
cloudant = Cloudant({account: ME, password: process.env.cloudant_password, plugins: 'retry'});
cloudant.db.create('my_db', function(er) {
if (er) throw er;
Expand Down Expand Up @@ -465,7 +465,7 @@ describe('Cloudant Search', function() {

var cloudant, db;
before(function(done) {
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');
cloudant = Cloudant({account: ME, password: process.env.cloudant_password, plugins: 'retry'});
cloudant.db.create('my_db', function(er) {
if (er) throw er;
Expand Down Expand Up @@ -552,7 +552,7 @@ describe('Cookie Authentication', function() {
var cloudant;
var mocks;
after(function(done) {
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');
cloudant = Cloudant({account: ME, password: process.env.cloudant_password, plugins: []});
cloudant.db.destroy('alice', function() {
mocks.done();
Expand All @@ -567,7 +567,7 @@ describe('Cookie Authentication', function() {
.get('/_session').reply(200, {ok: true, userCtx: {name: ME, roles: ['_admin', '_reader', '_writer']}})
.delete('/alice').reply(200, {ok: true});

var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');
cloudant = Cloudant({account: ME, password: process.env.cloudant_password, plugins: []});
cloudant.db.create('alice', function() {
done();
Expand All @@ -577,7 +577,7 @@ describe('Cookie Authentication', function() {
var cookies;

it('Example 1', function(done) {
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');
var username = ME; // Set this to your own account
var password = process.env.cloudant_password || 'sjedon';
var cloudant = Cloudant({account: username, password: password, plugins: []});
Expand Down Expand Up @@ -607,7 +607,7 @@ describe('Cookie Authentication', function() {

it('Example 2', function(done) {
// Make a new connection with the cookie.
var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');
var username = ME; // Set this to your own account
var other_cloudant = Cloudant({account: username, cookie: cookies[username], plugins: []});

Expand All @@ -632,7 +632,7 @@ describe('Cookie Authentication', function() {
it('Example 3', function(done) {
// (Presuming the "cookie" global from the above example is still in scope.)

var Cloudant = require('cloudant');
var Cloudant = require('@cloudant/cloudant');
var username = ME; // Set this to your own account
var cloudant = Cloudant({account: username, cookie: cookies[username], plugins: []});

Expand Down

0 comments on commit ac4eccc

Please sign in to comment.