New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@oclif/core

Package Overview
Dependencies
Maintainers
2
Versions
418
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oclif/core - npm Package Compare versions

Comparing version 3.24.0 to 3.25.0

lib/errors/error.d.ts

3

lib/cache.d.ts

@@ -0,1 +1,2 @@

import { Config } from './config/config';
import { PJSON, Plugin } from './interfaces';

@@ -8,2 +9,3 @@ type OclifCoreInfo = {

rootPlugin: Plugin;
config: Config;
exitCodes: PJSON.Plugin['oclif']['exitCodes'];

@@ -20,2 +22,3 @@ '@oclif/core': OclifCoreInfo;

static getInstance(): Cache;
get(key: 'config'): Config | undefined;
get(key: '@oclif/core'): OclifCoreInfo;

@@ -22,0 +25,0 @@ get(key: 'rootPlugin'): Plugin | undefined;

12

lib/config/ts-path.js

@@ -9,3 +9,3 @@ "use strict";

const cache_1 = __importDefault(require("../cache"));
const errors_1 = require("../errors");
const warn_1 = require("../errors/warn");
const settings_1 = require("../settings");

@@ -79,3 +79,3 @@ const fs_1 = require("../util/fs");

debug(`Could not parse tsconfig.json. Skipping typescript path lookup for ${root}.`);
(0, errors_1.memoizedWarn)(`Could not parse tsconfig.json for ${root}. Falling back to compiled source.`);
(0, warn_1.memoizedWarn)(`Could not parse tsconfig.json for ${root}. Falling back to compiled source.`);
}

@@ -95,3 +95,3 @@ }

debug(`Could not find ts-node at ${tsNodePath}. Skipping ts-node registration for ${root}.`);
(0, errors_1.memoizedWarn)(`Could not find ts-node at ${tsNodePath}. Please ensure that ts-node is a devDependency. Falling back to compiled source.`);
(0, warn_1.memoizedWarn)(`Could not find ts-node at ${tsNodePath}. Please ensure that ts-node is a devDependency. Falling back to compiled source.`);
return;

@@ -213,3 +213,3 @@ }

if (!(0, util_1.isProd)())
(0, errors_1.memoizedWarn)(`Could not find source for ${orig} based on tsconfig. Defaulting to compiled source.`);
(0, warn_1.memoizedWarn)(`Could not find source for ${orig} based on tsconfig. Defaulting to compiled source.`);
return orig;

@@ -237,3 +237,3 @@ }

if (plugin?.type === 'link')
(0, errors_1.memoizedWarn)(`${plugin?.name} is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used instead.`);
(0, warn_1.memoizedWarn)(`${plugin?.name} is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used instead.`);
return orig;

@@ -243,3 +243,3 @@ }

debug(`Skipping typescript path lookup for ${root} because ts-node is run in node version ${process.version}"`);
(0, errors_1.memoizedWarn)(`ts-node executable cannot transpile ESM in Node 20. Existing compiled source will be used instead. See https://github.com/oclif/core/issues/817.`);
(0, warn_1.memoizedWarn)(`ts-node executable cannot transpile ESM in Node 20. Existing compiled source will be used instead. See https://github.com/oclif/core/issues/817.`);
return orig;

@@ -246,0 +246,0 @@ }

@@ -11,2 +11,3 @@ import { OclifError, PrettyPrintableError } from '../../interfaces/errors';

oclif: OclifError['oclif'];
skipOclifErrorHandling?: boolean;
suggestions?: string[];

@@ -13,0 +14,0 @@ constructor(error: Error | string, options?: {

@@ -29,2 +29,3 @@ "use strict";

oclif = {};
skipOclifErrorHandling;
suggestions;

@@ -31,0 +32,0 @@ constructor(error, options = {}) {

import { OclifError, PrettyPrintableError } from '../interfaces';
import { CLIParseError } from '../parser/errors';
import { CLIError } from './errors/cli';
/**

@@ -10,6 +12,4 @@ * This is an odd abstraction for process.exit, but it allows us to stub it in tests.

};
type ErrorToHandle = Error & Partial<PrettyPrintableError> & Partial<OclifError> & {
skipOclifErrorHandling?: boolean;
};
type ErrorToHandle = Error & Partial<PrettyPrintableError> & Partial<OclifError> & Partial<CLIError> & Partial<CLIParseError>;
export declare function handle(err: ErrorToHandle): Promise<void>;
export {};

@@ -8,2 +8,4 @@ "use strict";

const clean_stack_1 = __importDefault(require("clean-stack"));
const cache_1 = __importDefault(require("../cache"));
const index_1 = require("../help/index");
const config_1 = require("./config");

@@ -35,2 +37,13 @@ const cli_1 = require("./errors/cli");

console.error(pretty ?? stack);
const config = cache_1.default.getInstance().get('config');
if (err.showHelp && err.parse?.input?.argv && config) {
const options = {
...(config.pjson.oclif.helpOptions ?? config.pjson.helpOptions),
sections: ['flags', 'usage', 'arguments'],
sendToStderr: true,
};
const help = new index_1.Help(config, options);
console.error();
await help.showHelp(process.argv.slice(2));
}
}

@@ -37,0 +50,0 @@ const exitCode = err.oclif?.exit ?? 1;

@@ -1,4 +0,4 @@

import { PrettyPrintableError } from '../interfaces';
export { PrettyPrintableError } from '../interfaces';
export { config } from './config';
export { error } from './error';
export { CLIError } from './errors/cli';

@@ -8,11 +8,4 @@ export { ExitError } from './errors/exit';

export { handle } from './handle';
export { Logger } from './logger';
export declare function exit(code?: number): never;
export declare function error(input: Error | string, options: {
exit: false;
} & PrettyPrintableError): void;
export declare function error(input: Error | string, options?: {
exit?: number;
} & PrettyPrintableError): never;
export declare function warn(input: Error | string): void;
export declare function memoizedWarn(input: Error | string): void;
export { Logger } from './logger';
export { warn } from './warn';
"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;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Logger = exports.memoizedWarn = exports.warn = exports.error = exports.exit = exports.handle = exports.ModuleLoadError = exports.ExitError = exports.CLIError = exports.config = void 0;
const write_1 = __importDefault(require("../cli-ux/write"));
const config_1 = require("./config");
const cli_1 = require("./errors/cli");
exports.warn = exports.exit = exports.Logger = exports.handle = exports.ModuleLoadError = exports.ExitError = exports.CLIError = exports.error = exports.config = void 0;
const exit_1 = require("./errors/exit");
const pretty_print_1 = __importStar(require("./errors/pretty-print"));
var config_2 = require("./config");
Object.defineProperty(exports, "config", { enumerable: true, get: function () { return config_2.config; } });
var cli_2 = require("./errors/cli");
Object.defineProperty(exports, "CLIError", { enumerable: true, get: function () { return cli_2.CLIError; } });
var config_1 = require("./config");
Object.defineProperty(exports, "config", { enumerable: true, get: function () { return config_1.config; } });
var error_1 = require("./error");
Object.defineProperty(exports, "error", { enumerable: true, get: function () { return error_1.error; } });
var cli_1 = require("./errors/cli");
Object.defineProperty(exports, "CLIError", { enumerable: true, get: function () { return cli_1.CLIError; } });
var exit_2 = require("./errors/exit");

@@ -45,2 +17,4 @@ Object.defineProperty(exports, "ExitError", { enumerable: true, get: function () { return exit_2.ExitError; } });

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; } });
function exit(code = 0) {

@@ -50,51 +24,3 @@ throw new exit_1.ExitError(code);

exports.exit = exit;
function error(input, options = {}) {
let err;
if (typeof input === 'string') {
err = new cli_1.CLIError(input, options);
}
else if (input instanceof Error) {
err = (0, cli_1.addOclifExitCode)(input, options);
}
else {
throw new TypeError('first argument must be a string or instance of Error');
}
err = (0, pretty_print_1.applyPrettyPrintOptions)(err, options);
if (options.exit === false) {
const message = (0, pretty_print_1.default)(err);
if (message)
write_1.default.stderr(message + '\n');
if (config_1.config.errorLogger)
config_1.config.errorLogger.log(err?.stack ?? '');
}
else
throw err;
}
exports.error = error;
function warn(input) {
let err;
if (typeof input === 'string') {
err = new cli_1.CLIError.Warn(input);
}
else if (input instanceof Error) {
err = (0, cli_1.addOclifExitCode)(input);
}
else {
throw new TypeError('first argument must be a string or instance of Error');
}
const message = (0, pretty_print_1.default)(err);
if (message)
write_1.default.stderr(message + '\n');
if (config_1.config.errorLogger)
config_1.config.errorLogger.log(err?.stack ?? '');
}
exports.warn = warn;
const WARNINGS = new Set();
function memoizedWarn(input) {
if (!WARNINGS.has(input))
warn(input);
WARNINGS.add(input);
}
exports.memoizedWarn = memoizedWarn;
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; } });

@@ -250,3 +250,3 @@ "use strict";

sections() {
return [
const sections = [
{

@@ -296,2 +296,4 @@ generate: () => this.usage(),

];
const allowedSections = this.opts.sections?.map((s) => s.toLowerCase());
return sections.filter(({ header }) => !allowedSections || allowedSections.includes(header.toLowerCase()));
}

@@ -298,0 +300,0 @@ usage() {

@@ -11,3 +11,3 @@ "use strict";

const write_1 = __importDefault(require("../cli-ux/write"));
const errors_1 = require("../errors");
const error_1 = require("../errors/error");
const module_loader_1 = require("../module-loader");

@@ -148,3 +148,5 @@ const symbols_1 = require("../symbols");

log(...args) {
write_1.default.stdout(node_util_1.format.apply(this, args) + '\n');
this.opts.sendToStderr
? write_1.default.stderr(node_util_1.format.apply(this, args) + '\n')
: write_1.default.stdout(node_util_1.format.apply(this, args) + '\n');
}

@@ -251,3 +253,3 @@ async showCommandHelp(command) {

}
(0, errors_1.error)(`Command ${subject} not found.`);
(0, error_1.error)(`Command ${subject} not found.`);
}

@@ -296,2 +298,4 @@ async showRootHelp() {

summary(c) {
if (this.opts.sections && !this.opts.sections.map((s) => s.toLowerCase()).includes('summary'))
return;
if (c.summary)

@@ -298,0 +302,0 @@ return (0, theme_1.colorize)(this.config?.theme?.commandSummary, this.render(c.summary.split('\n')[0]));

@@ -28,2 +28,10 @@ export interface HelpOptions {

/**
* Only show the help for the specified sections. Defaults to all sections.
*/
sections?: string[];
/**
* By default, the help output is sent to stdout. If this is true, it will be sent to stderr.
*/
sendToStderr?: boolean;
/**
* By default, titles show flag values as `<value>`. Some CLI developers may prefer titles

@@ -30,0 +38,0 @@ * to show the flag name as the value. i.e. `--myflag=myflag` instead of `--myflag=<value>`.

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.run = exports.versionAddition = exports.helpAddition = void 0;
const node_url_1 = require("node:url");
const cache_1 = __importDefault(require("./cache"));
const cli_ux_1 = require("./cli-ux");

@@ -56,2 +60,3 @@ const config_1 = require("./config");

const config = await config_1.Config.load(options ?? require.main?.filename ?? __dirname);
cache_1.default.getInstance().set('config', config);
// If this is a single command CLI, then insert the SINGLE_COMMAND_CLI_SYMBOL into the argv array to serve as the command id.

@@ -58,0 +63,0 @@ if (config.isSingleCommandCLI) {

@@ -8,3 +8,3 @@ "use strict";

const ts_path_1 = require("./config/ts-path");
const errors_1 = require("./errors");
const module_load_1 = require("./errors/errors/module-load");
const fs_1 = require("./util/fs");

@@ -20,3 +20,3 @@ const getPackageType = require('get-package-type');

if (error.code === 'MODULE_NOT_FOUND' || error.code === 'ERR_MODULE_NOT_FOUND') {
throw new errors_1.ModuleLoadError(`${isESM ? 'import()' : 'require'} failed to load ${path}: ${error.message}`);
throw new module_load_1.ModuleLoadError(`${isESM ? 'import()' : 'require'} failed to load ${path}: ${error.message}`);
}

@@ -103,6 +103,6 @@ throw error;

if (!relativePath) {
throw new errors_1.ModuleLoadError(`Cached command ${id} does not have a relative path`);
throw new module_load_1.ModuleLoadError(`Cached command ${id} does not have a relative path`);
}
if (isESM === undefined) {
throw new errors_1.ModuleLoadError(`Cached command ${id} does not have the isESM property set`);
throw new module_load_1.ModuleLoadError(`Cached command ${id} does not have the isESM property set`);
}

@@ -109,0 +109,0 @@ const filePath = (0, node_path_1.join)(modulePath, relativePath.join(node_path_1.sep));

@@ -12,2 +12,3 @@ import { CLIError } from '../errors';

parse: CLIParseErrorOptions['parse'];
showHelp: boolean;
constructor(options: CLIParseErrorOptions & {

@@ -14,0 +15,0 @@ message: string;

@@ -16,2 +16,3 @@ "use strict";

parse;
showHelp = false;
constructor(options) {

@@ -54,2 +55,3 @@ options.message += '\nSee more help with --help';

this.args = args;
this.showHelp = true;
}

@@ -64,2 +66,3 @@ }

this.args = args;
this.showHelp = true;
}

@@ -74,2 +77,3 @@ }

this.flags = flags;
this.showHelp = true;
}

@@ -76,0 +80,0 @@ }

@@ -10,3 +10,3 @@ "use strict";

const node_path_1 = require("node:path");
const errors_1 = require("../errors");
const warn_1 = require("../errors/warn");
const util_1 = require("./util");

@@ -50,3 +50,3 @@ const debug = (0, debug_1.default)('read-tsconfig');

if (!typescript) {
(0, errors_1.memoizedWarn)('Could not find typescript. Please ensure that typescript is a devDependency. Falling back to compiled source.');
(0, warn_1.memoizedWarn)('Could not find typescript. Please ensure that typescript is a devDependency. Falling back to compiled source.');
return;

@@ -53,0 +53,0 @@ }

{
"name": "@oclif/core",
"description": "base library for oclif CLIs",
"version": "3.24.0",
"version": "3.25.0",
"author": "Salesforce",

@@ -6,0 +6,0 @@ "bugs": "https://github.com/oclif/core/issues",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc