@oclif/plugin-plugins
Advanced tools
Comparing version 5.0.21 to 5.0.22-dev.0
import { Interfaces } from '@oclif/core'; | ||
import { ExecOptions, Output } from './fork.js'; | ||
import { LogLevel } from './log-level.js'; | ||
import { ExecOptions, Output } from './spawn.js'; | ||
type InstallOptions = { | ||
@@ -22,3 +22,4 @@ prod?: boolean; | ||
* Get the path to the npm CLI file. | ||
* This will always resolve npm to the pinned version in `@oclif/plugin-plugins/package.json`. | ||
* This will resolve npm to the pinned version in `@oclif/plugin-plugins/package.json` if it exists. | ||
* Otherwise, it will use the globally installed npm. | ||
* | ||
@@ -25,0 +26,0 @@ * @returns The path to the `npm/bin/npm-cli.js` file. |
@@ -1,2 +0,2 @@ | ||
import { ux } from '@oclif/core'; | ||
import { Errors, ux } from '@oclif/core'; | ||
import makeDebug from 'debug'; | ||
@@ -6,3 +6,3 @@ import { readFile } from 'node:fs/promises'; | ||
import { join, sep } from 'node:path'; | ||
import { fork } from './fork.js'; | ||
import { spawn } from './spawn.js'; | ||
const debug = makeDebug('@oclif/plugin-plugins:npm'); | ||
@@ -28,3 +28,3 @@ export class NPM { | ||
try { | ||
const output = await fork(bin, args, options); | ||
const output = await spawn(bin, args, options); | ||
debug('npm done'); | ||
@@ -53,3 +53,4 @@ return output; | ||
* Get the path to the npm CLI file. | ||
* This will always resolve npm to the pinned version in `@oclif/plugin-plugins/package.json`. | ||
* This will resolve npm to the pinned version in `@oclif/plugin-plugins/package.json` if it exists. | ||
* Otherwise, it will use the globally installed npm. | ||
* | ||
@@ -61,8 +62,17 @@ * @returns The path to the `npm/bin/npm-cli.js` file. | ||
return this.bin; | ||
const npmPjsonPath = createRequire(import.meta.url).resolve('npm/package.json'); | ||
const npmPjson = JSON.parse(await readFile(npmPjsonPath, { encoding: 'utf8' })); | ||
const npmPath = npmPjsonPath.slice(0, Math.max(0, npmPjsonPath.lastIndexOf(sep))); | ||
this.bin = join(npmPath, npmPjson.bin.npm); | ||
try { | ||
const npmPjsonPath = createRequire(import.meta.url).resolve('npm/package.json'); | ||
const npmPjson = JSON.parse(await readFile(npmPjsonPath, { encoding: 'utf8' })); | ||
const npmPath = npmPjsonPath.slice(0, Math.max(0, npmPjsonPath.lastIndexOf(sep))); | ||
this.bin = join(npmPath, npmPjson.bin.npm); | ||
} | ||
catch { | ||
const { default: which } = await import('which'); | ||
this.bin = await which('npm'); | ||
} | ||
if (!this.bin) { | ||
throw new Errors.CLIError('npm not found'); | ||
} | ||
return this.bin; | ||
} | ||
} |
@@ -270,3 +270,2 @@ import { Config, Errors, ux } from '@oclif/core'; | ||
async update() { | ||
// eslint-disable-next-line unicorn/no-await-expression-member | ||
let plugins = (await this.list()).filter((p) => p.type === 'user'); | ||
@@ -273,0 +272,0 @@ if (plugins.length === 0) |
import { Interfaces } from '@oclif/core'; | ||
import { ExecOptions, Output } from './fork.js'; | ||
import { LogLevel } from './log-level.js'; | ||
import { ExecOptions, Output } from './spawn.js'; | ||
export declare class Yarn { | ||
private bin; | ||
private config; | ||
@@ -6,0 +7,0 @@ private logLevel; |
@@ -1,9 +0,10 @@ | ||
import { ux } from '@oclif/core'; | ||
import { Errors, ux } from '@oclif/core'; | ||
import makeDebug from 'debug'; | ||
import { createRequire } from 'node:module'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { fork } from './fork.js'; | ||
import { spawn } from './spawn.js'; | ||
const require = createRequire(import.meta.url); | ||
const debug = makeDebug('@oclif/plugin-plugins:yarn'); | ||
export class Yarn { | ||
bin; | ||
config; | ||
@@ -27,3 +28,3 @@ logLevel; | ||
try { | ||
const output = await fork(bin, args, options); | ||
const output = await spawn(bin, args, options); | ||
debug('yarn done'); | ||
@@ -41,4 +42,16 @@ return output; | ||
async findYarn() { | ||
return require.resolve('yarn/bin/yarn.js', { paths: [this.config.root, fileURLToPath(import.meta.url)] }); | ||
if (this.bin) | ||
return this.bin; | ||
try { | ||
this.bin = require.resolve('yarn/bin/yarn.js', { paths: [this.config.root, fileURLToPath(import.meta.url)] }); | ||
} | ||
catch { | ||
const { default: which } = await import('which'); | ||
this.bin = await which('yarn'); | ||
} | ||
if (!this.bin) { | ||
throw new Errors.CLIError('yarn not found'); | ||
} | ||
return this.bin; | ||
} | ||
} |
@@ -395,3 +395,3 @@ { | ||
}, | ||
"version": "5.0.21" | ||
"version": "5.0.22-dev.0" | ||
} |
{ | ||
"name": "@oclif/plugin-plugins", | ||
"description": "plugins plugin for oclif", | ||
"version": "5.0.21", | ||
"version": "5.0.22-dev.0", | ||
"author": "Salesforce", | ||
@@ -17,2 +17,3 @@ "bugs": "https://github.com/oclif/plugin-plugins/issues", | ||
"validate-npm-package-name": "^5.0.0", | ||
"which": "^4.0.0", | ||
"yarn": "^1.22.22" | ||
@@ -32,2 +33,3 @@ }, | ||
"@types/validate-npm-package-name": "^4.0.2", | ||
"@types/which": "^3.0.3", | ||
"chai": "^4.4.1", | ||
@@ -42,3 +44,3 @@ "commitlint": "^18", | ||
"mocha": "^10.4.0", | ||
"oclif": "^4.10.1", | ||
"oclif": "^4.10.7", | ||
"prettier": "^3.2.5", | ||
@@ -45,0 +47,0 @@ "shx": "^0.3.4", |
@@ -121,3 +121,3 @@ # @oclif/plugin-plugins | ||
_See code: [src/commands/plugins/index.ts](https://github.com/oclif/plugin-plugins/blob/v5.0.21/src/commands/plugins/index.ts)_ | ||
_See code: [src/commands/plugins/index.ts](https://github.com/oclif/plugin-plugins/blob/v5.0.22-dev.0/src/commands/plugins/index.ts)_ | ||
@@ -196,3 +196,3 @@ ## `mycli plugins add PLUGIN` | ||
_See code: [src/commands/plugins/inspect.ts](https://github.com/oclif/plugin-plugins/blob/v5.0.21/src/commands/plugins/inspect.ts)_ | ||
_See code: [src/commands/plugins/inspect.ts](https://github.com/oclif/plugin-plugins/blob/v5.0.22-dev.0/src/commands/plugins/inspect.ts)_ | ||
@@ -246,3 +246,3 @@ ## `mycli plugins install PLUGIN` | ||
_See code: [src/commands/plugins/install.ts](https://github.com/oclif/plugin-plugins/blob/v5.0.21/src/commands/plugins/install.ts)_ | ||
_See code: [src/commands/plugins/install.ts](https://github.com/oclif/plugin-plugins/blob/v5.0.22-dev.0/src/commands/plugins/install.ts)_ | ||
@@ -277,3 +277,3 @@ ## `mycli plugins link PATH` | ||
_See code: [src/commands/plugins/link.ts](https://github.com/oclif/plugin-plugins/blob/v5.0.21/src/commands/plugins/link.ts)_ | ||
_See code: [src/commands/plugins/link.ts](https://github.com/oclif/plugin-plugins/blob/v5.0.22-dev.0/src/commands/plugins/link.ts)_ | ||
@@ -319,3 +319,3 @@ ## `mycli plugins remove [PLUGIN]` | ||
_See code: [src/commands/plugins/reset.ts](https://github.com/oclif/plugin-plugins/blob/v5.0.21/src/commands/plugins/reset.ts)_ | ||
_See code: [src/commands/plugins/reset.ts](https://github.com/oclif/plugin-plugins/blob/v5.0.22-dev.0/src/commands/plugins/reset.ts)_ | ||
@@ -348,3 +348,3 @@ ## `mycli plugins uninstall [PLUGIN]` | ||
_See code: [src/commands/plugins/uninstall.ts](https://github.com/oclif/plugin-plugins/blob/v5.0.21/src/commands/plugins/uninstall.ts)_ | ||
_See code: [src/commands/plugins/uninstall.ts](https://github.com/oclif/plugin-plugins/blob/v5.0.22-dev.0/src/commands/plugins/uninstall.ts)_ | ||
@@ -393,3 +393,3 @@ ## `mycli plugins unlink [PLUGIN]` | ||
_See code: [src/commands/plugins/update.ts](https://github.com/oclif/plugin-plugins/blob/v5.0.21/src/commands/plugins/update.ts)_ | ||
_See code: [src/commands/plugins/update.ts](https://github.com/oclif/plugin-plugins/blob/v5.0.22-dev.0/src/commands/plugins/update.ts)_ | ||
<!-- commandsstop --> | ||
@@ -396,0 +396,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
86532
1905
11
27
1
+ Addedwhich@^4.0.0
+ Addedisexe@3.1.1(transitive)
+ Addedwhich@4.0.0(transitive)