A big commit with a bunch of node modules so I could run puppeteer for Walmart. Added some todos and Headway's templates.
This commit is contained in:
215
Scripts/node_modules/cosmiconfig/dist/index.js
generated
vendored
215
Scripts/node_modules/cosmiconfig/dist/index.js
generated
vendored
@ -1,174 +1,128 @@
|
||||
"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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.cosmiconfigSync = exports.cosmiconfig = exports.defaultLoadersSync = exports.defaultLoaders = exports.metaSearchPlaces = void 0;
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
__exportStar(require("./types.js"), exports);
|
||||
const os_1 = __importDefault(require("os"));
|
||||
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 loaders_js_1 = require("./loaders.js");
|
||||
const util_1 = require("./util");
|
||||
// this needs to be hardcoded, as this is intended for end users, who can't supply options at this point
|
||||
exports.metaSearchPlaces = [
|
||||
'package.json',
|
||||
'.config.json',
|
||||
'.config.yaml',
|
||||
'.config.yml',
|
||||
'.config.js',
|
||||
'.config.ts',
|
||||
'.config.cjs',
|
||||
'.config.mjs',
|
||||
];
|
||||
// do not allow mutation of default loaders. Make sure it is set inside options
|
||||
exports.defaultLoaders = Object.freeze({
|
||||
'.mjs': loaders_js_1.loadJs,
|
||||
'.cjs': loaders_js_1.loadJs,
|
||||
'.js': loaders_js_1.loadJs,
|
||||
'.ts': loaders_js_1.loadTs,
|
||||
'.json': loaders_js_1.loadJson,
|
||||
'.yaml': loaders_js_1.loadYaml,
|
||||
'.yml': loaders_js_1.loadYaml,
|
||||
noExt: loaders_js_1.loadYaml,
|
||||
});
|
||||
exports.defaultLoadersSync = Object.freeze({
|
||||
'.cjs': loaders_js_1.loadJsSync,
|
||||
'.js': loaders_js_1.loadJsSync,
|
||||
'.ts': loaders_js_1.loadTsSync,
|
||||
'.json': loaders_js_1.loadJson,
|
||||
'.yaml': loaders_js_1.loadYaml,
|
||||
'.yml': loaders_js_1.loadYaml,
|
||||
noExt: loaders_js_1.loadYaml,
|
||||
});
|
||||
const identity = function identity(x) {
|
||||
return x;
|
||||
};
|
||||
function getInternalOptions(moduleName, options) {
|
||||
function getUserDefinedOptionsFromMetaConfig() {
|
||||
const metaExplorer = new ExplorerSync_js_1.ExplorerSync({
|
||||
packageProp: 'cosmiconfig',
|
||||
moduleName: 'cosmiconfig',
|
||||
stopDir: process.cwd(),
|
||||
searchPlaces: exports.metaSearchPlaces,
|
||||
searchPlaces: defaults_1.metaSearchPlaces,
|
||||
ignoreEmptySearchPlaces: false,
|
||||
applyPackagePropertyPathToConfiguration: true,
|
||||
loaders: exports.defaultLoaders,
|
||||
loaders: defaults_1.defaultLoaders,
|
||||
transform: identity,
|
||||
cache: true,
|
||||
metaConfigFilePath: null,
|
||||
mergeImportArrays: true,
|
||||
mergeSearchPlaces: true,
|
||||
searchStrategy: 'none',
|
||||
});
|
||||
const metaConfig = metaExplorer.search();
|
||||
if (!metaConfig) {
|
||||
return options;
|
||||
return null;
|
||||
}
|
||||
if (metaConfig.config?.loaders) {
|
||||
throw new Error('Can not specify loaders in meta config file');
|
||||
}
|
||||
const overrideOptions = metaConfig.config ?? {};
|
||||
if (overrideOptions.searchPlaces) {
|
||||
overrideOptions.searchPlaces = overrideOptions.searchPlaces.map((path) => path.replace('{name}', moduleName));
|
||||
if (metaConfig.config?.searchStrategy) {
|
||||
throw new Error('Can not specify searchStrategy in meta config file');
|
||||
}
|
||||
overrideOptions.metaConfigFilePath = metaConfig.filepath;
|
||||
return { ...options, ...(0, util_1.removeUndefinedValuesFromObject)(overrideOptions) };
|
||||
}
|
||||
function normalizeOptions(moduleName, options) {
|
||||
const defaults = {
|
||||
packageProp: moduleName,
|
||||
searchPlaces: [
|
||||
'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`,
|
||||
],
|
||||
ignoreEmptySearchPlaces: true,
|
||||
stopDir: os_1.default.homedir(),
|
||||
cache: true,
|
||||
transform: identity,
|
||||
loaders: exports.defaultLoaders,
|
||||
metaConfigFilePath: null,
|
||||
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 normalizeOptionsSync(moduleName, options) {
|
||||
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 = {
|
||||
packageProp: moduleName,
|
||||
searchPlaces: [
|
||||
'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`,
|
||||
],
|
||||
moduleName,
|
||||
searchPlaces: (0, defaults_1.getDefaultSearchPlaces)(moduleName),
|
||||
ignoreEmptySearchPlaces: true,
|
||||
stopDir: os_1.default.homedir(),
|
||||
cache: true,
|
||||
transform: identity,
|
||||
loaders: exports.defaultLoadersSync,
|
||||
loaders: defaults_1.defaultLoaders,
|
||||
metaConfigFilePath: null,
|
||||
mergeImportArrays: true,
|
||||
mergeSearchPlaces: true,
|
||||
searchStrategy: options.stopDir ? 'global' : 'none',
|
||||
};
|
||||
return {
|
||||
...defaults,
|
||||
...(0, util_1.removeUndefinedValuesFromObject)(options),
|
||||
loaders: {
|
||||
...defaults.loaders,
|
||||
...options.loaders,
|
||||
},
|
||||
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 internalOptions = getInternalOptions(moduleName, options);
|
||||
const normalizedOptions = normalizeOptions(moduleName, internalOptions);
|
||||
const normalizedOptions = mergeOptions(moduleName, options);
|
||||
const explorer = new Explorer_js_1.Explorer(normalizedOptions);
|
||||
return {
|
||||
search: explorer.search.bind(explorer),
|
||||
@ -180,8 +134,7 @@ function cosmiconfig(moduleName, options = {}) {
|
||||
}
|
||||
exports.cosmiconfig = cosmiconfig;
|
||||
function cosmiconfigSync(moduleName, options = {}) {
|
||||
const internalOptions = getInternalOptions(moduleName, options);
|
||||
const normalizedOptions = normalizeOptionsSync(moduleName, internalOptions);
|
||||
const normalizedOptions = mergeOptionsSync(moduleName, options);
|
||||
const explorerSync = new ExplorerSync_js_1.ExplorerSync(normalizedOptions);
|
||||
return {
|
||||
search: explorerSync.search.bind(explorerSync),
|
||||
|
||||
Reference in New Issue
Block a user