Skip to content
This repository has been archived by the owner on May 8, 2024. It is now read-only.

Commit

Permalink
fix(code-style): fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
Khaledgarbaya committed Sep 8, 2016
1 parent a20efb2 commit e9d4841
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 89 deletions.
126 changes: 63 additions & 63 deletions lib/run-space-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import dumpErrorBuffer from './dump-error-buffer'
import getTransformedDestinationResponse from './get-transformed-destination-response'

export default function runSpaceSync (usageParams) {
const {opts, syncTokenFile, errorLogFile} = usageParams
if(opts.proxyHost && opts.proxyPort){
opts.proxy = {host: opts.proxyHost, port: opts.proxyPort}
}
const {opts, syncTokenFile, errorLogFile} = usageParams
if (opts.proxyHost && opts.proxyPort) {
opts.proxy = {host: opts.proxyHost, port: opts.proxyPort}
}
const clients = createClients(opts)
return getSourceSpaceViaSync({
deliveryClient: clients.source.delivery,
Expand All @@ -25,76 +25,76 @@ export default function runSpaceSync (usageParams) {
nextSyncTokenFile: syncTokenFile
})

// Prepare object with both source and destination existing content
.then((sourceResponse) => {
return Promise.props({
source: sourceResponse,
destination: getTransformedDestinationResponse({
// Prepare object with both source and destination existing content
.then((sourceResponse) => {
return Promise.props({
source: sourceResponse,
destination: getTransformedDestinationResponse({
managementClient: clients.destination.management,
spaceId: clients.destination.spaceId,
sourceResponse: sourceResponse,
skipLocales: opts.skipLocales,
skipContentModel: opts.skipContentModel
})
})
})
.then((responses) => {
return Promise.props({
source: transformSpace(responses.source, responses.destination),
destination: responses.destination
})
})

// Get deleted content types
.then((responses) => {
responses.source.deletedContentTypes = filter(responses.destination.contentTypes, (contentType) => {
return !find(responses.source.contentTypes, {original: {sys: {id: contentType.sys.id}}})
})
responses.source.deletedLocales = filter(responses.destination.locales, (locale) => {
return !find(responses.source.locales, {original: {code: locale.code}})
})
return responses
})

// push source space content to destination space
.then((responses) => {
return pushToSpace({
sourceContent: responses.source,
destinationContent: responses.destination,
managementClient: clients.destination.management,
spaceId: clients.destination.spaceId,
sourceResponse: sourceResponse,
prePublishDelay: opts.prePublishDelay,
contentModelOnly: opts.contentModelOnly,
skipLocales: opts.skipLocales,
skipContentModel: opts.skipContentModel
})
})
})
.then((responses) => {
return Promise.props({
source: transformSpace(responses.source, responses.destination),
destination: responses.destination
})
})
.then(() => {
const nextSyncToken = responses.source.nextSyncToken
if (!opts.contentModelOnly && nextSyncToken) {
fs.writeFileSync(syncTokenFile, nextSyncToken)
log.info('Successfully sychronized the content and saved the sync token to:\n ', syncTokenFile)
} else {
log.info('Successfully sychronized the content model')
}
dumpErrorBuffer({
destinationSpace: opts.destinationSpace,
sourceSpace: opts.sourceSpace,
errorLogFile: errorLogFile
}, 'However, additional errors were found')

// Get deleted content types
.then((responses) => {
responses.source.deletedContentTypes = filter(responses.destination.contentTypes, (contentType) => {
return !find(responses.source.contentTypes, {original: {sys: {id: contentType.sys.id}}})
})
responses.source.deletedLocales = filter(responses.destination.locales, (locale) => {
return !find(responses.source.locales, {original: {code: locale.code}})
return {
nextSyncToken: nextSyncToken
}
})
})
return responses
})

// push source space content to destination space
.then((responses) => {
return pushToSpace({
sourceContent: responses.source,
destinationContent: responses.destination,
managementClient: clients.destination.management,
spaceId: clients.destination.spaceId,
prePublishDelay: opts.prePublishDelay,
contentModelOnly: opts.contentModelOnly,
skipLocales: opts.skipLocales,
skipContentModel: opts.skipContentModel
})
.then(() => {
const nextSyncToken = responses.source.nextSyncToken
if (!opts.contentModelOnly && nextSyncToken) {
fs.writeFileSync(syncTokenFile, nextSyncToken)
log.info('Successfully sychronized the content and saved the sync token to:\n ', syncTokenFile)
} else {
log.info('Successfully sychronized the content model')
}
// Output any errors caught along the way
.catch((err) => {
dumpErrorBuffer({
destinationSpace: opts.destinationSpace,
sourceSpace: opts.sourceSpace,
errorLogFile: errorLogFile
}, 'However, additional errors were found')

return {
nextSyncToken: nextSyncToken
}
})
})

// Output any errors caught along the way
.catch((err) => {
dumpErrorBuffer({
destinationSpace: opts.destinationSpace,
sourceSpace: opts.sourceSpace,
errorLogFile: errorLogFile
})
throw err
})
throw err
})
}
52 changes: 26 additions & 26 deletions lib/usageParams.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,40 +76,40 @@ var opts = yargs
.option('management-insecure', {
describe: 'If the Management API should use http instead of the default https.',
type: 'boolean'
})
.option('proxy-host', {
describe: 'hostname of the proxy server',
type:'string'
})
.option('proxy-port', {
describe: 'port of the proxy server',
type:'string'
})
.config('config', 'Configuration file with required values')
.check(function (argv) {
if (!argv.proxyHost && !argv.proxyPort){
return true
}
if (argv.proxyPort && argv.proxyHost){
return true
}
log.error('--proxy-host and --proxy-port must be both defined')
process.exit(1)
})
})
.option('proxy-host', {
describe: 'hostname of the proxy server',
type: 'string'
})
.option('proxy-port', {
describe: 'port of the proxy server',
type: 'string'
})
.config('config', 'Configuration file with required values')
.check(function (argv) {
if (!argv.proxyHost && !argv.proxyPort) {
return true
}
if (argv.proxyPort && argv.proxyHost) {
return true
}
log.error('--proxy-host and --proxy-port must be both defined')
process.exit(1)
})
.check(function (argv) {
if (!argv.sourceManagementToken &&
!argv.destinationManagementToken &&
argv.managementToken) {
!argv.destinationManagementToken &&
argv.managementToken) {
return true
}
if (argv.sourceManagementToken &&
argv.destinationManagementToken &&
!argv.managementToken) {
argv.destinationManagementToken &&
!argv.managementToken) {
return true
}
if ((!argv.sourceManagementToken ||
!argv.destinationManagementToken) &&
argv.managementToken) {
!argv.destinationManagementToken) &&
argv.managementToken) {
return true
}
log.error(
Expand Down

0 comments on commit e9d4841

Please sign in to comment.