A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/npm/cli/commit/c209e989b405fa3e86df7015c22e6840e18313b8 below:

Remove table output from many commands · npm/cli@c209e98 · GitHub

1 1

const cacache = require('cacache')

2 2

const fs = require('fs')

3 3

const fetch = require('make-fetch-happen')

4 -

const Table = require('cli-table3')

5 4

const which = require('which')

6 5

const pacote = require('pacote')

7 6

const { resolve } = require('path')

@@ -34,57 +33,59 @@ const maskLabel = mask => {

34 33 35 34

const subcommands = [

36 35

{

37 -

groups: ['ping', 'registry'],

38 -

title: 'npm ping',

36 +

// Ping is left in as a legacy command but is listed as "connection" to

37 +

// make more sense to more people

38 +

groups: ['connection', 'ping', 'registry'],

39 +

title: 'Connecting to the registry',

39 40

cmd: 'checkPing',

40 41

}, {

41 42

groups: ['versions'],

42 -

title: 'npm -v',

43 +

title: 'Checking npm version',

43 44

cmd: 'getLatestNpmVersion',

44 45

}, {

45 46

groups: ['versions'],

46 -

title: 'node -v',

47 +

title: 'Checking node version',

47 48

cmd: 'getLatestNodejsVersion',

48 49

}, {

49 50

groups: ['registry'],

50 -

title: 'npm config get registry',

51 +

title: 'Checking configured npm registry',

51 52

cmd: 'checkNpmRegistry',

52 53

}, {

53 54

groups: ['environment'],

54 -

title: 'git executable in PATH',

55 +

title: 'Checking for git executable in PATH',

55 56

cmd: 'getGitPath',

56 57

}, {

57 58

groups: ['environment'],

58 -

title: 'global bin folder in PATH',

59 +

title: 'Checking for global bin folder in PATH',

59 60

cmd: 'getBinPath',

60 61

}, {

61 62

groups: ['permissions', 'cache'],

62 -

title: 'Perms check on cached files',

63 +

title: 'Checking permissions on cached files (this may take awhile)',

63 64

cmd: 'checkCachePermission',

64 65

windows: false,

65 66

}, {

66 67

groups: ['permissions'],

67 -

title: 'Perms check on local node_modules',

68 +

title: 'Checking permissions on local node_modules (this may take awhile)',

68 69

cmd: 'checkLocalModulesPermission',

69 70

windows: false,

70 71

}, {

71 72

groups: ['permissions'],

72 -

title: 'Perms check on global node_modules',

73 +

title: 'Checking permissions on global node_modules (this may take awhile)',

73 74

cmd: 'checkGlobalModulesPermission',

74 75

windows: false,

75 76

}, {

76 77

groups: ['permissions'],

77 -

title: 'Perms check on local bin folder',

78 +

title: 'Checking permissions on local bin folder',

78 79

cmd: 'checkLocalBinPermission',

79 80

windows: false,

80 81

}, {

81 82

groups: ['permissions'],

82 -

title: 'Perms check on global bin folder',

83 +

title: 'Checking permissions on global bin folder',

83 84

cmd: 'checkGlobalBinPermission',

84 85

windows: false,

85 86

}, {

86 87

groups: ['cache'],

87 -

title: 'Verify cache contents',

88 +

title: 'Verifying cache contents (this may take awhile)',

88 89

cmd: 'verifyCachedFiles',

89 90

windows: false,

90 91

},

@@ -104,43 +105,28 @@ class Doctor extends BaseCommand {

104 105

static params = ['registry']

105 106

static ignoreImplicitWorkspace = false

106 107

static usage = [`[${subcommands.flatMap(s => s.groups)

107 -

.filter((value, index, self) => self.indexOf(value) === index)

108 +

.filter((value, index, self) => self.indexOf(value) === index && value !== 'ping')

108 109

.join('] [')}]`]

109 110 110 111

static subcommands = subcommands

111 112 112 -

// minimum width of check column, enough for the word `Check`

113 -

#checkWidth = 5

114 - 115 113

async exec (args) {

116 114

log.info('doctor', 'Running checkup')

117 115

let allOk = true

118 116 119 117

const actions = this.actions(args)

120 -

this.#checkWidth = actions.reduce((length, item) =>

121 -

Math.max(item.title.length, length), this.#checkWidth)

122 118 123 -

if (!this.npm.silent) {

124 -

this.output(['Check', 'Value', 'Recommendation/Notes'].map(h => this.npm.chalk.underline(h)))

125 -

}

126 -

// Do the actual work

119 +

const chalk = this.npm.chalk

127 120

for (const { title, cmd } of actions) {

128 -

const item = [title]

121 +

this.output(title)

122 +

// TODO when we have an in progress indicator that could go here

123 +

let result

129 124

try {

130 -

item.push(true, await this[cmd]())

125 +

result = await this[cmd]()

126 +

this.output(`${chalk.green('Ok')}${result ? `\n${result}` : ''}\n`)

131 127

} catch (err) {

132 -

item.push(false, err)

133 -

}

134 -

if (!item[1]) {

135 128

allOk = false

136 -

item[0] = this.npm.chalk.red(item[0])

137 -

item[1] = this.npm.chalk.red('not ok')

138 -

item[2] = this.npm.chalk.cyan(String(item[2]))

139 -

} else {

140 -

item[1] = this.npm.chalk.green('ok')

141 -

}

142 -

if (!this.npm.silent) {

143 -

this.output(item)

129 +

this.output(`${chalk.red('Not ok')}\n${chalk.cyan(err)}\n`)

144 130

}

145 131

}

146 132

@@ -343,38 +329,11 @@ class Doctor extends BaseCommand {

343 329

}

344 330

}

345 331 346 -

output (row) {

347 -

const t = new Table({

348 -

chars: {

349 -

top: '',

350 -

'top-mid': '',

351 -

'top-left': '',

352 -

'top-right': '',

353 -

bottom: '',

354 -

'bottom-mid': '',

355 -

'bottom-left': '',

356 -

'bottom-right': '',

357 -

left: '',

358 -

'left-mid': '',

359 -

mid: '',

360 -

'mid-mid': '',

361 -

right: '',

362 -

'right-mid': '',

363 -

middle: ' ',

364 -

},

365 -

style: {

366 -

'padding-left': 0,

367 -

'padding-right': 0,

368 -

// setting border here is not necessary visually since we've already

369 -

// zeroed out all the chars above, but without it cli-table3 will wrap

370 -

// some of the separator spaces with ansi codes which show up in

371 -

// snapshots.

372 -

border: 0,

373 -

},

374 -

colWidths: [this.#checkWidth, 6],

375 -

})

376 -

t.push(row)

377 -

output.standard(t.toString())

332 +

output (...args) {

333 +

// TODO display layer should do this

334 +

if (!this.npm.silent) {

335 +

output.standard(...args)

336 +

}

378 337

}

379 338 380 339

actions (params) {


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4