@sprucelabs/spruce-cli 29.0.1 → 29.1.1
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.
- package/CHANGELOG.md +19 -0
- package/build/__tests__/behavioral/skill/RegisteringAGoSkill.test.d.ts +5 -0
- package/build/__tests__/behavioral/skill/RegisteringAGoSkill.test.js +41 -0
- package/build/__tests__/behavioral/skill/RegisteringAGoSkill.test.js.map +1 -0
- package/build/__tests__/behavioral/skill/UnregisteringASkill.test.d.ts +23 -0
- package/build/__tests__/behavioral/skill/UnregisteringASkill.test.js +143 -0
- package/build/__tests__/behavioral/skill/UnregisteringASkill.test.js.map +1 -0
- package/build/__tests__/behavioral/upgrading/UpgradingASkill3.test.js +1 -0
- package/build/__tests__/behavioral/upgrading/UpgradingASkill3.test.js.map +1 -1
- package/build/__tests__/behavioral/views/WorkingWithViewsInNodeModule.test.d.ts +10 -0
- package/build/__tests__/behavioral/views/WorkingWithViewsInNodeModule.test.js +78 -0
- package/build/__tests__/behavioral/views/WorkingWithViewsInNodeModule.test.js.map +1 -0
- package/build/__tests__/support/EventFaker.d.ts +7 -2
- package/build/__tests__/support/EventFaker.js +22 -2
- package/build/__tests__/support/EventFaker.js.map +1 -1
- package/build/errors/SpruceError.js +1 -1
- package/build/errors/SpruceError.js.map +1 -1
- package/build/features/FeatureInstaller.d.ts +1 -1
- package/build/features/FeatureInstallerFactory.js +3 -0
- package/build/features/FeatureInstallerFactory.js.map +1 -1
- package/build/features/global/GlobalFeature.d.ts +21 -0
- package/build/features/global/GlobalFeature.js +21 -0
- package/build/features/global/GlobalFeature.js.map +1 -0
- package/build/features/global/actions/UnregisterSkillAction.d.ts +18 -0
- package/build/features/global/actions/UnregisterSkillAction.js +59 -0
- package/build/features/global/actions/UnregisterSkillAction.js.map +1 -0
- package/build/features/permission/PermissionFeature.js +4 -0
- package/build/features/permission/PermissionFeature.js.map +1 -1
- package/build/features/permission/writers/PermissionWriter.js +1 -0
- package/build/features/permission/writers/PermissionWriter.js.map +1 -1
- package/build/features/view/ViewFeature.d.ts +2 -0
- package/build/features/view/ViewFeature.js +9 -1
- package/build/features/view/ViewFeature.js.map +1 -1
- package/build/features/view/writers/ViewWriter.js +1 -0
- package/build/features/view/writers/ViewWriter.js.map +1 -1
- package/package.json +3 -3
- package/src/__tests__/behavioral/skill/RegisteringAGoSkill.test.ts +29 -0
- package/src/__tests__/behavioral/skill/UnregisteringASkill.test.ts +160 -0
- package/src/__tests__/behavioral/upgrading/UpgradingASkill3.test.ts +1 -0
- package/src/__tests__/behavioral/views/WorkingWithViewsInNodeModule.test.ts +75 -0
- package/src/__tests__/support/EventFaker.ts +48 -4
- package/src/errors/SpruceError.ts +1 -1
- package/src/features/FeatureInstallerFactory.ts +3 -0
- package/src/features/global/GlobalFeature.ts +29 -0
- package/src/features/global/actions/UnregisterSkillAction.ts +67 -0
- package/src/features/permission/PermissionFeature.ts +4 -0
- package/src/features/permission/writers/PermissionWriter.ts +1 -0
- package/src/features/view/ViewFeature.ts +11 -3
- package/src/features/view/writers/ViewWriter.ts +1 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { buildSchema } from '@sprucelabs/schema'
|
|
2
|
+
import { ListSkill } from '../../../__tests__/support/EventFaker'
|
|
3
|
+
import SpruceError from '../../../errors/SpruceError'
|
|
4
|
+
import AbstractAction from '../../AbstractAction'
|
|
5
|
+
import { ActionOptions, FeatureActionResponse } from '../../features.types'
|
|
6
|
+
import { SkillStore } from '../../skill/stores/SkillStore'
|
|
7
|
+
|
|
8
|
+
const optionsSchema = buildSchema({
|
|
9
|
+
id: 'unregisterSkill',
|
|
10
|
+
description: 'Unregister a skill from your account.',
|
|
11
|
+
fields: {},
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
type OptionsSchema = typeof optionsSchema
|
|
15
|
+
|
|
16
|
+
export default class UnregisterSkillAction extends AbstractAction<OptionsSchema> {
|
|
17
|
+
public optionsSchema: OptionsSchema = optionsSchema
|
|
18
|
+
public commandAliases = ['unregister.skill']
|
|
19
|
+
public invocationMessage = 'Unregistering skill... 🔧'
|
|
20
|
+
private skills: SkillStore
|
|
21
|
+
|
|
22
|
+
public constructor(options: ActionOptions) {
|
|
23
|
+
super(options)
|
|
24
|
+
this.skills = this.Store('skill')
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public async execute(): Promise<FeatureActionResponse> {
|
|
28
|
+
const response: FeatureActionResponse = {}
|
|
29
|
+
|
|
30
|
+
const skills = await this.skills.fetchMySkills()
|
|
31
|
+
if (skills.length > 0) {
|
|
32
|
+
const skillId = await this.ui.prompt({
|
|
33
|
+
type: 'select',
|
|
34
|
+
isRequired: true,
|
|
35
|
+
options: {
|
|
36
|
+
choices: skills.map((skill) => this.skillToChoices(skill)),
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const match = skills.find((s) => s.id === skillId)
|
|
41
|
+
|
|
42
|
+
const confirm = await this.ui.confirm(
|
|
43
|
+
`Are you sure you want to unregister the skill "${match?.name}"?`
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
if (confirm) {
|
|
47
|
+
await this.skills.unregisterSkill(skillId)
|
|
48
|
+
response.summaryLines = [`Unregistered ${match?.name}`]
|
|
49
|
+
} else {
|
|
50
|
+
response.summaryLines = ['Unregister cancelled.']
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
response.errors = [
|
|
54
|
+
new SpruceError({ code: 'NO_SKILLS_REGISTERED' }),
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return response
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private skillToChoices(skill: ListSkill): { value: string; label: string } {
|
|
62
|
+
return {
|
|
63
|
+
value: skill.id,
|
|
64
|
+
label: `${skill.slug}: ${skill.name}`,
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -55,6 +55,10 @@ export default class PermissionFeature extends AbstractFeature {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
public async afterPackageInstall(): Promise<InstallResults> {
|
|
58
|
+
const isInstalled = await this.features.isInstalled('skill')
|
|
59
|
+
if (!isInstalled) {
|
|
60
|
+
return {}
|
|
61
|
+
}
|
|
58
62
|
const files = await this.writePlugin()
|
|
59
63
|
const combinedFile = await this.writeTypesFile()
|
|
60
64
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
2
|
-
import { NpmPackage } from '../../types/cli.types'
|
|
2
|
+
import { GeneratedFile, NpmPackage } from '../../types/cli.types'
|
|
3
3
|
import AbstractFeature, { FeatureDependency } from '../AbstractFeature'
|
|
4
4
|
import { ActionOptions, FeatureCode } from '../features.types'
|
|
5
5
|
|
|
@@ -71,13 +71,21 @@ export default class ViewFeature extends AbstractFeature {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
private async handleDidExecuteUpgrade() {
|
|
74
|
-
const
|
|
74
|
+
const isInstalled = await this.features.isInstalled('skill')
|
|
75
|
+
let files: GeneratedFile[] = []
|
|
76
|
+
if (isInstalled) {
|
|
77
|
+
files = await this.Writer('view').writePlugin(this.cwd)
|
|
78
|
+
}
|
|
75
79
|
const results = await this.Action('view', 'sync').execute({})
|
|
76
|
-
|
|
77
80
|
return [...files, ...(results?.files ?? [])]
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
public async afterPackageInstall() {
|
|
84
|
+
const isInstalled = await this.features.isInstalled('skill')
|
|
85
|
+
if (!isInstalled) {
|
|
86
|
+
return {}
|
|
87
|
+
}
|
|
88
|
+
|
|
81
89
|
const files = await this.Writer('view').writePlugin(this.cwd)
|
|
82
90
|
|
|
83
91
|
this.Service('dependency').add({
|