@oclif/core 4.14.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/help/index.js CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Help = exports.HelpBase = exports.standardizeIDFromArgv = exports.normalizeArgv = exports.getHelpFlagAdditions = exports.HelpFormatter = exports.CommandHelp = void 0;
7
7
  exports.loadHelpClass = loadHelpClass;
8
8
  const ansis_1 = __importDefault(require("ansis"));
9
+ const node_path_1 = require("node:path");
9
10
  const ts_path_1 = require("../config/ts-path");
10
11
  const error_1 = require("../errors/error");
11
12
  const module_loader_1 = require("../module-loader");
@@ -331,11 +332,29 @@ function determineLocation(helpClass) {
331
332
  async function loadHelpClass(config) {
332
333
  if (config.pjson.oclif?.helpClass) {
333
334
  const { identifier, target } = determineLocation(config.pjson.oclif?.helpClass);
334
- try {
335
- const path = (await (0, ts_path_1.tsPath)(config.root, target)) ?? target;
335
+ const loadClass = async (path) => {
336
336
  const module = await (0, module_loader_1.load)(config, path);
337
337
  const helpClass = module[identifier] ?? (identifier === 'default' ? extractClass(module) : undefined);
338
338
  return extractClass(helpClass);
339
+ };
340
+ // The compiled artifact that `helpClass` points at (e.g. "./dist/help/myHelp.js").
341
+ const compiledPath = (0, node_path_1.isAbsolute)(target) ? target : (0, node_path_1.join)(config.root, target);
342
+ try {
343
+ // `tsPath` may rewrite the compiled path to the TypeScript source for local
344
+ // development. That source can be unloadable in some runtimes — e.g. an ESM
345
+ // CLI executed under plain `node` without `tsx` registered, where the `.js`
346
+ // specifiers in the source can't be resolved to their `.ts` siblings.
347
+ const path = (await (0, ts_path_1.tsPath)(config.root, target)) ?? target;
348
+ try {
349
+ return await loadClass(path);
350
+ }
351
+ catch (error) {
352
+ // If we tried (and failed) to load transpiled source, fall back to the
353
+ // configured compiled artifact before giving up.
354
+ if (path === compiledPath)
355
+ throw error;
356
+ return await loadClass(compiledPath);
357
+ }
339
358
  }
340
359
  catch (error) {
341
360
  throw new Error(`Unable to load configured help class "${target}", failed with message:\n${error.message}`);
package/lib/index.js CHANGED
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ux = exports.toStandardizedId = exports.toConfiguredId = exports.settings = exports.Performance = exports.Parser = exports.ModuleLoader = exports.getLogger = exports.Interfaces = exports.loadHelpClass = exports.HelpBase = exports.Help = exports.CommandHelp = exports.flush = exports.Flags = exports.execute = exports.handle = exports.Errors = exports.Constraints = exports.Plugin = exports.Config = exports.Command = exports.Args = void 0;
36
+ 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.Constraints = exports.Plugin = exports.Config = exports.Command = exports.Args = void 0;
37
37
  const util_1 = require("./util/util");
38
38
  function checkCWD() {
39
39
  try {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oclif/core",
3
3
  "description": "base library for oclif CLIs",
4
- "version": "4.14.0",
4
+ "version": "5.0.1",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {
@@ -64,10 +64,10 @@
64
64
  "sinon": "^18",
65
65
  "ts-node": "^10.9.2",
66
66
  "tsd": "^0.33.0",
67
- "typescript": "^5"
67
+ "typescript": "^6.0.3"
68
68
  },
69
69
  "engines": {
70
- "node": ">=18.0.0"
70
+ "node": ">=22.0.0"
71
71
  },
72
72
  "files": [
73
73
  "/lib"