diff --git a/CHANGELOG.md b/CHANGELOG.md index c16fe833..0841f90a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## 1.9.3 - 27 September 2022 +- Add more 'Complain To Me' links. [#193](https://github.com/getlocalci/local-ci/pull/193) + ## 1.9.2 - 26 September 2022 - Bump the binary version to the latest: 0.1.21412. [#191](https://github.com/getlocalci/local-ci/pull/191) diff --git a/package-lock.json b/package-lock.json index e23ba463..aad81a1e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "local-ci", - "version": "1.9.2", + "version": "1.9.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "local-ci", - "version": "1.9.2", + "version": "1.9.3", "hasInstallScript": true, "license": "GPL-2.0-or-later", "os": [ diff --git a/package.json b/package.json index 20c5905f..e38190b1 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "local-ci", "displayName": "Local CI", "description": "Debug CircleCI® workflows locally, with Bash access during and after. Free preview, then paid.", - "version": "1.9.2", + "version": "1.9.3", "publisher": "LocalCI", "contributors": [ "Ryan Kienstra" diff --git a/src/command/Complain.ts b/src/command/Complain.ts new file mode 100644 index 00000000..ce88a420 --- /dev/null +++ b/src/command/Complain.ts @@ -0,0 +1,25 @@ +import { inject, injectable } from 'inversify'; +import type { Command } from './index'; +import Types from 'common/Types'; +import EditorGateway from 'gateway/EditorGateway'; +import { COMPLAIN_COMMAND, COMPLAIN_URL } from 'constant'; + +@injectable() +export default class Complain implements Command { + @inject(Types.IEditorGateway) + editorGateway!: EditorGateway; + + commandName: string; + + constructor() { + this.commandName = COMPLAIN_COMMAND; + } + + getCallback() { + return () => { + this.editorGateway.editor.env.openExternal( + this.editorGateway.editor.Uri.parse(COMPLAIN_URL) + ); + }; + } +} diff --git a/src/command/test/Complain.spec.ts b/src/command/test/Complain.spec.ts new file mode 100644 index 00000000..cbb86eeb --- /dev/null +++ b/src/command/test/Complain.spec.ts @@ -0,0 +1,26 @@ +import AppTestHarness from 'test-tool/helper/AppTestHarness'; +import FakeEditorGateway from 'gateway/FakeEditorGateway'; +import Complain from 'command/Complain'; + +let complain: Complain; +let editorGateway: FakeEditorGateway; + +describe('Complain command', () => { + beforeEach(() => { + const testHarness = new AppTestHarness(); + testHarness.init(); + complain = testHarness.container.get(Complain); + editorGateway = testHarness.editorGateway; + }); + + test('opens the complain email url', () => { + const editorSpy = jest.fn(); + editorGateway.editor.env.openExternal = editorSpy; + const stubUri = 'emailto:ryan@getlocalci.com'; + editorGateway.editor.Uri.parse = () => stubUri; + + complain.getCallback()(); + + expect(editorSpy).toHaveBeenCalledWith(stubUri); + }); +}); diff --git a/src/common/Registrar.ts b/src/common/Registrar.ts index a5caf443..ef8afb07 100644 --- a/src/common/Registrar.ts +++ b/src/common/Registrar.ts @@ -1,5 +1,6 @@ import type vscode from 'vscode'; import type { Command } from 'command/index'; +import Complain from 'command/Complain'; import ConfigFile from 'config/ConfigFile'; import CreateConfigFile from 'command/CreateConfigFile'; import Delayer from 'job/Delayer'; @@ -36,6 +37,7 @@ export default class Registrar { public context: vscode.ExtensionContext, public jobProvider: JobProvider, public licenseProvider: LicenseProvider, + private complain: Complain, private configFile: ConfigFile, private createConfigFile: CreateConfigFile, private debugRepo: DebugRepo, @@ -61,6 +63,7 @@ export default class Registrar { registerCommands(): vscode.Disposable[] { return [ + this.complain, this.createConfigFile, this.debugRepo, this.enterLicense, diff --git a/src/common/RegistrarFactory.ts b/src/common/RegistrarFactory.ts index 4b519011..3bd50ea8 100644 --- a/src/common/RegistrarFactory.ts +++ b/src/common/RegistrarFactory.ts @@ -1,6 +1,7 @@ import { inject, injectable } from 'inversify'; import type vscode from 'vscode'; import Types from 'common/Types'; +import Complain from 'command/Complain'; import ConfigFile from 'config/ConfigFile'; import CreateConfigFile from 'command/CreateConfigFile'; import DebugRepo from 'command/DebugRepo'; @@ -29,6 +30,7 @@ import TryProcessAgain from '../command/TryProcessAgain'; @injectable() export default class RegistrarFactory { constructor( + @inject(Complain) private complain: Complain, @inject(ConfigFile) private configFile: ConfigFile, @inject(CreateConfigFile) private createConfigFile: CreateConfigFile, @inject(DebugRepo) private debugRepo: DebugRepo, @@ -61,6 +63,7 @@ export default class RegistrarFactory { context, jobProvider, licenseProvider, + this.complain, this.configFile, this.createConfigFile, this.debugRepo, diff --git a/src/common/test/LocalCi.spec.ts b/src/common/test/LocalCi.spec.ts index 7fa9cff1..b56c3472 100644 --- a/src/common/test/LocalCi.spec.ts +++ b/src/common/test/LocalCi.spec.ts @@ -20,6 +20,7 @@ describe('LocalCi', () => { test('activate registers commands', () => { const expectedCommands = [ + 'local-ci.email.complain', 'local-ci.create.config', 'local-ci.debug.repo', 'local-ci.license.enter', diff --git a/src/constant/index.ts b/src/constant/index.ts index 9900ec1d..1a655846 100644 --- a/src/constant/index.ts +++ b/src/constant/index.ts @@ -6,6 +6,9 @@ export const SELECTED_CONFIG_PATH = 'local-ci.config.path'; export const LICENSE_ERROR = 'localCiLicenseKeyError'; export const GET_LICENSE_COMMAND = 'local-ci.license.get'; export const ENTER_LICENSE_COMMAND = 'local-ci.license.enter'; +export const COMPLAIN_COMMAND = 'local-ci.email.complain'; +export const COMPLAIN_URL = + 'mailto:ryan@getlocalci.com?subject=Something went wrong in Local CI&body=Hi Ryan, Could you help with this problem in Local CI: '; export const EXIT_JOB_COMMAND = 'local-ci.job.exit'; export const PROCESS_TRY_AGAIN_COMMAND = 'local-ci.process-error.try-again'; export const GET_LICENSE_KEY_URL = diff --git a/src/job/JobListener.ts b/src/job/JobListener.ts index f237b061..ec6b38a9 100644 --- a/src/job/JobListener.ts +++ b/src/job/JobListener.ts @@ -52,7 +52,7 @@ export default class JobListener { `Log for CircleCI® job ${jobName} \n${new Date()} \n\n` ); const complainToMeLink = - 'mailto:ryan@getlocalci.com?subject=There was an error using Local CI&body=Hi Ryan, Could you help with this error I saw with Local CI: '; + 'mailto:ryan@getlocalci.com?subject=There was an error using Local CI&body=Hi Ryan, Could you help with this error in Local CI: '; const process = this.childProcessGateway.cp.spawn( '/bin/sh', @@ -210,7 +210,7 @@ export default class JobListener { const showJobOutput = 'Show job log'; const complainToMeText = 'Complain to me'; const complainToMeLink = - 'mailto:ryan@getlocalci.com?subject=A job failed with Local Ci, and I do not know why&body=Hi Ryan, Could you help with this error I saw with a Local CI job: '; + 'mailto:ryan@getlocalci.com?subject=A job failed with Local Ci, and I do not know why&body=Hi Ryan, Could you help with this error in a Local CI job: '; const dontShowAgain = `Don't show again`; this.editorGateway.editor.window diff --git a/src/job/JobProvider.ts b/src/job/JobProvider.ts index 81c57dcc..0316e8de 100644 --- a/src/job/JobProvider.ts +++ b/src/job/JobProvider.ts @@ -19,6 +19,7 @@ import LogFactory from '../log/LogFactory'; import ReporterGateway from 'gateway/ReporterGateway'; import WarningFactory from './WarningFactory'; import { + COMPLAIN_COMMAND, CREATE_CONFIG_FILE_COMMAND, ENTER_LICENSE_COMMAND, GET_LICENSE_COMMAND, @@ -263,12 +264,14 @@ export default class JobProvider 'Try Again', `${JOB_TREE_VIEW_ID}.refresh` ), + this.commandFactory.create('Complain To Me', COMPLAIN_COMMAND), ]; case JobError.LicenseKey: return [ this.warningFactory.create('Please enter a Local CI license key.'), this.commandFactory.create('Get License', GET_LICENSE_COMMAND), this.commandFactory.create('Enter License', ENTER_LICENSE_COMMAND), + this.commandFactory.create('Complain To Me', COMPLAIN_COMMAND), ]; case JobError.NoConfigFilePathInWorkspace: return [ @@ -277,11 +280,13 @@ export default class JobProvider 'Create a config for me', CREATE_CONFIG_FILE_COMMAND ), + this.commandFactory.create('Complain to me', COMPLAIN_COMMAND), ]; case JobError.NoConfigFilePathSelected: return [ this.warningFactory.create('Error: No jobs found'), this.commandFactory.create('Select repo', 'localCiJobs.selectRepo'), + this.commandFactory.create('Complain to me', COMPLAIN_COMMAND), ]; case JobError.ProcessFile: return [ @@ -298,6 +303,7 @@ export default class JobProvider .join(' ') ), this.commandFactory.create('Try Again', PROCESS_TRY_AGAIN_COMMAND), + this.commandFactory.create('Complain To Me', COMPLAIN_COMMAND), ]; default: return [];