diff --git a/packages/reg-notify-github-with-api-plugin/package.json b/packages/reg-notify-github-with-api-plugin/package.json index 6b007e4d..f4b0bcce 100644 --- a/packages/reg-notify-github-with-api-plugin/package.json +++ b/packages/reg-notify-github-with-api-plugin/package.json @@ -3,6 +3,7 @@ "version": "0.10.17", "description": "Notify reg-suit result to GHE repository using API", "main": "lib/index.js", + "types": "lib/index.d.ts", "scripts": { "test": "ts-node e2e/script.ts", "prepublish": "tsc -p tsconfig.build.json" diff --git a/packages/reg-notify-github-with-api-plugin/src/gh-gql-client.ts b/packages/reg-notify-github-with-api-plugin/src/gh-gql-client.ts index 2e273817..0651d577 100644 --- a/packages/reg-notify-github-with-api-plugin/src/gh-gql-client.ts +++ b/packages/reg-notify-github-with-api-plugin/src/gh-gql-client.ts @@ -93,11 +93,13 @@ export class GhGqlClient { repository, branchName, body, + markerComment = "reg-comment", }: { owner: string; repository: string; branchName: string; body: string; + markerComment?: string; }) { const { data, errors } = await this._client.query< ContextData, @@ -123,7 +125,7 @@ export class GhGqlClient { !data.repository.ref.associatedPullRequests.totalCount ) { // Nothing to do - return; + return []; } const pullRequests = data.repository.ref.associatedPullRequests.nodes; @@ -132,14 +134,14 @@ export class GhGqlClient { pullRequests.map(async pullRequest => { if (pullRequest.comments && pullRequest.comments.nodes) { const commentToBeUpdated = pullRequest.comments.nodes.find( - c => c.body && c.body.startsWith(""), + c => c.body && c.body.startsWith(``), ); if (commentToBeUpdated) { const { errors } = await this._client.mutate({ mutation: updateCommentMutation, variables: { id: commentToBeUpdated.id, - body: `\n${body}`, + body: `\n${body}`, }, }); if (errors) throw errors; @@ -150,7 +152,7 @@ export class GhGqlClient { mutation: createCommentMutation, variables: { id: pullRequest.id, - body: `\n${body}`, + body: `\n${body}`, }, }); if (errors) throw errors; diff --git a/packages/reg-notify-github-with-api-plugin/src/index.ts b/packages/reg-notify-github-with-api-plugin/src/index.ts index 89b22fdd..a3aed9eb 100644 --- a/packages/reg-notify-github-with-api-plugin/src/index.ts +++ b/packages/reg-notify-github-with-api-plugin/src/index.ts @@ -2,6 +2,8 @@ import { NotifierPluginFactory } from "reg-suit-interface"; import { GhApiNotifierPlugin } from "./gh-api-notifier-plugin"; import { GhApiPreparer } from "./gh-api-preparer"; +export { GhGqlClient as GithubCommentClient } from "./gh-gql-client"; + const factory: NotifierPluginFactory = () => { return { notifier: new GhApiNotifierPlugin(), @@ -9,4 +11,4 @@ const factory: NotifierPluginFactory = () => { }; }; -export = factory; +export default factory; diff --git a/packages/reg-suit-core/src/plugin-manager.test.ts b/packages/reg-suit-core/src/plugin-manager.test.ts index 3e715d07..b22dbfec 100644 --- a/packages/reg-suit-core/src/plugin-manager.test.ts +++ b/packages/reg-suit-core/src/plugin-manager.test.ts @@ -33,6 +33,13 @@ test("should return pluginHolders", () => { assert.equal(pm._pluginHolders[0].moduleId, "./lib/testing/dummy-plugin"); }); +test("should return pluginHolders2", () => { + const pm = createPluginManager({ "./lib/testing/dummy-plugin-mod": {} }); + pm.loadPlugins(); + assert.equal(pm._pluginHolders.length, 1); + assert.equal(pm._pluginHolders[0].moduleId, "./lib/testing/dummy-plugin-mod"); +}); + test("resolve locally installed module", () => { const pm = createPluginManager({}); expect(() => pm._loadPlugin("reg-simple-keygen-plugin")).not.toThrowError(); diff --git a/packages/reg-suit-core/src/plugin-manager.ts b/packages/reg-suit-core/src/plugin-manager.ts index 6798a10f..e02e8082 100644 --- a/packages/reg-suit-core/src/plugin-manager.ts +++ b/packages/reg-suit-core/src/plugin-manager.ts @@ -158,7 +158,7 @@ export class PluginManager { } if (pluginFileName) { const factory = require(pluginFileName); - const pluginHolder = factory(); + const pluginHolder = typeof factory?.default === "function" ? factory.default() : factory(); this._pluginHolders.push({ ...pluginHolder, moduleId: name }); } } diff --git a/packages/reg-suit-core/src/testing/dummy-plugin-mod.ts b/packages/reg-suit-core/src/testing/dummy-plugin-mod.ts new file mode 100644 index 00000000..04dfd41f --- /dev/null +++ b/packages/reg-suit-core/src/testing/dummy-plugin-mod.ts @@ -0,0 +1,7 @@ +const factory = () => ({ + notifier: { + notify: () => Promise.resolve("notify"), + }, +}); + +exports.default = factory; diff --git a/packages/reg-suit-util/package.json b/packages/reg-suit-util/package.json index 8a36c2ec..e268664c 100644 --- a/packages/reg-suit-util/package.json +++ b/packages/reg-suit-util/package.json @@ -3,7 +3,7 @@ "version": "0.10.17", "description": "", "main": "lib/index.js", - "typings": "lib/index.d.ts", + "types": "lib/index.d.ts", "scripts": { "test": "echo T.B.D.", "prepublish": "tsc -p tsconfig.build.json",