Skip to content

Commit

Permalink
feat: adding cocoapod verbose logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Drew Cortright authored and Drew Cortright committed Oct 12, 2020
1 parent 5059c52 commit d77487c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
23 changes: 20 additions & 3 deletions plugins/cocoapods/__tests__/cocoapods.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,17 @@ 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"],
});
const hook = makeHooks();
plugin.apply({
hooks: hook,
logger: dummyLog(),
logger,
prefixRelease,
} as Auto.Auto);

Expand All @@ -277,20 +280,24 @@ 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",
});
const hook = makeHooks();
plugin.apply({
hooks: hook,
logger: dummyLog(),
logger,
prefixRelease,
} as Auto.Auto);

Expand All @@ -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",
Expand All @@ -328,7 +341,7 @@ describe("Cocoapods Plugin", () => {
const hook = makeHooks();
plugin.apply({
hooks: hook,
logger: dummyLog(),
logger,
prefixRelease,
} as Auto.Auto);

Expand All @@ -341,6 +354,7 @@ describe("Cocoapods Plugin", () => {
"add",
"autoPublishRepo",
"someSpecsRepo",
"--verbose",
]);
expect(exec).toHaveBeenNthCalledWith(4, "pod", [
"repo",
Expand All @@ -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"));

Expand Down
11 changes: 11 additions & 0 deletions plugins/cocoapods/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -176,6 +182,7 @@ export default class CocoapodsPlugin implements IPlugin {
"push",
...(this.options.flags || []),
this.options.podspecPath,
...podLogLevel,
]);
return;
}
Expand All @@ -193,6 +200,7 @@ export default class CocoapodsPlugin implements IPlugin {
"repo",
"remove",
"autoPublishRepo",
...podLogLevel,
]);
}
} catch (error) {
Expand All @@ -208,6 +216,7 @@ export default class CocoapodsPlugin implements IPlugin {
"add",
"autoPublishRepo",
this.options.specsRepo,
...podLogLevel,
]);

auto.logger.log.info(
Expand All @@ -221,6 +230,7 @@ export default class CocoapodsPlugin implements IPlugin {
...(this.options.flags || []),
"autoPublishRepo",
this.options.podspecPath,
...podLogLevel,
]);
} catch (error) {
auto.logger.log.error(
Expand All @@ -235,6 +245,7 @@ export default class CocoapodsPlugin implements IPlugin {
"repo",
"remove",
"autoPublishRepo",
...podLogLevel,
]);
}
});
Expand Down

0 comments on commit d77487c

Please sign in to comment.