@sprucelabs/spruce-cli 22.2.0 → 22.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/.env +1 -1
  2. package/.eslintcache +1 -1
  3. package/build/__tests__/behavioral/features/InstallingFeaturesDirectly.test.d.ts +17 -0
  4. package/build/__tests__/behavioral/features/InstallingFeaturesDirectly.test.js +142 -0
  5. package/build/__tests__/behavioral/features/InstallingFeaturesDirectly.test.js.map +1 -0
  6. package/build/__tests__/behavioral/tests/SelectingAnAbstractTestClass.test.js +1 -1
  7. package/build/__tests__/behavioral/tests/SelectingAnAbstractTestClass.test.js.map +1 -1
  8. package/build/features/cache/CacheFeature.d.ts +8 -5
  9. package/build/features/cache/CacheFeature.js.map +1 -1
  10. package/build/features/conversation/ConversationFeature.d.ts +8 -5
  11. package/build/features/conversation/ConversationFeature.js.map +1 -1
  12. package/build/features/dependencies/DependencyFeature.d.ts +8 -5
  13. package/build/features/dependencies/DependencyFeature.js.map +1 -1
  14. package/build/features/deploy/DeployFeature.d.ts +8 -5
  15. package/build/features/deploy/DeployFeature.js.map +1 -1
  16. package/build/features/error/ErrorFeature.d.ts +8 -8
  17. package/build/features/error/ErrorFeature.js.map +1 -1
  18. package/build/features/eventContract/EventContractFeature.d.ts +8 -5
  19. package/build/features/eventContract/EventContractFeature.js.map +1 -1
  20. package/build/features/onboard/OnboardFeature.d.ts +8 -5
  21. package/build/features/onboard/OnboardFeature.js.map +1 -1
  22. package/build/features/organization/OrganizationFeature.d.ts +3 -0
  23. package/build/features/permission/PermissionFeature.d.ts +3 -0
  24. package/build/features/person/PersonFeature.d.ts +3 -0
  25. package/build/features/polish/PolishFeature.d.ts +3 -0
  26. package/build/features/sandbox/SandboxFeature.d.ts +8 -5
  27. package/build/features/sandbox/SandboxFeature.js.map +1 -1
  28. package/build/features/skill/actions/BootAction.d.ts +9 -9
  29. package/build/features/skill/actions/BootAction.js.map +1 -1
  30. package/build/features/skill/actions/InstallFeature.d.ts +0 -0
  31. package/build/features/skill/actions/InstallFeature.js +2 -0
  32. package/build/features/skill/actions/InstallFeature.js.map +1 -0
  33. package/build/features/skill/actions/InstallFeatureAction.d.ts +37 -0
  34. package/build/features/skill/actions/InstallFeatureAction.js +79 -0
  35. package/build/features/skill/actions/InstallFeatureAction.js.map +1 -0
  36. package/build/features/store/StoreFeature.d.ts +8 -5
  37. package/build/features/store/StoreFeature.js.map +1 -1
  38. package/build/features/test/TestFeature.d.ts +8 -5
  39. package/build/features/test/TestFeature.js.map +1 -1
  40. package/build/features/view/ViewFeature.d.ts +8 -8
  41. package/build/features/view/ViewFeature.js.map +1 -1
  42. package/build/features/view/actions/CreateAppAction.d.ts +1 -0
  43. package/build/features/view/actions/CreateAppAction.js +1 -1
  44. package/build/features/view/actions/CreateAppAction.js.map +1 -1
  45. package/build/features/vscode/VsCodeFeature.d.ts +8 -5
  46. package/build/features/vscode/VsCodeFeature.js.map +1 -1
  47. package/package.json +2 -2
  48. package/src/__tests__/behavioral/features/InstallingFeaturesDirectly.test.ts +149 -0
  49. package/src/__tests__/behavioral/tests/SelectingAnAbstractTestClass.test.ts +1 -1
  50. package/src/features/cache/CacheFeature.ts +10 -6
  51. package/src/features/conversation/ConversationFeature.ts +10 -6
  52. package/src/features/dependencies/DependencyFeature.ts +10 -6
  53. package/src/features/deploy/DeployFeature.ts +10 -6
  54. package/src/features/error/ErrorFeature.ts +10 -10
  55. package/src/features/eventContract/EventContractFeature.ts +10 -6
  56. package/src/features/onboard/OnboardFeature.ts +10 -6
  57. package/src/features/organization/OrganizationFeature.ts +4 -0
  58. package/src/features/permission/PermissionFeature.ts +4 -0
  59. package/src/features/person/PersonFeature.ts +4 -0
  60. package/src/features/polish/PolishFeature.ts +4 -0
  61. package/src/features/sandbox/SandboxFeature.ts +10 -6
  62. package/src/features/skill/actions/BootAction.ts +11 -11
  63. package/src/features/skill/actions/InstallFeatureAction.ts +93 -0
  64. package/src/features/store/StoreFeature.ts +10 -6
  65. package/src/features/test/TestFeature.ts +10 -6
  66. package/src/features/view/ViewFeature.ts +10 -10
  67. package/src/features/view/actions/CreateAppAction.ts +1 -2
  68. package/src/features/vscode/VsCodeFeature.ts +9 -6
@@ -20,4 +20,8 @@ declare module '../../features/features.types' {
20
20
  interface FeatureMap {
21
21
  person: PersonFeature
22
22
  }
23
+
24
+ interface FeatureOptionsMap {
25
+ person: undefined
26
+ }
23
27
  }
@@ -30,4 +30,8 @@ declare module '../../features/features.types' {
30
30
  interface FeatureMap {
31
31
  polish: PolishFeature
32
32
  }
33
+
34
+ interface FeatureOptionsMap {
35
+ polish: undefined
36
+ }
33
37
  }
@@ -3,12 +3,6 @@ import uiUtil from '../../utilities/ui.utility'
3
3
  import AbstractFeature, { FeatureDependency } from '../AbstractFeature'
4
4
  import { ActionOptions, FeatureCode } from '../features.types'
5
5
 
6
- declare module '../../features/features.types' {
7
- interface FeatureMap {
8
- sandbox: SandboxFeature
9
- }
10
- }
11
-
12
6
  export default class SandboxFeature extends AbstractFeature {
13
7
  public code: FeatureCode = 'sandbox'
14
8
  public nameReadable = 'Sandbox'
@@ -45,3 +39,13 @@ export default class SandboxFeature extends AbstractFeature {
45
39
  })
46
40
  }
47
41
  }
42
+
43
+ declare module '../../features/features.types' {
44
+ interface FeatureMap {
45
+ sandbox: SandboxFeature
46
+ }
47
+
48
+ interface FeatureOptionsMap {
49
+ sandbox: undefined
50
+ }
51
+ }
@@ -5,17 +5,6 @@ import CommandService from '../../../services/CommandService'
5
5
  import AbstractAction from '../../AbstractAction'
6
6
  import { FeatureActionResponse } from '../../features.types'
7
7
 
8
- type OptionsSchema = SpruceSchemas.SpruceCli.v2020_07_22.BootSkillOptionsSchema
9
- type Options = SpruceSchemas.SpruceCli.v2020_07_22.BootSkillOptions
10
-
11
- export interface BootMeta {
12
- kill: () => void
13
- pid: number
14
- promise: Promise<void>
15
- isBooted: boolean
16
- bootPromise: Promise<void>
17
- }
18
-
19
8
  export default class BootAction extends AbstractAction<OptionsSchema> {
20
9
  public optionsSchema: OptionsSchema = bootSkillOptionsSchema
21
10
  public commandAliases = ['boot']
@@ -125,3 +114,14 @@ export default class BootAction extends AbstractAction<OptionsSchema> {
125
114
  return null
126
115
  }
127
116
  }
117
+
118
+ type OptionsSchema = SpruceSchemas.SpruceCli.v2020_07_22.BootSkillOptionsSchema
119
+ type Options = SpruceSchemas.SpruceCli.v2020_07_22.BootSkillOptions
120
+
121
+ export interface BootMeta {
122
+ kill: () => void
123
+ pid: number
124
+ promise: Promise<void>
125
+ isBooted: boolean
126
+ bootPromise: Promise<void>
127
+ }
@@ -0,0 +1,93 @@
1
+ import { buildSchema, SchemaValues } from '@sprucelabs/schema'
2
+ import { SelectChoice } from '@sprucelabs/spruce-core-schemas'
3
+ import AbstractAction from '../../AbstractAction'
4
+ import { FeatureActionResponse, FeatureCode } from '../../features.types'
5
+
6
+ export default class InstallFeatureAction extends AbstractAction<OptionsSchema> {
7
+ public optionsSchema = optionsSchema
8
+ public invocationMessage = 'Installing a feature... 🚀'
9
+ public commandAliases = ['install.feature']
10
+
11
+ public async execute(
12
+ options: InstallFeatureActionOptions
13
+ ): Promise<FeatureActionResponse> {
14
+ let { code } = options ?? {}
15
+
16
+ if (!code) {
17
+ const choices: SelectChoice[] = await this.buildFeatureChoices()
18
+
19
+ if (!choices.length) {
20
+ return {
21
+ summaryLines: [
22
+ 'Nothing to install, you have already installed everything!',
23
+ ],
24
+ }
25
+ }
26
+
27
+ code = await this.promptForFeature(choices)
28
+ }
29
+ const results = await this.features.install({
30
+ features: [{ code: code as any }],
31
+ })
32
+
33
+ return results
34
+ }
35
+
36
+ private async promptForFeature(choices: SelectChoice[]) {
37
+ return await this.ui.prompt({
38
+ type: 'select',
39
+ label: 'Which feature do you want to install?',
40
+ isRequired: true,
41
+ options: {
42
+ choices,
43
+ },
44
+ })
45
+ }
46
+
47
+ private async buildFeatureChoices() {
48
+ const choices: SelectChoice[] = []
49
+
50
+ for (const key in features) {
51
+ const isInstalled = await this.features.isInstalled(
52
+ key as FeatureCode
53
+ )
54
+ if (!isInstalled) {
55
+ choices.push({
56
+ label: features[key as keyof typeof features],
57
+ value: key,
58
+ })
59
+ }
60
+ }
61
+ return choices
62
+ }
63
+ }
64
+
65
+ const features = {
66
+ error: 'Errors',
67
+ event: 'Events',
68
+ schema: 'Schemas',
69
+ store: 'Stores (including database support)',
70
+ test: 'Tests',
71
+ view: 'Views',
72
+ }
73
+
74
+ const allFeatureChoices: SelectChoice[] = Object.keys(features).map((key) => ({
75
+ label: features[key as keyof typeof features],
76
+ value: key,
77
+ }))
78
+
79
+ const optionsSchema = buildSchema({
80
+ id: 'installFeature',
81
+ fields: {
82
+ code: {
83
+ type: 'select',
84
+ label: 'Feature to install',
85
+ options: {
86
+ choices: allFeatureChoices,
87
+ },
88
+ },
89
+ },
90
+ })
91
+
92
+ type OptionsSchema = typeof optionsSchema
93
+ export type InstallFeatureActionOptions = SchemaValues<OptionsSchema>
@@ -6,12 +6,6 @@ import AbstractFeature, {
6
6
  } from '../AbstractFeature'
7
7
  import { FeatureCode } from '../features.types'
8
8
 
9
- declare module '../../features/features.types' {
10
- interface FeatureMap {
11
- store: StoreFeature
12
- }
13
- }
14
-
15
9
  export default class StoreFeature extends AbstractFeature {
16
10
  public nameReadable = 'Data Stores'
17
11
  public description = 'For working with remote places of storage.'
@@ -87,3 +81,13 @@ export default class StoreFeature extends AbstractFeature {
87
81
  }
88
82
  }
89
83
  }
84
+
85
+ declare module '../../features/features.types' {
86
+ interface FeatureMap {
87
+ store: StoreFeature
88
+ }
89
+
90
+ interface FeatureOptionsMap {
91
+ store: undefined
92
+ }
93
+ }
@@ -8,12 +8,6 @@ import AbstractFeature, { FeatureDependency } from '../AbstractFeature'
8
8
  import ParentTestFinder from '../error/ParentTestFinder'
9
9
  import { FeatureCode } from '../features.types'
10
10
 
11
- declare module '../../features/features.types' {
12
- interface FeatureMap {
13
- test: TestFeature
14
- }
15
- }
16
-
17
11
  export interface ParentClassCandidate {
18
12
  name: string
19
13
  label: string
@@ -149,3 +143,13 @@ export default class TestFeature extends AbstractFeature {
149
143
  return candidates
150
144
  }
151
145
  }
146
+
147
+ declare module '../../features/features.types' {
148
+ interface FeatureMap {
149
+ test: TestFeature
150
+ }
151
+
152
+ interface FeatureOptionsMap {
153
+ test: undefined
154
+ }
155
+ }
@@ -3,16 +3,6 @@ import { NpmPackage } from '../../types/cli.types'
3
3
  import AbstractFeature, { FeatureDependency } from '../AbstractFeature'
4
4
  import { ActionOptions, FeatureCode } from '../features.types'
5
5
 
6
- declare module '../../features/features.types' {
7
- interface FeatureMap {
8
- view: ViewFeature
9
- }
10
-
11
- interface FeatureOptionsMap {
12
- view: undefined
13
- }
14
- }
15
-
16
6
  export default class ViewFeature extends AbstractFeature {
17
7
  public nameReadable = 'views'
18
8
  public description = 'Views: Create views using the Heartwood framework.'
@@ -98,3 +88,13 @@ export default class ViewFeature extends AbstractFeature {
98
88
  return { files }
99
89
  }
100
90
  }
91
+
92
+ declare module '../../features/features.types' {
93
+ interface FeatureMap {
94
+ view: ViewFeature
95
+ }
96
+
97
+ interface FeatureOptionsMap {
98
+ view: undefined
99
+ }
100
+ }
@@ -6,6 +6,7 @@ import { FeatureActionResponse } from '../../features.types'
6
6
  export default class CreateAppAction extends AbstractAction<OptionsSchema> {
7
7
  public optionsSchema = optionsSchema
8
8
  public invocationMessage = 'Creating new app view controller... '
9
+ public readonly commandAliases = ['create.avc']
9
10
 
10
11
  public async execute(): Promise<FeatureActionResponse> {
11
12
  const writer = this.Writer('view', {})
@@ -19,8 +20,6 @@ export default class CreateAppAction extends AbstractAction<OptionsSchema> {
19
20
  results
20
21
  )
21
22
 
22
- debugger
23
-
24
23
  return merged
25
24
  }
26
25
  }
@@ -3,12 +3,6 @@ import { FileDescription } from '../../types/cli.types'
3
3
  import AbstractFeature from '../AbstractFeature'
4
4
  import { FeatureCode } from '../features.types'
5
5
 
6
- declare module '../../features/features.types' {
7
- interface FeatureMap {
8
- vscode: VsCodeFeature
9
- }
10
- }
11
-
12
6
  export default class VsCodeFeature extends AbstractFeature {
13
7
  public nameReadable = 'VSCode'
14
8
  public description = 'Create settings and install VSCode extensions'
@@ -52,3 +46,12 @@ export default class VsCodeFeature extends AbstractFeature {
52
46
  return true
53
47
  }
54
48
  }
49
+
50
+ declare module '../../features/features.types' {
51
+ interface FeatureMap {
52
+ vscode: VsCodeFeature
53
+ }
54
+ interface FeatureOptionsMap {
55
+ vscode: undefined
56
+ }
57
+ }