@oclif/core
Advanced tools
Comparing version 4.0.0-beta.2 to 4.0.0-beta.3
@@ -37,2 +37,3 @@ "use strict"; | ||
const util_1 = require("./help/util"); | ||
const logger_1 = require("./logger"); | ||
const Parser = __importStar(require("./parser")); | ||
@@ -127,3 +128,3 @@ const aggregate_flags_1 = require("./util/aggregate-flags"); | ||
try { | ||
this.debug = require('debug')(this.id ? `${this.config.bin}:${this.id}` : this.config.bin); | ||
this.debug = (0, logger_1.makeDebug)(this.id ? `${this.config.bin}:${this.id}` : this.config.bin); | ||
} | ||
@@ -184,18 +185,5 @@ catch { | ||
} | ||
async finally(_) { | ||
try { | ||
const { config } = Errors; | ||
if (config.errorLogger) | ||
await config.errorLogger.flush(); | ||
} | ||
catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
async finally(_) { } | ||
async init() { | ||
this.debug('init version: %s argv: %o', this.ctor._base, this.argv); | ||
if (this.config.debug) | ||
Errors.config.debug = true; | ||
if (this.config.errlog) | ||
Errors.config.errlog = this.config.errlog; | ||
const g = global; | ||
@@ -202,0 +190,0 @@ g['http-call'] = g['http-call'] || {}; |
@@ -16,5 +16,3 @@ import { Command } from '../command'; | ||
dataDir: string; | ||
debug: number; | ||
dirname: string; | ||
errlog: string; | ||
flexibleTaxonomy: boolean; | ||
@@ -118,10 +116,5 @@ home: string; | ||
scopedEnvVarTrue(k: string): boolean; | ||
protected warn(err: { | ||
detail: string; | ||
name: string; | ||
} | Error | string, scope?: string): void; | ||
protected windowsHome(): string | undefined; | ||
protected windowsHomedriveHome(): string | undefined; | ||
protected windowsUserprofileHome(): string | undefined; | ||
protected _debug(): number; | ||
protected _shell(): string; | ||
@@ -164,2 +157,4 @@ private buildS3Config; | ||
private loadTopics; | ||
private maybeAdjustDebugSetting; | ||
private warn; | ||
} |
@@ -38,2 +38,3 @@ "use strict"; | ||
const util_1 = require("../help/util"); | ||
const logger_1 = require("../logger"); | ||
const module_loader_1 = require("../module-loader"); | ||
@@ -50,7 +51,15 @@ const performance_1 = require("../performance"); | ||
const util_3 = require("./util"); | ||
// eslint-disable-next-line new-cap | ||
const debug = (0, util_3.Debug)(); | ||
const debug = (0, util_3.makeDebug)(); | ||
const _pjson = cache_1.default.getInstance().get('@oclif/core'); | ||
const BASE = `${_pjson.name}@${_pjson.version}`; | ||
const ROOT_ONLY_HOOKS = new Set(['preparse']); | ||
function displayWarnings() { | ||
if (process.listenerCount('warning') > 1) | ||
return; | ||
process.on('warning', (warning) => { | ||
console.error(warning.stack); | ||
if (warning.detail) | ||
console.error(warning.detail); | ||
}); | ||
} | ||
function channelFromVersion(version) { | ||
@@ -99,5 +108,3 @@ const m = version.match(/[^-]+(?:-([^.]+))?/); | ||
dataDir; | ||
debug = 0; | ||
dirname; | ||
errlog; | ||
flexibleTaxonomy; | ||
@@ -135,2 +142,3 @@ home; | ||
static async load(opts = module.filename || __dirname) { | ||
(0, logger_1.setLogger)(opts); | ||
// Handle the case when a file URL string is passed in such as 'import.meta.url'; covert to file path. | ||
@@ -270,2 +278,5 @@ if (typeof opts === 'string' && opts.startsWith('file://')) { | ||
(settings_1.settings.performanceEnabled === undefined ? this.options.enablePerf : settings_1.settings.performanceEnabled) ?? false; | ||
if (settings_1.settings.debug) | ||
displayWarnings(); | ||
(0, logger_1.setLogger)(this.options); | ||
const marker = performance_1.Performance.mark(performance_1.OCLIF_MARKER_OWNER, 'config.load'); | ||
@@ -303,3 +314,2 @@ this.pluginLoader = new plugin_loader_1.default({ plugins: this.options.plugins, root: this.options.root }); | ||
this.shell = this._shell(); | ||
this.debug = this._debug(); | ||
this.home = process.env.HOME || (this.windows && this.windowsHome()) || (0, os_1.getHomeDir)() || (0, node_os_1.tmpdir)(); | ||
@@ -309,3 +319,2 @@ this.cacheDir = this.scopedEnvVar('CACHE_DIR') || this.macosCacheDir() || this.dir('cache'); | ||
this.dataDir = this.scopedEnvVar('DATA_DIR') || this.dir('data'); | ||
this.errlog = (0, node_path_1.join)(this.cacheDir, 'error.log'); | ||
this.binPath = this.scopedEnvVar('BINPATH'); | ||
@@ -323,2 +332,3 @@ this.npmRegistry = this.scopedEnvVar('NPM_REGISTRY') || this.pjson.oclif.npmRegistry; | ||
this.pjson.oclif.commands?.target)); | ||
this.maybeAdjustDebugSetting(); | ||
await this.loadPluginsAndCommands(); | ||
@@ -458,3 +468,3 @@ debug('config done'); | ||
const promises = plugins.map(async (p) => { | ||
const debug = require('debug')([this.bin, p.name, 'hooks', event].join(':')); | ||
const debug = (0, logger_1.makeDebug)([p.name, 'hooks', event].join(':')); | ||
const context = { | ||
@@ -569,36 +579,2 @@ config: this, | ||
} | ||
warn(err, scope) { | ||
if (this.warned) | ||
return; | ||
if (typeof err === 'string') { | ||
process.emitWarning(err); | ||
return; | ||
} | ||
if (err instanceof Error) { | ||
const modifiedErr = err; | ||
modifiedErr.name = `${err.name} Plugin: ${this.name}`; | ||
modifiedErr.detail = (0, util_2.compact)([ | ||
err.detail, | ||
`module: ${this._base}`, | ||
scope && `task: ${scope}`, | ||
`plugin: ${this.name}`, | ||
`root: ${this.root}`, | ||
'See more details with DEBUG=*', | ||
]).join('\n'); | ||
process.emitWarning(err); | ||
return; | ||
} | ||
// err is an object | ||
process.emitWarning('Config.warn expected either a string or Error, but instead received an object'); | ||
err.name = `${err.name} Plugin: ${this.name}`; | ||
err.detail = (0, util_2.compact)([ | ||
err.detail, | ||
`module: ${this._base}`, | ||
scope && `task: ${scope}`, | ||
`plugin: ${this.name}`, | ||
`root: ${this.root}`, | ||
'See more details with DEBUG=*', | ||
]).join('\n'); | ||
process.emitWarning(JSON.stringify(err)); | ||
} | ||
windowsHome() { | ||
@@ -613,13 +589,2 @@ return this.windowsHomedriveHome() || this.windowsUserprofileHome(); | ||
} | ||
_debug() { | ||
if (this.scopedEnvVarTrue('DEBUG')) | ||
return 1; | ||
try { | ||
const { enabled } = require('debug')(this.bin); | ||
if (enabled) | ||
return 1; | ||
} | ||
catch { } | ||
return 0; | ||
} | ||
_shell() { | ||
@@ -842,3 +807,43 @@ let shellPath; | ||
} | ||
maybeAdjustDebugSetting() { | ||
if (this.scopedEnvVarTrue('DEBUG')) { | ||
settings_1.settings.debug = true; | ||
displayWarnings(); | ||
} | ||
} | ||
warn(err, scope) { | ||
if (this.warned) | ||
return; | ||
if (typeof err === 'string') { | ||
process.emitWarning(err); | ||
return; | ||
} | ||
if (err instanceof Error) { | ||
const modifiedErr = err; | ||
modifiedErr.name = `${err.name} Plugin: ${this.name}`; | ||
modifiedErr.detail = (0, util_2.compact)([ | ||
err.detail, | ||
`module: ${this._base}`, | ||
scope && `task: ${scope}`, | ||
`plugin: ${this.name}`, | ||
`root: ${this.root}`, | ||
'See more details with DEBUG=*', | ||
]).join('\n'); | ||
process.emitWarning(err); | ||
return; | ||
} | ||
// err is an object | ||
process.emitWarning('Config.warn expected either a string or Error, but instead received an object'); | ||
err.name = `${err.name} Plugin: ${this.name}`; | ||
err.detail = (0, util_2.compact)([ | ||
err.detail, | ||
`module: ${this._base}`, | ||
scope && `task: ${scope}`, | ||
`plugin: ${this.name}`, | ||
`root: ${this.root}`, | ||
'See more details with DEBUG=*', | ||
]).join('\n'); | ||
process.emitWarning(JSON.stringify(err)); | ||
} | ||
} | ||
exports.Config = Config; |
@@ -33,4 +33,3 @@ "use strict"; | ||
const util_2 = require("./util"); | ||
// eslint-disable-next-line new-cap | ||
const debug = (0, util_2.Debug)(); | ||
const debug = (0, util_2.makeDebug)(); | ||
function findMatchingDependencies(dependencies, patterns) { | ||
@@ -37,0 +36,0 @@ return Object.keys(dependencies).filter((p) => patterns.some((w) => (0, minimatch_1.minimatch)(p, w))); |
@@ -107,4 +107,3 @@ "use strict"; | ||
_base = `${_pjson.name}@${_pjson.version}`; | ||
// eslint-disable-next-line new-cap | ||
_debug = (0, util_2.Debug)(); | ||
_debug = (0, util_2.makeDebug)(); | ||
commandCache; | ||
@@ -194,4 +193,3 @@ commandDiscoveryOpts; | ||
throw new errors_1.CLIError(`no name in package.json (${root})`); | ||
// eslint-disable-next-line new-cap | ||
this._debug = (0, util_2.Debug)(this.name); | ||
this._debug = (0, util_2.makeDebug)(this.name); | ||
this.version = this.pjson.version; | ||
@@ -198,0 +196,0 @@ if (this.pjson.oclif) { |
@@ -16,4 +16,3 @@ "use strict"; | ||
const util_2 = require("./util"); | ||
// eslint-disable-next-line new-cap | ||
const debug = (0, util_2.Debug)('ts-path'); | ||
const debug = (0, util_2.makeDebug)('ts-path'); | ||
exports.TS_CONFIGS = {}; | ||
@@ -20,0 +19,0 @@ const REGISTERED = new Set(); |
@@ -1,2 +0,2 @@ | ||
export declare function Debug(...scope: string[]): (..._: any) => void; | ||
export declare function makeDebug(...scope: string[]): (..._: any) => void; | ||
export declare function getPermutations(arr: string[]): Array<string[]>; | ||
@@ -3,0 +3,0 @@ export declare function getCommandIdPermutations(commandId: string): string[]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.collectUsableIds = exports.getCommandIdPermutations = exports.getPermutations = exports.Debug = void 0; | ||
const debug = require('debug'); | ||
function displayWarnings() { | ||
if (process.listenerCount('warning') > 1) | ||
return; | ||
process.on('warning', (warning) => { | ||
console.error(warning.stack); | ||
if (warning.detail) | ||
console.error(warning.detail); | ||
}); | ||
exports.collectUsableIds = exports.getCommandIdPermutations = exports.getPermutations = exports.makeDebug = void 0; | ||
const logger_1 = require("../logger"); | ||
function makeDebug(...scope) { | ||
return (formatter, ...args) => (0, logger_1.getLogger)(['config', ...scope].join(':')).debug(formatter, ...args); | ||
} | ||
function Debug(...scope) { | ||
if (!debug) | ||
return (..._) => { | ||
// noop | ||
}; | ||
const d = debug(['config', ...scope].join(':')); | ||
if (d.enabled) | ||
displayWarnings(); | ||
return (...args) => d(...args); | ||
} | ||
exports.Debug = Debug; | ||
exports.makeDebug = makeDebug; | ||
// Adapted from https://github.com/angus-c/just/blob/master/packages/array-permutations/index.js | ||
@@ -26,0 +10,0 @@ function getPermutations(arr) { |
@@ -27,4 +27,4 @@ "use strict"; | ||
exports.error = void 0; | ||
const logger_1 = require("../logger"); | ||
const write_1 = require("../ux/write"); | ||
const config_1 = require("./config"); | ||
const cli_1 = require("./errors/cli"); | ||
@@ -48,4 +48,4 @@ const pretty_print_1 = __importStar(require("./errors/pretty-print")); | ||
(0, write_1.stderr)(message); | ||
if (config_1.config.errorLogger) | ||
config_1.config.errorLogger.log(err?.stack ?? ''); | ||
if (err?.stack) | ||
(0, logger_1.getLogger)().error(err.stack); | ||
} | ||
@@ -52,0 +52,0 @@ else |
@@ -13,3 +13,3 @@ "use strict"; | ||
const screen_1 = require("../../screen"); | ||
const config_1 = require("../config"); | ||
const settings_1 = require("../../settings"); | ||
/** | ||
@@ -52,3 +52,3 @@ * properties specific to internal oclif error handling | ||
render() { | ||
if (config_1.config.debug) { | ||
if (settings_1.settings.debug) { | ||
return this.stack; | ||
@@ -55,0 +55,0 @@ } |
@@ -10,3 +10,3 @@ "use strict"; | ||
const screen_1 = require("../../screen"); | ||
const config_1 = require("../config"); | ||
const settings_1 = require("../../settings"); | ||
function applyPrettyPrintOptions(error, options) { | ||
@@ -34,3 +34,3 @@ const prettyErrorKeys = ['message', 'code', 'ref', 'suggestions']; | ||
function prettyPrint(error) { | ||
if (config_1.config.debug) { | ||
if (settings_1.settings.debug) { | ||
return error.stack; | ||
@@ -37,0 +37,0 @@ } |
@@ -10,3 +10,3 @@ "use strict"; | ||
const index_1 = require("../help/index"); | ||
const config_1 = require("./config"); | ||
const logger_1 = require("../logger"); | ||
const cli_1 = require("./errors/cli"); | ||
@@ -50,13 +50,6 @@ const exit_1 = require("./errors/exit"); | ||
const exitCode = err.oclif?.exit ?? 1; | ||
if (config_1.config.errorLogger && err.code !== 'EEXIT') { | ||
if (stack) { | ||
config_1.config.errorLogger.log(stack); | ||
} | ||
await config_1.config.errorLogger | ||
.flush() | ||
.then(() => exports.Exit.exit(exitCode)) | ||
.catch(console.error); | ||
if (err.code !== 'EEXIT' && stack) { | ||
(0, logger_1.getLogger)().error(stack); | ||
} | ||
else | ||
exports.Exit.exit(exitCode); | ||
exports.Exit.exit(exitCode); | ||
} | ||
@@ -63,0 +56,0 @@ catch (error) { |
export { PrettyPrintableError } from '../interfaces'; | ||
export { config } from './config'; | ||
export { error } from './error'; | ||
@@ -9,3 +8,2 @@ export { CLIError } from './errors/cli'; | ||
export { handle } from './handle'; | ||
export { Logger } from './logger'; | ||
export { warn } from './warn'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.warn = exports.Logger = exports.handle = exports.exit = exports.ModuleLoadError = exports.ExitError = exports.CLIError = exports.error = exports.config = void 0; | ||
var config_1 = require("./config"); | ||
Object.defineProperty(exports, "config", { enumerable: true, get: function () { return config_1.config; } }); | ||
exports.warn = exports.handle = exports.exit = exports.ModuleLoadError = exports.ExitError = exports.CLIError = exports.error = void 0; | ||
var error_1 = require("./error"); | ||
@@ -18,5 +16,3 @@ Object.defineProperty(exports, "error", { enumerable: true, get: function () { return error_1.error; } }); | ||
Object.defineProperty(exports, "handle", { enumerable: true, get: function () { return handle_1.handle; } }); | ||
var logger_1 = require("./logger"); | ||
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } }); | ||
var warn_1 = require("./warn"); | ||
Object.defineProperty(exports, "warn", { enumerable: true, get: function () { return warn_1.warn; } }); |
@@ -7,4 +7,4 @@ "use strict"; | ||
exports.warn = void 0; | ||
const logger_1 = require("../logger"); | ||
const write_1 = require("../ux/write"); | ||
const config_1 = require("./config"); | ||
const cli_1 = require("./errors/cli"); | ||
@@ -37,6 +37,6 @@ const pretty_print_1 = __importDefault(require("./errors/pretty-print")); | ||
(0, write_1.stderr)(message); | ||
if (config_1.config.errorLogger) | ||
config_1.config.errorLogger.log(err?.stack ?? ''); | ||
if (err?.stack) | ||
(0, logger_1.getLogger)().error(err.stack); | ||
} | ||
exports.warn = warn; | ||
exports.default = warn; |
@@ -13,2 +13,3 @@ export * as Args from './args'; | ||
export { Hook } from './interfaces/hooks'; | ||
export { getLogger } from './logger'; | ||
export { run } from './main'; | ||
@@ -15,0 +16,0 @@ export * as ModuleLoader from './module-loader'; |
@@ -26,3 +26,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ux = exports.toStandardizedId = exports.toConfiguredId = exports.settings = exports.Performance = exports.Parser = exports.ModuleLoader = exports.run = exports.Interfaces = exports.loadHelpClass = exports.HelpBase = exports.Help = exports.CommandHelp = exports.flush = exports.Flags = exports.execute = exports.handle = exports.Errors = exports.Plugin = exports.Config = exports.Command = exports.Args = void 0; | ||
exports.ux = exports.toStandardizedId = exports.toConfiguredId = exports.settings = exports.Performance = exports.Parser = exports.ModuleLoader = exports.run = exports.getLogger = exports.Interfaces = exports.loadHelpClass = exports.HelpBase = exports.Help = exports.CommandHelp = exports.flush = exports.Flags = exports.execute = exports.handle = exports.Errors = exports.Plugin = exports.Config = exports.Command = exports.Args = void 0; | ||
function checkCWD() { | ||
@@ -59,2 +59,4 @@ try { | ||
exports.Interfaces = __importStar(require("./interfaces")); | ||
var logger_1 = require("./logger"); | ||
Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return logger_1.getLogger; } }); | ||
var main_1 = require("./main"); | ||
@@ -61,0 +63,0 @@ Object.defineProperty(exports, "run", { enumerable: true, get: function () { return main_1.run; } }); |
@@ -61,17 +61,5 @@ /// <reference types="node" /> | ||
/** | ||
* debugging level | ||
* | ||
* set by ${BIN}_DEBUG or DEBUG=$BIN | ||
*/ | ||
readonly debug: number; | ||
/** | ||
* base dirname to use in cacheDir/configDir/dataDir | ||
*/ | ||
readonly dirname: string; | ||
/** | ||
* points to a file that should be appended to for error logs | ||
* | ||
* example: ~/Library/Caches/mycli/error.log | ||
*/ | ||
readonly errlog: string; | ||
findCommand(id: string, opts: { | ||
@@ -78,0 +66,0 @@ must: true; |
@@ -8,2 +8,3 @@ export type { AlphabetLowercase, AlphabetUppercase } from './alphabet'; | ||
export type { Hook, Hooks } from './hooks'; | ||
export type { Logger } from './logger'; | ||
export type { Manifest } from './manifest'; | ||
@@ -10,0 +11,0 @@ export type { Arg, BooleanFlag, CustomOptions, Deprecation, Flag, FlagDefinition, OptionFlag } from './parser'; |
import { Command } from '../command'; | ||
import { Logger } from './logger'; | ||
import { HookOptions, PJSON } from './pjson'; | ||
@@ -24,2 +25,3 @@ import { Topic } from './topic'; | ||
jitPlugins?: boolean; | ||
logger?: Logger; | ||
pjson?: PJSON.Plugin; | ||
@@ -26,0 +28,0 @@ pluginAdditions?: { |
@@ -11,6 +11,6 @@ "use strict"; | ||
const help_1 = require("./help"); | ||
const logger_1 = require("./logger"); | ||
const performance_1 = require("./performance"); | ||
const symbols_1 = require("./symbols"); | ||
const ux_1 = __importDefault(require("./ux")); | ||
const debug = require('debug')('oclif:main'); | ||
const helpAddition = (argv, config) => { | ||
@@ -52,2 +52,4 @@ if (argv.length === 0 && !config.isSingleCommandCLI) | ||
}; | ||
(0, logger_1.setLogger)(options); | ||
const { debug } = (0, logger_1.getLogger)('main'); | ||
debug(`process.execPath: ${process.execPath}`); | ||
@@ -54,0 +56,0 @@ debug(`process.execArgv: ${process.execArgv}`); |
@@ -10,2 +10,3 @@ "use strict"; | ||
const cache_1 = __importDefault(require("../cache")); | ||
const logger_1 = require("../logger"); | ||
const util_1 = require("../util/util"); | ||
@@ -17,3 +18,3 @@ const errors_1 = require("./errors"); | ||
process.env.CLI_FLAGS_DEBUG === '1' | ||
? require('debug')('../parser') | ||
? (0, logger_1.makeDebug)('parser') | ||
: () => { | ||
@@ -20,0 +21,0 @@ // noop |
@@ -5,2 +5,3 @@ "use strict"; | ||
const node_perf_hooks_1 = require("node:perf_hooks"); | ||
const logger_1 = require("./logger"); | ||
const settings_1 = require("./settings"); | ||
@@ -147,3 +148,3 @@ exports.OCLIF_MARKER_OWNER = '@oclif/core'; | ||
return; | ||
const oclifDebug = require('debug')('oclif-perf'); | ||
const oclifDebug = (0, logger_1.makeDebug)('perf'); | ||
const processUpTime = (process.uptime() * 1000).toFixed(4); | ||
@@ -181,3 +182,3 @@ oclifDebug('Process Uptime: %sms', processUpTime); | ||
} | ||
const nonCoreDebug = require('debug')('non-oclif-perf'); | ||
const nonCoreDebug = (0, logger_1.makeDebug)('non-oclif-perf'); | ||
const nonCorePerf = Performance.results; | ||
@@ -184,0 +185,0 @@ if (nonCorePerf.size > 0) { |
@@ -17,8 +17,2 @@ export type Settings = { | ||
/** | ||
* The path to the error.log file. | ||
* | ||
* NOTE: This is read-only and setting it will have no effect. | ||
*/ | ||
errlog?: string; | ||
/** | ||
* Enable performance tracking. Resulting data is available in the `perf` property of the `Config` class. | ||
@@ -25,0 +19,0 @@ * This will be overridden by the `enablePerf` property passed into Config constructor. |
@@ -0,1 +1,2 @@ | ||
export declare function debug(...scope: string[]): (..._: any) => void; | ||
/** | ||
@@ -2,0 +3,0 @@ * Returns the root directory of the plugin. |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.findRoot = void 0; | ||
const debug_1 = __importDefault(require("debug")); | ||
exports.findRoot = exports.debug = void 0; | ||
const node_path_1 = require("node:path"); | ||
const logger_1 = require("../logger"); | ||
const fs_1 = require("./fs"); | ||
const debug = (0, debug_1.default)('find-root'); | ||
function debug(...scope) { | ||
return (formatter, ...args) => (0, logger_1.getLogger)(['find-root', ...scope].join(':')).debug(formatter, ...args); | ||
} | ||
exports.debug = debug; | ||
// essentially just "cd .." | ||
@@ -28,7 +28,7 @@ function* up(from) { | ||
// system until we find the directory that matches the plugin name. | ||
debug.extend(name ?? 'root-plugin')(`Finding root starting at ${root}`); | ||
debug(name ?? 'root-plugin')(`Finding root starting at ${root}`); | ||
if (name) { | ||
for (const next of up(root)) { | ||
if (next.endsWith((0, node_path_1.basename)(name))) { | ||
debug.extend(name)('Found root based on plugin name!'); | ||
debug(name)('Found root based on plugin name!'); | ||
return next; | ||
@@ -48,5 +48,5 @@ } | ||
const cur = (0, node_path_1.join)(next, 'package.json'); | ||
debug.extend(name ?? 'root-plugin')(`Checking ${cur}`); | ||
debug(name ?? 'root-plugin')(`Checking ${cur}`); | ||
if (await (0, fs_1.safeReadJson)(cur)) { | ||
debug.extend(name ?? 'root-plugin')('Found root by traversing up from starting point!'); | ||
debug(name ?? 'root-plugin')('Found root by traversing up from starting point!'); | ||
return (0, node_path_1.dirname)(cur); | ||
@@ -65,3 +65,3 @@ } | ||
async function findRootLegacy(name, root) { | ||
debug.extend(name ?? 'root-plugin')('Finding root using legacy method'); | ||
debug(name ?? 'root-plugin')('Finding root using legacy method'); | ||
for (const next of up(root)) { | ||
@@ -112,3 +112,3 @@ let cur; | ||
return; | ||
debug.extend(name)('Finding root for using pnp method'); | ||
debug(name)('Finding root for using pnp method'); | ||
const seen = new Set(); | ||
@@ -165,10 +165,10 @@ const traverseDependencyTree = (locator, parentPkg) => { | ||
if (name) { | ||
debug.extend(name)(`Finding root using ${root}`); | ||
debug(name)(`Finding root using ${root}`); | ||
let pkgPath; | ||
try { | ||
pkgPath = require.resolve(name, { paths: [root] }); | ||
debug.extend(name)(`Found starting point with require.resolve`); | ||
debug(name)(`Found starting point with require.resolve`); | ||
} | ||
catch { | ||
debug.extend(name)(`require.resolve could not find plugin starting point`); | ||
debug(name)(`require.resolve could not find plugin starting point`); | ||
} | ||
@@ -178,3 +178,3 @@ if (pkgPath) { | ||
if (found) { | ||
debug.extend(name)(`Found root at ${found}`); | ||
debug(name)(`Found root at ${found}`); | ||
return found; | ||
@@ -184,10 +184,10 @@ } | ||
const found = process.versions.pnp ? findPnpRoot(name, root) : await findRootLegacy(name, root); | ||
debug.extend(name)(found ? `Found root at ${found}` : 'No root found!'); | ||
debug(name)(found ? `Found root at ${found}` : 'No root found!'); | ||
return found; | ||
} | ||
debug.extend('root-plugin')(`Finding root plugin using ${root}`); | ||
debug('root-plugin')(`Finding root plugin using ${root}`); | ||
const found = await findPluginRoot(root); | ||
debug.extend('root-plugin')(found ? `Found root at ${found}` : 'No root found!'); | ||
debug('root-plugin')(found ? `Found root at ${found}` : 'No root found!'); | ||
return found; | ||
} | ||
exports.findRoot = findRoot; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.readTSConfig = void 0; | ||
const debug_1 = __importDefault(require("debug")); | ||
const promises_1 = require("node:fs/promises"); | ||
const node_path_1 = require("node:path"); | ||
const warn_1 = require("../errors/warn"); | ||
const logger_1 = require("../logger"); | ||
const util_1 = require("./util"); | ||
const debug = (0, debug_1.default)('read-tsconfig'); | ||
const debug = (0, logger_1.makeDebug)('read-tsconfig'); | ||
function resolve(root, name) { | ||
@@ -14,0 +11,0 @@ try { |
{ | ||
"name": "@oclif/core", | ||
"description": "base library for oclif CLIs", | ||
"version": "4.0.0-beta.2", | ||
"version": "4.0.0-beta.3", | ||
"author": "Salesforce", | ||
@@ -20,2 +20,3 @@ "bugs": "https://github.com/oclif/core/issues", | ||
"string-width": "^4.2.3", | ||
"supports-color": "^9.4.0", | ||
"widest-line": "^3.1.0", | ||
@@ -22,0 +23,0 @@ "wordwrap": "^1.0.0", |
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
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
390637
16
9834
+ Addedsupports-color@^9.4.0
+ Addedsupports-color@9.4.0(transitive)