Skip to content

Commit f6af537

Browse files
add logging
1 parent 67f3ba3 commit f6af537

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

plugins/update-repo/src/index.ts

+21-3
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,20 @@ const updateLernaMonorepo = (dir: string, name: string, version: string) =>
5252
);
5353

5454
/** Update a dependency in a JS project */
55-
const updateJsProject = (dir: string, name: string, version: string) => {
55+
const updateJsProject = (
56+
auto: Auto,
57+
dir: string,
58+
name: string,
59+
version: string
60+
) => {
5661
if (isLernaMonorepo()) {
62+
auto.logger.verbose.info(
63+
"Creating an update for necessary packages in target monorepo."
64+
);
5765
updateLernaMonorepo(dir, name, version);
5866
} else {
5967
const hasLock = fs.existsSync("yarn.lock");
68+
auto.logger.verbose.info("Creating an update for target npm package.");
6069
updateNpmPackage(dir, name, version, hasLock);
6170
}
6271
};
@@ -77,6 +86,10 @@ async function getUpdater(
7786
// We are in a lerna monorepo so we should try to make updates for all of the
7887
// packages in it. We assume that the thing we are updating is also a JS project
7988
if (isLernaMonorepo()) {
89+
auto.logger.verbose.info(
90+
"Detected monorepo of package to create PR updates for."
91+
);
92+
8093
const { name } = readPackageJson();
8194
// Since we have already tagged the release we need to calculate from the previous tag
8295
const lastRelease = await auto.git!.getPreviousTagInBranch();
@@ -92,16 +105,17 @@ async function getUpdater(
92105
return;
93106
}
94107

95-
updateJsProject(dir, p.name, p.version);
108+
updateJsProject(auto, dir, p.name, p.version);
96109
});
97110
},
98111
];
99112
}
100113

101114
// We are in NPM package. We assume that the thing we are updating is also a JS project.
102115
if (isNpmPackage()) {
116+
auto.logger.verbose.info("Detected NPM package to create PR updates for.");
103117
const { name, version } = readPackageJson();
104-
return [name, (dir) => updateJsProject(dir, name, version)];
118+
return [name, (dir) => updateJsProject(auto, dir, name, version)];
105119
}
106120
}
107121

@@ -150,12 +164,14 @@ export default class UpdateRepoPlugin implements IPlugin {
150164
this.name,
151165
async ({ newVersion, releaseNotes, response }) => {
152166
if (!newVersion || !response) {
167+
auto.logger.verbose.warn("No new versions to open PRs for.");
153168
return;
154169
}
155170

156171
const releases = Array.isArray(response) ? response : [response];
157172

158173
if (releases.some((release) => release.data.prerelease)) {
174+
auto.logger.verbose.warn("In prerelease, no PRs generated.");
159175
return;
160176
}
161177

@@ -203,5 +219,7 @@ export default class UpdateRepoPlugin implements IPlugin {
203219
body: releaseNotes,
204220
update,
205221
});
222+
223+
auto.logger.log.success(`Opened PR on ${repo.repo}: ${message}`);
206224
}
207225
}

0 commit comments

Comments
 (0)