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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules/
dist/
yarn-error.log
package-lock.json
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lockfiles should not be added to gitignore as they allow to pin specific versions of dependencies, preventing to download different versions when running 2 times "npm install" at different times but from the same source code

yarn.lock
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@
"main": "src/index.js",
"author": "iamludal",
"homepage": "https://github.com/iamludal/semantic-release-jira-notes",
"repository": "https://github.com/iamludal/semantic-release-jira-notes",
"repository": {
"type": "git",
"url": "git+https://github.com/iamludal/semantic-release-jira-notes.git"
},
"license": "MIT",
"type": "module",
"keywords": [
"jira",
"semantic-release",
"release-notes",
"changelog"
],
"dependencies": {
"@semantic-release/error": "2.2.0",
"@semantic-release/release-notes-generator": "^10.0.3",
"aggregate-error": "^4.0.1"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this dependency anymore?

"@semantic-release/error": "^4.0.0",
"@semantic-release/release-notes-generator": "^13.0.0"
}
}
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 default { verifyConditions, generateNotes };
10 changes: 5 additions & 5 deletions src/lib/constants.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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}$/;
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}$/;

module.exports = { INPUTS, TICKET_PREFIX_REGEX, ISSUE_REGEX, DOMAIN_NAME_REGEX };
export default { INPUTS, TICKET_PREFIX_REGEX, ISSUE_REGEX, DOMAIN_NAME_REGEX };
10 changes: 5 additions & 5 deletions src/lib/errors.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
const SemanticReleaseError = require("@semantic-release/error");
import SemanticReleaseError from "@semantic-release/error";

class RegexError extends SemanticReleaseError {
export class RegexError extends SemanticReleaseError {
constructor(value, pattern) {
super(`Value '${value}' does not match regex: ${pattern}`);
}
}

class InvalidTypeError extends SemanticReleaseError {
export class InvalidTypeError extends SemanticReleaseError {
constructor(variableName, expectedType) {
super(`${variableName} should be of type: ${expectedType}`);
}
}

class InputRequiredError extends SemanticReleaseError {
export class InputRequiredError extends SemanticReleaseError {
constructor(inputName) {
super(`Input '${inputName}' is required`);
}
}

module.exports = { RegexError, InvalidTypeError, InputRequiredError };
export default { RegexError, InvalidTypeError, InputRequiredError };
6 changes: 3 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) => {
export default async (pluginConfig, context) => {
const ticketPrefixes = pluginConfig[INPUTS.ticketPrefixes];
const jiraHost = pluginConfig[INPUTS.jiraHost];
const notes = await generateNotes(pluginConfig, context);
Expand Down
9 changes: 3 additions & 6 deletions src/lib/verify-conditions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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";
import SemanticReleaseError from "@semantic-release/error";
import constants from "./constants";

const { INPUTS, TICKET_PREFIX_REGEX, DOMAIN_NAME_REGEX } = constants;

Expand All @@ -10,8 +9,6 @@ module.exports = async pluginConfig => {
const jiraHost = pluginConfig[INPUTS.jiraHost];
const errors = [];

const AggregateError = (await AggregateErrorPromise).default;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need this class anymore? We are using it a line 32 🤔


if (ticketPrefixes && !Array.isArray(ticketPrefixes)) {
errors.push(new SemanticReleaseError(INPUTS.ticketPrefixes, Array.name));
} else if (ticketPrefixes) {
Expand Down