@@ -44,19 +44,19 @@ main().catch((error) => {
44
44
export async function main ( ) : Promise < void > {
45
45
const {
46
46
githubEventName,
47
- baseCommitId ,
48
- headCommitId ,
47
+ baseRef ,
48
+ headRef ,
49
49
possibleReleaseTitle,
50
50
validReleaseTitlePatterns,
51
- } = await parseCommandLineArguments ( ) ;
51
+ } = parseCommandLineArguments ( ) ;
52
52
53
- console . log ( '\nRunning validations' ) ;
53
+ console . log ( 'Running validations' ) ;
54
54
console . log ( '-------------------\n' ) ;
55
55
56
56
console . log ( '- Checking whether root version has been bumped...' ) ;
57
57
const rootVersionBumpedResult = await validateRootVersionBumped (
58
- baseCommitId ,
59
- headCommitId ,
58
+ baseRef ,
59
+ headRef ,
60
60
) ;
61
61
console . log ( ` - ${ rootVersionBumpedResult . message } ` ) ;
62
62
@@ -73,7 +73,7 @@ export async function main(): Promise<void> {
73
73
74
74
console . log ( '- Checking whether any workspace packages have been bumped...' ) ;
75
75
const anyWorkspacePackageVersionBumpedResult =
76
- await validateAnyPublicWorkspacePackageBumped ( baseCommitId , headCommitId ) ;
76
+ await validateAnyPublicWorkspacePackageBumped ( baseRef , headRef ) ;
77
77
console . log ( ` - ${ anyWorkspacePackageVersionBumpedResult . message } ` ) ;
78
78
79
79
const releaseValidationResult = getReleaseValidationResult (
@@ -204,7 +204,7 @@ function failWithInvalidUsage(message: string) {
204
204
*
205
205
* @returns The previous commit ID and release title prefix.
206
206
*/
207
- async function parseCommandLineArguments ( ) {
207
+ function parseCommandLineArguments ( ) {
208
208
const args = process . argv . slice ( 2 ) ;
209
209
210
210
if ( args . length < 4 ) {
@@ -234,16 +234,10 @@ async function parseCommandLineArguments() {
234
234
) ;
235
235
}
236
236
237
- const { stdout : baseCommitId } = await execa ( 'git' , [ 'rev-parse' , baseRef ] ) ;
238
- const { stdout : headCommitId } = await execa ( 'git' , [ 'rev-parse' , headRef ] ) ;
239
-
240
- console . log ( `Base commit: ${ baseRef } -> ${ baseCommitId } ` ) ;
241
- console . log ( `Head commit: ${ headRef } -> ${ headCommitId } ` ) ;
242
-
243
237
return {
244
238
githubEventName : githubEventName as GitHubEventName ,
245
- baseCommitId ,
246
- headCommitId ,
239
+ baseRef ,
240
+ headRef ,
247
241
possibleReleaseTitle,
248
242
validReleaseTitlePatterns,
249
243
} ;
@@ -271,24 +265,24 @@ async function getPublicWorkspaces(): Promise<WorkspaceInfo[]> {
271
265
* Fetches the `package.json` in the directory from the base and head commits
272
266
* and returns their version fields.
273
267
*
274
- * @param baseCommitId - The ID of the first commit to fetch.
275
- * @param headCommitId - The ID of the second commit to fetch.
268
+ * @param baseRef - The ref of the first commit to fetch.
269
+ * @param headRef - The ref of the second commit to fetch.
276
270
* @param directory - The directory where `package.json` is located (must end
277
271
* with `/`).
278
272
* @returns The output.
279
273
*/
280
274
async function getPreviousAndCurrentPackageVersions (
281
- baseCommitId : string ,
282
- headCommitId : string ,
275
+ baseRef : string ,
276
+ headRef : string ,
283
277
directory : string ,
284
278
) : Promise < { previousVersion : string ; currentVersion : string } > {
285
279
const { stdout : rawPreviousManifest } = await execa ( 'git' , [
286
280
'show' ,
287
- `${ baseCommitId } :${ directory } package.json` ,
281
+ `${ baseRef } :${ directory } package.json` ,
288
282
] ) ;
289
283
const { stdout : rawCurrentManifest } = await execa ( 'git' , [
290
284
'show' ,
291
- `${ headCommitId } :${ directory } package.json` ,
285
+ `${ headRef } :${ directory } package.json` ,
292
286
] ) ;
293
287
294
288
const previousManifest = JSON . parse ( rawPreviousManifest ) as {
@@ -342,6 +336,7 @@ function validateReleaseTitle({
342
336
`^(?:${ validReleaseTitleRegexpSource } )$` ,
343
337
'u' ,
344
338
) ;
339
+ console . log ( 'validReleaseTitleRegexp' , validReleaseTitleRegexp ) ;
345
340
const match = possibleReleaseTitle . match ( validReleaseTitleRegexp ) ;
346
341
const source =
347
342
githubEventName === 'push' ? 'commit message' : 'pull request title' ;
@@ -363,20 +358,16 @@ function validateReleaseTitle({
363
358
* Checks if the version in the the root package's `package.json` has been
364
359
* bumped.
365
360
*
366
- * @param baseCommitId - The base commit ID .
367
- * @param headCommitId - The head commit ID .
361
+ * @param baseRef - The base commit ref .
362
+ * @param headRef - The head commit ref .
368
363
* @returns The result of the validation.
369
364
*/
370
365
async function validateRootVersionBumped (
371
- baseCommitId : string ,
372
- headCommitId : string ,
366
+ baseRef : string ,
367
+ headRef : string ,
373
368
) : Promise < RootVersionBumpedValidationResult > {
374
369
const { previousVersion, currentVersion } =
375
- await getPreviousAndCurrentPackageVersions (
376
- baseCommitId ,
377
- headCommitId ,
378
- './' ,
379
- ) ;
370
+ await getPreviousAndCurrentPackageVersions ( baseRef , headRef , './' ) ;
380
371
381
372
if ( currentVersion !== previousVersion ) {
382
373
return {
@@ -397,22 +388,22 @@ async function validateRootVersionBumped(
397
388
/**
398
389
* Checks if any of the versions among workspace package have been bumped.
399
390
*
400
- * @param baseCommitId - The base commit ID .
401
- * @param headCommitId - The head commit ID .
391
+ * @param baseRef - The base commit ref .
392
+ * @param headRef - The head commit ref .
402
393
* @returns The result of the validation.
403
394
*/
404
395
async function validateAnyPublicWorkspacePackageBumped (
405
- baseCommitId : string ,
406
- headCommitId : string ,
396
+ baseRef : string ,
397
+ headRef : string ,
407
398
) : Promise < AnyWorkspacePackageVersionBumpedValidationResult > {
408
399
const publicWorkspaces = await getPublicWorkspaces ( ) ;
409
400
410
401
const workspacesWithVersions = await Promise . all (
411
402
publicWorkspaces . map ( async ( publicWorkspace ) => {
412
403
const { previousVersion, currentVersion } =
413
404
await getPreviousAndCurrentPackageVersions (
414
- baseCommitId ,
415
- headCommitId ,
405
+ baseRef ,
406
+ headRef ,
416
407
`${ publicWorkspace . location } /` ,
417
408
) ;
418
409
0 commit comments