Skip to content

Commit 09e1b16

Browse files
Merge pull request #196 from technote-space/release/next-v2.0.45
release: v2.1.0
2 parents 37e74da + bc9a976 commit 09e1b16

18 files changed

+925
-2256
lines changed

.eslintrc

+8-42
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"plugin:@typescript-eslint/eslint-recommended"
66
],
77
"plugins": [
8-
"@typescript-eslint"
8+
"@typescript-eslint",
9+
"import"
910
],
1011
"parser": "@typescript-eslint/parser",
1112
"parserOptions": {
@@ -30,29 +31,6 @@
3031
"properties": "always"
3132
}
3233
],
33-
"require-jsdoc": [
34-
"error",
35-
{
36-
"require": {
37-
"FunctionDeclaration": true,
38-
"MethodDefinition": true,
39-
"ClassDeclaration": true
40-
}
41-
}
42-
],
43-
"valid-jsdoc": [
44-
"error",
45-
{
46-
"requireReturn": false,
47-
"preferType": {
48-
"String": "string",
49-
"Object": "object",
50-
"Number": "number",
51-
"Function": "function",
52-
"Void": "void"
53-
}
54-
}
55-
],
5634
"quotes": [
5735
"error",
5836
"single",
@@ -71,12 +49,6 @@
7149
}
7250
}
7351
],
74-
"no-magic-numbers": [
75-
"error",
76-
{
77-
"ignoreArrayIndexes": true
78-
}
79-
],
8052
"eqeqeq": "error",
8153
"block-scoped-var": "error",
8254
"complexity": [
@@ -85,7 +57,6 @@
8557
"maximum": 20
8658
}
8759
],
88-
"curly": "error",
8960
"default-case": "error",
9061
"dot-location": [
9162
"error",
@@ -102,16 +73,6 @@
10273
"after": true
10374
}
10475
],
105-
"id-length": [
106-
"error",
107-
{
108-
"min": 2,
109-
"properties": "never",
110-
"exceptions": [
111-
"$"
112-
]
113-
}
114-
],
11576
"indent": [
11677
"error",
11778
2,
@@ -144,6 +105,11 @@
144105
],
145106
"semi": [
146107
"error"
147-
]
108+
],
109+
"sort-imports": 0,
110+
"import/order": [2, {
111+
"groups": ["type", "builtin", "external", "internal", "parent", "sibling", "index", "object"],
112+
"alphabetize": { "order": "asc", "caseInsensitive": true }
113+
}]
148114
}
149115
}

jest.config.js

-13
This file was deleted.

jest.setup.ts

-3
This file was deleted.

package.json

+24-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@technote-space/github-action-config-helper",
3-
"version": "2.0.45",
3+
"version": "2.1.0",
44
"description": "Helper for GitHub Action to manage config.",
55
"keywords": [
66
"github",
@@ -20,38 +20,43 @@
2020
"email": "[email protected]",
2121
"url": "https://technote.space"
2222
},
23-
"main": "dist/index.js",
23+
"type": "module",
24+
"exports": "./dist/index.mjs",
25+
"main": "dist/index.mjs",
2426
"types": "dist/index.d.ts",
2527
"files": [
2628
"dist"
2729
],
2830
"scripts": {
29-
"build": "tsc",
30-
"cover": "jest --coverage",
31-
"lint": "eslint 'src/**/*.ts' '__tests__/**/*.ts' --cache",
32-
"lint:fix": "eslint --fix 'src/**/*.ts' '__tests__/**/*.ts'",
33-
"test": "yarn lint && yarn cover",
31+
"build": "tsc && rm -f dist/*.js && rollup -c",
32+
"cover": "vitest run --coverage",
33+
"lint": "eslint 'src/**/*.ts' --cache",
34+
"lint:fix": "eslint --fix 'src/**/*.ts'",
35+
"test": "yarn lint && yarn typecheck && yarn cover",
36+
"typecheck": "tsc --noEmit",
3437
"update": "npm_config_yes=true npx npm-check-updates -u --timeout 100000 && yarn install && yarn upgrade && yarn audit"
3538
},
3639
"dependencies": {
37-
"@actions/github": "^5.0.0",
40+
"@actions/github": "^5.0.1",
3841
"@octokit/plugin-rest-endpoint-methods": "^5.13.0",
39-
"@technote-space/github-action-helper": "^5.2.27",
42+
"@technote-space/github-action-helper": "^5.3.1",
4043
"js-yaml": "^4.1.0"
4144
},
4245
"devDependencies": {
43-
"@technote-space/github-action-test-helper": "^0.7.40",
44-
"@types/jest": "^27.4.1",
46+
"@rollup/plugin-typescript": "^8.3.2",
47+
"@sindresorhus/tsconfig": "^2.0.0",
48+
"@technote-space/github-action-test-helper": "^0.9.2",
4549
"@types/js-yaml": "^4.0.5",
46-
"@types/node": "^17.0.22",
47-
"@typescript-eslint/eslint-plugin": "^5.16.0",
48-
"@typescript-eslint/parser": "^5.16.0",
49-
"eslint": "^8.11.0",
50-
"jest": "^27.5.1",
51-
"jest-circus": "^27.5.1",
50+
"@types/node": "^17.0.25",
51+
"@typescript-eslint/eslint-plugin": "^5.20.0",
52+
"@typescript-eslint/parser": "^5.20.0",
53+
"c8": "^7.11.0",
54+
"eslint": "^8.13.0",
55+
"eslint-plugin-import": "^2.26.0",
5256
"nock": "^13.2.4",
53-
"ts-jest": "^27.1.3",
54-
"typescript": "^4.6.2"
57+
"rollup": "^2.70.2",
58+
"typescript": "^4.6.3",
59+
"vitest": "^0.9.3"
5560
},
5661
"publishConfig": {
5762
"access": "public"

rollup.config.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import pluginTypescript from '@rollup/plugin-typescript';
2+
3+
export default {
4+
input: 'src/index.ts',
5+
output: {
6+
file: 'dist/index.mjs',
7+
format: 'es',
8+
},
9+
plugins: [
10+
pluginTypescript(),
11+
],
12+
};
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/index.test.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { expect, it } from 'vitest';
2+
import { getConfig, parseConfig } from '.';
3+
4+
it('helper methods should be imported', () => {
5+
expect(getConfig).not.toBeFalsy();
6+
expect(parseConfig).not.toBeFalsy();
7+
});

src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export {getConfig} from './utils';
2-
export {parseConfig} from './misc';
1+
export { getConfig } from './utils';
2+
export { parseConfig } from './misc';

__tests__/misc.test.ts renamed to src/misc.test.ts

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/* eslint-disable no-magic-numbers */
2-
import {encodeContent, spyOnStdout, stdoutCalledWith, getLogStdout} from '@technote-space/github-action-test-helper';
3-
import {parseConfig} from '../src';
4-
import {isYaml, parseYamlConfig, parseJsonConfig} from '../src/misc';
2+
import { encodeContent, spyOnStdout, stdoutCalledWith, getLogStdout } from '@technote-space/github-action-test-helper';
3+
import { describe, expect, it } from 'vitest';
4+
import { parseConfig } from '../src';
5+
import { isYaml, parseYamlConfig, parseJsonConfig } from './misc';
56

67
describe('isYaml', () => {
78
it('should return true', () => {
@@ -20,8 +21,8 @@ describe('isYaml', () => {
2021

2122
describe('parseYamlConfig', () => {
2223
it('should parse config', async() => {
23-
expect(parseYamlConfig('a: b')).toEqual({a: 'b'});
24-
expect(parseYamlConfig('a:\n - b\n - c')).toEqual({a: ['b', 'c']});
24+
expect(parseYamlConfig('a: b')).toEqual({ a: 'b' });
25+
expect(parseYamlConfig('a:\n - b\n - c')).toEqual({ a: ['b', 'c'] });
2526
});
2627

2728
it('should return empty if empty', () => {
@@ -51,8 +52,8 @@ describe('parseYamlConfig', () => {
5152

5253
describe('parseJsonConfig', () => {
5354
it('should parse config', async() => {
54-
expect(parseJsonConfig('{"a": "b"}')).toEqual({a: 'b'});
55-
expect(parseJsonConfig('{"a": ["b", "c"]}')).toEqual({a: ['b', 'c']});
55+
expect(parseJsonConfig('{"a": "b"}')).toEqual({ a: 'b' });
56+
expect(parseJsonConfig('{"a": ["b", "c"]}')).toEqual({ a: ['b', 'c'] });
5657
});
5758

5859
it('should return empty if error', () => {
@@ -68,12 +69,12 @@ describe('parseJsonConfig', () => {
6869

6970
describe('parseConfig', () => {
7071
it('should parse yaml', async() => {
71-
expect(parseConfig(encodeContent('a: b'))).toEqual({a: 'b'});
72-
expect(parseConfig(encodeContent('a: b'), 'test.yaml')).toEqual({a: 'b'});
72+
expect(parseConfig(encodeContent('a: b'))).toEqual({ a: 'b' });
73+
expect(parseConfig(encodeContent('a: b'), 'test.yaml')).toEqual({ a: 'b' });
7374
});
7475

7576
it('should parse json', () => {
76-
expect(parseConfig(encodeContent('{"a": "b"}'), 'test.json')).toEqual({a: 'b'});
77-
expect(parseConfig(encodeContent('{"a": "b"}'), '.eslintrc')).toEqual({a: 'b'});
77+
expect(parseConfig(encodeContent('{"a": "b"}'), 'test.json')).toEqual({ a: 'b' });
78+
expect(parseConfig(encodeContent('{"a": "b"}'), '.eslintrc')).toEqual({ a: 'b' });
7879
});
7980
});

src/misc.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {load} from 'js-yaml';
1+
import { load } from 'js-yaml';
22

33
export const isYaml = (filename: string): boolean => ['yaml', 'yml'].includes(String(filename.split('.').pop()));
44

src/setup.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { setupGlobal } from '@technote-space/github-action-test-helper';
2+
3+
setupGlobal();

__tests__/utils.test.ts renamed to src/utils.test.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
/* eslint-disable no-magic-numbers */
2+
import { resolve } from 'path';
3+
import { disableNetConnect, getConfigFixture, getContext, getOctokit } from '@technote-space/github-action-test-helper';
24
import nock from 'nock';
3-
import {resolve} from 'path';
4-
import {disableNetConnect, getConfigFixture, getContext, getOctokit} from '@technote-space/github-action-test-helper';
5-
import {getConfig} from '../src';
5+
import { describe, expect, it } from 'vitest';
6+
import { getConfig } from './utils';
67

78
const fixturesDir = resolve(__dirname, 'fixtures');
89

@@ -38,7 +39,7 @@ describe('getConfig', () => {
3839
owner: 'hello',
3940
repo: 'world',
4041
},
41-
}), {ref: 'feature/change', configPath: ''});
42+
}), { ref: 'feature/change', configPath: '' });
4243

4344
expect(config).toHaveProperty('Backlog');
4445
expect(config['Backlog']).toHaveProperty('test1');
@@ -69,6 +70,6 @@ describe('getConfig', () => {
6970
owner: 'hello',
7071
repo: 'world',
7172
},
72-
}), {configPath: '.test'})).rejects.toThrow();
73+
}), { configPath: '.test' })).rejects.toThrow();
7374
});
7475
});

src/utils.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import {join} from 'path';
2-
import {Context} from '@actions/github/lib/context';
3-
import {Octokit} from '@technote-space/github-action-helper/dist/types';
4-
import {parseConfig} from './misc';
5-
import {NOT_FOUND_STATUS} from './constant';
1+
import type { Context } from '@actions/github/lib/context';
2+
import type { Octokit } from '@technote-space/github-action-helper/dist/types';
3+
import { join } from 'path';
4+
import { NOT_FOUND_STATUS } from './constant';
5+
import { parseConfig } from './misc';
66

77
// eslint-disable-next-line @typescript-eslint/no-explicit-any
88
export const getConfig = async(fileName: string, octokit: Octokit, context: Context, options: { configPath?: string; ref?: string } = {}): Promise<{ [key: string]: any } | false> | never => {
9-
const {configPath = '.github', ref} = options;
9+
const { configPath = '.github', ref } = options;
1010
try {
1111
const params: {
1212
owner: string;

0 commit comments

Comments
 (0)