修改后台权限

This commit is contained in:
yoyuzh
2026-03-24 14:30:59 +08:00
parent 00f902f475
commit b2d9db7be9
9310 changed files with 1246063 additions and 48 deletions

2
node_modules/cosmiconfig/dist/Explorer.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=Explorer.d.ts.map

170
node_modules/cosmiconfig/dist/Explorer.js generated vendored Normal file
View File

@@ -0,0 +1,170 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Explorer = void 0;
const promises_1 = __importDefault(require("fs/promises"));
const path_1 = __importDefault(require("path"));
const defaults_1 = require("./defaults");
const ExplorerBase_js_1 = require("./ExplorerBase.js");
const merge_1 = require("./merge");
const util_js_1 = require("./util.js");
/**
* @internal
*/
class Explorer extends ExplorerBase_js_1.ExplorerBase {
async load(filepath) {
filepath = path_1.default.resolve(filepath);
const load = async () => {
return await this.config.transform(await this.#readConfiguration(filepath));
};
if (this.loadCache) {
return await (0, util_js_1.emplace)(this.loadCache, filepath, load);
}
return await load();
}
async search(from = '') {
if (this.config.metaConfigFilePath) {
this.loadingMetaConfig = true;
const config = await this.load(this.config.metaConfigFilePath);
this.loadingMetaConfig = false;
if (config && !config.isEmpty) {
return config;
}
}
from = path_1.default.resolve(from);
const dirs = this.#getDirs(from);
const firstDirIter = await dirs.next();
/* istanbul ignore if -- @preserve */
if (firstDirIter.done) {
// this should never happen
throw new Error(`Could not find any folders to iterate through (start from ${from})`);
}
let currentDir = firstDirIter.value;
const search = async () => {
/* istanbul ignore if -- @preserve */
if (await (0, util_js_1.isDirectory)(currentDir.path)) {
for (const filepath of this.getSearchPlacesForDir(currentDir, defaults_1.globalConfigSearchPlaces)) {
try {
const result = await this.#readConfiguration(filepath);
if (result !== null &&
!(result.isEmpty && this.config.ignoreEmptySearchPlaces)) {
return await this.config.transform(result);
}
}
catch (error) {
if (error.code === 'ENOENT' ||
error.code === 'EISDIR' ||
error.code === 'ENOTDIR' ||
error.code === 'EACCES') {
continue;
}
throw error;
}
}
}
const nextDirIter = await dirs.next();
if (!nextDirIter.done) {
currentDir = nextDirIter.value;
if (this.searchCache) {
return await (0, util_js_1.emplace)(this.searchCache, currentDir.path, search);
}
return await search();
}
return await this.config.transform(null);
};
if (this.searchCache) {
return await (0, util_js_1.emplace)(this.searchCache, from, search);
}
return await search();
}
async #readConfiguration(filepath, importStack = []) {
const contents = await promises_1.default.readFile(filepath, { encoding: 'utf-8' });
return this.toCosmiconfigResult(filepath, await this.#loadConfigFileWithImports(filepath, contents, importStack));
}
async #loadConfigFileWithImports(filepath, contents, importStack) {
const loadedContent = await this.#loadConfiguration(filepath, contents);
if (!loadedContent || !(0, merge_1.hasOwn)(loadedContent, '$import')) {
return loadedContent;
}
const fileDirectory = path_1.default.dirname(filepath);
const { $import: imports, ...ownContent } = loadedContent;
const importPaths = Array.isArray(imports) ? imports : [imports];
const newImportStack = [...importStack, filepath];
this.validateImports(filepath, importPaths, newImportStack);
const importedConfigs = await Promise.all(importPaths.map(async (importPath) => {
const fullPath = path_1.default.resolve(fileDirectory, importPath);
const result = await this.#readConfiguration(fullPath, newImportStack);
return result?.config;
}));
return (0, merge_1.mergeAll)([...importedConfigs, ownContent], {
mergeArrays: this.config.mergeImportArrays,
});
}
async #loadConfiguration(filepath, contents) {
if (contents.trim() === '') {
return;
}
const extension = path_1.default.extname(filepath);
const loader = this.config.loaders[extension || 'noExt'] ??
this.config.loaders['default'];
if (!loader) {
throw new Error(`No loader specified for ${(0, ExplorerBase_js_1.getExtensionDescription)(extension)}`);
}
try {
const loadedContents = await loader(filepath, contents);
if (path_1.default.basename(filepath, extension) !== 'package') {
return loadedContents;
}
return ((0, util_js_1.getPropertyByPath)(loadedContents, this.config.packageProp ?? this.config.moduleName) ?? null);
}
catch (error) {
error.filepath = filepath;
throw error;
}
}
async #fileExists(path) {
try {
await promises_1.default.stat(path);
return true;
}
catch (e) {
return false;
}
}
async *#getDirs(startDir) {
switch (this.config.searchStrategy) {
case 'none': {
// only check in the passed directory (defaults to working directory)
yield { path: startDir, isGlobalConfig: false };
return;
}
case 'project': {
let currentDir = startDir;
while (true) {
yield { path: currentDir, isGlobalConfig: false };
for (const ext of ['json', 'yaml']) {
const packageFile = path_1.default.join(currentDir, `package.${ext}`);
if (await this.#fileExists(packageFile)) {
break;
}
}
const parentDir = path_1.default.dirname(currentDir);
/* istanbul ignore if -- @preserve */
if (parentDir === currentDir) {
// we're probably at the root of the directory structure
break;
}
currentDir = parentDir;
}
return;
}
case 'global': {
yield* this.getGlobalDirs(startDir);
}
}
}
}
exports.Explorer = Explorer;
//# sourceMappingURL=Explorer.js.map

2
node_modules/cosmiconfig/dist/ExplorerBase.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=ExplorerBase.d.ts.map

126
node_modules/cosmiconfig/dist/ExplorerBase.js generated vendored Normal file
View File

@@ -0,0 +1,126 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getExtensionDescription = exports.ExplorerBase = void 0;
const env_paths_1 = __importDefault(require("env-paths"));
const os_1 = __importDefault(require("os"));
const path_1 = __importDefault(require("path"));
const util_js_1 = require("./util.js");
/**
* @internal
*/
class ExplorerBase {
#loadingMetaConfig = false;
config;
loadCache;
searchCache;
constructor(options) {
this.config = options;
if (options.cache) {
this.loadCache = new Map();
this.searchCache = new Map();
}
this.#validateConfig();
}
set loadingMetaConfig(value) {
this.#loadingMetaConfig = value;
}
#validateConfig() {
const config = this.config;
for (const place of config.searchPlaces) {
const extension = path_1.default.extname(place);
const loader = this.config.loaders[extension || 'noExt'] ??
this.config.loaders['default'];
if (loader === undefined) {
throw new Error(`Missing loader for ${getExtensionDescription(place)}.`);
}
if (typeof loader !== 'function') {
throw new Error(`Loader for ${getExtensionDescription(place)} is not a function: Received ${typeof loader}.`);
}
}
}
clearLoadCache() {
if (this.loadCache) {
this.loadCache.clear();
}
}
clearSearchCache() {
if (this.searchCache) {
this.searchCache.clear();
}
}
clearCaches() {
this.clearLoadCache();
this.clearSearchCache();
}
toCosmiconfigResult(filepath, config) {
if (config === null) {
return null;
}
if (config === undefined) {
return { filepath, config: undefined, isEmpty: true };
}
if (this.config.applyPackagePropertyPathToConfiguration ||
this.#loadingMetaConfig) {
const packageProp = this.config.packageProp ?? this.config.moduleName;
config = (0, util_js_1.getPropertyByPath)(config, packageProp);
}
if (config === undefined) {
return { filepath, config: undefined, isEmpty: true };
}
return { config, filepath };
}
validateImports(containingFilePath, imports, importStack) {
const fileDirectory = path_1.default.dirname(containingFilePath);
for (const importPath of imports) {
if (typeof importPath !== 'string') {
throw new Error(`${containingFilePath}: Key $import must contain a string or a list of strings`);
}
const fullPath = path_1.default.resolve(fileDirectory, importPath);
if (fullPath === containingFilePath) {
throw new Error(`Self-import detected in ${containingFilePath}`);
}
const idx = importStack.indexOf(fullPath);
if (idx !== -1) {
throw new Error(`Circular import detected:
${[...importStack, fullPath]
.map((path, i) => `${i + 1}. ${path}`)
.join('\n')} (same as ${idx + 1}.)`);
}
}
}
getSearchPlacesForDir(dir, globalConfigPlaces) {
return (dir.isGlobalConfig ? globalConfigPlaces : this.config.searchPlaces).map((place) => path_1.default.join(dir.path, place));
}
getGlobalConfigDir() {
return (0, env_paths_1.default)(this.config.moduleName, { suffix: '' }).config;
}
*getGlobalDirs(startDir) {
const stopDir = path_1.default.resolve(this.config.stopDir ?? os_1.default.homedir());
yield { path: startDir, isGlobalConfig: false };
let currentDir = startDir;
while (currentDir !== stopDir) {
const parentDir = path_1.default.dirname(currentDir);
/* istanbul ignore if -- @preserve */
if (parentDir === currentDir) {
// we're probably at the root of the directory structure
break;
}
yield { path: parentDir, isGlobalConfig: false };
currentDir = parentDir;
}
yield { path: this.getGlobalConfigDir(), isGlobalConfig: true };
}
}
exports.ExplorerBase = ExplorerBase;
/**
* @internal
*/
function getExtensionDescription(extension) {
/* istanbul ignore next -- @preserve */
return extension ? `extension "${extension}"` : 'files without extensions';
}
exports.getExtensionDescription = getExtensionDescription;
//# sourceMappingURL=ExplorerBase.js.map

2
node_modules/cosmiconfig/dist/ExplorerSync.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=ExplorerSync.d.ts.map

184
node_modules/cosmiconfig/dist/ExplorerSync.js generated vendored Normal file
View File

@@ -0,0 +1,184 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExplorerSync = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const defaults_1 = require("./defaults");
const ExplorerBase_js_1 = require("./ExplorerBase.js");
const merge_1 = require("./merge");
const util_js_1 = require("./util.js");
/**
* @internal
*/
class ExplorerSync extends ExplorerBase_js_1.ExplorerBase {
load(filepath) {
filepath = path_1.default.resolve(filepath);
const load = () => {
return this.config.transform(this.#readConfiguration(filepath));
};
if (this.loadCache) {
return (0, util_js_1.emplace)(this.loadCache, filepath, load);
}
return load();
}
search(from = '') {
if (this.config.metaConfigFilePath) {
this.loadingMetaConfig = true;
const config = this.load(this.config.metaConfigFilePath);
this.loadingMetaConfig = false;
if (config && !config.isEmpty) {
return config;
}
}
from = path_1.default.resolve(from);
const dirs = this.#getDirs(from);
const firstDirIter = dirs.next();
/* istanbul ignore if -- @preserve */
if (firstDirIter.done) {
// this should never happen
throw new Error(`Could not find any folders to iterate through (start from ${from})`);
}
let currentDir = firstDirIter.value;
const search = () => {
/* istanbul ignore if -- @preserve */
if ((0, util_js_1.isDirectorySync)(currentDir.path)) {
for (const filepath of this.getSearchPlacesForDir(currentDir, defaults_1.globalConfigSearchPlacesSync)) {
try {
const result = this.#readConfiguration(filepath);
if (result !== null &&
!(result.isEmpty && this.config.ignoreEmptySearchPlaces)) {
return this.config.transform(result);
}
}
catch (error) {
if (error.code === 'ENOENT' ||
error.code === 'EISDIR' ||
error.code === 'ENOTDIR' ||
error.code === 'EACCES') {
continue;
}
throw error;
}
}
}
const nextDirIter = dirs.next();
if (!nextDirIter.done) {
currentDir = nextDirIter.value;
if (this.searchCache) {
return (0, util_js_1.emplace)(this.searchCache, currentDir.path, search);
}
return search();
}
return this.config.transform(null);
};
if (this.searchCache) {
return (0, util_js_1.emplace)(this.searchCache, from, search);
}
return search();
}
#readConfiguration(filepath, importStack = []) {
const contents = fs_1.default.readFileSync(filepath, 'utf8');
return this.toCosmiconfigResult(filepath, this.#loadConfigFileWithImports(filepath, contents, importStack));
}
#loadConfigFileWithImports(filepath, contents, importStack) {
const loadedContent = this.#loadConfiguration(filepath, contents);
if (!loadedContent || !(0, merge_1.hasOwn)(loadedContent, '$import')) {
return loadedContent;
}
const fileDirectory = path_1.default.dirname(filepath);
const { $import: imports, ...ownContent } = loadedContent;
const importPaths = Array.isArray(imports) ? imports : [imports];
const newImportStack = [...importStack, filepath];
this.validateImports(filepath, importPaths, newImportStack);
const importedConfigs = importPaths.map((importPath) => {
const fullPath = path_1.default.resolve(fileDirectory, importPath);
const result = this.#readConfiguration(fullPath, newImportStack);
return result?.config;
});
return (0, merge_1.mergeAll)([...importedConfigs, ownContent], {
mergeArrays: this.config.mergeImportArrays,
});
}
#loadConfiguration(filepath, contents) {
if (contents.trim() === '') {
return;
}
const extension = path_1.default.extname(filepath);
const loader = this.config.loaders[extension || 'noExt'] ??
this.config.loaders['default'];
if (!loader) {
throw new Error(`No loader specified for ${(0, ExplorerBase_js_1.getExtensionDescription)(extension)}`);
}
try {
const loadedContents = loader(filepath, contents);
if (path_1.default.basename(filepath, extension) !== 'package') {
return loadedContents;
}
return ((0, util_js_1.getPropertyByPath)(loadedContents, this.config.packageProp ?? this.config.moduleName) ?? null);
}
catch (error) {
error.filepath = filepath;
throw error;
}
}
#fileExists(path) {
try {
fs_1.default.statSync(path);
return true;
}
catch (e) {
return false;
}
}
*#getDirs(startDir) {
switch (this.config.searchStrategy) {
case 'none': {
// there is no next dir
yield { path: startDir, isGlobalConfig: false };
return;
}
case 'project': {
let currentDir = startDir;
while (true) {
yield { path: currentDir, isGlobalConfig: false };
for (const ext of ['json', 'yaml']) {
const packageFile = path_1.default.join(currentDir, `package.${ext}`);
if (this.#fileExists(packageFile)) {
break;
}
}
const parentDir = path_1.default.dirname(currentDir);
/* istanbul ignore if -- @preserve */
if (parentDir === currentDir) {
// we're probably at the root of the directory structure
break;
}
currentDir = parentDir;
}
return;
}
case 'global': {
yield* this.getGlobalDirs(startDir);
}
}
}
/**
* @deprecated Use {@link ExplorerSync.prototype.load}.
*/
/* istanbul ignore next */
loadSync(filepath) {
return this.load(filepath);
}
/**
* @deprecated Use {@link ExplorerSync.prototype.search}.
*/
/* istanbul ignore next */
searchSync(from = '') {
return this.search(from);
}
}
exports.ExplorerSync = ExplorerSync;
//# sourceMappingURL=ExplorerSync.js.map

5
node_modules/cosmiconfig/dist/cacheWrapper.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
import { Cache, CosmiconfigResult } from './types';
declare function cacheWrapper(cache: Cache, key: string, fn: () => Promise<CosmiconfigResult>): Promise<CosmiconfigResult>;
declare function cacheWrapperSync(cache: Cache, key: string, fn: () => CosmiconfigResult): CosmiconfigResult;
export { cacheWrapper, cacheWrapperSync };
//# sourceMappingURL=cacheWrapper.d.ts.map

32
node_modules/cosmiconfig/dist/cacheWrapper.js generated vendored Normal file
View File

@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.cacheWrapper = cacheWrapper;
exports.cacheWrapperSync = cacheWrapperSync;
async function cacheWrapper(cache, key, fn) {
const cached = cache.get(key);
if (cached !== undefined) {
return cached;
}
const result = await fn();
cache.set(key, result);
return result;
}
function cacheWrapperSync(cache, key, fn) {
const cached = cache.get(key);
if (cached !== undefined) {
return cached;
}
const result = fn();
cache.set(key, result);
return result;
}
//# sourceMappingURL=cacheWrapper.js.map

View File

@@ -0,0 +1,3 @@
declare function canUseDynamicImport(): boolean;
export { canUseDynamicImport };
//# sourceMappingURL=canUseDynamicImport.d.ts.map

23
node_modules/cosmiconfig/dist/canUseDynamicImport.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.canUseDynamicImport = canUseDynamicImport;
/* istanbul ignore file -- @preserve */
let result;
function canUseDynamicImport() {
if (result === undefined) {
try {
new Function('id', 'return import(id);');
result = true;
} catch (e) {
result = false;
}
}
return result;
}
//# sourceMappingURL=canUseDynamicImport.js.map

25
node_modules/cosmiconfig/dist/defaults.d.ts generated vendored Normal file
View File

@@ -0,0 +1,25 @@
export declare function getDefaultSearchPlaces(moduleName: string): Array<string>;
export declare function getDefaultSearchPlacesSync(moduleName: string): Array<string>;
export declare const globalConfigSearchPlaces: string[];
export declare const globalConfigSearchPlacesSync: string[];
export declare const metaSearchPlaces: string[];
export declare const defaultLoaders: Readonly<{
readonly '.mjs': import("./types").Loader;
readonly '.cjs': import("./types").Loader;
readonly '.js': import("./types").Loader;
readonly '.ts': import("./types").Loader;
readonly '.json': import("./types").LoaderSync;
readonly '.yaml': import("./types").LoaderSync;
readonly '.yml': import("./types").LoaderSync;
readonly noExt: import("./types").LoaderSync;
}>;
export declare const defaultLoadersSync: Readonly<{
readonly '.cjs': import("./types").LoaderSync;
readonly '.js': import("./types").LoaderSync;
readonly '.ts': import("./types").LoaderSync;
readonly '.json': import("./types").LoaderSync;
readonly '.yaml': import("./types").LoaderSync;
readonly '.yml': import("./types").LoaderSync;
readonly noExt: import("./types").LoaderSync;
}>;
//# sourceMappingURL=defaults.d.ts.map

105
node_modules/cosmiconfig/dist/defaults.js generated vendored Normal file
View File

@@ -0,0 +1,105 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultLoadersSync = exports.defaultLoaders = exports.metaSearchPlaces = exports.globalConfigSearchPlacesSync = exports.globalConfigSearchPlaces = exports.getDefaultSearchPlacesSync = exports.getDefaultSearchPlaces = void 0;
const loaders_1 = require("./loaders");
function getDefaultSearchPlaces(moduleName) {
return [
'package.json',
`.${moduleName}rc`,
`.${moduleName}rc.json`,
`.${moduleName}rc.yaml`,
`.${moduleName}rc.yml`,
`.${moduleName}rc.js`,
`.${moduleName}rc.ts`,
`.${moduleName}rc.cjs`,
`.${moduleName}rc.mjs`,
`.config/${moduleName}rc`,
`.config/${moduleName}rc.json`,
`.config/${moduleName}rc.yaml`,
`.config/${moduleName}rc.yml`,
`.config/${moduleName}rc.js`,
`.config/${moduleName}rc.ts`,
`.config/${moduleName}rc.cjs`,
`.config/${moduleName}rc.mjs`,
`${moduleName}.config.js`,
`${moduleName}.config.ts`,
`${moduleName}.config.cjs`,
`${moduleName}.config.mjs`,
];
}
exports.getDefaultSearchPlaces = getDefaultSearchPlaces;
function getDefaultSearchPlacesSync(moduleName) {
return [
'package.json',
`.${moduleName}rc`,
`.${moduleName}rc.json`,
`.${moduleName}rc.yaml`,
`.${moduleName}rc.yml`,
`.${moduleName}rc.js`,
`.${moduleName}rc.ts`,
`.${moduleName}rc.cjs`,
`.config/${moduleName}rc`,
`.config/${moduleName}rc.json`,
`.config/${moduleName}rc.yaml`,
`.config/${moduleName}rc.yml`,
`.config/${moduleName}rc.js`,
`.config/${moduleName}rc.ts`,
`.config/${moduleName}rc.cjs`,
`${moduleName}.config.js`,
`${moduleName}.config.ts`,
`${moduleName}.config.cjs`,
];
}
exports.getDefaultSearchPlacesSync = getDefaultSearchPlacesSync;
exports.globalConfigSearchPlaces = [
'config',
'config.json',
'config.yaml',
'config.yml',
'config.js',
'config.ts',
'config.cjs',
'config.mjs',
];
exports.globalConfigSearchPlacesSync = [
'config',
'config.json',
'config.yaml',
'config.yml',
'config.js',
'config.ts',
'config.cjs',
];
// this needs to be hardcoded, as this is intended for end users, who can't supply options at this point
exports.metaSearchPlaces = [
'package.json',
'package.yaml',
'.config/config.json',
'.config/config.yaml',
'.config/config.yml',
'.config/config.js',
'.config/config.ts',
'.config/config.cjs',
'.config/config.mjs',
];
// do not allow mutation of default loaders. Make sure it is set inside options
exports.defaultLoaders = Object.freeze({
'.mjs': loaders_1.loadJs,
'.cjs': loaders_1.loadJs,
'.js': loaders_1.loadJs,
'.ts': loaders_1.loadTs,
'.json': loaders_1.loadJson,
'.yaml': loaders_1.loadYaml,
'.yml': loaders_1.loadYaml,
noExt: loaders_1.loadYaml,
});
exports.defaultLoadersSync = Object.freeze({
'.cjs': loaders_1.loadJsSync,
'.js': loaders_1.loadJsSync,
'.ts': loaders_1.loadTsSync,
'.json': loaders_1.loadJson,
'.yaml': loaders_1.loadYaml,
'.yml': loaders_1.loadYaml,
noExt: loaders_1.loadYaml,
});
//# sourceMappingURL=defaults.js.map

4
node_modules/cosmiconfig/dist/getDirectory.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
declare function getDirectory(filepath: string): Promise<string>;
declare function getDirectorySync(filepath: string): string;
export { getDirectory, getDirectorySync };
//# sourceMappingURL=getDirectory.d.ts.map

38
node_modules/cosmiconfig/dist/getDirectory.js generated vendored Normal file
View File

@@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getDirectory = getDirectory;
exports.getDirectorySync = getDirectorySync;
var _path = _interopRequireDefault(require("path"));
var _pathType = require("path-type");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
async function getDirectory(filepath) {
const filePathIsDirectory = await (0, _pathType.isDirectory)(filepath);
if (filePathIsDirectory === true) {
return filepath;
}
const directory = _path.default.dirname(filepath);
return directory;
}
function getDirectorySync(filepath) {
const filePathIsDirectory = (0, _pathType.isDirectorySync)(filepath);
if (filePathIsDirectory === true) {
return filepath;
}
const directory = _path.default.dirname(filepath);
return directory;
}
//# sourceMappingURL=getDirectory.js.map

5
node_modules/cosmiconfig/dist/getPropertyByPath.d.ts generated vendored Normal file
View File

@@ -0,0 +1,5 @@
declare function getPropertyByPath(source: {
[key: string]: unknown;
}, path: string | Array<string>): unknown;
export { getPropertyByPath };
//# sourceMappingURL=getPropertyByPath.d.ts.map

28
node_modules/cosmiconfig/dist/getPropertyByPath.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getPropertyByPath = getPropertyByPath;
// Resolves property names or property paths defined with period-delimited
// strings or arrays of strings. Property names that are found on the source
// object are used directly (even if they include a period).
// Nested property names that include periods, within a path, are only
// understood in array paths.
function getPropertyByPath(source, path) {
if (typeof path === 'string' && Object.prototype.hasOwnProperty.call(source, path)) {
return source[path];
}
const parsedPath = typeof path === 'string' ? path.split('.') : path; // eslint-disable-next-line @typescript-eslint/no-explicit-any
return parsedPath.reduce((previous, key) => {
if (previous === undefined) {
return previous;
}
return previous[key];
}, source);
}
//# sourceMappingURL=getPropertyByPath.js.map

6
node_modules/cosmiconfig/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import { defaultLoaders, defaultLoadersSync, getDefaultSearchPlaces, getDefaultSearchPlacesSync, globalConfigSearchPlaces, globalConfigSearchPlacesSync } from './defaults';
import { CommonOptions, Config, CosmiconfigResult, Loader, LoaderResult, Loaders, LoadersSync, LoaderSync, Options, OptionsSync, PublicExplorer, PublicExplorerBase, PublicExplorerSync, SearchStrategy, Transform, TransformSync } from './types.js';
export declare function cosmiconfig(moduleName: string, options?: Readonly<Partial<Options>>): PublicExplorer;
export declare function cosmiconfigSync(moduleName: string, options?: Readonly<Partial<OptionsSync>>): PublicExplorerSync;
export { Config, CosmiconfigResult, LoaderResult, Loader, Loaders, LoaderSync, LoadersSync, Transform, TransformSync, SearchStrategy, CommonOptions, Options, OptionsSync, PublicExplorerBase, PublicExplorer, PublicExplorerSync, getDefaultSearchPlaces, getDefaultSearchPlacesSync, globalConfigSearchPlaces, globalConfigSearchPlacesSync, defaultLoaders, defaultLoadersSync, };
//# sourceMappingURL=index.d.ts.map

148
node_modules/cosmiconfig/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,148 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultLoadersSync = exports.defaultLoaders = exports.globalConfigSearchPlacesSync = exports.globalConfigSearchPlaces = exports.getDefaultSearchPlacesSync = exports.getDefaultSearchPlaces = exports.cosmiconfigSync = exports.cosmiconfig = void 0;
const defaults_1 = require("./defaults");
Object.defineProperty(exports, "defaultLoaders", { enumerable: true, get: function () { return defaults_1.defaultLoaders; } });
Object.defineProperty(exports, "defaultLoadersSync", { enumerable: true, get: function () { return defaults_1.defaultLoadersSync; } });
Object.defineProperty(exports, "getDefaultSearchPlaces", { enumerable: true, get: function () { return defaults_1.getDefaultSearchPlaces; } });
Object.defineProperty(exports, "getDefaultSearchPlacesSync", { enumerable: true, get: function () { return defaults_1.getDefaultSearchPlacesSync; } });
Object.defineProperty(exports, "globalConfigSearchPlaces", { enumerable: true, get: function () { return defaults_1.globalConfigSearchPlaces; } });
Object.defineProperty(exports, "globalConfigSearchPlacesSync", { enumerable: true, get: function () { return defaults_1.globalConfigSearchPlacesSync; } });
const Explorer_js_1 = require("./Explorer.js");
const ExplorerSync_js_1 = require("./ExplorerSync.js");
const util_1 = require("./util");
const identity = function identity(x) {
return x;
};
function getUserDefinedOptionsFromMetaConfig() {
const metaExplorer = new ExplorerSync_js_1.ExplorerSync({
moduleName: 'cosmiconfig',
stopDir: process.cwd(),
searchPlaces: defaults_1.metaSearchPlaces,
ignoreEmptySearchPlaces: false,
applyPackagePropertyPathToConfiguration: true,
loaders: defaults_1.defaultLoaders,
transform: identity,
cache: true,
metaConfigFilePath: null,
mergeImportArrays: true,
mergeSearchPlaces: true,
searchStrategy: 'none',
});
const metaConfig = metaExplorer.search();
if (!metaConfig) {
return null;
}
if (metaConfig.config?.loaders) {
throw new Error('Can not specify loaders in meta config file');
}
if (metaConfig.config?.searchStrategy) {
throw new Error('Can not specify searchStrategy in meta config file');
}
const overrideOptions = {
mergeSearchPlaces: true,
...(metaConfig.config ?? {}),
};
return {
config: (0, util_1.removeUndefinedValuesFromObject)(overrideOptions),
filepath: metaConfig.filepath,
};
}
function getResolvedSearchPlaces(moduleName, toolDefinedSearchPlaces, userConfiguredOptions) {
const userConfiguredSearchPlaces = userConfiguredOptions.searchPlaces?.map((path) => path.replace('{name}', moduleName));
if (userConfiguredOptions.mergeSearchPlaces) {
return [...(userConfiguredSearchPlaces ?? []), ...toolDefinedSearchPlaces];
}
return (userConfiguredSearchPlaces ??
/* istanbul ignore next */ toolDefinedSearchPlaces);
}
function mergeOptionsBase(moduleName, defaults, options) {
const userDefinedConfig = getUserDefinedOptionsFromMetaConfig();
if (!userDefinedConfig) {
return {
...defaults,
...(0, util_1.removeUndefinedValuesFromObject)(options),
loaders: {
...defaults.loaders,
...options.loaders,
},
};
}
const userConfiguredOptions = userDefinedConfig.config;
const toolDefinedSearchPlaces = options.searchPlaces ?? defaults.searchPlaces;
return {
...defaults,
...(0, util_1.removeUndefinedValuesFromObject)(options),
metaConfigFilePath: userDefinedConfig.filepath,
...userConfiguredOptions,
searchPlaces: getResolvedSearchPlaces(moduleName, toolDefinedSearchPlaces, userConfiguredOptions),
loaders: {
...defaults.loaders,
...options.loaders,
},
};
}
function validateOptions(options) {
if (options.searchStrategy != null &&
options.searchStrategy !== 'global' &&
options.stopDir) {
throw new Error('Can not supply `stopDir` option with `searchStrategy` other than "global"');
}
}
function mergeOptions(moduleName, options) {
validateOptions(options);
const defaults = {
moduleName,
searchPlaces: (0, defaults_1.getDefaultSearchPlaces)(moduleName),
ignoreEmptySearchPlaces: true,
cache: true,
transform: identity,
loaders: defaults_1.defaultLoaders,
metaConfigFilePath: null,
mergeImportArrays: true,
mergeSearchPlaces: true,
searchStrategy: options.stopDir ? 'global' : 'none',
};
return mergeOptionsBase(moduleName, defaults, options);
}
function mergeOptionsSync(moduleName, options) {
validateOptions(options);
const defaults = {
moduleName,
searchPlaces: (0, defaults_1.getDefaultSearchPlacesSync)(moduleName),
ignoreEmptySearchPlaces: true,
cache: true,
transform: identity,
loaders: defaults_1.defaultLoadersSync,
metaConfigFilePath: null,
mergeImportArrays: true,
mergeSearchPlaces: true,
searchStrategy: options.stopDir ? 'global' : 'none',
};
return mergeOptionsBase(moduleName, defaults, options);
}
function cosmiconfig(moduleName, options = {}) {
const normalizedOptions = mergeOptions(moduleName, options);
const explorer = new Explorer_js_1.Explorer(normalizedOptions);
return {
search: explorer.search.bind(explorer),
load: explorer.load.bind(explorer),
clearLoadCache: explorer.clearLoadCache.bind(explorer),
clearSearchCache: explorer.clearSearchCache.bind(explorer),
clearCaches: explorer.clearCaches.bind(explorer),
};
}
exports.cosmiconfig = cosmiconfig;
function cosmiconfigSync(moduleName, options = {}) {
const normalizedOptions = mergeOptionsSync(moduleName, options);
const explorerSync = new ExplorerSync_js_1.ExplorerSync(normalizedOptions);
return {
search: explorerSync.search.bind(explorerSync),
load: explorerSync.load.bind(explorerSync),
clearLoadCache: explorerSync.clearLoadCache.bind(explorerSync),
clearSearchCache: explorerSync.clearSearchCache.bind(explorerSync),
clearCaches: explorerSync.clearCaches.bind(explorerSync),
};
}
exports.cosmiconfigSync = cosmiconfigSync;
//# sourceMappingURL=index.js.map

8
node_modules/cosmiconfig/dist/loaders.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import { Loader, LoaderSync } from './types.js';
export declare const loadJsSync: LoaderSync;
export declare const loadJs: Loader;
export declare const loadJson: LoaderSync;
export declare const loadYaml: LoaderSync;
export declare const loadTsSync: LoaderSync;
export declare const loadTs: Loader;
//# sourceMappingURL=loaders.d.ts.map

150
node_modules/cosmiconfig/dist/loaders.js generated vendored Normal file
View File

@@ -0,0 +1,150 @@
"use strict";
/* eslint-disable @typescript-eslint/no-require-imports */
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadTs = exports.loadTsSync = exports.loadYaml = exports.loadJson = exports.loadJs = exports.loadJsSync = void 0;
const fs_1 = require("fs");
const promises_1 = require("fs/promises");
const path_1 = __importDefault(require("path"));
const url_1 = require("url");
const crypto_1 = require("crypto");
let importFresh;
const loadJsSync = function loadJsSync(filepath) {
if (importFresh === undefined) {
importFresh = require('import-fresh');
}
return importFresh(filepath);
};
exports.loadJsSync = loadJsSync;
const loadJs = async function loadJs(filepath) {
try {
const { href } = (0, url_1.pathToFileURL)(await (0, promises_1.realpath)(filepath));
return (await import(href)).default;
}
catch (error) {
try {
return (0, exports.loadJsSync)(filepath, '');
}
catch (requireError) {
/* istanbul ignore next -- @preserve */
if (requireError.code === 'ERR_REQUIRE_ESM' ||
(requireError instanceof SyntaxError &&
requireError
.toString()
.includes('Cannot use import statement outside a module'))) {
throw error;
}
throw requireError;
}
}
};
exports.loadJs = loadJs;
let parseJson;
const loadJson = function loadJson(filepath, content) {
if (parseJson === undefined) {
parseJson = require('parse-json');
}
try {
return parseJson(content);
}
catch (error) {
error.message = `JSON Error in ${filepath}:\n${error.message}`;
throw error;
}
};
exports.loadJson = loadJson;
let yaml;
const loadYaml = function loadYaml(filepath, content) {
if (yaml === undefined) {
yaml = require('js-yaml');
}
try {
return yaml.load(content);
}
catch (error) {
error.message = `YAML Error in ${filepath}:\n${error.message}`;
throw error;
}
};
exports.loadYaml = loadYaml;
let typescript;
const loadTsSync = function loadTsSync(filepath, content) {
/* istanbul ignore next -- @preserve */
if (typescript === undefined) {
typescript = require('typescript');
}
const compiledFilepath = `${filepath}.${(0, crypto_1.randomUUID)()}.cjs`;
try {
const config = resolveTsConfig(path_1.default.dirname(filepath)) ?? {};
config.compilerOptions = {
...config.compilerOptions,
module: typescript.ModuleKind.NodeNext,
moduleResolution: typescript.ModuleResolutionKind.NodeNext,
target: typescript.ScriptTarget.ES2022,
noEmit: false,
};
content = typescript.transpileModule(content, config).outputText;
(0, fs_1.writeFileSync)(compiledFilepath, content);
return (0, exports.loadJsSync)(compiledFilepath, content).default;
}
catch (error) {
error.message = `TypeScript Error in ${filepath}:\n${error.message}`;
throw error;
}
finally {
if ((0, fs_1.existsSync)(compiledFilepath)) {
(0, fs_1.rmSync)(compiledFilepath);
}
}
};
exports.loadTsSync = loadTsSync;
const loadTs = async function loadTs(filepath, content) {
if (typescript === undefined) {
typescript = (await import('typescript')).default;
}
const compiledFilepath = `${filepath}.${(0, crypto_1.randomUUID)()}.mjs`;
let transpiledContent;
try {
try {
const config = resolveTsConfig(path_1.default.dirname(filepath)) ?? {};
config.compilerOptions = {
...config.compilerOptions,
module: typescript.ModuleKind.ES2022,
moduleResolution: typescript.ModuleResolutionKind.Bundler,
target: typescript.ScriptTarget.ES2022,
noEmit: false,
};
transpiledContent = typescript.transpileModule(content, config).outputText;
await (0, promises_1.writeFile)(compiledFilepath, transpiledContent);
}
catch (error) {
error.message = `TypeScript Error in ${filepath}:\n${error.message}`;
throw error;
}
// eslint-disable-next-line @typescript-eslint/return-await
return await (0, exports.loadJs)(compiledFilepath, transpiledContent);
}
finally {
if ((0, fs_1.existsSync)(compiledFilepath)) {
await (0, promises_1.rm)(compiledFilepath);
}
}
};
exports.loadTs = loadTs;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function resolveTsConfig(directory) {
const filePath = typescript.findConfigFile(directory, (fileName) => {
return typescript.sys.fileExists(fileName);
});
if (filePath !== undefined) {
const { config, error } = typescript.readConfigFile(filePath, (path) => typescript.sys.readFile(path));
if (error) {
throw new Error(`Error in ${filePath}: ${error.messageText.toString()}`);
}
return config;
}
return;
}
//# sourceMappingURL=loaders.js.map

9
node_modules/cosmiconfig/dist/merge.d.ts generated vendored Normal file
View File

@@ -0,0 +1,9 @@
export declare const hasOwn: (thisArg: any, ...argArray: any[]) => any;
export interface MergeOptions {
mergeArrays: boolean;
}
/**
* Merges multiple objects. Doesn't care about cloning non-primitives, as we load all these objects fresh from a file.
*/
export declare function mergeAll(objects: ReadonlyArray<any>, options: MergeOptions): any;
//# sourceMappingURL=merge.d.ts.map

40
node_modules/cosmiconfig/dist/merge.js generated vendored Normal file
View File

@@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mergeAll = exports.hasOwn = void 0;
/* eslint-disable @typescript-eslint/unbound-method */
exports.hasOwn = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
const objToString = Function.prototype.call.bind(Object.prototype.toString);
/* eslint-enable @typescript-eslint/unbound-method */
function isPlainObject(obj) {
return objToString(obj) === '[object Object]';
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function merge(target, source, options) {
for (const key of Object.keys(source)) {
const newValue = source[key];
if ((0, exports.hasOwn)(target, key)) {
if (Array.isArray(target[key]) && Array.isArray(newValue)) {
if (options.mergeArrays) {
target[key].push(...newValue);
continue;
}
}
else if (isPlainObject(target[key]) && isPlainObject(newValue)) {
target[key] = merge(target[key], newValue, options);
continue;
}
}
target[key] = newValue;
}
return target;
}
/**
* Merges multiple objects. Doesn't care about cloning non-primitives, as we load all these objects fresh from a file.
*/
function mergeAll(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
objects, options) {
return objects.reduce((target, source) => merge(target, source, options), {});
}
exports.mergeAll = mergeAll;
//# sourceMappingURL=merge.js.map

7
node_modules/cosmiconfig/dist/readFile.d.ts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
interface Options {
throwNotFound?: boolean;
}
declare function readFile(filepath: string, options?: Options): Promise<string | null>;
declare function readFileSync(filepath: string, options?: Options): string | null;
export { readFile, readFileSync };
//# sourceMappingURL=readFile.d.ts.map

56
node_modules/cosmiconfig/dist/readFile.js generated vendored Normal file
View File

@@ -0,0 +1,56 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.readFile = readFile;
exports.readFileSync = readFileSync;
var _fs = _interopRequireDefault(require("fs"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
async function fsReadFileAsync(pathname, encoding) {
return new Promise((resolve, reject) => {
_fs.default.readFile(pathname, encoding, (error, contents) => {
if (error) {
reject(error);
return;
}
resolve(contents);
});
});
}
async function readFile(filepath, options = {}) {
const throwNotFound = options.throwNotFound === true;
try {
const content = await fsReadFileAsync(filepath, 'utf8');
return content;
} catch (error) {
if (throwNotFound === false && (error.code === 'ENOENT' || error.code === 'EISDIR')) {
return null;
}
throw error;
}
}
function readFileSync(filepath, options = {}) {
const throwNotFound = options.throwNotFound === true;
try {
const content = _fs.default.readFileSync(filepath, 'utf8');
return content;
} catch (error) {
if (throwNotFound === false && (error.code === 'ENOENT' || error.code === 'EISDIR')) {
return null;
}
throw error;
}
}
//# sourceMappingURL=readFile.js.map

98
node_modules/cosmiconfig/dist/types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,98 @@
/**
* @public
*/
export type Config = any;
/**
* @public
*/
export type CosmiconfigResult = {
config: Config;
filepath: string;
isEmpty?: boolean;
} | null;
/**
* @public
*/
export type LoaderResult = Config | null;
/**
* @public
*/
export type Loader = ((filepath: string, content: string) => Promise<LoaderResult>) | LoaderSync;
/**
* @public
*/
export type LoaderSync = (filepath: string, content: string) => LoaderResult;
/**
* @public
*/
export type Transform = ((CosmiconfigResult: CosmiconfigResult) => Promise<CosmiconfigResult>) | TransformSync;
/**
* @public
*/
export type TransformSync = (CosmiconfigResult: CosmiconfigResult) => CosmiconfigResult;
/**
* @public
*/
export type SearchStrategy = 'none' | 'project' | 'global';
/**
* @public
*/
export interface CommonOptions {
packageProp?: string | Array<string>;
searchPlaces: Array<string>;
ignoreEmptySearchPlaces: boolean;
stopDir?: string;
cache: boolean;
mergeImportArrays: boolean;
mergeSearchPlaces: boolean;
searchStrategy: SearchStrategy;
}
/**
* @public
*/
export interface Options extends CommonOptions {
loaders: Loaders;
transform: Transform;
}
/**
* @public
*/
export interface OptionsSync extends CommonOptions {
loaders: LoadersSync;
transform: TransformSync;
}
/**
* @public
*/
export interface Loaders {
[key: string]: Loader;
}
/**
* @public
*/
export interface LoadersSync {
[key: string]: LoaderSync;
}
/**
* @public
*/
export interface PublicExplorerBase {
clearLoadCache: () => void;
clearSearchCache: () => void;
clearCaches: () => void;
}
/**
* @public
*/
export interface PublicExplorer extends PublicExplorerBase {
search: (searchFrom?: string) => Promise<CosmiconfigResult>;
load: (filepath: string) => Promise<CosmiconfigResult>;
}
/**
* @public
*/
export interface PublicExplorerSync extends PublicExplorerBase {
search: (searchFrom?: string) => CosmiconfigResult;
load: (filepath: string) => CosmiconfigResult;
}
//# sourceMappingURL=types.d.ts.map

3
node_modules/cosmiconfig/dist/types.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=types.js.map

2
node_modules/cosmiconfig/dist/util.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=util.d.ts.map

99
node_modules/cosmiconfig/dist/util.js generated vendored Normal file
View File

@@ -0,0 +1,99 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.isDirectorySync = exports.isDirectory = exports.removeUndefinedValuesFromObject = exports.getPropertyByPath = exports.emplace = void 0;
const fs_1 = __importStar(require("fs"));
/**
* @internal
*/
function emplace(map, key, fn) {
const cached = map.get(key);
if (cached !== undefined) {
return cached;
}
const result = fn();
map.set(key, result);
return result;
}
exports.emplace = emplace;
// Resolves property names or property paths defined with period-delimited
// strings or arrays of strings. Property names that are found on the source
// object are used directly (even if they include a period).
// Nested property names that include periods, within a path, are only
// understood in array paths.
/**
* @internal
*/
function getPropertyByPath(source, path) {
if (typeof path === 'string' &&
Object.prototype.hasOwnProperty.call(source, path)) {
return source[path];
}
const parsedPath = typeof path === 'string' ? path.split('.') : path;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return parsedPath.reduce((previous, key) => {
if (previous === undefined) {
return previous;
}
return previous[key];
}, source);
}
exports.getPropertyByPath = getPropertyByPath;
/** @internal */
function removeUndefinedValuesFromObject(options) {
return Object.fromEntries(Object.entries(options).filter(([, value]) => value !== undefined));
}
exports.removeUndefinedValuesFromObject = removeUndefinedValuesFromObject;
/** @internal */
/* istanbul ignore next -- @preserve */
async function isDirectory(path) {
try {
const stat = await fs_1.promises.stat(path);
return stat.isDirectory();
}
catch (e) {
if (e.code === 'ENOENT') {
return false;
}
throw e;
}
}
exports.isDirectory = isDirectory;
/** @internal */
/* istanbul ignore next -- @preserve */
function isDirectorySync(path) {
try {
const stat = fs_1.default.statSync(path);
return stat.isDirectory();
}
catch (e) {
if (e.code === 'ENOENT') {
return false;
}
throw e;
}
}
exports.isDirectorySync = isDirectorySync;
//# sourceMappingURL=util.js.map