package-manager-manager
Advanced tools
Comparing version 0.1.1 to 0.1.2-35550fa
@@ -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 @@ } |
@@ -13,7 +13,7 @@ import { getPackageManager as h } from "./packageManager.js"; | ||
import "./package/npm.js"; | ||
import "./package/shared.js"; | ||
import "./package/pnpm.js"; | ||
import "./package/yarn.js"; | ||
import "./utils/cliCommands.js"; | ||
import "./utils/pmDetection.js"; | ||
import "./utils/workspace.js"; | ||
import "./utils/cliCommands.js"; | ||
export { | ||
@@ -20,0 +20,0 @@ h as getPackageManager |
{ | ||
"name": "package-manager-manager", | ||
"version": "0.1.1", | ||
"version": "0.1.2-35550fa", | ||
"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 { getBunGetPackageInfoFunction as n } from "./bun.js"; | ||
import { getNpmGetPackageInfoFunction as o } from "./npm.js"; | ||
import { getPnpmGetPackageInfoFunction as r } from "./pnpm.js"; | ||
import { getYarnGetPackageInfoFunction as e } from "./yarn.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 "./shared.js"; | ||
import "node:fs/promises"; | ||
@@ -12,10 +11,10 @@ import "node:path"; | ||
import "../utils/yarn.js"; | ||
function I(t) { | ||
function F(t) { | ||
switch (t.name) { | ||
case "npm": | ||
return e(); | ||
case "pnpm": | ||
return o(); | ||
case "pnpm": | ||
return r(); | ||
case "yarn": | ||
return e(t); | ||
return r(t); | ||
case "bun": | ||
@@ -28,4 +27,4 @@ return n(); | ||
export { | ||
I as getPackageInfoFunction | ||
F as getPackageInfoFunction | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,5 +0,3 @@ | ||
export declare function getNpmGetPackageInfoFunction(): (packageName: string) => Promise<{ | ||
name: string; | ||
version: string; | ||
} | null>; | ||
import type { GetPackageInfo } from './index'; | ||
export declare function getNpmGetPackageInfoFunction(): (packageName: string) => ReturnType<GetPackageInfo>; | ||
//# sourceMappingURL=npm.d.ts.map |
@@ -1,9 +0,16 @@ | ||
import { getNpmOrPnpmGetPackageInfoFunction as n } from "./shared.js"; | ||
import "shellac"; | ||
function e() { | ||
return n("npm"); | ||
import s from "shellac"; | ||
function p() { | ||
return async (...[t]) => { | ||
var n, e; | ||
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; | ||
} catch { | ||
throw new Error(`An error occurred while gathering the package info of "${t}"`); | ||
} | ||
}; | ||
} | ||
export { | ||
e as getNpmGetPackageInfoFunction | ||
p as getNpmGetPackageInfoFunction | ||
}; | ||
//# sourceMappingURL=npm.js.map |
@@ -1,5 +0,3 @@ | ||
export declare function getPnpmGetPackageInfoFunction(): (packageName: string) => Promise<{ | ||
name: string; | ||
version: string; | ||
} | null>; | ||
import type { GetPackageInfo } from './index'; | ||
export declare function getPnpmGetPackageInfoFunction(): (packageName: string) => ReturnType<GetPackageInfo>; | ||
//# sourceMappingURL=pnpm.d.ts.map |
@@ -1,9 +0,15 @@ | ||
import { getNpmOrPnpmGetPackageInfoFunction as n } from "./shared.js"; | ||
import "shellac"; | ||
function e() { | ||
return n("pnpm"); | ||
import c from "shellac"; | ||
function s() { | ||
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; | ||
} catch { | ||
throw new Error(`An error occurred while gathering the package info of "${t}"`); | ||
} | ||
}; | ||
} | ||
export { | ||
e as getPnpmGetPackageInfoFunction | ||
s as getPnpmGetPackageInfoFunction | ||
}; | ||
//# sourceMappingURL=pnpm.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,44 +0,39 @@ | ||
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"; | ||
import "./package/bun.js"; | ||
import "./package/npm.js"; | ||
import "./package/shared.js"; | ||
import "./package/pnpm.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 u`$ ${e} --version`; | ||
return n; | ||
} | ||
async function N() { | ||
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: m } = l(t), { getRunExec: g, getRunExecStruct: s } = f(t); | ||
return t.getRunScript = u, t.getRunScriptStruct = m, t.getRunExec = g, t.getRunExecStruct = s, t; | ||
} | ||
async function h() { | ||
const { packageManagerName: e, filesBasedPackageManager: n } = await R(); | ||
if (e) { | ||
const r = e, a = await S(e), t = { | ||
name: e, | ||
version: a, | ||
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 = l(t), t.getPackageInfo = s({ name: r, version: a }); | ||
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; | ||
} | ||
@@ -48,4 +43,4 @@ return null; | ||
export { | ||
N as getPackageManager | ||
h 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 |
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
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 4 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 2 instances in 1 package
134217
963
13
2