yarn-version 8.6.1 → 8.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/index-node.mjs +257 -230
- package/dist/index-node.mjs.map +1 -1
- package/package.json +7 -12
- package/src/__fixtures__/monorepo-duplicate-names/package.json +7 -0
- package/src/__fixtures__/monorepo-duplicate-names/packages/pkg-a/package.json +4 -0
- package/src/__fixtures__/monorepo-duplicate-names/packages/pkg-b/package.json +4 -0
- package/src/__fixtures__/monorepo-invalid-package-json/package.json +7 -0
- package/src/__fixtures__/monorepo-invalid-package-json/packages/pkg-with-invalid-json/package.json +5 -0
- package/src/__fixtures__/monorepo-nested/package.json +9 -0
- package/src/__fixtures__/monorepo-nested/packages/deep-nested/package.json +4 -0
- package/src/__fixtures__/monorepo-nested/packages/nested-1/packages/package-nested.json +4 -0
- package/src/__fixtures__/monorepo-nested/packages/nested-1/packages/package.json +4 -0
- package/src/__fixtures__/monorepo-nested/packages/package-1/package.json +4 -0
- package/src/__fixtures__/monorepo-no-name/package.json +7 -0
- package/src/__fixtures__/monorepo-no-name/packages/no-name-package/package.json +3 -0
- package/src/__fixtures__/monorepo-object-form/package.json +9 -0
- package/src/__fixtures__/monorepo-object-form/packages/package-1/package.json +4 -0
- package/src/__fixtures__/monorepo-object-form/packages/package-2/package.json +4 -0
- package/src/__fixtures__/monorepo-object-form/packages/package-3/package.json +4 -0
- package/src/__fixtures__/monorepo-object-form/packages/package-4/package.json +4 -0
- package/src/__fixtures__/monorepo-object-form/packages/package-5/package.json +4 -0
- package/src/commands/version.test.ts +14 -8
- package/src/commands/version.ts +269 -273
- package/src/missing-types.d.ts +0 -1
- package/src/utils/conventionalChangelogUtils.test.ts +1 -0
- package/src/utils/mapWorkspaces.test.ts +89 -0
- package/src/utils/packageDependenciesUtils.test.ts +1 -0
- package/src/utils/packageUtils.test.ts +32 -0
- package/src/utils/packageUtils.ts +52 -22
- package/tsconfig.json +1 -3
package/src/commands/version.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable complexity */
|
|
2
2
|
|
|
3
3
|
import { Option, program } from "commander";
|
|
4
|
-
import {
|
|
4
|
+
import { LoggerCLI } from "nightingale";
|
|
5
5
|
import { satisfies } from "semver";
|
|
6
6
|
import { UsageError } from "../utils/UsageError.ts";
|
|
7
7
|
import type { BumpType } from "../utils/bumpTypeUtils.ts";
|
|
@@ -111,20 +111,8 @@ const todayInYYYYMMDD = (): string => {
|
|
|
111
111
|
|
|
112
112
|
export const versionCommandAction = async (
|
|
113
113
|
options: VersionCommandOptions,
|
|
114
|
-
{
|
|
114
|
+
{ logger = new LoggerCLI("yarn-version", { json: options.json }) } = {},
|
|
115
115
|
): Promise<void> => {
|
|
116
|
-
// todo nightingale-cli
|
|
117
|
-
if (options.json) {
|
|
118
|
-
process.env.NIGHTINGALE_CONSOLE_FORMATTER = "json";
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
addConfig({
|
|
122
|
-
pattern: /^yarn-version/,
|
|
123
|
-
handler: nightingaleHandler,
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
const logger = new Logger("yarn-version");
|
|
127
|
-
|
|
128
116
|
const rootWorkspace = await (options.cwdIsRoot
|
|
129
117
|
? createWorkspace(options.cwd)
|
|
130
118
|
: findRootWorkspace(options.cwd));
|
|
@@ -192,50 +180,51 @@ export const versionCommandAction = async (
|
|
|
192
180
|
const changedWorkspaces = new Map<Workspace, ChangedWorkspace>();
|
|
193
181
|
const dependenciesMap = isMonorepo ? buildDependenciesMaps(project) : null;
|
|
194
182
|
|
|
195
|
-
|
|
196
|
-
|
|
183
|
+
const bumpableWorkspaces: BumpableWorkspace[] = [];
|
|
184
|
+
|
|
185
|
+
logger.group(
|
|
197
186
|
options.force
|
|
198
187
|
? "Check all workspaces (force option)"
|
|
199
188
|
: "Finding changed workspaces",
|
|
200
|
-
|
|
189
|
+
() => {
|
|
190
|
+
// check workspaces and create bumpableWorkspaces
|
|
201
191
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const workspaceName = getWorkspaceName(workspace);
|
|
207
|
-
const isRoot = workspace === rootWorkspace;
|
|
208
|
-
if (isRoot && isMonorepo && isMonorepoVersionIndependent) continue;
|
|
192
|
+
for (const workspace of workspaces) {
|
|
193
|
+
const workspaceName = getWorkspaceName(workspace);
|
|
194
|
+
const isRoot = workspace === rootWorkspace;
|
|
195
|
+
if (isRoot && isMonorepo && isMonorepoVersionIndependent) continue;
|
|
209
196
|
|
|
210
|
-
|
|
197
|
+
const version = workspace.pkg.version;
|
|
211
198
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
199
|
+
if (!version || version === "0.0.0") {
|
|
200
|
+
if (
|
|
201
|
+
(isRoot || isMonorepoVersionIndependent) &&
|
|
202
|
+
(!isMonorepo || !isMonorepoVersionIndependent)
|
|
203
|
+
) {
|
|
204
|
+
throw new UsageError(
|
|
205
|
+
'package.json has no version in its manifest. For the first release, set to "1.0.0-pre" or "0.1.0-pre".',
|
|
206
|
+
);
|
|
207
|
+
}
|
|
221
208
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
209
|
+
logger.info(`${workspaceName}: skipped (no version)`);
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
225
212
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
213
|
+
bumpableWorkspaces.push({
|
|
214
|
+
workspace,
|
|
215
|
+
workspaceName,
|
|
216
|
+
isRoot,
|
|
217
|
+
version,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
233
220
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
221
|
+
if (bumpableWorkspaces.length > 0) {
|
|
222
|
+
logger.info("Found bumpable workspaces", {
|
|
223
|
+
count: bumpableWorkspaces.length,
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
);
|
|
239
228
|
|
|
240
229
|
const previousTagVersionByWorkspace = new Map<
|
|
241
230
|
Workspace,
|
|
@@ -303,61 +292,58 @@ export const versionCommandAction = async (
|
|
|
303
292
|
),
|
|
304
293
|
);
|
|
305
294
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
let bumpReason: string | undefined;
|
|
295
|
+
await logger.group("Finding changed workspaces", async () => {
|
|
296
|
+
for (const { workspace, workspaceName } of bumpableWorkspaces) {
|
|
297
|
+
let bumpType: BumpType | null = null;
|
|
298
|
+
let bumpReason: string | undefined;
|
|
311
299
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
300
|
+
if (options.force) {
|
|
301
|
+
bumpType = options.force;
|
|
302
|
+
bumpReason = "forced by --force flag";
|
|
303
|
+
} else {
|
|
304
|
+
const commits = commitsByWorkspace?.get(workspace);
|
|
317
305
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
306
|
+
// No changes found for this package
|
|
307
|
+
if (!commits || commits.length === 0) {
|
|
308
|
+
logger.info(`${workspaceName}: skipped (no changes)`);
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
323
311
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
312
|
+
const { releaseType, reason } = await recommendBump(
|
|
313
|
+
commits,
|
|
314
|
+
conventionalCommitConfig,
|
|
315
|
+
);
|
|
316
|
+
bumpReason = reason;
|
|
329
317
|
|
|
330
|
-
|
|
331
|
-
|
|
318
|
+
if (releaseType) {
|
|
319
|
+
bumpType = releaseType as BumpType;
|
|
320
|
+
}
|
|
332
321
|
}
|
|
333
|
-
}
|
|
334
322
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
323
|
+
if (bumpType) {
|
|
324
|
+
if (isMonorepo && !workspace.pkg.name) {
|
|
325
|
+
throw new Error("Workspace name is required");
|
|
326
|
+
}
|
|
339
327
|
|
|
340
|
-
|
|
328
|
+
const currentVersion = workspace.pkg.version;
|
|
341
329
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
330
|
+
if (!currentVersion) {
|
|
331
|
+
throw new UsageError(
|
|
332
|
+
`Invalid "${getWorkspaceName(workspace)}" version`,
|
|
333
|
+
);
|
|
334
|
+
}
|
|
347
335
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
336
|
+
changedWorkspaces.set(workspace, {
|
|
337
|
+
bumpType,
|
|
338
|
+
bumpReason,
|
|
339
|
+
});
|
|
340
|
+
}
|
|
352
341
|
}
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
if (changedWorkspaces.size === 0) {
|
|
356
|
-
logger.info("No changed workspaces");
|
|
357
|
-
return;
|
|
358
|
-
}
|
|
359
342
|
|
|
360
|
-
|
|
343
|
+
if (changedWorkspaces.size === 0) {
|
|
344
|
+
logger.info("No changed workspaces");
|
|
345
|
+
}
|
|
346
|
+
});
|
|
361
347
|
|
|
362
348
|
const bumpedWorkspaces = new Map<Workspace, BumpedWorkspace>();
|
|
363
349
|
const noVersionToUpdateWorkspaces = new Map<
|
|
@@ -368,147 +354,151 @@ export const versionCommandAction = async (
|
|
|
368
354
|
? buildTopologicalOrderBatches(project, dependenciesMap)
|
|
369
355
|
: [[rootWorkspace]];
|
|
370
356
|
|
|
371
|
-
|
|
372
|
-
for (const
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
if (!currentVersion && !workspace.pkg.private) {
|
|
376
|
-
throw new UsageError(
|
|
377
|
-
`Invalid "${getWorkspaceName(workspace)}" version`,
|
|
378
|
-
);
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
const changedWorkspace = changedWorkspaces.get(workspace);
|
|
382
|
-
let bumpType: BumpType | null = null;
|
|
383
|
-
const bumpReasons: string[] = [];
|
|
384
|
-
const dependenciesToBump: BumpedWorkspace["dependenciesToBump"] = [];
|
|
385
|
-
|
|
386
|
-
if (changedWorkspace) {
|
|
387
|
-
bumpType = changedWorkspace.bumpType;
|
|
388
|
-
bumpReasons.push(changedWorkspace.bumpReason || "by commits");
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
const dependencies = dependenciesMap?.get(workspace);
|
|
357
|
+
logger.group("Preparing bumping", () => {
|
|
358
|
+
for (const batch of batches) {
|
|
359
|
+
for (const workspace of batch) {
|
|
360
|
+
const currentVersion = workspace.pkg.version;
|
|
392
361
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
] of dependencies) {
|
|
399
|
-
const dependencyBumpedWorkspace =
|
|
400
|
-
bumpedWorkspaces.get(dependencyWorkspace);
|
|
401
|
-
|
|
402
|
-
if (!dependencyBumpedWorkspace) {
|
|
403
|
-
continue;
|
|
404
|
-
}
|
|
362
|
+
if (!currentVersion && !workspace.pkg.private) {
|
|
363
|
+
throw new UsageError(
|
|
364
|
+
`Invalid "${getWorkspaceName(workspace)}" version`,
|
|
365
|
+
);
|
|
366
|
+
}
|
|
405
367
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
satisfies(
|
|
411
|
-
dependencyBumpedWorkspace.newVersion,
|
|
412
|
-
dependencyDescriptor.selector,
|
|
413
|
-
{ includePrerelease: true },
|
|
414
|
-
)
|
|
415
|
-
) {
|
|
416
|
-
continue;
|
|
417
|
-
}
|
|
368
|
+
const changedWorkspace = changedWorkspaces.get(workspace);
|
|
369
|
+
let bumpType: BumpType | null = null;
|
|
370
|
+
const bumpReasons: string[] = [];
|
|
371
|
+
const dependenciesToBump: BumpedWorkspace["dependenciesToBump"] = [];
|
|
418
372
|
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
);
|
|
373
|
+
if (changedWorkspace) {
|
|
374
|
+
bumpType = changedWorkspace.bumpType;
|
|
375
|
+
bumpReasons.push(changedWorkspace.bumpReason || "by commits");
|
|
376
|
+
}
|
|
424
377
|
|
|
425
|
-
|
|
426
|
-
continue;
|
|
427
|
-
}
|
|
378
|
+
const dependencies = dependenciesMap?.get(workspace);
|
|
428
379
|
|
|
429
|
-
|
|
380
|
+
if (dependencies) {
|
|
381
|
+
for (const [
|
|
382
|
+
dependencyWorkspace,
|
|
430
383
|
dependencyType,
|
|
431
384
|
dependencyDescriptor,
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
385
|
+
] of dependencies) {
|
|
386
|
+
const dependencyBumpedWorkspace =
|
|
387
|
+
bumpedWorkspaces.get(dependencyWorkspace);
|
|
388
|
+
|
|
389
|
+
if (!dependencyBumpedWorkspace) {
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
if (
|
|
394
|
+
dependencyType === "peerDependencies" &&
|
|
395
|
+
!options.alwaysBumpPeerDependencies &&
|
|
396
|
+
// skip when peerdependency with a new version satisfied by the existing range.
|
|
397
|
+
satisfies(
|
|
398
|
+
dependencyBumpedWorkspace.newVersion,
|
|
399
|
+
dependencyDescriptor.selector,
|
|
400
|
+
{ includePrerelease: true },
|
|
401
|
+
)
|
|
402
|
+
) {
|
|
403
|
+
continue;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
const newRange = calcBumpRange(
|
|
407
|
+
workspace,
|
|
408
|
+
dependencyDescriptor.selector,
|
|
409
|
+
dependencyBumpedWorkspace.newVersion,
|
|
410
|
+
);
|
|
448
411
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
if (workspace !== rootWorkspace) {
|
|
453
|
-
noVersionToUpdateWorkspaces.set(workspace, {
|
|
454
|
-
dependenciesToBump,
|
|
455
|
-
});
|
|
456
|
-
}
|
|
457
|
-
} else if (!bumpType) {
|
|
458
|
-
logger.info(
|
|
459
|
-
`${workspaceName}: skipped (${
|
|
460
|
-
changedWorkspace
|
|
461
|
-
? `no bump recommended by ${options.preset}`
|
|
462
|
-
: "no changes"
|
|
463
|
-
})`,
|
|
464
|
-
);
|
|
465
|
-
} else {
|
|
466
|
-
const newVersion = incrementVersion(
|
|
467
|
-
workspace,
|
|
468
|
-
currentVersion,
|
|
469
|
-
bumpType,
|
|
470
|
-
);
|
|
412
|
+
if (dependencyDescriptor.selector === newRange) {
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
471
415
|
|
|
472
|
-
|
|
416
|
+
dependenciesToBump.push([
|
|
417
|
+
dependencyType,
|
|
418
|
+
dependencyDescriptor,
|
|
419
|
+
newRange,
|
|
420
|
+
]);
|
|
421
|
+
|
|
422
|
+
bumpType = getHighestBumpType([
|
|
423
|
+
bumpType ?? "patch",
|
|
424
|
+
calcBumpType(
|
|
425
|
+
dependencyBumpedWorkspace.bumpType,
|
|
426
|
+
options.bumpDependentsHighestAs,
|
|
427
|
+
),
|
|
428
|
+
]);
|
|
473
429
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
430
|
+
bumpReasons.push(
|
|
431
|
+
`Version bump for dependency: ${PackageDescriptorNameUtils.stringify(dependencyDescriptor.name)}`,
|
|
432
|
+
);
|
|
433
|
+
}
|
|
477
434
|
}
|
|
478
435
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
436
|
+
const workspaceName = getWorkspaceName(workspace);
|
|
437
|
+
if (!currentVersion) {
|
|
438
|
+
logger.info(`${workspaceName}: skipped (no version)`);
|
|
439
|
+
if (workspace !== rootWorkspace) {
|
|
440
|
+
noVersionToUpdateWorkspaces.set(workspace, {
|
|
441
|
+
dependenciesToBump,
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
} else if (!bumpType) {
|
|
445
|
+
logger.info(
|
|
446
|
+
`${workspaceName}: skipped (${
|
|
447
|
+
changedWorkspace
|
|
448
|
+
? `no bump recommended by ${options.preset}`
|
|
449
|
+
: "no changes"
|
|
450
|
+
})`,
|
|
451
|
+
);
|
|
452
|
+
} else {
|
|
453
|
+
const newVersion = incrementVersion(
|
|
454
|
+
workspace,
|
|
482
455
|
currentVersion,
|
|
483
456
|
bumpType,
|
|
484
|
-
bumpReason,
|
|
485
|
-
bumpForDependenciesReasons: changedWorkspace
|
|
486
|
-
? bumpReasons.slice(1)
|
|
487
|
-
: bumpReasons,
|
|
488
|
-
newVersion,
|
|
489
|
-
newTag: tagName,
|
|
490
|
-
hasChanged: changedWorkspace !== undefined,
|
|
491
|
-
dependenciesToBump,
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
logger.info(
|
|
495
|
-
`${workspaceName}: ${currentVersion} -> ${
|
|
496
|
-
!isMonorepo || isMonorepoVersionIndependent ? newVersion : "bump"
|
|
497
|
-
} (${bumpReason.replace("\n", " ; ")})`,
|
|
498
457
|
);
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
458
|
+
|
|
459
|
+
const tagName = buildTagName(workspace, newVersion);
|
|
460
|
+
|
|
461
|
+
if (workspace === rootWorkspace) {
|
|
462
|
+
rootNewVersion = newVersion;
|
|
463
|
+
rootNewTag = tagName;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
if (workspace !== rootWorkspace || !isMonorepo) {
|
|
467
|
+
const bumpReason = bumpReasons.join("\n");
|
|
468
|
+
bumpedWorkspaces.set(workspace, {
|
|
469
|
+
currentVersion,
|
|
470
|
+
bumpType,
|
|
471
|
+
bumpReason,
|
|
472
|
+
bumpForDependenciesReasons: changedWorkspace
|
|
473
|
+
? bumpReasons.slice(1)
|
|
474
|
+
: bumpReasons,
|
|
475
|
+
newVersion,
|
|
476
|
+
newTag: tagName,
|
|
477
|
+
hasChanged: changedWorkspace !== undefined,
|
|
478
|
+
dependenciesToBump,
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
logger.info(
|
|
482
|
+
`${workspaceName}: ${currentVersion} -> ${
|
|
483
|
+
!isMonorepo || isMonorepoVersionIndependent
|
|
484
|
+
? newVersion
|
|
485
|
+
: "bump"
|
|
486
|
+
} (${bumpReason.replace("\n", " ; ")})`,
|
|
487
|
+
);
|
|
488
|
+
// TODO Json only:
|
|
489
|
+
// logger.info({
|
|
490
|
+
// cwd: npath.fromPortablePath(workspace.cwd),
|
|
491
|
+
// ident: workspaceName,
|
|
492
|
+
// oldVersion: currentVersion,
|
|
493
|
+
// ...(isMonorepoVersionIndependent ? { newVersion } : {}),
|
|
494
|
+
// bumpType,
|
|
495
|
+
// bumpReasons,
|
|
496
|
+
// });
|
|
497
|
+
}
|
|
508
498
|
}
|
|
509
499
|
}
|
|
510
500
|
}
|
|
511
|
-
}
|
|
501
|
+
});
|
|
512
502
|
|
|
513
503
|
// TODO ask for confirmation
|
|
514
504
|
// if (!this.yes) {
|
|
@@ -569,74 +559,81 @@ export const versionCommandAction = async (
|
|
|
569
559
|
);
|
|
570
560
|
}
|
|
571
561
|
|
|
572
|
-
|
|
562
|
+
await logger.group("Applying changes", async () => {
|
|
563
|
+
// Update yarn.lock ; must be done to make sure preversion script can be ran
|
|
573
564
|
|
|
574
|
-
|
|
565
|
+
if (!options.dryRun) {
|
|
566
|
+
logger.info(`${getWorkspaceName(rootWorkspace)}: Running install`);
|
|
567
|
+
await execCommand(rootWorkspace, ["yarn", "install"], "inherit");
|
|
575
568
|
|
|
576
|
-
|
|
577
|
-
logger.info(`${getWorkspaceName(rootWorkspace)}: Running install`);
|
|
578
|
-
await execCommand(rootWorkspace, ["yarn", "install"], "inherit");
|
|
569
|
+
logger.info("Lifecycle script: preversion");
|
|
579
570
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
571
|
+
if (
|
|
572
|
+
isMonorepoVersionIndependent &&
|
|
573
|
+
rootWorkspace.pkg.scripts?.preversion
|
|
574
|
+
) {
|
|
575
|
+
await execCommand(
|
|
576
|
+
rootWorkspace,
|
|
577
|
+
["yarn", "run", "preversion"],
|
|
578
|
+
"inherit",
|
|
579
|
+
);
|
|
580
|
+
}
|
|
589
581
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
582
|
+
// lifecycle: preversion
|
|
583
|
+
for (const workspace of bumpedWorkspaces.keys()) {
|
|
584
|
+
if (workspace.pkg.scripts?.preversion) {
|
|
585
|
+
await execCommand(
|
|
586
|
+
workspace,
|
|
587
|
+
["yarn", "run", "preversion"],
|
|
588
|
+
"inherit",
|
|
589
|
+
);
|
|
590
|
+
}
|
|
594
591
|
}
|
|
595
|
-
}
|
|
596
592
|
|
|
597
|
-
|
|
598
|
-
|
|
593
|
+
logger.info("Modifying versions in package.json");
|
|
594
|
+
// update versions
|
|
599
595
|
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
596
|
+
await Promise.all(
|
|
597
|
+
[...bumpedWorkspaces.entries()].map(
|
|
598
|
+
([workspace, { newVersion, dependenciesToBump }]) => {
|
|
599
|
+
workspace.pkg.version = newVersion;
|
|
604
600
|
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
dependencyDescriptor,
|
|
608
|
-
dependencyNewRange,
|
|
609
|
-
] of dependenciesToBump) {
|
|
610
|
-
const newDescriptor = PackageDependencyDescriptorUtils.make(
|
|
601
|
+
for (const [
|
|
602
|
+
dependencyType,
|
|
611
603
|
dependencyDescriptor,
|
|
612
604
|
dependencyNewRange,
|
|
613
|
-
)
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
605
|
+
] of dependenciesToBump) {
|
|
606
|
+
const newDescriptor = PackageDependencyDescriptorUtils.make(
|
|
607
|
+
dependencyDescriptor,
|
|
608
|
+
dependencyNewRange,
|
|
609
|
+
);
|
|
610
|
+
const [key, newValue] =
|
|
611
|
+
PackageDependencyDescriptorUtils.stringify(newDescriptor);
|
|
612
|
+
workspace.pkg[dependencyType]![key] = newValue;
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
return writePkg(workspace);
|
|
616
|
+
},
|
|
617
|
+
),
|
|
618
|
+
);
|
|
623
619
|
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
620
|
+
// Update yarn.lock ; must be done before running again lifecycle scripts
|
|
621
|
+
logger.info(`${getWorkspaceName(rootWorkspace)}: Running install`);
|
|
622
|
+
await execCommand(rootWorkspace, ["yarn", "install"], "inherit");
|
|
627
623
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
624
|
+
// lifecycle: version
|
|
625
|
+
logger.info("Lifecycle script: version");
|
|
626
|
+
for (const workspace of bumpedWorkspaces.keys()) {
|
|
627
|
+
if (workspace.pkg.scripts?.version) {
|
|
628
|
+
await execCommand(workspace, ["yarn", "run", "version"], "inherit");
|
|
629
|
+
}
|
|
633
630
|
}
|
|
634
631
|
}
|
|
635
|
-
}
|
|
636
632
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
633
|
+
if (isMonorepoVersionIndependent && rootWorkspace.pkg.scripts?.version) {
|
|
634
|
+
await execCommand(rootWorkspace, ["yarn", "run", "version"], "inherit");
|
|
635
|
+
}
|
|
636
|
+
});
|
|
640
637
|
|
|
641
638
|
const changelogs = new Map<Workspace, string>();
|
|
642
639
|
|
|
@@ -709,15 +706,13 @@ export const versionCommandAction = async (
|
|
|
709
706
|
);
|
|
710
707
|
|
|
711
708
|
if (!options.dryRun) {
|
|
712
|
-
|
|
713
|
-
console.log();
|
|
709
|
+
logger.separator();
|
|
714
710
|
|
|
715
711
|
// install to update versions in lock file
|
|
716
712
|
logger.info(`${getWorkspaceName(rootWorkspace)}: Running install`);
|
|
717
713
|
await execCommand(rootWorkspace, ["yarn", "install"], "inherit");
|
|
718
714
|
|
|
719
|
-
|
|
720
|
-
console.log();
|
|
715
|
+
logger.separator();
|
|
721
716
|
|
|
722
717
|
logger.info("Commit, tag and push", {
|
|
723
718
|
changedFiles: await getDirtyFiles(rootWorkspace),
|
|
@@ -903,4 +898,5 @@ export default program
|
|
|
903
898
|
'Ignore changes in files matching the glob. Example: "**/*.test.js"',
|
|
904
899
|
),
|
|
905
900
|
)
|
|
901
|
+
.addOption(new Option("--json", "Logger json"))
|
|
906
902
|
.action((options) => versionCommandAction(options));
|
package/src/missing-types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { beforeAll, describe, expect, it } from "vitest";
|
|
2
3
|
import { loadPreset } from "conventional-changelog-preset-loader";
|
|
3
4
|
import { parseCommits } from "conventional-commits-parser";
|
|
4
5
|
import type { Commit } from "conventional-commits-parser";
|