Repository: infinitered/solidarity
Pull request #253 (2020-03-09 20:42:43)

V3 fixes

codecov[bot]: # [Codecov](https://codecov.io/gh/infinitered/solidarity/pull/253?src=pr&el=h1) Report
> Merging [#253](https://codecov.io/gh/infinitered/solidarity/pull/253?src=pr&el=desc) into [master](https://codecov.io/gh/infinitered/solidarity/commit/1510bca6cd59c6b9a471548955998305beb1da3e?src=pr&el=desc) will **decrease** coverage by `0.35%`.
> The diff coverage is `0%`.

[![Impacted file tree graph](https://codecov.io/gh/infinitered/solidarity/pull/253/graphs/tree.svg?width=650&token=eTjcyCooFB&height=150&src=pr)](https://codecov.io/gh/infinitered/solidarity/pull/253?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #253      +/-   ##
==========================================
- Coverage   83.38%   83.02%   -0.36%     
==========================================
  Files          36       36              
  Lines         704      707       +3     
  Branches      136      137       +1     
==========================================
  Hits          587      587              
- Misses         74       77       +3     
  Partials       43       43
```


| [Impacted Files](https://codecov.io/gh/infinitered/solidarity/pull/253?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [...c/extensions/functions/buildSpecificRequirement.ts](https://codecov.io/gh/infinitered/solidarity/pull/253/diff?src=pr&el=tree#diff-c3JjL2V4dGVuc2lvbnMvZnVuY3Rpb25zL2J1aWxkU3BlY2lmaWNSZXF1aXJlbWVudC50cw==) | `95% <ø> (ø)` | :arrow_up: |
| [src/extensions/functions/createPlugin.ts](https://codecov.io/gh/infinitered/solidarity/pull/253/diff?src=pr&el=tree#diff-c3JjL2V4dGVuc2lvbnMvZnVuY3Rpb25zL2NyZWF0ZVBsdWdpbi50cw==) | `96.15% <ø> (ø)` | :arrow_up: |
| [src/commands/snapshot.ts](https://codecov.io/gh/infinitered/solidarity/pull/253/diff?src=pr&el=tree#diff-c3JjL2NvbW1hbmRzL3NuYXBzaG90LnRz) | `52% <0%> (-3.32%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/infinitered/solidarity/pull/253?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/infinitered/solidarity/pull/253?src=pr&el=footer). Last update [1510bca...ea86e7b](https://codecov.io/gh/infinitered/solidarity/pull/253?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

gwmccull: @kevinvangelder if you want, once you're all in master, I can try it out on our project
kevinvangelder: @gwmccull Yes, I did the package.json changes on master (yeah, I know).

Patch:
diff --git a/src/commands/onboard.ts b/src/commands/onboard.ts
index f52dc3a..86a85ca 100644
--- a/src/commands/onboard.ts
+++ b/src/commands/onboard.ts
@@ -1,6 +1,6 @@
 import { GluegunCommand } from 'gluegun'
 
-import { SolidarityRunContext } from '../types'
+import { SolidarityRunContext, SolidarityRule } from '../types'
 
 namespace Onboard {
   export const run = async (context: SolidarityRunContext) => {
@@ -38,16 +38,18 @@ namespace Onboard {
 
       printWizard(context)
       let repeat = true
+      let rules: Array<SolidarityRule> = []
       while (repeat) {
         // Find out what they wanted
         let answer = await onboardAdd(context)
         // execute their will
-        await executeAddRule(context, answer)
+        const rule = await executeAddRule(context, answer)
+        rules.push(rule)
         // more?
         repeat = await addMore(context)
       }
 
-      reviewAndSave(context)
+      reviewAndSave(context, rules)
     }
   }
 }
diff --git a/src/commands/snapshot.ts b/src/commands/snapshot.ts
index 5684847..b39fe4b 100644
--- a/src/commands/snapshot.ts
+++ b/src/commands/snapshot.ts
@@ -35,19 +35,24 @@ namespace Snapshot {
       const answer = await context.prompt.ask({
         name: 'selectedPlugin',
         message: 'Which of the above technology snapshots will you use for this project?',
-        type: 'list',
+        type: 'select',
         choices: pluginOptions,
       })
 
       if (answer.selectedPlugin === FriendlyMessages.NONE) {
         print.info(FriendlyMessages.NOTHING)
+        print.info("If you don't wish to use a plugin, try creating your own rules with `solidarity onboard`")
       } else {
         const pluginSpinner = print.spin(`Running ${answer.selectedPlugin} Snapshot`)
         // Config for selected plugin only
         const runPlugin = head(filter(propEq('name', answer.selectedPlugin), pluginsWithTemplates))
-        // run plugin
-        await runPluginSnapshot(runPlugin, context)
-        pluginSpinner.succeed('Snapshot complete')
+        if (runPlugin) {
+          // run plugin
+          await runPluginSnapshot(runPlugin, context)
+          pluginSpinner.succeed('Snapshot complete')
+        } else {
+          pluginSpinner.fail("Couldn't find plugin")
+        }
       }
     } else {
       print.error(`No solidarity plugins found!
diff --git a/src/extensions/functions/buildSpecificRequirement.ts b/src/extensions/functions/buildSpecificRequirement.ts
index 5acb718..7fbb9f5 100644
--- a/src/extensions/functions/buildSpecificRequirement.ts
+++ b/src/extensions/functions/buildSpecificRequirement.ts
@@ -54,7 +54,7 @@ namespace buildSpecificRequirement {
       const answer = await prompt.ask({
         name: 'selectedRequirement',
         message: 'Which of the above technology snapshots will you use for this project?',
-        type: 'list',
+        type: 'select',
         choices: requirementOptions,
       })
       requirementName = answer.selectedRequirement
diff --git a/src/extensions/functions/createPlugin.ts b/src/extensions/functions/createPlugin.ts
index f69f61a..fc7d823 100644
--- a/src/extensions/functions/createPlugin.ts
+++ b/src/extensions/functions/createPlugin.ts
@@ -27,7 +27,7 @@ module.exports = async context => {
     'Template + optional rules',
   ]
   const answer = await prompt.ask({
-    type: 'list',
+    type: 'select',
     name: 'ruleChoice',
     message: 'Your initial rule file template?',
     choices: ruleChoices,
diff --git a/src/extensions/functions/onboard/executeAddRule.ts b/src/extensions/functions/onboard/executeAddRule.ts
index 0bc4f32..3256022 100644
--- a/src/extensions/functions/onboard/executeAddRule.ts
+++ b/src/extensions/functions/onboard/executeAddRule.ts
@@ -8,7 +8,6 @@ export default async (context: SolidarityRunContext, answer: string): Promise<vo
   let rule
   switch (answer) {
     case 'cli':
-      print.info('Kickoff CLI')
       rule = await Kickoffs.kickoffCLI(context)
       break
     case 'env':
@@ -21,7 +20,6 @@ export default async (context: SolidarityRunContext, answer: string): Promise<vo
       rule = await Kickoffs.kickoffDir(context)
       break
     case 'shell':
-      print.info('Kickoff SHELL')
       rule = await Kickoffs.kickoffShell(context)
       break
     default:
@@ -32,4 +30,5 @@ export default async (context: SolidarityRunContext, answer: string): Promise<vo
   // Now ask questions for ALL rules
   rule = await Kickoffs.kickoffAllRules(context, rule)
   // Now add rule to requirement
+  return rule
 }
diff --git a/src/extensions/functions/onboard/kickoffs/kickoffAllRules.ts b/src/extensions/functions/onboard/kickoffs/kickoffAllRules.ts
index d35606a..102495f 100644
--- a/src/extensions/functions/onboard/kickoffs/kickoffAllRules.ts
+++ b/src/extensions/functions/onboard/kickoffs/kickoffAllRules.ts
@@ -30,7 +30,7 @@ export default async (context: SolidarityRunContext, rule: SolidarityRule): Prom
   if (platformSpecific.value) {
     const platforms = await prompt.ask({
       name: 'value',
-      type: 'checkbox',
+      type: 'multiselect',
       message: 'Which operating systems does this rule run for?',
       choices: ['macos', 'freebsd', 'linux', 'sunos', 'windows'],
     })
diff --git a/src/extensions/functions/onboard/kickoffs/kickoffCLI.ts b/src/extensions/functions/onboard/kickoffs/kickoffCLI.ts
index 888d4fc..dda8685 100644
--- a/src/extensions/functions/onboard/kickoffs/kickoffCLI.ts
+++ b/src/extensions/functions/onboard/kickoffs/kickoffCLI.ts
@@ -1,7 +1,5 @@
-import { SolidarityRunContext } from '../../../../types'
+import { SolidarityRunContext, SolidarityRule } from '../../../../types'
 
-export default async (context: SolidarityRunContext): Promise<void> => {
-  const { print } = context
-  print.info(`kickoff CLI function`)
-  // return { rule: 'cli' }
+export default async (context: SolidarityRunContext): Promise<SolidarityRule> => {
+  return { rule: 'cli', binary: '' }
 }
diff --git a/src/extensions/functions/onboard/kickoffs/kickoffEnv.ts b/src/extensions/functions/onboard/kickoffs/kickoffEnv.ts
index bcd9030..75ec10d 100644
--- a/src/extensions/functions/onboard/kickoffs/kickoffEnv.ts
+++ b/src/extensions/functions/onboard/kickoffs/kickoffEnv.ts
@@ -7,7 +7,7 @@ export default async (context: SolidarityRunContext): Promise<SolidarityRule> =>
 
   const envStyle = await prompt.ask({
     name: 'value',
-    type: 'list',
+    type: 'select',
     message: 'How would you like to pick your environment variable',
     choices: [pickSentence, typeSentence],
   })
@@ -16,7 +16,7 @@ export default async (context: SolidarityRunContext): Promise<SolidarityRule> =>
   if (envStyle.value === pickSentence) {
     pickEnv = await prompt.ask({
       name: 'value',
-      type: 'list',
+      type: 'select',
       message: 'Which environment variable would you like to enforce?',
       choices: Object.keys(process.env),
     })
diff --git a/src/extensions/functions/onboard/kickoffs/kickoffShell.ts b/src/extensions/functions/onboard/kickoffs/kickoffShell.ts
index a14a937..d2bde06 100644
--- a/src/extensions/functions/onboard/kickoffs/kickoffShell.ts
+++ b/src/extensions/functions/onboard/kickoffs/kickoffShell.ts
@@ -1,6 +1,5 @@
-import { SolidarityRunContext } from '../../../../types'
+import { SolidarityRunContext, SolidarityRule } from '../../../../types'
 
-export default async (context: SolidarityRunContext): Promise<void> => {
-  const { print } = context
-  print.info(`kickoff Shell function`)
+export default async (context: SolidarityRunContext): Promise<SolidarityRule> => {
+  return { rule: 'shell', command: '', match: '' }
 }
diff --git a/src/extensions/functions/onboard/onboardAdd.ts b/src/extensions/functions/onboard/onboardAdd.ts
index 9eb27bf..ebfe3ea 100644
--- a/src/extensions/functions/onboard/onboardAdd.ts
+++ b/src/extensions/functions/onboard/onboardAdd.ts
@@ -11,7 +11,7 @@ export default async (context: SolidarityRunContext): Promise<string> => {
   `)
   const userAnswer = await prompt.ask({
     name: 'addRule',
-    type: 'radio',
+    type: 'select',
     message: 'What kind of rule would you like to add?',
     choices: ['cli', 'env', 'file', 'dir', 'shell'],
   })
diff --git a/src/extensions/functions/onboard/reviewAndSave.ts b/src/extensions/functions/onboard/reviewAndSave.ts
index c44698a..652b79b 100644
--- a/src/extensions/functions/onboard/reviewAndSave.ts
+++ b/src/extensions/functions/onboard/reviewAndSave.ts
@@ -1,6 +1,9 @@
-import { SolidarityRunContext } from '../../../types'
+import { SolidarityRunContext, SolidarityRule } from '../../../types'
 // TODO: Make this fancier
-export default (context: SolidarityRunContext): void => {
-  const { print } = context
+export default (context: SolidarityRunContext, rules: Array<SolidarityRule>): void => {
+  const { print, solidarity: { setSolidaritySettings } } = context
+
+  setSolidaritySettings({ requirements: rules }, context)
   print.success('Review and Save')
+  print.success('For full custom rules documentation visit: https://infinitered.github.io/solidarity/#/docs/options?id=solidarity-rules')
 }


Test patch:
diff --git a/__tests__/commands/__snapshots__/snapshot.ts.snap b/__tests__/commands/__snapshots__/snapshot.ts.snap
index 059a9a1..cba40b9 100644
--- a/__tests__/commands/__snapshots__/snapshot.ts.snap
+++ b/__tests__/commands/__snapshots__/snapshot.ts.snap
@@ -31,7 +31,7 @@ Array [
       ],
       "message": "Which of the above technology snapshots will you use for this project?",
       "name": "selectedRequirement",
-      "type": "list",
+      "type": "select",
     },
   ],
   Array [