package-manager-manager
Advanced tools
Comparing version 0.1.2 to 0.1.3-69fef32
@@ -1,2 +0,2 @@ | ||
var w = (r, e, s) => { | ||
var b = (r, e, s) => { | ||
if (!e.has(r)) | ||
@@ -10,3 +10,3 @@ throw TypeError("Cannot " + s); | ||
}; | ||
var l = (r, e, s) => (w(r, e, "access private method"), s); | ||
var l = (r, e, s) => (b(r, e, "access private method"), s); | ||
import "node:fs/promises"; | ||
@@ -16,4 +16,6 @@ import "node:path"; | ||
import "../utils/locks.js"; | ||
import { isYarnClassic as b } from "../utils/yarn.js"; | ||
var i, p, n, f; | ||
import { isYarnClassic as x } from "../utils/yarn.js"; | ||
import "../utils/shellac.js"; | ||
import "shellac"; | ||
var i, f, n, o; | ||
const h = class { | ||
@@ -25,9 +27,9 @@ constructor(e, s, t) { | ||
var g; | ||
l(g = h, i, p).call(g, e, s, c, m).then( | ||
({ cmd: o, pmCmd: C }) => { | ||
var x; | ||
this.cmd = o, this.pmCmd = C, ["yarn", "pnpm"].includes(e.name) && C === "exec" && (this.pkgCmd = l(x = h, n, f).call(x, this.pkgCmd)), e.name === "npm" && this.pmCmd === "exec" && (this.argsNeedDoubleDashes = !0), a(); | ||
l(g = h, i, f).call(g, e, s, c, m).then( | ||
({ cmd: w, pmCmd: C }) => { | ||
var p; | ||
this.cmd = w, this.pmCmd = C, ["yarn", "pnpm"].includes(e.name) && C === "exec" && (this.pkgCmd = l(p = h, n, o).call(p, this.pkgCmd)), e.name === "npm" && this.pmCmd === "exec" && (this.argsNeedDoubleDashes = !0), a(); | ||
} | ||
); | ||
}), this.argsNeedDoubleDashes = b(e); | ||
}), this.argsNeedDoubleDashes = x(e); | ||
} | ||
@@ -47,3 +49,3 @@ get cmdArgs() { | ||
let d = h; | ||
i = new WeakSet(), p = async function(e, s, t, c) { | ||
i = new WeakSet(), f = async function(e, s, t, c) { | ||
switch (e.name) { | ||
@@ -55,3 +57,3 @@ case "bun": | ||
case "yarn": | ||
if (e.version.startsWith("1.")) | ||
if (x(e)) | ||
return { cmd: "yarn", pmCmd: "exec" }; | ||
@@ -75,3 +77,3 @@ break; | ||
return m; | ||
}, n = new WeakSet(), f = function(e) { | ||
}, n = new WeakSet(), o = function(e) { | ||
const s = e.match(/^@[^/]+\/(.*)/); | ||
@@ -87,3 +89,3 @@ return (s == null ? void 0 : s[1]) ?? e; | ||
u(d, n); | ||
function k(r) { | ||
function R(r) { | ||
const e = async (t, c) => { | ||
@@ -101,4 +103,4 @@ if (!t) | ||
export { | ||
k as getRunExecFunctions | ||
R as getRunExecFunctions | ||
}; | ||
//# sourceMappingURL=getRunExec.js.map |
@@ -19,4 +19,4 @@ import type { PackageManager } from '../packageManager'; | ||
}; | ||
export type GetRunScript = (script: string, options?: Partial<GetRunScriptOptions>) => string | null; | ||
export type GetRunScriptStruct = (script: string, options?: Partial<GetRunScriptOptions>) => CommandScriptStruct | null; | ||
export type GetRunScript = (script: string, options?: Partial<GetRunScriptOptions>) => Promise<string | null>; | ||
export type GetRunScriptStruct = (script: string, options?: Partial<GetRunScriptOptions>) => Promise<CommandScriptStruct | null>; | ||
export declare function getRunScriptFunctions(packageManager: Pick<PackageManager, 'name' | 'cliCommandKeywords'>): { | ||
@@ -23,0 +23,0 @@ getRunScript: GetRunScript; |
@@ -1,18 +0,18 @@ | ||
var g = (s, t, e) => { | ||
if (!t.has(s)) | ||
throw TypeError("Cannot " + e); | ||
var g = (e, t, s) => { | ||
if (!t.has(e)) | ||
throw TypeError("Cannot " + s); | ||
}; | ||
var l = (s, t, e) => { | ||
if (t.has(s)) | ||
var l = (e, t, s) => { | ||
if (t.has(e)) | ||
throw TypeError("Cannot add the same private member more than once"); | ||
t instanceof WeakSet ? t.add(s) : t.set(s, e); | ||
t instanceof WeakSet ? t.add(e) : t.set(e, s); | ||
}; | ||
var m = (s, t, e) => (g(s, t, "access private method"), e); | ||
var m = (e, t, s) => (g(e, t, "access private method"), s); | ||
var u, c; | ||
const h = class { | ||
constructor(t, e, r) { | ||
constructor(t, s, r) { | ||
var d; | ||
this.script = e, this.pmCmd = void 0, this.targetArgs = (r == null ? void 0 : r.args) ?? []; | ||
this.script = s, this.pmCmd = void 0, this.targetArgs = (r == null ? void 0 : r.args) ?? []; | ||
const i = (r == null ? void 0 : r.format) ?? "short"; | ||
this.cmd = t.name, m(d = h, u, c).call(d, t, e, i) && (this.pmCmd = "run"), this.argsNeedDoubleDashes = ["npm", "bun"].includes(t.name); | ||
this.cmd = t.name, m(d = h, u, c).call(d, t, s, i) && (this.pmCmd = "run"), this.argsNeedDoubleDashes = ["npm", "bun"].includes(t.name); | ||
} | ||
@@ -32,10 +32,10 @@ get cmdArgs() { | ||
let n = h; | ||
u = new WeakSet(), c = function(t, e, r) { | ||
return r === "full" ? !0 : e === "start" ? !1 : !!(t.name === "npm" || t.cliCommandKeywords.has(e)); | ||
u = new WeakSet(), c = function(t, s, r) { | ||
return r === "full" ? !0 : s === "start" ? !1 : !!(t.name === "npm" || t.cliCommandKeywords.has(s)); | ||
}, l(n, u); | ||
function C(s) { | ||
const t = (r, i) => r ? new n(s, r, i) : null; | ||
return { getRunScript: (...r) => { | ||
function C(e) { | ||
const t = async (r, i) => r ? new n(e, r, i) : null; | ||
return { getRunScript: async (...r) => { | ||
var i; | ||
return ((i = t(...r)) == null ? void 0 : i.toString()) ?? null; | ||
return ((i = await t(...r)) == null ? void 0 : i.toString()) ?? null; | ||
}, getRunScriptStruct: t }; | ||
@@ -42,0 +42,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import { getRunScriptFunctions as e } from "./getRunScript.js"; | ||
import { getRunExecFunctions as u } from "./getRunExec.js"; | ||
import { getRunScriptFunctions as u } from "./getRunScript.js"; | ||
import { getRunExecFunctions as f } from "./getRunExec.js"; | ||
import "node:fs/promises"; | ||
@@ -8,6 +8,8 @@ import "node:path"; | ||
import "../utils/yarn.js"; | ||
import "../utils/shellac.js"; | ||
import "shellac"; | ||
export { | ||
u as getRunExecFunctions, | ||
e as getRunScriptFunctions | ||
f as getRunExecFunctions, | ||
u as getRunScriptFunctions | ||
}; | ||
//# sourceMappingURL=index.js.map |
export { getPackageManager } from './packageManager'; | ||
export type { PackageManager, PackageManagerName } from './packageManager'; | ||
export type { PackageInfo } from './package'; | ||
export type { GetRunScriptOptions } from './commands/getRunScript'; | ||
export type { GetRunExecOptions } from './commands/getRunExec'; | ||
export type { CommandScriptStruct, CommandExecStruct } from './commands/CommandStruct'; | ||
//# sourceMappingURL=index.d.ts.map |
10
index.js
@@ -1,3 +0,2 @@ | ||
import { getPackageManager as d } from "./packageManager.js"; | ||
import "shellac"; | ||
import { getPackageManager as j } from "./packageManager.js"; | ||
import "./commands/getRunScript.js"; | ||
@@ -10,2 +9,4 @@ import "./commands/getRunExec.js"; | ||
import "./utils/yarn.js"; | ||
import "./utils/shellac.js"; | ||
import "shellac"; | ||
import "./package/index.js"; | ||
@@ -16,7 +17,8 @@ import "./package/bun.js"; | ||
import "./package/yarn.js"; | ||
import "./utils/cliCommands.js"; | ||
import "./utils/pmDetection.js"; | ||
import "./utils/workspace.js"; | ||
import "./utils/cliCommands.js"; | ||
export { | ||
d as getPackageManager | ||
j as getPackageManager | ||
}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "package-manager-manager", | ||
"version": "0.1.2", | ||
"version": "0.1.3-69fef32", | ||
"description": "Utilities for managing package managers.", | ||
@@ -54,2 +54,5 @@ "license": "MIT", | ||
}, | ||
"versionMetadata": { | ||
"type": "BETA" | ||
}, | ||
"scripts": { | ||
@@ -67,4 +70,5 @@ "build": "vite build", | ||
"alter-version": "node ./scripts/alter-version.js", | ||
"changeset": "changeset", | ||
"release": "changeset publish" | ||
} | ||
} |
@@ -1,7 +0,12 @@ | ||
import c from "shellac"; | ||
function u() { | ||
import "node:fs/promises"; | ||
import "node:path"; | ||
import "node:process"; | ||
import "../utils/locks.js"; | ||
import { shellac as i } from "../utils/shellac.js"; | ||
import "shellac"; | ||
function g() { | ||
return async (...[t]) => { | ||
try { | ||
const e = (await c`$ bun pm ls`).stdout, o = new RegExp(`^[└─\\s]*${t}@(.*)$`, "im"), r = e.match(o), n = r == null ? void 0 : r[1]; | ||
return n ? { name: t, version: n } : null; | ||
const n = (await i`$ bun pm ls`).stdout, e = new RegExp(`^[└─\\s]*${t}@(.*)$`, "im"), r = n.match(e), o = r == null ? void 0 : r[1]; | ||
return o ? { name: t, version: o } : null; | ||
} catch { | ||
@@ -13,4 +18,4 @@ throw new Error(`An error occurred while gathering the package info of "${t}"`); | ||
export { | ||
u as getBunGetPackageInfoFunction | ||
g as getBunGetPackageInfoFunction | ||
}; | ||
//# sourceMappingURL=bun.js.map |
import type { PackageManager } from '../packageManager'; | ||
type PackageInfo = { | ||
export type PackageInfo = { | ||
/** The name of the package */ | ||
@@ -16,3 +16,2 @@ name: string; | ||
export declare function getPackageInfoFunction(packageManager: Pick<PackageManager, 'name' | 'version'>): GetPackageInfo; | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
import { getBunGetPackageInfoFunction as n } from "./bun.js"; | ||
import { getNpmGetPackageInfoFunction as e } from "./npm.js"; | ||
import { getPnpmGetPackageInfoFunction as o } from "./pnpm.js"; | ||
import { getYarnGetPackageInfoFunction as r } from "./yarn.js"; | ||
import "shellac"; | ||
import { getNpmGetPackageInfoFunction as o } from "./npm.js"; | ||
import { getPnpmGetPackageInfoFunction as r } from "./pnpm.js"; | ||
import { getYarnGetPackageInfoFunction as e } from "./yarn.js"; | ||
import "node:fs/promises"; | ||
@@ -10,11 +9,13 @@ import "node:path"; | ||
import "../utils/locks.js"; | ||
import "../utils/shellac.js"; | ||
import "shellac"; | ||
import "../utils/yarn.js"; | ||
function F(t) { | ||
function I(t) { | ||
switch (t.name) { | ||
case "npm": | ||
return e(); | ||
return o(); | ||
case "pnpm": | ||
return o(); | ||
return r(); | ||
case "yarn": | ||
return r(t); | ||
return e(t); | ||
case "bun": | ||
@@ -27,4 +28,4 @@ return n(); | ||
export { | ||
F as getPackageInfoFunction | ||
I as getPackageInfoFunction | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,8 +0,13 @@ | ||
import s from "shellac"; | ||
function p() { | ||
import "node:fs/promises"; | ||
import "node:path"; | ||
import "node:process"; | ||
import "../utils/locks.js"; | ||
import { shellac as p } from "../utils/shellac.js"; | ||
import "shellac"; | ||
function l() { | ||
return async (...[t]) => { | ||
var n, e; | ||
var o, r; | ||
try { | ||
const c = (await s`$ npm list --depth=0 --json`).stdout, o = JSON.parse(c), r = ((n = o.dependencies) == null ? void 0 : n[t]) ?? ((e = o.devDependencies) == null ? void 0 : e[t]); | ||
return r ? { name: t, version: r.version } : null; | ||
const i = (await p`$ npm list --depth=0 --json`).stdout, n = JSON.parse(i), e = ((o = n.dependencies) == null ? void 0 : o[t]) ?? ((r = n.devDependencies) == null ? void 0 : r[t]); | ||
return e ? { name: t, version: e.version } : null; | ||
} catch { | ||
@@ -14,4 +19,4 @@ throw new Error(`An error occurred while gathering the package info of "${t}"`); | ||
export { | ||
p as getNpmGetPackageInfoFunction | ||
l as getNpmGetPackageInfoFunction | ||
}; | ||
//# sourceMappingURL=npm.js.map |
@@ -1,7 +0,12 @@ | ||
import c from "shellac"; | ||
function s() { | ||
import "node:fs/promises"; | ||
import "node:path"; | ||
import "node:process"; | ||
import "../utils/locks.js"; | ||
import { shellac as i } from "../utils/shellac.js"; | ||
import "shellac"; | ||
function g() { | ||
return async (...[t]) => { | ||
try { | ||
const e = (await c`$ pnpm list --depth=0`).stdout, o = new RegExp(`^${t}\\s+(.*)$`, "im"), r = e.match(o), n = r == null ? void 0 : r[1]; | ||
return n ? { name: t, version: n } : null; | ||
const n = (await i`$ pnpm list --depth=0`).stdout, e = new RegExp(`^${t}\\s+(.*)$`, "im"), r = n.match(e), o = r == null ? void 0 : r[1]; | ||
return o ? { name: t, version: o } : null; | ||
} catch { | ||
@@ -13,4 +18,4 @@ throw new Error(`An error occurred while gathering the package info of "${t}"`); | ||
export { | ||
s as getPnpmGetPackageInfoFunction | ||
g as getPnpmGetPackageInfoFunction | ||
}; | ||
//# sourceMappingURL=pnpm.js.map |
@@ -1,2 +0,1 @@ | ||
import i from "shellac"; | ||
import "node:fs/promises"; | ||
@@ -7,3 +6,5 @@ import "node:path"; | ||
import { isYarnClassic as c } from "../utils/yarn.js"; | ||
function f(s) { | ||
import { shellac as i } from "../utils/shellac.js"; | ||
import "shellac"; | ||
function w(s) { | ||
return async (...[r]) => { | ||
@@ -26,4 +27,4 @@ try { | ||
export { | ||
f as getYarnGetPackageInfoFunction | ||
w as getYarnGetPackageInfoFunction | ||
}; | ||
//# sourceMappingURL=yarn.js.map |
@@ -8,4 +8,9 @@ import type { GetRunExec, GetRunExecStruct, GetRunScript, GetRunScriptStruct } from './commands'; | ||
export type PackageManager = { | ||
/** The name of the package manager (one of `'npm'`, `'yarn'`, `'pnpm'` or `'bun'`) */ | ||
/** The name of the current package manager (one of `'npm'`, `'yarn'`, `'pnpm'` or `'bun'`) */ | ||
name: PackageManagerName; | ||
/** The name of the package manager the project in the current directory is set up for (if any), which might | ||
* be different from the package manager's name in the case the package manager being used is different from | ||
* the one the project is supposed to be used with (e.g. if the current process is running via `npm` inside a | ||
* project set up using `pnpm`) */ | ||
projectPackageManager: PackageManagerName | null; | ||
/** The version of the package manager */ | ||
@@ -12,0 +17,0 @@ version: string; |
@@ -1,12 +0,13 @@ | ||
import p from "shellac"; | ||
import { getRunScriptFunctions as l } from "./commands/getRunScript.js"; | ||
import { getRunExecFunctions as f } from "./commands/getRunExec.js"; | ||
import { getPackageInfoFunction as R } from "./package/index.js"; | ||
import { getProjectRootDir as S } from "./utils/workspace.js"; | ||
import { lockFiles as c } from "./utils/locks.js"; | ||
import { getPmCliCommandKeywords as k } from "./utils/cliCommands.js"; | ||
import { getRunScriptFunctions as u } from "./commands/getRunScript.js"; | ||
import { getRunExecFunctions as m } from "./commands/getRunExec.js"; | ||
import { getPackageInfoFunction as p } from "./package/index.js"; | ||
import "node:fs/promises"; | ||
import "node:path"; | ||
import "node:process"; | ||
import "./utils/locks.js"; | ||
import { getPmCliCommandKeywords as s } from "./utils/cliCommands.js"; | ||
import { detectPackageManagerName as l } from "./utils/pmDetection.js"; | ||
import { shellac as R } from "./utils/shellac.js"; | ||
import "./utils/yarn.js"; | ||
import "shellac"; | ||
import "./package/bun.js"; | ||
@@ -16,29 +17,25 @@ import "./package/npm.js"; | ||
import "./package/yarn.js"; | ||
async function y(n) { | ||
const { stdout: o } = await p`$ ${n} --version`; | ||
return o; | ||
import "./utils/workspace.js"; | ||
async function S(e) { | ||
const { stdout: n } = await R`$ ${e} --version`; | ||
return n; | ||
} | ||
async function h() { | ||
const n = await S(); | ||
if (!n) | ||
return null; | ||
const o = n.files; | ||
for (const i of Object.keys(c)) { | ||
const e = i; | ||
if (o.includes(c[e])) { | ||
const a = e, r = await y(e), t = { | ||
name: e, | ||
version: r, | ||
// initialization of dummy fields which get populated in the next steps | ||
cliCommandKeywords: /* @__PURE__ */ new Set(), | ||
getPackageInfo: async () => null, | ||
getRunScript: () => null, | ||
getRunScriptStruct: () => null, | ||
getRunExec: async () => null, | ||
getRunExecStruct: async () => null | ||
}; | ||
t.cliCommandKeywords = k(t), t.getPackageInfo = R({ name: a, version: r }); | ||
const { getRunScript: u, getRunScriptStruct: g } = l(t), { getRunExec: m, getRunExecStruct: s } = f(t); | ||
return t.getRunScript = u, t.getRunScriptStruct = g, t.getRunExec = m, t.getRunExecStruct = s, t; | ||
} | ||
async function j() { | ||
const { packageManagerName: e, filesBasedPackageManager: n } = await l(); | ||
if (e) { | ||
const a = e, r = await S(e), t = { | ||
name: e, | ||
version: r, | ||
projectPackageManager: n, | ||
// initialization of dummy fields which get populated in the next steps | ||
cliCommandKeywords: /* @__PURE__ */ new Set(), | ||
getPackageInfo: async () => null, | ||
getRunScript: async () => null, | ||
getRunScriptStruct: async () => null, | ||
getRunExec: async () => null, | ||
getRunExecStruct: async () => null | ||
}; | ||
t.cliCommandKeywords = s(t), t.getPackageInfo = p({ name: a, version: r }); | ||
const { getRunScript: c, getRunScriptStruct: o } = u(t), { getRunExec: i, getRunExecStruct: g } = m(t); | ||
return t.getRunScript = c, t.getRunScriptStruct = o, t.getRunExec = i, t.getRunExecStruct = g, t; | ||
} | ||
@@ -48,4 +45,4 @@ return null; | ||
export { | ||
h as getPackageManager | ||
j as getPackageManager | ||
}; | ||
//# sourceMappingURL=packageManager.js.map |
@@ -6,2 +6,4 @@ export * from './os'; | ||
export * from './cliCommands'; | ||
export * from './pmDetection'; | ||
export * from './shellac'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,17 +0,24 @@ | ||
import { isWindows as m } from "./os.js"; | ||
import { getProjectRootDir as s } from "./workspace.js"; | ||
import { isLockFile as l, lockFiles as x } from "./locks.js"; | ||
import { isYarnClassic as a } from "./yarn.js"; | ||
import { getPmCliCommandKeywords as n } from "./cliCommands.js"; | ||
import { isWindows as i } from "./os.js"; | ||
import { getProjectRootDir as c } from "./workspace.js"; | ||
import { isLockFile as g, lockFiles as n } from "./locks.js"; | ||
import { isYarnClassic as l } from "./yarn.js"; | ||
import { getPmCliCommandKeywords as x } from "./cliCommands.js"; | ||
import { detectPackageManagerBasedOnFiles as P, detectPackageManagerBasedOnUserAgent as C, detectPackageManagerName as F } from "./pmDetection.js"; | ||
import { shellac as w } from "./shellac.js"; | ||
import "node:fs/promises"; | ||
import "node:path"; | ||
import "node:process"; | ||
import "shellac"; | ||
export { | ||
n as getPmCliCommandKeywords, | ||
s as getProjectRootDir, | ||
l as isLockFile, | ||
m as isWindows, | ||
a as isYarnClassic, | ||
x as lockFiles | ||
P as detectPackageManagerBasedOnFiles, | ||
C as detectPackageManagerBasedOnUserAgent, | ||
F as detectPackageManagerName, | ||
x as getPmCliCommandKeywords, | ||
c as getProjectRootDir, | ||
g as isLockFile, | ||
i as isWindows, | ||
l as isYarnClassic, | ||
n as lockFiles, | ||
w as shellac | ||
}; | ||
//# sourceMappingURL=index.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 4 instances 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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 4 instances in 1 package
139932
117
1035
13
4