@pkgr/utils
Advanced tools
Comparing version 2.2.0 to 2.3.0
// based on https://github.com/facebook/create-react-app/blob/master/packages/react-dev-utils/openBrowser.js | ||
import { execSync } from 'child_process'; | ||
import { execSync } from 'node:child_process'; | ||
import path from 'node:path'; | ||
@@ -4,0 +4,0 @@ import { fileURLToPath } from 'node:url'; |
@@ -12,1 +12,11 @@ /// <reference types="node" /> | ||
export declare const EXTENSIONS: string[]; | ||
export declare const SCRIPT_RUNNERS: { | ||
readonly npm: "npx"; | ||
readonly pnpm: "pnpm"; | ||
readonly yarn: "yarn"; | ||
}; | ||
export declare const SCRIPT_EXECUTORS: { | ||
readonly npm: "npx"; | ||
readonly pnpm: "pnpx"; | ||
readonly yarn: "yarn dlx"; | ||
}; |
var _a; | ||
import { createRequire } from 'module'; | ||
import { createRequire } from 'node:module'; | ||
export const DEV = 'development'; | ||
@@ -13,2 +13,12 @@ export const PROD = 'production'; | ||
export const EXTENSIONS = ['.ts', '.tsx', ...Object.keys(cjsRequire.extensions)]; | ||
export const SCRIPT_RUNNERS = { | ||
npm: 'npx', | ||
pnpm: 'pnpm', | ||
yarn: 'yarn', | ||
}; | ||
export const SCRIPT_EXECUTORS = { | ||
npm: 'npx', | ||
pnpm: 'pnpx', | ||
yarn: 'yarn dlx', | ||
}; | ||
//# sourceMappingURL=constants.js.map |
@@ -10,3 +10,3 @@ export declare const tryPkg: (pkg: string) => string | undefined; | ||
export declare const isVueAvailable: boolean; | ||
export declare const tryFile: (filePath?: string | string[] | undefined, includeDir?: boolean) => string; | ||
export declare const tryFile: (filePath?: string[] | string, includeDir?: boolean) => string; | ||
export declare const tryExtensions: (filepath: string, extensions?: string[]) => string; | ||
@@ -20,1 +20,4 @@ export declare const tryGlob: (paths: string[], options?: string | { | ||
export declare const arrayify: <T, R = T extends (infer S)[] ? NonNullable<S> : NonNullable<T>>(...args: (R | R[])[]) => R[]; | ||
export declare const getPackageManager: () => "pnpm" | "yarn" | "npm" | undefined; | ||
export declare const getScriptRunner: () => "npx" | "pnpm" | "yarn" | undefined; | ||
export declare const getScriptExecutor: () => "npx" | "pnpx" | "yarn dlx" | undefined; |
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import isGlob from 'is-glob'; | ||
import { CWD, EXTENSIONS, cjsRequire } from './constants.js'; | ||
import { CWD, EXTENSIONS, cjsRequire, SCRIPT_RUNNERS, SCRIPT_EXECUTORS, } from './constants.js'; | ||
export const tryPkg = (pkg) => { | ||
@@ -79,2 +79,32 @@ try { | ||
}, []); | ||
export const getPackageManager = () => { | ||
const execPath = process.env.npm_execpath; | ||
if (!execPath) { | ||
return; | ||
} | ||
if (/\byarn\b/.test(execPath)) { | ||
return 'yarn'; | ||
} | ||
if (/\bpnpm\b/.test(execPath)) { | ||
return 'pnpm'; | ||
} | ||
if (/\bnpm\b/.test(execPath)) { | ||
return 'npm'; | ||
} | ||
console.warn('unknown package manager:', execPath); | ||
}; | ||
export const getScriptRunner = () => { | ||
const pm = getPackageManager(); | ||
if (!pm) { | ||
return; | ||
} | ||
return SCRIPT_RUNNERS[pm]; | ||
}; | ||
export const getScriptExecutor = () => { | ||
const pm = getPackageManager(); | ||
if (!pm) { | ||
return; | ||
} | ||
return SCRIPT_EXECUTORS[pm]; | ||
}; | ||
//# sourceMappingURL=helpers.js.map |
{ | ||
"name": "@pkgr/utils", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"type": "module", | ||
"description": "Shared utils for `@pkgr` packages or any package else", | ||
"repository": "git+https://github.com/rx-ts/pkgr.git", | ||
"homepage": "https://github.com/rx-ts/pkgr/blob/master/packages/utils", | ||
"author": "JounQin <admin@1stg.me>", | ||
"repository": "git+https://github.com/un-ts/pkgr.git", | ||
"homepage": "https://github.com/un-ts/pkgr/blob/master/packages/utils", | ||
"author": "JounQin (https://www.1stG.me) <admin@1stg.me>", | ||
"donate": { | ||
"recipients": [ | ||
{ | ||
"name": "unts", | ||
"platform": "opencollective", | ||
"address": "https://opencollective.com/unts", | ||
"weight": 60 | ||
}, | ||
{ | ||
"name": "rxts", | ||
"platform": "opencollective", | ||
"address": "https://opencollective.com/rxts", | ||
"weight": 20 | ||
}, | ||
{ | ||
"name": "1stG", | ||
"email": "i@1stg.me", | ||
"weight": 20, | ||
"platforms": [ | ||
{ | ||
"platform": "opencollective", | ||
"address": "https://opencollective.com/1stG" | ||
}, | ||
{ | ||
"platform": "patreon", | ||
"address": "https://www.patreon.com/1stG" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"funding": "https://opencollective.com/unts", | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=12" | ||
"node": "^12.20.0 || ^14.18.0 || >=16.0.0" | ||
}, | ||
@@ -13,0 +45,0 @@ "main": "./lib/index.cjs", |
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
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
35614
590
0
0