@sprucelabs/spruce-cli 14.29.5 → 14.29.9
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 +32 -0
- package/build/GlobalEmitter.js +2 -2
- package/build/__tests__/behavioral/InstallingASkillAtAnOrg.test.d.ts +1 -1
- package/build/__tests__/behavioral/InstallingASkillAtAnOrg.test.js +93 -93
- package/build/__tests__/behavioral/InstallingASkillAtAnOrg.test.js.map +1 -1
- package/build/__tests__/behavioral/SettingUpSchemasForModuleDistribution.test.js +2 -2
- package/build/__tests__/behavioral/events/CreatingAnEvent.test.js +2 -2
- package/build/__tests__/behavioral/events/KeepingEventsInSync2.test.js +2 -2
- package/build/__tests__/behavioral/views/CreatingASkillView.test.d.ts +1 -0
- package/build/__tests__/behavioral/views/CreatingASkillView.test.js +35 -3
- package/build/__tests__/behavioral/views/CreatingASkillView.test.js.map +1 -1
- package/build/__tests__/implementation/EventContractCleanerUtil.test.js +2 -2
- package/build/__tests__/implementation/EventTemplateItemBuilder.test.js +2 -2
- package/build/__tests__/implementation/PkgService.test.js +3 -6
- package/build/__tests__/implementation/PkgService.test.js.map +1 -1
- package/build/__tests__/implementation/SchemaStore.test.js +2 -2
- package/build/__tests__/implementation/SchemaTemplateItemBuilder.test.js +2 -2
- package/build/cli.js +11 -9
- package/build/cli.js.map +1 -1
- package/build/components/AbstractComponent.js +2 -2
- package/build/components/FormComponent.js +2 -2
- package/build/components/QuizComponent.js +2 -2
- package/build/features/AbstractAction.js +2 -2
- package/build/features/AbstractFeature.js +2 -2
- package/build/features/ActionExecuter.js +2 -2
- package/build/features/ActionFactory.js +2 -2
- package/build/features/ActionQuestionAsker.js +2 -2
- package/build/features/FeatureCommandAttacher.js +2 -2
- package/build/features/FeatureInstaller.js +2 -2
- package/build/features/OverrideActionDecorator.js +2 -2
- package/build/features/deploy/actions/HerokuAction.js.map +1 -1
- package/build/features/error/actions/CreateAction.js +2 -2
- package/build/features/error/actions/SyncAction.js +2 -2
- package/build/features/error/writers/ErrorWriter.js +2 -2
- package/build/features/event/EventFeature.js.map +1 -1
- package/build/features/event/actions/CreateAction.js +2 -2
- package/build/features/event/actions/ListenAction.js +2 -2
- package/build/features/event/builders/EventContractBuilder.js +2 -2
- package/build/features/event/builders/ListenerTemplateItemBuilder.js +2 -2
- package/build/features/event/stores/EventStore.js +2 -2
- package/build/features/event/stores/ListenerStore.js +2 -2
- package/build/features/event/writers/EventWriter.js +2 -2
- package/build/features/eventContract/EventContractFeature.js +3 -1
- package/build/features/eventContract/EventContractFeature.js.map +1 -1
- package/build/features/node/NodeFeature.js +12 -10
- package/build/features/node/NodeFeature.js.map +1 -1
- package/build/features/node/actions/UpgradeAction.js +10 -9
- package/build/features/node/actions/UpgradeAction.js.map +1 -1
- package/build/features/node/writers/NodeWriter.js +2 -2
- package/build/features/organization/OrganizationFeature.js +3 -1
- package/build/features/organization/OrganizationFeature.js.map +1 -1
- package/build/features/person/PersonFeature.js +3 -1
- package/build/features/person/PersonFeature.js.map +1 -1
- package/build/features/person/actions/LoginAction.js +2 -2
- package/build/features/sandbox/SandboxFeature.js +3 -1
- package/build/features/sandbox/SandboxFeature.js.map +1 -1
- package/build/features/schema/actions/CreateAction.js +2 -2
- package/build/features/schema/stores/SchemaStore.js +2 -2
- package/build/features/schema/utilities/schemaDisk.utility.js +2 -2
- package/build/features/schema/writers/SchemaWriter.js +2 -2
- package/build/features/skill/SkillFeature.js +2 -2
- package/build/features/skill/actions/CreateAction.js +2 -2
- package/build/features/skill/stores/SkillStore.js +2 -2
- package/build/features/skill/writers/SkillWriter.js +2 -2
- package/build/features/store/actions/CreateAction.js +2 -2
- package/build/features/test/TestFeature.js +2 -2
- package/build/features/test/TestReporter.js +2 -2
- package/build/features/test/TestRunner.js +2 -2
- package/build/features/test/actions/CreateAction.js +2 -2
- package/build/features/validateAndNormalize.utility.js +2 -2
- package/build/features/view/actions/CreateAction.js +2 -2
- package/build/features/view/writers/ViewWriter.js +2 -2
- package/build/features/vscode/VsCodeFeature.js +3 -1
- package/build/features/vscode/VsCodeFeature.js.map +1 -1
- package/build/interfaces/TerminalInterface.js +2 -2
- package/build/schemas/v2020_07_22/createConversationTopicOptions.builder.js +2 -2
- package/build/schemas/v2020_07_22/createErrorOptions.builder.js +2 -2
- package/build/schemas/v2020_07_22/createOrganizationOptions.builder.js +2 -2
- package/build/schemas/v2020_07_22/createSchemaOptions.builder.js +2 -2
- package/build/schemas/v2020_07_22/listenEventOptions.builder.js +2 -2
- package/build/schemas/v2020_07_22/syncErrorOptions.builder.js +2 -2
- package/build/schemas/v2020_07_22/syncSchemasOptions.builder.js +2 -2
- package/build/services/CommandService.js +2 -2
- package/build/services/PkgService.d.ts +4 -16
- package/build/services/PkgService.js +11 -127
- package/build/services/PkgService.js.map +1 -1
- package/build/services/ServiceFactory.d.ts +1 -2
- package/build/services/ServiceFactory.js +2 -4
- package/build/services/ServiceFactory.js.map +1 -1
- package/build/services/TypeCheckerService.js +4 -3
- package/build/services/TypeCheckerService.js.map +1 -1
- package/build/stores/AbstractLocalStore.js +2 -2
- package/build/templateItemBuilders/EventTemplateItemBuilder.js +2 -2
- package/build/templateItemBuilders/SchemaTemplateItemBuilder.js +2 -2
- package/build/tests/AbstractCliTest.js +2 -2
- package/build/tests/AbstractEventTest.js +2 -2
- package/build/tests/AbstractSchemaTest.js +2 -2
- package/build/tests/JestJsonParser.js +2 -2
- package/build/tests/fixtures/FeatureFixture.js +2 -2
- package/build/tests/fixtures/OrganizationFixture.js +2 -2
- package/build/tests/fixtures/PersonFixture.js +2 -2
- package/build/tests/fixtures/SkillFixture.js +2 -2
- package/build/types/cli.types.d.ts +1 -6
- package/build/types/cli.types.js +8 -0
- package/build/types/cli.types.js.map +1 -1
- package/build/updaters/ScriptUpdater.js +2 -2
- package/build/utilities/commander.utility.js +2 -2
- package/build/utilities/eventContractCleaner.utility.js +2 -2
- package/build/widgets/WidgetFactory.js +2 -2
- package/build/widgets/terminalKit/TKButtonWidget.js +2 -2
- package/build/widgets/terminalKit/TkBaseWidget.js +2 -2
- package/build/widgets/terminalKit/TkInputWidget.js +2 -2
- package/build/widgets/terminalKit/TkLayoutCellWidget.js +2 -2
- package/build/widgets/terminalKit/TkLayoutWidget.js +2 -2
- package/build/widgets/terminalKit/TkMenuBarWidget.js +2 -2
- package/build/widgets/terminalKit/TkPopupWidget.js +2 -2
- package/build/widgets/terminalKit/TkProgressBarWidget.js +2 -2
- package/build/widgets/terminalKit/TkTextWidget.js +2 -2
- package/build/widgets/terminalKit/termKit.utility.js +2 -2
- package/build/writers/AbstractWriter.js +2 -2
- package/build/writers/WriterFactory.js +2 -2
- package/package.json +38 -38
- package/src/__tests__/behavioral/InstallingASkillAtAnOrg.test.ts +6 -6
- package/src/__tests__/behavioral/views/CreatingASkillView.test.ts +16 -0
- package/src/__tests__/implementation/PkgService.test.ts +1 -2
- package/src/cli.ts +4 -1
- package/src/features/deploy/actions/HerokuAction.ts +1 -2
- package/src/features/event/EventFeature.ts +0 -1
- package/src/features/node/NodeFeature.ts +3 -0
- package/src/features/node/actions/UpgradeAction.ts +1 -0
- package/src/services/PkgService.ts +13 -93
- package/src/services/ServiceFactory.ts +10 -7
- package/src/types/cli.types.ts +1 -6
- package/build/__tests__/implementation/AuthService.test.d.ts +0 -14
- package/build/__tests__/implementation/AuthService.test.js +0 -255
- package/build/__tests__/implementation/AuthService.test.js.map +0 -1
- package/build/services/AuthService.d.ts +0 -23
- package/build/services/AuthService.js +0 -109
- package/build/services/AuthService.js.map +0 -1
- package/src/__tests__/implementation/AuthService.test.ts +0 -95
- package/src/services/AuthService.ts +0 -91
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { diskUtil, HASH_SPRUCE_DIR } from '@sprucelabs/spruce-skill-utils'
|
|
2
|
-
import { test, assert } from '@sprucelabs/test'
|
|
3
|
-
import { errorAssertUtil } from '@sprucelabs/test-utils'
|
|
4
|
-
import AuthService from '../../services/AuthService'
|
|
5
|
-
import AbstractCliTest from '../../tests/AbstractCliTest'
|
|
6
|
-
|
|
7
|
-
export default class AuthServiceTest extends AbstractCliTest {
|
|
8
|
-
private static auth: AuthService
|
|
9
|
-
protected static async beforeEach() {
|
|
10
|
-
await super.beforeEach()
|
|
11
|
-
diskUtil.createDir(this.resolvePath(HASH_SPRUCE_DIR))
|
|
12
|
-
this.auth = this.Service('auth')
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
@test()
|
|
16
|
-
protected static async canInstantiatePersonStore() {
|
|
17
|
-
assert.isTruthy(this.auth)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
@test()
|
|
21
|
-
protected static async hasLoggedInPersonMethod() {
|
|
22
|
-
assert.isFunction(this.auth.getLoggedInPerson)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@test()
|
|
26
|
-
protected static async loggedInPersonIsNullWhenNotLoggedIn() {
|
|
27
|
-
assert.isNull(this.auth.getLoggedInPerson())
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@test()
|
|
31
|
-
protected static async cantSaveBadLoggedInPerson() {
|
|
32
|
-
const err = assert.doesThrow(() =>
|
|
33
|
-
//@ts-ignore
|
|
34
|
-
this.auth.setLoggedInPerson({ test: true })
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
errorAssertUtil.assertError(err, 'MISSING_PARAMETERS')
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@test()
|
|
41
|
-
protected static canSaveLoggedInPerson() {
|
|
42
|
-
const auth = this.auth
|
|
43
|
-
const person = {
|
|
44
|
-
id: 'test',
|
|
45
|
-
casualName: 'friend',
|
|
46
|
-
token: 'token',
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
auth.setLoggedInPerson(person)
|
|
50
|
-
|
|
51
|
-
const loggedIn = auth.getLoggedInPerson()
|
|
52
|
-
|
|
53
|
-
assert.isEqualDeep(loggedIn, { ...person, isLoggedIn: true })
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
@test()
|
|
57
|
-
protected static canLogOut() {
|
|
58
|
-
const auth = this.auth
|
|
59
|
-
const person = {
|
|
60
|
-
id: 'test',
|
|
61
|
-
casualName: 'friend',
|
|
62
|
-
token: 'token',
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
auth.setLoggedInPerson(person)
|
|
66
|
-
auth.logOutPerson()
|
|
67
|
-
|
|
68
|
-
assert.isNull(auth.getLoggedInPerson())
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
@test()
|
|
72
|
-
protected static getCurrentSkillReturnsNull() {
|
|
73
|
-
this.writePackageJson()
|
|
74
|
-
assert.isNull(this.auth.getCurrentSkill())
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
@test()
|
|
78
|
-
protected static canSetCurrentSkill() {
|
|
79
|
-
this.writePackageJson()
|
|
80
|
-
const skill = {
|
|
81
|
-
id: '123467aaoeuaoeu',
|
|
82
|
-
apiKey: 'taco',
|
|
83
|
-
name: 'go team',
|
|
84
|
-
slug: 'taco-bravo',
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
this.auth.updateCurrentSkill(skill)
|
|
88
|
-
|
|
89
|
-
assert.isEqualDeep(this.auth.getCurrentSkill(), skill)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
private static writePackageJson() {
|
|
93
|
-
diskUtil.writeFile(this.resolvePath('package.json'), '{}')
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { SpruceSchemas } from '@sprucelabs/mercury-types'
|
|
2
|
-
import { normalizeSchemaValues, validateSchemaValues } from '@sprucelabs/schema'
|
|
3
|
-
import { EnvService, namesUtil } from '@sprucelabs/spruce-skill-utils'
|
|
4
|
-
import personWithTokenSchema from '#spruce/schemas/spruceCli/v2020_07_22/personWithToken.schema'
|
|
5
|
-
import PkgService from './PkgService'
|
|
6
|
-
|
|
7
|
-
type PersonWithToken = SpruceSchemas.SpruceCli.v2020_07_22.PersonWithToken
|
|
8
|
-
|
|
9
|
-
export interface SkillAuth {
|
|
10
|
-
id: string
|
|
11
|
-
apiKey: string
|
|
12
|
-
name: string
|
|
13
|
-
slug: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const LOGGED_IN_PERSON_KEY = 'LOGGED_IN_PERSON'
|
|
17
|
-
|
|
18
|
-
export default class AuthService {
|
|
19
|
-
private env: EnvService
|
|
20
|
-
private pkg: PkgService
|
|
21
|
-
|
|
22
|
-
public constructor(envService: EnvService, pkgService: PkgService) {
|
|
23
|
-
this.env = envService
|
|
24
|
-
this.pkg = pkgService
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public getLoggedInPerson(): PersonWithToken | null {
|
|
28
|
-
const p = this.env.get(LOGGED_IN_PERSON_KEY)
|
|
29
|
-
if (typeof p === 'string') {
|
|
30
|
-
return JSON.parse(p)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return null
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public setLoggedInPerson(person: PersonWithToken) {
|
|
37
|
-
const normalized = normalizeSchemaValues(personWithTokenSchema, person)
|
|
38
|
-
validateSchemaValues(personWithTokenSchema, normalized)
|
|
39
|
-
|
|
40
|
-
this.env.set(
|
|
41
|
-
LOGGED_IN_PERSON_KEY,
|
|
42
|
-
JSON.stringify({
|
|
43
|
-
...normalized,
|
|
44
|
-
isLoggedIn: true,
|
|
45
|
-
})
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
public logOutPerson() {
|
|
50
|
-
this.env.unset(LOGGED_IN_PERSON_KEY)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
public getCurrentSkill(): SkillAuth | null {
|
|
54
|
-
const id = this.env.get('SKILL_ID') as string
|
|
55
|
-
const apiKey = this.env.get('SKILL_API_KEY') as string
|
|
56
|
-
const name = this.env.get('SKILL_NAME') as string
|
|
57
|
-
const slug = this.pkg.get('skill.namespace') as string
|
|
58
|
-
|
|
59
|
-
if (id && apiKey) {
|
|
60
|
-
return {
|
|
61
|
-
id,
|
|
62
|
-
apiKey,
|
|
63
|
-
name,
|
|
64
|
-
slug,
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return null
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
public logoutCurrentSkill() {
|
|
72
|
-
this.env.unset('SKILL_ID')
|
|
73
|
-
this.env.unset('SKILL_API_KEY')
|
|
74
|
-
this.env.unset('SKILL_NAME')
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
public updateCurrentSkill(skill: SkillAuth) {
|
|
78
|
-
this.env.set('SKILL_ID', skill.id)
|
|
79
|
-
this.env.set('SKILL_API_KEY', skill.apiKey)
|
|
80
|
-
this.env.set('SKILL_NAME', skill.name)
|
|
81
|
-
|
|
82
|
-
this.updateCurrentSkillNamespace(skill.slug)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
public updateCurrentSkillNamespace(namespace: string) {
|
|
86
|
-
this.pkg.set({
|
|
87
|
-
path: 'skill.namespace',
|
|
88
|
-
value: namesUtil.toKebab(namespace),
|
|
89
|
-
})
|
|
90
|
-
}
|
|
91
|
-
}
|