From 290c06074a666e7cf5e1d252029ef25212cd471b Mon Sep 17 00:00:00 2001 From: Paulo Castro Date: Fri, 3 Jan 2020 23:10:43 +0000 Subject: [PATCH 1/4] Add '.nyc_output' folder to '.gitignore' (test coverage reporting) Change-type: patch Signed-off-by: Paulo Castro --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ad00a3b6..97a1de72 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ lib-cov # Coverage directory used by tools like istanbul coverage +.nyc_output # node-waf configuration .lock-wscript From edd755d41c08eeae8800c8a3e00379cae9531cf0 Mon Sep 17 00:00:00 2001 From: Paulo Castro Date: Fri, 3 Jan 2020 23:13:20 +0000 Subject: [PATCH 2/4] Add hint about the 'jq' utility in the documentation of the --json option Change-type: patch Signed-off-by: Paulo Castro --- doc/cli.markdown | 38 ++++++++++++++------------ lib/actions-oclif/devices/supported.ts | 13 ++++----- lib/actions-oclif/envs.ts | 18 ++++++------ lib/actions-oclif/version.ts | 7 +++-- 4 files changed, 42 insertions(+), 34 deletions(-) diff --git a/doc/cli.markdown b/doc/cli.markdown index 2d101a14..facf479d 100644 --- a/doc/cli.markdown +++ b/doc/cli.markdown @@ -579,16 +579,15 @@ confirm non interactively List the supported device types (like 'raspberrypi3' or 'intel-nuc'). The --verbose option adds extra columns/fields to the output, including the -"STATE" column whose values are one of 'beta', 'release' or 'discontinued'. +"STATE" column whose values are one of 'beta', 'released' or 'discontinued'. However, 'discontinued' device types are only listed if the '--discontinued' option is used. -The --json option is recommended when scripting the output of this command -(perhaps in combination with the [jq -utility](https://stedolan.github.io/jq/manual/)), as it is more parser -friendly (e.g. the ALIASES column contains a list of zero or more values) -and also more "stable" in relation to added or reordered columns in tabular -output (which is intended for "human eyes"). +The --json option is recommended when scripting the output of this command, +because the JSON format is less likely to change and it better represents data +types like lists and empty strings (for example, the ALIASES column contains a +list of zero or more values). The 'jq' utility may be helpful in shell scripts +(https://stedolan.github.io/jq/manual/). Examples: @@ -636,14 +635,16 @@ SERVICE columns to distinguish between application-wide, device-specific and service-specific variables. As asterisk in these columns indicates that the variable applies to "all devices" or "all services". -If you are parsing the output in a script, please select the JSON format with -the '-j' option. This avoids future compatibility issues if columns are added, -renamed or reordered. Also, when the JSON format is selected, an empty JSON -array ([]) is printed instead of an error message when no variables exist for -the given query. When querying variables for a device, note that the application -name may be null in JSON output (or 'N/A' in tabular output) if the application -linked to the device is no longer accessible by the current user (for example, -in case the current user has been removed from the application by its owner). +The --json option is recommended when scripting the output of this command, +because the JSON format is less likely to change and it better represents data +types like lists and empty strings. The 'jq' utility may be helpful in shell +scripts (https://stedolan.github.io/jq/manual/). When --json is used, an empty +JSON array ([]) is printed instead of an error message when no variables exist +for the given query. When querying variables for a device, note that the +application name may be null in JSON output (or 'N/A' in tabular output) if the +application linked to the device is no longer accessible by the current user +(for example, in case the current user has been removed from the application +by its owner). Examples: @@ -986,8 +987,11 @@ show additional commands ## version Display version information for the balena CLI and/or Node.js. -If you intend to parse the output, please use the -j option for -JSON output, as its format is more stable. + +The --json option is recommended when scripting the output of this command, +because the JSON format is less likely to change and it better represents +data types like lists and empty strings. The 'jq' utility may be helpful +in shell scripts (https://stedolan.github.io/jq/manual/). Examples: diff --git a/lib/actions-oclif/devices/supported.ts b/lib/actions-oclif/devices/supported.ts index 2f825209..86a434b3 100644 --- a/lib/actions-oclif/devices/supported.ts +++ b/lib/actions-oclif/devices/supported.ts @@ -40,16 +40,15 @@ export default class DevicesSupportedCmd extends Command { List the supported device types (like 'raspberrypi3' or 'intel-nuc'). The --verbose option adds extra columns/fields to the output, including the - "STATE" column whose values are one of 'beta', 'release' or 'discontinued'. + "STATE" column whose values are one of 'beta', 'released' or 'discontinued'. However, 'discontinued' device types are only listed if the '--discontinued' option is used. - The --json option is recommended when scripting the output of this command - (perhaps in combination with the [jq - utility](https://stedolan.github.io/jq/manual/)), as it is more parser - friendly (e.g. the ALIASES column contains a list of zero or more values) - and also more "stable" in relation to added or reordered columns in tabular - output (which is intended for "human eyes"). + The --json option is recommended when scripting the output of this command, + because the JSON format is less likely to change and it better represents data + types like lists and empty strings (for example, the ALIASES column contains a + list of zero or more values). The 'jq' utility may be helpful in shell scripts + (https://stedolan.github.io/jq/manual/). `; public static examples = [ '$ balena devices supported', diff --git a/lib/actions-oclif/envs.ts b/lib/actions-oclif/envs.ts index 75e6a8a8..4653202c 100644 --- a/lib/actions-oclif/envs.ts +++ b/lib/actions-oclif/envs.ts @@ -80,14 +80,16 @@ export default class EnvsCmd extends Command { service-specific variables. As asterisk in these columns indicates that the variable applies to "all devices" or "all services". - If you are parsing the output in a script, please select the JSON format with - the '-j' option. This avoids future compatibility issues if columns are added, - renamed or reordered. Also, when the JSON format is selected, an empty JSON - array ([]) is printed instead of an error message when no variables exist for - the given query. When querying variables for a device, note that the application - name may be null in JSON output (or 'N/A' in tabular output) if the application - linked to the device is no longer accessible by the current user (for example, - in case the current user has been removed from the application by its owner). + The --json option is recommended when scripting the output of this command, + because the JSON format is less likely to change and it better represents data + types like lists and empty strings. The 'jq' utility may be helpful in shell + scripts (https://stedolan.github.io/jq/manual/). When --json is used, an empty + JSON array ([]) is printed instead of an error message when no variables exist + for the given query. When querying variables for a device, note that the + application name may be null in JSON output (or 'N/A' in tabular output) if the + application linked to the device is no longer accessible by the current user + (for example, in case the current user has been removed from the application + by its owner). `; public static examples = [ '$ balena envs --application MyApp', diff --git a/lib/actions-oclif/version.ts b/lib/actions-oclif/version.ts index b5743968..603665bc 100644 --- a/lib/actions-oclif/version.ts +++ b/lib/actions-oclif/version.ts @@ -34,8 +34,11 @@ export default class VersionCmd extends Command { Display version information for the balena CLI and/or Node.js. Display version information for the balena CLI and/or Node.js. - If you intend to parse the output, please use the -j option for - JSON output, as its format is more stable. + + The --json option is recommended when scripting the output of this command, + because the JSON format is less likely to change and it better represents + data types like lists and empty strings. The 'jq' utility may be helpful + in shell scripts (https://stedolan.github.io/jq/manual/). `; public static examples = [ '$ balena version', From 95843dd816a866c93500cab90ff47cc1b401c0bc Mon Sep 17 00:00:00 2001 From: Paulo Castro Date: Fri, 3 Jan 2020 23:45:40 +0000 Subject: [PATCH 3/4] Fix 'balena push' hanging on Windows (CTRL-C was required after the unicorn) Resolves: #1182 Resolves: #1554 Change-type: patch Signed-off-by: Paulo Castro --- lib/app.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/app.ts b/lib/app.ts index 9681f028..8ae67afb 100644 --- a/lib/app.ts +++ b/lib/app.ts @@ -37,6 +37,9 @@ export async function run( // shared options, and performs node version requirement checks. globalInit(); await routeCliFramework(cliArgs, options); + + // Windows fix: reading from stdin prevents the process from exiting + process.stdin.pause(); } /** From 3466be19923523c7a0d8cca429f54b0bd69b0aed Mon Sep 17 00:00:00 2001 From: Paulo Castro Date: Tue, 14 Jan 2020 17:12:17 +0000 Subject: [PATCH 4/4] Increase default mocha test timeout to avoid spurious CI failures Change-type: patch Signed-off-by: Paulo Castro --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4e82e0ba..9e7aff47 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "package": "npm run build:fast && npm run build:standalone && npm run build:installer", "release": "ts-node --type-check -P automation/tsconfig.json automation/run.ts release", "pretest": "npm run build", - "test": "mocha -r ts-node/register \"tests/**/*.spec.ts\"", + "test": "mocha --timeout 6000 -r ts-node/register \"tests/**/*.spec.ts\"", "test:fast": "npm run build:fast && npm run test", "ci": "npm run test && catch-uncommitted", "watch": "gulp watch",