Skip to content

Commit

Permalink
use aioLogger and not debug() directly (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
purplecabbage authored Jun 10, 2020
1 parent 21a3ed6 commit 5fc0487
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/commands/app/add/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ governing permissions and limitations under the License.

const BaseCommand = require('../../../BaseCommand')
const yeoman = require('yeoman-environment')
const debug = require('debug')('aio-cli-plugin-app:init')
const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app:add:action', { provider: 'debug' })
const { flags } = require('@oclif/command')

const config = require('@adobe/aio-lib-core-config')
Expand All @@ -20,7 +20,7 @@ class AddActionCommand extends BaseCommand {
async run () {
const { args, flags } = this.parse(AddActionCommand)

debug(`adding component ${args.component} to the project, using flags: `, flags)
aioLogger.debug(`adding component ${args.component} to the project, using flags: ${flags}`)

const services = (config.get('services') || []).map(s => s.code).join(',')

Expand Down
4 changes: 2 additions & 2 deletions src/commands/app/add/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ governing permissions and limitations under the License.
*/

const BaseCommand = require('../../../BaseCommand')
const debug = require('debug')('aio-cli-plugin-app:init')
const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app:add:auth', { provider: 'debug' })

const AppScripts = require('@adobe/aio-app-scripts')

class AddAuthCommand extends BaseCommand {
async run () {
const { flags } = this.parse(AddAuthCommand)

debug('add auth to the project, using flags:', flags)
aioLogger.debug(`add auth to the project, using flags: ${flags}`)

const scripts = AppScripts({})
const res = await scripts.addAuth()
Expand Down
4 changes: 2 additions & 2 deletions src/commands/app/add/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ governing permissions and limitations under the License.

const BaseCommand = require('../../../BaseCommand')
const yeoman = require('yeoman-environment')
const debug = require('debug')('aio-cli-plugin-app:init')
const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app:add:ci', { provider: 'debug' })

class AddCICommand extends BaseCommand {
async run () {
const { args, flags } = this.parse(AddCICommand)

debug(`adding component ${args.component} to the project, using flags: `, flags)
aioLogger.debug(`adding component ${args.component} to the project, using flags: ${flags}`)

const generator = '@adobe/generator-aio-app/generators/add-ci'
const env = yeoman.createEnv()
Expand Down
4 changes: 2 additions & 2 deletions src/commands/app/add/web-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ governing permissions and limitations under the License.

const BaseCommand = require('../../../BaseCommand')
const yeoman = require('yeoman-environment')
const debug = require('debug')('aio-cli-plugin-app:init')
const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app:add:web-assets', { provider: 'debug' })
const { flags } = require('@oclif/command')

const config = require('@adobe/aio-lib-core-config')
Expand All @@ -20,7 +20,7 @@ class AddWebAssetsCommand extends BaseCommand {
async run () {
const { args, flags } = this.parse(AddWebAssetsCommand)

debug(`adding component ${args.component} to the project, using flags: `, flags)
aioLogger.debug(`adding component ${args.component} to the project, using flags: ${flags}`)

const services = (config.get('services') || []).map(s => s.code).join(',')

Expand Down
4 changes: 2 additions & 2 deletions src/commands/app/delete/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ governing permissions and limitations under the License.

const BaseCommand = require('../../../BaseCommand')
const yeoman = require('yeoman-environment')
const debug = require('debug')('aio-cli-plugin-app:init')
const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app:delete:action', { provider: 'debug' })
const { flags } = require('@oclif/command')

class DeleteActionCommand extends BaseCommand {
async run () {
const { args, flags } = this.parse(DeleteActionCommand)

debug('deleting an action from the project, with args', args, 'and flags:', flags)
aioLogger.debug(`deleting an action from the project, with args ${args}, and flags: ${flags}`)

// is there an oclif mechanism for flag depends on arg?
if (flags.yes && !args['action-name']) {
Expand Down
4 changes: 2 additions & 2 deletions src/commands/app/delete/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ governing permissions and limitations under the License.

const BaseCommand = require('../../../BaseCommand')
const yeoman = require('yeoman-environment')
const debug = require('debug')('aio-cli-plugin-app:init')
const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app:add:action', { provider: 'debug' })
const { flags } = require('@oclif/command')

class DeleteCICommand extends BaseCommand {
async run () {
const { flags } = this.parse(DeleteCICommand)

debug('deleting CI files from the project, using flags: ', flags)
aioLogger.debug(`deleting CI files from the project, using flags: ${flags}`)

const generator = '@adobe/generator-aio-app/generators/delete-ci'

Expand Down
4 changes: 2 additions & 2 deletions src/commands/app/delete/web-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ governing permissions and limitations under the License.

const BaseCommand = require('../../../BaseCommand')
const yeoman = require('yeoman-environment')
const debug = require('debug')('aio-cli-plugin-app:init')
const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app:add:action', { provider: 'debug' })
const { flags } = require('@oclif/command')

class DeleteWebAssetsCommand extends BaseCommand {
async run () {
const { flags } = this.parse(DeleteWebAssetsCommand)

debug('deleting web assets from the project, using flags: ', flags)
aioLogger.debug(`deleting web assets from the project, using flags: ${flags}`)

// todo should we undeploy web assets or leave it to the user ?

Expand Down
2 changes: 1 addition & 1 deletion src/commands/app/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class InitCommand extends BaseCommand {
}

const env = yeoman.createEnv()
aioLogger.debug('creating new app with init command ', flags)
aioLogger.debug(`creating new app with init command: ${flags}`)

// default project name and services
let projectName = path.basename(process.cwd())
Expand Down
12 changes: 6 additions & 6 deletions src/lib/app-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const execa = require('execa')
const fs = require('fs-extra')
const path = require('path')
const which = require('which')
const debug = require('debug')('aio-cli-plugin-app:app-helper')
const aioLogger = require('@adobe/aio-lib-core-logging')('@adobe/aio-cli-plugin-app:lib-app-helper', { provider: 'debug' })
const { getToken, context } = require('@adobe/aio-lib-ims')
const { CLI } = require('@adobe/aio-lib-ims/src/context')

Expand All @@ -30,13 +30,13 @@ function isGitInstalled () {

/** @private */
async function installPackage (dir) {
debug(`running npm install : ${dir}`)
aioLogger.debug(`running npm install : ${dir}`)
if (!(fs.statSync(dir).isDirectory())) {
debug(`${dir} is not a directory`)
aioLogger.debug(`${dir} is not a directory`)
throw new Error(`${dir} is not a directory`)
}
if (!fs.readdirSync(dir).includes('package.json')) {
debug(`${dir} does not contain a package.json file.`)
aioLogger.debug(`${dir} does not contain a package.json file.`)
throw new Error(`${dir} does not contain a package.json file.`)
}
// npm install
Expand All @@ -48,7 +48,7 @@ async function runPackageScript (scriptName, dir, cmdArgs = []) {
if (!dir) {
dir = process.cwd()
}
debug(`running npm run-script ${scriptName} in dir: ${dir}`)
aioLogger.debug(`running npm run-script ${scriptName} in dir: ${dir}`)
const pkg = await fs.readJSON(path.join(dir, 'package.json'))
if (pkg && pkg.scripts && pkg.scripts[scriptName]) {
return execa('npm', ['run-script', scriptName].concat(cmdArgs), { cwd: dir, stdio: 'inherit' })
Expand Down Expand Up @@ -77,7 +77,7 @@ async function getCliInfo () {
const { env = 'prod' } = await context.getCli() || {}
await context.setCli({ '$cli.bare-output': true }, false) // set this globally

debug('Retrieving CLI Token')
aioLogger.debug('Retrieving CLI Token')
const accessToken = await getToken(CLI)

return { accessToken, env }
Expand Down
2 changes: 1 addition & 1 deletion src/lib/import.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ function transformCredentials (credentials, imsOrgId) {

// enrich jwt credentials with ims org id
if (credential && credential.jwt && !credential.jwt.ims_org_id) {
aioLogger.debug('adding ims_org_id to $ims.jwt config')
aioLogger.debug('adding ims_org_id to ims.jwt config')
credential.jwt.ims_org_id = imsOrgId
}

Expand Down

0 comments on commit 5fc0487

Please sign in to comment.