diff --git a/src/__tests__/commands/capabilities/presentation/create.test.ts b/src/__tests__/commands/capabilities/presentation/create.test.ts index 39a949646..a99e05a63 100644 --- a/src/__tests__/commands/capabilities/presentation/create.test.ts +++ b/src/__tests__/commands/capabilities/presentation/create.test.ts @@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { CapabilitiesEndpoint, CapabilityPresentationCreate, CapabilityPresentation } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../../commands/capabilities/presentation/create.js' +import type { buildEpilog } from '../../../../lib/help.js' import type { APIOrganizationCommand, apiOrganizationCommand, @@ -19,12 +20,14 @@ import type { import type { CustomCommonOutputProducer } from '../../../../lib/command/format.js' import type { chooseCapability } from '../../../../lib/command/util/capabilities-choose.js' import type { buildTableOutput } from '../../../../lib/command/util/capabilities-presentation-table.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 { apiDocsURLMock } = apiCommandMocks('../../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) const apiOrganizationCommandMock = jest.fn() const apiOrganizationCommandBuilderMock = jest.fn() @@ -85,7 +88,7 @@ test('builder', () => { .toHaveBeenCalledExactlyOnceWith(capabilityIdBuilderArgvMock) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/capabilities/presentation/update.test.ts b/src/__tests__/commands/capabilities/presentation/update.test.ts index d706fc749..00b2e1beb 100644 --- a/src/__tests__/commands/capabilities/presentation/update.test.ts +++ b/src/__tests__/commands/capabilities/presentation/update.test.ts @@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { CapabilitiesEndpoint, CapabilityPresentationUpdate, CapabilityPresentation } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../../commands/capabilities/presentation/update.js' +import type { buildEpilog } from '../../../../lib/help.js' import type { APIOrganizationCommand, apiOrganizationCommand, @@ -19,12 +20,14 @@ import type { import type { CustomCommonOutputProducer } from '../../../../lib/command/format.js' import type { chooseCapability } from '../../../../lib/command/util/capabilities-choose.js' import type { buildTableOutput } from '../../../../lib/command/util/capabilities-presentation-table.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 { apiDocsURLMock } = apiCommandMocks('../../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) const apiOrganizationCommandMock = jest.fn() const apiOrganizationCommandBuilderMock = jest.fn() @@ -85,7 +88,7 @@ test('builder', () => { .toHaveBeenCalledExactlyOnceWith(capabilityIdBuilderArgvMock) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/capabilities/translations.test.ts b/src/__tests__/commands/capabilities/translations.test.ts index 4c4b81881..761333c7b 100644 --- a/src/__tests__/commands/capabilities/translations.test.ts +++ b/src/__tests__/commands/capabilities/translations.test.ts @@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { CapabilitiesEndpoint, DeviceProfileTranslations, LocaleReference } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../commands/capabilities/translations.js' +import type { buildEpilog } from '../../../lib/help.js' import type { APIOrganizationCommand, APIOrganizationCommandFlags, @@ -20,12 +21,14 @@ import type { } from '../../../lib/command/listing-io.js' import type { chooseCapability } from '../../../lib/command/util/capabilities-choose.js' import type { buildTableOutput } from '../../../lib/command/util/capabilities-translations-table.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 { apiDocsURLMock } = apiCommandMocks('../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) const apiOrganizationCommandMock = jest.fn() const apiOrganizationCommandBuilderMock = jest.fn() @@ -87,7 +90,7 @@ test('builder', () => { expect(optionMock).toHaveBeenCalledTimes(2) expect(epilogMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/config/reset.test.ts b/src/__tests__/commands/config/reset.test.ts index 55457e0ca..8e78bf8de 100644 --- a/src/__tests__/commands/config/reset.test.ts +++ b/src/__tests__/commands/config/reset.test.ts @@ -4,6 +4,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { CommandArgs } from '../../../commands/config/reset.js' import type { resetManagedConfig } from '../../../lib/cli-config.js' +import type { buildEpilog } from '../../../lib/help.js' import type { booleanInput } from '../../../lib/user-query.js' import type { SmartThingsCommand, @@ -14,6 +15,11 @@ import type { import { buildArgvMock } from '../../test-lib/builder-mock.js' +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + const resetManagedConfigMock = jest.fn() jest.unstable_mockModule('../../../lib/cli-config.js', () => ({ resetManagedConfig: resetManagedConfigMock, @@ -53,6 +59,7 @@ test('builder', () => { expect(smartThingsCommandBuilderMock).toHaveBeenCalledExactlyOnceWith(yargsMock) expect(exampleMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/devicepreferences/translations.test.ts b/src/__tests__/commands/devicepreferences/translations.test.ts index 4e4f0684e..6b9e88bad 100644 --- a/src/__tests__/commands/devicepreferences/translations.test.ts +++ b/src/__tests__/commands/devicepreferences/translations.test.ts @@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import { DevicePreferencesEndpoint, LocaleReference, PreferenceLocalization } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../commands/devicepreferences/translations.js' +import type { buildEpilog } from '../../../lib/help.js' import type { APIOrganizationCommand, apiOrganizationCommand, @@ -20,6 +21,11 @@ import { chooseDevicePreference } from '../../../lib/command/util/devicepreferen import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js' +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + const apiOrganizationCommandMock = jest.fn() const apiOrganizationCommandBuilderMock = jest.fn() jest.unstable_mockModule('../../../lib/command/api-organization-command.js', () => ({ @@ -49,6 +55,7 @@ test('builder', () => { yargsMock: apiOrganizationCommandBuilderArgvMock, positionalMock, exampleMock, + epilogMock, argvMock, } = buildArgvMock() @@ -63,6 +70,8 @@ test('builder', () => { expect(outputItemOrListBuilderMock).toHaveBeenCalledExactlyOnceWith(apiOrganizationCommandBuilderArgvMock) expect(positionalMock).toHaveBeenCalledTimes(2) expect(exampleMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) + expect(epilogMock).toHaveBeenCalledTimes(1) }) describe('handler', () => { diff --git a/src/__tests__/commands/devicepreferences/translations/create.test.ts b/src/__tests__/commands/devicepreferences/translations/create.test.ts index bea0c3b5b..a7bf226d9 100644 --- a/src/__tests__/commands/devicepreferences/translations/create.test.ts +++ b/src/__tests__/commands/devicepreferences/translations/create.test.ts @@ -9,6 +9,7 @@ import type { } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../../commands/devicepreferences/translations/create.js' +import type { buildEpilog } from '../../../../lib/help.js' import type { APIOrganizationCommand, APIOrganizationCommandFlags, @@ -26,6 +27,11 @@ import { import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock.js' +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + const apiOrganizationCommandMock = jest.fn() const apiOrganizationCommandBuilderMock = jest.fn() jest.unstable_mockModule('../../../../lib/command/api-organization-command.js', () => ({ @@ -57,6 +63,7 @@ test('builder', () => { yargsMock: apiOrganizationCommandBuilderArgvMock, positionalMock, exampleMock, + epilogMock, argvMock, } = buildArgvMock() @@ -73,6 +80,8 @@ test('builder', () => { expect(exampleMock).toHaveBeenCalledTimes(1) expect(positionalMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) + expect(epilogMock).toHaveBeenCalledTimes(1) }) test('handler', async () => { diff --git a/src/__tests__/commands/devicepreferences/translations/update.test.ts b/src/__tests__/commands/devicepreferences/translations/update.test.ts index 893838b64..1a8def153 100644 --- a/src/__tests__/commands/devicepreferences/translations/update.test.ts +++ b/src/__tests__/commands/devicepreferences/translations/update.test.ts @@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import { DevicePreferencesEndpoint, PreferenceLocalization } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../../commands/devicepreferences/translations/update.js' +import type { buildEpilog } from '../../../../lib/help.js' import type { APIOrganizationCommand, apiOrganizationCommand, @@ -20,6 +21,11 @@ import { tableFieldDefinitions } from '../../../../lib/command/util/deviceprefer import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock.js' +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + const apiOrganizationCommandMock = jest.fn() const apiOrganizationCommandBuilderMock = jest.fn() jest.unstable_mockModule('../../../../lib/command/api-organization-command.js', () => ({ @@ -50,6 +56,7 @@ test('builder', () => { yargsMock: apiOrganizationCommandBuilderArgvMock, positionalMock, exampleMock, + epilogMock, argvMock, } = buildArgvMock() @@ -66,6 +73,8 @@ test('builder', () => { expect(exampleMock).toHaveBeenCalledTimes(1) expect(positionalMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) + expect(epilogMock).toHaveBeenCalledTimes(1) }) test('handler', async () => { diff --git a/src/__tests__/commands/edge/channels/metainfo.test.ts b/src/__tests__/commands/edge/channels/metainfo.test.ts index fb032d46e..615ee3831 100644 --- a/src/__tests__/commands/edge/channels/metainfo.test.ts +++ b/src/__tests__/commands/edge/channels/metainfo.test.ts @@ -6,6 +6,7 @@ import type { CommandArgs } from '../../../../commands/edge/channels/metainfo.js import { ChannelsEndpoint, DriverChannelDetails, EdgeDriver } 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 { outputItemOrList, outputItemOrListBuilder } from '../../../../lib/command/listing-io.js' @@ -16,6 +17,11 @@ import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock import { tableGeneratorMock } from '../../../test-lib/table-mock.js' +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../../..') const outputItemOrListMock = jest.fn>() @@ -47,6 +53,7 @@ test('builder', async () => { positionalMock, optionMock, exampleMock, + epilogMock, argvMock, } = buildArgvMock() @@ -62,6 +69,8 @@ test('builder', async () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(optionMock).toHaveBeenCalledTimes(1) expect(exampleMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) + expect(epilogMock).toHaveBeenCalledTimes(1) }) describe('handler', () => { diff --git a/src/__tests__/commands/edge/drivers/default.test.ts b/src/__tests__/commands/edge/drivers/default.test.ts index 316fea3ba..99bf53125 100644 --- a/src/__tests__/commands/edge/drivers/default.test.ts +++ b/src/__tests__/commands/edge/drivers/default.test.ts @@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { DriversEndpoint, EdgeDriver } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../../commands/edge/drivers/default.js' +import type { buildEpilog } from '../../../../lib/help.js' import type { fatalError } from '../../../../lib/util.js' import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js' import type { CustomCommonOutputProducer } from '../../../../lib/command/format.js' @@ -15,12 +16,17 @@ import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock import { tableGeneratorMock } from '../../../test-lib/table-mock.js' +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + const fatalErrorMock = jest.fn().mockReturnValue('never return' as never) jest.unstable_mockModule('../../../../lib/util.js', () => ({ fatalError: fatalErrorMock, })) -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../../..') +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../../..') const outputItemOrListMock = jest.fn>() const outputItemOrListBuilderMock = jest.fn() @@ -62,7 +68,7 @@ test('builder', async () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(optionMock).toHaveBeenCalledTimes(0) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/edge/drivers/delete.test.ts b/src/__tests__/commands/edge/drivers/delete.test.ts index 9550676e7..1683b1fe8 100644 --- a/src/__tests__/commands/edge/drivers/delete.test.ts +++ b/src/__tests__/commands/edge/drivers/delete.test.ts @@ -5,13 +5,19 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { DriversEndpoint } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../../commands/edge/drivers/delete.js' +import type { buildEpilog } from '../../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js' import type { chooseDriver } from '../../../../lib/command/util/drivers-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 chooseDriverMock = jest.fn().mockResolvedValue('chosen-driver-id') jest.unstable_mockModule('../../../../lib/command/util/drivers-choose.js', () => ({ @@ -44,7 +50,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(optionMock).toHaveBeenCalledTimes(0) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/edge/drivers/install.test.ts b/src/__tests__/commands/edge/drivers/install.test.ts index 13972acb4..ab03ee38d 100644 --- a/src/__tests__/commands/edge/drivers/install.test.ts +++ b/src/__tests__/commands/edge/drivers/install.test.ts @@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { EnrolledChannel, HubdevicesEndpoint } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../../commands/edge/drivers/install.js' +import type { buildEpilog } from '../../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js' import type { selectFromList } from '../../../../lib/command/select.js' import type { chooseDriverFromChannelFn } from '../../../../lib/command/util/drivers-choose.js' @@ -15,7 +16,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 selectFromListMock = jest.fn() jest.unstable_mockModule('../../../../lib/command/select.js', () => ({ @@ -61,7 +67,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/edge/drivers/installed.test.ts b/src/__tests__/commands/edge/drivers/installed.test.ts index fac4a7862..7aff2197a 100644 --- a/src/__tests__/commands/edge/drivers/installed.test.ts +++ b/src/__tests__/commands/edge/drivers/installed.test.ts @@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { HubdevicesEndpoint, InstalledDriver } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../../commands/edge/drivers/installed.js' +import type { buildEpilog } from '../../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js' import type { TableCommonOutputProducer } from '../../../../lib/command/format.js' import type { outputItemOrList, outputItemOrListBuilder } 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 outputItemOrListMock = jest.fn>() const outputItemOrListBuilderMock = jest.fn() @@ -60,7 +66,7 @@ test('builder', async () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(optionMock).toHaveBeenCalledTimes(3) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/edge/drivers/package.test.ts b/src/__tests__/commands/edge/drivers/package.test.ts index 20a690470..4718bd163 100644 --- a/src/__tests__/commands/edge/drivers/package.test.ts +++ b/src/__tests__/commands/edge/drivers/package.test.ts @@ -15,6 +15,7 @@ import type { } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../../commands/edge/drivers/package.js' +import type { buildEpilog } from '../../../../lib/help.js' import type { CLIConfig } from '../../../../lib/cli-config.js' import type { fatalError } from '../../../../lib/util.js' import type { APICommand } from '../../../../lib/command/api-command.js' @@ -35,6 +36,11 @@ import { apiCommandMocks } from '../../../test-lib/api-command-mock.js' import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock.js' +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + const fatalErrorMock = jest.fn() jest.unstable_mockModule('../../../../lib/util.js', () => ({ fatalError: fatalErrorMock, @@ -67,7 +73,7 @@ jest.unstable_mockModule('jszip', () => ({ default: JSZipMock, })) -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../../..') +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../../..') const outputItemMock = jest.fn() const outputItemBuilderMock = jest.fn() @@ -137,7 +143,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(optionMock).toHaveBeenCalledTimes(6) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/edge/drivers/switch.test.ts b/src/__tests__/commands/edge/drivers/switch.test.ts index 3e123fcf9..9f2d48ada 100644 --- a/src/__tests__/commands/edge/drivers/switch.test.ts +++ b/src/__tests__/commands/edge/drivers/switch.test.ts @@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import { type Device, DeviceIntegrationType, type HubdevicesEndpoint } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../../commands/edge/drivers/switch.js' +import type { buildEpilog } from '../../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js' import type { chooseDeviceFn } from '../../../../lib/command/util/devices-choose.js' import type { chooseDriver } from '../../../../lib/command/util/drivers-choose.js' @@ -20,7 +21,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 chooseDeviceMock = jest.fn>().mockResolvedValue('chosen-device') const chooseDeviceFnMock = jest.fn().mockReturnValue(chooseDeviceMock) @@ -72,7 +78,7 @@ test('builder', () => { expect(positionalMock).toHaveBeenCalledTimes(1) expect(optionMock).toHaveBeenCalledTimes(3) expect(exampleMock).toHaveBeenCalledTimes(1) - expect(apiDocsURLMock).toHaveBeenCalledTimes(1) + expect(buildEpilogMock).toHaveBeenCalledTimes(1) expect(epilogMock).toHaveBeenCalledTimes(1) }) diff --git a/src/__tests__/commands/edge/drivers/uninstall.test.ts b/src/__tests__/commands/edge/drivers/uninstall.test.ts index 567ec574e..4a02ea449 100644 --- a/src/__tests__/commands/edge/drivers/uninstall.test.ts +++ b/src/__tests__/commands/edge/drivers/uninstall.test.ts @@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type{ Device, HubdevicesEndpoint, InstalledDriver } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../../commands/edge/drivers/uninstall.js' +import type { buildEpilog } from '../../../../lib/help.js' import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js' import type { chooseDriverFromChannelFn } from '../../../../lib/command/util/drivers-choose.js' import type { DriverChannelDetailsWithName } from '../../../../lib/command/util/edge-drivers.js' @@ -15,7 +16,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 chooseDriverFromChannelMock = jest.fn>() .mockResolvedValue('driver-id-chosen-from-channel') @@ -62,7 +68,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/installedapps/delete.test.ts b/src/__tests__/commands/installedapps/delete.test.ts index fb89f3fce..c546c9147 100644 --- a/src/__tests__/commands/installedapps/delete.test.ts +++ b/src/__tests__/commands/installedapps/delete.test.ts @@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import { InstalledApp, type InstalledAppsEndpoint, type SmartThingsClient } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../commands/installedapps/delete.js' +import type { buildEpilog } from '../../../lib/help.js' import type { chooseInstalledAppFn } from '../../../lib/command/util/installedapps-util.js' import type { ChooseFunction } from '../../../lib/command/util/util-util.js' import { apiCommandMocks } from '../../test-lib/api-command-mock.js' @@ -12,7 +13,12 @@ import { buildArgvMock } from '../../test-lib/builder-mock.js' import { APICommand } from '../../../lib/command/api-command.js' -const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..') +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + +const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..') const chooseInstalledAppMock = jest.fn>() const chooseInstalledAppFnMock = jest.fn() @@ -46,7 +52,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/rename.test.ts b/src/__tests__/commands/installedapps/rename.test.ts index 395a1df34..59e0e95a5 100644 --- a/src/__tests__/commands/installedapps/rename.test.ts +++ b/src/__tests__/commands/installedapps/rename.test.ts @@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { InstalledApp, InstalledAppsEndpoint } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../commands/installedapps/rename.js' +import type { buildEpilog } from '../../../lib/help.js' import type { WithNamedLocation } from '../../../lib/api-helpers.js' import type { stringInput } from '../../../lib/user-query.js' import type { APICommand } from '../../../lib/command/api-command.js' @@ -18,6 +19,11 @@ import { apiCommandMocks } from '../../test-lib/api-command-mock.js' import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js' +const buildEpilogMock = jest.fn() +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) + const stringInputMock = jest.fn() jest.unstable_mockModule('../../../lib/user-query.js', () => ({ stringInput: stringInputMock, @@ -47,6 +53,7 @@ test('builder', () => { yargsMock: apiCommandBuilderArgvMock, positionalMock, exampleMock, + epilogMock, argvMock, } = buildArgvMock() @@ -61,6 +68,8 @@ test('builder', () => { expect(formatAndWriteItemBuilderMock).toHaveBeenCalledExactlyOnceWith(apiCommandBuilderArgvMock) expect(positionalMock).toHaveBeenCalledOnce() expect(exampleMock).toHaveBeenCalledOnce() + expect(buildEpilogMock).toHaveBeenCalledOnce() + expect(epilogMock).toHaveBeenCalledOnce() }) describe('handler', () => { diff --git a/src/__tests__/commands/schema/regenerate.test.ts b/src/__tests__/commands/schema/regenerate.test.ts index 7a24a4509..87677f3f5 100644 --- a/src/__tests__/commands/schema/regenerate.test.ts +++ b/src/__tests__/commands/schema/regenerate.test.ts @@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs' import type { SchemaEndpoint, SchemaCreateResponse } from '@smartthings/core-sdk' import type { CommandArgs } from '../../../commands/schema/regenerate.js' +import type { buildEpilog } from '../../../lib/help.js' import type { APIOrganizationCommand, apiOrganizationCommand, @@ -13,12 +14,13 @@ import type { } from '../../../lib/command/api-organization-command.js' import type { outputItem, outputItemBuilder } from '../../../lib/command/output-item.js' import type { chooseSchemaApp } from '../../../lib/command/util/schema-util.js' -import type { buildEpilog } from '../../../lib/help.js' import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js' const buildEpilogMock = jest.fn() -jest.unstable_mockModule('../../../lib/help.js', () => ({ buildEpilog: buildEpilogMock })) +jest.unstable_mockModule('../../../lib/help.js', () => ({ + buildEpilog: buildEpilogMock, +})) const apiOrganizationCommandMock = jest.fn() const apiOrganizationCommandBuilderMock = jest.fn() diff --git a/src/commands/capabilities/namespaces.ts b/src/commands/capabilities/namespaces.ts index 7485525dd..a1dcc261c 100644 --- a/src/commands/capabilities/namespaces.ts +++ b/src/commands/capabilities/namespaces.ts @@ -2,6 +2,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type CapabilityNamespace } from '@smartthings/core-sdk' +import { buildEpilog } from '../../lib/help.js' import { apiOrganizationCommand, apiOrganizationCommandBuilder, @@ -31,6 +32,7 @@ const builder = (yargs: Argv): Argv => 'list namespaces', ], ]) + .epilog(buildEpilog({ command })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/capabilities/presentation/create.ts b/src/commands/capabilities/presentation/create.ts index 7e822e8c7..13e2c4b6b 100644 --- a/src/commands/capabilities/presentation/create.ts +++ b/src/commands/capabilities/presentation/create.ts @@ -2,7 +2,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type CapabilityPresentationCreate, type CapabilityPresentation } from '@smartthings/core-sdk' -import { apiDocsURL } from '../../../lib/command/api-command.js' +import { buildEpilog } from '../../../lib/help.js' import { apiOrganizationCommand, apiOrganizationCommandBuilder, @@ -39,7 +39,7 @@ const builder = (yargs: Argv): Argv => 'create a presentation for cathappy12345.myCapability defined in presentation.json', ], ]) - .epilog(apiDocsURL('createCustomCapabilityPresentation')) + .epilog(buildEpilog({ command, apiDocs: 'createCustomCapabilityPresentation' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/capabilities/presentation/update.ts b/src/commands/capabilities/presentation/update.ts index 83b8a4eec..c38e9ef27 100644 --- a/src/commands/capabilities/presentation/update.ts +++ b/src/commands/capabilities/presentation/update.ts @@ -2,7 +2,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { CapabilityPresentation, type CapabilityPresentationUpdate } from '@smartthings/core-sdk' -import { apiDocsURL } from '../../../lib/command/api-command.js' +import { buildEpilog } from '../../../lib/help.js' import { apiOrganizationCommand, apiOrganizationCommandBuilder, @@ -39,7 +39,7 @@ const builder = (yargs: Argv): Argv => 'update the presentation for capability cathappy12345.myCapability with the one defined in presentation.json', ], ]) - .epilog(apiDocsURL('updateCustomCapabilityPresentation')) + .epilog(buildEpilog({ command, apiDocs: 'updateCustomCapabilityPresentation' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/capabilities/translations.ts b/src/commands/capabilities/translations.ts index 366927a86..4b0fd49f5 100644 --- a/src/commands/capabilities/translations.ts +++ b/src/commands/capabilities/translations.ts @@ -6,7 +6,7 @@ import { } from '@smartthings/core-sdk' import { type WithLocales } from '../../lib/api-helpers.js' -import { apiDocsURL } from '../../lib/command/api-command.js' +import { buildEpilog } from '../../lib/help.js' import { apiOrganizationCommand, apiOrganizationCommandBuilder, @@ -73,7 +73,7 @@ export const builder = (yargs: Argv): Argv => ' "smartthings capabilities"', ], ]) - .epilog(apiDocsURL('listCapabilityLocalizations', 'getCapabilityLocalization')) + .epilog(buildEpilog({ command, apiDocs: ['listCapabilityLocalizations', 'getCapabilityLocalization'] })) export type CapabilitySummaryWithLocales = CapabilitySummaryWithNamespace & WithLocales diff --git a/src/commands/config/reset.ts b/src/commands/config/reset.ts index 12b5ec21e..52ba5f41b 100644 --- a/src/commands/config/reset.ts +++ b/src/commands/config/reset.ts @@ -7,6 +7,7 @@ import { smartThingsCommandBuilder, type SmartThingsCommandFlags, } from '../../lib/command/smartthings-command.js' +import { buildEpilog } from '../../lib/help.js' export type CommandArgs = @@ -22,8 +23,11 @@ const builder = (yargs: Argv): Argv => ['$0 config:reset', 'reset cli-managed configuration for the default profile'], ['$0 config:reset --profile hub2', 'reset cli-managed configuration for the profile named "hub2"'], ]) - .epilog('The CLI will occasionally ask you if you want it to remember the answer to a question, such as ' + - '"Which hub do you want to use?" You can use this command to clear those answers.') + .epilog(buildEpilog({ + command, + notes: 'The CLI will occasionally ask you if you want it to remember the answer to a question, such as ' + + '"Which hub do you want to use?" You can use this command to clear those answers.', + })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await smartThingsCommand(argv) diff --git a/src/commands/devicepreferences/create.ts b/src/commands/devicepreferences/create.ts index 50b81055f..ff99442dd 100644 --- a/src/commands/devicepreferences/create.ts +++ b/src/commands/devicepreferences/create.ts @@ -3,7 +3,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type DevicePreferenceCreate, type PreferenceType } from '@smartthings/core-sdk' -import { apiDocsURL } from '../../lib/command/api-command.js' +import { buildEpilog } from '../../lib/help.js' import { apiOrganizationCommand, apiOrganizationCommandBuilder, @@ -55,7 +55,7 @@ const builder = (yargs: Argv): Argv => 'create a new device preference defined by the file dp.json and write the results to dp-saved.json', ], ]) - .epilog(apiDocsURL('createPreference')) + .epilog(buildEpilog({ command, apiDocs: ['createPreference'] })) const getInputFromUser = async (): Promise => { const validateName: ValidateFunction = input => !input || input.match(/^[a-z][a-zA-Z0-9]{2,23}$/) diff --git a/src/commands/devicepreferences/translations.ts b/src/commands/devicepreferences/translations.ts index f70b41e6a..ae0354ff4 100644 --- a/src/commands/devicepreferences/translations.ts +++ b/src/commands/devicepreferences/translations.ts @@ -2,6 +2,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type LocaleReference, type PreferenceLocalization } from '@smartthings/core-sdk' +import { buildEpilog } from '../../lib/help.js' import { apiOrganizationCommand, apiOrganizationCommandBuilder, @@ -50,6 +51,7 @@ const builder = (yargs: Argv): Argv => 'display translations for the specified device preference id and locale', ], ]) + .epilog(buildEpilog({ command })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/devicepreferences/translations/create.ts b/src/commands/devicepreferences/translations/create.ts index 61651f48a..cbe3aad27 100644 --- a/src/commands/devicepreferences/translations/create.ts +++ b/src/commands/devicepreferences/translations/create.ts @@ -2,6 +2,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type PreferenceLocalization } from '@smartthings/core-sdk' +import { buildEpilog } from '../../../lib/help.js' import { apiOrganizationCommand, apiOrganizationCommandBuilder, @@ -38,6 +39,7 @@ const builder = (yargs: Argv): Argv => 'create a translation as defined in preferenceTranslation.json', ], ]) + .epilog(buildEpilog({ command })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/devicepreferences/translations/update.ts b/src/commands/devicepreferences/translations/update.ts index 17ba226c2..58e097550 100644 --- a/src/commands/devicepreferences/translations/update.ts +++ b/src/commands/devicepreferences/translations/update.ts @@ -2,6 +2,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type PreferenceLocalization } from '@smartthings/core-sdk' +import { buildEpilog } from '../../../lib/help.js' import { apiOrganizationCommand, apiOrganizationCommandBuilder, @@ -40,6 +41,7 @@ const builder = (yargs: Argv): Argv => 'update the translation defined in en.yaml for the "cathappy12345.myPreference" device preference', ], ]) + .epilog(buildEpilog({ command })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/devicepreferences/update.ts b/src/commands/devicepreferences/update.ts index 0dd1c6d1b..96f87a8fd 100644 --- a/src/commands/devicepreferences/update.ts +++ b/src/commands/devicepreferences/update.ts @@ -2,7 +2,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type DevicePreference } from '@smartthings/core-sdk' -import { apiDocsURL } from '../../lib/command/api-command.js' +import { buildEpilog } from '../../lib/help.js' import { apiOrganizationCommand, apiOrganizationCommandBuilder, @@ -40,7 +40,7 @@ const builder = (yargs: Argv): Argv => 'update specified device preference with data from dp.yaml', ], ]) - .epilog(apiDocsURL('updatePreferenceById')) + .epilog(buildEpilog({ command, apiDocs: ['updatePreferenceById'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiOrganizationCommand(argv) diff --git a/src/commands/edge/channels/assign.ts b/src/commands/edge/channels/assign.ts index 357849686..024af8033 100644 --- a/src/commands/edge/channels/assign.ts +++ b/src/commands/edge/channels/assign.ts @@ -1,7 +1,7 @@ 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 { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../../lib/command/api-command.js' import { chooseChannel } from '../../../lib/command/util/edge/channels-choose.js' import { chooseDriver } from '../../../lib/command/util/drivers-choose.js' @@ -39,7 +39,7 @@ const builder = (yargs: Argv): Argv => 'assign the specified driver to the specified channel', ], ]) - .epilog(apiDocsURL('createDriverChannel')) + .epilog(buildEpilog({ command, apiDocs: 'createDriverChannel' })) const handler = async (argv: ArgumentsCamelCase): Promise => { diff --git a/src/commands/edge/channels/enroll.ts b/src/commands/edge/channels/enroll.ts index 444b977e2..5823da081 100644 --- a/src/commands/edge/channels/enroll.ts +++ b/src/commands/edge/channels/enroll.ts @@ -1,5 +1,6 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' +import { buildEpilog } from '../../../lib/help.js' import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../../lib/command/api-command.js' import { chooseChannelFn } from '../../../lib/command/util/edge/channels-choose.js' import { chooseHub } from '../../../lib/command/util/hubs-choose.js' @@ -28,6 +29,7 @@ const builder = (yargs: Argv): Argv => 'enroll the specified hub in the specified channel', ], ]) + .epilog(buildEpilog({ command })) const handler = async (argv: ArgumentsCamelCase): Promise => { diff --git a/src/commands/edge/channels/metainfo.ts b/src/commands/edge/channels/metainfo.ts index 91e1ee7df..605463fda 100644 --- a/src/commands/edge/channels/metainfo.ts +++ b/src/commands/edge/channels/metainfo.ts @@ -2,6 +2,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import type { EdgeDriver } from '@smartthings/core-sdk' +import { buildEpilog } from '../../../lib/help.js' import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../../lib/command/api-command.js' import { outputItemOrList, @@ -48,6 +49,7 @@ const builder = (yargs: Argv): Argv => 'display metainfo about a driver by using its channel and id', ], ]) + .epilog(buildEpilog({ command })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/edge/channels/unassign.ts b/src/commands/edge/channels/unassign.ts index f6fc402bd..1b98ddaee 100644 --- a/src/commands/edge/channels/unassign.ts +++ b/src/commands/edge/channels/unassign.ts @@ -1,6 +1,7 @@ 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 { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../../lib/command/api-command.js' import { chooseChannelFn } from '../../../lib/command/util/edge/channels-choose.js' import { chooseDriverFromChannelFn } from '../../../lib/command/util/drivers-choose.js' @@ -36,7 +37,7 @@ const builder = (yargs: Argv): Argv => 'remove the specified driver from the specified channel', ], ]) - .epilog(apiDocsURL('deleteDriverChannel')) + .epilog(buildEpilog({ command, apiDocs: 'deleteDriverChannel' })) const handler = async (argv: ArgumentsCamelCase): Promise => { diff --git a/src/commands/edge/channels/unenroll.ts b/src/commands/edge/channels/unenroll.ts index 3b65636d1..eb8f5271c 100644 --- a/src/commands/edge/channels/unenroll.ts +++ b/src/commands/edge/channels/unenroll.ts @@ -2,8 +2,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type Device } from '@smartthings/core-sdk' +import { buildEpilog } from '../../../lib/help.js' import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../../lib/command/api-command.js' - import { chooseChannelFn } from '../../../lib/command/util/edge/channels-choose.js' import { listOwnedHubs } from '../../../lib/command/util/hubs.js' import { chooseHub } from '../../../lib/command/util/hubs-choose.js' @@ -38,6 +38,7 @@ const builder = (yargs: Argv): Argv => 'unenroll the specified hub from the specified channel', ], ]) + .epilog(buildEpilog({ command })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/edge/drivers/default.ts b/src/commands/edge/drivers/default.ts index c99a565c3..26c58719a 100644 --- a/src/commands/edge/drivers/default.ts +++ b/src/commands/edge/drivers/default.ts @@ -2,8 +2,9 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type EdgeDriver } from '@smartthings/core-sdk' +import { buildEpilog } from '../../../lib/help.js' import { fatalError } from '../../../lib/util.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, @@ -39,7 +40,7 @@ const builder = (yargs: Argv): Argv => 'display details for a default driver by id', ], ]) - .epilog(apiDocsURL('getDefaultDrivers')) + .epilog(buildEpilog({ command, apiDocs: 'getDefaultDrivers' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/edge/drivers/delete.ts b/src/commands/edge/drivers/delete.ts index 28e507123..42a95f13e 100644 --- a/src/commands/edge/drivers/delete.ts +++ b/src/commands/edge/drivers/delete.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 { buildEpilog } from '../../../lib/help.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../../lib/command/api-command.js' import { chooseDriver } from '../../../lib/command/util/drivers-choose.js' @@ -24,7 +25,7 @@ const builder = (yargs: Argv): Argv => 'delete the specified driver', ], ]) - .epilog(apiDocsURL('deleteDriver')) + .epilog(buildEpilog({ command, apiDocs: 'deleteDriver' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/edge/drivers/devices.ts b/src/commands/edge/drivers/devices.ts index 0333708e8..9fa5ff58e 100644 --- a/src/commands/edge/drivers/devices.ts +++ b/src/commands/edge/drivers/devices.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 { buildEpilog } from '../../../lib/help.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../../lib/command/api-command.js' import { outputItemOrList, outputItemOrListBuilder, @@ -47,7 +48,7 @@ const builder = (yargs: Argv): Argv => 'list devices that use the specified driver', ], ]) - .epilog(apiDocsURL('getDevices', 'listDrivers', 'getDriver', 'getDriverRevision')) + .epilog(buildEpilog({ command, apiDocs: ['getDevices', 'listDrivers', 'getDriver', 'getDriverRevision'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/edge/drivers/install.ts b/src/commands/edge/drivers/install.ts index 99524f9ea..47b86323b 100644 --- a/src/commands/edge/drivers/install.ts +++ b/src/commands/edge/drivers/install.ts @@ -2,7 +2,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type EnrolledChannel } 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 { selectFromList, type SelectFromListConfig } from '../../../lib/command/select.js' import { chooseDriverFromChannelFn } from '../../../lib/command/util/drivers-choose.js' import { chooseHub } from '../../../lib/command/util/hubs-choose.js' @@ -38,7 +39,7 @@ const builder = (yargs: Argv): Argv => 'install a driver from a channel on an enrolled hub', ], ]) - .epilog(apiDocsURL('installDrivers')) + .epilog(buildEpilog({ command, apiDocs: 'installDrivers' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/edge/drivers/installed.ts b/src/commands/edge/drivers/installed.ts index 1e732aa0b..43144e1ed 100644 --- a/src/commands/edge/drivers/installed.ts +++ b/src/commands/edge/drivers/installed.ts @@ -2,7 +2,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type InstalledDriver } 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 { outputItemOrList, outputItemOrListBuilder, @@ -48,7 +49,7 @@ const builder = (yargs: Argv): Argv => 'display details for an installed driver by id', ], ]) - .epilog(apiDocsURL('listHubInstalledDrivers', 'getHubDeviceDriver')) + .epilog(buildEpilog({ command, apiDocs: ['listHubInstalledDrivers', 'getHubDeviceDriver'] })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/edge/drivers/logcat.ts b/src/commands/edge/drivers/logcat.ts index 9032f337d..efd089de0 100644 --- a/src/commands/edge/drivers/logcat.ts +++ b/src/commands/edge/drivers/logcat.ts @@ -11,6 +11,7 @@ import { fetch, Agent } from 'undici' import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { green, red } from '../../../lib/colors.js' +import { buildEpilog } from '../../../lib/help.js' import { type DriverInfo, handleConnectionErrors, @@ -87,6 +88,7 @@ const builder = (yargs: Argv): Argv => 'log for all drivers on hub with IP address 192.168.1.13', ], ]) + .epilog(buildEpilog({ command })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/edge/drivers/package.ts b/src/commands/edge/drivers/package.ts index 038da4d81..93fa5cdf7 100644 --- a/src/commands/edge/drivers/package.ts +++ b/src/commands/edge/drivers/package.ts @@ -6,8 +6,9 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type EdgeDriver } from '@smartthings/core-sdk' +import { buildEpilog } from '../../../lib/help.js' import { fatalError } from '../../../lib/util.js' -import { apiCommand, apiCommandBuilder, apiDocsURL, type APICommandFlags } from '../../../lib/command/api-command.js' +import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../../lib/command/api-command.js' import { outputItem, outputItemBuilder, type OutputItemConfig } from '../../../lib/command/output-item.js' import { buildTestFileMatchers, @@ -123,7 +124,7 @@ const builder = (yargs: Argv): Argv => 'upload the previously built driver found in driver.zip', ], ]) - .epilog(apiDocsURL('uploadDriverPackage')) + .epilog(buildEpilog({ command, apiDocs: 'uploadDriverPackage' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/edge/drivers/prune.ts b/src/commands/edge/drivers/prune.ts index 97dafb666..d8d8179ed 100644 --- a/src/commands/edge/drivers/prune.ts +++ b/src/commands/edge/drivers/prune.ts @@ -3,8 +3,9 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type InstalledDriver } from '@smartthings/core-sdk' +import { buildEpilog } from '../../../lib/help.js' import { booleanInput } from '../../../lib/user-query.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 { formatAndWriteItem, type FormatAndWriteItemConfig } from '../../../lib/command/format.js' import { getDriverDevices } from '../../../lib/command/util/edge-drivers.js' import { chooseHub } from '../../../lib/command/util/hubs-choose.js' @@ -30,7 +31,7 @@ const builder = (yargs: Argv): Argv => 'prune drivers on the specified hub', ], ]) - .epilog(apiDocsURL('uninstallDriver')) + .epilog(buildEpilog({ command, apiDocs: 'uninstallDriver' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/edge/drivers/switch.ts b/src/commands/edge/drivers/switch.ts index 7f3074b2c..ebfa3d966 100644 --- a/src/commands/edge/drivers/switch.ts +++ b/src/commands/edge/drivers/switch.ts @@ -2,7 +2,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type Device, DeviceIntegrationType } 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 { chooseDeviceFn } from '../../../lib/command/util/devices-choose.js' import { chooseDriver } from '../../../lib/command/util/drivers-choose.js' import { edgeDeviceTypes, listAllAvailableDrivers, listMatchingDrivers } from '../../../lib/command/util/edge-drivers.js' @@ -48,7 +49,7 @@ const builder = (yargs: Argv): Argv => "include all available drivers in prompt, even if they don't match the chosen device", ], ]) - .epilog(apiDocsURL('updateHubDevice')) + .epilog(buildEpilog({ command, apiDocs: 'updateHubDevice' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/edge/drivers/uninstall.ts b/src/commands/edge/drivers/uninstall.ts index e364da095..885321318 100644 --- a/src/commands/edge/drivers/uninstall.ts +++ b/src/commands/edge/drivers/uninstall.ts @@ -2,7 +2,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type InstalledDriver } 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 { chooseDriver } from '../../../lib/command/util/drivers-choose.js' import { chooseHubFn } from '../../../lib/command/util/hubs-choose.js' @@ -29,7 +30,7 @@ const builder = (yargs: Argv): Argv => 'uninstall the specified driver', ], ]) - .epilog(apiDocsURL('uninstallDriver')) + .epilog(buildEpilog({ command, apiDocs: 'uninstallDriver' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/installedapps/delete.ts b/src/commands/installedapps/delete.ts index a31d1e792..3dcef0a5f 100644 --- a/src/commands/installedapps/delete.ts +++ b/src/commands/installedapps/delete.ts @@ -2,7 +2,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type InstalledAppListOptions } 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 { chooseInstalledAppFn } from '../../lib/command/util/installedapps-util.js' @@ -36,7 +37,7 @@ const builder = (yargs: Argv): Argv => 'delete the installed app with the specified id', ], ]) - .epilog(apiDocsURL('deleteInstallation')) + .epilog(buildEpilog({ command, apiDocs: 'deleteInstallation' })) const handler = async (argv: ArgumentsCamelCase): Promise => { diff --git a/src/commands/installedapps/rename.ts b/src/commands/installedapps/rename.ts index 6aaf59580..925db31b2 100644 --- a/src/commands/installedapps/rename.ts +++ b/src/commands/installedapps/rename.ts @@ -2,6 +2,7 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import { type InstalledAppListOptions } from '@smartthings/core-sdk' +import { buildEpilog } from '../../lib/help.js' import { stringInput } from '../../lib/user-query.js' import { apiCommand, apiCommandBuilder, type APICommandFlags } from '../../lib/command/api-command.js' import { @@ -49,6 +50,7 @@ export const builder = (yargs: Argv): Argv => 'rename the installed app with the specified id to "New Name"', ], ]) + .epilog(buildEpilog({ command })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv) diff --git a/src/commands/installedschema/delete.ts b/src/commands/installedschema/delete.ts index 3e8eaf6bb..761016458 100644 --- a/src/commands/installedschema/delete.ts +++ b/src/commands/installedschema/delete.ts @@ -3,7 +3,8 @@ import { type ArgumentsCamelCase, type Argv, type CommandModule } from 'yargs' import type { InstalledSchemaApp } from '@smartthings/core-sdk' import { 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 { selectFromList, SelectFromListConfig } from '../../lib/command/select.js' import { installedSchemaInstances } from '../../lib/command/util/installedschema-util.js' @@ -38,7 +39,7 @@ const builder = (yargs: Argv): Argv => 'delete the installed Schema App with the specified id', ], ]) - .epilog(apiDocsURL('deleteIsaByIsaId')) + .epilog(buildEpilog({ command, apiDocs: 'deleteIsaByIsaId' })) const handler = async (argv: ArgumentsCamelCase): Promise => { const command = await apiCommand(argv)