diff --git a/plugins/cocoapods/__tests__/cocoapods.test.ts b/plugins/cocoapods/__tests__/cocoapods.test.ts index abd33b23c..2c8e7276e 100644 --- a/plugins/cocoapods/__tests__/cocoapods.test.ts +++ b/plugins/cocoapods/__tests__/cocoapods.test.ts @@ -257,6 +257,9 @@ describe("Cocoapods Plugin", () => { test("should push to trunk if no specsRepo in options with flags", async () => { mockPodspec(specWithVersion("0.0.1")); + const logger = dummyLog(); + logger.logLevel = "verbose"; + const plugin = new CocoapodsPlugin({ ...options, flags: ["--sources", "someOtherSpecsRepo"], @@ -264,7 +267,7 @@ describe("Cocoapods Plugin", () => { const hook = makeHooks(); plugin.apply({ hooks: hook, - logger: dummyLog(), + logger, prefixRelease, } as Auto.Auto); @@ -277,12 +280,16 @@ describe("Cocoapods Plugin", () => { "--sources", "someOtherSpecsRepo", "./Test.podspec", + "--verbose", ]); }); test("should push to specs repo if specsRepo in options", async () => { mockPodspec(specWithVersion("0.0.1")); + const logger = dummyLog(); + logger.logLevel = "quiet"; + const plugin = new CocoapodsPlugin({ ...options, specsRepo: "someSpecsRepo", @@ -290,7 +297,7 @@ describe("Cocoapods Plugin", () => { const hook = makeHooks(); plugin.apply({ hooks: hook, - logger: dummyLog(), + logger, prefixRelease, } as Auto.Auto); @@ -303,23 +310,29 @@ describe("Cocoapods Plugin", () => { "add", "autoPublishRepo", "someSpecsRepo", + "--silent", ]); expect(exec).toHaveBeenNthCalledWith(4, "pod", [ "repo", "push", "autoPublishRepo", "./Test.podspec", + "--silent", ]); expect(exec).toHaveBeenNthCalledWith(5, "pod", [ "repo", "remove", "autoPublishRepo", + "--silent", ]); }); test("should push to specs repo if specsRepo in options with flags", async () => { mockPodspec(specWithVersion("0.0.1")); + const logger = dummyLog(); + logger.logLevel = "veryVerbose"; + const plugin = new CocoapodsPlugin({ ...options, specsRepo: "someSpecsRepo", @@ -328,7 +341,7 @@ describe("Cocoapods Plugin", () => { const hook = makeHooks(); plugin.apply({ hooks: hook, - logger: dummyLog(), + logger, prefixRelease, } as Auto.Auto); @@ -341,6 +354,7 @@ describe("Cocoapods Plugin", () => { "add", "autoPublishRepo", "someSpecsRepo", + "--verbose", ]); expect(exec).toHaveBeenNthCalledWith(4, "pod", [ "repo", @@ -349,13 +363,16 @@ describe("Cocoapods Plugin", () => { "someOtherSpecsRepo", "autoPublishRepo", "./Test.podspec", + "--verbose", ]); expect(exec).toHaveBeenNthCalledWith(5, "pod", [ "repo", "remove", "autoPublishRepo", + "--verbose", ]); }); + test("should delete autoPublishRepo if it exists and push to specs repo if specsRepo in options", async () => { mockPodspec(specWithVersion("0.0.1")); diff --git a/plugins/cocoapods/src/index.ts b/plugins/cocoapods/src/index.ts index b6343b30d..c43da0d6c 100644 --- a/plugins/cocoapods/src/index.ts +++ b/plugins/cocoapods/src/index.ts @@ -123,6 +123,12 @@ export default class CocoapodsPlugin implements IPlugin { /** Tap into auto plugin points. */ apply(auto: Auto) { + const isQuiet = auto.logger.logLevel === "quiet"; + const isVerbose = + auto.logger.logLevel === "verbose" || + auto.logger.logLevel === "veryVerbose"; + const podLogLevel = isQuiet ? ["--silent"] : isVerbose ? ["--verbose"] : []; + auto.hooks.validateConfig.tapPromise(this.name, async (name, options) => { if (name === this.name || name === `@auto-it/${this.name}`) { return validatePluginConfiguration(this.name, pluginOptions, options); @@ -176,6 +182,7 @@ export default class CocoapodsPlugin implements IPlugin { "push", ...(this.options.flags || []), this.options.podspecPath, + ...podLogLevel, ]); return; } @@ -193,6 +200,7 @@ export default class CocoapodsPlugin implements IPlugin { "repo", "remove", "autoPublishRepo", + ...podLogLevel, ]); } } catch (error) { @@ -208,6 +216,7 @@ export default class CocoapodsPlugin implements IPlugin { "add", "autoPublishRepo", this.options.specsRepo, + ...podLogLevel, ]); auto.logger.log.info( @@ -221,6 +230,7 @@ export default class CocoapodsPlugin implements IPlugin { ...(this.options.flags || []), "autoPublishRepo", this.options.podspecPath, + ...podLogLevel, ]); } catch (error) { auto.logger.log.error( @@ -235,6 +245,7 @@ export default class CocoapodsPlugin implements IPlugin { "repo", "remove", "autoPublishRepo", + ...podLogLevel, ]); } });