Repository: oclif/core
Pull request #44 (2020-09-16 18:52:11)

feat: export OclifError & PrettyPrintableError in Interfaces

codecov[bot]: # [Codecov](https://codecov.io/gh/oclif/core/pull/44?src=pr&el=h1) Report
> Merging [#44](https://codecov.io/gh/oclif/core/pull/44?src=pr&el=desc) into [master](https://codecov.io/gh/oclif/core/commit/10d3de9144998bbf015812d4a08d3bf2509b7fc7?el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/oclif/core/pull/44/graphs/tree.svg?width=650&height=150&src=pr&token=K0kGk9tefA)](https://codecov.io/gh/oclif/core/pull/44?src=pr&el=tree)

```diff
@@          Coverage Diff           @@
##           master     #44   +/-   ##
======================================
  Coverage    0.00%   0.00%           
======================================
  Files           3       3           
  Lines          15      15           
  Branches        2       2           
======================================
  Misses         15      15           
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/oclif/core/pull/44?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/oclif/core/pull/44?src=pr&el=footer). Last update [10d3de9...ad77237](https://codecov.io/gh/oclif/core/pull/44?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/src/config/ts-node.ts b/src/config/ts-node.ts
index 8bd84ee..c3fb2c7 100644
--- a/src/config/ts-node.ts
+++ b/src/config/ts-node.ts
@@ -2,6 +2,7 @@ import * as fs from 'fs'
 import * as path from 'path'
 import * as TSNode from 'ts-node'
 
+import {TSConfig} from '../interfaces/ts-config'
 import {Debug} from './util'
 // eslint-disable-next-line new-cap
 const debug = Debug()
@@ -10,18 +11,6 @@ const tsconfigs: {[root: string]: TSConfig} = {}
 const rootDirs: string[] = []
 const typeRoots = [`${__dirname}/../node_modules/@types`]
 
-export interface TSConfig {
-  compilerOptions: {
-    rootDir?: string;
-    rootDirs?: string[];
-    outDir?: string;
-    target?: string;
-    esModuleInterop?: boolean;
-    experimentalDecorators?: boolean;
-    emitDecoratorMetadata?: boolean;
-  };
-}
-
 function loadTSConfig(root: string): TSConfig | undefined {
   const tsconfigPath = path.join(root, 'tsconfig.json')
   let typescript: typeof import('typescript') | undefined
diff --git a/src/errors/errors/cli.ts b/src/errors/errors/cli.ts
index 46473ac..3a428ea 100644
--- a/src/errors/errors/cli.ts
+++ b/src/errors/errors/cli.ts
@@ -6,16 +6,11 @@ import Indent = require('indent-string')
 import * as Wrap from 'wrap-ansi'
 
 import {config} from '../config'
-import {PrettyPrintableError} from './pretty-print'
+import {PrettyPrintableError, OclifError} from '../../interfaces/errors'
 
 /**
  * properties specific to internal oclif error handling
  */
-export interface OclifError {
-  oclif: {
-    exit?: number | false;
-  };
-}
 
 export function addOclifExitCode(error: Record<string, any>, options?: { exit?: number | false }): OclifError {
   if (!('oclif' in error)) {
diff --git a/src/errors/errors/exit.ts b/src/errors/errors/exit.ts
index 790e374..eeb7c31 100644
--- a/src/errors/errors/exit.ts
+++ b/src/errors/errors/exit.ts
@@ -1,4 +1,5 @@
-import {CLIError, OclifError} from './cli'
+import {CLIError} from './cli'
+import {OclifError} from '../../interfaces'
 
 export class ExitError extends CLIError implements OclifError {
   oclif!: { exit: number }
diff --git a/src/errors/errors/pretty-print.ts b/src/errors/errors/pretty-print.ts
index e1de26d..379ead8 100644
--- a/src/errors/errors/pretty-print.ts
+++ b/src/errors/errors/pretty-print.ts
@@ -1,30 +1,9 @@
 import * as wrap from 'wrap-ansi'
 import indent = require('indent-string')
+
 import * as screen from '../screen'
 import {config} from '../config'
-
-export interface PrettyPrintableError {
-  /**
-   * messsage to display related to the error
-   */
-  message?: string;
-
-  /**
-   * a unique error code for this error class
-   */
-  code?: string;
-
-  /**
-   * a url to find out more information related to this error
-   * or fixing the error
-   */
-  ref?: string;
-
-  /**
-   * a suggestion that may be useful or provide additional context
-   */
-  suggestions?: string[];
-}
+import {PrettyPrintableError} from '../../interfaces/errors'
 
 // These exist for backwards compatibility with CLIError
 type CLIErrorDisplayOptions = { name?: string; bang?: string }
diff --git a/src/errors/handle.ts b/src/errors/handle.ts
index b7430ea..0e09276 100644
--- a/src/errors/handle.ts
+++ b/src/errors/handle.ts
@@ -1,10 +1,11 @@
 /* eslint-disable no-process-exit */
 /* eslint-disable unicorn/no-process-exit */
 import {config} from './config'
-import prettyPrint, {PrettyPrintableError} from './errors/pretty-print'
+import prettyPrint from './errors/pretty-print'
 import {ExitError} from '.'
 import clean = require('clean-stack')
-import {OclifError, CLIError} from './errors/cli'
+import {CLIError} from './errors/cli'
+import {OclifError, PrettyPrintableError} from '../interfaces'
 
 export const handle = (err: Error & Partial<PrettyPrintableError> & Partial<OclifError>) => {
   try {
diff --git a/src/errors/index.ts b/src/errors/index.ts
index d3e9229..2470f3d 100644
--- a/src/errors/index.ts
+++ b/src/errors/index.ts
@@ -7,9 +7,10 @@ export {Logger} from './logger'
 export {config} from './config'
 
 import {config} from './config'
-import {CLIError, addOclifExitCode, OclifError} from './errors/cli'
+import {CLIError, addOclifExitCode} from './errors/cli'
 import {ExitError} from './errors/exit'
-import prettyPrint, {PrettyPrintableError, applyPrettyPrintOptions} from './errors/pretty-print'
+import prettyPrint, {applyPrettyPrintOptions} from './errors/pretty-print'
+import {OclifError, PrettyPrintableError} from '../interfaces'
 
 export {PrettyPrintableError}
 
diff --git a/src/interfaces/errors.ts b/src/interfaces/errors.ts
new file mode 100644
index 0000000..6046051
--- /dev/null
+++ b/src/interfaces/errors.ts
@@ -0,0 +1,28 @@
+export interface OclifError {
+  oclif: {
+    exit?: number | false;
+  };
+}
+
+export interface PrettyPrintableError {
+  /**
+   * messsage to display related to the error
+   */
+  message?: string;
+
+  /**
+   * a unique error code for this error class
+   */
+  code?: string;
+
+  /**
+   * a url to find out more information related to this error
+   * or fixing the error
+   */
+  ref?: string;
+
+  /**
+   * a suggestion that may be useful or provide additional context
+   */
+  suggestions?: string[];
+}
diff --git a/src/interfaces/index.ts b/src/interfaces/index.ts
index 1aebac2..a3d54c6 100644
--- a/src/interfaces/index.ts
+++ b/src/interfaces/index.ts
@@ -1,7 +1,9 @@
 export {Config, ArchTypes, PlatformTypes, LoadOptions} from './config'
 export {Command} from './command'
+export {OclifError, PrettyPrintableError} from './errors'
 export {Hook, HookKeyOrOptions, Hooks} from './hooks'
 export {Manifest} from './manifest'
 export {PJSON} from './pjson'
 export {Plugin, PluginOptions, Options} from './plugin'
 export {Topic} from './topic'
+export {TSConfig} from './ts-config'
diff --git a/src/interfaces/ts-config.ts b/src/interfaces/ts-config.ts
new file mode 100644
index 0000000..b656541
--- /dev/null
+++ b/src/interfaces/ts-config.ts
@@ -0,0 +1,11 @@
+export interface TSConfig {
+  compilerOptions: {
+    rootDir?: string;
+    rootDirs?: string[];
+    outDir?: string;
+    target?: string;
+    esModuleInterop?: boolean;
+    experimentalDecorators?: boolean;
+    emitDecoratorMetadata?: boolean;
+  };
+}


Test patch:
diff --git a/test/config/ts-node.test.ts b/test/config/ts-node.test.ts
index 6d5ea81..157fadd 100644
--- a/test/config/ts-node.test.ts
+++ b/test/config/ts-node.test.ts
@@ -2,7 +2,7 @@ import * as path from 'path'
 import * as proxyquire from 'proxyquire'
 import * as tsNode from 'ts-node'
 
-import {TSConfig} from '../../src/config/ts-node'
+import {Interfaces} from '../../src'
 
 import {expect, fancy} from './test'
 
@@ -10,18 +10,18 @@ const root = path.resolve(__dirname, 'fixtures/typescript')
 const orig = 'src/hooks/init.ts'
 let tsNodeRegisterCallArguments: any[] = []
 
-const DEFAULT_TS_CONFIG: TSConfig = {
+const DEFAULT_TS_CONFIG: Interfaces.TSConfig = {
   compilerOptions: {},
 }
 
-const withMockTsConfig = (config: TSConfig = DEFAULT_TS_CONFIG) => {
+const withMockTsConfig = (config: Interfaces.TSConfig = DEFAULT_TS_CONFIG) => {
   const tsNodePlugin = proxyquire('../../src/config/ts-node', {fs: {
     existsSync: () => true,
     readFileSync: () => JSON.stringify(config),
   }})
 
-  // This prints "loadTSConfig unstubbed" not "loadTSConfig proxyquire"!
-  tsNodePlugin.tsPath('poop', 'asdf')
+  // This prints "loadInterfaces.TSConfig unstubbed" not "loadInterfaces.TSConfig proxyquire"!
+  tsNodePlugin.tsPath('qwerty', 'asdf')
 
   return fancy
   .add('tsNodePlugin', () => tsNodePlugin)
diff --git a/test/errors/error.test.ts b/test/errors/error.test.ts
index aa58a3a..15ab20a 100644
--- a/test/errors/error.test.ts
+++ b/test/errors/error.test.ts
@@ -1,6 +1,6 @@
 import {expect, fancy} from 'fancy-test'
 import {error} from '../../src/errors'
-import {PrettyPrintableError} from '../../src/errors/errors/pretty-print'
+import {PrettyPrintableError} from '../../src/interfaces/errors'
 
 describe('error', () => {
   fancy
diff --git a/test/errors/pretty-print.test.ts b/test/errors/pretty-print.test.ts
index 4831a0d..8313368 100644
--- a/test/errors/pretty-print.test.ts
+++ b/test/errors/pretty-print.test.ts
@@ -1,5 +1,6 @@
 import {expect, fancy} from 'fancy-test'
-import prettyPrint, {PrettyPrintableError} from '../../src/errors/errors/pretty-print'
+import prettyPrint from '../../src/errors/errors/pretty-print'
+import {PrettyPrintableError} from '../../src/interfaces/errors'
 import {CLIError} from '../../src/errors'
 import {config} from '../../src/errors/config'
 const stripAnsi = require('strip-ansi')