Skip to content
Open
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed .yarn/cache/nx-npm-21.6.5-dd9eda55ec-9a8a114657.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
"@angular-devkit/schematics": "19.2.19",
"@commitlint/cli": "^19.0.0",
"@commitlint/config-angular": "^19.0.0",
"@nx/devkit": "21.6.5",
"@nx/eslint-plugin": "21.6.5",
"@nx/jest": "21.6.5",
"@nx/js": "21.6.5",
"@nx/plugin": "21.6.5",
"@nx/workspace": "21.6.5",
"@nx/devkit": "22.4.5",
"@nx/eslint-plugin": "22.4.5",
"@nx/jest": "22.4.5",
"@nx/js": "22.4.5",
"@nx/plugin": "22.4.5",
"@nx/workspace": "22.4.5",
"@swc-node/register": "1.10.10",
"@swc/core": "1.11.11",
"@types/jest": "30.0.0",
Expand All @@ -54,7 +54,7 @@
"jest-extended": "^4.0.0",
"jest-util": "30.0.5",
"ngx-deploy-npm": "^8.0.0",
"nx": "21.6.5",
"nx": "22.4.5",
"prettier": "3.6.2",
"tmp": "^0.2.1",
"ts-jest": "29.4.5",
Expand Down
3 changes: 0 additions & 3 deletions packages/semver/src/executors/common/exec.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { lastValueFrom } from 'rxjs';
import { exec } from './exec';

describe(exec.name, () => {
it('should exec and return stdout', (done) => {
const observer = {
next: jest.fn(),
};

exec('node', ['--version']).subscribe({
next: observer.next,
error: done.fail,
Expand All @@ -19,7 +17,6 @@ describe(exec.name, () => {
},
});
});

it('should handle failure and return stderr', async () => {
await expect(lastValueFrom(exec('exit', ['1']))).rejects.toThrow();
});
Expand Down
29 changes: 0 additions & 29 deletions packages/semver/src/executors/github/executor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,144 +1,115 @@
import { logger } from '@nx/devkit';
import { of, throwError } from 'rxjs';

import { exec } from '../common/exec';
import executor from './executor';

import type { GithubExecutorSchema } from './schema';

jest.mock('../common/exec');

const options: GithubExecutorSchema = {
tag: 'v1.0.0',
};

describe('@jscutlery/semver:github', () => {
const mockExec = exec as jest.Mock;

beforeEach(() => {
mockExec.mockImplementation(() => {
return of({
stdout: 'success',
});
});
});

it('create release with specified --tag', async () => {
const output = await executor(options);

expect(mockExec).toHaveBeenCalledWith(
'gh',
expect.arrayContaining(['release', 'create', 'v1.0.0']),
);
expect(output.success).toBe(true);
});

it('create release with specified --files', async () => {
const output = await executor({ ...options, files: ['./dist/package'] });

expect(mockExec).toHaveBeenCalledWith(
'gh',
expect.arrayContaining(['./dist/package']),
);
expect(output.success).toBe(true);
});

it('create release with specified --target', async () => {
const output = await executor({ ...options, target: 'master' });

expect(mockExec).toHaveBeenCalledWith(
'gh',
expect.arrayContaining(['--target', 'master']),
);
expect(output.success).toBe(true);
});

it('create release with specified --notes', async () => {
const output = await executor({ ...options, notes: 'add feature' });

expect(mockExec).toHaveBeenCalledWith(
'gh',
expect.arrayContaining(['--notes', 'add feature']),
);
expect(output.success).toBe(true);
});

it('create release with specified --notesFile', async () => {
const output = await executor({
...options,
notesFile: 'libs/my-lib/CHANGELOG.md',
});

expect(mockExec).toHaveBeenCalledWith(
'gh',
expect.arrayContaining(['--notes-file', 'libs/my-lib/CHANGELOG.md']),
);
expect(output.success).toBe(true);
});

it('create release with specified --draft', async () => {
const output = await executor({ ...options, draft: true });

expect(mockExec).toHaveBeenCalledWith(
'gh',
expect.arrayContaining(['--draft']),
);
expect(output.success).toBe(true);
});

it('create release with specified --title', async () => {
const output = await executor({ ...options, title: 'Title for release' });

expect(mockExec).toHaveBeenCalledWith(
'gh',
expect.arrayContaining(['--title', 'Title for release']),
);
expect(output.success).toBe(true);
});

it('create release with specified --prerelease', async () => {
const output = await executor({ ...options, prerelease: true });

expect(mockExec).toHaveBeenCalledWith(
'gh',
expect.arrayContaining(['--prerelease']),
);
expect(output.success).toBe(true);
});

it('create release with specified --discussion-category', async () => {
const output = await executor({
...options,
discussionCategory: 'General',
});

expect(mockExec).toHaveBeenCalledWith(
'gh',
expect.arrayContaining(['--discussion-category', 'General']),
);
expect(output.success).toBe(true);
});

it('create release with specified --repo', async () => {
const output = await executor({ ...options, repo: 'repo:MYORG/REPO' });

expect(mockExec).toHaveBeenCalledWith(
'gh',
expect.arrayContaining(['--repo', 'repo:MYORG/REPO']),
);
expect(output.success).toBe(true);
});

it('handle gh CLI errors', async () => {
mockExec.mockImplementation(() => {
return throwError(() => ({
stderr: 'something went wrong',
}));
});
jest.spyOn(logger, 'error').mockImplementation();

const output = await executor(options);

expect(logger.error).toHaveBeenCalled();
expect(output.success).toBe(false);
});
Expand Down
23 changes: 0 additions & 23 deletions packages/semver/src/executors/gitlab/executor.spec.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,34 @@
import { logger } from '@nx/devkit';
import { of, throwError } from 'rxjs';

import { exec } from '../common/exec';
import executor from './executor';

import type { GitLabReleaseSchema } from './schema';

jest.mock('../common/exec');

const options: GitLabReleaseSchema = {
tag: 'v1.0.0',
};

describe('@jscutlery/semver:gitlab', () => {
const mockExec = exec as jest.Mock;

beforeEach(() => {
mockExec.mockImplementation(() => {
return of({
stdout: 'success',
});
});
});

it('create release with specified --tag', async () => {
const output = await executor(options);

expect(mockExec).toHaveBeenCalledWith(
'release-cli',
expect.arrayContaining(['create', '--tag-name', 'v1.0.0']),
);
expect(output.success).toBe(true);
});

it('create release with specified --assets', async () => {
const output = await executor({
...options,
assets: [{ name: 'asset1', url: './dist/package' }],
});

expect(mockExec).toHaveBeenCalledWith(
'release-cli',
expect.arrayContaining([
Expand All @@ -48,70 +38,57 @@ describe('@jscutlery/semver:gitlab', () => {
);
expect(output.success).toBe(true);
});

it('create release with specified --ref', async () => {
const output = await executor({ ...options, ref: 'master' });

expect(mockExec).toHaveBeenCalledWith(
'release-cli',
expect.arrayContaining(['--ref', 'master']),
);
expect(output.success).toBe(true);
});

it('create release with specified --description', async () => {
const output = await executor({ ...options, description: 'add feature' });

expect(mockExec).toHaveBeenCalledWith(
'release-cli',
expect.arrayContaining(['--description', 'add feature']),
);
expect(output.success).toBe(true);
});

it('create release with specified --name', async () => {
const output = await executor({ ...options, name: 'Title for release' });

expect(mockExec).toHaveBeenCalledWith(
'release-cli',
expect.arrayContaining(['--name', 'Title for release']),
);
expect(output.success).toBe(true);
});

it('create release with specified --milestones', async () => {
const output = await executor({
...options,
milestones: ['v1.0.0'],
});

expect(mockExec).toHaveBeenCalledWith(
'release-cli',
expect.arrayContaining(['--milestone', 'v1.0.0']),
);
expect(output.success).toBe(true);
});

it('create release with specified --releasedAt', async () => {
const output = await executor({ ...options, releasedAt: 'XYZ' });

expect(mockExec).toHaveBeenCalledWith(
'release-cli',
expect.arrayContaining(['--released-at', 'XYZ']),
);
expect(output.success).toBe(true);
});

it('handle release CLI errors', async () => {
mockExec.mockImplementation(() => {
return throwError(() => ({
stderr: 'something went wrong',
}));
});
jest.spyOn(logger, 'error').mockImplementation();

const output = await executor(options);

expect(logger.error).toHaveBeenCalled();
expect(output.success).toBe(false);
});
Expand Down
Loading
Loading