New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

couch-continuum

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

couch-continuum - npm Package Compare versions

Comparing version 1.2.0-alpha to 2.0.0-alpha

10

bin.js

@@ -18,5 +18,5 @@ #!/usr/bin/env node

function getContinuum (argv) {
const { copyName, couchUrl, dbName, filterTombstones, interval, placement, q, verbose } = argv
const { copyName, couchUrl, dbName, filterTombstones, interval, n, placement, q, verbose } = argv
if (verbose) process.env.LOG = true
const options = { copyName, couchUrl, dbName, filterTombstones, interval, placement, q }
const options = { copyName, couchUrl, dbName, filterTombstones, interval, n, placement, q }
return new CouchContinuum(options)

@@ -66,3 +66,3 @@ }

dbName: {
alias: 'n',
alias: 'N',
description: 'The name of the database to modify.',

@@ -188,2 +188,6 @@ required: true,

},
n: {
description: 'The desired "n" value for the new database.',
type: 'number'
},
verbose: {

@@ -190,0 +194,0 @@ alias: 'v',

@@ -117,3 +117,3 @@ 'use strict'

constructor ({ couchUrl, dbName, copyName, filterTombstones, placement, interval, q }) {
constructor ({ couchUrl, dbName, copyName, filterTombstones, placement, interval, q, n }) {
assert(couchUrl, 'The Continuum requires a URL for accessing CouchDB.')

@@ -126,2 +126,3 @@ assert(dbName, 'The Continuum requires a target database.')

this.q = q
this.n = n
this.placement = placement

@@ -134,2 +135,3 @@ this.filterTombstones = filterTombstones

q: this.q,
n: this.n,
placement: this.placement

@@ -142,2 +144,3 @@ })

if (this.q) qs.q = this.q
if (this.n) qs.n = this.n
if (this.placement) qs.placement = this.placement

@@ -144,0 +147,0 @@ return makeRequest({

{
"name": "couch-continuum",
"version": "1.2.0-alpha",
"version": "2.0.0-alpha",
"description": "Tool for migrating CouchDB databases to new configuration values.",

@@ -10,3 +10,3 @@ "main": "index.js",

"scripts": {
"test": "standard && dependency-check . --unused --no-dev && mocha"
"test": "standard && dependency-check . --unused --no-dev && mocha && npm audit"
},

@@ -17,3 +17,3 @@ "author": "Diana Thayer <garbados@gmail.com>",

"progress": "^2.0.0",
"request": "^2.83.0",
"request": "^2.86.0",
"yargs": "^11.0.0"

@@ -20,0 +20,0 @@ },

@@ -13,13 +13,8 @@ # couch-continuum

```bash
$ couch-continuum -n hello-world -q 4 -u http://$USER:$PASS@localhost:5984
[couch-continuum] Migrating database 'hello-world' to new settings { q: 4 }...
[couch-continuum] Replicating hello-world to hello-world_temp_copy
[couch-continuum] (====================) 100% 0.0s
$ couch-continuum -N hello-world -q 4 -n 1 -u http://$USER:$PASS@localhost:5984
[couch-continuum] Migrating database 'hello-world'...
Ready to replace the primary with the replica. Continue? [y/N] y
[couch-continuum] Recreating primary hello-world
[couch-continuum] (====================) 100% 0.0s
[couch-continuum] Replicating hello-world_temp_copy to hello-world
[couch-continuum] (====================) 100% 0.0s
[couch-continuum] ... success!
```

@@ -99,2 +94,3 @@

-q The desired "q" value for the new database. [number]
-n The desired "n" value for the new database. [number]
--verbose, -v Enable verbose logging. [boolean]

@@ -105,3 +101,3 @@ --placement, -p Placement rule for the affected database(s). [string]

--config Path to JSON config file
--dbName, -n The name of the database to modify.[string] [required]
--dbName, -N The name of the database to modify.[string] [required]
--copyName, -c The name of the database to use as a replica. Defaults

@@ -115,5 +111,5 @@ to {dbName}_temp_copy [string]

```
$ couch-continuum -n hello-world -q 4 -u http://... -v
[couch-continuum] Created new continuum: {"db1":"hello-world","db2":"hello-world_temp_copy","interval":1000,"q":4}
[couch-continuum] Migrating database 'hello-world' to new settings { q: 4 }...
$ couch-continuum -N hello-world -q 4 -u http://... -v
[couch-continuum] Created new continuum: {"db1":"hello-world","db2":"hello-world_temp_copy","interval":1000,"q":4,"n":1}
[couch-continuum] Migrating database 'hello-world'...
[couch-continuum] Creating replica hello-world_temp_copy...

@@ -123,5 +119,2 @@ [couch-continuum] [0/5] Checking if primary is in use...

[couch-continuum] [2/5] Beginning replication of primary to replica...
[couch-continuum] Replicating hello-world to hello-world_temp_copy
[couch-continuum] (====================) 100% 0.0s
[couch-continuum] [3/5] Verifying primary did not change during replication...

@@ -140,5 +133,2 @@ [couch-continuum] [4/5] Verifying primary and replica match...

[couch-continuum] [5/8] Beginning replication of replica to primary...
[couch-continuum] Replicating hello-world_temp_copy to hello-world
[couch-continuum] (====================) 100% 0.0s
[couch-continuum] [6/8] Replicated. Destroying replica...

@@ -145,0 +135,0 @@ [couch-continuum] [7/8] Setting primary to available.

@@ -79,3 +79,32 @@ /* globals describe, it, before, after */

it('should filter tombstones', function () {
const options = { couchUrl, dbName, filterTombstones: true }
const continuum = new CouchContinuum(options)
return continuum.createReplica()
})
it('should modify n', function () {
const options = { couchUrl, dbName, n: 1 }
const continuum = new CouchContinuum(options)
return continuum.createReplica()
.then(() => {
return new Promise((resolve, reject) => {
const url = [couchUrl, continuum.db2].join('/')
request({ url, json: true }, (err, response, { cluster }) => {
if (err) {
return reject(err)
} else if (cluster === undefined) {
return resolve() // 1.x, travis
} else if (cluster.n !== 1) {
return reject(new Error(`n should be 1 but is ${cluster.n}.`))
} else {
return resolve()
}
})
})
})
})
it('should migrate all OK', function () {
this.timeout(30 * 1000)
return CouchContinuum

@@ -101,7 +130,16 @@ .getCheckpoint(couchUrl)

it('should filter tombstones', function () {
const options = { couchUrl, dbName, filterTombstones: true }
const continuum = new CouchContinuum(options)
return continuum.createReplica()
it('should clean up after itself', function (done) {
const url = [couchUrl, '_all_dbs'].join('/')
request({ url, json: true }, (err, response, allDbs) => {
if (err) return done(err)
const leftovers = allDbs.filter((db) => {
return (db.substring(0, 1) !== '_') && (db !== dbName)
})
if (leftovers.length > 0) {
done(new Error(`There should be no DBs leftover from testing. Instead found: ${leftovers}`))
} else {
done()
}
})
})
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc