Skip to content

Commit 59fae5e

Browse files
committed
fixups and simplifying
1 parent 1faf25d commit 59fae5e

File tree

5 files changed

+30
-23
lines changed

5 files changed

+30
-23
lines changed

__tests__/__mocks__/examplePlugin.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ module.exports = context => {
4343
},
4444
{
4545
prop: 'nachos',
46-
value: true
47-
}
48-
]
46+
value: true,
47+
},
48+
],
4949
},
5050
checkThirdThing: {
5151
check: async (rule, context) => {
@@ -54,7 +54,7 @@ module.exports = context => {
5454
message: 'PAZZZZZ',
5555
}
5656
},
57-
snapshot: async (rule, context) => []
57+
snapshot: async (rule, context) => [],
5858
},
5959
},
6060
})

__tests__/command_helpers/findPluginInfo.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,33 @@ describe('findPluginInfo Function', () => {
77
const rule = {
88
rule: 'custom',
99
plugin: 'FAKE',
10-
name: 'checkThing'
10+
name: 'checkThing',
1111
}
1212
const customPluginRule = findPluginInfo(rule, mockContext)
1313
expect(customPluginRule).toEqual({ message: "Plugin not found 'FAKE'", success: false })
14-
}
14+
})
1515

1616
test('can fail to find plugins', () => {
1717
const rule = {
1818
rule: 'custom',
1919
plugin: 'Example Plugin',
20-
name: 'FAKE'
20+
name: 'FAKE',
2121
}
2222
const customPluginRule = findPluginInfo(rule, mockContext)
23-
expect(customPluginRule.message).toEqual("NOT FOUND: Custom rule from 'Example Plugin' plugin with check function 'FAKE'")
23+
expect(customPluginRule.message).toEqual(
24+
"NOT FOUND: Custom rule from 'Example Plugin' plugin with check function 'FAKE'"
25+
)
2426
expect(customPluginRule.success).toBeFalsy()
25-
}
27+
})
2628

2729
test('can find plugins', () => {
2830
const rule = {
2931
rule: 'custom',
3032
plugin: 'Example Plugin',
31-
name: 'checkThing'
33+
name: 'checkThing',
3234
}
3335
const customPluginRule = findPluginInfo(rule, mockContext)
3436
expect(customPluginRule.success).toBeTruthy()
3537
expect(customPluginRule).toMatchSnapshot()
36-
}
38+
})
3739
})

__tests__/command_helpers/updateRequirement.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ describe('updateRequirement', () => {
2525
spin: jest.fn(() => spinner),
2626
error: jest.fn(),
2727
colors: {
28-
green: jest.fn()
29-
}
30-
28+
green: jest.fn(),
29+
},
3130
}
3231
})
3332

@@ -162,7 +161,7 @@ describe('updateRequirement', () => {
162161
TestRequirement: [
163162
{ rule: 'custom', plugin: 'Example Plugin', name: 'checkThing' },
164163
{ rule: 'custom', plugin: 'Example Plugin', name: 'checkSecondThing' },
165-
{ rule: 'custom', plugin: 'Example Plugin', name: 'checkThirdThing' }
164+
{ rule: 'custom', plugin: 'Example Plugin', name: 'checkThirdThing' },
166165
],
167166
})[0]
168167

src/commands/report.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { GluegunCommand } from 'gluegun'
2-
import { helpers } from 'envinfo'
32
import { SolidarityRunContext, SolidarityReportResults } from '../types'
43
import { map, toPairs } from 'ramda'
4+
import { createReport } from '../extensions/functions/solidarityReport'
55

66
module.exports = {
77
alias: 'r',
@@ -22,13 +22,7 @@ module.exports = {
2222
process.exit(3)
2323
}
2424

25-
let results: SolidarityReportResults = {
26-
basicInfo: [['System Basics', 'Value'], ['OS', helpers.getOperatingSystemInfo()], ['CPU', helpers.getCPUInfo()]],
27-
cliRules: [['Binary', 'Location', 'Version', 'Desired']],
28-
envRules: [['Environment Var', 'Value']],
29-
filesystemRules: [['Location', 'Type', 'Exists']],
30-
shellRules: [['Command', 'Pattern', 'Matches']],
31-
}
25+
let results: SolidarityReportResults = createReport()
3226

3327
// break all rules into requirements
3428
const reportCalls = map(
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { SolidarityReportResults } from '../../types'
2+
import { helpers } from 'envinfo'
3+
4+
export const createReport = (): SolidarityReportResults => {
5+
return {
6+
basicInfo: [['System Basics', 'Value'], ['OS', helpers.getOperatingSystemInfo()], ['CPU', helpers.getCPUInfo()]],
7+
cliRules: [['Binary', 'Location', 'Version', 'Desired']],
8+
envRules: [['Environment Var', 'Value']],
9+
filesystemRules: [['Location', 'Type', 'Exists']],
10+
shellRules: [['Command', 'Pattern', 'Matches']],
11+
}
12+
}

0 commit comments

Comments
 (0)