@sprucelabs/spruce-cli 18.1.7 → 18.2.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.
- package/CHANGELOG.md +10 -0
- package/build/__tests__/behavioral/WatchingSkillViews.test.js +1 -1
- package/build/__tests__/behavioral/WatchingSkillViews.test.js.map +1 -1
- package/build/__tests__/behavioral/permissions/AbstractPermissionsTest.d.ts +8 -0
- package/build/__tests__/behavioral/permissions/AbstractPermissionsTest.js +85 -0
- package/build/__tests__/behavioral/permissions/AbstractPermissionsTest.js.map +1 -0
- package/build/__tests__/behavioral/permissions/CreatingPermissions.test.d.ts +5 -6
- package/build/__tests__/behavioral/permissions/CreatingPermissions.test.js +54 -34
- package/build/__tests__/behavioral/permissions/CreatingPermissions.test.js.map +1 -1
- package/build/__tests__/behavioral/permissions/PermissionStore.test.d.ts +24 -0
- package/build/__tests__/behavioral/permissions/PermissionStore.test.js +420 -0
- package/build/__tests__/behavioral/permissions/PermissionStore.test.js.map +1 -0
- package/build/__tests__/behavioral/permissions/SyncingPermissions.test.d.ts +7 -0
- package/build/__tests__/behavioral/permissions/SyncingPermissions.test.js +88 -0
- package/build/__tests__/behavioral/permissions/SyncingPermissions.test.js.map +1 -0
- package/build/__tests__/implementation/{GlobalEmitter.d.ts → GlobalEmitter.test.d.ts} +0 -0
- package/build/__tests__/implementation/{GlobalEmitter.js → GlobalEmitter.test.js} +1 -1
- package/build/__tests__/implementation/GlobalEmitter.test.js.map +1 -0
- package/build/__tests__/support/EventFaker.d.ts +5 -0
- package/build/__tests__/support/EventFaker.js +48 -0
- package/build/__tests__/support/EventFaker.js.map +1 -0
- package/build/features/error/writers/ErrorWriter.js +1 -4
- package/build/features/error/writers/ErrorWriter.js.map +1 -1
- package/build/features/event/EventFeature.js.map +1 -1
- package/build/features/event/writers/EventWriter.js +6 -2
- package/build/features/event/writers/EventWriter.js.map +1 -1
- package/build/features/permission/actions/CreateAction.d.ts +51 -24
- package/build/features/permission/actions/CreateAction.js +36 -10
- package/build/features/permission/actions/CreateAction.js.map +1 -1
- package/build/features/permission/actions/SyncAction.d.ts +16 -0
- package/build/features/permission/actions/SyncAction.js +71 -0
- package/build/features/permission/actions/SyncAction.js.map +1 -0
- package/build/features/permission/stores/PermissionStore.d.ts +7 -0
- package/build/features/permission/stores/PermissionStore.js +159 -0
- package/build/features/permission/stores/PermissionStore.js.map +1 -0
- package/build/features/permission/writers/PermissionWriter.d.ts +10 -0
- package/build/features/permission/writers/PermissionWriter.js +94 -0
- package/build/features/permission/writers/PermissionWriter.js.map +1 -0
- package/build/features/view/actions/WatchAction.js +1 -1
- package/build/features/view/actions/WatchAction.js.map +1 -1
- package/build/stores/StoreFactory.d.ts +2 -0
- package/build/stores/StoreFactory.js +3 -1
- package/build/stores/StoreFactory.js.map +1 -1
- package/build/tests/cleanTestData.js +25 -18
- package/build/tests/cleanTestData.js.map +1 -1
- package/build/writers/WriterFactory.d.ts +2 -0
- package/build/writers/WriterFactory.js +3 -1
- package/build/writers/WriterFactory.js.map +1 -1
- package/node_modules/@typescript-eslint/parser/package.json +6 -6
- package/node_modules/@typescript-eslint/scope-manager/dist/ScopeManager.js +9 -9
- package/node_modules/@typescript-eslint/scope-manager/dist/ScopeManager.js.map +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/definition/Definition.d.ts +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/definition/Definition.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/dom.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/dom.iterable.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/dom.iterable.js +1 -0
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/dom.iterable.js.map +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/dom.js +21 -7
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/dom.js.map +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/es2019.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/es2019.intl.d.ts +3 -0
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/es2019.intl.d.ts.map +1 -0
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/es2019.intl.js +12 -0
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/es2019.intl.js.map +1 -0
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/es2019.js +2 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/es2019.js.map +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/index.d.ts +1 -0
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/index.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/index.js +2 -0
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/index.js.map +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/webworker.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/webworker.iterable.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/webworker.iterable.js +2 -0
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/webworker.iterable.js.map +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/webworker.js +39 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/lib/webworker.js.map +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/referencer/ExportVisitor.d.ts +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/referencer/ExportVisitor.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/referencer/PatternVisitor.d.ts +2 -2
- package/node_modules/@typescript-eslint/scope-manager/dist/referencer/PatternVisitor.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/referencer/PatternVisitor.js +9 -9
- package/node_modules/@typescript-eslint/scope-manager/dist/referencer/PatternVisitor.js.map +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/referencer/Reference.js +17 -17
- package/node_modules/@typescript-eslint/scope-manager/dist/referencer/Reference.js.map +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/referencer/Referencer.js.map +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/scope/Scope.d.ts +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/scope/Scope.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/scope/ScopeBase.d.ts +1 -1
- package/node_modules/@typescript-eslint/scope-manager/dist/scope/ScopeBase.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/scope-manager/package.json +12 -12
- package/node_modules/@typescript-eslint/types/_ts3.4/dist/generated/ast-spec.d.ts +8 -2
- package/node_modules/@typescript-eslint/types/_ts3.4/dist/lib.d.ts +1 -1
- package/node_modules/@typescript-eslint/types/_ts3.4/dist/parser-options.d.ts +3 -3
- package/node_modules/@typescript-eslint/types/dist/generated/ast-spec.d.ts +8 -2
- package/node_modules/@typescript-eslint/types/dist/generated/ast-spec.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/types/dist/generated/ast-spec.js +1 -0
- package/node_modules/@typescript-eslint/types/dist/generated/ast-spec.js.map +1 -1
- package/node_modules/@typescript-eslint/types/dist/lib.d.ts +1 -1
- package/node_modules/@typescript-eslint/types/dist/lib.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/types/dist/parser-options.d.ts +3 -3
- package/node_modules/@typescript-eslint/types/dist/parser-options.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/types/package.json +3 -3
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/create-program/shared.d.ts +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/parseSettings/index.d.ts +2 -2
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/parser-options.d.ts +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/parser.d.ts +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/simple-traverse.d.ts +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/ts-estree/estree-to-ts-node-types.d.ts +2 -1
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/ts-estree/ts-nodes.d.ts +2 -2
- package/node_modules/@typescript-eslint/typescript-estree/dist/convert.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/convert.js +7 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/convert.js.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createWatchProgram.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createWatchProgram.js +9 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createWatchProgram.js.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/shared.d.ts +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/shared.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/index.d.ts +2 -2
- package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/index.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/warnAboutTSVersion.js +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/parser-options.d.ts +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/parser-options.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/parser.d.ts +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/parser.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/simple-traverse.d.ts +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/simple-traverse.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/ts-estree/estree-to-ts-node-types.d.ts +2 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/ts-estree/estree-to-ts-node-types.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/ts-estree/ts-nodes.d.ts +2 -2
- package/node_modules/@typescript-eslint/typescript-estree/dist/ts-estree/ts-nodes.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/package.json +6 -6
- package/node_modules/@typescript-eslint/visitor-keys/dist/visitor-keys.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/visitor-keys/dist/visitor-keys.js +1 -0
- package/node_modules/@typescript-eslint/visitor-keys/dist/visitor-keys.js.map +1 -1
- package/node_modules/@typescript-eslint/visitor-keys/package.json +4 -4
- package/package.json +28 -26
- package/src/__tests__/behavioral/WatchingSkillViews.test.ts +1 -1
- package/src/__tests__/behavioral/permissions/AbstractPermissionsTest.ts +20 -0
- package/src/__tests__/behavioral/permissions/CreatingPermissions.test.ts +32 -16
- package/src/__tests__/behavioral/permissions/PermissionStore.test.ts +233 -0
- package/src/__tests__/behavioral/permissions/SyncingPermissions.test.ts +25 -0
- package/src/__tests__/implementation/{GlobalEmitter.ts → GlobalEmitter.test.ts} +0 -0
- package/src/__tests__/support/EventFaker.ts +23 -0
- package/src/features/error/writers/ErrorWriter.ts +0 -2
- package/src/features/event/EventFeature.ts +0 -1
- package/src/features/event/writers/EventWriter.ts +4 -0
- package/src/features/permission/actions/CreateAction.ts +39 -16
- package/src/features/permission/actions/SyncAction.ts +23 -0
- package/src/features/permission/stores/PermissionStore.ts +51 -0
- package/src/features/permission/writers/PermissionWriter.ts +54 -0
- package/src/features/view/actions/WatchAction.ts +1 -1
- package/src/stores/StoreFactory.ts +5 -2
- package/src/tests/cleanTestData.ts +7 -3
- package/src/writers/WriterFactory.ts +3 -0
- package/build/__tests__/implementation/GlobalEmitter.js.map +0 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { test } from '@sprucelabs/test-utils'
|
|
2
|
+
import SyncAction from '../../../features/permission/actions/SyncAction'
|
|
3
|
+
import AbstractSkillTest from '../../../tests/AbstractSkillTest'
|
|
4
|
+
import testUtil from '../../../tests/utilities/test.utility'
|
|
5
|
+
|
|
6
|
+
export default class SyncingPermissionsTest extends AbstractSkillTest {
|
|
7
|
+
protected static skillCacheKey = 'permissions'
|
|
8
|
+
private static sync: SyncAction
|
|
9
|
+
|
|
10
|
+
protected static async beforeEach() {
|
|
11
|
+
await super.beforeEach()
|
|
12
|
+
this.sync = this.Action('permission', 'sync')
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@test()
|
|
16
|
+
protected static async generatesExpectedTypesFile() {
|
|
17
|
+
const results = await this.sync.execute()
|
|
18
|
+
const expected = this.resolveHashSprucePath(
|
|
19
|
+
`permissions/permissions.types.ts`
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
testUtil.assertFileByPathInGeneratedFiles(expected, results.files)
|
|
23
|
+
await this.assertValidActionResponseFiles(results)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SpruceSchemas } from '@sprucelabs/mercury-types'
|
|
2
|
+
import { eventFaker } from '@sprucelabs/spruce-test-fixtures'
|
|
3
|
+
|
|
4
|
+
export type ListPermContractsTargetAndPayload =
|
|
5
|
+
SpruceSchemas.Mercury.v2020_12_25.ListPermissionContractsEmitTargetAndPayload
|
|
6
|
+
export default class EventFaker {
|
|
7
|
+
public async fakeListPermissionContracts(
|
|
8
|
+
cb?: (
|
|
9
|
+
targetAndPayload: ListPermContractsTargetAndPayload
|
|
10
|
+
) =>
|
|
11
|
+
| void
|
|
12
|
+
| SpruceSchemas.Mercury.v2020_12_25.ListPermissionContractsResponsePayload['permissionContracts']
|
|
13
|
+
) {
|
|
14
|
+
await eventFaker.on(
|
|
15
|
+
'list-permission-contracts::v2020_12_25',
|
|
16
|
+
(targetAndPayload) => {
|
|
17
|
+
return {
|
|
18
|
+
permissionContracts: cb?.(targetAndPayload) ?? [],
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -219,7 +219,6 @@ export default class EventFeature extends AbstractFeature {
|
|
|
219
219
|
public hasBeenSynced() {
|
|
220
220
|
if (diskUtil.doesHashSprucePathExist(this.cwd)) {
|
|
221
221
|
const writer = this.Writer('event')
|
|
222
|
-
|
|
223
222
|
return writer.hasCombinedContractBeenWritten(this.cwd)
|
|
224
223
|
}
|
|
225
224
|
|
|
@@ -233,6 +233,8 @@ export default class EventWriter extends AbstractWriter {
|
|
|
233
233
|
description: 'Permissions someone else will need to emit your event.',
|
|
234
234
|
context: {
|
|
235
235
|
nameCamel: nameCamel + 'Emit',
|
|
236
|
+
nameKebab,
|
|
237
|
+
description: '',
|
|
236
238
|
},
|
|
237
239
|
},
|
|
238
240
|
{
|
|
@@ -243,6 +245,8 @@ export default class EventWriter extends AbstractWriter {
|
|
|
243
245
|
'Permissions someone else will need to listen to your event.',
|
|
244
246
|
context: {
|
|
245
247
|
nameCamel: nameCamel + 'Listen',
|
|
248
|
+
nameKebab,
|
|
249
|
+
description: '',
|
|
246
250
|
},
|
|
247
251
|
},
|
|
248
252
|
{
|
|
@@ -1,29 +1,52 @@
|
|
|
1
1
|
import { buildSchema, pickFields, SchemaValues } from '@sprucelabs/schema'
|
|
2
|
+
import { diskUtil, namesUtil } from '@sprucelabs/spruce-skill-utils'
|
|
2
3
|
import namedTemplateItemSchema from '#spruce/schemas/spruceCli/v2020_07_22/namedTemplateItem.schema'
|
|
3
4
|
import AbstractAction from '../../AbstractAction'
|
|
4
5
|
import { FeatureActionResponse } from '../../features.types'
|
|
5
6
|
|
|
7
|
+
export default class CreateAction extends AbstractAction<OptionsSchema> {
|
|
8
|
+
public optionsSchema = schema
|
|
9
|
+
public invocationMessage = 'Creating a permission contract... 🛡'
|
|
10
|
+
public readonly commandAliases: string[] = [
|
|
11
|
+
'create.permissions',
|
|
12
|
+
'create.permission',
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
public async execute(options: Options): Promise<FeatureActionResponse> {
|
|
16
|
+
const { nameKebab, nameReadable, nameCamel, description } =
|
|
17
|
+
this.validateAndNormalizeOptions(options)
|
|
18
|
+
|
|
19
|
+
const destination = diskUtil.resolvePath(this.cwd, 'src', 'permissions')
|
|
20
|
+
|
|
21
|
+
const writer = this.Writer('permission')
|
|
22
|
+
const files = await writer.writeContract(destination, {
|
|
23
|
+
nameKebab: nameKebab ?? namesUtil.toKebab(nameReadable),
|
|
24
|
+
nameReadable,
|
|
25
|
+
nameCamel,
|
|
26
|
+
description,
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
files,
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
6
35
|
const schema = buildSchema({
|
|
7
36
|
id: 'createPermission',
|
|
8
37
|
fields: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
38
|
+
nameReadable: {
|
|
39
|
+
...namedTemplateItemSchema.fields.nameReadable,
|
|
40
|
+
label: `Name your permission contract`,
|
|
41
|
+
hint: `A contract contains many permissions grouped by a responsibility`,
|
|
42
|
+
},
|
|
43
|
+
...pickFields(namedTemplateItemSchema.fields, ['nameCamel', 'nameKebab']),
|
|
44
|
+
description: {
|
|
45
|
+
...namedTemplateItemSchema.fields.description,
|
|
46
|
+
label: `Describe this contract`,
|
|
47
|
+
},
|
|
13
48
|
},
|
|
14
49
|
})
|
|
15
50
|
|
|
16
51
|
type OptionsSchema = typeof schema
|
|
17
52
|
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
|
-
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { buildSchema } from '@sprucelabs/schema'
|
|
2
|
+
import AbstractAction from '../../AbstractAction'
|
|
3
|
+
import { FeatureActionResponse } from '../../features.types'
|
|
4
|
+
|
|
5
|
+
export default class SyncAction extends AbstractAction<OptionsSchema> {
|
|
6
|
+
public invocationMessage = 'Syncing permissions... 🛡'
|
|
7
|
+
public optionsSchema = schema
|
|
8
|
+
|
|
9
|
+
public async execute(): Promise<FeatureActionResponse> {
|
|
10
|
+
const files = await this.Writer('permission').writeTypesFile(this.cwd)
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
files,
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const schema = buildSchema({
|
|
19
|
+
id: 'syncPermissions',
|
|
20
|
+
fields: {},
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
type OptionsSchema = typeof schema
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PermissionContract,
|
|
3
|
+
PermissionContractMap,
|
|
4
|
+
} from '@sprucelabs/mercury-types'
|
|
5
|
+
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
6
|
+
import globby from 'globby'
|
|
7
|
+
import AbstractStore from '../../../stores/AbstractStore'
|
|
8
|
+
|
|
9
|
+
export default class PermissionStore extends AbstractStore {
|
|
10
|
+
public name = 'permission'
|
|
11
|
+
|
|
12
|
+
private async loadLocalPermissions() {
|
|
13
|
+
const matches = await globby('**/*.permissions.ts', {
|
|
14
|
+
cwd: this.cwd,
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const map: PermissionContractMap = {}
|
|
18
|
+
|
|
19
|
+
for (const file of matches) {
|
|
20
|
+
const contract = (await this.Service('import').importDefault(
|
|
21
|
+
diskUtil.resolvePath(this.cwd, file)
|
|
22
|
+
)) as PermissionContract
|
|
23
|
+
|
|
24
|
+
map[contract.id] = contract.permissions.map((p) => p.id)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return map
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public async fetchContracts() {
|
|
31
|
+
const client = await this.connectToApi()
|
|
32
|
+
const deps = this.Service('dependency').get()
|
|
33
|
+
|
|
34
|
+
const [{ permissionContracts }] = await client.emitAndFlattenResponses(
|
|
35
|
+
'list-permission-contracts::v2020_12_25',
|
|
36
|
+
{
|
|
37
|
+
target: {
|
|
38
|
+
namespaces: deps.map((d) => d.namespace),
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
const map: PermissionContractMap = await this.loadLocalPermissions()
|
|
44
|
+
|
|
45
|
+
for (const result of permissionContracts) {
|
|
46
|
+
map[result.contract.id] = result.contract.permissions.map((p) => p.id)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return map
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
2
|
+
import AbstractWriter from '../../../writers/AbstractWriter'
|
|
3
|
+
|
|
4
|
+
export default class PermissionWriter extends AbstractWriter {
|
|
5
|
+
public async writeTypesFile(destinationDir: string) {
|
|
6
|
+
const destination = diskUtil.resolveHashSprucePath(
|
|
7
|
+
destinationDir,
|
|
8
|
+
'permissions',
|
|
9
|
+
'permissions.types.ts'
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
const files = await this.writeFileIfChangedMixinResults(
|
|
13
|
+
destination,
|
|
14
|
+
'',
|
|
15
|
+
'Types file for any permission contracts you created or depend on.'
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
return files
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public async writeContract(
|
|
22
|
+
destinationDir: string,
|
|
23
|
+
options: {
|
|
24
|
+
nameReadable: string
|
|
25
|
+
nameKebab: string
|
|
26
|
+
nameCamel: string
|
|
27
|
+
description?: string
|
|
28
|
+
}
|
|
29
|
+
) {
|
|
30
|
+
const { nameReadable, nameKebab, nameCamel, description } = options
|
|
31
|
+
|
|
32
|
+
const destination = diskUtil.resolvePath(
|
|
33
|
+
destinationDir,
|
|
34
|
+
`${nameKebab}.permissions.ts`
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
const content = this.templates.permissionContractBuilder({
|
|
38
|
+
nameCamel,
|
|
39
|
+
nameKebab,
|
|
40
|
+
description,
|
|
41
|
+
nameReadable,
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
const files = await this.writeFileIfChangedMixinResults(
|
|
45
|
+
destination,
|
|
46
|
+
content,
|
|
47
|
+
'Your brand new permissions contract!'
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
await this.lint(destination)
|
|
51
|
+
|
|
52
|
+
return files
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -24,7 +24,7 @@ export default class WatchAction extends AbstractAction<OptionsSchema> {
|
|
|
24
24
|
this.resetUi()
|
|
25
25
|
const commands = this.Service('command')
|
|
26
26
|
await commands.execute(
|
|
27
|
-
'ENABLED_SKILL_FEATURES=view,event
|
|
27
|
+
'ENABLED_SKILL_FEATURES=view,event SHOULD_WATCH_VIEWS=true MAXIMUM_LOG_PREFIXES_LENGTH=0 yarn boot',
|
|
28
28
|
{
|
|
29
29
|
onData: (data) => {
|
|
30
30
|
const line = this.popLastLine(data)
|
|
@@ -3,6 +3,7 @@ import EventStore from '../features/event/stores/EventStore'
|
|
|
3
3
|
import ListenerStore from '../features/event/stores/ListenerStore'
|
|
4
4
|
import OnboardingStore from '../features/onboard/stores/OnboardingStore'
|
|
5
5
|
import OrganizationStore from '../features/organization/stores/OrganizationStore'
|
|
6
|
+
import PermissionStore from '../features/permission/stores/PermissionStore'
|
|
6
7
|
import SchemaStore from '../features/schema/stores/SchemaStore'
|
|
7
8
|
import SkillStore, {
|
|
8
9
|
SkillStoreOptions,
|
|
@@ -74,10 +75,9 @@ export interface StoreMap {
|
|
|
74
75
|
store: StoreStore
|
|
75
76
|
view: ViewStore
|
|
76
77
|
listener: ListenerStore
|
|
78
|
+
permission: PermissionStore
|
|
77
79
|
}
|
|
78
80
|
|
|
79
|
-
export type StoreCode = keyof StoreMap
|
|
80
|
-
|
|
81
81
|
const storeMap = {
|
|
82
82
|
onboarding: OnboardingStore,
|
|
83
83
|
schema: SchemaStore,
|
|
@@ -88,8 +88,11 @@ const storeMap = {
|
|
|
88
88
|
store: StoreStore,
|
|
89
89
|
view: ViewStore,
|
|
90
90
|
listener: ListenerStore,
|
|
91
|
+
permission: PermissionStore,
|
|
91
92
|
}
|
|
92
93
|
|
|
94
|
+
export type StoreCode = keyof StoreMap
|
|
95
|
+
|
|
93
96
|
export interface StoreFactoryOptions {
|
|
94
97
|
cwd: string
|
|
95
98
|
serviceFactory: ServiceFactory
|
|
@@ -50,9 +50,13 @@ async function run() {
|
|
|
50
50
|
const totalOrgs = await orgFixture.clearAllOrgs()
|
|
51
51
|
term.renderLine(`${totalOrgs} orgs deleted`)
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
try {
|
|
54
|
+
term.renderLine('Deleting skills')
|
|
55
|
+
const totalSkills = await skillFixture.clearAllSkills()
|
|
56
|
+
term.renderLine(`${totalSkills} deleted`)
|
|
57
|
+
} catch (err: any) {
|
|
58
|
+
console.error(err.stack ?? err.message)
|
|
59
|
+
}
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
await mercuryFixture.disconnectAll()
|
|
@@ -6,6 +6,7 @@ import ErrorWriter from '../features/error/writers/ErrorWriter'
|
|
|
6
6
|
import EventWriter from '../features/event/writers/EventWriter'
|
|
7
7
|
import LogWriter from '../features/log/writers/LogWriter'
|
|
8
8
|
import NodeWriter from '../features/node/writers/NodeWriter'
|
|
9
|
+
import PermissionWriter from '../features/permission/writers/PermissionWriter'
|
|
9
10
|
import PolishWriter from '../features/polish/writers/PolishWriter'
|
|
10
11
|
import SandboxWriter from '../features/sandbox/writers/SandboxWriter'
|
|
11
12
|
import SchemaWriter from '../features/schema/writers/SchemaWriter'
|
|
@@ -34,6 +35,7 @@ const classMap = {
|
|
|
34
35
|
view: ViewWriter,
|
|
35
36
|
log: LogWriter,
|
|
36
37
|
polish: PolishWriter,
|
|
38
|
+
permission: PermissionWriter,
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
export interface WriterMap {
|
|
@@ -51,6 +53,7 @@ export interface WriterMap {
|
|
|
51
53
|
view: ViewWriter
|
|
52
54
|
log: LogWriter
|
|
53
55
|
polish: PolishWriter
|
|
56
|
+
permission: PermissionWriter
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
export type WriterCode = keyof WriterMap
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalEmitter.js","names":["GlobalEmitterTest","test","assert","isTrue","emitter","shouldEmitSequentally","AbstractCliTest"],"sources":["../../../src/__tests__/implementation/GlobalEmitter.ts"],"sourcesContent":["import { test, assert } from '@sprucelabs/test-utils'\nimport AbstractCliTest from '../../tests/AbstractCliTest'\n\nexport default class GlobalEmitterTest extends AbstractCliTest {\n\t@test()\n\tprotected static async globalEmitterEmitsEquentally() {\n\t\t//@ts-ignore\n\t\tassert.isTrue(this.emitter.shouldEmitSequentally)\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AACA;AAAyD;AAAA;AAAA;AAAA,IAEpCA,iBAAiB,WACpC,IAAAC,eAAI,GAAE;EAAA;EAAA;EAAA;IAAA;IAAA;EAAA;EAAA;IAAA;IAAA;MAAA,kHAAP;QAAA;UAAA;YAAA;cAAA;gBAEC;gBACAC,iBAAM,CAACC,MAAM,CAAC,IAAI,CAACC,OAAO,CAACC,qBAAqB,CAAC;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,CACjD;MAAA;QAAA;MAAA;MAAA;IAAA;EAAA;EAAA;AAAA,EAL6CC,4BAAe;AAAA"}
|