Website Structure
This commit is contained in:
parent
62812f2090
commit
71f0676a62
22365 changed files with 4265753 additions and 791 deletions
21
Frontend-Learner/node_modules/local-pkg/LICENSE
generated
vendored
Normal file
21
Frontend-Learner/node_modules/local-pkg/LICENSE
generated
vendored
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2021 Anthony Fu <https://github.com/antfu>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
55
Frontend-Learner/node_modules/local-pkg/README.md
generated
vendored
Normal file
55
Frontend-Learner/node_modules/local-pkg/README.md
generated
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
# local-pkg
|
||||
|
||||
[](https://www.npmjs.com/package/local-pkg)
|
||||
|
||||
Get information on local packages. Works on both CJS and ESM.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm i local-pkg
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```ts
|
||||
import {
|
||||
getPackageInfo,
|
||||
importModule,
|
||||
isPackageExists,
|
||||
resolveModule,
|
||||
} from 'local-pkg'
|
||||
|
||||
isPackageExists('local-pkg') // true
|
||||
isPackageExists('foo') // false
|
||||
|
||||
await getPackageInfo('local-pkg')
|
||||
/* {
|
||||
* name: "local-pkg",
|
||||
* version: "0.1.0",
|
||||
* rootPath: "/path/to/node_modules/local-pkg",
|
||||
* packageJson: {
|
||||
* ...
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
|
||||
// similar to `require.resolve` but works also in ESM
|
||||
resolveModule('local-pkg')
|
||||
// '/path/to/node_modules/local-pkg/dist/index.cjs'
|
||||
|
||||
// similar to `await import()` but works also in CJS
|
||||
const { importModule } = await importModule('local-pkg')
|
||||
```
|
||||
|
||||
## 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)
|
||||
190
Frontend-Learner/node_modules/local-pkg/dist/index.cjs
generated
vendored
Normal file
190
Frontend-Learner/node_modules/local-pkg/dist/index.cjs
generated
vendored
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
'use strict';
|
||||
|
||||
const fs = require('node:fs');
|
||||
const node_module = require('node:module');
|
||||
const path = require('node:path');
|
||||
const process = require('node:process');
|
||||
const fsPromises = require('node:fs/promises');
|
||||
const node_url = require('node:url');
|
||||
const mlly = require('mlly');
|
||||
const macro = require('quansync/macro');
|
||||
|
||||
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
||||
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
||||
|
||||
const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
||||
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
||||
const process__default = /*#__PURE__*/_interopDefaultCompat(process);
|
||||
const fsPromises__default = /*#__PURE__*/_interopDefaultCompat(fsPromises);
|
||||
|
||||
const toPath = urlOrPath => urlOrPath instanceof URL ? node_url.fileURLToPath(urlOrPath) : urlOrPath;
|
||||
|
||||
async function findUp$1(name, {
|
||||
cwd = process__default.cwd(),
|
||||
type = 'file',
|
||||
stopAt,
|
||||
} = {}) {
|
||||
let directory = path__default.resolve(toPath(cwd) ?? '');
|
||||
const {root} = path__default.parse(directory);
|
||||
stopAt = path__default.resolve(directory, toPath(stopAt ?? root));
|
||||
const isAbsoluteName = path__default.isAbsolute(name);
|
||||
|
||||
while (directory) {
|
||||
const filePath = isAbsoluteName ? name : path__default.join(directory, name);
|
||||
try {
|
||||
const stats = await fsPromises__default.stat(filePath); // eslint-disable-line no-await-in-loop
|
||||
if ((type === 'file' && stats.isFile()) || (type === 'directory' && stats.isDirectory())) {
|
||||
return filePath;
|
||||
}
|
||||
} catch {}
|
||||
|
||||
if (directory === stopAt || directory === root) {
|
||||
break;
|
||||
}
|
||||
|
||||
directory = path__default.dirname(directory);
|
||||
}
|
||||
}
|
||||
|
||||
function findUpSync(name, {
|
||||
cwd = process__default.cwd(),
|
||||
type = 'file',
|
||||
stopAt,
|
||||
} = {}) {
|
||||
let directory = path__default.resolve(toPath(cwd) ?? '');
|
||||
const {root} = path__default.parse(directory);
|
||||
stopAt = path__default.resolve(directory, toPath(stopAt) ?? root);
|
||||
const isAbsoluteName = path__default.isAbsolute(name);
|
||||
|
||||
while (directory) {
|
||||
const filePath = isAbsoluteName ? name : path__default.join(directory, name);
|
||||
|
||||
try {
|
||||
const stats = fs__default.statSync(filePath, {throwIfNoEntry: false});
|
||||
if ((type === 'file' && stats?.isFile()) || (type === 'directory' && stats?.isDirectory())) {
|
||||
return filePath;
|
||||
}
|
||||
} catch {}
|
||||
|
||||
if (directory === stopAt || directory === root) {
|
||||
break;
|
||||
}
|
||||
|
||||
directory = path__default.dirname(directory);
|
||||
}
|
||||
}
|
||||
|
||||
function _resolve(path$1, options = {}) {
|
||||
if (options.platform === "auto" || !options.platform)
|
||||
options.platform = process__default.platform === "win32" ? "win32" : "posix";
|
||||
if (process__default.versions.pnp) {
|
||||
const paths = options.paths || [];
|
||||
if (paths.length === 0)
|
||||
paths.push(process__default.cwd());
|
||||
const targetRequire = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
||||
try {
|
||||
return targetRequire.resolve(path$1, { paths });
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
const modulePath = mlly.resolvePathSync(path$1, {
|
||||
url: options.paths
|
||||
});
|
||||
if (options.platform === "win32")
|
||||
return path.win32.normalize(modulePath);
|
||||
return modulePath;
|
||||
}
|
||||
function resolveModule(name, options = {}) {
|
||||
try {
|
||||
return _resolve(name, options);
|
||||
} catch {
|
||||
return void 0;
|
||||
}
|
||||
}
|
||||
async function importModule(path) {
|
||||
const i = await import(path);
|
||||
if (i)
|
||||
return mlly.interopDefault(i);
|
||||
return i;
|
||||
}
|
||||
function isPackageExists(name, options = {}) {
|
||||
return !!resolvePackage(name, options);
|
||||
}
|
||||
function getPackageJsonPath(name, options = {}) {
|
||||
const entry = resolvePackage(name, options);
|
||||
if (!entry)
|
||||
return;
|
||||
return searchPackageJSON(entry);
|
||||
}
|
||||
const readFile = macro.quansync({
|
||||
async: (id) => fs__default.promises.readFile(id, "utf8"),
|
||||
sync: (id) => fs__default.readFileSync(id, "utf8")
|
||||
});
|
||||
const getPackageInfo = macro.quansync(function* (name, options = {}) {
|
||||
const packageJsonPath = getPackageJsonPath(name, options);
|
||||
if (!packageJsonPath)
|
||||
return;
|
||||
const packageJson = JSON.parse(yield readFile(packageJsonPath));
|
||||
return {
|
||||
name,
|
||||
version: packageJson.version,
|
||||
rootPath: path.dirname(packageJsonPath),
|
||||
packageJsonPath,
|
||||
packageJson
|
||||
};
|
||||
});
|
||||
const getPackageInfoSync = getPackageInfo.sync;
|
||||
function resolvePackage(name, options = {}) {
|
||||
try {
|
||||
return _resolve(`${name}/package.json`, options);
|
||||
} catch {
|
||||
}
|
||||
try {
|
||||
return _resolve(name, options);
|
||||
} catch (e) {
|
||||
if (e.code !== "MODULE_NOT_FOUND" && e.code !== "ERR_MODULE_NOT_FOUND")
|
||||
console.error(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function searchPackageJSON(dir) {
|
||||
let packageJsonPath;
|
||||
while (true) {
|
||||
if (!dir)
|
||||
return;
|
||||
const newDir = path.dirname(dir);
|
||||
if (newDir === dir)
|
||||
return;
|
||||
dir = newDir;
|
||||
packageJsonPath = path.join(dir, "package.json");
|
||||
if (fs__default.existsSync(packageJsonPath))
|
||||
break;
|
||||
}
|
||||
return packageJsonPath;
|
||||
}
|
||||
const findUp = macro.quansync({
|
||||
sync: findUpSync,
|
||||
async: findUp$1
|
||||
});
|
||||
const loadPackageJSON = macro.quansync(function* (cwd = process__default.cwd()) {
|
||||
const path = yield findUp("package.json", { cwd });
|
||||
if (!path || !fs__default.existsSync(path))
|
||||
return null;
|
||||
return JSON.parse(yield readFile(path));
|
||||
});
|
||||
const loadPackageJSONSync = loadPackageJSON.sync;
|
||||
const isPackageListed = macro.quansync(function* (name, cwd) {
|
||||
const pkg = (yield loadPackageJSON(cwd)) || {};
|
||||
return name in (pkg.dependencies || {}) || name in (pkg.devDependencies || {});
|
||||
});
|
||||
const isPackageListedSync = isPackageListed.sync;
|
||||
|
||||
exports.getPackageInfo = getPackageInfo;
|
||||
exports.getPackageInfoSync = getPackageInfoSync;
|
||||
exports.importModule = importModule;
|
||||
exports.isPackageExists = isPackageExists;
|
||||
exports.isPackageListed = isPackageListed;
|
||||
exports.isPackageListedSync = isPackageListedSync;
|
||||
exports.loadPackageJSON = loadPackageJSON;
|
||||
exports.loadPackageJSONSync = loadPackageJSONSync;
|
||||
exports.resolveModule = resolveModule;
|
||||
42
Frontend-Learner/node_modules/local-pkg/dist/index.d.cts
generated
vendored
Normal file
42
Frontend-Learner/node_modules/local-pkg/dist/index.d.cts
generated
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import * as quansync_types from 'quansync/types';
|
||||
import { PackageJson } from 'pkg-types';
|
||||
|
||||
interface PackageInfo {
|
||||
name: string;
|
||||
rootPath: string;
|
||||
packageJsonPath: string;
|
||||
version: string;
|
||||
packageJson: PackageJson;
|
||||
}
|
||||
interface PackageResolvingOptions {
|
||||
paths?: string[];
|
||||
/**
|
||||
* @default 'auto'
|
||||
* Resolve path as posix or win32
|
||||
*/
|
||||
platform?: 'posix' | 'win32' | 'auto';
|
||||
}
|
||||
declare function resolveModule(name: string, options?: PackageResolvingOptions): string | undefined;
|
||||
declare function importModule<T = any>(path: string): Promise<T>;
|
||||
declare function isPackageExists(name: string, options?: PackageResolvingOptions): boolean;
|
||||
declare const getPackageInfo: quansync_types.QuansyncFn<{
|
||||
name: string;
|
||||
version: string | undefined;
|
||||
rootPath: string;
|
||||
packageJsonPath: string;
|
||||
packageJson: PackageJson;
|
||||
} | undefined, [name: string, options?: PackageResolvingOptions | undefined]>;
|
||||
declare const getPackageInfoSync: (name: string, options?: PackageResolvingOptions | undefined) => {
|
||||
name: string;
|
||||
version: string | undefined;
|
||||
rootPath: string;
|
||||
packageJsonPath: string;
|
||||
packageJson: PackageJson;
|
||||
} | undefined;
|
||||
declare const loadPackageJSON: quansync_types.QuansyncFn<PackageJson | null, [cwd?: Args[0] | undefined]>;
|
||||
declare const loadPackageJSONSync: (cwd?: Args[0] | undefined) => PackageJson | null;
|
||||
declare const isPackageListed: quansync_types.QuansyncFn<boolean, [name: string, cwd?: string | undefined]>;
|
||||
declare const isPackageListedSync: (name: string, cwd?: string | undefined) => boolean;
|
||||
|
||||
export { getPackageInfo, getPackageInfoSync, importModule, isPackageExists, isPackageListed, isPackageListedSync, loadPackageJSON, loadPackageJSONSync, resolveModule };
|
||||
export type { PackageInfo, PackageResolvingOptions };
|
||||
42
Frontend-Learner/node_modules/local-pkg/dist/index.d.mts
generated
vendored
Normal file
42
Frontend-Learner/node_modules/local-pkg/dist/index.d.mts
generated
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import * as quansync_types from 'quansync/types';
|
||||
import { PackageJson } from 'pkg-types';
|
||||
|
||||
interface PackageInfo {
|
||||
name: string;
|
||||
rootPath: string;
|
||||
packageJsonPath: string;
|
||||
version: string;
|
||||
packageJson: PackageJson;
|
||||
}
|
||||
interface PackageResolvingOptions {
|
||||
paths?: string[];
|
||||
/**
|
||||
* @default 'auto'
|
||||
* Resolve path as posix or win32
|
||||
*/
|
||||
platform?: 'posix' | 'win32' | 'auto';
|
||||
}
|
||||
declare function resolveModule(name: string, options?: PackageResolvingOptions): string | undefined;
|
||||
declare function importModule<T = any>(path: string): Promise<T>;
|
||||
declare function isPackageExists(name: string, options?: PackageResolvingOptions): boolean;
|
||||
declare const getPackageInfo: quansync_types.QuansyncFn<{
|
||||
name: string;
|
||||
version: string | undefined;
|
||||
rootPath: string;
|
||||
packageJsonPath: string;
|
||||
packageJson: PackageJson;
|
||||
} | undefined, [name: string, options?: PackageResolvingOptions | undefined]>;
|
||||
declare const getPackageInfoSync: (name: string, options?: PackageResolvingOptions | undefined) => {
|
||||
name: string;
|
||||
version: string | undefined;
|
||||
rootPath: string;
|
||||
packageJsonPath: string;
|
||||
packageJson: PackageJson;
|
||||
} | undefined;
|
||||
declare const loadPackageJSON: quansync_types.QuansyncFn<PackageJson | null, [cwd?: Args[0] | undefined]>;
|
||||
declare const loadPackageJSONSync: (cwd?: Args[0] | undefined) => PackageJson | null;
|
||||
declare const isPackageListed: quansync_types.QuansyncFn<boolean, [name: string, cwd?: string | undefined]>;
|
||||
declare const isPackageListedSync: (name: string, cwd?: string | undefined) => boolean;
|
||||
|
||||
export { getPackageInfo, getPackageInfoSync, importModule, isPackageExists, isPackageListed, isPackageListedSync, loadPackageJSON, loadPackageJSONSync, resolveModule };
|
||||
export type { PackageInfo, PackageResolvingOptions };
|
||||
42
Frontend-Learner/node_modules/local-pkg/dist/index.d.ts
generated
vendored
Normal file
42
Frontend-Learner/node_modules/local-pkg/dist/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import * as quansync_types from 'quansync/types';
|
||||
import { PackageJson } from 'pkg-types';
|
||||
|
||||
interface PackageInfo {
|
||||
name: string;
|
||||
rootPath: string;
|
||||
packageJsonPath: string;
|
||||
version: string;
|
||||
packageJson: PackageJson;
|
||||
}
|
||||
interface PackageResolvingOptions {
|
||||
paths?: string[];
|
||||
/**
|
||||
* @default 'auto'
|
||||
* Resolve path as posix or win32
|
||||
*/
|
||||
platform?: 'posix' | 'win32' | 'auto';
|
||||
}
|
||||
declare function resolveModule(name: string, options?: PackageResolvingOptions): string | undefined;
|
||||
declare function importModule<T = any>(path: string): Promise<T>;
|
||||
declare function isPackageExists(name: string, options?: PackageResolvingOptions): boolean;
|
||||
declare const getPackageInfo: quansync_types.QuansyncFn<{
|
||||
name: string;
|
||||
version: string | undefined;
|
||||
rootPath: string;
|
||||
packageJsonPath: string;
|
||||
packageJson: PackageJson;
|
||||
} | undefined, [name: string, options?: PackageResolvingOptions | undefined]>;
|
||||
declare const getPackageInfoSync: (name: string, options?: PackageResolvingOptions | undefined) => {
|
||||
name: string;
|
||||
version: string | undefined;
|
||||
rootPath: string;
|
||||
packageJsonPath: string;
|
||||
packageJson: PackageJson;
|
||||
} | undefined;
|
||||
declare const loadPackageJSON: quansync_types.QuansyncFn<PackageJson | null, [cwd?: Args[0] | undefined]>;
|
||||
declare const loadPackageJSONSync: (cwd?: Args[0] | undefined) => PackageJson | null;
|
||||
declare const isPackageListed: quansync_types.QuansyncFn<boolean, [name: string, cwd?: string | undefined]>;
|
||||
declare const isPackageListedSync: (name: string, cwd?: string | undefined) => boolean;
|
||||
|
||||
export { getPackageInfo, getPackageInfoSync, importModule, isPackageExists, isPackageListed, isPackageListedSync, loadPackageJSON, loadPackageJSONSync, resolveModule };
|
||||
export type { PackageInfo, PackageResolvingOptions };
|
||||
172
Frontend-Learner/node_modules/local-pkg/dist/index.mjs
generated
vendored
Normal file
172
Frontend-Learner/node_modules/local-pkg/dist/index.mjs
generated
vendored
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
import fs from 'node:fs';
|
||||
import { createRequire } from 'node:module';
|
||||
import path, { dirname, join, win32 } from 'node:path';
|
||||
import process from 'node:process';
|
||||
import fsPromises from 'node:fs/promises';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { resolvePathSync, interopDefault } from 'mlly';
|
||||
import { quansync } from 'quansync/macro';
|
||||
|
||||
const toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
|
||||
|
||||
async function findUp$1(name, {
|
||||
cwd = process.cwd(),
|
||||
type = 'file',
|
||||
stopAt,
|
||||
} = {}) {
|
||||
let directory = path.resolve(toPath(cwd) ?? '');
|
||||
const {root} = path.parse(directory);
|
||||
stopAt = path.resolve(directory, toPath(stopAt ?? root));
|
||||
const isAbsoluteName = path.isAbsolute(name);
|
||||
|
||||
while (directory) {
|
||||
const filePath = isAbsoluteName ? name : path.join(directory, name);
|
||||
try {
|
||||
const stats = await fsPromises.stat(filePath); // eslint-disable-line no-await-in-loop
|
||||
if ((type === 'file' && stats.isFile()) || (type === 'directory' && stats.isDirectory())) {
|
||||
return filePath;
|
||||
}
|
||||
} catch {}
|
||||
|
||||
if (directory === stopAt || directory === root) {
|
||||
break;
|
||||
}
|
||||
|
||||
directory = path.dirname(directory);
|
||||
}
|
||||
}
|
||||
|
||||
function findUpSync(name, {
|
||||
cwd = process.cwd(),
|
||||
type = 'file',
|
||||
stopAt,
|
||||
} = {}) {
|
||||
let directory = path.resolve(toPath(cwd) ?? '');
|
||||
const {root} = path.parse(directory);
|
||||
stopAt = path.resolve(directory, toPath(stopAt) ?? root);
|
||||
const isAbsoluteName = path.isAbsolute(name);
|
||||
|
||||
while (directory) {
|
||||
const filePath = isAbsoluteName ? name : path.join(directory, name);
|
||||
|
||||
try {
|
||||
const stats = fs.statSync(filePath, {throwIfNoEntry: false});
|
||||
if ((type === 'file' && stats?.isFile()) || (type === 'directory' && stats?.isDirectory())) {
|
||||
return filePath;
|
||||
}
|
||||
} catch {}
|
||||
|
||||
if (directory === stopAt || directory === root) {
|
||||
break;
|
||||
}
|
||||
|
||||
directory = path.dirname(directory);
|
||||
}
|
||||
}
|
||||
|
||||
function _resolve(path, options = {}) {
|
||||
if (options.platform === "auto" || !options.platform)
|
||||
options.platform = process.platform === "win32" ? "win32" : "posix";
|
||||
if (process.versions.pnp) {
|
||||
const paths = options.paths || [];
|
||||
if (paths.length === 0)
|
||||
paths.push(process.cwd());
|
||||
const targetRequire = createRequire(import.meta.url);
|
||||
try {
|
||||
return targetRequire.resolve(path, { paths });
|
||||
} catch {
|
||||
}
|
||||
}
|
||||
const modulePath = resolvePathSync(path, {
|
||||
url: options.paths
|
||||
});
|
||||
if (options.platform === "win32")
|
||||
return win32.normalize(modulePath);
|
||||
return modulePath;
|
||||
}
|
||||
function resolveModule(name, options = {}) {
|
||||
try {
|
||||
return _resolve(name, options);
|
||||
} catch {
|
||||
return void 0;
|
||||
}
|
||||
}
|
||||
async function importModule(path) {
|
||||
const i = await import(path);
|
||||
if (i)
|
||||
return interopDefault(i);
|
||||
return i;
|
||||
}
|
||||
function isPackageExists(name, options = {}) {
|
||||
return !!resolvePackage(name, options);
|
||||
}
|
||||
function getPackageJsonPath(name, options = {}) {
|
||||
const entry = resolvePackage(name, options);
|
||||
if (!entry)
|
||||
return;
|
||||
return searchPackageJSON(entry);
|
||||
}
|
||||
const readFile = quansync({
|
||||
async: (id) => fs.promises.readFile(id, "utf8"),
|
||||
sync: (id) => fs.readFileSync(id, "utf8")
|
||||
});
|
||||
const getPackageInfo = quansync(function* (name, options = {}) {
|
||||
const packageJsonPath = getPackageJsonPath(name, options);
|
||||
if (!packageJsonPath)
|
||||
return;
|
||||
const packageJson = JSON.parse(yield readFile(packageJsonPath));
|
||||
return {
|
||||
name,
|
||||
version: packageJson.version,
|
||||
rootPath: dirname(packageJsonPath),
|
||||
packageJsonPath,
|
||||
packageJson
|
||||
};
|
||||
});
|
||||
const getPackageInfoSync = getPackageInfo.sync;
|
||||
function resolvePackage(name, options = {}) {
|
||||
try {
|
||||
return _resolve(`${name}/package.json`, options);
|
||||
} catch {
|
||||
}
|
||||
try {
|
||||
return _resolve(name, options);
|
||||
} catch (e) {
|
||||
if (e.code !== "MODULE_NOT_FOUND" && e.code !== "ERR_MODULE_NOT_FOUND")
|
||||
console.error(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function searchPackageJSON(dir) {
|
||||
let packageJsonPath;
|
||||
while (true) {
|
||||
if (!dir)
|
||||
return;
|
||||
const newDir = dirname(dir);
|
||||
if (newDir === dir)
|
||||
return;
|
||||
dir = newDir;
|
||||
packageJsonPath = join(dir, "package.json");
|
||||
if (fs.existsSync(packageJsonPath))
|
||||
break;
|
||||
}
|
||||
return packageJsonPath;
|
||||
}
|
||||
const findUp = quansync({
|
||||
sync: findUpSync,
|
||||
async: findUp$1
|
||||
});
|
||||
const loadPackageJSON = quansync(function* (cwd = process.cwd()) {
|
||||
const path = yield findUp("package.json", { cwd });
|
||||
if (!path || !fs.existsSync(path))
|
||||
return null;
|
||||
return JSON.parse(yield readFile(path));
|
||||
});
|
||||
const loadPackageJSONSync = loadPackageJSON.sync;
|
||||
const isPackageListed = quansync(function* (name, cwd) {
|
||||
const pkg = (yield loadPackageJSON(cwd)) || {};
|
||||
return name in (pkg.dependencies || {}) || name in (pkg.devDependencies || {});
|
||||
});
|
||||
const isPackageListedSync = isPackageListed.sync;
|
||||
|
||||
export { getPackageInfo, getPackageInfoSync, importModule, isPackageExists, isPackageListed, isPackageListedSync, loadPackageJSON, loadPackageJSONSync, resolveModule };
|
||||
65
Frontend-Learner/node_modules/local-pkg/package.json
generated
vendored
Normal file
65
Frontend-Learner/node_modules/local-pkg/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
{
|
||||
"name": "local-pkg",
|
||||
"type": "module",
|
||||
"version": "1.1.2",
|
||||
"description": "Get information on local packages.",
|
||||
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
||||
"license": "MIT",
|
||||
"funding": "https://github.com/sponsors/antfu",
|
||||
"homepage": "https://github.com/antfu-collective/local-pkg#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/antfu-collective/local-pkg.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/antfu-collective/local-pkg/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"package"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.cjs"
|
||||
}
|
||||
},
|
||||
"main": "dist/index.cjs",
|
||||
"module": "dist/index.mjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
},
|
||||
"dependencies": {
|
||||
"mlly": "^1.7.4",
|
||||
"pkg-types": "^2.3.0",
|
||||
"quansync": "^0.2.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "^5.2.1",
|
||||
"@antfu/ni": "^25.0.0",
|
||||
"@antfu/utils": "^9.2.0",
|
||||
"@types/chai": "^5.2.2",
|
||||
"@types/node": "^24.3.0",
|
||||
"bumpp": "^10.2.3",
|
||||
"chai": "^5.3.1",
|
||||
"eslint": "^9.33.0",
|
||||
"esno": "^4.8.0",
|
||||
"find-up-simple": "^1.0.1",
|
||||
"typescript": "^5.9.2",
|
||||
"unbuild": "^3.6.1",
|
||||
"unplugin-quansync": "^0.4.4",
|
||||
"vitest": "^3.2.4"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "unbuild",
|
||||
"lint": "eslint .",
|
||||
"release": "bumpp",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"test": "vitest run && node ./test/cjs.cjs && node ./test/esm.mjs"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue