couch-continuum
Advanced tools
Comparing version 2.1.2 to 2.2.0
21
index.js
const assert = require('assert') | ||
const path = require('path') | ||
const ProgressBar = require('progress') | ||
const urlParse = require('url').parse | ||
const url = require('url') | ||
@@ -13,2 +13,4 @@ const log = require('./lib/log') | ||
const TEMP_COPY_SUFFIX = 'temp_copy_' | ||
module.exports = | ||
@@ -20,3 +22,3 @@ class CouchContinuum { | ||
const isSpecial = (dbName[0] === '_') // ignore special dbs | ||
const isReplica = dbName.indexOf('_temp_copy') > -1 | ||
const isReplica = dbName.indexOf(TEMP_COPY_SUFFIX) > -1 | ||
return !isSpecial && !isReplica | ||
@@ -106,20 +108,23 @@ }) | ||
assert(source, 'The Continuum requires a source database.') | ||
this.url = urlParse(couchUrl) | ||
this.url = url.parse(couchUrl) | ||
// get source url | ||
const parsedSource = urlParse(source) | ||
const parsedSource = url.parse(source) | ||
if (parsedSource.host) { | ||
this.source = parsedSource | ||
} else { | ||
this.source = urlParse(`${this.url.href}${encodeURIComponent(source)}`) | ||
this.source = url.parse(`${this.url.href}${encodeURIComponent(source)}`) | ||
} | ||
// get target url | ||
if (target) { | ||
const parsedTarget = urlParse(target) | ||
const parsedTarget = url.parse(target) | ||
if (parsedTarget.host) { | ||
this.target = parsedTarget | ||
} else { | ||
this.target = urlParse(`${this.url.href}${encodeURIComponent(target)}`) | ||
this.target = url.parse(`${this.url.href}${encodeURIComponent(target)}`) | ||
} | ||
} else { | ||
this.target = urlParse(`${this.source.href}_temp_copy`) | ||
const tmpTarget = JSON.parse(JSON.stringify(this.source)) | ||
const tmpTargetNoLeadingSlash = tmpTarget.pathname.substr(1) | ||
tmpTarget.pathname = `${TEMP_COPY_SUFFIX}${tmpTargetNoLeadingSlash}` | ||
this.target = url.parse(url.format(tmpTarget)) | ||
} | ||
@@ -126,0 +131,0 @@ // save other variables |
{ | ||
"name": "couch-continuum", | ||
"version": "2.1.2", | ||
"version": "2.2.0", | ||
"description": "Tool for migrating CouchDB databases to new configuration values.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -37,3 +37,3 @@ /* globals describe, it, beforeEach, before, afterEach */ | ||
await request({ url: `${couchUrl}/${dbName}`, method: 'DELETE' }) | ||
await request({ url: `${couchUrl}/${dbName}_temp_copy`, method: 'DELETE' }) | ||
await request({ url: `${couchUrl}/temp_copy_${dbName}`, method: 'DELETE' }) | ||
}) | ||
@@ -69,3 +69,3 @@ | ||
// verify cleanup | ||
const { error } = await request({ url: `${couchUrl}/${dbName}_temp_copy`, json: true }) | ||
const { error } = await request({ url: `${couchUrl}/temp_copy_${dbName}`, json: true }) | ||
assert.strictEqual(error, 'not_found') | ||
@@ -95,3 +95,3 @@ }) | ||
// check that tombstones were actually filtered | ||
const { results: afterResults } = await request({ url: `${couchUrl}/${dbName}_temp_copy/_changes`, json: true }) | ||
const { results: afterResults } = await request({ url: `${couchUrl}/temp_copy_${dbName}/_changes`, json: true }) | ||
const tombstones = afterResults.filter(({ deleted }) => { return deleted }) | ||
@@ -182,3 +182,3 @@ assert.strictEqual(tombstones.length, 0) | ||
const replicaSec = await request({ | ||
url: `${couchUrl}/${dbName}_temp_copy/_security`, | ||
url: `${couchUrl}/temp_copy_${dbName}/_security`, | ||
json: true | ||
@@ -185,0 +185,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46230
681