Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: use npm for plugin operations #776

Merged
merged 53 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from 52 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
ba6a18c
feat: add npm and pnpm options
mdonnalley Jan 18, 2024
ea2163f
Merge branch 'main' into mdonnalley/revamp
mdonnalley Jan 18, 2024
94f0668
feat!: use npm for installs
mdonnalley Jan 23, 2024
1e80a62
chore: bump to v5 prerelease
mdonnalley Jan 23, 2024
3953b9c
Merge branch 'main' into mdonnalley/revamp
mdonnalley Jan 23, 2024
737b967
fix: remove yarn.lock
mdonnalley Jan 24, 2024
d87fcbf
test: skip sf integration tests
mdonnalley Jan 24, 2024
6c3cb6f
fix: force rm yarn.lock
mdonnalley Jan 25, 2024
6ebb1fc
fix: use fork for npm show
mdonnalley Jan 25, 2024
b155136
feat: remove all yarn functionality
mdonnalley Jan 25, 2024
d7c09cb
chore: clean up
mdonnalley Jan 25, 2024
b1ea1f1
test: debug failing windows tests
mdonnalley Jan 25, 2024
3cc66c8
feat: add --npm-log-level flag
mdonnalley Jan 25, 2024
fd4f30f
chore: clean up
mdonnalley Jan 25, 2024
85b2da0
test: debug failing windows tests
mdonnalley Jan 25, 2024
002675b
test: compilation errors
mdonnalley Jan 25, 2024
b2a4d14
fix: use CLIError
mdonnalley Jan 25, 2024
9b736f6
test: debug failing windows tests
mdonnalley Jan 25, 2024
503a9d3
test: debug failing windows tests
mdonnalley Jan 25, 2024
6d23bb9
test: debug failing windows tests
mdonnalley Jan 25, 2024
0e6c372
chore: remove unused dep
mdonnalley Jan 25, 2024
daac083
chore: clean up
mdonnalley Jan 25, 2024
7e3f0a8
fix: add suggestion for failed install
mdonnalley Jan 25, 2024
dd8f69c
fix: npm-run-path is actually needed
mdonnalley Jan 25, 2024
b4da5fd
test: debug failing windows tests
mdonnalley Jan 25, 2024
409db00
test: debug failing windows tests
mdonnalley Jan 25, 2024
9331d65
test: extend timeout
mdonnalley Jan 25, 2024
be382e7
test: renable sf integration tests
mdonnalley Jan 26, 2024
d1c9d74
feat: simplify logging options
mdonnalley Jan 26, 2024
b4ef3d3
fix: clean up yarn.lock and node_modules if they exist
mdonnalley Jan 30, 2024
d044775
Merge branch 'main' into mdonnalley/revamp
mdonnalley Jan 31, 2024
57dda03
perf: spawn new process for removing node_modules
mdonnalley Jan 31, 2024
a739a4f
chore(release): 5.0.0-beta.1 [skip ci]
svc-cli-bot Feb 1, 2024
82ee43c
Merge branch 'main' into mdonnalley/revamp
mdonnalley Feb 22, 2024
95f6cac
chore(release): 5.0.0-beta.2 [skip ci]
svc-cli-bot Feb 22, 2024
eab8e5b
Merge branch 'main' into mdonnalley/revamp
mdonnalley Mar 7, 2024
6581914
chore(release): 5.0.0-beta.3 [skip ci]
svc-cli-bot Mar 7, 2024
b7eca7a
chore: merge main conflicts
iowillhoit Mar 14, 2024
7c33ba1
chore(release): 5.0.0-beta.4 [skip ci]
svc-cli-bot Mar 14, 2024
a127059
fix: reinstall plugin from url if applicable
mdonnalley Mar 21, 2024
d9a67ae
feat: better logging
mdonnalley Mar 21, 2024
7167090
fix: uninstall mis-scoped plugin
mdonnalley Mar 21, 2024
6fdb181
fix: warn about missing expected files after github install
mdonnalley Mar 21, 2024
c07eccf
fix: add type
mdonnalley Mar 21, 2024
b799b38
feat: improve ux when no output from npm
mdonnalley Mar 21, 2024
2c722b4
chore: merge main conflicts
iowillhoit Mar 22, 2024
fa30d5e
chore(release): 5.0.0-beta.5 [skip ci]
svc-cli-bot Mar 22, 2024
a53853b
fix: display name when uninstalling wiht no args
mdonnalley Mar 22, 2024
ac2c394
test: set timeout on install test
mdonnalley Mar 22, 2024
566af61
fix: ensure dir exists before checking for name
mdonnalley Mar 22, 2024
034a067
Merge branch 'main' into mdonnalley/revamp
iowillhoit Mar 25, 2024
183be3f
chore(release): 5.0.0-beta.6 [skip ci]
svc-cli-bot Mar 25, 2024
12808a5
Merge branch 'main' into mdonnalley/revamp
mdonnalley Mar 25, 2024
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
63 changes: 34 additions & 29 deletions docs/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ List installed plugins.

- [`mycli plugins`](#mycli-plugins)
- [`mycli plugins:inspect PLUGIN...`](#mycli-pluginsinspect-plugin)
- [`mycli plugins:install PLUGIN...`](#mycli-pluginsinstall-plugin)
- [`mycli plugins:link PLUGIN`](#mycli-pluginslink-plugin)
- [`mycli plugins install PLUGIN`](#mycli-plugins-install-plugin)
- [`mycli plugins link PATH`](#mycli-plugins-link-path)
- [`mycli plugins reset`](#mycli-plugins-reset)
- [`mycli plugins:uninstall PLUGIN...`](#mycli-pluginsuninstall-plugin)
- [`mycli plugins uninstall [PLUGIN]`](#mycli-plugins-uninstall-plugin)
- [`mycli plugins update`](#mycli-plugins-update)

## `mycli plugins`
Expand All @@ -31,7 +31,7 @@ EXAMPLES
$ mycli plugins
```

_See code: [src/commands/plugins/index.ts](https://github.com/oclif/plugin-plugins/blob/4.3.9/src/commands/plugins/index.ts)_
_See code: [src/commands/plugins/index.ts](https://github.com/oclif/plugin-plugins/blob/4.3.10-beta.0/src/commands/plugins/index.ts)_

## `mycli plugins:inspect PLUGIN...`

Expand All @@ -58,59 +58,64 @@ EXAMPLES
$ mycli plugins inspect myplugin
```

_See code: [src/commands/plugins/inspect.ts](https://github.com/oclif/plugin-plugins/blob/4.3.9/src/commands/plugins/inspect.ts)_
_See code: [src/commands/plugins/inspect.ts](https://github.com/oclif/plugin-plugins/blob/4.3.10-beta.0/src/commands/plugins/inspect.ts)_

## `mycli plugins:install PLUGIN...`
## `mycli plugins install PLUGIN`

Installs a plugin into the CLI.
Installs a plugin into mycli.

```
USAGE
$ mycli plugins install PLUGIN...
$ mycli plugins install PLUGIN... [--json] [-f] [-h] [-s | -v]

ARGUMENTS
PLUGIN... Plugin to install.

FLAGS
-f, --force Run yarn install with force flag.
-f, --force Force npm to fetch remote resources even if a local copy exists on disk.
-h, --help Show CLI help.
-s, --silent Silences yarn output.
-v, --verbose Show verbose yarn output.
-s, --silent Silences npm output.
-v, --verbose Show verbose npm output.

GLOBAL FLAGS
--json Format output as json.

DESCRIPTION
Installs a plugin into the CLI.
Can be installed from npm or a git url.
Installs a plugin into mycli.

Installation of a user-installed plugin will override a core plugin.
Uses bundled npm executable to install plugins into /home/runner/.local/share/@oclif/plugin-plugins

e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
the CLI without the need to patch and update the whole CLI.
Installation of a user-installed plugin will override a core plugin.

Use the MYCLI_NPM_LOG_LEVEL environment variable to set the npm loglevel.
Use the MYCLI_NPM_REGISTRY environment variable to set the npm registry.

ALIASES
$ mycli plugins add

EXAMPLES
$ mycli plugins install myplugin
Install a plugin from npm registry.

$ mycli plugins install myplugin

Install a plugin from a github url.

$ mycli plugins install https://github.com/someuser/someplugin

$ mycli plugins install https://github.com/someuser/someplugin
Install a plugin from a github slug.

$ mycli plugins install someuser/someplugin
$ mycli plugins install someuser/someplugin
```

_See code: [src/commands/plugins/install.ts](https://github.com/oclif/plugin-plugins/blob/4.3.9/src/commands/plugins/install.ts)_
_See code: [src/commands/plugins/install.ts](https://github.com/oclif/plugin-plugins/blob/4.3.10-beta.0/src/commands/plugins/install.ts)_

## `mycli plugins:link PLUGIN`
## `mycli plugins link PATH`

Links a plugin into the CLI for development.

```
USAGE
$ mycli plugins link PLUGIN
$ mycli plugins link PATH [-h] [--install] [-v]

ARGUMENTS
PATH [default: .] path to plugin
Expand All @@ -132,7 +137,7 @@ EXAMPLES
$ mycli plugins link myplugin
```

_See code: [src/commands/plugins/link.ts](https://github.com/oclif/plugin-plugins/blob/4.3.9/src/commands/plugins/link.ts)_
_See code: [src/commands/plugins/link.ts](https://github.com/oclif/plugin-plugins/blob/4.3.10-beta.0/src/commands/plugins/link.ts)_

## `mycli plugins reset`

Expand All @@ -147,15 +152,15 @@ FLAGS
--reinstall Reinstall all plugins after uninstalling.
```

_See code: [src/commands/plugins/reset.ts](https://github.com/oclif/plugin-plugins/blob/4.3.9/src/commands/plugins/reset.ts)_
_See code: [src/commands/plugins/reset.ts](https://github.com/oclif/plugin-plugins/blob/4.3.10-beta.0/src/commands/plugins/reset.ts)_

## `mycli plugins:uninstall PLUGIN...`
## `mycli plugins uninstall [PLUGIN]`

Removes a plugin from the CLI.

```
USAGE
$ mycli plugins uninstall PLUGIN...
$ mycli plugins uninstall [PLUGIN...] [-h] [-v]

ARGUMENTS
PLUGIN... plugin to uninstall
Expand All @@ -175,7 +180,7 @@ EXAMPLES
$ mycli plugins uninstall myplugin
```

_See code: [src/commands/plugins/uninstall.ts](https://github.com/oclif/plugin-plugins/blob/4.3.9/src/commands/plugins/uninstall.ts)_
_See code: [src/commands/plugins/uninstall.ts](https://github.com/oclif/plugin-plugins/blob/4.3.10-beta.0/src/commands/plugins/uninstall.ts)_

## `mycli plugins update`

Expand All @@ -193,4 +198,4 @@ DESCRIPTION
Update installed plugins.
```

_See code: [src/commands/plugins/update.ts](https://github.com/oclif/plugin-plugins/blob/4.3.9/src/commands/plugins/update.ts)_
_See code: [src/commands/plugins/update.ts](https://github.com/oclif/plugin-plugins/blob/4.3.10-beta.0/src/commands/plugins/update.ts)_
19 changes: 9 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
{
"name": "@oclif/plugin-plugins",
"description": "plugins plugin for oclif",
"version": "4.3.9",
"version": "5.0.0-beta.6",
"author": "Salesforce",
"bugs": "https://github.com/oclif/plugin-plugins/issues",
"dependencies": {
"@oclif/core": "^3.25.2",
"chalk": "^5.3.0",
"debug": "^4.3.4",
"npm": "10.5.0",
"npm-run-path": "^4.0.1",
"npm-package-arg": "^11.0.1",
"npm-run-path": "^5.2.0",
"semver": "^7.6.0",
"shelljs": "^0.8.5",
"validate-npm-package-name": "^5.0.0",
"yarn": "^1.22.21"
"validate-npm-package-name": "^5.0.0"
},
"devDependencies": {
"@commitlint/config-conventional": "^18",
Expand All @@ -23,6 +22,7 @@
"@types/debug": "^4.1.12",
"@types/mocha": "^10.0.6",
"@types/node": "^18",
"@types/npm-package-arg": "^6.1.4",
"@types/semver": "^7.5.8",
"@types/shelljs": "^0.8.15",
"@types/sinon": "^17",
Expand Down Expand Up @@ -50,8 +50,7 @@
"files": [
"oclif.manifest.json",
"/lib",
"npm-shrinkwrap.json",
"oclif.lock"
"npm-shrinkwrap.json"
],
"homepage": "https://github.com/oclif/plugin-plugins",
"keywords": [
Expand All @@ -77,15 +76,15 @@
"repository": "oclif/plugin-plugins",
"scripts": {
"build": "shx rm -rf lib && tsc",
"clean": "shx rm -f oclif.manifest.json npm-shrinkwrap.json oclif.lock",
"clean": "shx rm -f oclif.manifest.json npm-shrinkwrap.json",
"compile": "tsc",
"lint": "eslint . --ext .ts",
"postpack": "yarn run clean",
"posttest": "yarn lint",
"prepack": "yarn build && oclif manifest && oclif readme && npm shrinkwrap && oclif lock",
"prepack": "yarn build && oclif manifest && oclif readme && npm shrinkwrap",
"prepare": "husky && yarn build",
"pretest": "yarn build --noEmit && tsc -p test --noEmit",
"test:integration:install": "mocha \"test/**/install.integration.ts\"",
"test:integration:install": "mocha \"test/**/install.integration.ts\" --timeout 1200000",
"test:integration:link": "mocha \"test/**/link.integration.ts\"",
"test:integration:sf": "mocha \"test/**/sf.integration.ts\"",
"test:integration": "mocha \"test/**/*.integration.ts\"",
Expand Down
6 changes: 5 additions & 1 deletion src/commands/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ export default class PluginsIndex extends Command {
core: Flags.boolean({description: 'Show core plugins.'}),
}

plugins = new Plugins(this.config)
plugins!: Plugins

async run(): Promise<PluginsJson> {
const {flags} = await this.parse(PluginsIndex)
this.plugins = new Plugins({
config: this.config,
})

let plugins = this.config.getPluginsList()
sortBy(plugins, (p) => this.plugins.friendlyName(p.name))
if (!flags.core) {
Expand Down
8 changes: 6 additions & 2 deletions src/commands/plugins/inspect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import chalk from 'chalk'
import {readFile} from 'node:fs/promises'
import {dirname, join, sep} from 'node:path'

import {determineLogLevel} from '../../log-level.js'
import Plugins from '../../plugins.js'
import {sortBy} from '../../util.js'

Expand Down Expand Up @@ -59,7 +60,7 @@ export default class PluginsInspect extends Command {

static usage = 'plugins:inspect PLUGIN...'

plugins = new Plugins(this.config)
plugins!: Plugins

async findDep(plugin: Plugin, dependency: string): Promise<{pkgPath: null | string; version: null | string}> {
const dependencyPath = join(...dependency.split('/'))
Expand Down Expand Up @@ -140,7 +141,10 @@ export default class PluginsInspect extends Command {
/* eslint-disable no-await-in-loop */
async run(): Promise<PluginWithDeps[]> {
const {argv, flags} = await this.parse(PluginsInspect)
if (flags.verbose) this.plugins.verbose = true
this.plugins = new Plugins({
config: this.config,
logLevel: determineLogLevel(this.config, flags, 'silent'),
})
const aliases = this.config.pjson.oclif.aliases ?? {}
const plugins: PluginWithDeps[] = []
for (let name of argv as string[]) {
Expand Down
Loading
Loading