Skip to content

Commit

Permalink
fix(monorepo): warning "The distTag option is deprecated. Use the n…
Browse files Browse the repository at this point in the history
…pmDistTag option instead." (#798)
  • Loading branch information
mrgrain authored Feb 19, 2025
1 parent a19d4a7 commit 34d4703
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
19 changes: 13 additions & 6 deletions src/yarn/monorepo-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class MonorepoRelease extends Component {
readonly release: {
readonly workspace: TypeScriptWorkspace;
readonly publisher: projenRelease.Publisher;
readonly options: Partial<projenRelease.BranchOptions>;
};
}>();

Expand Down Expand Up @@ -72,6 +73,17 @@ export class MonorepoRelease extends Component {
release: {
workspace: workspaceRelease.workspace,
publisher: workspaceRelease.publisher,
options: {
// enforced options
workflowName: this.options.releaseWorkflowName,
tagPrefix: `${project.name}@`,

// options that may be override locally
majorVersion: options.versionBranchOptions.majorVersion ?? this.options.majorVersion,
minMajorVersion: options.versionBranchOptions.minMajorVersion ?? this.options.minMajorVersion,
prerelease: options.versionBranchOptions.prerelease ?? this.options.prerelease,
npmDistTag: options.npmDistTag ?? this.options.npmDistTag,
},
},
});
}
Expand Down Expand Up @@ -116,12 +128,7 @@ export class MonorepoRelease extends Component {

private renderPublishJobs() {
for (const { release } of this.packagesToRelease) {
const packagePublishJobs = release.publisher._renderJobsForBranch(this.branchName, {
majorVersion: this.options.majorVersion,
minMajorVersion: this.options.minMajorVersion,
npmDistTag: this.options.npmDistTag,
prerelease: this.options.prerelease,
});
const packagePublishJobs = release.publisher._renderJobsForBranch(this.branchName, release.options);

for (const job of Object.values(packagePublishJobs)) {
// Find the 'download-artifact' job and replace the build artifact name with the unique per-project one
Expand Down
1 change: 0 additions & 1 deletion src/yarn/typescript-workspace-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export class WorkspaceRelease extends Component {
// GitHub Releases comes for free with a `Release` component, NPM must be added explicitly
if (options.publishToNpm ?? true) {
this.publisher.publishToNpm({
distTag: options.npmDistTag,
registry: project.package.npmRegistry,
npmTokenSecret: project.package.npmTokenSecret,
});
Expand Down
31 changes: 31 additions & 0 deletions test/cdklabs-monorepo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,37 @@ describe('CdkLabsMonorepo', () => {
})]),
}));
});

test('prerelease is respected for the right workspace package', () => {
new yarn.TypeScriptWorkspace({
parent,
name: '@cdklabs/one',
prerelease: 'rc',
});

new yarn.TypeScriptWorkspace({
parent,
name: '@cdklabs/two',
});

Testing.synth(parent);

expect(parent.github?.tryFindWorkflow('release')?.getJob('cdklabs-one_release_github'))
.toMatchObject(expect.objectContaining({
steps: expect.arrayContaining([expect.objectContaining({
name: 'Release',
run: expect.stringContaining('-p'),
})]),
}));

expect(parent.github?.tryFindWorkflow('release')?.getJob('cdklabs-two_release_github'))
.toMatchObject(expect.objectContaining({
steps: expect.arrayContaining([expect.objectContaining({
name: 'Release',
run: expect.not.stringContaining('-p'),
})]),
}));
});
});

describe('VSCode Workspace', () => {
Expand Down

0 comments on commit 34d4703

Please sign in to comment.