Merge pull request #2097 from balena-io/2096-login-unhandled-rejection

Fix unhandled rejection, --debug logic and add doc references to masterclasses
This commit is contained in:
bulldozer-balena[bot] 2020-11-20 12:42:13 +00:00 committed by GitHub
commit 0689074dd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 46 additions and 40 deletions

View File

@ -139,12 +139,14 @@ The full CLI command reference is available [on the web](https://www.balena.io/d
## Support, FAQ and troubleshooting
If you come across any problems or would like to get in touch:
To learn more, troubleshoot issues, or to contact us for support:
* Check our [FAQ / troubleshooting document](https://github.com/balena-io/balena-cli/blob/master/TROUBLESHOOTING.md).
* Ask us a question through the [balenaCloud forum](https://forums.balena.io/c/balena-cloud).
* For bug reports or feature requests,
[have a look at the GitHub issues or create a new one](https://github.com/balena-io/balena-cli/issues/).
* Check the [masterclass tutorials](https://www.balena.io/docs/learn/more/masterclasses/overview/)
* Check our [FAQ / troubleshooting document](https://github.com/balena-io/balena-cli/blob/master/TROUBLESHOOTING.md)
* Ask us a question through the [balenaCloud forum](https://forums.balena.io/c/balena-cloud)
For CLI bug reports or feature requests, check the
[CLI GitHub issues](https://github.com/balena-io/balena-cli/issues/).
## Deprecation policy

View File

@ -127,12 +127,14 @@ address like `192.168.1.2`.
## Support, FAQ and troubleshooting
If you come across any problems or would like to get in touch:
To learn more, troubleshoot issues, or to contact us for support:
* Check our [FAQ / troubleshooting document](https://github.com/balena-io/balena-cli/blob/master/TROUBLESHOOTING.md).
* Ask us a question through the [balenaCloud forum](https://forums.balena.io/c/balena-cloud).
* For bug reports or feature requests,
[have a look at the GitHub issues or create a new one](https://github.com/balena-io/balena-cli/issues/).
* Check the [masterclass tutorials](https://www.balena.io/docs/learn/more/masterclasses/overview/)
* Check our [FAQ / troubleshooting document](https://github.com/balena-io/balena-cli/blob/master/TROUBLESHOOTING.md)
* Ask us a question through the [balenaCloud forum](https://forums.balena.io/c/balena-cloud)
For CLI bug reports or feature requests, check the
[CLI GitHub issues](https://github.com/balena-io/balena-cli/issues/).
## Deprecation policy

View File

@ -224,7 +224,7 @@ export const printErrorMessage = function (message: string) {
console.error(line);
});
console.error(`\n${getHelp}\n`);
console.error(`\n${getHelp()}\n`);
};
export const printExpectedErrorMessage = function (message: string) {

View File

@ -84,7 +84,7 @@ export async function trackCommand(commandSignature: string) {
try {
const balena = getBalenaSdk();
const $username = await balena.auth.whoami();
storage.set('cachedUsername', {
await storage.set('cachedUsername', {
token,
username: $username,
} as CachedUsername);

View File

@ -1,3 +1,19 @@
/**
* @license
* Copyright 2017-2020 Balena Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Help from '@oclif/plugin-help';
import * as indent from 'indent-string';
import { getChalk } from './utils/lazy';
@ -123,16 +139,10 @@ export default class BalenaHelp extends Help {
console.log(' --help, -h');
console.log(' --debug\n');
console.log(
`For help, visit our support forums: ${chalk.grey(
'https://forums.balena.io',
)}`,
);
console.log(
`For bug reports or feature requests, see: ${chalk.grey(
'https://github.com/balena-io/balena-cli/issues/',
)}\n`,
);
const {
reachingOut,
} = require('./utils/messages') as typeof import('./utils/messages');
console.log(reachingOut);
}
protected formatCommands(commands: any[]): string {

View File

@ -15,26 +15,20 @@
* limitations under the License.
*/
const DEBUG_MODE = !!process.env.DEBUG;
export const reachingOut = `\
If you need help, or just want to say hi, don't hesitate in reaching out
through our discussion and support forums at https://forums.balena.io
For bug reports or feature requests, have a look at the GitHub issues or
create a new one at: https://github.com/balena-io/balena-cli/issues/\
For further help or support, visit:
https://www.balena.io/docs/reference/balena-cli/#support-faq-and-troubleshooting
`;
const debugHint = `\
Additional information may be available with the \`--debug\` flag.
`;
\n`;
export const help = `\
For help, visit our support forums: https://forums.balena.io
For bug reports or feature requests, see: https://github.com/balena-io/balena-cli/issues/
`;
export const help = reachingOut;
export const getHelp = (DEBUG_MODE ? '' : debugHint) + help;
// Note that the value of process.env.DEBUG may change after the --debug flag
// is parsed, so its evaluation cannot happen at module loading time.
export const getHelp = () => (process.env.DEBUG ? '' : debugHint) + help;
export const balenaAsciiArt = `\
_ _

View File

@ -19,6 +19,7 @@ import { expect } from 'chai';
import { BalenaAPIMock } from '../balena-api-mock';
import { cleanOutput, runCommand } from '../helpers';
import * as messages from '../../build/utils/messages';
const SIMPLE_HELP = `
USAGE
@ -103,10 +104,7 @@ GLOBAL OPTIONS
`;
const ONLINE_RESOURCES = `
For help, visit our support forums: https://forums.balena.io
For bug reports or feature requests, see: https://github.com/balena-io/balena-cli/issues/
`;
const ONLINE_RESOURCES = messages.reachingOut;
describe.skip('balena help', function () {
let api: BalenaAPIMock;

View File

@ -187,7 +187,7 @@ describe('printErrorMessage() function', () => {
expect(consoleError.getCall(0).args[0]).to.equal(expectedOutputMessages[0]);
expect(consoleError.getCall(1).args[0]).to.equal(expectedOutputMessages[1]);
expect(consoleError.getCall(2).args[0]).to.equal(expectedOutputMessages[2]);
expect(consoleError.getCall(3).args[0]).to.equal(`\n${getHelp}\n`);
expect(consoleError.getCall(3).args[0]).to.equal(`\n${getHelp()}\n`);
consoleError.restore();
});