diff --git a/packages/cli/__mocks__/term-size.js b/packages/cli/__mocks__/term-size.js index 91477a62a..c6fb46ab1 100644 --- a/packages/cli/__mocks__/term-size.js +++ b/packages/cli/__mocks__/term-size.js @@ -1,3 +1,7 @@ -module.exports = function size() { +function size() { return { columns: 80, rows: 80 }; -}; +} + +size.size = size; + +module.exports = size; diff --git a/packages/cli/tests/__snapshots__/Failure.test.tsx.snap b/packages/cli/tests/__snapshots__/Failure.test.tsx.snap index 16c481d59..dda8c6d25 100644 --- a/packages/cli/tests/__snapshots__/Failure.test.tsx.snap +++ b/packages/cli/tests/__snapshots__/Failure.test.tsx.snap @@ -2,106 +2,28 @@ exports[` > doesnt render code frame if a common error 1`] = ` " -  ERROR  Cannot read properties of undefined (reading 'columns') - - src/components/Failure.tsx:57:29 - - 54: return null; - 55: } - 56: - 57: const width = screen.size().columns; - 58: let type: StyleType = 'failure'; - 59: let cmd = \`\${delimiter}\${binName} \${commandLine}\`; - 60: let arg = ''; - - - Failure.renderCodeFrame (src/components/Failure.tsx:57:29) - - Failure.render (src/components/Failure.tsx:164:12) - -finishClassCompo (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler. - ent development.js:8912:31) - -updateClassCompo (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler. - ent development.js:8862:24) - -beginWor (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler.developm - ent.js:10500:16) - -Object.invokeGuardedCall (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-rec - ackProd onciler.development.js:12101:10) - -invokeGuardedCall (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler - ack .development.js:12292:31) - -beginWork$ (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler.develo - pment.js:16531:7) - -performUnitOfW (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler.de - rk velopment.js:15340:12) - -workLoopSyn (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler.devel - opment.js:15268:5) + ERROR  + + Something is broken! " `; exports[` > doesnt render code frame if arg not found 1`] = ` " -  ERROR  Cannot read properties of undefined (reading 'columns') - - src/components/Failure.tsx:57:29 - - 54: return null; - 55: } - 56: - 57: const width = screen.size().columns; - 58: let type: StyleType = 'failure'; - 59: let cmd = \`\${delimiter}\${binName} \${commandLine}\`; - 60: let arg = ''; - - - Failure.renderCodeFrame (src/components/Failure.tsx:57:29) - - Failure.render (src/components/Failure.tsx:164:12) - -finishClassCompo (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler. - ent development.js:8912:31) - -updateClassCompo (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler. - ent development.js:8862:24) - -beginWor (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler.developm - ent.js:10500:16) - -Object.invokeGuardedCall (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-rec - ackProd onciler.development.js:12101:10) - -invokeGuardedCall (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler - ack .development.js:12292:31) - -beginWork$ (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler.develo - pment.js:16531:7) - -performUnitOfW (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler.de - rk velopment.js:15340:12) - -workLoopSyn (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler.devel - opment.js:15268:5) + ERROR  + + Flags and short option groups may not use inline values. " `; exports[` > reduces command line by half when index appears off screen 1`] = ` " - ERROR Cannot read properties of undefined (reading 'columns') - - src/components/Failure.tsx:57:29 - - 54: return null; - 55: } - 56: - 57: const width = screen.size().columns; - 58: let type: StyleType = 'failure'; - 59: let cmd = \`\${delimiter}\${binName} \${commandLine}\`; - 60: let arg = ''; - - - Failure.renderCodeFrame (src/components/Failure.tsx:57:29) - - Failure.render (src/components/Failure.tsx:164:12) - -finishClassCompo (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler. - ent development.js:8912:31) - -updateClassCompo (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler. - ent development.js:8862:24) - -beginWor (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler.developm - ent.js:10500:16) - -Object.invokeGuardedCall (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-rec - ackProd onciler.development.js:12101:10) - -invokeGuardedCall (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler - ack .development.js:12292:31) - -beginWork$ (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler.develo - pment.js:16531:7) - -performUnitOfW (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler.de - rk velopment.js:15340:12) - -workLoopSyn (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler.devel - opment.js:15268:5) + ERROR + + Flags and short option groups may not use inline values. + + … wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww" --flag=123 -gSA "mmmmmmmmmmmm … + └────────┘ " `; @@ -123,36 +45,12 @@ exports[` > renders a parse error 1`] = ` exports[` > renders a parse error with a command line 1`] = ` " - ERROR Cannot read properties of undefined (reading 'columns') - - src/components/Failure.tsx:57:29 - - 54: return null; - 55: } - 56: - 57: const width = screen.size().columns; - 58: let type: StyleType = 'failure'; - 59: let cmd = \`\${delimiter}\${binName} \${commandLine}\`; - 60: let arg = ''; - - - Failure.renderCodeFrame (src/components/Failure.tsx:57:29) - - Failure.render (src/components/Failure.tsx:164:12) - -finishClassCompo (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler. - ent development.js:8912:31) - -updateClassCompo (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler. - ent development.js:8862:24) - -beginWor (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler.developm - ent.js:10500:16) - -Object.invokeGuardedCall (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-rec - ackProd onciler.development.js:12101:10) - -invokeGuardedCall (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler - ack .development.js:12292:31) - -beginWork$ (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler.develo - pment.js:16531:7) - -performUnitOfW (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler.de - rk velopment.js:15340:12) - -workLoopSyn (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler.devel - opment.js:15268:5) + ERROR + + Flags and short option groups may not use inline values. + + $ boost --foo value --flag=123 -gSA + └────────┘ " `; @@ -166,35 +64,11 @@ exports[` > renders a validation error 1`] = ` exports[` > renders a validation error with a command line 1`] = ` " - ERROR Cannot read properties of undefined (reading 'columns') - - src/components/Failure.tsx:57:29 - - 54: return null; - 55: } - 56: - 57: const width = screen.size().columns; - 58: let type: StyleType = 'failure'; - 59: let cmd = \`\${delimiter}\${binName} \${commandLine}\`; - 60: let arg = ''; - - - Failure.renderCodeFrame (src/components/Failure.tsx:57:29) - - Failure.render (src/components/Failure.tsx:164:12) - -finishClassCompo (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler. - ent development.js:8912:31) - -updateClassCompo (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler. - ent development.js:8862:24) - -beginWor (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler.developm - ent.js:10500:16) - -Object.invokeGuardedCall (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-rec - ackProd onciler.development.js:12101:10) - -invokeGuardedCall (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler - ack .development.js:12292:31) - -beginWork$ (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler.develo - pment.js:16531:7) - -performUnitOfW (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler.de - rk velopment.js:15340:12) - -workLoopSyn (/Users/miles/Projects/boost/node_modules/react-reconciler/cjs/react-reconciler.devel - opment.js:15268:5) + ERROR + + Not enough arity arguments. + + $ boost --foo value --flag=123 -gSA + └───┘ " `; diff --git a/packages/cli/tests/__snapshots__/Program.test.tsx.snap b/packages/cli/tests/__snapshots__/Program.test.tsx.snap index e79a3f2c2..8b6dc0a4b 100644 --- a/packages/cli/tests/__snapshots__/Program.test.tsx.snap +++ b/packages/cli/tests/__snapshots__/Program.test.tsx.snap @@ -63,7 +63,7 @@ exports[` > exit > renders a non-zero exit 1`] = ` "  ERROR  - Cannot read properties of undefined (reading 'columns') + Fail! " `; @@ -80,7 +80,7 @@ exports[` > failure > renders if an error is thrown 1`] = ` "  ERROR  - Cannot read properties of undefined (reading 'columns') + Broken! " `; @@ -88,7 +88,10 @@ exports[` > failure > renders when args parsing fails 1`] = ` "  ERROR  - Cannot read properties of undefined (reading 'columns') + Unknown option "--foo" found. Did you mean "help"? [ARG:OPTION_UNKNOWN_MORE] + + $ boost --foo +  └───┘ " `; @@ -96,7 +99,7 @@ exports[` > failure > renders when invalid command name passed 1`] = "  ERROR  - Cannot read properties of undefined (reading 'columns') + Unknown command "prune". Did you mean "build"? [CLI:COMMAND_UNKNOWN] " `; @@ -104,7 +107,7 @@ exports[` > failure > renders when misspelt command name passed 1`] = "  ERROR  - Cannot read properties of undefined (reading 'columns') + Unknown command "buld". Did you mean "build"? [CLI:COMMAND_UNKNOWN] " `; @@ -112,7 +115,7 @@ exports[` > failure > renders when no commands could be found 1`] = ` "  ERROR  - Cannot read properties of undefined (reading 'columns') + Failed to determine a command to run. [CLI:COMMAND_INVALID_RUN] " `; @@ -120,7 +123,8 @@ exports[` > failure > renders when no commands have been registered 1 "  ERROR  - Cannot read properties of undefined (reading 'columns') + No commands have been registered. At least 1 is required. + [CLI:COMMAND_NONE_REGISTERED] " `; @@ -128,7 +132,7 @@ exports[` > failure > renders with custom exit error 1`] = ` "  ERROR  - Cannot read properties of undefined (reading 'columns') + Oops " `; @@ -383,7 +387,10 @@ exports[` > locale > errors for invalid \`--locale\` 1`] = ` "  ERROR  - Cannot read properties of undefined (reading 'columns') + Locale must be in the format of "en" or "en-US". + + $ boost --locale wtf +  └──────┘ " `; @@ -414,7 +421,7 @@ exports[` > nested programs > bubbles up errors 1`] = ` "  ERROR  - Cannot read properties of undefined (reading 'columns') + Bubbles " `;