diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f26dde6f..f766c16c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,31 @@ +## [3.3.3](https://github.com/oclif/core/compare/3.3.2...3.3.3) (2023-10-19) + + +### Bug Fixes + +* allow github-installed plugins to be auto-transpiled ([6f2c5e2](https://github.com/oclif/core/commit/6f2c5e2ec9b9bafa7dea4ae2e7350ada64ff0e88)) +* handle ModuleLoadError from hooks ([0321093](https://github.com/oclif/core/commit/0321093e4f8a0f659346a9e2e808ad44c6d3771f)) + + + +## [3.3.2](https://github.com/oclif/core/compare/3.3.1...3.3.2) (2023-10-17) + + +### Bug Fixes + +* **deps:** bump @babel/traverse from 7.23.0 to 7.23.2 ([d53498a](https://github.com/oclif/core/commit/d53498af1da6bdcb3fb70f7c0b6e0da8da0831a1)) + + + +## [3.3.1](https://github.com/oclif/core/compare/3.3.0...3.3.1) (2023-10-16) + + +### Bug Fixes + +* add frequency and frequencyUnit to warn-if-update ([#827](https://github.com/oclif/core/issues/827)) ([3567c74](https://github.com/oclif/core/commit/3567c748a8a04ab94cca493aa1dfcb4f10370f6e)) + + + # [3.3.0](https://github.com/oclif/core/compare/3.2.1...3.3.0) (2023-10-16) diff --git a/package.json b/package.json index 240f29376..fc69dd996 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@oclif/core", "description": "base library for oclif CLIs", - "version": "3.3.0", + "version": "3.3.3", "author": "Salesforce", "bugs": "https://github.com/oclif/core/issues", "dependencies": { diff --git a/src/config/config.ts b/src/config/config.ts index 4715b6004..00610fc64 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -527,7 +527,17 @@ export class Config implements IConfig { } catch (error: any) { final.failures.push({error: error as Error, plugin: p}) debug(error) - if (!captureErrors && error.oclif?.exit !== undefined) throw error + // Do not throw the error if + // captureErrors is set to true + // error.oclif.exit is undefined or 0 + // error.code is MODULE_NOT_FOUND + if ( + !captureErrors && + error.oclif?.exit !== undefined && + error.oclif?.exit !== 0 && + error.code !== 'MODULE_NOT_FOUND' + ) + throw error } marker?.addDetails({ diff --git a/src/config/plugin-loader.ts b/src/config/plugin-loader.ts index 0fcc8a130..ea466387d 100644 --- a/src/config/plugin-loader.ts +++ b/src/config/plugin-loader.ts @@ -94,7 +94,7 @@ export default class PluginLoader { private async loadPlugins( root: string, type: string, - plugins: ({name?: string; root?: string; tag?: string} | string)[], + plugins: ({name?: string; root?: string; tag?: string; url?: string} | string)[], parent?: Plugin.Plugin, ): Promise { if (!plugins || plugins.length === 0) return @@ -112,6 +112,7 @@ export default class PluginLoader { if (typeof plugin !== 'string') { opts.tag = plugin.tag || opts.tag opts.root = plugin.root || opts.root + opts.url = plugin.url } if (parent) { diff --git a/src/config/ts-node.ts b/src/config/ts-node.ts index ee61c2a79..8fe6e42b5 100644 --- a/src/config/ts-node.ts +++ b/src/config/ts-node.ts @@ -200,7 +200,7 @@ function determinePath(root: string, orig: string): string { export function tsPath(root: string, orig: string, plugin: Plugin): string export function tsPath(root: string, orig: string | undefined, plugin?: Plugin): string | undefined export function tsPath(root: string, orig: string | undefined, plugin?: Plugin): string | undefined { - const rootPlugin = Cache.getInstance().get('rootPlugin') + const rootPlugin = plugin?.options.isRoot ? plugin : Cache.getInstance().get('rootPlugin') if (!orig) return orig orig = orig.startsWith(root) ? orig : join(root, orig) @@ -222,10 +222,16 @@ export function tsPath(root: string, orig: string | undefined, plugin?: Plugin): memoizedWarn( `${plugin?.name} is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used instead.`, ) + + if (plugin?.options.url) + memoizedWarn( + `${plugin?.name} is an ESM module installed from github and cannot be auto-transpiled. Existing compiled source will be used instead.`, + ) return orig } - if (settings.tsnodeEnabled === undefined && isProduction && plugin?.type !== 'link') { + // Do not skip ts-node registration if the plugin is linked or installed from github + if (settings.tsnodeEnabled === undefined && isProduction && plugin?.type !== 'link' && !plugin?.options.url) { debug(`Skipping ts-node registration for ${root} because NODE_ENV is NOT "test" or "development"`) return orig } diff --git a/src/interfaces/pjson.ts b/src/interfaces/pjson.ts index 204356acc..3f82f5fd4 100644 --- a/src/interfaces/pjson.ts +++ b/src/interfaces/pjson.ts @@ -105,6 +105,8 @@ export namespace PJSON { message: string registry: string timeoutInDays: number + frequency: number + frequencyUnit: 'days' | 'hours' | 'minutes' | 'seconds' | 'milliseconds' } } } diff --git a/src/interfaces/plugin.ts b/src/interfaces/plugin.ts index 7917429b7..994a42216 100644 --- a/src/interfaces/plugin.ts +++ b/src/interfaces/plugin.ts @@ -14,6 +14,7 @@ export interface PluginOptions { root: string tag?: string type?: string + url?: string } export interface Options extends PluginOptions { @@ -56,6 +57,7 @@ export interface Plugin { * name from package.json */ name: string + readonly options: Options parent?: Plugin /** * full package.json diff --git a/test/config/config.flexible.test.ts b/test/config/config.flexible.test.ts index 2d95ea68a..b68162c2c 100644 --- a/test/config/config.flexible.test.ts +++ b/test/config/config.flexible.test.ts @@ -104,6 +104,7 @@ describe('Config with flexible taxonomy', () => { moduleType: 'commonjs', hasManifest: false, isRoot: false, + options: {root: ''}, } const pluginB: IPlugin = { @@ -125,6 +126,7 @@ describe('Config with flexible taxonomy', () => { moduleType: 'commonjs', hasManifest: false, isRoot: false, + options: {root: ''}, } const plugins = new Map().set(pluginA.name, pluginA).set(pluginB.name, pluginB) diff --git a/test/config/config.test.ts b/test/config/config.test.ts index 82f014a5e..1fd875216 100644 --- a/test/config/config.test.ts +++ b/test/config/config.test.ts @@ -293,6 +293,7 @@ describe('Config', () => { moduleType: 'commonjs', hasManifest: false, isRoot: false, + options: {root: ''}, } const pluginB: IPlugin = { @@ -314,6 +315,7 @@ describe('Config', () => { moduleType: 'commonjs', hasManifest: false, isRoot: false, + options: {root: ''}, } const plugins = new Map().set(pluginA.name, pluginA).set(pluginB.name, pluginB) let test = fancy