Skip to content
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
50 changes: 8 additions & 42 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"plugin:@typescript-eslint/eslint-recommended"
],
"plugins": [
"@typescript-eslint"
"@typescript-eslint",
"import"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
Expand All @@ -30,29 +31,6 @@
"properties": "always"
}
],
"require-jsdoc": [
"error",
{
"require": {
"FunctionDeclaration": true,
"MethodDefinition": true,
"ClassDeclaration": true
}
}
],
"valid-jsdoc": [
"error",
{
"requireReturn": false,
"preferType": {
"String": "string",
"Object": "object",
"Number": "number",
"Function": "function",
"Void": "void"
}
}
],
"quotes": [
"error",
"single",
Expand All @@ -71,12 +49,6 @@
}
}
],
"no-magic-numbers": [
"error",
{
"ignoreArrayIndexes": true
}
],
"eqeqeq": "error",
"block-scoped-var": "error",
"complexity": [
Expand All @@ -85,7 +57,6 @@
"maximum": 20
}
],
"curly": "error",
"default-case": "error",
"dot-location": [
"error",
Expand All @@ -102,16 +73,6 @@
"after": true
}
],
"id-length": [
"error",
{
"min": 2,
"properties": "never",
"exceptions": [
"$"
]
}
],
"indent": [
"error",
2,
Expand Down Expand Up @@ -144,6 +105,11 @@
],
"semi": [
"error"
]
],
"sort-imports": 0,
"import/order": [2, {
"groups": ["type", "builtin", "external", "internal", "parent", "sibling", "index", "object"],
"alphabetize": { "order": "asc", "caseInsensitive": true }
}]
}
}
13 changes: 0 additions & 13 deletions jest.config.js

This file was deleted.

47 changes: 26 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@technote-space/github-action-version-helper",
"version": "0.5.30",
"version": "0.6.0",
"description": "Version helper for GitHub Actions.",
"keywords": [
"github",
Expand All @@ -20,46 +20,51 @@
"email": "technote.space@gmail.com",
"url": "https://technote.space"
},
"main": "dist/index.js",
"type": "module",
"exports": "./dist/index.mjs",
"main": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "tsc",
"cover": "jest --coverage",
"build": "tsc && rm -f dist/*.js && rollup -c",
"cover": "vitest run --coverage",
"postinstall": "[ -n \"$CI\" ] || [ ! -f node_modules/.bin/husky ] || husky install",
"lint": "eslint 'src/**/*.ts' '__tests__/**/*.ts' --cache",
"lint:fix": "eslint --fix 'src/**/*.ts' '__tests__/**/*.ts'",
"lint": "eslint 'src/**/*.ts' --cache",
"lint:fix": "eslint --fix 'src/**/*.ts'",
"prepublishOnly": "[ -n \"$CI\" ] || [ ! -f node_modules/.bin/pinst ] || pinst --disable",
"postpublish": "[ -n \"$CI\" ] || [ ! -f node_modules/.bin/pinst ] || pinst --enable",
"test": "yarn lint && yarn cover",
"test": "yarn lint && yarn typecheck && yarn cover",
"typecheck": "tsc --noEmit",
"update": "npm_config_yes=true npx npm-check-updates -u --timeout 100000 && yarn install && yarn upgrade && yarn audit"
},
"dependencies": {
"@actions/github": "^5.0.0",
"@actions/github": "^5.0.1",
"@octokit/openapi-types": "^11.2.0",
"@technote-space/github-action-helper": "^5.2.27",
"@technote-space/github-action-log-helper": "^0.1.50"
"@technote-space/github-action-helper": "^5.3.1",
"@technote-space/github-action-log-helper": "^0.2.1"
},
"devDependencies": {
"@commitlint/cli": "^16.2.3",
"@commitlint/config-conventional": "^16.2.1",
"@octokit/types": "^6.34.0",
"@technote-space/github-action-test-helper": "^0.7.40",
"@types/jest": "^27.4.1",
"@types/node": "^17.0.21",
"@typescript-eslint/eslint-plugin": "^5.15.0",
"@typescript-eslint/parser": "^5.15.0",
"eslint": "^8.11.0",
"@rollup/plugin-typescript": "^8.3.2",
"@sindresorhus/tsconfig": "^2.0.0",
"@technote-space/github-action-test-helper": "^0.9.2",
"@types/node": "^17.0.25",
"@typescript-eslint/eslint-plugin": "^5.20.0",
"@typescript-eslint/parser": "^5.20.0",
"c8": "^7.11.0",
"eslint": "^8.13.0",
"eslint-plugin-import": "^2.26.0",
"husky": "^7.0.4",
"jest": "^27.5.1",
"jest-circus": "^27.5.1",
"lint-staged": "^12.3.7",
"lint-staged": "^12.3.8",
"nock": "^13.2.4",
"pinst": "^3.0.0",
"ts-jest": "^27.1.3",
"typescript": "^4.6.2"
"rollup": "^2.70.2",
"typescript": "^4.6.3",
"vitest": "^0.9.3"
},
"publishConfig": {
"access": "public"
Expand Down
13 changes: 13 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import pluginTypescript from '@rollup/plugin-typescript';

export default {
input: 'src/index.ts',
output: {
file: 'dist/index.mjs',
format: 'es',
},
plugins: [
pluginTypescript(),
],
external: ['@technote-space/github-action-helper'],
};
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Commit from './utils/commit';
import * as Version from './utils/version';
import * as Misc from './utils/misc';
import * as Version from './utils/version';

export { Commit, Version, Misc };
File renamed without changes.
5 changes: 3 additions & 2 deletions __tests__/utils/commit.test.ts → src/utils/commit.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/* eslint-disable no-magic-numbers */
import nock from 'nock';
import { resolve } from 'path';
import {
generateContext,
disableNetConnect,
getApiFixture,
getOctokit,
} from '@technote-space/github-action-test-helper';
import { getCommits } from '../../src/utils/commit';
import nock from 'nock';
import { describe, expect, it } from 'vitest';
import { getCommits } from './commit';

const fixtureRootDir = resolve(__dirname, '..', 'fixtures');
const octokit = getOctokit();
Expand Down
18 changes: 9 additions & 9 deletions src/utils/commit.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { Context } from '@actions/github/lib/context';
import { Octokit } from '@technote-space/github-action-helper/dist/types';
import { ensureNotNull } from '@technote-space/github-action-helper/dist/utils';
import { components } from '@octokit/openapi-types';
import { parseCommitMessage } from './misc';
import { Commit, ParentCommitMessage } from '../types';
import type { Commit, ParentCommitMessage } from '../types';
import type { Context } from '@actions/github/lib/context';
import type { components } from '@octokit/openapi-types';
import type { Types } from '@technote-space/github-action-helper';
import { Utils } from '@technote-space/github-action-helper';
import { MERGE_MESSAGE_PATTERN } from '../constant';
import { parseCommitMessage } from './misc';

type PullsListCommitsResponseData = components['schemas']['commit'];

const listCommits = async(octokit: Octokit, context: Context): Promise<Array<PullsListCommitsResponseData>> => (octokit.paginate)(
const listCommits = async(octokit: Types.Octokit, context: Context): Promise<Array<PullsListCommitsResponseData>> => (octokit.paginate)(
octokit.rest.pulls.listCommits,
{
...context.repo,
'pull_number': context.payload.number,
},
);

export const getCommits = async(types: Array<string>, excludeMessages: Array<string>, breakingChangeNotes: Array<string>, octokit: Octokit, context: Context): Promise<Array<Commit>> =>
export const getCommits = async(types: Array<string>, excludeMessages: Array<string>, breakingChangeNotes: Array<string>, octokit: Types.Octokit, context: Context): Promise<Array<Commit>> =>
(await listCommits(octokit, context))
.filter(commit => !MERGE_MESSAGE_PATTERN.test(commit.commit.message))
.map(commit => ({commit, message: parseCommitMessage(commit.commit.message, types, excludeMessages, breakingChangeNotes)}))
.filter(item => item.message)
.map(item => ({
sha: ensureNotNull(item.commit.sha),
sha: Utils.ensureNotNull(item.commit.sha),
...(item.message as ParentCommitMessage),
}));

3 changes: 2 additions & 1 deletion __tests__/utils/misc.test.ts → src/utils/misc.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { parseLine, parseCommitMessage } from '../../src/utils/misc';
import { describe, expect, it } from 'vitest';
import { parseLine, parseCommitMessage } from './misc';

describe('parseLine', () => {
it('should return empty', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/misc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Logger } from '@technote-space/github-action-log-helper';
import { ParentCommitMessage, ChildCommitMessage } from '../types';
import type { ParentCommitMessage, ChildCommitMessage } from '../types';
import type { Logger } from '@technote-space/github-action-log-helper';
import { SEMANTIC_MESSAGE_PATTERN } from '../constant';

export const parseLine = (message: string): ChildCommitMessage | undefined => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable no-magic-numbers */
import { resolve } from 'path';
import { ApiHelper } from '@technote-space/github-action-helper';
import { Logger } from '@technote-space/github-action-log-helper';
import nock from 'nock';
import { resolve } from 'path';
import {
generateContext,
disableNetConnect,
Expand All @@ -12,7 +11,9 @@ import {
stdoutCalledWith,
getLogStdout,
} from '@technote-space/github-action-test-helper';
import { getCurrentVersion, whatBump, getNextVersionLevel, getNextVersion } from '../../src/utils/version';
import nock from 'nock';
import { describe, expect, it } from 'vitest';
import { getCurrentVersion, whatBump, getNextVersionLevel, getNextVersion } from './version';

const fixtureRootDir = resolve(__dirname, '..', 'fixtures');
const octokit = getOctokit();
Expand Down
14 changes: 7 additions & 7 deletions src/utils/version.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Context } from '@actions/github/lib/context';
import { Utils, ApiHelper } from '@technote-space/github-action-helper';
import { Logger } from '@technote-space/github-action-log-helper';
import { Octokit } from '@technote-space/github-action-helper/dist/types';
import type { Commit } from '../types';
import type { Context } from '@actions/github/lib/context';
import type { ApiHelper, Types } from '@technote-space/github-action-helper';
import type { Logger } from '@technote-space/github-action-log-helper';
import { Utils } from '@technote-space/github-action-helper';
import { VERSION_BUMP } from '../constant';
import { getCommits } from './commit';
import { log } from './misc';
import { Commit } from '../types';
import { VERSION_BUMP } from '../constant';

export const getCurrentVersion = async(helper: ApiHelper): Promise<string> => helper.getLastTag();

Expand All @@ -23,7 +23,7 @@ export const whatBump = (minorUpdateCommitTypes: Array<string>, commits: Array<P

export const getNextVersionLevel = (minorUpdateCommitTypes: Array<string>, commits: Array<Pick<Commit, 'notes' | 'type'>>): number => VERSION_BUMP[whatBump(minorUpdateCommitTypes, commits)];

export const getNextVersion = async(minorUpdateCommitTypes: Array<string>, excludeMessages: Array<string>, breakingChangeNotes: Array<string>, helper: ApiHelper, octokit: Octokit, context: Context, logger?: Logger): Promise<string> => {
export const getNextVersion = async(minorUpdateCommitTypes: Array<string>, excludeMessages: Array<string>, breakingChangeNotes: Array<string>, helper: ApiHelper, octokit: Types.Octokit, context: Context, logger?: Logger): Promise<string> => {
const commits = await getCommits(minorUpdateCommitTypes, excludeMessages, breakingChangeNotes, octokit, context);
log(logger => logger.startProcess('Target commits:'), logger);
log(() => console.log(
Expand Down
Loading