Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@antfu/install-pkg

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antfu/install-pkg - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

dist/index.cjs

8

dist/index.d.ts

@@ -1,6 +0,6 @@

import execa from 'execa';
import * as execa from 'execa';
declare type PackageManager = 'pnpm' | 'yarn' | 'npm' | 'bun';
type PackageManager = 'pnpm' | 'yarn' | 'npm' | 'bun';
declare const AGENTS: readonly ["pnpm", "yarn", "npm", "pnpm@6", "yarn@berry", "bun"];
declare type Agent = typeof AGENTS[number];
type Agent = typeof AGENTS[number];
declare function detectPackageManager(cwd?: string): Promise<Agent | null>;

@@ -19,2 +19,2 @@

export { Agent, InstallPackageOptions, PackageManager, detectPackageManager, installPackage };
export { type Agent, type InstallPackageOptions, type PackageManager, detectPackageManager, installPackage };

@@ -1,38 +0,6 @@

"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
detectPackageManager: () => detectPackageManager,
installPackage: () => installPackage
});
module.exports = __toCommonJS(src_exports);
// src/detect.ts
var import_fs = __toESM(require("fs"));
var import_path = __toESM(require("path"));
var import_find_up = __toESM(require("find-up"));
import fs from "fs";
import path from "path";
import process from "process";
import { findUp } from "find-up";
var AGENTS = ["pnpm", "yarn", "npm", "pnpm@6", "yarn@berry", "bun"];

@@ -48,18 +16,18 @@ var LOCKS = {

let agent = null;
const lockPath = await (0, import_find_up.default)(Object.keys(LOCKS), { cwd });
const lockPath = await findUp(Object.keys(LOCKS), { cwd });
let packageJsonPath;
if (lockPath)
packageJsonPath = import_path.default.resolve(lockPath, "../package.json");
packageJsonPath = path.resolve(lockPath, "../package.json");
else
packageJsonPath = await (0, import_find_up.default)("package.json", { cwd });
if (packageJsonPath && import_fs.default.existsSync(packageJsonPath)) {
packageJsonPath = await findUp("package.json", { cwd });
if (packageJsonPath && fs.existsSync(packageJsonPath)) {
try {
const pkg = JSON.parse(import_fs.default.readFileSync(packageJsonPath, "utf8"));
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
if (typeof pkg.packageManager === "string") {
const [name, version] = pkg.packageManager.split("@");
if (name === "yarn" && parseInt(version) > 1)
if (name === "yarn" && Number.parseInt(version) > 1)
agent = "yarn@berry";
else if (name === "pnpm" && parseInt(version) < 7)
else if (name === "pnpm" && Number.parseInt(version) < 7)
agent = "pnpm@6";
else if (name in AGENTS)
else if (AGENTS.includes(name))
agent = name;

@@ -73,3 +41,3 @@ else

if (!agent && lockPath)
agent = LOCKS[import_path.default.basename(lockPath)];
agent = LOCKS[path.basename(lockPath)];
return agent;

@@ -79,3 +47,3 @@ }

// src/install.ts
var import_execa = __toESM(require("execa"));
import { execa } from "execa";
async function installPackage(names, options = {}) {

@@ -93,3 +61,3 @@ const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";

}
return (0, import_execa.default)(
return execa(
agent,

@@ -108,6 +76,5 @@ [

}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
export {
detectPackageManager,
installPackage
});
};
{
"name": "@antfu/install-pkg",
"version": "0.1.1",
"packageManager": "pnpm@7.12.0",
"type": "module",
"version": "0.2.0",
"packageManager": "pnpm@8.10.5",
"description": "Install package programmatically.",

@@ -22,8 +23,8 @@ "author": "Anthony Fu <anthonyfu117@hotmail.com>",

"types": "./dist/index.d.ts",
"require": "./dist/index.js",
"import": "./dist/index.mjs"
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"module": "dist/index.js",
"types": "dist/index.d.ts",

@@ -34,14 +35,14 @@ "files": [

"dependencies": {
"execa": "^5.1.1",
"find-up": "^5.0.0"
"execa": "^8.0.1",
"find-up": "^7.0.0"
},
"devDependencies": {
"@antfu/eslint-config": "^0.27.0",
"@antfu/ni": "^0.18.0",
"@types/node": "^16.11.59",
"bumpp": "^8.2.1",
"eslint": "^8.23.1",
"esno": "^0.16.3",
"tsup": "^6.2.3",
"typescript": "^4.8.3"
"@antfu/eslint-config": "^2.0.0",
"@antfu/ni": "^0.21.10",
"@types/node": "^20.9.3",
"bumpp": "^9.2.0",
"eslint": "^8.54.0",
"esno": "^4.0.0",
"tsup": "^8.0.1",
"typescript": "^5.3.2"
},

@@ -48,0 +49,0 @@ "scripts": {

@@ -5,3 +5,3 @@ # install-pkg

Install package programmatically. Detect package managers automatically (`npm`, `yarn` and `pnpm`).
Install package programmatically. Detect package managers automatically (`npm`, `yarn`, `bun` and `pnpm`).

@@ -8,0 +8,0 @@ ```bash

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc