Skip to content

Commit 84643e2

Browse files
Merge pull request #246 from technote-space/release/v1.1.7
Release/v1.1.7
2 parents 347128d + 6a8391b commit 84643e2

File tree

4 files changed

+84
-18
lines changed

4 files changed

+84
-18
lines changed

__tests__/context-helper.test.ts

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {
77
import { testEnv, getContext } from '@technote-space/github-action-test-helper';
88
import { Logger, ContextHelper } from '../src';
99

10-
const {isRelease, isPush, isPr, isIssue, isCron, isCustomEvent, isCreateTag, getGitUrl, getRepository, getTagName, getSender, showActionInfo} = ContextHelper;
10+
const {isRelease, isPush, isPr, isIssue, isCron, isCustomEvent, isCreateTag} = ContextHelper;
11+
const {getGitUrl, getRepository, getTagName, getSender, removeToken, showActionInfo} = ContextHelper;
1112

1213
describe('isRelease', () => {
1314
it('should return true', () => {
@@ -221,6 +222,52 @@ describe('getSender', () => {
221222
});
222223
});
223224

225+
describe('removeToken', () => {
226+
it('should remove token', () => {
227+
expect(removeToken({})).toEqual({});
228+
expect(removeToken({
229+
test1: {
230+
token: 'test',
231+
},
232+
test2: 2,
233+
test3: {
234+
test: 3,
235+
236+
},
237+
})).toEqual({
238+
test1: {},
239+
test2: 2,
240+
test3: {
241+
test: 3,
242+
},
243+
});
244+
expect(removeToken({
245+
token: 'test',
246+
test1: {
247+
token: 'test',
248+
test2: 2,
249+
test3: 3,
250+
test4: {
251+
test5: {
252+
token: 'test',
253+
test6: 6,
254+
},
255+
},
256+
},
257+
})).toEqual({
258+
test1: {
259+
test2: 2,
260+
test3: 3,
261+
test4: {
262+
test5: {
263+
test6: 6,
264+
},
265+
},
266+
},
267+
});
268+
});
269+
});
270+
224271
describe('showActionInfo', () => {
225272
beforeEach(() => {
226273
Logger.resetForTesting();

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@technote-space/github-action-helper",
3-
"version": "1.1.6",
3+
"version": "1.1.7",
44
"description": "Helper to filter GitHub Action.",
55
"author": {
66
"name": "Technote",

src/context-helper.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,18 @@ export const getGitUrlWithToken = (context: Context, token?: string | undefined)
2929

3030
export const getGitUrl = (context: Context, accessTokenRequired = true): string => getGitUrlWithToken(context, getAccessToken(accessTokenRequired));
3131

32+
export const removeToken = (value: object): object => {
33+
Object.keys(value).forEach(key => {
34+
if (typeof value[key] === 'object') {
35+
value[key] = removeToken(value[key]);
36+
} else if ('token' === key) {
37+
delete value[key];
38+
}
39+
});
40+
41+
return value;
42+
};
43+
3244
export const showActionInfo = (rootDir: string, logger: Logger, context: Context): void => {
3345
const info = getBuildInfo(path.resolve(rootDir, 'build.json'));
3446
const tagName = getTagName(context);
@@ -64,9 +76,9 @@ export const showActionInfo = (rootDir: string, logger: Logger, context: Context
6476
logger.log('repo: %s', context.repo.repo);
6577
logger.log();
6678
logger.startProcess('Dump context');
67-
console.log(context);
79+
console.log(removeToken(context));
6880
logger.startProcess('Dump Payload');
69-
console.log(context.payload);
81+
console.log(removeToken(context.payload));
7082
logger.endProcess();
7183
logger.log(separator);
7284
logger.log();

yarn.lock

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,13 @@
354354
"@octokit/types" "^2.0.0"
355355

356356
"@octokit/endpoint@^5.5.0":
357-
version "5.5.2"
358-
resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-5.5.2.tgz#ed19d01fe85ac58bc2b774661658f9e5429b8164"
359-
integrity sha512-ICDcRA0C2vtTZZGud1nXRrBLXZqFayodXAKZfo3dkdcLNqcHsgaz3YSTupbURusYeucSVRjjG+RTcQhx6HPPcg==
357+
version "5.5.3"
358+
resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-5.5.3.tgz#0397d1baaca687a4c8454ba424a627699d97c978"
359+
integrity sha512-EzKwkwcxeegYYah5ukEeAI/gYRLv2Y9U5PpIsseGSFDk+G3RbipQGBs8GuYS1TLCtQaqoO66+aQGtITPalxsNQ==
360360
dependencies:
361361
"@octokit/types" "^2.0.0"
362362
is-plain-object "^3.0.0"
363-
universal-user-agent "^4.0.0"
363+
universal-user-agent "^5.0.0"
364364

365365
"@octokit/graphql@^4.3.1":
366366
version "4.3.1"
@@ -401,9 +401,9 @@
401401
once "^1.4.0"
402402

403403
"@octokit/request@^5.2.0", "@octokit/request@^5.3.0":
404-
version "5.3.1"
405-
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.3.1.tgz#3a1ace45e6f88b1be4749c5da963b3a3b4a2f120"
406-
integrity sha512-5/X0AL1ZgoU32fAepTfEoggFinO3rxsMLtzhlUX+RctLrusn/CApJuGFCd0v7GMFhF+8UiCsTTfsu7Fh1HnEJg==
404+
version "5.3.2"
405+
resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.3.2.tgz#1ca8b90a407772a1ee1ab758e7e0aced213b9883"
406+
integrity sha512-7NPJpg19wVQy1cs2xqXjjRq/RmtSomja/VSWnptfYwuBxLdbYh2UjhGi0Wx7B1v5Iw5GKhfFDQL7jM7SSp7K2g==
407407
dependencies:
408408
"@octokit/endpoint" "^5.5.0"
409409
"@octokit/request-error" "^1.0.1"
@@ -412,7 +412,7 @@
412412
is-plain-object "^3.0.0"
413413
node-fetch "^2.3.0"
414414
once "^1.4.0"
415-
universal-user-agent "^4.0.0"
415+
universal-user-agent "^5.0.0"
416416

417417
"@octokit/rest@^16.43.1":
418418
version "16.43.1"
@@ -437,9 +437,9 @@
437437
universal-user-agent "^4.0.0"
438438

439439
"@octokit/types@^2.0.0", "@octokit/types@^2.0.1":
440-
version "2.1.1"
441-
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-2.1.1.tgz#77e80d1b663c5f1f829e5377b728fa3c4fe5a97d"
442-
integrity sha512-89LOYH+d/vsbDX785NOfLxTW88GjNd0lWRz1DVPVsZgg9Yett5O+3MOvwo7iHgvUwbFz0mf/yPIjBkUbs4kxoQ==
440+
version "2.2.0"
441+
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-2.2.0.tgz#ddb0a90cf3e9624ae97e09d16f21f4c4a682d3be"
442+
integrity sha512-iEeW3XlkxeM/CObeoYvbUv24Oe+DldGofY+3QyeJ5XKKA6B+V94ePk14EDCarseWdMs6afKZPv3dFq8C+SY5lw==
443443
dependencies:
444444
"@types/node" ">= 8"
445445

@@ -3898,9 +3898,16 @@ union-value@^1.0.0:
38983898
set-value "^2.0.1"
38993899

39003900
universal-user-agent@^4.0.0:
3901-
version "4.0.0"
3902-
resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-4.0.0.tgz#27da2ec87e32769619f68a14996465ea1cb9df16"
3903-
integrity sha512-eM8knLpev67iBDizr/YtqkJsF3GK8gzDc6st/WKzrTuPtcsOKW/0IdL4cnMBsU69pOx0otavLWBDGTwg+dB0aA==
3901+
version "4.0.1"
3902+
resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-4.0.1.tgz#fd8d6cb773a679a709e967ef8288a31fcc03e557"
3903+
integrity sha512-LnST3ebHwVL2aNe4mejI9IQh2HfZ1RLo8Io2HugSif8ekzD1TlWpHpColOB/eh8JHMLkGH3Akqf040I+4ylNxg==
3904+
dependencies:
3905+
os-name "^3.1.0"
3906+
3907+
universal-user-agent@^5.0.0:
3908+
version "5.0.0"
3909+
resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-5.0.0.tgz#a3182aa758069bf0e79952570ca757de3579c1d9"
3910+
integrity sha512-B5TPtzZleXyPrUMKCpEHFmVhMN6EhmJYjG5PQna9s7mXeSqGTLap4OpqLl5FCEFUI3UBmllkETwKf/db66Y54Q==
39043911
dependencies:
39053912
os-name "^3.1.0"
39063913

0 commit comments

Comments
 (0)