Skip to content

BREAKING CHANGE: update project to ESM #5

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 1 commit into from
May 28, 2024
Merged
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
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
# semantic-release-jira-notes

[![npm latest version](https://img.shields.io/npm/v/semantic-release-jira-notes/latest.svg)](https://www.npmjs.com/package/semantic-release-jira-notes)
[![ESM-only package][package]][package-url]
[![NPM version][npm]][npm-url]
[![Node version][node]][node-url]
[![Dependencies status][deps]][deps-url]
[![Install size][size]][size-url]

[package]: https://img.shields.io/badge/package-ESM--only-ffe536.svg
[package-url]: https://nodejs.org/api/esm.html

[npm]: https://img.shields.io/npm/v/semantic-release-jira-notes/latest.svg
[npm-url]: https://www.npmjs.com/package/semantic-release-jira-notes

[node]: https://img.shields.io/node/v/semantic-release-jira-notes/latest.svg
[node-url]: https://nodejs.org

[deps]: https://img.shields.io/librariesio/release/npm/semantic-release-jira-notes
[deps-url]: https://libraries.io/npm/semantic-release-jira-notes/tree

[size]: https://packagephobia.com/badge?p=semantic-release-jira-notes
[size-url]: https://packagephobia.com/result?p=semantic-release-jira-notes

[**semantic-release**](https://github.com/semantic-release/semantic-release) plugin to add links to
JIRA issues in the release notes.
Expand All @@ -23,8 +42,12 @@ For each JIRA issue detected in the release notes, it will add a link that bring
### Installation

```bash
$ npm install --save-dev semantic-release-jira-notes
$ yarn add --dev semantic-release-jira-notes
# npm
npm install --save-dev semantic-release-jira-notes
# yarn
yarn add --dev semantic-release-jira-notes
# pnpm
pnpm add --save-dev semantic-release-jira-notes
```

### Inputs
Expand Down
16 changes: 13 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"name": "semantic-release-jira-notes",
"version": "3.0.0",
"engines": {
"node": ">=18"
},
"description": "Semantic Release plugin to add JIRA issues link to the release notes",
"main": "src/index.js",
"type": "module",
"author": "iamludal",
"homepage": "https://github.com/iamludal/semantic-release-jira-notes",
"repository": "https://github.com/iamludal/semantic-release-jira-notes",
Expand All @@ -14,8 +18,14 @@
"changelog"
],
"dependencies": {
"@semantic-release/error": "2.2.0",
"@semantic-release/release-notes-generator": "^10.0.3",
"aggregate-error": "^4.0.1"
"@semantic-release/error": "4.0.0",
"@semantic-release/release-notes-generator": "^13.0.0",
"aggregate-error": "^5.0.0"
},
"scripts": {
"prettier": "prettier --write src/**/*.js"
},
"devDependencies": {
"prettier": "^3.2.5"
}
}
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const verifyConditions = require("./lib/verify-conditions");
const generateNotes = require("./lib/generate-notes");
import { verifyConditions } from "./lib/verify-conditions.js";
import { generateNotes } from "./lib/generate-notes.js";

module.exports = { verifyConditions, generateNotes };
export { verifyConditions, generateNotes };
10 changes: 4 additions & 6 deletions src/lib/constants.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const INPUTS = { ticketPrefixes: "ticketPrefixes", jiraHost: "jiraHost" };
export const INPUTS = { ticketPrefixes: "ticketPrefixes", jiraHost: "jiraHost" };

const TICKET_PREFIX_REGEX = /^[A-Z][A-Z0-9]{0,50}$/;
const ISSUE_REGEX = /([A-Z][A-Z0-9]{0,50}-[1-9][0-9]*)/;
const DOMAIN_NAME_REGEX = /^((?!-)[A-Za-z0-9-]{1,63}(?<!-)\.)+[A-Za-z]{2,6}$/;

module.exports = { INPUTS, TICKET_PREFIX_REGEX, ISSUE_REGEX, DOMAIN_NAME_REGEX };
export const TICKET_PREFIX_REGEX = /^[A-Z][A-Z0-9]{0,50}$/;
export const ISSUE_REGEX = /([A-Z][A-Z0-9]{0,50}-[1-9][0-9]*)/;
export const DOMAIN_NAME_REGEX = /^((?!-)[A-Za-z0-9-]{1,63}(?<!-)\.)+[A-Za-z]{2,6}$/;
4 changes: 2 additions & 2 deletions src/lib/errors.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const SemanticReleaseError = require("@semantic-release/error");
import SemanticReleaseError from "@semantic-release/error";

class RegexError extends SemanticReleaseError {
constructor(value, pattern) {
Expand All @@ -18,4 +18,4 @@ class InputRequiredError extends SemanticReleaseError {
}
}

module.exports = { RegexError, InvalidTypeError, InputRequiredError };
export { RegexError, InvalidTypeError, InputRequiredError };
8 changes: 5 additions & 3 deletions src/lib/generate-notes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { INPUTS, ISSUE_REGEX } = require("./constants");
const { generateNotes } = require("@semantic-release/release-notes-generator");
import { INPUTS, ISSUE_REGEX } from "./constants.js";
import { generateNotes } from "@semantic-release/release-notes-generator";

module.exports = async (pluginConfig, context) => {
const generateJiraNotes = async (pluginConfig, context) => {
const ticketPrefixes = pluginConfig[INPUTS.ticketPrefixes];
const jiraHost = pluginConfig[INPUTS.jiraHost];
const notes = await generateNotes(pluginConfig, context);
Expand All @@ -18,3 +18,5 @@ module.exports = async (pluginConfig, context) => {

return notes?.replace(issueRegex, `[$1](https://${jiraHost}/browse/$1)`);
};

export { generateJiraNotes as generateNotes };
14 changes: 7 additions & 7 deletions src/lib/verify-conditions.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
const { InputRequiredError, RegexError } = require("./errors");
const SemanticReleaseError = require("@semantic-release/error");
const AggregateErrorPromise = import("aggregate-error");
const constants = require("./constants");
import { InputRequiredError, RegexError } from "./errors.js";
import SemanticReleaseError from "@semantic-release/error";
import AggregateErrorPromise from "aggregate-error";
import { INPUTS, TICKET_PREFIX_REGEX, DOMAIN_NAME_REGEX } from "./constants.js";

const { INPUTS, TICKET_PREFIX_REGEX, DOMAIN_NAME_REGEX } = constants;

module.exports = async pluginConfig => {
const verifyConditions = async pluginConfig => {
const ticketPrefixes = pluginConfig[INPUTS.ticketPrefixes];
const jiraHost = pluginConfig[INPUTS.jiraHost];
const errors = [];
Expand All @@ -32,3 +30,5 @@ module.exports = async pluginConfig => {
throw new AggregateError(errors);
}
};

export { verifyConditions };
Loading