Skip to content

Commit 5fb647a

Browse files
committed
feat(eui-release-cli): compute list of publishable workspaces instead of throwing an error when a package version is already published
1 parent 49b776f commit 5fb647a

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

packages/release-cli/src/release.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,9 @@ export const release = async (options: ReleaseOptions) => {
124124

125125
await stepRunPreScripts(options);
126126

127-
await stepCheckWorkspaces(options, changedWorkspaces);
127+
const publishableWorkspaces = await stepCheckWorkspaces(options, changedWorkspaces);
128128

129-
await stepPublish(options, changedWorkspaces);
129+
await stepPublish(options, publishableWorkspaces);
130130

131131
await stepRunPostScripts(options);
132132
};

packages/release-cli/src/steps/check_workspaces.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const stepCheckWorkspaces = async (
3030
) => {
3131
const { logger } = options;
3232
const rootWorkspaceDir = getRootWorkspaceDir();
33+
const publishableWorkspaces: Array<YarnWorkspace> = [];
3334

3435
logger.info('Checking latest versions of published packages on npmjs');
3536

@@ -38,13 +39,22 @@ export const stepCheckWorkspaces = async (
3839
const packageJson = await getWorkspacePackageJson(workspaceDir);
3940

4041
if (packageJson.private) {
41-
logger.debug(`[${workspace.name}] Package is private and will not be published`);
42+
logger.debug(
43+
`[${workspace.name}] Package is private and will not be published`
44+
);
4245
continue;
4346
}
4447

4548
const publishedVersions = await getNpmPublishedVersions(workspace.name);
4649
if (publishedVersions.includes(packageJson.version)) {
47-
throw new ValidationError(`${workspace.name}@${packageJson.version} is already available on npmjs and cannot be republished`);
50+
logger.warning(
51+
`[${workspace.name}] Version ${packageJson.version} is already available on npmjs and cannot be republished. The package will be skipped from publishing`
52+
);
53+
continue;
4854
}
55+
56+
publishableWorkspaces.push(workspace);
4957
}
58+
59+
return publishableWorkspaces;
5060
};

packages/release-cli/src/steps/publish.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ export const stepPublish = async (
2828
const { logger, dryRun } = options;
2929
const rootWorkspaceDir = getRootWorkspaceDir();
3030

31+
if (!workspacesToPublish.length) {
32+
logger.warning('No packages to publish');
33+
return;
34+
}
35+
3136
const publishedWorkspaces: Array<PublishedWorkspace> = [];
3237

3338
for (const workspace of workspacesToPublish) {

0 commit comments

Comments
 (0)