完成世界书、骰子、apiconfig页面处理
This commit is contained in:
27
frontend/node_modules/@antfu/install-pkg/README.md
generated
vendored
Normal file
27
frontend/node_modules/@antfu/install-pkg/README.md
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
# install-pkg
|
||||
|
||||
[](https://www.npmjs.com/package/@antfu/install-pkg)
|
||||
|
||||
Install package programmatically. Detect package managers automatically (`npm`, `yarn`, `bun` and `pnpm`).
|
||||
|
||||
```bash
|
||||
npm i @antfu/install-pkg
|
||||
```
|
||||
|
||||
```ts
|
||||
import { installPackage } from '@antfu/install-pkg'
|
||||
|
||||
await installPackage('vite', { silent: true })
|
||||
```
|
||||
|
||||
## Sponsors
|
||||
|
||||
<p align="center">
|
||||
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
|
||||
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./LICENSE) License © 2021 [Anthony Fu](https://github.com/antfu)
|
||||
27
frontend/node_modules/@antfu/install-pkg/dist/index.d.cts
generated
vendored
Normal file
27
frontend/node_modules/@antfu/install-pkg/dist/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import { Agent } from 'package-manager-detector';
|
||||
export { Agent } from 'package-manager-detector';
|
||||
import * as tinyexec from 'tinyexec';
|
||||
|
||||
type PackageManager = 'pnpm' | 'yarn' | 'npm' | 'bun';
|
||||
declare function detectPackageManager(cwd?: string): Promise<Agent | null>;
|
||||
|
||||
interface InstallPackageOptions {
|
||||
cwd?: string;
|
||||
dev?: boolean;
|
||||
silent?: boolean;
|
||||
packageManager?: string;
|
||||
preferOffline?: boolean;
|
||||
additionalArgs?: string[] | ((agent: string, detectedAgent: string) => string[] | undefined);
|
||||
}
|
||||
declare function installPackage(names: string | string[], options?: InstallPackageOptions): Promise<tinyexec.Output>;
|
||||
|
||||
interface UninstallPackageOptions {
|
||||
cwd?: string;
|
||||
dev?: boolean;
|
||||
silent?: boolean;
|
||||
packageManager?: string;
|
||||
additionalArgs?: string[];
|
||||
}
|
||||
declare function uninstallPackage(names: string | string[], options?: UninstallPackageOptions): Promise<tinyexec.Output>;
|
||||
|
||||
export { type InstallPackageOptions, type PackageManager, type UninstallPackageOptions, detectPackageManager, installPackage, uninstallPackage };
|
||||
96
frontend/node_modules/@antfu/install-pkg/dist/index.js
generated
vendored
Normal file
96
frontend/node_modules/@antfu/install-pkg/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
// src/detect.ts
|
||||
import process from "node:process";
|
||||
import { detect } from "package-manager-detector/detect";
|
||||
async function detectPackageManager(cwd = process.cwd()) {
|
||||
const result = await detect({
|
||||
cwd,
|
||||
onUnknown(packageManager) {
|
||||
console.warn("[@antfu/install-pkg] Unknown packageManager:", packageManager);
|
||||
return void 0;
|
||||
}
|
||||
});
|
||||
return result?.agent || null;
|
||||
}
|
||||
|
||||
// src/install.ts
|
||||
import { existsSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import process2 from "node:process";
|
||||
import { x } from "tinyexec";
|
||||
async function installPackage(names, options = {}) {
|
||||
const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
|
||||
const [agent] = detectedAgent.split("@");
|
||||
if (!Array.isArray(names))
|
||||
names = [names];
|
||||
const args = (typeof options.additionalArgs === "function" ? options.additionalArgs(agent, detectedAgent) : options.additionalArgs) || [];
|
||||
if (options.preferOffline) {
|
||||
if (detectedAgent === "yarn@berry")
|
||||
args.unshift("--cached");
|
||||
else
|
||||
args.unshift("--prefer-offline");
|
||||
}
|
||||
if (agent === "pnpm") {
|
||||
args.unshift(
|
||||
/**
|
||||
* Prevent pnpm from removing installed devDeps while `NODE_ENV` is `production`
|
||||
* @see https://pnpm.io/cli/install#--prod--p
|
||||
*/
|
||||
"--prod=false"
|
||||
);
|
||||
if (existsSync(resolve(options.cwd ?? process2.cwd(), "pnpm-workspace.yaml"))) {
|
||||
args.unshift("-w");
|
||||
}
|
||||
}
|
||||
return x(
|
||||
agent,
|
||||
[
|
||||
agent === "yarn" ? "add" : "install",
|
||||
options.dev ? "-D" : "",
|
||||
...args,
|
||||
...names
|
||||
].filter(Boolean),
|
||||
{
|
||||
nodeOptions: {
|
||||
stdio: options.silent ? "ignore" : "inherit",
|
||||
cwd: options.cwd
|
||||
},
|
||||
throwOnError: true
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// src/uninstall.ts
|
||||
import { existsSync as existsSync2 } from "node:fs";
|
||||
import process3 from "node:process";
|
||||
import { resolve as resolve2 } from "node:path";
|
||||
import { x as x2 } from "tinyexec";
|
||||
async function uninstallPackage(names, options = {}) {
|
||||
const detectedAgent = options.packageManager || await detectPackageManager(options.cwd) || "npm";
|
||||
const [agent] = detectedAgent.split("@");
|
||||
if (!Array.isArray(names))
|
||||
names = [names];
|
||||
const args = options.additionalArgs || [];
|
||||
if (agent === "pnpm" && existsSync2(resolve2(options.cwd ?? process3.cwd(), "pnpm-workspace.yaml")))
|
||||
args.unshift("-w");
|
||||
return x2(
|
||||
agent,
|
||||
[
|
||||
agent === "yarn" ? "remove" : "uninstall",
|
||||
options.dev ? "-D" : "",
|
||||
...args,
|
||||
...names
|
||||
].filter(Boolean),
|
||||
{
|
||||
nodeOptions: {
|
||||
stdio: options.silent ? "ignore" : "inherit",
|
||||
cwd: options.cwd
|
||||
},
|
||||
throwOnError: true
|
||||
}
|
||||
);
|
||||
}
|
||||
export {
|
||||
detectPackageManager,
|
||||
installPackage,
|
||||
uninstallPackage
|
||||
};
|
||||
Reference in New Issue
Block a user