Skip to content

Commit 4cecbb9

Browse files
V3 fixes (#253)
* fix snapshot and onboard commands * update additional old-style gluegun questions * more tweaks for updated gluegun * use the correct spinner method * fix snapshot snapshot * finish implementing basic onboarding functionality * fix lint * remove commented lines
1 parent 1510bca commit 4cecbb9

File tree

12 files changed

+34
-28
lines changed

12 files changed

+34
-28
lines changed

__tests__/commands/__snapshots__/snapshot.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Array [
3131
],
3232
"message": "Which of the above technology snapshots will you use for this project?",
3333
"name": "selectedRequirement",
34-
"type": "list",
34+
"type": "select",
3535
},
3636
],
3737
Array [

src/commands/onboard.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { GluegunCommand } from 'gluegun'
22

3-
import { SolidarityRunContext } from '../types'
3+
import { SolidarityRunContext, SolidarityRule } from '../types'
44

55
namespace Onboard {
66
export const run = async (context: SolidarityRunContext) => {
@@ -38,16 +38,18 @@ namespace Onboard {
3838

3939
printWizard(context)
4040
let repeat = true
41+
let rules: Array<SolidarityRule> = []
4142
while (repeat) {
4243
// Find out what they wanted
4344
let answer = await onboardAdd(context)
4445
// execute their will
45-
await executeAddRule(context, answer)
46+
const rule = await executeAddRule(context, answer)
47+
rules.push(rule)
4648
// more?
4749
repeat = await addMore(context)
4850
}
4951

50-
reviewAndSave(context)
52+
reviewAndSave(context, rules)
5153
}
5254
}
5355
}

src/commands/snapshot.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,24 @@ namespace Snapshot {
3535
const answer = await context.prompt.ask({
3636
name: 'selectedPlugin',
3737
message: 'Which of the above technology snapshots will you use for this project?',
38-
type: 'list',
38+
type: 'select',
3939
choices: pluginOptions,
4040
})
4141

4242
if (answer.selectedPlugin === FriendlyMessages.NONE) {
4343
print.info(FriendlyMessages.NOTHING)
44+
print.info("If you don't wish to use a plugin, try creating your own rules with `solidarity onboard`")
4445
} else {
4546
const pluginSpinner = print.spin(`Running ${answer.selectedPlugin} Snapshot`)
4647
// Config for selected plugin only
4748
const runPlugin = head(filter(propEq('name', answer.selectedPlugin), pluginsWithTemplates))
48-
// run plugin
49-
await runPluginSnapshot(runPlugin, context)
50-
pluginSpinner.succeed('Snapshot complete')
49+
if (runPlugin) {
50+
// run plugin
51+
await runPluginSnapshot(runPlugin, context)
52+
pluginSpinner.succeed('Snapshot complete')
53+
} else {
54+
pluginSpinner.fail("Couldn't find plugin")
55+
}
5156
}
5257
} else {
5358
print.error(`No solidarity plugins found!

src/extensions/functions/buildSpecificRequirement.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace buildSpecificRequirement {
5454
const answer = await prompt.ask({
5555
name: 'selectedRequirement',
5656
message: 'Which of the above technology snapshots will you use for this project?',
57-
type: 'list',
57+
type: 'select',
5858
choices: requirementOptions,
5959
})
6060
requirementName = answer.selectedRequirement

src/extensions/functions/createPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module.exports = async context => {
2727
'Template + optional rules',
2828
]
2929
const answer = await prompt.ask({
30-
type: 'list',
30+
type: 'select',
3131
name: 'ruleChoice',
3232
message: 'Your initial rule file template?',
3333
choices: ruleChoices,

src/extensions/functions/onboard/executeAddRule.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export default async (context: SolidarityRunContext, answer: string): Promise<vo
88
let rule
99
switch (answer) {
1010
case 'cli':
11-
print.info('Kickoff CLI')
1211
rule = await Kickoffs.kickoffCLI(context)
1312
break
1413
case 'env':
@@ -21,7 +20,6 @@ export default async (context: SolidarityRunContext, answer: string): Promise<vo
2120
rule = await Kickoffs.kickoffDir(context)
2221
break
2322
case 'shell':
24-
print.info('Kickoff SHELL')
2523
rule = await Kickoffs.kickoffShell(context)
2624
break
2725
default:
@@ -32,4 +30,5 @@ export default async (context: SolidarityRunContext, answer: string): Promise<vo
3230
// Now ask questions for ALL rules
3331
rule = await Kickoffs.kickoffAllRules(context, rule)
3432
// Now add rule to requirement
33+
return rule
3534
}

src/extensions/functions/onboard/kickoffs/kickoffAllRules.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default async (context: SolidarityRunContext, rule: SolidarityRule): Prom
3030
if (platformSpecific.value) {
3131
const platforms = await prompt.ask({
3232
name: 'value',
33-
type: 'checkbox',
33+
type: 'multiselect',
3434
message: 'Which operating systems does this rule run for?',
3535
choices: ['macos', 'freebsd', 'linux', 'sunos', 'windows'],
3636
})
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import { SolidarityRunContext } from '../../../../types'
1+
import { SolidarityRunContext, SolidarityRule } from '../../../../types'
22

3-
export default async (context: SolidarityRunContext): Promise<void> => {
4-
const { print } = context
5-
print.info(`kickoff CLI function`)
6-
// return { rule: 'cli' }
3+
export default async (context: SolidarityRunContext): Promise<SolidarityRule> => {
4+
return { rule: 'cli', binary: '' }
75
}

src/extensions/functions/onboard/kickoffs/kickoffEnv.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default async (context: SolidarityRunContext): Promise<SolidarityRule> =>
77

88
const envStyle = await prompt.ask({
99
name: 'value',
10-
type: 'list',
10+
type: 'select',
1111
message: 'How would you like to pick your environment variable',
1212
choices: [pickSentence, typeSentence],
1313
})
@@ -16,7 +16,7 @@ export default async (context: SolidarityRunContext): Promise<SolidarityRule> =>
1616
if (envStyle.value === pickSentence) {
1717
pickEnv = await prompt.ask({
1818
name: 'value',
19-
type: 'list',
19+
type: 'select',
2020
message: 'Which environment variable would you like to enforce?',
2121
choices: Object.keys(process.env),
2222
})
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { SolidarityRunContext } from '../../../../types'
1+
import { SolidarityRunContext, SolidarityRule } from '../../../../types'
22

3-
export default async (context: SolidarityRunContext): Promise<void> => {
4-
const { print } = context
5-
print.info(`kickoff Shell function`)
3+
export default async (context: SolidarityRunContext): Promise<SolidarityRule> => {
4+
return { rule: 'shell', command: '', match: '' }
65
}

0 commit comments

Comments
 (0)