Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 0 additions & 7 deletions src/command-line-arguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export type CommandLineArguments = {
projectDirectory: string;
tempDirectory: string | undefined;
reset: boolean;
backport: boolean;
};

/**
Expand Down Expand Up @@ -38,12 +37,6 @@ export async function readCommandLineArguments(
type: 'boolean',
default: false,
})
.option('backport', {
describe:
'Instructs the tool to bump the second part of the version rather than the first for a backport release.',
type: 'boolean',
default: false,
})
.help()
.strict()
.parse();
Expand Down
112 changes: 0 additions & 112 deletions src/functional.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,118 +116,6 @@ describe('create-release-branch (functional)', () => {
);
});

it('bumps the backport part of the root package and updates the versions of the specified packages according to the release spec if --backport is provided', async () => {
await withMonorepoProjectEnvironment(
{
packages: {
$root$: {
name: '@scope/monorepo',
version: '1.0.0',
directoryPath: '.',
},
a: {
name: '@scope/a',
version: '0.1.2',
directoryPath: 'packages/a',
},
b: {
name: '@scope/b',
version: '1.1.4',
directoryPath: 'packages/b',
},
c: {
name: '@scope/c',
version: '2.0.13',
directoryPath: 'packages/c',
},
d: {
name: '@scope/d',
version: '1.2.3',
directoryPath: 'packages/d',
},
},
workspaces: {
'.': ['packages/*'],
},
},
async (environment) => {
await environment.updateJsonFile('package.json', {
scripts: {
foo: 'bar',
},
});
await environment.updateJsonFileWithinPackage('a', 'package.json', {
scripts: {
foo: 'bar',
},
});
await environment.updateJsonFileWithinPackage('b', 'package.json', {
scripts: {
foo: 'bar',
},
});
await environment.updateJsonFileWithinPackage('c', 'package.json', {
scripts: {
foo: 'bar',
},
});
await environment.updateJsonFileWithinPackage('d', 'package.json', {
scripts: {
foo: 'bar',
},
});

await environment.runTool({
args: ['--backport'],
releaseSpecification: {
packages: {
a: 'major',
b: 'minor',
c: 'patch',
d: '1.2.4',
},
},
});

expect(await environment.readJsonFile('package.json')).toStrictEqual({
name: '@scope/monorepo',
version: '1.1.0',
private: true,
workspaces: ['packages/*'],
scripts: { foo: 'bar' },
});
expect(
await environment.readJsonFileWithinPackage('a', 'package.json'),
).toStrictEqual({
name: '@scope/a',
version: '1.0.0',
scripts: { foo: 'bar' },
});
expect(
await environment.readJsonFileWithinPackage('b', 'package.json'),
).toStrictEqual({
name: '@scope/b',
version: '1.2.0',
scripts: { foo: 'bar' },
});
expect(
await environment.readJsonFileWithinPackage('c', 'package.json'),
).toStrictEqual({
name: '@scope/c',
version: '2.0.14',
scripts: { foo: 'bar' },
});
expect(
await environment.readJsonFileWithinPackage('d', 'package.json'),
).toStrictEqual({
name: '@scope/d',
version: '1.2.4',
scripts: { foo: 'bar' },
});
},
);
});

it("updates each of the specified packages' changelogs by adding a new section which lists all commits concerning the package over the entire history of the repo", async () => {
await withMonorepoProjectEnvironment(
{
Expand Down
61 changes: 0 additions & 61 deletions src/initial-parameters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ describe('initial-parameters', () => {
projectDirectory: '/path/to/project',
tempDirectory: '/path/to/temp',
reset: true,
backport: false,
});
jest
.spyOn(envModule, 'getEnvironmentVariables')
Expand All @@ -53,7 +52,6 @@ describe('initial-parameters', () => {
project,
tempDirectoryPath: '/path/to/temp',
reset: true,
releaseType: 'ordinary',
});
});

Expand All @@ -68,7 +66,6 @@ describe('initial-parameters', () => {
projectDirectory: 'project',
tempDirectory: undefined,
reset: true,
backport: false,
});
jest
.spyOn(envModule, 'getEnvironmentVariables')
Expand Down Expand Up @@ -97,7 +94,6 @@ describe('initial-parameters', () => {
projectDirectory: '/path/to/project',
tempDirectory: 'tmp',
reset: true,
backport: false,
});
jest
.spyOn(envModule, 'getEnvironmentVariables')
Expand Down Expand Up @@ -126,7 +122,6 @@ describe('initial-parameters', () => {
projectDirectory: '/path/to/project',
tempDirectory: undefined,
reset: true,
backport: false,
});
jest
.spyOn(envModule, 'getEnvironmentVariables')
Expand Down Expand Up @@ -155,7 +150,6 @@ describe('initial-parameters', () => {
projectDirectory: '/path/to/project',
tempDirectory: '/path/to/temp',
reset: true,
backport: false,
});
jest
.spyOn(envModule, 'getEnvironmentVariables')
Expand All @@ -182,7 +176,6 @@ describe('initial-parameters', () => {
projectDirectory: '/path/to/project',
tempDirectory: '/path/to/temp',
reset: false,
backport: false,
});
jest
.spyOn(envModule, 'getEnvironmentVariables')
Expand All @@ -199,59 +192,5 @@ describe('initial-parameters', () => {

expect(initialParameters.reset).toBe(false);
});

it('returns initial parameters including a releaseType of "backport", derived from a command-line argument of "--backport true"', async () => {
const project = buildMockProject();
const stderr = createNoopWriteStream();
when(jest.spyOn(commandLineArgumentsModule, 'readCommandLineArguments'))
.calledWith(['arg1', 'arg2'])
.mockResolvedValue({
projectDirectory: '/path/to/project',
tempDirectory: '/path/to/temp',
reset: false,
backport: true,
});
jest
.spyOn(envModule, 'getEnvironmentVariables')
.mockReturnValue({ EDITOR: undefined });
when(jest.spyOn(projectModule, 'readProject'))
.calledWith('/path/to/project', { stderr })
.mockResolvedValue(project);

const initialParameters = await determineInitialParameters({
argv: ['arg1', 'arg2'],
cwd: '/path/to/somewhere',
stderr,
});

expect(initialParameters.releaseType).toBe('backport');
});

it('returns initial parameters including a releaseType of "ordinary", derived from a command-line argument of "--backport false"', async () => {
const project = buildMockProject();
const stderr = createNoopWriteStream();
when(jest.spyOn(commandLineArgumentsModule, 'readCommandLineArguments'))
.calledWith(['arg1', 'arg2'])
.mockResolvedValue({
projectDirectory: '/path/to/project',
tempDirectory: '/path/to/temp',
reset: false,
backport: false,
});
jest
.spyOn(envModule, 'getEnvironmentVariables')
.mockReturnValue({ EDITOR: undefined });
when(jest.spyOn(projectModule, 'readProject'))
.calledWith('/path/to/project', { stderr })
.mockResolvedValue(project);

const initialParameters = await determineInitialParameters({
argv: ['arg1', 'arg2'],
cwd: '/path/to/somewhere',
stderr,
});

expect(initialParameters.releaseType).toBe('ordinary');
});
});
});
13 changes: 0 additions & 13 deletions src/initial-parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,10 @@ import { readCommandLineArguments } from './command-line-arguments';
import { WriteStreamLike } from './fs';
import { readProject, Project } from './project';

/**
* The type of release being created as determined by the parent release.
*
* - An *ordinary* release includes features or fixes applied against the
* latest release and is designated by bumping the first part of that release's
* version string.
* - A *backport* release includes fixes applied against a previous release and
* is designated by bumping the second part of that release's version string.
*/
export type ReleaseType = 'ordinary' | 'backport';

type InitialParameters = {
project: Project;
tempDirectoryPath: string;
reset: boolean;
releaseType: ReleaseType;
};

/**
Expand Down Expand Up @@ -58,6 +46,5 @@ export async function determineInitialParameters({
project,
tempDirectoryPath,
reset: args.reset,
releaseType: args.backport ? 'backport' : 'ordinary',
};
}
3 changes: 0 additions & 3 deletions src/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ describe('main', () => {
project,
tempDirectoryPath: '/path/to/temp/directory',
reset: true,
releaseType: 'backport',
});
const followMonorepoWorkflowSpy = jest
.spyOn(monorepoWorkflowOperations, 'followMonorepoWorkflow')
Expand All @@ -35,7 +34,6 @@ describe('main', () => {
project,
tempDirectoryPath: '/path/to/temp/directory',
firstRemovingExistingReleaseSpecification: true,
releaseType: 'backport',
stdout,
stderr,
});
Expand All @@ -51,7 +49,6 @@ describe('main', () => {
project,
tempDirectoryPath: '/path/to/temp/directory',
reset: false,
releaseType: 'backport',
});
const followMonorepoWorkflowSpy = jest
.spyOn(monorepoWorkflowOperations, 'followMonorepoWorkflow')
Expand Down
3 changes: 1 addition & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function main({
stdout: Pick<WriteStream, 'write'>;
stderr: Pick<WriteStream, 'write'>;
}) {
const { project, tempDirectoryPath, reset, releaseType } =
const { project, tempDirectoryPath, reset } =
await determineInitialParameters({ argv, cwd, stderr });

if (project.isMonorepo) {
Expand All @@ -36,7 +36,6 @@ export async function main({
project,
tempDirectoryPath,
firstRemovingExistingReleaseSpecification: reset,
releaseType,
stdout,
stderr,
});
Expand Down
Loading