Skip to content

Update release spec to only list changed packages #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Sep 30, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 37 additions & 56 deletions src/package.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('package', () => {
);
});

it("returns the fact that the package has been changed since its latest release, if a tag matching the current version exists and changes have been made to the package's directory since the tag", async () => {
it("flags the package as having been changed since its latest release if a tag matching the current version exists and changes have been made to the package's directory since the tag", async () => {
jest
.spyOn(packageManifestModule, 'readPackageManifest')
.mockResolvedValue({
Expand All @@ -118,7 +118,7 @@ describe('package', () => {
});
});

it("returns the fact that the package has not been changed since its latest release if a tag matching the current version exists, and changes have not been made to the package's directory since the tag", async () => {
it("does not flag the package as having been changed since its latest release if a tag matching the current version exists, but changes have not been made to the package's directory since the tag", async () => {
jest
.spyOn(packageManifestModule, 'readPackageManifest')
.mockResolvedValue({
Expand All @@ -142,55 +142,7 @@ describe('package', () => {
});
});

it("returns the fact that the package has been changed since its latest release, if a tag matching 'v' + the current version exists and changes have been made to the package's directory since the tag", async () => {
jest
.spyOn(packageManifestModule, 'readPackageManifest')
.mockResolvedValue({
unvalidated: {},
validated: buildMockManifest({
version: new SemVer('1.0.0'),
}),
});
when(jest.spyOn(repoModule, 'hasChangesInDirectorySinceGitTag'))
.calledWith('/path/to/project', '/path/to/package', 'v1.0.0')
.mockResolvedValue(true);

const pkg = await readMonorepoRootPackage({
packageDirectoryPath: '/path/to/package',
projectDirectoryPath: '/path/to/project',
projectTagNames: ['v1.0.0'],
});

expect(pkg).toMatchObject({
hasChangesSinceLatestRelease: true,
});
});

it("returns the fact that the package has not been changed since its latest release if a tag matching 'v' + the current version exists, and changes have not been made to the package's directory since the tag", async () => {
jest
.spyOn(packageManifestModule, 'readPackageManifest')
.mockResolvedValue({
unvalidated: {},
validated: buildMockManifest({
version: new SemVer('1.0.0'),
}),
});
when(jest.spyOn(repoModule, 'hasChangesInDirectorySinceGitTag'))
.calledWith('/path/to/project', '/path/to/package', 'v1.0.0')
.mockResolvedValue(false);

const pkg = await readMonorepoRootPackage({
packageDirectoryPath: '/path/to/package',
projectDirectoryPath: '/path/to/project',
projectTagNames: ['v1.0.0'],
});

expect(pkg).toMatchObject({
hasChangesSinceLatestRelease: false,
});
});

it("returns the fact that the package has been changed since its latest release if a tag matching neither the current version nor 'v' + the current version exists", async () => {
it('flags the package as having been changed since its latest release if a tag matching the current version does not exist', async () => {
jest
.spyOn(packageManifestModule, 'readPackageManifest')
.mockResolvedValue({
Expand Down Expand Up @@ -288,7 +240,7 @@ describe('package', () => {
);
});

it("returns the fact that the package has been changed since its latest release, if a tag matching the package name + version exists and changes have been made to the package's directory since the tag", async () => {
it("flags the package as having been changed since its latest release if a tag matching the package name + version exists and changes have been made to the package's directory since the tag", async () => {
jest
.spyOn(packageManifestModule, 'readPackageManifest')
.mockResolvedValue({
Expand Down Expand Up @@ -319,7 +271,7 @@ describe('package', () => {
});
});

it("returns the fact that the package has not been changed since its latest release if a tag matching the package name + version exists, and changes have not been made to the package's directory since the tag", async () => {
it("does not flag the package as having been changed since its latest release if a tag matching the package name + version exists, but changes have not been made to the package's directory since the tag", async () => {
jest
.spyOn(packageManifestModule, 'readPackageManifest')
.mockResolvedValue({
Expand Down Expand Up @@ -350,7 +302,7 @@ describe('package', () => {
});
});

it("returns the fact that the package has been changed since its latest release, if a tag matching 'v' + the root package version exists and changes have been made to the package's directory since the tag", async () => {
it("flags the package as having been changed since its latest release if a tag matching 'v' + the root package version exists instead of the package name + version, and changes have been made to the package's directory since the tag", async () => {
jest
.spyOn(packageManifestModule, 'readPackageManifest')
.mockResolvedValue({
Expand All @@ -376,7 +328,7 @@ describe('package', () => {
});
});

it("returns the fact that the package has not been changed since its latest release if a tag matching 'v' + the root package exists and changes have not been made to the package's directory since the tag", async () => {
it("does not flag the package as having been changed since its latest release if a tag matching 'v' + the root package version exists instead of the package name + version, but changes have not been made to the package's directory since the tag", async () => {
jest
.spyOn(packageManifestModule, 'readPackageManifest')
.mockResolvedValue({
Expand All @@ -402,7 +354,36 @@ describe('package', () => {
});
});

it("returns the fact that the package has been changed since its latest release if a tag matching neither the package name + version nor 'v' + the root package version exists", async () => {
it("prints a warning if a tag matching 'v' + the root package version exists instead of the package name + version", async () => {
const stderr = new MockWritable();
jest
.spyOn(packageManifestModule, 'readPackageManifest')
.mockResolvedValue({
unvalidated: {},
validated: buildMockManifest({
name: 'workspace-package',
version: new SemVer('1.0.0'),
}),
});
when(jest.spyOn(repoModule, 'hasChangesInDirectorySinceGitTag'))
.calledWith('/path/to/project', '/path/to/package', 'v5.0.0')
.mockResolvedValue(false);

await readMonorepoWorkspacePackage({
packageDirectoryPath: '/path/to/package',
projectDirectoryPath: '/path/to/project',
projectTagNames: ['v5.0.0'],
rootPackageName: 'root-package',
rootPackageVersion: new SemVer('5.0.0'),
stderr,
});

expect(stderr.data()).toStrictEqual(
'WARNING: It appears that the package workspace-package is missing a Git tag for its current release 1.0.0 (expected: "1.0.0"). This tool can make do with the tag that exists for root package ("v5.0.0"), but you should create this tag as soon as possible.',
);
});

it("flags the package as having been changed since its latest release if a tag matching neither the package name + version nor 'v' + the root package version exists", async () => {
jest
.spyOn(packageManifestModule, 'readPackageManifest')
.mockResolvedValue({
Expand Down