Skip to content

Commit 9775eb7

Browse files
committed
feat: add buildEpilog to rest of commands and removed old apiDocsURL
1 parent 576800a commit 9775eb7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+219
-117
lines changed

src/__tests__/commands/capabilities/presentation.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
55
import type { CapabilitiesEndpoint, SmartThingsClient, CapabilityPresentation } from '@smartthings/core-sdk'
66

77
import type { CommandArgs } from '../../../commands/capabilities/presentation.js'
8+
import type { buildEpilog } from '../../../lib/help.js'
89
import type {
910
APIOrganizationCommand,
1011
APIOrganizationCommandFlags,
@@ -18,12 +19,14 @@ import type {
1819
import type { CustomCommonOutputProducer, formatAndWriteItem, formatAndWriteItemBuilder } from '../../../lib/command/format.js'
1920
import { chooseCapability } from '../../../lib/command/util/capabilities-choose.js'
2021
import { buildTableOutput } from '../../../lib/command/util/capabilities-presentation-table.js'
21-
import { apiCommandMocks } from '../../test-lib/api-command-mock.js'
2222
import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js'
2323
import { tableGeneratorMock } from '../../test-lib/table-mock.js'
2424

2525

26-
const { apiDocsURLMock } = apiCommandMocks('../../..')
26+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
27+
jest.unstable_mockModule('../../../lib/help.js', () => ({
28+
buildEpilog: buildEpilogMock,
29+
}))
2730

2831
const apiOrganizationCommandMock = jest.fn<typeof apiOrganizationCommand>()
2932
const apiOrganizationCommandBuilderMock = jest.fn<typeof apiOrganizationCommandBuilder>()
@@ -85,7 +88,7 @@ test('builder', () => {
8588

8689
expect(exampleMock).toHaveBeenCalledTimes(1)
8790
expect(optionMock).toHaveBeenCalledTimes(1)
88-
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
91+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
8992
expect(epilogMock).toHaveBeenCalledTimes(1)
9093
})
9194

src/__tests__/commands/config.test.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import type { join } from 'node:path'
44

55
import type { ArgumentsCamelCase, Argv } from 'yargs'
66

7-
import type { Profile, ProfilesByName } from '../../lib/cli-config.js'
87
import type { CommandArgs } from '../../commands/config.js'
8+
import type { Profile, ProfilesByName } from '../../lib/cli-config.js'
9+
import type { buildEpilog } from '../../lib/help.js'
910
import type { stringTranslateToId } from '../../lib/command/command-util.js'
1011
import type { TableCommonListOutputProducer, TableCommonOutputProducer } from '../../lib/command/format.js'
1112
import type { outputItemOrListBuilder } from '../../lib/command/listing-io.js'
@@ -32,6 +33,11 @@ jest.unstable_mockModule('node:path', () => ({
3233
join: joinMock,
3334
}))
3435

36+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
37+
jest.unstable_mockModule('../../lib/help.js', () => ({
38+
buildEpilog: buildEpilogMock,
39+
}))
40+
3541
const stringTranslateToIdMock = jest.fn<typeof stringTranslateToId>()
3642
jest.unstable_mockModule('../../lib/command/command-util.js', () => ({
3743
stringTranslateToId: stringTranslateToIdMock,
@@ -84,6 +90,7 @@ test('builder', () => {
8490
positionalMock,
8591
optionMock,
8692
exampleMock,
93+
epilogMock,
8794
argvMock,
8895
} = buildArgvMock<SmartThingsCommandFlags, BuildOutputFormatterFlags>()
8996

@@ -96,6 +103,9 @@ test('builder', () => {
96103
expect(positionalMock).toHaveBeenCalledTimes(1)
97104
expect(optionMock).toHaveBeenCalledTimes(1)
98105
expect(exampleMock).toHaveBeenCalledTimes(1)
106+
expect(exampleMock).toHaveBeenCalledTimes(1)
107+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
108+
expect(epilogMock).toHaveBeenCalledTimes(1)
99109
})
100110

101111
describe('handler', () => {

src/__tests__/commands/edge/channels/delete.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
55
import { ChannelsEndpoint } from '@smartthings/core-sdk'
66

77
import type { CommandArgs } from '../../../../commands/edge/channels/delete.js'
8+
import type { buildEpilog } from '../../../../lib/help.js'
89
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
910
import type { CLIConfig, resetManagedConfigKey } from '../../../../lib/cli-config.js'
1011
import type { chooseChannel } from '../../../../lib/command/util/edge/channels-choose.js'
@@ -17,7 +18,12 @@ jest.unstable_mockModule('../../../../lib/cli-config.js', () => ({
1718
resetManagedConfigKey: resetManagedConfigKeyMock,
1819
}))
1920

20-
const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../../..')
21+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
22+
jest.unstable_mockModule('../../../../lib/help.js', () => ({
23+
buildEpilog: buildEpilogMock,
24+
}))
25+
26+
const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../../..')
2127

2228
const chooseChannelMock = jest.fn<typeof chooseChannel>().mockResolvedValue('chosen-channel-id')
2329
jest.unstable_mockModule('../../../../lib/command/util/edge/channels-choose.js', () => ({
@@ -50,7 +56,7 @@ test('builder', () => {
5056
expect(positionalMock).toHaveBeenCalledTimes(1)
5157
expect(optionMock).toHaveBeenCalledTimes(0)
5258
expect(exampleMock).toHaveBeenCalledTimes(1)
53-
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
59+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
5460
expect(epilogMock).toHaveBeenCalledTimes(1)
5561
})
5662

src/__tests__/commands/edge/channels/drivers.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { jest } from '@jest/globals'
33
import type { ArgumentsCamelCase, Argv } from 'yargs'
44

55
import type { CommandArgs } from '../../../../commands/edge/channels/drivers.js'
6+
import type { buildEpilog } from '../../../../lib/help.js'
67
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
78
import type { outputList, outputListBuilder } from '../../../../lib/command/output-list.js'
89
import type {
@@ -15,7 +16,12 @@ import { apiCommandMocks } from '../../../test-lib/api-command-mock.js'
1516
import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock.js'
1617

1718

18-
const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../../..')
19+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
20+
jest.unstable_mockModule('../../../../lib/help.js', () => ({
21+
buildEpilog: buildEpilogMock,
22+
}))
23+
24+
const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../../..')
1925

2026
const outputListMock = jest.fn<typeof outputList>()
2127
const outputListBuilderMock = jest.fn<typeof outputListBuilder>()
@@ -62,7 +68,7 @@ test('builder', async () => {
6268
expect(positionalMock).toHaveBeenCalledTimes(1)
6369
expect(optionMock).toHaveBeenCalledTimes(0)
6470
expect(exampleMock).toHaveBeenCalledTimes(1)
65-
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
71+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
6672
expect(epilogMock).toHaveBeenCalledTimes(1)
6773
})
6874

src/__tests__/commands/edge/channels/enrollments.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,20 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
55
import type { EnrolledChannel, HubdevicesEndpoint } from '@smartthings/core-sdk'
66

77
import type { CommandArgs } from '../../../../commands/edge/channels/enrollments.js'
8+
import type { buildEpilog } from '../../../../lib/help.js'
89
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
910
import type { outputList, outputListBuilder } from '../../../../lib/command/output-list.js'
1011
import type { chooseHub } from '../../../../lib/command/util/hubs-choose.js'
1112
import { apiCommandMocks } from '../../../test-lib/api-command-mock.js'
1213
import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock.js'
1314

1415

15-
const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../../..')
16+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
17+
jest.unstable_mockModule('../../../../lib/help.js', () => ({
18+
buildEpilog: buildEpilogMock,
19+
}))
20+
21+
const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../../..')
1622

1723
const outputListMock = jest.fn<typeof outputList>()
1824
const outputListBuilderMock = jest.fn<typeof outputListBuilder>()
@@ -53,7 +59,7 @@ test('builder', async () => {
5359
expect(positionalMock).toHaveBeenCalledTimes(1)
5460
expect(optionMock).toHaveBeenCalledTimes(0)
5561
expect(exampleMock).toHaveBeenCalledTimes(1)
56-
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
62+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
5763
expect(epilogMock).toHaveBeenCalledTimes(1)
5864
})
5965

src/__tests__/commands/locations/rooms/delete.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,19 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
55
import type { RoomsEndpoint } from '@smartthings/core-sdk'
66

77
import { CommandArgs } from '../../../../commands/locations/rooms/delete.js'
8+
import type { buildEpilog } from '../../../../lib/help.js'
89
import type { chooseRoom } from '../../../../lib/command/util/rooms-choose.js'
910
import { apiCommandMocks } from '../../../test-lib/api-command-mock.js'
1011
import { buildArgvMock } from '../../../test-lib/builder-mock.js'
1112
import { APICommand } from '../../../../lib/command/api-command.js'
1213

1314

14-
const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../../..')
15+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
16+
jest.unstable_mockModule('../../../../lib/help.js', () => ({
17+
buildEpilog: buildEpilogMock,
18+
}))
19+
20+
const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../../..')
1521

1622
const chooseRoomMock = jest.fn<typeof chooseRoom>()
1723
jest.unstable_mockModule('../../../../lib/command/util/rooms-choose.js', () => ({
@@ -45,7 +51,7 @@ test('builder', () => {
4551
expect(optionMock).toHaveBeenCalledTimes(1)
4652
expect(positionalMock).toHaveBeenCalledTimes(1)
4753
expect(exampleMock).toHaveBeenCalledTimes(1)
48-
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
54+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
4955
expect(epilogMock).toHaveBeenCalledTimes(1)
5056
})
5157

src/__tests__/commands/locations/rooms/update.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
55
import type { Room, RoomRequest, RoomsEndpoint } from '@smartthings/core-sdk'
66

77
import type { CommandArgs } from '../../../../commands/locations/rooms/update.js'
8+
import type { buildEpilog } from '../../../../lib/help.js'
89
import type { APICommand, APICommandFlags } from '../../../../lib/command/api-command.js'
910
import type { inputAndOutputItem, inputAndOutputItemBuilder } from '../../../../lib/command/input-and-output-item.js'
1011
import type { chooseRoom } from '../../../../lib/command/util/rooms-choose.js'
@@ -13,7 +14,12 @@ import { apiCommandMocks } from '../../../test-lib/api-command-mock.js'
1314
import { buildArgvMock, buildArgvMockStub } from '../../../test-lib/builder-mock.js'
1415

1516

16-
const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../../..')
17+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
18+
jest.unstable_mockModule('../../../../lib/help.js', () => ({
19+
buildEpilog: buildEpilogMock,
20+
}))
21+
22+
const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../../..')
1723

1824
const inputAndOutputItemMock = jest.fn<typeof inputAndOutputItem>()
1925
const inputAndOutputItemBuilderMock = jest.fn<typeof inputAndOutputItemBuilder>()
@@ -56,7 +62,7 @@ test('builder', () => {
5662
expect(positionalMock).toHaveBeenCalledTimes(1)
5763
expect(optionMock).toHaveBeenCalledTimes(1)
5864
expect(exampleMock).toHaveBeenCalledTimes(1)
59-
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
65+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
6066
expect(epilogMock).toHaveBeenCalledTimes(1)
6167
})
6268

src/__tests__/commands/organizations.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type {
99
} from '@smartthings/core-sdk'
1010

1111
import type { APICommand, APICommandFlags } from '../../lib/command/api-command.js'
12+
import type { buildEpilog } from '../../lib/help.js'
1213
import type { outputItemOrList, outputItemOrListBuilder } from '../../lib/command/listing-io.js'
1314
import type { CommandArgs } from '../../commands/organizations.js'
1415
import type { BuildOutputFormatterFlags } from '../../lib/command/output-builder.js'
@@ -17,6 +18,11 @@ import { apiCommandMocks } from '../test-lib/api-command-mock.js'
1718
import { buildArgvMock, buildArgvMockStub } from '../test-lib/builder-mock.js'
1819

1920

21+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
22+
jest.unstable_mockModule('../../lib/help.js', () => ({
23+
buildEpilog: buildEpilogMock,
24+
}))
25+
2026
const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../..')
2127

2228
const outputItemOrListMock = jest.fn<typeof outputItemOrList<OrganizationResponse>>()
@@ -36,6 +42,7 @@ test('builder', () => {
3642
yargsMock: apiCommandBuilderArgvMock,
3743
positionalMock,
3844
exampleMock,
45+
epilogMock,
3946
argvMock,
4047
} = buildArgvMock<SmartThingsCommandFlags, BuildOutputFormatterFlags>()
4148

@@ -50,6 +57,8 @@ test('builder', () => {
5057
expect(outputItemOrListBuilderMock).toHaveBeenCalledExactlyOnceWith(apiCommandBuilderArgvMock)
5158
expect(positionalMock).toHaveBeenCalledTimes(1)
5259
expect(exampleMock).toHaveBeenCalledTimes(1)
60+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
61+
expect(epilogMock).toHaveBeenCalledTimes(1)
5362
})
5463

5564
describe('handler', () => {

src/__tests__/commands/organizations/current.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type {
99
} from '@smartthings/core-sdk'
1010

1111
import type { CommandArgs } from '../../../commands/organizations/current.js'
12+
import type { buildEpilog } from '../../../lib/help.js'
1213
import type {
1314
APIOrganizationCommand,
1415
APIOrganizationCommandFlags,
@@ -26,6 +27,11 @@ import { buildArgvMock, buildArgvMockStub } from '../../test-lib/builder-mock.js
2627
import { CLIConfig } from '../../../lib/cli-config.js'
2728

2829

30+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
31+
jest.unstable_mockModule('../../../lib/help.js', () => ({
32+
buildEpilog: buildEpilogMock,
33+
}))
34+
2935
const apiOrganizationCommandMock = jest.fn<typeof apiOrganizationCommand>()
3036
const apiOrganizationCommandBuilderMock = jest.fn<typeof apiOrganizationCommandBuilder>()
3137
jest.unstable_mockModule('../../../lib/command/api-organization-command.js', () => ({
@@ -57,6 +63,7 @@ test('builder', () => {
5763
const {
5864
yargsMock: apiOrganizationCommandBuilderArgvMock,
5965
exampleMock,
66+
epilogMock,
6067
argvMock,
6168
} = buildArgvMock<APIOrganizationCommandFlags, CommandArgs>()
6269

@@ -72,6 +79,8 @@ test('builder', () => {
7279
.toHaveBeenCalledExactlyOnceWith(apiOrganizationCommandBuilderArgvMock)
7380

7481
expect(exampleMock).toHaveBeenCalledTimes(1)
82+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
83+
expect(epilogMock).toHaveBeenCalledTimes(1)
7584
})
7685

7786
describe('handler', () => {

src/__tests__/commands/presentation/device-config.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { ArgumentsCamelCase, Argv } from 'yargs'
55
import type { PresentationDeviceConfig, PresentationEndpoint } from '@smartthings/core-sdk'
66

77
import type { CommandArgs } from '../../../commands/presentation/device-config.js'
8+
import type { buildEpilog } from '../../../lib/help.js'
89
import type { APICommand, APICommandFlags } from '../../../lib/command/api-command.js'
910
import type { OutputItemOrListFlags } from '../../../lib/command/listing-io.js'
1011
import type { outputItem, outputItemBuilder } from '../../../lib/command/output-item.js'
@@ -16,7 +17,12 @@ import { CustomCommonOutputProducer } from '../../../lib/command/format.js'
1617
import { tableGeneratorMock } from '../../test-lib/table-mock.js'
1718

1819

19-
const { apiCommandMock, apiCommandBuilderMock, apiDocsURLMock } = apiCommandMocks('../../..')
20+
const buildEpilogMock = jest.fn<typeof buildEpilog>()
21+
jest.unstable_mockModule('../../../lib/help.js', () => ({
22+
buildEpilog: buildEpilogMock,
23+
}))
24+
25+
const { apiCommandMock, apiCommandBuilderMock } = apiCommandMocks('../../..')
2026

2127
const outputItemMock = jest.fn<typeof outputItem>()
2228
const outputItemBuilderMock = jest.fn<typeof outputItemBuilder>()
@@ -55,7 +61,7 @@ test('builder', () => {
5561
expect(outputItemBuilderMock).toHaveBeenCalledExactlyOnceWith(apiCommandBuilderArgvMock)
5662
expect(positionalMock).toHaveBeenCalledTimes(2)
5763
expect(exampleMock).toHaveBeenCalledTimes(1)
58-
expect(apiDocsURLMock).toHaveBeenCalledTimes(1)
64+
expect(buildEpilogMock).toHaveBeenCalledTimes(1)
5965
expect(epilogMock).toHaveBeenCalledTimes(1)
6066
})
6167

0 commit comments

Comments
 (0)