package-manager-manager
Advanced tools
Comparing version 0.1.2 to 0.1.3-ff58791
@@ -1,2 +0,2 @@ | ||
var w = (r, e, s) => { | ||
var o = (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) => (o(r, e, "access private method"), s); | ||
import "node:fs/promises"; | ||
@@ -16,4 +16,4 @@ import "node:path"; | ||
import "../utils/locks.js"; | ||
import { isYarnClassic as b } from "../utils/yarn.js"; | ||
var i, p, n, f; | ||
import { isYarnClassic as p } from "../utils/yarn.js"; | ||
var i, f, n, w; | ||
const h = class { | ||
@@ -25,9 +25,9 @@ constructor(e, s, t) { | ||
var g; | ||
l(g = h, i, p).call(g, e, s, c, m).then( | ||
({ cmd: o, pmCmd: C }) => { | ||
l(g = h, i, f).call(g, e, s, c, m).then( | ||
({ cmd: b, 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(); | ||
this.cmd = b, this.pmCmd = C, ["yarn", "pnpm"].includes(e.name) && C === "exec" && (this.pkgCmd = l(x = h, n, w).call(x, this.pkgCmd)), e.name === "npm" && this.pmCmd === "exec" && (this.argsNeedDoubleDashes = !0), a(); | ||
} | ||
); | ||
}), this.argsNeedDoubleDashes = b(e); | ||
}), this.argsNeedDoubleDashes = p(e); | ||
} | ||
@@ -47,3 +47,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 +55,3 @@ case "bun": | ||
case "yarn": | ||
if (e.version.startsWith("1.")) | ||
if (p(e)) | ||
return { cmd: "yarn", pmCmd: "exec" }; | ||
@@ -75,3 +75,3 @@ break; | ||
return m; | ||
}, n = new WeakSet(), f = function(e) { | ||
}, n = new WeakSet(), w = function(e) { | ||
const s = e.match(/^@[^/]+\/(.*)/); | ||
@@ -78,0 +78,0 @@ return (s == null ? void 0 : s[1]) ?? e; |
@@ -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 @@ } |
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 |
@@ -1,2 +0,2 @@ | ||
import { getPackageManager as d } from "./packageManager.js"; | ||
import { getPackageManager as h } from "./packageManager.js"; | ||
import "shellac"; | ||
@@ -15,7 +15,8 @@ import "./commands/getRunScript.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 | ||
h as getPackageManager | ||
}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "package-manager-manager", | ||
"version": "0.1.2", | ||
"version": "0.1.3-ff58791", | ||
"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" | ||
} | ||
} |
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 |
@@ -8,6 +8,11 @@ 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 */ | ||
version: string; | ||
version: string | null; | ||
/** | ||
@@ -14,0 +19,0 @@ * Utility to get the information of an installed package |
@@ -1,11 +0,11 @@ | ||
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 u from "shellac"; | ||
import { getRunScriptFunctions as m } from "./commands/getRunScript.js"; | ||
import { getRunExecFunctions as p } from "./commands/getRunExec.js"; | ||
import { getPackageInfoFunction as s } from "./package/index.js"; | ||
import "node:fs/promises"; | ||
import "node:path"; | ||
import "node:process"; | ||
import "./utils/locks.js"; | ||
import { getPmCliCommandKeywords as l } from "./utils/cliCommands.js"; | ||
import { detectPackageManagerName as R } from "./utils/pmDetection.js"; | ||
import "./utils/yarn.js"; | ||
@@ -16,35 +16,35 @@ import "./package/bun.js"; | ||
import "./package/yarn.js"; | ||
async function y(n) { | ||
const { stdout: o } = await p`$ ${n} --version`; | ||
return o; | ||
} | ||
async function h() { | ||
const n = await S(); | ||
if (!n) | ||
import "./utils/workspace.js"; | ||
async function S(n) { | ||
try { | ||
const { stdout: e } = await u`$ ${n} --version`; | ||
return e; | ||
} catch { | ||
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 $() { | ||
const { packageManagerName: n, filesBasedPackageManager: e } = await R(); | ||
if (n) { | ||
const a = n, r = await S(n), t = { | ||
name: n, | ||
version: r, | ||
projectPackageManager: e, | ||
// 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 = l(t), t.getPackageInfo = s({ name: a, version: r }); | ||
const { getRunScript: c, getRunScriptStruct: o } = m(t), { getRunExec: i, getRunExecStruct: g } = p(t); | ||
return t.getRunScript = c, t.getRunScriptStruct = o, t.getRunExec = i, t.getRunExecStruct = g, t; | ||
} | ||
return null; | ||
} | ||
export { | ||
h as getPackageManager | ||
$ as getPackageManager | ||
}; | ||
//# sourceMappingURL=packageManager.js.map |
@@ -6,2 +6,3 @@ export * from './os'; | ||
export * from './cliCommands'; | ||
export * from './pmDetection'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,6 +0,7 @@ | ||
import { isWindows as m } from "./os.js"; | ||
import { isWindows as i } 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 { isLockFile as g, lockFiles as n } from "./locks.js"; | ||
import { isYarnClassic as d } from "./yarn.js"; | ||
import { getPmCliCommandKeywords as l } from "./cliCommands.js"; | ||
import { detectPackageManagerBasedOnFiles as k, detectPackageManagerBasedOnUserAgent as P, detectPackageManagerName as C } from "./pmDetection.js"; | ||
import "node:fs/promises"; | ||
@@ -10,9 +11,12 @@ import "node:path"; | ||
export { | ||
n as getPmCliCommandKeywords, | ||
k as detectPackageManagerBasedOnFiles, | ||
P as detectPackageManagerBasedOnUserAgent, | ||
C as detectPackageManagerName, | ||
l as getPmCliCommandKeywords, | ||
s as getProjectRootDir, | ||
l as isLockFile, | ||
m as isWindows, | ||
a as isYarnClassic, | ||
x as lockFiles | ||
g as isLockFile, | ||
i as isWindows, | ||
d as isYarnClassic, | ||
n as lockFiles | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,7 +0,8 @@ | ||
function r(n) { | ||
return n.name === "yarn" && n.version.startsWith("1."); | ||
function s(n) { | ||
var r; | ||
return !!(n.name === "yarn" && ((r = n.version) != null && r.startsWith("1."))); | ||
} | ||
export { | ||
r as isYarnClassic | ||
s as isYarnClassic | ||
}; | ||
//# sourceMappingURL=yarn.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
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 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 3 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 2 instances in 1 package
135062
111
971
13
2