@sprucelabs/spruce-cli 14.29.2 → 14.29.6
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/__tests__/behavioral/events/CreatingAListener.test.d.ts +1 -0
- package/build/__tests__/behavioral/events/CreatingAListener.test.js +67 -24
- package/build/__tests__/behavioral/events/CreatingAListener.test.js.map +1 -1
- package/build/__tests__/behavioral/{ListeningToAnEventYouCreate.test.d.ts → events/ListeningToAnEventYouCreate.test.d.ts} +1 -1
- package/build/__tests__/behavioral/{ListeningToAnEventYouCreate.test.js → events/ListeningToAnEventYouCreate.test.js} +2 -2
- package/build/__tests__/behavioral/events/ListeningToAnEventYouCreate.test.js.map +1 -0
- package/build/__tests__/implementation/PkgService.test.js +3 -6
- package/build/__tests__/implementation/PkgService.test.js.map +1 -1
- package/build/cli.js +9 -7
- package/build/cli.js.map +1 -1
- package/build/features/deploy/actions/HerokuAction.js.map +1 -1
- package/build/features/skill/actions/RegisterAction.js +1 -0
- package/build/features/skill/actions/RegisterAction.js.map +1 -1
- package/build/schemas/v2020_07_22/personWithToken.builder.js +1 -0
- package/build/schemas/v2020_07_22/personWithToken.builder.js.map +1 -1
- 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/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/package.json +34 -34
- package/src/__tests__/behavioral/events/CreatingAListener.test.ts +20 -0
- package/src/__tests__/behavioral/{ListeningToAnEventYouCreate.test.ts → events/ListeningToAnEventYouCreate.test.ts} +2 -2
- 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/skill/actions/RegisterAction.ts +3 -0
- package/src/schemas/v2020_07_22/personWithToken.builder.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__/behavioral/ListeningToAnEventYouCreate.test.js.map +0 -1
- package/build/__tests__/behavioral/README.md +0 -8
- 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/__tests__/implementation/README.md +0 -5
- package/build/components/README.md +0 -5
- 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__/behavioral/README.md +0 -8
- package/src/__tests__/implementation/AuthService.test.ts +0 -95
- package/src/__tests__/implementation/README.md +0 -5
- package/src/components/README.md +0 -5
- package/src/services/AuthService.ts +0 -91
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/services/ServiceFactory.ts"],"names":["ServiceFactory","cwd","type","AuthService","
|
|
1
|
+
{"version":3,"sources":["../../src/services/ServiceFactory.ts"],"names":["ServiceFactory","cwd","type","AuthService","Auth","PkgService","Service","EnvService","VsCodeService","SchemaService","command","CommandService","LintService","RemoteService","TypeCheckerService","buildImportService","SettingsService","DependencyService","commandService","BuildService","EventSettingsService","Error","ImportService"],"mappings":";;;;;;;;;;;;;AAAA;;AAKA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;IAwBqBA,c;;;;;;;;;;;;;;;;;MACpB,UAAkCC,GAAlC,EAA+CC,IAA/C,EAAuE;AAAA;;AACtE,cAAQA,IAAR;AACC,aAAK,MAAL;AACC,iBAAOC,8BAAYC,IAAZ,CAAiBH,GAAjB,CAAP;;AACD,aAAK,KAAL;AACC,iBAAO,IAAII,sBAAJ,CACNJ,GADM,EAEN,KAAKK,OAAL,CAAaL,GAAb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AP;AAIA;;AACD,aAAK,eAAL;AACC,iBAAO,IAAImB,gCAAJ,CACN,IAAIJ,iCAAJ,CAAoBf,GAApB,CADM,CAAP;;AAGD;AACC,gBAAM,IAAIoB,KAAJ,qBAAsBnB,IAAtB,kBAAN;AAlDF;AAoDA,K;;;WAED,4BAA2BD,GAA3B,EAAuD;AACtD,aAAO,IAAIqB,yBAAJ,CAAkB;AACxBrB,QAAAA,GAAG,EAAHA,GADwB;AAExBS,QAAAA,OAAO,EAAE,IAAIC,0BAAJ,CAAmBV,GAAnB;AAFe,OAAlB,CAAP;AAIA","sourcesContent":["import {\n\tSettingsService,\n\tEnvService,\n\tAuthService,\n} from '@sprucelabs/spruce-skill-utils'\nimport EventSettingsService from '../features/event/services/EventSettingsService'\nimport RemoteService from '../features/event/services/RemoteService'\nimport { FeatureCode } from '../features/features.types'\nimport SchemaService from '../features/schema/services/SchemaService'\nimport VsCodeService from '../features/vscode/services/VsCodeService'\nimport BuildService from './BuildService'\nimport CommandService from './CommandService'\nimport DependencyService from './DependencyService'\nimport ImportService from './ImportService'\nimport LintService from './LintService'\nimport PkgService from './PkgService'\nimport TypeCheckerService from './TypeCheckerService'\n\nexport interface ServiceMap {\n\tpkg: PkgService\n\tvsCode: VsCodeService\n\tschema: SchemaService\n\tlint: LintService\n\tcommand: CommandService\n\ttypeChecker: TypeCheckerService\n\timport: ImportService\n\tbuild: BuildService\n\tsettings: SettingsService\n\tenv: EnvService\n\tauth: AuthService\n\tremote: RemoteService\n\teventSettings: EventSettingsService\n\tdependency: DependencyService\n}\n\nexport type Service = keyof ServiceMap\n\nexport interface ServiceProvider {\n\tService<S extends Service>(type: S, cwd?: string): ServiceMap[S]\n}\nexport default class ServiceFactory {\n\tpublic Service<S extends Service>(cwd: string, type: S): ServiceMap[S] {\n\t\tswitch (type) {\n\t\t\tcase 'auth':\n\t\t\t\treturn AuthService.Auth(cwd) as ServiceMap[S]\n\t\t\tcase 'pkg':\n\t\t\t\treturn new PkgService(\n\t\t\t\t\tcwd,\n\t\t\t\t\tthis.Service(cwd, 'command')\n\t\t\t\t) as ServiceMap[S]\n\t\t\tcase 'env':\n\t\t\t\treturn new EnvService(cwd) as ServiceMap[S]\n\t\t\tcase 'vsCode':\n\t\t\t\treturn new VsCodeService(cwd) as ServiceMap[S]\n\t\t\tcase 'schema':\n\t\t\t\treturn new SchemaService({\n\t\t\t\t\tcwd,\n\t\t\t\t\tcommand: new CommandService(cwd),\n\t\t\t\t}) as ServiceMap[S]\n\t\t\tcase 'lint':\n\t\t\t\treturn new LintService(cwd, () =>\n\t\t\t\t\tthis.Service(cwd, 'command')\n\t\t\t\t) as ServiceMap[S]\n\t\t\tcase 'command': {\n\t\t\t\treturn new CommandService(cwd) as ServiceMap[S]\n\t\t\t}\n\t\t\tcase 'remote':\n\t\t\t\treturn new RemoteService(new EnvService(cwd)) as ServiceMap[S]\n\t\t\tcase 'typeChecker':\n\t\t\t\treturn new TypeCheckerService(\n\t\t\t\t\tthis.buildImportService(cwd)\n\t\t\t\t) as ServiceMap[S]\n\t\t\tcase 'settings':\n\t\t\t\treturn new SettingsService<FeatureCode>(cwd) as ServiceMap[S]\n\t\t\tcase 'dependency':\n\t\t\t\treturn new DependencyService(\n\t\t\t\t\tnew SettingsService<FeatureCode>(cwd)\n\t\t\t\t) as ServiceMap[S]\n\t\t\tcase 'import':\n\t\t\t\treturn this.buildImportService(cwd) as ServiceMap[S]\n\t\t\tcase 'build': {\n\t\t\t\tconst commandService = new CommandService(cwd)\n\t\t\t\treturn new BuildService(\n\t\t\t\t\tcommandService,\n\t\t\t\t\tnew LintService(cwd, () => this.Service(cwd, 'command'))\n\t\t\t\t) as ServiceMap[S]\n\t\t\t}\n\t\t\tcase 'eventSettings':\n\t\t\t\treturn new EventSettingsService(\n\t\t\t\t\tnew SettingsService(cwd)\n\t\t\t\t) as ServiceMap[S]\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Service \"${type}\" not found`)\n\t\t}\n\t}\n\n\tprivate buildImportService(cwd: string): ImportService {\n\t\treturn new ImportService({\n\t\t\tcwd,\n\t\t\tcommand: new CommandService(cwd),\n\t\t})\n\t}\n}\n"],"file":"ServiceFactory.js"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SpruceSchemas } from "./../.spruce/schemas/schemas.types";
|
|
2
2
|
import { FeatureAction, FeatureActionResponse } from '../features/features.types';
|
|
3
3
|
import { GraphicsInterface as IGraphicsInterface } from './graphicsInterface.types';
|
|
4
|
+
export { NpmPackage } from '@sprucelabs/spruce-skill-utils';
|
|
4
5
|
export interface GraphicsInterface extends IGraphicsInterface {
|
|
5
6
|
renderActionSummary(results: ExecutionResults & {
|
|
6
7
|
totalTime?: number;
|
|
@@ -18,11 +19,6 @@ export interface GraphicsInterface extends IGraphicsInterface {
|
|
|
18
19
|
export declare type GeneratedFile = SpruceSchemas.SpruceCli.v2020_07_22.GeneratedFile;
|
|
19
20
|
export declare type GeneratedDir = SpruceSchemas.SpruceCli.v2020_07_22.GeneratedDir;
|
|
20
21
|
export declare type GeneratedFileOrDir = SpruceSchemas.SpruceCli.v2020_07_22.WatcherDidDetectChangesEmitPayload['changes'][number];
|
|
21
|
-
export interface NpmPackage {
|
|
22
|
-
name: string;
|
|
23
|
-
version?: string;
|
|
24
|
-
isDev?: boolean;
|
|
25
|
-
}
|
|
26
22
|
export interface ExecutionResults extends FeatureActionResponse {
|
|
27
23
|
featureCode: string;
|
|
28
24
|
actionCode: string;
|
|
@@ -50,4 +46,3 @@ export interface OptionOverrides {
|
|
|
50
46
|
export interface BlockedCommands {
|
|
51
47
|
[command: string]: string;
|
|
52
48
|
}
|
|
53
|
-
export {};
|
package/build/types/cli.types.js
CHANGED
|
@@ -3,4 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "NpmPackage", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _spruceSkillUtils.NpmPackage;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _spruceSkillUtils = require("@sprucelabs/spruce-skill-utils");
|
|
6
14
|
//# sourceMappingURL=cli.types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"cli.types.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/types/cli.types.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA","sourcesContent":["import { SpruceSchemas } from '#spruce/schemas/schemas.types'\nimport {\n\tFeatureAction,\n\tFeatureActionResponse,\n} from '../features/features.types'\nimport { GraphicsInterface as IGraphicsInterface } from './graphicsInterface.types'\nexport { NpmPackage } from '@sprucelabs/spruce-skill-utils'\n\nexport interface GraphicsInterface extends IGraphicsInterface {\n\trenderActionSummary(results: ExecutionResults & { totalTime?: number }): void\n\tgetCursorPosition(): Promise<{ x: number; y: number } | null>\n\tmoveCursorTo(x: number, y: number): void\n\tclearBelowCursor(): void\n\tclear(): void\n\twaitForEnter(message?: string): Promise<void>\n\tsendInput(message: string): Promise<void>\n}\n\nexport type GeneratedFile = SpruceSchemas.SpruceCli.v2020_07_22.GeneratedFile\nexport type GeneratedDir = SpruceSchemas.SpruceCli.v2020_07_22.GeneratedDir\nexport type GeneratedFileOrDir =\n\tSpruceSchemas.SpruceCli.v2020_07_22.WatcherDidDetectChangesEmitPayload['changes'][number]\n\nexport interface ExecutionResults extends FeatureActionResponse {\n\tfeatureCode: string\n\tactionCode: string\n\theadline: string\n\taction: FeatureAction\n}\n\ntype Skill = Omit<SpruceSchemas.Spruce.v2020_07_22.Skill, 'creators'>\n\nexport type CurrentSkill = Partial<Skill> & {\n\tname: string\n\tisRegistered: boolean\n\tnamespacePascal: string\n}\n\nexport type RegisteredSkill = Omit<\n\tSpruceSchemas.Spruce.v2020_07_22.Skill,\n\t'creators'\n>\n\nexport type UpgradeMode =\n\tSpruceSchemas.SpruceCli.v2020_07_22.UpgradeSkillOptions['upgradeMode']\n\nexport type FileDescription = {\n\tpath: string\n\tdescription: string\n\tshouldOverwriteWhenChanged: boolean\n\tconfirmPromptOnFirstWrite?: string\n}\n\nexport type InternalUpdateHandler = (message: string) => void\n\nexport interface OptionOverrides {\n\t[command: string]: Record<string, any>\n}\n\nexport interface BlockedCommands {\n\t[command: string]: string\n}\n"],"file":"cli.types.js"}
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
"license": "MIT",
|
|
21
|
-
"version": "14.29.
|
|
21
|
+
"version": "14.29.6",
|
|
22
22
|
"bin": {
|
|
23
23
|
"spruce": "./build/index.js"
|
|
24
24
|
},
|
|
@@ -75,20 +75,20 @@
|
|
|
75
75
|
"@babel/cli": "^7.16.0",
|
|
76
76
|
"@babel/plugin-proposal-decorators": "^7.16.4",
|
|
77
77
|
"@babel/runtime": "^7.16.3",
|
|
78
|
-
"@jest/reporters": "^27.4.
|
|
79
|
-
"@sprucelabs/error": "^5.0.
|
|
80
|
-
"@sprucelabs/heartwood-view-controllers": "^51.
|
|
81
|
-
"@sprucelabs/jest-json-reporter": "^6.0.
|
|
82
|
-
"@sprucelabs/mercury-client": "^17.4.
|
|
83
|
-
"@sprucelabs/mercury-event-emitter": "^17.4.
|
|
84
|
-
"@sprucelabs/mercury-types": "^26.1.
|
|
85
|
-
"@sprucelabs/schema": "^25.4.
|
|
86
|
-
"@sprucelabs/spruce-core-schemas": "^22.6.
|
|
87
|
-
"@sprucelabs/spruce-event-plugin": "^18.
|
|
88
|
-
"@sprucelabs/spruce-event-utils": "^17.1.
|
|
89
|
-
"@sprucelabs/spruce-skill-booter": "^18.
|
|
90
|
-
"@sprucelabs/spruce-skill-utils": "^22.
|
|
91
|
-
"@sprucelabs/spruce-templates": "^14.29.
|
|
78
|
+
"@jest/reporters": "^27.4.4",
|
|
79
|
+
"@sprucelabs/error": "^5.0.332",
|
|
80
|
+
"@sprucelabs/heartwood-view-controllers": "^51.14.1",
|
|
81
|
+
"@sprucelabs/jest-json-reporter": "^6.0.276",
|
|
82
|
+
"@sprucelabs/mercury-client": "^17.4.85",
|
|
83
|
+
"@sprucelabs/mercury-event-emitter": "^17.4.85",
|
|
84
|
+
"@sprucelabs/mercury-types": "^26.1.1050",
|
|
85
|
+
"@sprucelabs/schema": "^25.4.102",
|
|
86
|
+
"@sprucelabs/spruce-core-schemas": "^22.6.299",
|
|
87
|
+
"@sprucelabs/spruce-event-plugin": "^18.3.3",
|
|
88
|
+
"@sprucelabs/spruce-event-utils": "^17.1.339",
|
|
89
|
+
"@sprucelabs/spruce-skill-booter": "^18.3.3",
|
|
90
|
+
"@sprucelabs/spruce-skill-utils": "^22.2.3",
|
|
91
|
+
"@sprucelabs/spruce-templates": "^14.29.6",
|
|
92
92
|
"@typescript-eslint/eslint-plugin": "^5.6.0",
|
|
93
93
|
"@typescript-eslint/parser": "^5.6.0",
|
|
94
94
|
"cfonts": "^2.10.0",
|
|
@@ -119,26 +119,26 @@
|
|
|
119
119
|
"uuid": "^8.3.2"
|
|
120
120
|
},
|
|
121
121
|
"devDependencies": {
|
|
122
|
-
"@sprucelabs/data-stores": "^7.2.
|
|
123
|
-
"@sprucelabs/jest-sheets-reporter": "^1.2.
|
|
124
|
-
"@sprucelabs/mercury-core-events": "^1.6.
|
|
125
|
-
"@sprucelabs/resolve-path-aliases": "^1.0.
|
|
126
|
-
"@sprucelabs/spruce-conversation-plugin": "^18.
|
|
127
|
-
"@sprucelabs/spruce-deploy-plugin": "^18.
|
|
128
|
-
"@sprucelabs/spruce-store-plugin": "^18.
|
|
129
|
-
"@sprucelabs/spruce-test-fixtures": "^18.
|
|
130
|
-
"@sprucelabs/test": "^7.7.
|
|
131
|
-
"@sprucelabs/test-utils": "^3.0.
|
|
122
|
+
"@sprucelabs/data-stores": "^7.2.1",
|
|
123
|
+
"@sprucelabs/jest-sheets-reporter": "^1.2.276",
|
|
124
|
+
"@sprucelabs/mercury-core-events": "^1.6.289",
|
|
125
|
+
"@sprucelabs/resolve-path-aliases": "^1.0.240",
|
|
126
|
+
"@sprucelabs/spruce-conversation-plugin": "^18.3.3",
|
|
127
|
+
"@sprucelabs/spruce-deploy-plugin": "^18.3.3",
|
|
128
|
+
"@sprucelabs/spruce-store-plugin": "^18.3.3",
|
|
129
|
+
"@sprucelabs/spruce-test-fixtures": "^18.3.3",
|
|
130
|
+
"@sprucelabs/test": "^7.7.258",
|
|
131
|
+
"@sprucelabs/test-utils": "^3.0.320",
|
|
132
132
|
"@types/blessed": "^0.1.19",
|
|
133
133
|
"@types/eslint": "^8.2.1",
|
|
134
134
|
"@types/fs-extra": "^9.0.13",
|
|
135
135
|
"@types/inflection": "^1.13.0",
|
|
136
136
|
"@types/inquirer": "^8.1.3",
|
|
137
137
|
"@types/jsonwebtoken": "^8.5.6",
|
|
138
|
-
"@types/lodash": "^4.14.
|
|
138
|
+
"@types/lodash": "^4.14.178",
|
|
139
139
|
"@types/md5": "^2.3.1",
|
|
140
140
|
"@types/mkdirp": "^1.0.2",
|
|
141
|
-
"@types/node": "^16.11.
|
|
141
|
+
"@types/node": "^16.11.12",
|
|
142
142
|
"@types/promise.allsettled": "^1.0.3",
|
|
143
143
|
"@types/ps-node": "^0.1.1",
|
|
144
144
|
"@types/rimraf": "^3.0.2",
|
|
@@ -152,21 +152,21 @@
|
|
|
152
152
|
"concurrently": "^6.4.0",
|
|
153
153
|
"conventional-changelog-sprucelabs": "^1.1.2",
|
|
154
154
|
"dotenv": "^10.0.0",
|
|
155
|
-
"eslint": "^8.4.
|
|
156
|
-
"eslint-config-spruce": "^10.
|
|
155
|
+
"eslint": "^8.4.1",
|
|
156
|
+
"eslint-config-spruce": "^10.11.0",
|
|
157
157
|
"find-process": "^1.4.7",
|
|
158
|
-
"jest": "^27.4.
|
|
159
|
-
"jest-circus": "^27.4.
|
|
158
|
+
"jest": "^27.4.4",
|
|
159
|
+
"jest-circus": "^27.4.4",
|
|
160
160
|
"jest-junit": "^13.0.0",
|
|
161
161
|
"jest-reporters": "^0.0.2",
|
|
162
162
|
"prettier": "^2.5.1",
|
|
163
163
|
"ps-node": "^0.1.6",
|
|
164
164
|
"rimraf": "^3.0.2",
|
|
165
|
-
"ts-jest": "^27.1.
|
|
165
|
+
"ts-jest": "^27.1.1",
|
|
166
166
|
"ts-node": "^10.4.0",
|
|
167
167
|
"tsc-watch": "^4.5.0",
|
|
168
168
|
"tsconfig-paths": "^3.12.0",
|
|
169
|
-
"typescript": "^4.5.
|
|
169
|
+
"typescript": "^4.5.3"
|
|
170
170
|
},
|
|
171
171
|
"testSkillCache": {
|
|
172
172
|
"everything": [
|
|
@@ -597,5 +597,5 @@
|
|
|
597
597
|
"ora"
|
|
598
598
|
]
|
|
599
599
|
},
|
|
600
|
-
"gitHead": "
|
|
600
|
+
"gitHead": "7e3cfb4f6c0edf37269de5d431eec3b3f19fd3c1"
|
|
601
601
|
}
|
|
@@ -265,6 +265,26 @@ export default class CreatingAListenerTest extends AbstractEventTest {
|
|
|
265
265
|
)
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
+
@test()
|
|
269
|
+
protected static async listeningToAnEventWithNoEmitTargetOrPayloadGeneratesValidListener() {
|
|
270
|
+
const { listenerPath } =
|
|
271
|
+
await this.setupSkillsInstallAtOrgRegisterEventContractAndGenerateListener(
|
|
272
|
+
{
|
|
273
|
+
isGlobal: true,
|
|
274
|
+
responsePayloadSchema: {
|
|
275
|
+
id: 'test',
|
|
276
|
+
fields: {
|
|
277
|
+
id: {
|
|
278
|
+
type: 'id',
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
}
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
await this.Service('typeChecker').check(listenerPath)
|
|
286
|
+
}
|
|
287
|
+
|
|
268
288
|
private static async installEventsAndCreateListener() {
|
|
269
289
|
const cli = await this.installEventFeature('events')
|
|
270
290
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { eventNameUtil } from '@sprucelabs/spruce-event-utils'
|
|
2
2
|
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
3
3
|
import { test, assert } from '@sprucelabs/test'
|
|
4
|
-
import AbstractEventTest from '
|
|
5
|
-
import testUtil from '
|
|
4
|
+
import AbstractEventTest from '../../../tests/AbstractEventTest'
|
|
5
|
+
import testUtil from '../../../tests/utilities/test.utility'
|
|
6
6
|
|
|
7
7
|
export default class ListeningToAnEventYouCreateTest extends AbstractEventTest {
|
|
8
8
|
@test()
|
package/src/cli.ts
CHANGED
|
@@ -361,6 +361,9 @@ export default class Cli implements CliInterface {
|
|
|
361
361
|
|
|
362
362
|
let auth: SpruceSchemas.Mercury.v2020_12_25.AuthenticateEmitPayload = {}
|
|
363
363
|
|
|
364
|
+
const pkg = serviceFactory.Service(cwd, 'pkg')
|
|
365
|
+
const doesPkgExist = pkg.doesExist()
|
|
366
|
+
|
|
364
367
|
if (options?.skillId && options?.apiKey) {
|
|
365
368
|
auth = {
|
|
366
369
|
skillId: options.skillId,
|
|
@@ -375,7 +378,7 @@ export default class Cli implements CliInterface {
|
|
|
375
378
|
apiKey: skill.apiKey,
|
|
376
379
|
}
|
|
377
380
|
}
|
|
378
|
-
} else if (shouldAuthAsLoggedInPerson) {
|
|
381
|
+
} else if (doesPkgExist && shouldAuthAsLoggedInPerson) {
|
|
379
382
|
const person = serviceFactory.Service(cwd, 'auth').getLoggedInPerson()
|
|
380
383
|
|
|
381
384
|
if (person) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { buildSchema, SchemaValues } from '@sprucelabs/schema'
|
|
2
|
-
import { diskUtil, namesUtil } from '@sprucelabs/spruce-skill-utils'
|
|
2
|
+
import { diskUtil, namesUtil, SkillAuth } from '@sprucelabs/spruce-skill-utils'
|
|
3
3
|
import SpruceError from '../../../errors/SpruceError'
|
|
4
|
-
import { SkillAuth } from '../../../services/AuthService'
|
|
5
4
|
import actionUtil from '../../../utilities/action.utility'
|
|
6
5
|
import AbstractAction from '../../AbstractAction'
|
|
7
6
|
import { FeatureActionResponse } from '../../features.types'
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import pathUtil from 'path'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { NpmPackage } from '../types/cli.types'
|
|
2
|
+
import {
|
|
3
|
+
diskUtil,
|
|
4
|
+
PkgService as BasePkgService,
|
|
5
|
+
} from '@sprucelabs/spruce-skill-utils'
|
|
7
6
|
import isCi from '../utilities/isCi'
|
|
8
7
|
import CommandService from './CommandService'
|
|
9
8
|
|
|
@@ -13,68 +12,12 @@ export interface AddOptions {
|
|
|
13
12
|
shouldCleanupLockFiles?: boolean
|
|
14
13
|
}
|
|
15
14
|
|
|
16
|
-
export default class PkgService extends
|
|
17
|
-
private
|
|
15
|
+
export default class PkgService extends BasePkgService {
|
|
16
|
+
private commandService: CommandService
|
|
18
17
|
|
|
19
|
-
public
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public set(options: {
|
|
25
|
-
path: string | string[]
|
|
26
|
-
value: string | Record<string, any> | undefined
|
|
27
|
-
}) {
|
|
28
|
-
const { path, value } = options
|
|
29
|
-
const contents = this.readPackage()
|
|
30
|
-
const updated = set(contents, path, value)
|
|
31
|
-
const destination = this.buildPath()
|
|
32
|
-
|
|
33
|
-
fs.outputFileSync(destination, JSON.stringify(updated, null, 2))
|
|
34
|
-
this._parsedPkg = undefined
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public doesExist() {
|
|
38
|
-
return diskUtil.doesFileExist(this.buildPath())
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
public unset(path: string | string[]) {
|
|
42
|
-
this.set({ path, value: undefined })
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public readPackage(): Record<string, any | undefined> {
|
|
46
|
-
if (this._parsedPkg) {
|
|
47
|
-
return this._parsedPkg
|
|
48
|
-
}
|
|
49
|
-
const packagePath = this.buildPath()
|
|
50
|
-
|
|
51
|
-
try {
|
|
52
|
-
const contents = fs.readFileSync(packagePath).toString()
|
|
53
|
-
const parsed = JSON.parse(contents)
|
|
54
|
-
this._parsedPkg = parsed
|
|
55
|
-
|
|
56
|
-
return parsed
|
|
57
|
-
} catch (err: any) {
|
|
58
|
-
throw new SpruceError({
|
|
59
|
-
code: 'FAILED_TO_IMPORT',
|
|
60
|
-
file: packagePath,
|
|
61
|
-
originalError: err,
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private buildPath() {
|
|
67
|
-
return pathUtil.join(this.cwd, 'package.json')
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
public isInstalled(pkg: string) {
|
|
71
|
-
try {
|
|
72
|
-
const contents = this.readPackage()
|
|
73
|
-
|
|
74
|
-
return !!contents.dependencies?.[pkg] || !!contents.devDependencies?.[pkg]
|
|
75
|
-
} catch (e) {
|
|
76
|
-
return false
|
|
77
|
-
}
|
|
18
|
+
public constructor(cwd: string, commandService: CommandService) {
|
|
19
|
+
super(cwd)
|
|
20
|
+
this.commandService = commandService
|
|
78
21
|
}
|
|
79
22
|
|
|
80
23
|
public async install(pkg?: string[] | string, options?: AddOptions) {
|
|
@@ -84,7 +27,7 @@ export default class PkgService extends CommandService {
|
|
|
84
27
|
: () => {}
|
|
85
28
|
|
|
86
29
|
if (!pkg) {
|
|
87
|
-
await this.execute('yarn', { args: ['install'] })
|
|
30
|
+
await this.commandService.execute('yarn', { args: ['install'] })
|
|
88
31
|
deleteLockFile()
|
|
89
32
|
return { totalInstalled: -1, totalSkipped: -1 }
|
|
90
33
|
}
|
|
@@ -115,13 +58,13 @@ export default class PkgService extends CommandService {
|
|
|
115
58
|
options
|
|
116
59
|
)
|
|
117
60
|
|
|
118
|
-
await this.execute(executable, {
|
|
61
|
+
await this.commandService.execute(executable, {
|
|
119
62
|
args,
|
|
120
63
|
})
|
|
121
64
|
} else if (
|
|
122
65
|
!diskUtil.doesDirExist(pathUtil.join(this.cwd, 'node_modules'))
|
|
123
66
|
) {
|
|
124
|
-
await this.execute('yarn', { args: ['install'] })
|
|
67
|
+
await this.commandService.execute('yarn', { args: ['install'] })
|
|
125
68
|
}
|
|
126
69
|
|
|
127
70
|
deleteLockFile()
|
|
@@ -150,20 +93,10 @@ export default class PkgService extends CommandService {
|
|
|
150
93
|
return { executable, args }
|
|
151
94
|
}
|
|
152
95
|
|
|
153
|
-
public deleteLockFile() {
|
|
154
|
-
const files = ['package-lock.json', 'yarn.lock']
|
|
155
|
-
for (const file of files) {
|
|
156
|
-
const lock = pathUtil.join(this.cwd, file)
|
|
157
|
-
if (diskUtil.doesFileExist(lock)) {
|
|
158
|
-
diskUtil.deleteFile(lock)
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
96
|
public async uninstall(pkg: string[] | string) {
|
|
164
97
|
const packages = Array.isArray(pkg) ? pkg : [pkg]
|
|
165
98
|
const args: string[] = ['uninstall', ...packages]
|
|
166
|
-
await this.execute('npm', {
|
|
99
|
+
await this.commandService.execute('npm', {
|
|
167
100
|
args,
|
|
168
101
|
})
|
|
169
102
|
|
|
@@ -171,17 +104,4 @@ export default class PkgService extends CommandService {
|
|
|
171
104
|
|
|
172
105
|
await this.install()
|
|
173
106
|
}
|
|
174
|
-
|
|
175
|
-
public stripLatest(name: string): string {
|
|
176
|
-
return name.replace('@latest', '')
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
public buildPackageName(dep: NpmPackage): string {
|
|
180
|
-
const { name, version } = dep
|
|
181
|
-
if (!version) {
|
|
182
|
-
return name
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return `${name}@${version}`
|
|
186
|
-
}
|
|
187
107
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
SettingsService,
|
|
3
|
+
EnvService,
|
|
4
|
+
AuthService,
|
|
5
|
+
} from '@sprucelabs/spruce-skill-utils'
|
|
2
6
|
import EventSettingsService from '../features/event/services/EventSettingsService'
|
|
3
7
|
import RemoteService from '../features/event/services/RemoteService'
|
|
4
8
|
import { FeatureCode } from '../features/features.types'
|
|
5
9
|
import SchemaService from '../features/schema/services/SchemaService'
|
|
6
10
|
import VsCodeService from '../features/vscode/services/VsCodeService'
|
|
7
|
-
import AuthService from './AuthService'
|
|
8
11
|
import BuildService from './BuildService'
|
|
9
12
|
import CommandService from './CommandService'
|
|
10
13
|
import DependencyService from './DependencyService'
|
|
@@ -39,12 +42,12 @@ export default class ServiceFactory {
|
|
|
39
42
|
public Service<S extends Service>(cwd: string, type: S): ServiceMap[S] {
|
|
40
43
|
switch (type) {
|
|
41
44
|
case 'auth':
|
|
42
|
-
return
|
|
43
|
-
new EnvService(cwd),
|
|
44
|
-
new PkgService(cwd)
|
|
45
|
-
) as ServiceMap[S]
|
|
45
|
+
return AuthService.Auth(cwd) as ServiceMap[S]
|
|
46
46
|
case 'pkg':
|
|
47
|
-
return new PkgService(
|
|
47
|
+
return new PkgService(
|
|
48
|
+
cwd,
|
|
49
|
+
this.Service(cwd, 'command')
|
|
50
|
+
) as ServiceMap[S]
|
|
48
51
|
case 'env':
|
|
49
52
|
return new EnvService(cwd) as ServiceMap[S]
|
|
50
53
|
case 'vsCode':
|
package/src/types/cli.types.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
FeatureActionResponse,
|
|
5
5
|
} from '../features/features.types'
|
|
6
6
|
import { GraphicsInterface as IGraphicsInterface } from './graphicsInterface.types'
|
|
7
|
+
export { NpmPackage } from '@sprucelabs/spruce-skill-utils'
|
|
7
8
|
|
|
8
9
|
export interface GraphicsInterface extends IGraphicsInterface {
|
|
9
10
|
renderActionSummary(results: ExecutionResults & { totalTime?: number }): void
|
|
@@ -20,12 +21,6 @@ export type GeneratedDir = SpruceSchemas.SpruceCli.v2020_07_22.GeneratedDir
|
|
|
20
21
|
export type GeneratedFileOrDir =
|
|
21
22
|
SpruceSchemas.SpruceCli.v2020_07_22.WatcherDidDetectChangesEmitPayload['changes'][number]
|
|
22
23
|
|
|
23
|
-
export interface NpmPackage {
|
|
24
|
-
name: string
|
|
25
|
-
version?: string
|
|
26
|
-
isDev?: boolean
|
|
27
|
-
}
|
|
28
|
-
|
|
29
24
|
export interface ExecutionResults extends FeatureActionResponse {
|
|
30
25
|
featureCode: string
|
|
31
26
|
actionCode: string
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/__tests__/behavioral/ListeningToAnEventYouCreate.test.ts"],"names":["ListeningToAnEventYouCreateTest","registerCurrentSkillAndInstallToOrg","currentSkill","eventName","version","fqen","eventNameUtil","join","eventNamespace","slug","source","resolveTestPath","destination","resolvePath","diskUtil","copyDir","listenPromise","Action","execute","waitForInput","ui","sendInput","results","assert","isFalsy","errors","match","testUtil","assertFileByNameInGeneratedFiles","files","doesInclude","assertClientIsProperlyTyped","sourceFile","contents","readFile","replace","destinationFile","writeFile","Service","check","AbstractEventTest"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;IAEqBA,+B,WACnB,iB;;;;;;;;;;;;;qHAAD;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAEgC,KAAKC,mCAAL,EAFhC;;AAAA;AAAA;AAESC,gBAAAA,YAFT,yBAESA,YAFT;AAIOC,gBAAAA,SAJP,GAImB,sBAJnB;AAKOC,gBAAAA,OALP,GAKiB,aALjB;AAOOC,gBAAAA,IAPP,GAOcC,gCAAcC,IAAd,CAAmB;AAC/BJ,kBAAAA,SAAS,EAATA,SAD+B;AAE/BK,kBAAAA,cAAc,EAAEN,YAAY,CAACO,IAFE;AAG/BL,kBAAAA,OAAO,EAAPA;AAH+B,iBAAnB,CAPd;AAaOM,gBAAAA,MAbP,GAagB,KAAKC,eAAL,CAAqB,sCA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B,KAAKvB,WAAL,CAAiB,yBAAjB,CANzB;;AAOCC,2CAASuB,SAAT,CAAmBD,eAAnB,EAAoCH,QAApC;;AAPD;AAAA,uBASO,KAAKK,OAAL,CAAa,aAAb,EAA4BC,KAA5B,CAAkCH,eAAlC,CATP;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;EA5C4DI,8B","sourcesContent":["import { eventNameUtil } from '@sprucelabs/spruce-event-utils'\nimport { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport { test, assert } from '@sprucelabs/test'\nimport AbstractEventTest from '../../tests/AbstractEventTest'\nimport testUtil from '../../tests/utilities/test.utility'\n\nexport default class ListeningToAnEventYouCreateTest extends AbstractEventTest {\n\t@test()\n\tprotected static async canListenToEventWeCreated() {\n\t\tconst { currentSkill } = await this.registerCurrentSkillAndInstallToOrg()\n\n\t\tconst eventName = 'register-skill-views'\n\t\tconst version = 'v2021_04_11'\n\n\t\tconst fqen = eventNameUtil.join({\n\t\t\teventName,\n\t\t\teventNamespace: currentSkill.slug,\n\t\t\tversion,\n\t\t})\n\n\t\tconst source = this.resolveTestPath('skill_register_skill_views_event/src')\n\t\tconst destination = this.resolvePath('src')\n\n\t\tawait diskUtil.copyDir(source, destination)\n\n\t\tconst listenPromise = this.Action('event', 'listen').execute({})\n\n\t\tawait this.waitForInput()\n\t\tawait this.ui.sendInput(currentSkill.slug)\n\n\t\tawait this.waitForInput()\n\t\tawait this.ui.sendInput(fqen)\n\n\t\tconst results = await listenPromise\n\n\t\tassert.isFalsy(results.errors)\n\n\t\tconst match = testUtil.assertFileByNameInGeneratedFiles(\n\t\t\t`${eventName}.${version}.listener.ts`,\n\t\t\tresults.files\n\t\t)\n\n\t\tassert.doesInclude(\n\t\t\tmatch,\n\t\t\tdiskUtil.resolvePath('listeners', currentSkill.slug)\n\t\t)\n\n\t\tawait this.assertClientIsProperlyTyped(currentSkill.slug)\n\t}\n\n\tprivate static async assertClientIsProperlyTyped(eventNamespace: string) {\n\t\tconst sourceFile = this.resolvePath('src/client-type-test.ts.hbs')\n\t\tconst contents = diskUtil\n\t\t\t.readFile(sourceFile)\n\t\t\t.replace('{{eventNamespace}}', eventNamespace)\n\n\t\tconst destinationFile = this.resolvePath('src/client-type-test.ts')\n\t\tdiskUtil.writeFile(destinationFile, contents)\n\n\t\tawait this.Service('typeChecker').check(destinationFile)\n\t}\n}\n"],"file":"ListeningToAnEventYouCreate.test.js"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import AbstractCliTest from '../../tests/AbstractCliTest';
|
|
2
|
-
export default class AuthServiceTest extends AbstractCliTest {
|
|
3
|
-
private static auth;
|
|
4
|
-
protected static beforeEach(): Promise<void>;
|
|
5
|
-
protected static canInstantiatePersonStore(): Promise<void>;
|
|
6
|
-
protected static hasLoggedInPersonMethod(): Promise<void>;
|
|
7
|
-
protected static loggedInPersonIsNullWhenNotLoggedIn(): Promise<void>;
|
|
8
|
-
protected static cantSaveBadLoggedInPerson(): Promise<void>;
|
|
9
|
-
protected static canSaveLoggedInPerson(): void;
|
|
10
|
-
protected static canLogOut(): void;
|
|
11
|
-
protected static getCurrentSkillReturnsNull(): void;
|
|
12
|
-
protected static canSetCurrentSkill(): void;
|
|
13
|
-
private static writePackageJson;
|
|
14
|
-
}
|