Skip to content

Commit

Permalink
Merge branch 'main' into mdonnalley/no-wrapped-process
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Oct 19, 2023
2 parents 3059f5d + 266d4d5 commit a96b033
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 5 deletions.
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
12 changes: 11 additions & 1 deletion src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
3 changes: 2 additions & 1 deletion src/config/plugin-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
if (!plugins || plugins.length === 0) return
Expand All @@ -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) {
Expand Down
10 changes: 8 additions & 2 deletions src/config/ts-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/pjson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ export namespace PJSON {
message: string
registry: string
timeoutInDays: number
frequency: number
frequencyUnit: 'days' | 'hours' | 'minutes' | 'seconds' | 'milliseconds'
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface PluginOptions {
root: string
tag?: string
type?: string
url?: string
}

export interface Options extends PluginOptions {
Expand Down Expand Up @@ -56,6 +57,7 @@ export interface Plugin {
* name from package.json
*/
name: string
readonly options: Options
parent?: Plugin
/**
* full package.json
Expand Down
2 changes: 2 additions & 0 deletions test/config/config.flexible.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ describe('Config with flexible taxonomy', () => {
moduleType: 'commonjs',
hasManifest: false,
isRoot: false,
options: {root: ''},
}

const pluginB: IPlugin = {
Expand All @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions test/config/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ describe('Config', () => {
moduleType: 'commonjs',
hasManifest: false,
isRoot: false,
options: {root: ''},
}

const pluginB: IPlugin = {
Expand All @@ -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
Expand Down

0 comments on commit a96b033

Please sign in to comment.