From f8473c321261f16a8aa9a01731a73447732c5a29 Mon Sep 17 00:00:00 2001 From: Ross Stenersen Date: Wed, 12 Nov 2025 14:49:36 -0600 Subject: [PATCH] feat: add `buildEpilog` to more commands --- src/__tests__/commands/apps/authorize.test.ts | 9 +++++- src/__tests__/commands/apps/create.test.ts | 10 +++++-- src/__tests__/commands/apps/oauth.test.ts | 10 +++++-- .../commands/apps/oauth/generate.test.ts | 7 +++-- .../commands/apps/oauth/update.test.ts | 7 +++-- src/__tests__/commands/apps/register.test.ts | 14 +++++++--- src/__tests__/commands/apps/settings.test.ts | 12 ++++++-- .../commands/apps/settings/update.test.ts | 10 +++++-- src/__tests__/commands/apps/update.test.ts | 28 +++++++++++-------- .../commands/devicepreferences.test.ts | 24 ++++++---------- src/__tests__/commands/deviceprofiles.test.ts | 18 ++++-------- src/__tests__/commands/devices.test.ts | 10 +++++-- .../devices/capability-status.test.ts | 7 +++++ src/__tests__/commands/devices/delete.test.ts | 7 +++-- src/__tests__/commands/devices/update.test.ts | 7 +++-- src/__tests__/commands/installedapps.test.ts | 10 +++++-- .../commands/installedschema.test.ts | 10 +++++-- src/__tests__/commands/rules.test.ts | 10 +++++-- src/__tests__/commands/rules/create.test.ts | 14 +++++++--- src/__tests__/commands/rules/delete.test.ts | 10 +++++-- src/__tests__/commands/rules/execute.test.ts | 22 +++++++++------ src/__tests__/commands/rules/update.test.ts | 10 +++++-- src/__tests__/commands/scenes.test.ts | 10 +++++-- .../commands/virtualdevices/update.test.ts | 7 +++-- src/__tests__/lib/command/api-command.test.ts | 2 +- src/commands/apps/authorize.ts | 12 +++++--- src/commands/apps/create.ts | 4 +-- src/commands/apps/oauth.ts | 5 ++-- src/commands/apps/oauth/generate.ts | 5 ++-- src/commands/apps/oauth/update.ts | 5 ++-- src/commands/apps/register.ts | 5 ++-- src/commands/apps/settings.ts | 5 ++-- src/commands/apps/settings/update.ts | 4 +-- src/commands/apps/update.ts | 5 ++-- src/commands/devicepreferences.ts | 21 +++++++------- src/commands/deviceprofiles.ts | 4 +-- src/commands/devices.ts | 5 ++-- src/commands/devices/capability-status.ts | 8 +++--- src/commands/devices/component-status.ts | 4 +-- src/commands/devices/delete.ts | 4 +-- src/commands/devices/update.ts | 5 ++-- src/commands/installedapps.ts | 4 +-- src/commands/installedschema.ts | 5 ++-- src/commands/rules.ts | 5 ++-- src/commands/rules/create.ts | 4 +-- src/commands/rules/delete.ts | 4 +-- src/commands/rules/execute.ts | 5 ++-- src/commands/rules/update.ts | 4 +-- src/commands/scenes.ts | 4 +-- src/commands/virtualdevices/update.ts | 4 +-- 50 files changed, 270 insertions(+), 155 deletions(-) diff --git a/src/__tests__/commands/apps/authorize.test.ts b/src/__tests__/commands/apps/authorize.test.ts index 6bbcdba7..f43786f7 100644 --- a/src/__tests__/commands/apps/authorize.test.ts +++ b/src/__tests__/commands/apps/authorize.test.ts @@ -3,7 +3,8 @@ import { jest } from '@jest/globals' import type { ArgumentsCamelCase, Argv } from 'yargs' import type { CommandArgs } from '../../../commands/apps/authorize.js' -import { addPermission } from '../../../lib/aws-util.js' +import type { addPermission } from '../../../lib/aws-util.js' +import type { buildEpilog } from '../../../lib/help.js' import type { lambdaAuthBuilder, LambdaAuthFlags } from '../../../lib/command/common-flags.js' import type { smartThingsCommand, @@ -19,6 +20,11 @@ jest.unstable_mockModule('../../../lib/aws-util.js', () => ({ addPermission: addPermissionMock, })) +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + const lambdaAuthBuilderMock = jest.fn() jest.unstable_mockModule('../../../lib/command/common-flags.js', () => ({ lambdaAuthBuilder: lambdaAuthBuilderMock, @@ -55,6 +61,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/apps/create.test.ts b/src/__tests__/commands/apps/create.test.ts index 452699cf..cd8e47f8 100644 --- a/src/__tests__/commands/apps/create.test.ts +++ b/src/__tests__/commands/apps/create.test.ts @@ -9,6 +9,7 @@ import type { SmartThingsClient, } from '@smartthings/core-sdk' +import type { buildEpilog } from '../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' import type { lambdaAuthBuilder } from '../../../lib/command/common-flags.js' import type { CustomCommonOutputProducer } from '../../../lib/command/format.js' @@ -29,7 +30,12 @@ import { } from '../../test-lib/table-mock.js' -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') const lambdaAuthBuilderMock = jest.fn() jest.unstable_mockModule('../../../lib/command/common-flags.js', () => ({ @@ -94,7 +100,7 @@ test('builder', () => { expect(exampleMock).toHaveBeenCalledTimes(1) expect(optionMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/apps/oauth.test.ts b/src/__tests__/commands/apps/oauth.test.ts index c6ee2294..1d4f30c3 100644 --- a/src/__tests__/commands/apps/oauth.test.ts +++ b/src/__tests__/commands/apps/oauth.test.ts @@ -4,6 +4,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { AppOAuthResponse, AppsEndpoint } from '@smartthings/core-sdk' +import type { buildEpilog } from '../../../lib/help.js' import type { CommandArgs } from '../../../commands/apps/oauth.js' import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' import type { OutputItemOrListFlags } from '../../../lib/command/listing-io.js' @@ -14,7 +15,12 @@ import { apiCommandMocks } from '../../test-lib/api-command-mock.js' import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js' -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') const outputItemMock = jest.fn() const outputItemBuilderMock = jest.fn() @@ -54,7 +60,7 @@ test('builder', () => { expect(outputItemBuilderMock).toHaveBeenCalledExactlyOnceWith(apiCommandBuilderArgvMock) expect(positionalMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/apps/oauth/generate.test.ts b/src/__tests__/commands/apps/oauth/generate.test.ts index dcb6e841..6fd4fa25 100644 --- a/src/__tests__/commands/apps/oauth/generate.test.ts +++ b/src/__tests__/commands/apps/oauth/generate.test.ts @@ -10,7 +10,7 @@ import type { SmartThingsClient, } from '@smartthings/core-sdk' -import type { itemInputHelpText } from '../../../../lib/help.js' +import type { itemInputHelpText, buildEpilog } from '../../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js' import type { inputAndOutputItem, @@ -25,15 +25,16 @@ import { apiCommandMocks } from '../../../test-lib/api-command-mock.js' import { buildInputDefMock } from '../../../test-lib/input-type-mock.js' +const buildEpilogMock = jest.fn() const itemInputHelpTextMock = jest.fn() jest.unstable_mockModule('../../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, itemInputHelpText: itemInputHelpTextMock, })) const { apiCommandMock, apiCommandBuilderMock, - apiDocsURLMock, } = apiCommandMocks('../../../..') const inputAndOutputItemMock = @@ -93,7 +94,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/apps/oauth/update.test.ts b/src/__tests__/commands/apps/oauth/update.test.ts index ed2d57eb..9f5e1ad0 100644 --- a/src/__tests__/commands/apps/oauth/update.test.ts +++ b/src/__tests__/commands/apps/oauth/update.test.ts @@ -11,7 +11,7 @@ import type { SmartThingsClient, } from '@smartthings/core-sdk' -import type { itemInputHelpText } from '../../../../lib/help.js' +import type { itemInputHelpText, buildEpilog } from '../../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js' import type { inputAndOutputItem, @@ -26,15 +26,16 @@ import { apiCommandMocks } from '../../../test-lib/api-command-mock.js' import { buildInputDefMock } from '../../../test-lib/input-type-mock.js' +const buildEpilogMock = jest.fn() const itemInputHelpTextMock = jest.fn() jest.unstable_mockModule('../../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, itemInputHelpText: itemInputHelpTextMock, })) const { apiCommandMock, apiCommandBuilderMock, - apiDocsURLMock, } = apiCommandMocks('../../../..') const inputAndOutputItemMock = @@ -97,7 +98,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/apps/register.test.ts b/src/__tests__/commands/apps/register.test.ts index 92d7332a..627354b7 100644 --- a/src/__tests__/commands/apps/register.test.ts +++ b/src/__tests__/commands/apps/register.test.ts @@ -4,14 +4,20 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import { type AppsEndpoint, AppType, PagedApp } from '@smartthings/core-sdk' -import { CommandArgs } from '../../../commands/apps/register.js' +import type { CommandArgs } from '../../../commands/apps/register.js' +import type { buildEpilog } from '../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' -import { chooseApp } from '../../../lib/command/util/apps-util.js' +import type { chooseApp } from '../../../lib/command/util/apps-util.js' import { apiCommandMocks } from '../../test-lib/api-command-mock.js' import { buildArgvMock } from '../../test-lib/builder-mock.js' -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') const chooseAppMock = jest.fn() jest.unstable_mockModule('../../../lib/command/util/apps-util.js', () => ({ @@ -42,7 +48,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/apps/settings.test.ts b/src/__tests__/commands/apps/settings.test.ts index 28278794..8410591a 100644 --- a/src/__tests__/commands/apps/settings.test.ts +++ b/src/__tests__/commands/apps/settings.test.ts @@ -5,18 +5,24 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { AppsEndpoint, AppSettingsResponse } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../commands/apps/settings.js' +import type { buildEpilog } from '../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' import type { CustomCommonOutputProducer } from '../../../lib/command/format.js' import type { OutputItemOrListFlags } from '../../../lib/command/listing-io.js' import type { outputItem, outputItemBuilder } from '../../../lib/command/output-item.js' import type { SmartThingsCommandFlags } from '../../../lib/command/smartthings-command.js' -import { buildTableOutput, type chooseApp } from '../../../lib/command/util/apps-util.js' +import type { buildTableOutput, chooseApp } from '../../../lib/command/util/apps-util.js' import { apiCommandMocks } from '../../test-lib/api-command-mock.js' import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js' import { tableGeneratorMock } from '../../test-lib/table-mock.js' -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') const outputItemMock = jest.fn() const outputItemBuilderMock = jest.fn() @@ -57,7 +63,7 @@ test('builder', () => { expect(outputItemBuilderMock).toHaveBeenCalledExactlyOnceWith(apiCommandBuilderArgvMock) expect(positionalMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/apps/settings/update.test.ts b/src/__tests__/commands/apps/settings/update.test.ts index 384149b4..3215fc6f 100644 --- a/src/__tests__/commands/apps/settings/update.test.ts +++ b/src/__tests__/commands/apps/settings/update.test.ts @@ -4,6 +4,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { AppsEndpoint, AppSettingsResponse, SmartThingsClient } from '@smartthings/core-sdk' +import type { buildEpilog } from '../../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js' import type { inputAndOutputItem, @@ -17,7 +18,12 @@ import { CustomCommonOutputProducer } from '../../../../lib/command/format.js' import { tableGeneratorMock } from '../../../test-lib/table-mock.js' -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../../..') const inputAndOutputItemMock = jest.fn() const inputAndOutputItemBuilderMock = jest.fn() @@ -58,7 +64,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/apps/update.test.ts b/src/__tests__/commands/apps/update.test.ts index c0f2badd..00498a8a 100644 --- a/src/__tests__/commands/apps/update.test.ts +++ b/src/__tests__/commands/apps/update.test.ts @@ -2,29 +2,35 @@ import { jest } from '@jest/globals' import type { ArgumentsCamelCase, Argv } from 'yargs' -import { - type AppCreateRequest, - type AppCreationResponse, - type AppResponse, - type AppsEndpoint, - type AppUpdateRequest, +import type { + AppCreateRequest, + AppCreationResponse, + AppResponse, + AppsEndpoint, + AppUpdateRequest, } from '@smartthings/core-sdk' +import type { buildEpilog } from '../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' import type { lambdaAuthBuilder } from '../../../lib/command/common-flags.js' -import { +import type { inputAndOutputItem, inputAndOutputItemBuilder, } from '../../../lib/command/input-and-output-item.js' -import { InputProcessor, userInputProcessor } from '../../../lib/command/input-processor.js' +import type { InputProcessor, userInputProcessor } from '../../../lib/command/input-processor.js' import { type authorizeApp, type chooseApp, tableFieldDefinitions } from '../../../lib/command/util/apps-util.js' -import { getAppUpdateRequestFromUser } from '../../../lib/command/util/apps-user-input-update.js' +import type { getAppUpdateRequestFromUser } from '../../../lib/command/util/apps-user-input-update.js' import type { CommandArgs } from '../../../commands/apps/create.js' import { apiCommandMocks } from '../../test-lib/api-command-mock.js' import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js' -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') const lambdaAuthBuilderMock = jest.fn() jest.unstable_mockModule('../../../lib/command/common-flags.js', () => ({ @@ -97,7 +103,7 @@ test('builder', () => { expect(exampleMock).toHaveBeenCalledTimes(1) expect(positionalMock).toHaveBeenCalledTimes(1) expect(optionMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/devicepreferences.test.ts b/src/__tests__/commands/devicepreferences.test.ts index 652644d6..04f8db6a 100644 --- a/src/__tests__/commands/devicepreferences.test.ts +++ b/src/__tests__/commands/devicepreferences.test.ts @@ -10,17 +10,16 @@ import type { } from '@smartthings/core-sdk' import type { WithOrganization, forAllOrganizations } from '../../lib/api-helpers.js' +import type { buildEpilog } from '../../lib/help.js' import type { APIOrganizationCommand, APIOrganizationCommandFlags, apiOrganizationCommand, apiOrganizationCommandBuilder, } from '../../lib/command/api-organization-command.js' -import { AllOrganizationFlags, allOrganizationsBuilder } from '../../lib/command/common-flags.js' -import { outputItemOrList, outputItemOrListBuilder } from '../../lib/command/listing-io.js' -import { CommandArgs } from '../../commands/devicepreferences.js' -import { shortARNorURL, verboseApps } from '../../lib/command/util/apps-util.js' -import { apiCommandMocks } from '../test-lib/api-command-mock.js' +import type { AllOrganizationFlags, allOrganizationsBuilder } from '../../lib/command/common-flags.js' +import type { outputItemOrList, outputItemOrListBuilder } from '../../lib/command/listing-io.js' +import type { CommandArgs } from '../../commands/devicepreferences.js' import { buildArgvMock, buildArgvMockStub } from '../test-lib/builder-mock.js' @@ -29,7 +28,10 @@ jest.unstable_mockModule('../../lib/api-helpers.js', () => ({ forAllOrganizations: forAllOrganizationsMock, })) -const { apiDocsURLMock } = apiCommandMocks('../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) const apiOrganizationCommandMock = jest.fn() const apiOrganizationCommandBuilderMock = jest.fn() @@ -50,14 +52,6 @@ jest.unstable_mockModule('../../lib/command/listing-io.js', () => ({ outputItemOrListBuilder: outputItemOrListBuilderMock, })) -const shortARNorURLMock = jest.fn() -const verboseAppsMock = jest.fn() -jest.unstable_mockModule('../../lib/command/util/apps-util.js', () => ({ - shortARNorURL: shortARNorURLMock, - verboseApps: verboseAppsMock, - tableFieldDefinitions: [], -})) - const { default: cmd } = await import('../../commands/devicepreferences.js') @@ -89,7 +83,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(optionMock).toHaveBeenCalledTimes(2) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/deviceprofiles.test.ts b/src/__tests__/commands/deviceprofiles.test.ts index a0deedd3..ef892572 100644 --- a/src/__tests__/commands/deviceprofiles.test.ts +++ b/src/__tests__/commands/deviceprofiles.test.ts @@ -11,6 +11,7 @@ import type { import type { CommandArgs } from '../../commands/deviceprofiles.js' import type { WithOrganization, forAllOrganizations } from '../../lib/api-helpers.js' +import type { buildEpilog } from '../../lib/help.js' import type { APIOrganizationCommand, APIOrganizationCommandFlags, @@ -27,9 +28,7 @@ import type { } from '../../lib/command/format.js' import type { outputItemOrList, outputItemOrListBuilder } from '../../lib/command/listing-io.js' import type { ValueTableFieldDefinition } from '../../lib/table-generator.js' -import type { shortARNorURL, verboseApps } from '../../lib/command/util/apps-util.js' import type { buildTableOutput } from '../../lib/command/util/deviceprofiles-util.js' -import { apiCommandMocks } from '../test-lib/api-command-mock.js' import { buildArgvMock, buildArgvMockStub } from '../test-lib/builder-mock.js' import { tableGeneratorMock } from '../test-lib/table-mock.js' @@ -39,7 +38,10 @@ jest.unstable_mockModule('../../lib/api-helpers.js', () => ({ forAllOrganizations: forAllOrganizationsMock, })) -const { apiDocsURLMock } = apiCommandMocks('../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) const apiOrganizationCommandMock = jest.fn() const apiOrganizationCommandBuilderMock = jest.fn() @@ -61,14 +63,6 @@ jest.unstable_mockModule('../../lib/command/listing-io.js', () => ({ outputItemOrListBuilder: outputItemOrListBuilderMock, })) -const shortARNorURLMock = jest.fn() -const verboseAppsMock = jest.fn() -jest.unstable_mockModule('../../lib/command/util/apps-util.js', () => ({ - shortARNorURL: shortARNorURLMock, - verboseApps: verboseAppsMock, - tableFieldDefinitions: [], -})) - const buildTableOutputMock = jest.fn() jest.unstable_mockModule('../../lib/command/util/deviceprofiles-util.js', () => ({ buildTableOutput: buildTableOutputMock, @@ -107,7 +101,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(optionMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/devices.test.ts b/src/__tests__/commands/devices.test.ts index bc9a07a0..a4727414 100644 --- a/src/__tests__/commands/devices.test.ts +++ b/src/__tests__/commands/devices.test.ts @@ -13,6 +13,7 @@ import { import type { CommandArgs, OutputDevice } from '../../commands/devices.js' import type { withLocationAndRoom, withLocationsAndRooms } from '../../lib/api-helpers.js' +import type { buildEpilog } from '../../lib/help.js' import type { APICommand, APICommandFlags } from '../../lib/command/api-command.js' import type { outputItemOrList, outputItemOrListBuilder } from '../../lib/command/listing-io.js' import type { CustomCommonOutputProducer } from '../../lib/command/format.js' @@ -31,7 +32,12 @@ jest.unstable_mockModule('../../lib/api-helpers.js', () => ({ withLocationsAndRooms: withLocationsAndRoomsMock, })) -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../..') const outputItemOrListMock = jest.fn>() const outputItemOrListBuilderMock = jest.fn() @@ -75,7 +81,7 @@ describe('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(optionMock).toHaveBeenCalledTimes(9) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/devices/capability-status.test.ts b/src/__tests__/commands/devices/capability-status.test.ts index 0c299391..e90404b6 100644 --- a/src/__tests__/commands/devices/capability-status.test.ts +++ b/src/__tests__/commands/devices/capability-status.test.ts @@ -10,6 +10,7 @@ import type { } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../commands/devices/capability-status.js' +import type { buildEpilog } from '../../../lib/help.js' import type { APICommand } from '../../../lib/command/api-command.js' import type { stringTranslateToId } from '../../../lib/command/command-util.js' import type { @@ -38,6 +39,11 @@ import { apiCommandMocks } from '../../test-lib/api-command-mock.js' const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + const stringTranslateToIdMock = jest.fn() jest.unstable_mockModule('../../../lib/command/command-util.js', () => ({ stringTranslateToId: stringTranslateToIdMock, @@ -103,6 +109,7 @@ test('builder', () => { expect(formatAndWriteItemBuilderMock).toHaveBeenCalledExactlyOnceWith(apiCommandBuilderArgvMock) expect(positionalMock).toHaveBeenCalledTimes(3) expect(exampleMock).toHaveBeenCalledOnce() + expect(buildEpilogMock).toHaveBeenCalledOnce() expect(epilogMock).toHaveBeenCalledOnce() }) diff --git a/src/__tests__/commands/devices/delete.test.ts b/src/__tests__/commands/devices/delete.test.ts index 7bd2dc64..dc472478 100644 --- a/src/__tests__/commands/devices/delete.test.ts +++ b/src/__tests__/commands/devices/delete.test.ts @@ -5,13 +5,16 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { DevicesEndpoint, SmartThingsClient } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../commands/devices/delete.js' +import type { buildEpilog } from '../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' import type { chooseDevice } from '../../../lib/command/util/devices-choose.js' import { apiCommandMocks } from '../../test-lib/api-command-mock.js' import { buildArgvMock } from '../../test-lib/builder-mock.js' -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ buildEpilog: buildEpilogMock })) +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') const chooseDeviceMock = jest.fn() jest.unstable_mockModule('../../../lib/command/util/devices-choose.js', () => ({ @@ -43,7 +46,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/devices/update.test.ts b/src/__tests__/commands/devices/update.test.ts index b6347c09..f320045f 100644 --- a/src/__tests__/commands/devices/update.test.ts +++ b/src/__tests__/commands/devices/update.test.ts @@ -4,6 +4,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { Device, DevicesEndpoint, DeviceUpdate } from '@smartthings/core-sdk' +import type { buildEpilog } from '../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' import type { CustomCommonOutputProducer } from '../../../lib/command/format.js' import type { inputAndOutputItem, inputAndOutputItemBuilder } from '../../../lib/command/input-and-output-item.js' @@ -15,7 +16,9 @@ import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js import { tableGeneratorMock } from '../../test-lib/table-mock.js' -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ buildEpilog: buildEpilogMock })) +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') const inputAndOutputItemMock = jest.fn>() const inputAndOutputItemBuilderMock = jest.fn() @@ -61,7 +64,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/installedapps.test.ts b/src/__tests__/commands/installedapps.test.ts index 928cfc25..b56e9569 100644 --- a/src/__tests__/commands/installedapps.test.ts +++ b/src/__tests__/commands/installedapps.test.ts @@ -9,6 +9,7 @@ import { } from '@smartthings/core-sdk' import type { withLocation, withLocations, WithLocation } from '../../lib/api-helpers.js' +import type { buildEpilog } from '../../lib/help.js' import type { APICommand, APICommandFlags } from '../../lib/command/api-command.js' import type { outputItemOrList, outputItemOrListBuilder } from '../../lib/command/listing-io.js' import type { BuildOutputFormatterFlags } from '../../lib/command/output-builder.js' @@ -27,7 +28,12 @@ jest.unstable_mockModule('../../lib/api-helpers.js', () => ({ withLocations: withLocationsMock, })) -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../..') const outputItemOrListMock = jest.fn>() const outputItemOrListBuilderMock = jest.fn() @@ -63,7 +69,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(optionMock).toHaveBeenCalledTimes(2) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/installedschema.test.ts b/src/__tests__/commands/installedschema.test.ts index 6197625a..5d79f8a8 100644 --- a/src/__tests__/commands/installedschema.test.ts +++ b/src/__tests__/commands/installedschema.test.ts @@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { InstalledSchemaApp, SchemaEndpoint } from '@smartthings/core-sdk' import type { withLocation, WithLocation } from '../../lib/api-helpers.js' +import type { buildEpilog } from '../../lib/help.js' import type { APICommand, APICommandFlags } from '../../lib/command/api-command.js' import type { outputItemOrList, outputItemOrListBuilder, OutputItemOrListFlags } from '../../lib/command/listing-io.js' import type { SmartThingsCommandFlags } from '../../lib/command/smartthings-command.js' @@ -20,7 +21,12 @@ jest.unstable_mockModule('../../lib/api-helpers.js', () => ({ withLocation: withLocationMock, })) -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../..') const outputItemOrListMock = jest.fn>() const outputItemOrListBuilderMock = jest.fn() @@ -63,7 +69,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(optionMock).toHaveBeenCalledTimes(2) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/rules.test.ts b/src/__tests__/commands/rules.test.ts index 1314d96b..a810101b 100644 --- a/src/__tests__/commands/rules.test.ts +++ b/src/__tests__/commands/rules.test.ts @@ -4,6 +4,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { Rule } from '@smartthings/core-sdk' +import type { buildEpilog } from '../../lib/help.js' import type { APICommand } from '../../lib/command/api-command.js' import type { outputItemOrList, outputItemOrListBuilder } from '../../lib/command/listing-io.js' import type { CommandArgs } from '../../commands/rules.js' @@ -15,7 +16,12 @@ import { buildArgvMock, buildArgvMockStub } from '../test-lib/builder-mock.js' import { WithNamedLocation } from '../../lib/api-helpers.js' -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../..') const outputItemOrListMock = jest.fn>() const outputItemOrListBuilderMock = jest.fn() @@ -58,7 +64,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(optionMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/rules/create.test.ts b/src/__tests__/commands/rules/create.test.ts index 79b7c6d0..f490b977 100644 --- a/src/__tests__/commands/rules/create.test.ts +++ b/src/__tests__/commands/rules/create.test.ts @@ -5,15 +5,21 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import { Rule, RuleRequest, RulesEndpoint } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../commands/locations/create.js' -import { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' -import { inputAndOutputItem, inputAndOutputItemBuilder } from '../../../lib/command/input-and-output-item.js' +import type { buildEpilog } from '../../../lib/help.js' +import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' +import type { inputAndOutputItem, inputAndOutputItemBuilder } from '../../../lib/command/input-and-output-item.js' import type { chooseLocation } from '../../../lib/command/util/locations-util.js' import { tableFieldDefinitions } from '../../../lib/command/util/rules-table.js' import { apiCommandMocks } from '../../test-lib/api-command-mock.js' import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js' -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') const inputAndOutputItemMock = jest.fn() const inputAndOutputItemBuilderMock = jest.fn() @@ -52,7 +58,7 @@ test('builder', () => { expect(inputAndOutputItemBuilderMock).toHaveBeenCalledWith(apiCommandBuilderArgvMock) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/rules/delete.test.ts b/src/__tests__/commands/rules/delete.test.ts index 5a24c5b4..cae61924 100644 --- a/src/__tests__/commands/rules/delete.test.ts +++ b/src/__tests__/commands/rules/delete.test.ts @@ -6,6 +6,7 @@ import { Rule, RulesEndpoint, SmartThingsClient } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../commands/rules/delete.js' import type { WithNamedLocation } from '../../../lib/api-helpers.js' +import type { buildEpilog } from '../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' import type { chooseRuleFn } from '../../../lib/command/util/rules-choose.js' import type { getRuleWithLocation } from '../../../lib/command/util/rules-util.js' @@ -14,7 +15,12 @@ import { apiCommandMocks } from '../../test-lib/api-command-mock.js' import { buildArgvMock } from '../../test-lib/builder-mock.js' -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') const chooseRuleMock = jest.fn>() const chooseRuleFnMock = jest.fn().mockReturnValue(chooseRuleMock) @@ -52,7 +58,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/rules/execute.test.ts b/src/__tests__/commands/rules/execute.test.ts index 5a1362ff..6874ce70 100644 --- a/src/__tests__/commands/rules/execute.test.ts +++ b/src/__tests__/commands/rules/execute.test.ts @@ -4,20 +4,26 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { RulesEndpoint, RuleExecutionResponse, Rule } from '@smartthings/core-sdk' +import type { CommandArgs } from '../../../commands/rules/execute.js' +import type { WithLocation } from '../../../lib/api-helpers.js' +import type { buildEpilog } from '../../../lib/help.js' +import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' +import type { CustomCommonOutputProducer, formatAndWriteItem, formatAndWriteItemBuilder } from '../../../lib/command/format.js' import type { chooseRuleFn } from '../../../lib/command/util/rules-choose.js' import type { buildExecuteResponseTableOutput } from '../../../lib/command/util/rules-table.js' import type { getRuleWithLocation } from '../../../lib/command/util/rules-util.js' -import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js' -import { CustomCommonOutputProducer, formatAndWriteItem, formatAndWriteItemBuilder } from '../../../lib/command/format.js' -import { CommandArgs } from '../../../commands/rules/execute.js' -import { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' -import { WithLocation } from '../../../lib/api-helpers.js' -import { ChooseFunction } from '../../../lib/command/util/util-util.js' +import type { ChooseFunction } from '../../../lib/command/util/util-util.js' import { apiCommandMocks } from '../../test-lib/api-command-mock.js' +import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js' import { tableGeneratorMock } from '../../test-lib/table-mock.js' -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') const formatAndWriteItemMock = jest.fn>() const formatAndWriteItemBuilderMock = jest.fn() @@ -66,7 +72,7 @@ test('builder', () => { expect(formatAndWriteItemBuilderMock).toHaveBeenCalledExactlyOnceWith(apiCommandBuilderArgvMock) expect(positionalMock).toHaveBeenCalledOnce() expect(exampleMock).toHaveBeenCalledOnce() - expect(apiDocsURLMock).toHaveBeenCalledOnce() + expect(buildEpilogMock).toHaveBeenCalledOnce() expect(epilogMock).toHaveBeenCalledOnce() }) diff --git a/src/__tests__/commands/rules/update.test.ts b/src/__tests__/commands/rules/update.test.ts index f84ccad2..72924a87 100644 --- a/src/__tests__/commands/rules/update.test.ts +++ b/src/__tests__/commands/rules/update.test.ts @@ -6,6 +6,7 @@ import type { Rule, RuleRequest, RulesEndpoint } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../commands/rules/update.js' import type { WithLocation } from '../../../lib/api-helpers.js' +import type { buildEpilog } from '../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' import type { inputAndOutputItem, inputAndOutputItemBuilder } from '../../../lib/command/input-and-output-item.js' import type { chooseRuleFn } from '../../../lib/command/util/rules-choose.js' @@ -16,7 +17,12 @@ import { apiCommandMocks } from '../../test-lib/api-command-mock.js' import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js' -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') const inputAndOutputItemMock = jest.fn>() const inputAndOutputItemBuilderMock = jest.fn() @@ -65,7 +71,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(optionMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/scenes.test.ts b/src/__tests__/commands/scenes.test.ts index 4e132b41..cc94bd88 100644 --- a/src/__tests__/commands/scenes.test.ts +++ b/src/__tests__/commands/scenes.test.ts @@ -8,6 +8,7 @@ import type { SmartThingsClient, } from '@smartthings/core-sdk' +import type { buildEpilog } from '../../lib/help.js' import type { APICommand, APICommandFlags } from '../../lib/command/api-command.js' import type { outputItemOrList, outputItemOrListBuilder } from '../../lib/command/listing-io.js' import type { BuildOutputFormatterFlags } from '../../lib/command/output-builder.js' @@ -18,7 +19,12 @@ import { apiCommandMocks } from '../test-lib/api-command-mock.js' import { buildArgvMock, buildArgvMockStub } from '../test-lib/builder-mock.js' -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../..') const outputItemOrListMock = jest.fn>() const outputItemOrListBuilderMock = jest.fn() @@ -54,7 +60,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(optionMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/virtualdevices/update.test.ts b/src/__tests__/commands/virtualdevices/update.test.ts index 780e0fd2..a3938ec2 100644 --- a/src/__tests__/commands/virtualdevices/update.test.ts +++ b/src/__tests__/commands/virtualdevices/update.test.ts @@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import { DeviceIntegrationType, type Device, type DevicesEndpoint, type DeviceUpdate } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../commands/devices/update.js' +import type { buildEpilog } from '../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js' import type { CustomCommonOutputProducer } from '../../../lib/command/format.js' import type { inputAndOutputItem, inputAndOutputItemBuilder } from '../../../lib/command/input-and-output-item.js' @@ -16,7 +17,9 @@ import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js import { tableGeneratorMock } from '../../test-lib/table-mock.js' -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ buildEpilog: buildEpilogMock })) +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') const inputAndOutputItemMock = jest.fn>() const inputAndOutputItemBuilderMock = jest.fn() @@ -63,7 +66,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/lib/command/api-command.test.ts b/src/__tests__/lib/command/api-command.test.ts index 528d7348..16278c59 100644 --- a/src/__tests__/lib/command/api-command.test.ts +++ b/src/__tests__/lib/command/api-command.test.ts @@ -17,11 +17,11 @@ import type { smartThingsCommandBuilder, } from '../../../lib/command/smartthings-command.js' import type { newBearerTokenAuthenticator, newSmartThingsClient } from '../../../lib/command/util/st-client-wrapper.js' +import type { CLIConfig } from '../../../lib/cli-config.js' import type { coreSDKLoggerFromLog4JSLogger } from '../../../lib/log-utils.js' import { defaultClientIdProvider, type loginAuthenticator } from '../../../lib/login-authenticator.js' import type { TableGenerator } from '../../../lib/table-generator.js' import { buildArgvMock } from '../../test-lib/builder-mock.js' -import type { CLIConfig } from '../../../lib/cli-config.js' const { errorMock, loggerMock } = await import('../../test-lib/logger-mock.js') diff --git a/src/commands/apps/authorize.ts b/src/commands/apps/authorize.ts index 70b427d5..81baaa9e 100644 --- a/src/commands/apps/authorize.ts +++ b/src/commands/apps/authorize.ts @@ -1,11 +1,12 @@ import { ArgumentsCamelCase, Argv, CommandModule } from 'yargs' import { addPermission } from '../../lib/aws-util.js' -import { lambdaAuthBuilder, LambdaAuthFlags } from '../../lib/command/common-flags.js' +import { buildEpilog } from '../../lib/help.js' +import { lambdaAuthBuilder, type LambdaAuthFlags } from '../../lib/command/common-flags.js' import { smartThingsCommand, smartThingsCommandBuilder, - SmartThingsCommandFlags, + type SmartThingsCommandFlags, } from '../../lib/command/smartthings-command.js' @@ -29,13 +30,16 @@ const builder = (yargs: Argv): Argv => 'authorize an app', ], ]) - .epilog(`NOTE: The example above is the same as running the following with the AWS CLI: + .epilog(buildEpilog({ + command, + formattedNotes: `The example above is the same as running the following with the AWS CLI: $ aws lambda add-permission --region us-east-1 --function-name \\ > arn:aws:lambda:us-east-1:1234567890:function:your-app \\ > --statement smartthings --principal 906037444270 --action lambda:InvokeFunction -This command requires your machine to be configured to run the AWS CLI.`) +This command requires your machine to be configured to run the AWS CLI.`, + })) const handler = async (argv: ArgumentsCamelCase): Promise => { await smartThingsCommand(argv) diff --git a/src/commands/apps/create.ts b/src/commands/apps/create.ts index 24ff2ab7..7005a3b4 100644 --- a/src/commands/apps/create.ts +++ b/src/commands/apps/create.ts @@ -2,11 +2,11 @@ import type { ArgumentsCamelCase, Argv, CommandModule } from 'yargs' import { type AppCreateRequest, type AppCreationResponse } from '@smartthings/core-sdk' +import { buildEpilog } from '../../lib/help.js' import { apiCommand, apiCommandBuilder, type APICommandFlags, - apiDocsURL, } from '../../lib/command/api-command.js' import { lambdaAuthBuilder, LambdaAuthFlags } from '../../lib/command/common-flags.js' import { @@ -49,7 +49,7 @@ const builder = (yargs: Argv): Argv => '(See "smartthings apps:authorize" for more information on authorization.)', ], ]) - .epilog(apiDocsURL('createApp')) + .epilog(buildEpilog({ command, apiDocs: ['createApp'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/apps/oauth.ts b/src/commands/apps/oauth.ts index c6561b46..7e0af67c 100644 --- a/src/commands/apps/oauth.ts +++ b/src/commands/apps/oauth.ts @@ -1,6 +1,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' -import { apiCommand, apiCommandBuilder, type APICommandFlags, apiDocsURL } from '../../lib/command/api-command.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../lib/command/api-command.js' +import { buildEpilog } from '../../lib/help.js' import { outputItem, outputItemBuilder, type OutputItemFlags } from '../../lib/command/output-item.js' import { chooseApp, oauthTableFieldDefinitions } from '../../lib/command/util/apps-util.js' @@ -30,7 +31,7 @@ const builder = (yargs: Argv): Argv => 'list OAuth information for the app with the given id', ], ]) - .epilog(apiDocsURL('getAppOauth')) + .epilog(buildEpilog({ command, apiDocs: ['getAppOauth'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/apps/oauth/generate.ts b/src/commands/apps/oauth/generate.ts index 05d010b1..d55aa437 100644 --- a/src/commands/apps/oauth/generate.ts +++ b/src/commands/apps/oauth/generate.ts @@ -2,13 +2,12 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import type { GenerateAppOAuthRequest, GenerateAppOAuthResponse } from '@smartthings/core-sdk' -import { itemInputHelpText } from '../../../lib/help.js' +import { buildEpilog, itemInputHelpText } from '../../../lib/help.js' import { type TableFieldDefinition } from '../../../lib/table-generator.js' import { apiCommand, apiCommandBuilder, type APICommandFlags, - apiDocsURL, } from '../../../lib/command/api-command.js' import { inputAndOutputItem, @@ -44,7 +43,7 @@ const builder = (yargs: Argv): Argv => 'regenerate the OAuth clientId and clientSecret of the app with the given id', ], ]) - .epilog(apiDocsURL(docNames)) + .epilog(buildEpilog({ command, apiDocs: [docNames] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/apps/oauth/update.ts b/src/commands/apps/oauth/update.ts index 68998694..26928048 100644 --- a/src/commands/apps/oauth/update.ts +++ b/src/commands/apps/oauth/update.ts @@ -2,12 +2,11 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { AppOAuthRequest } from '@smartthings/core-sdk' -import { itemInputHelpText } from '../../../lib/help.js' +import { buildEpilog, itemInputHelpText } from '../../../lib/help.js' import { apiCommand, apiCommandBuilder, APICommandFlags, - apiDocsURL, } from '../../../lib/command/api-command.js' import { inputAndOutputItem, @@ -49,7 +48,7 @@ const builder = (yargs: Argv): Argv => 'update OAuth settings for the app with the given id using the data in "oauth-settings.json"', ], ]) - .epilog(apiDocsURL(docNames)) + .epilog(buildEpilog({ command, apiDocs: [docNames] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/apps/register.ts b/src/commands/apps/register.ts index 96625a1c..27879fcf 100644 --- a/src/commands/apps/register.ts +++ b/src/commands/apps/register.ts @@ -2,7 +2,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { AppType, type PagedApp } from '@smartthings/core-sdk' -import { apiCommand, apiCommandBuilder, type APICommandFlags, apiDocsURL } from '../../lib/command/api-command.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../lib/command/api-command.js' +import { buildEpilog } from '../../lib/help.js' import { chooseApp } from '../../lib/command/util/apps-util.js' @@ -24,7 +25,7 @@ const builder = (yargs: Argv): Argv => 'send registration request to the app with the given id', ], ]) - .epilog(apiDocsURL('register')) + .epilog(buildEpilog({ command, apiDocs: ['register'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/apps/settings.ts b/src/commands/apps/settings.ts index 60bd256d..9d5b67f3 100644 --- a/src/commands/apps/settings.ts +++ b/src/commands/apps/settings.ts @@ -1,6 +1,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' -import { apiCommand, apiCommandBuilder, type APICommandFlags, apiDocsURL } from '../../lib/command/api-command.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../lib/command/api-command.js' +import { buildEpilog } from '../../lib/help.js' import { outputItem, outputItemBuilder, OutputItemFlags } from '../../lib/command/output-item.js' import { buildTableOutput, chooseApp } from '../../lib/command/util/apps-util.js' @@ -30,7 +31,7 @@ const builder = (yargs: Argv): Argv => 'get the settings of the app with the given id', ], ]) - .epilog(apiDocsURL('getAppSettings')) + .epilog(buildEpilog({ command, apiDocs: ['getAppSettings'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/apps/settings/update.ts b/src/commands/apps/settings/update.ts index e33235c9..74f40c7e 100644 --- a/src/commands/apps/settings/update.ts +++ b/src/commands/apps/settings/update.ts @@ -5,9 +5,9 @@ import { type AppSettingsRequest, type AppSettingsResponse } from '@smartthings/ import { apiCommand, apiCommandBuilder, - apiDocsURL, type APICommandFlags, } from '../../../lib/command/api-command.js' +import { buildEpilog } from '../../../lib/help.js' import { inputAndOutputItem, inputAndOutputItemBuilder, @@ -37,7 +37,7 @@ const builder = (yargs: Argv): Argv => 'ask for the ID of an app to update and then update it using the data in "app-settings.json"', ], ]) - .epilog(apiDocsURL('updateAppSettings')) + .epilog(buildEpilog({ command, apiDocs: ['updateAppSettings'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/apps/update.ts b/src/commands/apps/update.ts index 4e199a8d..91c1fa99 100644 --- a/src/commands/apps/update.ts +++ b/src/commands/apps/update.ts @@ -2,7 +2,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type AppUpdateRequest, type AppResponse } from '@smartthings/core-sdk' -import { apiCommand, apiCommandBuilder, type APICommandFlags, apiDocsURL } from '../../lib/command/api-command.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../lib/command/api-command.js' +import { buildEpilog } from '../../lib/help.js' import { lambdaAuthBuilder, type LambdaAuthFlags } from '../../lib/command/common-flags.js' import { type TableCommonOutputProducer } from '../../lib/command/format.js' import { @@ -56,7 +57,7 @@ const builder = (yargs: Argv): Argv => ], ]) .epilog('See apps:oauth:update and apps:oauth:generate for updating oauth-related data.\n\n' + - apiDocsURL('updateApp')) + buildEpilog({ command, apiDocs: ['updateApp'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/devicepreferences.ts b/src/commands/devicepreferences.ts index 44d11aa2..9ba66981 100644 --- a/src/commands/devicepreferences.ts +++ b/src/commands/devicepreferences.ts @@ -1,23 +1,24 @@ -import { ArgumentsCamelCase, Argv, CommandModule } from 'yargs' +import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' -import { DevicePreference } from '@smartthings/core-sdk' +import { type DevicePreference } from '@smartthings/core-sdk' -import { WithOrganization, forAllOrganizations } from '../lib/api-helpers.js' -import { APICommand, APICommandFlags, apiDocsURL } from '../lib/command/api-command.js' +import { type WithOrganization, forAllOrganizations } from '../lib/api-helpers.js' +import { buildEpilog } from '../lib/help.js' +import { type TableFieldDefinition } from '../lib/table-generator.js' +import { type APICommand, type APICommandFlags } from '../lib/command/api-command.js' import { - APIOrganizationCommandFlags, + type APIOrganizationCommandFlags, apiOrganizationCommand, apiOrganizationCommandBuilder, } from '../lib/command/api-organization-command.js' -import { AllOrganizationFlags, allOrganizationsBuilder } from '../lib/command/common-flags.js' +import { type AllOrganizationFlags, allOrganizationsBuilder } from '../lib/command/common-flags.js' import { - OutputItemOrListConfig, - OutputItemOrListFlags, + type OutputItemOrListConfig, + type OutputItemOrListFlags, outputItemOrList, outputItemOrListBuilder, } from '../lib/command/listing-io.js' import { tableFieldDefinitions } from '../lib/command/util/devicepreferences-util.js' -import { TableFieldDefinition } from '../lib/table-generator.js' export const standardPreferences = async (command: APICommand): Promise => { @@ -72,7 +73,7 @@ const builder = (yargs: Argv): Argv => ['$0 devicepreferences motionSensitivity', 'display details for a preference by id'], ['$0 devicepreferences --standard', 'list standard device preferences'], ]) - .epilog(apiDocsURL('listPreferences', 'getPreferenceById')) + .epilog(buildEpilog({ command, apiDocs: ['listPreferences', 'getPreferenceById'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/deviceprofiles.ts b/src/commands/deviceprofiles.ts index 2d016d86..3fe9a18f 100644 --- a/src/commands/deviceprofiles.ts +++ b/src/commands/deviceprofiles.ts @@ -3,13 +3,13 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type DeviceProfile } from '@smartthings/core-sdk' import { forAllOrganizations, WithOrganization } from '../lib/api-helpers.js' +import { buildEpilog } from '../lib/help.js' import { buildTableOutput } from '../lib/command/util/deviceprofiles-util.js' import { apiOrganizationCommand, apiOrganizationCommandBuilder, type APIOrganizationCommandFlags, } from '../lib/command/api-organization-command.js' -import { apiDocsURL } from '../lib/command/api-command.js' import { AllOrganizationFlags, allOrganizationsBuilder } from '../lib/command/common-flags.js' import { outputItemOrList, @@ -51,7 +51,7 @@ const builder = (yargs: Argv): Argv => ], ['$0 deviceprofiles 8bd382bb-07e8-48d3-8b11-5f0b508b1729', 'display details for a device profile by id'], ]) - .epilog(apiDocsURL('listDeviceProfiles', 'getDeviceProfile')) + .epilog(buildEpilog({ command, apiDocs: ['listDeviceProfiles', 'getDeviceProfile'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/devices.ts b/src/commands/devices.ts index c049af2c..37c44735 100644 --- a/src/commands/devices.ts +++ b/src/commands/devices.ts @@ -9,8 +9,9 @@ import { } from '@smartthings/core-sdk' import { withLocationAndRoom, withLocationsAndRooms, type WithNamedRoom } from '../lib/api-helpers.js' +import { buildEpilog } from '../lib/help.js' import { type TableFieldDefinition } from '../lib/table-generator.js' -import { apiCommand, apiCommandBuilder, type APICommandFlags, apiDocsURL } from '../lib/command/api-command.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../lib/command/api-command.js' import { outputItemOrList, outputItemOrListBuilder, @@ -112,7 +113,7 @@ const builder = (yargs: Argv): Argv => ['$0 devices --verbose', 'include location and room names in the output'], ['$0 devices --type zigbee --type zwave', 'list Zigbee and Z-Wave devices'], ]) - .epilog(apiDocsURL('getDevices', 'getDevice')) + .epilog(buildEpilog({ command, apiDocs: ['getDevices', 'getDevice'] })) // type that includes extra fields sometimes included when requested via command line flags export type OutputDevice = Device & WithNamedRoom & Pick diff --git a/src/commands/devices/capability-status.ts b/src/commands/devices/capability-status.ts index 19713ddc..cb79af2b 100644 --- a/src/commands/devices/capability-status.ts +++ b/src/commands/devices/capability-status.ts @@ -2,10 +2,12 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type CapabilityReference, type CapabilityStatus } from '@smartthings/core-sdk' +import { buildEpilog } from '../../lib/help.js' +import { type TableGenerator } from '../../lib/table-generator.js' +import { fatalError } from '../../lib/util.js' import { apiCommand, apiCommandBuilder, - apiDocsURL, type APICommandFlags, } from '../../lib/command/api-command.js' import { stringTranslateToId } from '../../lib/command/command-util.js' @@ -17,8 +19,6 @@ import { import { selectFromList, type SelectFromListConfig } from '../../lib/command/select.js' import { prettyPrintAttribute } from '../../lib/command/util/devices.js' import { chooseComponentFn, chooseDevice } from '../../lib/command/util/devices-choose.js' -import { type TableGenerator } from '../../lib/table-generator.js' -import { fatalError } from '../../lib/util.js' export type CommandArgs = APICommandFlags & FormatAndWriteItemFlags & { @@ -45,7 +45,7 @@ const builder = (yargs: Argv): Argv => ['$0 devices:capability-status fa1eb54c-c571-405f-8817-ffb7cd2f5a9d main switch', 'display the status for the specified device, component, and capability'], ]) - .epilog(apiDocsURL('getDeviceStatusByCapability')) + .epilog(buildEpilog({ command, apiDocs: 'getDeviceStatusByCapability' })) export const buildTableOutput = ( tableGenerator: TableGenerator, diff --git a/src/commands/devices/component-status.ts b/src/commands/devices/component-status.ts index b54b8ed1..888bcee0 100644 --- a/src/commands/devices/component-status.ts +++ b/src/commands/devices/component-status.ts @@ -3,9 +3,9 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { apiCommand, apiCommandBuilder, - apiDocsURL, type APICommandFlags, } from '../../lib/command/api-command.js' +import { buildEpilog } from '../../lib/help.js' import { formatAndWriteItem, formatAndWriteItemBuilder, @@ -43,7 +43,7 @@ const builder = (yargs: Argv): Argv => ['$0 devices:capability-status fa1eb54c-c571-405f-8817-ffb7cd2f5a9d main', 'display the status for the specified device and component'], ]) - .epilog(apiDocsURL('getDeviceComponentStatus')) + .epilog(buildEpilog({ command, apiDocs: ['getDeviceComponentStatus'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/devices/delete.ts b/src/commands/devices/delete.ts index c328df16..12fce393 100644 --- a/src/commands/devices/delete.ts +++ b/src/commands/devices/delete.ts @@ -4,8 +4,8 @@ import { type APICommandFlags, apiCommand, apiCommandBuilder, - apiDocsURL, } from '../../lib/command/api-command.js' +import { buildEpilog } from '../../lib/help.js' import { chooseDevice } from '../../lib/command/util/devices-choose.js' @@ -27,7 +27,7 @@ const builder = (yargs: Argv): Argv => 'delete the device with the specified id', ], ]) - .epilog(apiDocsURL('deleteDevice')) + .epilog(buildEpilog({ command, apiDocs: ['deleteDevice'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/devices/update.ts b/src/commands/devices/update.ts index 8797c15a..d7eb59bc 100644 --- a/src/commands/devices/update.ts +++ b/src/commands/devices/update.ts @@ -2,7 +2,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type Device, type DeviceUpdate } from '@smartthings/core-sdk' -import { apiCommand, apiCommandBuilder, type APICommandFlags, apiDocsURL } from '../../lib/command/api-command.js' +import { buildEpilog } from '../../lib/help.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../lib/command/api-command.js' import { inputAndOutputItem, inputAndOutputItemBuilder, @@ -36,7 +37,7 @@ const builder = (yargs: Argv): Argv => 'update the device with the given id using the data in "my-device.json"', ], ]) - .epilog(apiDocsURL('updateDevice')) + .epilog(buildEpilog({ command, apiDocs: ['updateDevice'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/installedapps.ts b/src/commands/installedapps.ts index 67e931e5..0ceb4ae9 100644 --- a/src/commands/installedapps.ts +++ b/src/commands/installedapps.ts @@ -3,10 +3,10 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type InstalledApp, type InstalledAppListOptions } from '@smartthings/core-sdk' import { withLocation, withLocations, type WithNamedLocation } from '../lib/api-helpers.js' +import { buildEpilog } from '../lib/help.js' import { apiCommand, apiCommandBuilder, - apiDocsURL, type APICommandFlags, } from '../lib/command/api-command.js' import { @@ -62,7 +62,7 @@ const builder = (yargs: Argv): Argv => 'display details for an installed app by id', ], ]) - .epilog(apiDocsURL('listInstallations', 'getInstallation')) + .epilog(buildEpilog({ command, apiDocs: ['listInstallations', 'getInstallation'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/installedschema.ts b/src/commands/installedschema.ts index 75662d2a..994377e9 100644 --- a/src/commands/installedschema.ts +++ b/src/commands/installedschema.ts @@ -3,7 +3,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type InstalledSchemaApp } from '@smartthings/core-sdk' import { withLocation, type WithNamedLocation } from '../lib/api-helpers.js' -import { apiCommand, apiCommandBuilder, type APICommandFlags, apiDocsURL } from '../lib/command/api-command.js' +import { buildEpilog } from '../lib/help.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../lib/command/api-command.js' import { outputItemOrList, outputItemOrListBuilder, @@ -57,7 +58,7 @@ const builder = (yargs: Argv): Argv => 'display details for an installed schema app by id', ], ]) - .epilog(apiDocsURL('getIsaByLocationId', 'getDevicesByIsaId')) + .epilog(buildEpilog({ command, apiDocs: ['getIsaByLocationId', 'getDevicesByIsaId'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/rules.ts b/src/commands/rules.ts index 73022b8e..407d9eb3 100644 --- a/src/commands/rules.ts +++ b/src/commands/rules.ts @@ -3,7 +3,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type Rule } from '@smartthings/core-sdk' import { type WithNamedLocation } from '../lib/api-helpers.js' -import { apiCommand, apiCommandBuilder, APICommandFlags, apiDocsURL } from '../lib/command/api-command.js' +import { buildEpilog } from '../lib/help.js' +import { apiCommand, apiCommandBuilder, APICommandFlags } from '../lib/command/api-command.js' import { outputItemOrList, outputItemOrListBuilder, @@ -39,7 +40,7 @@ const builder = (yargs: Argv): Argv => ['$0 rules 1', 'display details for the first rule in the list retrieved by running "smartthings rules"'], ['$0 rules 5dfd6626-ab1d-42da-bb76-90def3153998', 'display details for an rule by id'], ]) - .epilog(apiDocsURL('listRules', 'getRule')) + .epilog(buildEpilog({ command, apiDocs: ['listRules', 'getRule'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/rules/create.ts b/src/commands/rules/create.ts index 4c179b48..50b7a73a 100644 --- a/src/commands/rules/create.ts +++ b/src/commands/rules/create.ts @@ -2,11 +2,11 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type Rule, type RuleRequest } from '@smartthings/core-sdk' +import { buildEpilog } from '../../lib/help.js' import { apiCommand, apiCommandBuilder, type APICommandFlags, - apiDocsURL, } from '../../lib/command/api-command.js' import { inputAndOutputItem, @@ -41,7 +41,7 @@ const builder = (yargs: Argv): Argv => 'create a rule defined in "my-rule.yaml"', ], ]) - .epilog(apiDocsURL('createRule')) + .epilog(buildEpilog({ command, apiDocs: ['createRule'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/rules/delete.ts b/src/commands/rules/delete.ts index fc22a5bd..b73eb6f3 100644 --- a/src/commands/rules/delete.ts +++ b/src/commands/rules/delete.ts @@ -1,10 +1,10 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' +import { buildEpilog } from '../../lib/help.js' import { type APICommandFlags, apiCommand, apiCommandBuilder, - apiDocsURL, } from '../../lib/command/api-command.js' import { chooseRuleFn } from '../../lib/command/util/rules-choose.js' import { getRuleWithLocation } from '../../lib/command/util/rules-util.js' @@ -30,7 +30,7 @@ const builder = (yargs: Argv): Argv => 'delete the rule with the specified id', ], ]) - .epilog(apiDocsURL('deleteRule')) + .epilog(buildEpilog({ command, apiDocs: ['deleteRule'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/rules/execute.ts b/src/commands/rules/execute.ts index c0351363..0e006b10 100644 --- a/src/commands/rules/execute.ts +++ b/src/commands/rules/execute.ts @@ -2,7 +2,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type RuleExecutionResponse } from '@smartthings/core-sdk' -import { apiCommand, apiCommandBuilder, type APICommandFlags, apiDocsURL } from '../../lib/command/api-command.js' +import { buildEpilog } from '../../lib/help.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../lib/command/api-command.js' import { formatAndWriteItem, formatAndWriteItemBuilder, FormatAndWriteItemFlags } from '../../lib/command/format.js' import { chooseRuleFn } from '../../lib/command/util/rules-choose.js' import { buildExecuteResponseTableOutput } from '../../lib/command/util/rules-table.js' @@ -39,7 +40,7 @@ export const builder = (yargs: Argv): Argv => 'execute the rule with the specified id', ], ]) - .epilog(apiDocsURL('executeRule')) + .epilog(buildEpilog({ command, apiDocs: ['executeRule'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/rules/update.ts b/src/commands/rules/update.ts index 2c2f9f4e..fd5661ee 100644 --- a/src/commands/rules/update.ts +++ b/src/commands/rules/update.ts @@ -2,11 +2,11 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import type { Rule, RuleRequest } from '@smartthings/core-sdk' +import { buildEpilog } from '../../lib/help.js' import { type APICommandFlags, apiCommand, apiCommandBuilder, - apiDocsURL, } from '../../lib/command/api-command.js' import { type InputAndOutputItemFlags, @@ -48,7 +48,7 @@ const builder = (yargs: Argv): Argv => 'update the rule with the given id using the data in "my-rule.json"', ], ]) - .epilog(apiDocsURL('updateRule')) + .epilog(buildEpilog({ command, apiDocs: ['updateRule'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/scenes.ts b/src/commands/scenes.ts index 20ebf9cb..ec4efb6d 100644 --- a/src/commands/scenes.ts +++ b/src/commands/scenes.ts @@ -2,11 +2,11 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type SceneSummary, type SceneListOptions } from '@smartthings/core-sdk' +import { buildEpilog } from '../lib/help.js' import { apiCommand, apiCommandBuilder, type APICommandFlags, - apiDocsURL, } from '../lib/command/api-command.js' import { outputItemOrList, @@ -52,7 +52,7 @@ const builder = (yargs: Argv): Argv => 'list all scenes at the specified location', ], ]) - .epilog(apiDocsURL('listScenes')) + .epilog(buildEpilog({ command, apiDocs: ['listScenes'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/virtualdevices/update.ts b/src/commands/virtualdevices/update.ts index f85d5fee..408f1897 100644 --- a/src/commands/virtualdevices/update.ts +++ b/src/commands/virtualdevices/update.ts @@ -2,11 +2,11 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type Device, DeviceIntegrationType, type DeviceUpdate } from '@smartthings/core-sdk' +import { buildEpilog } from '../../lib/help.js' import { type APICommandFlags, apiCommand, apiCommandBuilder, - apiDocsURL, } from '../../lib/command/api-command.js' import { type InputAndOutputItemFlags, @@ -41,7 +41,7 @@ const builder = (yargs: Argv): Argv => 'update the virtual device with the given id using the data in "my-virtualdevice.json"', ], ]) - .epilog(apiDocsURL('updateDevice')) + .epilog(buildEpilog({ command, apiDocs: ['updateDevice'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv)