Skip to content

Commit

Permalink
chore: Remove deprecated function
Browse files Browse the repository at this point in the history
  • Loading branch information
makinwab committed Mar 13, 2019
1 parent 71f9175 commit 419afe3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
13 changes: 11 additions & 2 deletions lib/cmds/content-type_cmds/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { assertLoggedIn, assertSpaceIdProvided } from '../../utils/assertions'
import { handleAsyncError as handle } from '../../utils/async'
import { log } from '../../utils/log'
import paginate from '../../utils/pagination'
import { highlightStyle } from '../../utils/styles'

export const command = 'list'

Expand All @@ -17,25 +18,33 @@ export const builder = (yargs) => {
return yargs
.option('space-id', { alias: 's', type: 'string', describe: 'Space id' })
.option('management-token', { alias: 'mt', type: 'string', describe: 'Contentful management API token' })
.option('environment-id', {
alias: 'e',
type: 'string',
describe: 'Environment ID you want to interact with. Defaults to the current active environment.'
})
.epilog('Copyright 2018 Contentful, this is a BETA release')
}

async function ctList (argv) {
await assertLoggedIn(argv)
await assertSpaceIdProvided(argv)

const { cmaToken, activeSpaceId } = await getContext()
const { cmaToken, activeSpaceId, activeEnvironmentId } = await getContext()
const managementToken = argv.managementToken || cmaToken
const spaceId = argv.spaceId || activeSpaceId
const environmentId = argv.environmentId || activeEnvironmentId

const client = await createManagementClient({
accessToken: managementToken,
feature: 'content_type-list'
})

const space = await client.getSpace(spaceId)
const environment = await space.getEnvironment(environmentId)
log(highlightStyle(`Environment: "${environmentId}"`))
const result = await paginate({
client: space,
client: environment,
method: 'getContentTypes',
query: {
order: 'name,sys.id'
Expand Down
17 changes: 15 additions & 2 deletions lib/cmds/space_cmds/environment_cmds/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { handleAsyncError as handle } from '../../../utils/async'
import { createManagementClient } from '../../../utils/contentful-clients'
import { log } from '../../../utils/log'
import paginate from '../../../utils/pagination'
import { highlightStyle } from '../../../utils/styles'

export const command = 'list'

Expand Down Expand Up @@ -37,7 +38,7 @@ export async function environmentList (argv) {
await assertLoggedIn(argv)
await assertSpaceIdProvided(argv)

const { cmaToken, activeSpaceId } = await getContext()
const { cmaToken, activeSpaceId, activeEnvironmentId } = await getContext()
const spaceId = argv.spaceId || activeSpaceId
const managementToken = argv.managementToken || cmaToken

Expand All @@ -57,7 +58,19 @@ export async function environmentList (argv) {
})

environments.forEach((environment) => {
table.push([environment.name, environment.sys.id, environment.sys.status.sys.id])
if (activeEnvironmentId === environment.sys.id) {
table.push([
highlightStyle(`${environment.name} [active]`),
highlightStyle(environment.sys.id),
highlightStyle(environment.sys.status.sys.id)
])
} else {
table.push([
environment.name,
environment.sys.id,
environment.sys.status.sys.id
])
}
})

log(table.toString())
Expand Down

0 comments on commit 419afe3

Please sign in to comment.