Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 3 additions & 102 deletions eslint-suppressions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@
}
},
"src/commands/plugins/index.ts": {
"@stylistic/lines-between-class-members": {
"count": 1
},
"@typescript-eslint/consistent-type-definitions": {
"count": 1
},
"@typescript-eslint/consistent-type-imports": {
"count": 1
},
"@typescript-eslint/no-unnecessary-type-conversion": {
"count": 1
},
Expand All @@ -37,20 +28,11 @@
"@eslint-community/eslint-comments/require-description": {
"count": 1
},
"@stylistic/lines-between-class-members": {
"count": 2
},
"@typescript-eslint/consistent-type-imports": {
"count": 1
},
"@typescript-eslint/no-restricted-types": {
"count": 3
},
"@typescript-eslint/no-unsafe-argument": {
"count": 1
},
"@typescript-eslint/no-unsafe-assignment": {
"count": 3
"count": 4
},
"@typescript-eslint/no-unsafe-call": {
"count": 1
Expand All @@ -64,9 +46,6 @@
"unicorn/consistent-boolean-name": {
"count": 1
},
"unicorn/consistent-conditional-object-spread": {
"count": 2
},
"unicorn/import-style": {
"count": 1
},
Expand All @@ -78,12 +57,6 @@
"@eslint-community/eslint-comments/require-description": {
"count": 1
},
"@stylistic/lines-between-class-members": {
"count": 3
},
"@typescript-eslint/consistent-type-imports": {
"count": 1
},
"@typescript-eslint/no-shadow": {
"count": 1
},
Expand All @@ -95,26 +68,12 @@
},
"unicorn/no-computed-property-existence-check": {
"count": 1
},
"unicorn/no-unnecessary-boolean-comparison": {
"count": 1
}
},
"src/commands/plugins/link.ts": {
"@stylistic/lines-between-class-members": {
"count": 2
}
},
"src/commands/plugins/reset.ts": {
"@eslint-community/eslint-comments/require-description": {
"count": 1
},
"@stylistic/lines-between-class-members": {
"count": 1
},
"@typescript-eslint/promise-function-async": {
"count": 1
},
"unicorn/import-style": {
"count": 1
},
Expand All @@ -125,28 +84,9 @@
"src/commands/plugins/uninstall.ts": {
"@eslint-community/eslint-comments/require-description": {
"count": 1
},
"@stylistic/lines-between-class-members": {
"count": 2
},
"@typescript-eslint/no-unnecessary-type-assertion": {
"count": 2
}
},
"src/hooks/update.ts": {
"@typescript-eslint/consistent-type-imports": {
"count": 1
}
},
"src/log-level.ts": {
"@typescript-eslint/consistent-type-imports": {
"count": 1
}
},
"src/npm.ts": {
"@typescript-eslint/consistent-type-imports": {
"count": 3
},
"@typescript-eslint/default-param-last": {
"count": 1
},
Expand All @@ -159,9 +99,6 @@
"@typescript-eslint/no-unsafe-member-access": {
"count": 1
},
"@typescript-eslint/prefer-readonly": {
"count": 2
},
"unicorn/consistent-class-member-order": {
"count": 1
},
Expand All @@ -170,12 +107,6 @@
}
},
"src/plugins.ts": {
"@typescript-eslint/consistent-type-imports": {
"count": 3
},
"@typescript-eslint/no-confusing-void-expression": {
"count": 1
},
"@typescript-eslint/no-dynamic-delete": {
"count": 1
},
Expand All @@ -195,12 +126,9 @@
"count": 1
},
"unicorn/consistent-boolean-name": {
"count": 2
},
"unicorn/consistent-class-member-order": {
"count": 1
},
"unicorn/consistent-conditional-object-spread": {
"unicorn/consistent-class-member-order": {
"count": 1
},
"unicorn/import-style": {
Expand All @@ -211,15 +139,9 @@
},
"unicorn/prefer-array-some": {
"count": 1
},
"unicorn/prefer-early-return": {
"count": 1
}
},
"src/spawn.ts": {
"@typescript-eslint/consistent-type-imports": {
"count": 1
},
"@typescript-eslint/default-param-last": {
"count": 1
},
Expand All @@ -228,9 +150,6 @@
},
"n/prefer-global/buffer": {
"count": 2
},
"unicorn/consistent-boolean-name": {
"count": 1
}
},
"src/util.ts": {
Expand All @@ -243,26 +162,17 @@
"unicorn/no-array-sort": {
"count": 1
},
"unicorn/no-negated-array-predicate": {
"count": 1
},
"unicorn/no-useless-recursion": {
"count": 1
}
},
"src/yarn.ts": {
"@typescript-eslint/consistent-type-imports": {
"count": 3
},
"@typescript-eslint/default-param-last": {
"count": 1
},
"@typescript-eslint/no-unused-private-class-members": {
"count": 1
},
"@typescript-eslint/prefer-readonly": {
"count": 2
},
"unicorn/consistent-class-member-order": {
"count": 1
}
Expand All @@ -281,9 +191,6 @@
}
},
"test/integration/link.integration.ts": {
"@typescript-eslint/no-confusing-void-expression": {
"count": 1
},
"unicorn/import-style": {
"count": 1
}
Expand All @@ -303,17 +210,11 @@
}
},
"test/plugins.test.ts": {
"@typescript-eslint/array-type": {
"count": 2
},
"@typescript-eslint/consistent-type-imports": {
"count": 2
},
"@typescript-eslint/prefer-nullish-coalescing": {
"count": 1
},
"unicorn/import-style": {
"count": 1
}
}
}
}
5 changes: 3 additions & 2 deletions src/commands/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command, Flags, Interfaces, Plugin} from '@oclif/core'
import {Command, Flags, type Interfaces, type Plugin} from '@oclif/core'
import {dim} from 'ansis'
// @ts-expect-error because object-treeify does not have types: https://github.com/blackflux/object-treeify/issues/1077
import treeify from 'object-treeify'
Expand All @@ -8,7 +8,7 @@ import {sortBy} from '../../util.js'

type JitPlugin = {name: string; type: string; version: string}
type PluginsJson = Array<Interfaces.Plugin | JitPlugin>
interface RecursiveTree {
type RecursiveTree = {
[key: string]: RecursiveTree | string
}

Expand All @@ -19,6 +19,7 @@ export default class PluginsIndex extends Command {
static flags = {
core: Flags.boolean({description: 'Show core plugins.'}),
}

plugins!: Plugins

public async run(): Promise<PluginsJson> {
Expand Down
19 changes: 12 additions & 7 deletions src/commands/plugins/inspect.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Args, Command, Flags, Plugin} from '@oclif/core'
import {Args, Command, Flags, type Plugin} from '@oclif/core'
import {bold, dim} from 'ansis'
import {readFile} from 'node:fs/promises'
import {dirname, join, sep} from 'node:path'
Expand Down Expand Up @@ -46,18 +46,23 @@ export default class PluginsInspect extends Command {
required: true,
}),
}

static description = 'Displays installation properties of a plugin.'
static enableJsonFlag = true
static examples = ['<%= config.bin %> <%= command.id %> <%- config.pjson.oclif.examplePlugin || "myplugin" %> ']
static flags = {
help: Flags.help({char: 'h'}),
verbose: Flags.boolean({char: 'v'}),
}

static strict = false
static usage = 'plugins:inspect PLUGIN...'
plugins!: Plugins

async findDep(plugin: Plugin, dependency: string): Promise<{pkgPath: null | string; version: null | string}> {
async findDep(
plugin: Plugin,
dependency: string,
): Promise<{pkgPath: string | undefined; version: string | undefined}> {
const dependencyPath = join(...dependency.split('/'))
let start = join(plugin.root, 'node_modules')
const paths = [start]
Expand All @@ -80,7 +85,7 @@ export default class PluginsInspect extends Command {
}
}

return {pkgPath: null, version: null}
return {pkgPath: undefined, version: undefined}
}

findPlugin(pluginName: string): Plugin {
Expand All @@ -98,7 +103,7 @@ export default class PluginsInspect extends Command {

async inspect(pluginName: string, verbose = false): Promise<PluginWithDeps> {
const plugin = this.findPlugin(pluginName)
const dependencies: Record<string, null> = {}
const dependencies: Record<string, undefined> = {}
const depsJson: Dependencies = {}
for (const dep of sortBy(Object.keys({...plugin.pjson.dependencies}), (d) => d)) {
// eslint-disable-next-line no-await-in-loop
Expand All @@ -109,15 +114,15 @@ export default class PluginsInspect extends Command {
const versionMsg = dim(from ? `${from} => ${version}` : version)
const msg = verbose ? `${dep} ${versionMsg} ${pkgPath}` : `${dep} ${versionMsg}`

dependencies[msg] = null
dependencies[msg] = undefined
depsJson[dep] = {from, version}
}

const tree = {
[bold.cyan(plugin.name)]: {
[`version ${plugin.version}`]: null,
...(plugin.tag ? {[`tag ${plugin.tag}`]: null} : {}),
...(plugin.pjson.homepage ? {[`homepage ${plugin.pjson.homepage}`]: null} : {}),
...(plugin.tag && {[`tag ${plugin.tag}`]: null}),
...(plugin.pjson.homepage && {[`homepage ${plugin.pjson.homepage}`]: null}),
[`location ${plugin.root}`]: null,
commands: Object.fromEntries(sortBy(plugin.commandIDs, (c) => c).map((id) => [id, null])),
dependencies,
Expand Down
7 changes: 5 additions & 2 deletions src/commands/plugins/install.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-await-in-loop */
import {Args, Command, Errors, Flags, Interfaces, Plugin, ux} from '@oclif/core'
import {Args, Command, Errors, Flags, type Interfaces, Plugin, ux} from '@oclif/core'
import {bold, cyan} from 'ansis'
import validate from 'validate-npm-package-name'

Expand All @@ -11,6 +11,7 @@ export default class PluginsInstall extends Command {
static args = {
plugin: Args.string({description: 'Plugin to install.', required: true}),
}

static description = `Uses npm to install plugins.

Installation of a user-installed plugin will override a core plugin.
Expand All @@ -32,6 +33,7 @@ Use the <%= config.scopedEnvVarKey('NPM_REGISTRY') %> environment variable to se
description: 'Install a plugin from a github slug.',
},
]

static flags = {
force: Flags.boolean({
char: 'f',
Expand All @@ -41,7 +43,7 @@ Use the <%= config.scopedEnvVarKey('NPM_REGISTRY') %> environment variable to se
jit: Flags.boolean({
hidden: true,
async parse(input, ctx) {
if (input === false || input === undefined) return input
if (!input || input === undefined) return input

const requestedPlugins = ctx.argv.filter((a) => !a.startsWith('-'))
if (requestedPlugins.length === 0) return input
Expand Down Expand Up @@ -77,6 +79,7 @@ Use the <%= config.scopedEnvVarKey('NPM_REGISTRY') %> environment variable to se
exclusive: ['silent'],
}),
}

static strict = false
static summary = 'Installs a plugin into <%= config.bin %>.'
flags!: Interfaces.InferredFlags<typeof PluginsInstall.flags>
Expand Down
2 changes: 2 additions & 0 deletions src/commands/plugins/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default class PluginsLink extends Command {
static args = {
path: Args.string({default: '.', description: 'path to plugin', name: 'path', required: true}),
}

static description = `Installation of a linked plugin will override a user-installed or core plugin.

e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello' command will override the user-installed or core plugin implementation. This is useful for development work.
Expand All @@ -22,6 +23,7 @@ e.g. If you have a user-installed or core plugin that has a 'hello' command, ins
}),
verbose: Flags.boolean({char: 'v'}),
}

static summary = 'Links a plugin into the CLI for development.'

async run(): Promise<void> {
Expand Down
Loading
Loading