@sprucelabs/spruce-cli 17.1.0 → 17.1.3
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 +24 -0
- package/build/__tests__/behavioral/AddingADependency.test.js +2 -1
- package/build/__tests__/behavioral/AddingADependency.test.js.map +1 -1
- package/build/__tests__/behavioral/permissions/CreatingPermissions.test.d.ts +7 -0
- package/build/__tests__/behavioral/permissions/CreatingPermissions.test.js +137 -0
- package/build/__tests__/behavioral/permissions/CreatingPermissions.test.js.map +1 -0
- package/build/__tests__/testDirsAndFiles/related_schemas/v2020_10_06/skillWithExtraField.builder.d.ts +10 -2
- package/build/features/FeatureInstaller.d.ts +1 -1
- package/build/features/FeatureInstallerFactory.js +4 -2
- package/build/features/FeatureInstallerFactory.js.map +1 -1
- package/build/features/event/actions/CreateAction.d.ts +24 -16
- package/build/features/event/actions/CreateAction.js +3 -5
- package/build/features/event/actions/CreateAction.js.map +1 -1
- package/build/features/node/actions/UpdateDependenciesAction.js +25 -32
- package/build/features/node/actions/UpdateDependenciesAction.js.map +1 -1
- package/build/features/organization/OrganizationFeature.d.ts +5 -5
- package/build/features/organization/OrganizationFeature.js.map +1 -1
- package/build/features/permission/PermissionFeature.d.ts +15 -0
- package/build/features/permission/PermissionFeature.js +66 -0
- package/build/features/permission/PermissionFeature.js.map +1 -0
- package/build/features/permission/actions/CreateAction.d.ts +46 -0
- package/build/features/permission/actions/CreateAction.js +96 -0
- package/build/features/permission/actions/CreateAction.js.map +1 -0
- package/build/features/skill/actions/RegisterAction.d.ts +2 -0
- package/build/features/skill/actions/RegisterAction.js +4 -2
- package/build/features/skill/actions/RegisterAction.js.map +1 -1
- package/build/features/skill/stores/SkillStore.d.ts +9 -8
- package/build/features/skill/stores/SkillStore.js +4 -3
- package/build/features/skill/stores/SkillStore.js.map +1 -1
- package/build/tests/fixtures/SkillFixture.d.ts +3 -8
- package/build/tests/fixtures/SkillFixture.js.map +1 -1
- package/build/widgets/terminalKit/TkBaseWidget.js +9 -18
- package/build/widgets/terminalKit/TkBaseWidget.js.map +1 -1
- package/package.json +18 -3
- package/src/__tests__/behavioral/AddingADependency.test.ts +1 -0
- package/src/__tests__/behavioral/permissions/CreatingPermissions.test.ts +25 -0
- package/src/features/FeatureInstallerFactory.ts +3 -0
- package/src/features/event/actions/CreateAction.ts +5 -6
- package/src/features/organization/OrganizationFeature.ts +6 -6
- package/src/features/permission/PermissionFeature.ts +28 -0
- package/src/features/permission/actions/CreateAction.ts +29 -0
- package/src/features/skill/actions/RegisterAction.ts +2 -0
- package/src/features/skill/stores/SkillStore.ts +13 -11
- package/src/tests/fixtures/SkillFixture.ts +6 -3
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
"license": "MIT",
|
|
21
|
-
"version": "17.1.
|
|
21
|
+
"version": "17.1.3",
|
|
22
22
|
"bin": {
|
|
23
23
|
"spruce": "./build/index.js"
|
|
24
24
|
},
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"@sprucelabs/spruce-event-utils": "^27.0.5",
|
|
89
89
|
"@sprucelabs/spruce-skill-booter": "^41.0.4",
|
|
90
90
|
"@sprucelabs/spruce-skill-utils": "^26.0.88",
|
|
91
|
-
"@sprucelabs/spruce-templates": "^17.1.
|
|
91
|
+
"@sprucelabs/spruce-templates": "^17.1.3",
|
|
92
92
|
"@typescript-eslint/eslint-plugin": "^5.27.1",
|
|
93
93
|
"@typescript-eslint/parser": "^5.27.1",
|
|
94
94
|
"cfonts": "^3.1.0",
|
|
@@ -394,6 +394,21 @@
|
|
|
394
394
|
"code": "event"
|
|
395
395
|
}
|
|
396
396
|
],
|
|
397
|
+
"permissions": [
|
|
398
|
+
{
|
|
399
|
+
"code": "skill",
|
|
400
|
+
"options": {
|
|
401
|
+
"name": "testing permissions",
|
|
402
|
+
"description": "This is for permissions"
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
"code": "event"
|
|
407
|
+
},
|
|
408
|
+
{
|
|
409
|
+
"code": "permission"
|
|
410
|
+
}
|
|
411
|
+
],
|
|
397
412
|
"organizations": [
|
|
398
413
|
{
|
|
399
414
|
"code": "skill",
|
|
@@ -612,5 +627,5 @@
|
|
|
612
627
|
"terminal-kit"
|
|
613
628
|
]
|
|
614
629
|
},
|
|
615
|
-
"gitHead": "
|
|
630
|
+
"gitHead": "7923db6829666ddfaa1484da32422b05afc8b544"
|
|
616
631
|
}
|
|
@@ -121,6 +121,7 @@ export default class ConfiguringDependenciesTest extends AbstractSkillTest {
|
|
|
121
121
|
protected static async canAddSkillThatWasCreatedBySomeoneElse() {
|
|
122
122
|
const skill = await this.getSkillFixture().seedDemoSkill({
|
|
123
123
|
name: 'global dependency skill',
|
|
124
|
+
isPublished: true,
|
|
124
125
|
})
|
|
125
126
|
|
|
126
127
|
await this.people.loginAsDemoPerson(DEMO_NUMBER_GLOBAL_EVENTS)
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { test, assert } from '@sprucelabs/test'
|
|
2
|
+
import CreateAction from '../../../features/permission/actions/CreateAction'
|
|
3
|
+
import AbstractCliTest from '../../../tests/AbstractCliTest'
|
|
4
|
+
|
|
5
|
+
export default class CreatingPermissionsTest extends AbstractCliTest {
|
|
6
|
+
private static create: CreateAction
|
|
7
|
+
|
|
8
|
+
protected static async beforeEach() {
|
|
9
|
+
await super.beforeEach()
|
|
10
|
+
await this.FeatureFixture().installCachedFeatures('permissions')
|
|
11
|
+
this.create = this.Action('permission', 'create')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@test()
|
|
15
|
+
protected static async canCreateCreatingPermissions() {
|
|
16
|
+
assert.isFunction(this.create.execute)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@test()
|
|
20
|
+
protected static async createsFileBasedOnName() {
|
|
21
|
+
await this.create.execute({
|
|
22
|
+
nameReadable: 'booking',
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -19,6 +19,7 @@ import LogFeature from './log/LogFeature'
|
|
|
19
19
|
import NodeFeature from './node/NodeFeature'
|
|
20
20
|
import OnboardFeature from './onboard/OnboardFeature'
|
|
21
21
|
import OrganizationFeature from './organization/OrganizationFeature'
|
|
22
|
+
import PermissionFeature from './permission/PermissionFeature'
|
|
22
23
|
import PersonFeature from './person/PersonFeature'
|
|
23
24
|
import PolishFeature from './polish/PolishFeature'
|
|
24
25
|
import SandboxFeature from './sandbox/SandboxFeature'
|
|
@@ -52,6 +53,7 @@ export default class FeatureInstallerFactory {
|
|
|
52
53
|
LogFeature,
|
|
53
54
|
DependencyFeature,
|
|
54
55
|
PolishFeature,
|
|
56
|
+
PermissionFeature,
|
|
55
57
|
]
|
|
56
58
|
|
|
57
59
|
public static readonly featureCodes: FeatureCode[] = [
|
|
@@ -76,6 +78,7 @@ export default class FeatureInstallerFactory {
|
|
|
76
78
|
'log',
|
|
77
79
|
'dependency',
|
|
78
80
|
'polish',
|
|
81
|
+
'permission',
|
|
79
82
|
]
|
|
80
83
|
|
|
81
84
|
public static WithAllFeatures(options: {
|
|
@@ -5,10 +5,9 @@ import {
|
|
|
5
5
|
} from '@sprucelabs/schema'
|
|
6
6
|
import { eventNameUtil } from '@sprucelabs/spruce-event-utils'
|
|
7
7
|
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
8
|
+
import namedTemplateItemSchema from '#spruce/schemas/spruceCli/v2020_07_22/namedTemplateItem.schema'
|
|
8
9
|
import syncEventActionSchema from '#spruce/schemas/spruceCli/v2020_07_22/syncEventOptions.schema'
|
|
9
10
|
import SpruceError from '../../../errors/SpruceError'
|
|
10
|
-
import namedTemplateItemBuilder from '../../../schemas/v2020_07_22/namedTemplateItem.builder'
|
|
11
|
-
import syncEventActionBuilder from '../../../schemas/v2020_07_22/syncEventOptions.builder'
|
|
12
11
|
import actionUtil from '../../../utilities/action.utility'
|
|
13
12
|
import AbstractAction from '../../AbstractAction'
|
|
14
13
|
import { FeatureActionResponse } from '../../features.types'
|
|
@@ -19,17 +18,17 @@ const optionsSchema = buildSchema({
|
|
|
19
18
|
"Create a new event and I'll register it with Mercury when you boot the skill!",
|
|
20
19
|
fields: {
|
|
21
20
|
nameReadable: {
|
|
22
|
-
...
|
|
21
|
+
...namedTemplateItemSchema.fields.nameReadable,
|
|
23
22
|
isRequired: true,
|
|
24
23
|
},
|
|
25
24
|
nameKebab: {
|
|
26
|
-
...
|
|
25
|
+
...namedTemplateItemSchema.fields.nameKebab,
|
|
27
26
|
label: 'Event name',
|
|
28
27
|
hint: `kebab-case`,
|
|
29
28
|
isRequired: true,
|
|
30
29
|
},
|
|
31
30
|
nameCamel: {
|
|
32
|
-
...
|
|
31
|
+
...namedTemplateItemSchema.fields.nameCamel,
|
|
33
32
|
isRequired: true,
|
|
34
33
|
},
|
|
35
34
|
isGlobal: {
|
|
@@ -42,7 +41,7 @@ const optionsSchema = buildSchema({
|
|
|
42
41
|
label: 'Version',
|
|
43
42
|
isPrivate: true,
|
|
44
43
|
},
|
|
45
|
-
...
|
|
44
|
+
...syncEventActionSchema.fields,
|
|
46
45
|
},
|
|
47
46
|
})
|
|
48
47
|
|
|
@@ -2,12 +2,6 @@ import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
|
2
2
|
import AbstractFeature, { FeatureDependency } from '../AbstractFeature'
|
|
3
3
|
import { FeatureCode } from '../features.types'
|
|
4
4
|
|
|
5
|
-
declare module '../../features/features.types' {
|
|
6
|
-
interface FeatureMap {
|
|
7
|
-
organization: OrganizationFeature
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
5
|
export default class OrganizationFeature extends AbstractFeature {
|
|
12
6
|
public code: FeatureCode = 'organization'
|
|
13
7
|
public nameReadable = 'Organization'
|
|
@@ -26,3 +20,9 @@ export default class OrganizationFeature extends AbstractFeature {
|
|
|
26
20
|
|
|
27
21
|
public actionsDir = diskUtil.resolvePath(__dirname, 'actions')
|
|
28
22
|
}
|
|
23
|
+
|
|
24
|
+
declare module '../../features/features.types' {
|
|
25
|
+
interface FeatureMap {
|
|
26
|
+
organization: OrganizationFeature
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
2
|
+
import AbstractFeature, { FeatureDependency } from '../AbstractFeature'
|
|
3
|
+
import { FeatureCode } from '../features.types'
|
|
4
|
+
|
|
5
|
+
export default class PermissionFeature extends AbstractFeature {
|
|
6
|
+
public code: FeatureCode = 'permission'
|
|
7
|
+
public nameReadable = 'permission'
|
|
8
|
+
public description = 'Manage permissions for your skill'
|
|
9
|
+
public dependencies: FeatureDependency[] = [
|
|
10
|
+
{
|
|
11
|
+
code: 'skill',
|
|
12
|
+
isRequired: true,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
code: 'event',
|
|
16
|
+
isRequired: true,
|
|
17
|
+
},
|
|
18
|
+
]
|
|
19
|
+
public packageDependencies = []
|
|
20
|
+
|
|
21
|
+
public actionsDir = diskUtil.resolvePath(__dirname, 'actions')
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
declare module '../../features/features.types' {
|
|
25
|
+
interface FeatureMap {
|
|
26
|
+
permission: PermissionFeature
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { buildSchema, pickFields, SchemaValues } from '@sprucelabs/schema'
|
|
2
|
+
import namedTemplateItemSchema from '#spruce/schemas/spruceCli/v2020_07_22/namedTemplateItem.schema'
|
|
3
|
+
import AbstractAction from '../../AbstractAction'
|
|
4
|
+
import { FeatureActionResponse } from '../../features.types'
|
|
5
|
+
|
|
6
|
+
const schema = buildSchema({
|
|
7
|
+
id: 'createPermission',
|
|
8
|
+
fields: {
|
|
9
|
+
...pickFields(namedTemplateItemSchema.fields, [
|
|
10
|
+
'nameReadable',
|
|
11
|
+
'nameKebab',
|
|
12
|
+
]),
|
|
13
|
+
},
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
type OptionsSchema = typeof schema
|
|
17
|
+
type Options = SchemaValues<OptionsSchema>
|
|
18
|
+
|
|
19
|
+
export default class CreateAction extends AbstractAction<OptionsSchema> {
|
|
20
|
+
public optionsSchema = schema
|
|
21
|
+
public invocationMessage = 'Creating a permission contract... 🛡'
|
|
22
|
+
|
|
23
|
+
public async execute(_options: Options): Promise<FeatureActionResponse> {
|
|
24
|
+
// const { nameKebab, nameReadable } =
|
|
25
|
+
// this.validateAndNormalizeOptions(options)
|
|
26
|
+
|
|
27
|
+
return {}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -13,11 +13,13 @@ const optionsSchema = buildSchema({
|
|
|
13
13
|
type: 'text',
|
|
14
14
|
label: `What is your skill's name?`,
|
|
15
15
|
isRequired: true,
|
|
16
|
+
hint: 'The name people will see with their special eyes!',
|
|
16
17
|
},
|
|
17
18
|
nameKebab: {
|
|
18
19
|
type: 'text',
|
|
19
20
|
label: 'Namespace',
|
|
20
21
|
isRequired: true,
|
|
22
|
+
hint: 'The namespace of your skill in-kebab-case',
|
|
21
23
|
},
|
|
22
24
|
description: {
|
|
23
25
|
type: 'text',
|
|
@@ -4,16 +4,6 @@ import SpruceError from '../../../errors/SpruceError'
|
|
|
4
4
|
import AbstractStore from '../../../stores/AbstractStore'
|
|
5
5
|
import { CurrentSkill, RegisteredSkill } from '../../../types/cli.types'
|
|
6
6
|
|
|
7
|
-
export interface CreateSkill {
|
|
8
|
-
name: string
|
|
9
|
-
slug: string
|
|
10
|
-
description?: string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface RegisterSkillOptions {
|
|
14
|
-
isRegisteringCurrentSkill?: boolean
|
|
15
|
-
}
|
|
16
|
-
|
|
17
7
|
export default class SkillStore extends AbstractStore {
|
|
18
8
|
public readonly name = 'skill'
|
|
19
9
|
private static currentSkill?: CurrentSkill
|
|
@@ -31,7 +21,7 @@ export default class SkillStore extends AbstractStore {
|
|
|
31
21
|
|
|
32
22
|
isRegisteringCurrentSkill && this.assertInSkill()
|
|
33
23
|
|
|
34
|
-
const { name, slug, description } = values
|
|
24
|
+
const { name, slug, description, isPublished } = values
|
|
35
25
|
const client = await this.connectToApi()
|
|
36
26
|
|
|
37
27
|
const results = await client.emit('register-skill::v2020_12_25', {
|
|
@@ -39,6 +29,7 @@ export default class SkillStore extends AbstractStore {
|
|
|
39
29
|
name,
|
|
40
30
|
slug,
|
|
41
31
|
description,
|
|
32
|
+
isPublished,
|
|
42
33
|
},
|
|
43
34
|
})
|
|
44
35
|
|
|
@@ -189,3 +180,14 @@ export default class SkillStore extends AbstractStore {
|
|
|
189
180
|
return skills
|
|
190
181
|
}
|
|
191
182
|
}
|
|
183
|
+
|
|
184
|
+
export interface CreateSkill {
|
|
185
|
+
name: string
|
|
186
|
+
slug?: string
|
|
187
|
+
description?: string
|
|
188
|
+
isPublished?: boolean
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export interface RegisterSkillOptions {
|
|
192
|
+
isRegisteringCurrentSkill?: boolean
|
|
193
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { EventContract, SpruceSchemas } from '@sprucelabs/mercury-types'
|
|
2
2
|
import { namesUtil } from '@sprucelabs/spruce-skill-utils'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
CreateSkill,
|
|
5
|
+
RegisterSkillOptions,
|
|
6
|
+
} from '../../features/skill/stores/SkillStore'
|
|
4
7
|
import StoreFactory from '../../stores/StoreFactory'
|
|
5
8
|
import {
|
|
6
9
|
ApiClientFactory,
|
|
@@ -27,7 +30,7 @@ export default class SkillFixture {
|
|
|
27
30
|
}
|
|
28
31
|
|
|
29
32
|
public async seedDemoSkill(
|
|
30
|
-
values:
|
|
33
|
+
values: CreateSkill,
|
|
31
34
|
options?: { phone?: string }
|
|
32
35
|
) {
|
|
33
36
|
return this.registerCurrentSkill(values, {
|
|
@@ -37,7 +40,7 @@ export default class SkillFixture {
|
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
public async registerCurrentSkill(
|
|
40
|
-
values:
|
|
43
|
+
values: CreateSkill,
|
|
41
44
|
options?: RegisterSkillOptions & { phone?: string }
|
|
42
45
|
) {
|
|
43
46
|
await this.personFixture.loginAsDemoPerson(options?.phone)
|