backport 6.3.0-beta-2 → 6.3.0-beta-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backportRun.js +3 -2
- package/dist/options/ConfigOptions.d.ts +2 -2
- package/dist/options/cliArgs.js +16 -0
- package/dist/options/config/config.d.ts +1 -7
- package/dist/options/config/readConfigFile.d.ts +1 -7
- package/dist/options/options.d.ts +1 -7
- package/dist/options/options.test.js +3 -5
- package/dist/runSequentially.js +1 -0
- package/dist/services/github/v3/index.d.ts +1 -0
- package/dist/services/github/v3/index.js +61 -0
- package/dist/services/github/v4/apiRequestV4.js +10 -2
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.d.ts +1 -7
- package/dist/services/github/v4/getOptionsFromGithub/getOptionsFromGithub.js +7 -6
- package/dist/services/github/v4/getOptionsFromGithub/query.d.ts +15 -24
- package/dist/services/github/v4/getOptionsFromGithub/query.js +17 -25
- package/dist/services/logger.d.ts +3 -15
- package/dist/services/logger.js +10 -50
- package/dist/utils/packageVersion.d.ts +1 -1
- package/dist/utils/packageVersion.js +1 -1
- package/package.json +3 -2
- package/yarn.lock +5 -0
package/dist/backportRun.js
CHANGED
|
@@ -43,6 +43,7 @@ async function backportRun(processArgs, optionsFromModule = {}) {
|
|
|
43
43
|
options,
|
|
44
44
|
backportResponse,
|
|
45
45
|
});
|
|
46
|
+
logger_1.logger.info('backportResponse', backportResponse);
|
|
46
47
|
return backportResponse;
|
|
47
48
|
}
|
|
48
49
|
catch (e) {
|
|
@@ -70,9 +71,9 @@ async function backportRun(processArgs, optionsFromModule = {}) {
|
|
|
70
71
|
(0, logger_1.consoleLog)(chalk_1.default.italic(`For additional details see the logs: ${(0, env_1.getLogfilePath)({
|
|
71
72
|
logFilePath,
|
|
72
73
|
})}`));
|
|
73
|
-
// write to log
|
|
74
|
-
logger_1.logger.info('Unknown error:', e);
|
|
75
74
|
}
|
|
75
|
+
logger_1.logger.error('Unhandled exception', e);
|
|
76
|
+
process.exitCode = 1;
|
|
76
77
|
return backportResponse;
|
|
77
78
|
}
|
|
78
79
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import winston from 'winston';
|
|
2
2
|
export interface TargetBranchChoice {
|
|
3
3
|
name: string;
|
|
4
4
|
checked?: boolean;
|
|
@@ -7,7 +7,7 @@ export declare type TargetBranchChoiceOrString = string | TargetBranchChoice;
|
|
|
7
7
|
declare type AutoFixConflictsHandler = ({ files, directory, logger, targetBranch, }: {
|
|
8
8
|
files: string[];
|
|
9
9
|
directory: string;
|
|
10
|
-
logger: Logger;
|
|
10
|
+
logger: winston.Logger;
|
|
11
11
|
targetBranch: string;
|
|
12
12
|
}) => boolean | Promise<boolean>;
|
|
13
13
|
declare type Options = Partial<{
|
package/dist/options/cliArgs.js
CHANGED
|
@@ -210,10 +210,17 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
|
|
|
210
210
|
.option('repoOwner', {
|
|
211
211
|
description: 'Repository owner',
|
|
212
212
|
type: 'string',
|
|
213
|
+
conflicts: ['repo'],
|
|
213
214
|
})
|
|
214
215
|
.option('repoName', {
|
|
215
216
|
description: 'Repository name',
|
|
216
217
|
type: 'string',
|
|
218
|
+
conflicts: ['repo'],
|
|
219
|
+
})
|
|
220
|
+
.option('repo', {
|
|
221
|
+
description: 'Repo owner and name',
|
|
222
|
+
type: 'string',
|
|
223
|
+
conflicts: ['repoName', 'repoOwner'],
|
|
217
224
|
})
|
|
218
225
|
.option('sha', {
|
|
219
226
|
conflicts: ['pullNumber', 'prFilter'],
|
|
@@ -283,14 +290,23 @@ function getOptionsFromCliArgs(processArgs, { exitOnError = true } = {}) {
|
|
|
283
290
|
$0, _,
|
|
284
291
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
285
292
|
multiple, multipleBranches, multipleCommits, all,
|
|
293
|
+
// repoName and repoOwner
|
|
294
|
+
repo,
|
|
286
295
|
// filters
|
|
287
296
|
author, since, until,
|
|
288
297
|
// negations
|
|
289
298
|
noCherrypickRef, noFork, noStatusComment, noVerify, verify,
|
|
290
299
|
// array types (should be renamed to plural form)
|
|
291
300
|
assignee, path, reviewer, sourcePRLabel, targetBranch, targetBranchChoice, targetPRLabel, ...restOptions } = yargsInstance.parseSync();
|
|
301
|
+
const [repoOwner, repoName] = repo?.split('/') ?? [
|
|
302
|
+
restOptions.repoOwner,
|
|
303
|
+
restOptions.repoName,
|
|
304
|
+
];
|
|
292
305
|
return (0, excludeUndefined_1.excludeUndefined)({
|
|
293
306
|
...restOptions,
|
|
307
|
+
// repoName and repoOwner
|
|
308
|
+
repoOwner,
|
|
309
|
+
repoName,
|
|
294
310
|
// filters
|
|
295
311
|
author: all ? null : author,
|
|
296
312
|
dateSince: since ? new Date(since).toISOString() : undefined,
|
|
@@ -13,13 +13,7 @@ export declare function getOptionsFromConfigFiles({ optionsFromCliArgs, optionsF
|
|
|
13
13
|
autoFixConflicts?: (({ files, directory, logger, targetBranch, }: {
|
|
14
14
|
files: string[];
|
|
15
15
|
directory: string;
|
|
16
|
-
logger:
|
|
17
|
-
error: (message: string, meta?: unknown) => void;
|
|
18
|
-
warn: (message: string, meta?: unknown) => void;
|
|
19
|
-
info: (message: string, meta?: unknown) => void;
|
|
20
|
-
verbose: (message: string, meta?: unknown) => void;
|
|
21
|
-
debug: (message: string, meta?: unknown) => void;
|
|
22
|
-
};
|
|
16
|
+
logger: import("winston").Logger;
|
|
23
17
|
targetBranch: string;
|
|
24
18
|
}) => boolean | Promise<boolean>) | undefined;
|
|
25
19
|
autoMerge?: boolean | undefined;
|
|
@@ -46,13 +46,7 @@ export declare function withConfigMigrations({ upstream, labels, branches, ...co
|
|
|
46
46
|
autoFixConflicts?: (({ files, directory, logger, targetBranch, }: {
|
|
47
47
|
files: string[];
|
|
48
48
|
directory: string;
|
|
49
|
-
logger:
|
|
50
|
-
error: (message: string, meta?: unknown) => void;
|
|
51
|
-
warn: (message: string, meta?: unknown) => void;
|
|
52
|
-
info: (message: string, meta?: unknown) => void;
|
|
53
|
-
verbose: (message: string, meta?: unknown) => void;
|
|
54
|
-
debug: (message: string, meta?: unknown) => void;
|
|
55
|
-
};
|
|
49
|
+
logger: import("winston").Logger;
|
|
56
50
|
targetBranch: string;
|
|
57
51
|
}) => boolean | Promise<boolean>) | undefined;
|
|
58
52
|
backportBinary?: string | undefined;
|
|
@@ -50,13 +50,7 @@ export declare function getOptions(processArgs: string[], optionsFromModule: Con
|
|
|
50
50
|
autoFixConflicts?: (({ files, directory, logger, targetBranch, }: {
|
|
51
51
|
files: string[];
|
|
52
52
|
directory: string;
|
|
53
|
-
logger:
|
|
54
|
-
error: (message: string, meta?: unknown) => void;
|
|
55
|
-
warn: (message: string, meta?: unknown) => void;
|
|
56
|
-
info: (message: string, meta?: unknown) => void;
|
|
57
|
-
verbose: (message: string, meta?: unknown) => void;
|
|
58
|
-
debug: (message: string, meta?: unknown) => void;
|
|
59
|
-
};
|
|
53
|
+
logger: import("winston").Logger;
|
|
60
54
|
targetBranch: string;
|
|
61
55
|
}) => boolean | Promise<boolean>) | undefined;
|
|
62
56
|
backportBinary: string;
|
|
@@ -110,7 +110,7 @@ describe('getOptions', () => {
|
|
|
110
110
|
});
|
|
111
111
|
});
|
|
112
112
|
it('should ensure that "backport" branch does not exist', async () => {
|
|
113
|
-
mockGithubConfigOptions({
|
|
113
|
+
mockGithubConfigOptions({ hasBackportBranch: true });
|
|
114
114
|
await expect((0, options_1.getOptions)([], {})).rejects.toThrowError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
|
|
115
115
|
});
|
|
116
116
|
it('should merge config options and module options', async () => {
|
|
@@ -308,7 +308,7 @@ function mockProjectConfig(projectConfig) {
|
|
|
308
308
|
},
|
|
309
309
|
});
|
|
310
310
|
}
|
|
311
|
-
function mockGithubConfigOptions({ viewerLogin = 'DO_NOT_USE-sqren', defaultBranchRef = 'DO_NOT_USE-default-branch-name',
|
|
311
|
+
function mockGithubConfigOptions({ viewerLogin = 'DO_NOT_USE-sqren', defaultBranchRef = 'DO_NOT_USE-default-branch-name', hasBackportBranch, historicalMappings = [], }) {
|
|
312
312
|
return (0, nockHelpers_1.mockGqlRequest)({
|
|
313
313
|
name: 'GithubConfigOptions',
|
|
314
314
|
statusCode: 200,
|
|
@@ -318,9 +318,7 @@ function mockGithubConfigOptions({ viewerLogin = 'DO_NOT_USE-sqren', defaultBran
|
|
|
318
318
|
login: viewerLogin,
|
|
319
319
|
},
|
|
320
320
|
repository: {
|
|
321
|
-
|
|
322
|
-
parent: null,
|
|
323
|
-
ref: refName ? { name: refName } : null,
|
|
321
|
+
illegalBackportBranch: hasBackportBranch ? { id: 'foo' } : null,
|
|
324
322
|
defaultBranchRef: {
|
|
325
323
|
name: defaultBranchRef,
|
|
326
324
|
target: {
|
package/dist/runSequentially.js
CHANGED
|
@@ -32,6 +32,7 @@ async function runSequentially({ options, commits, targetBranches, }) {
|
|
|
32
32
|
error: e,
|
|
33
33
|
});
|
|
34
34
|
(0, logger_1.consoleLog)(e.message);
|
|
35
|
+
logger_1.logger.error('Could not backport commit', e);
|
|
35
36
|
}
|
|
36
37
|
});
|
|
37
38
|
// return the results for consumers to programatically read
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
const core = __importStar(require("@actions/core"));
|
|
23
|
+
const exec_1 = require("@actions/exec");
|
|
24
|
+
const github_1 = require("@actions/github");
|
|
25
|
+
const backport_1 = require("backport");
|
|
26
|
+
async function init() {
|
|
27
|
+
const { payload, repo } = github_1.context;
|
|
28
|
+
if (!payload.pull_request) {
|
|
29
|
+
throw Error('Only pull_request events are supported.');
|
|
30
|
+
}
|
|
31
|
+
const pullRequest = payload.pull_request;
|
|
32
|
+
const prAuthor = pullRequest.user.login;
|
|
33
|
+
const accessToken = core.getInput('github_token', { required: true });
|
|
34
|
+
const commitUser = core.getInput('commit_user', { required: false });
|
|
35
|
+
const commitEmail = core.getInput('commit_email', { required: false });
|
|
36
|
+
const autoMerge = core.getInput('auto_merge', { required: false }) === 'true';
|
|
37
|
+
const autoMergeMethod = core.getInput('auto_merge_method', {
|
|
38
|
+
required: false,
|
|
39
|
+
});
|
|
40
|
+
const targetPRLabels = core
|
|
41
|
+
.getInput('target_pr_labels', { required: false })
|
|
42
|
+
.split(',')
|
|
43
|
+
.map((label) => label.trim());
|
|
44
|
+
await (0, exec_1.exec)(`git config --global user.name "${commitUser}"`);
|
|
45
|
+
await (0, exec_1.exec)(`git config --global user.email "${commitEmail}"`);
|
|
46
|
+
await (0, backport_1.backportRun)({
|
|
47
|
+
repoOwner: repo.owner,
|
|
48
|
+
repoName: repo.repo,
|
|
49
|
+
accessToken,
|
|
50
|
+
ci: true,
|
|
51
|
+
pullNumber: pullRequest.number,
|
|
52
|
+
targetPRLabels: targetPRLabels,
|
|
53
|
+
assignees: [prAuthor],
|
|
54
|
+
autoMerge: autoMerge,
|
|
55
|
+
autoMergeMethod: autoMergeMethod,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
init().catch((error) => {
|
|
59
|
+
console.error('An error occurred', error);
|
|
60
|
+
core.setFailed(error.message);
|
|
61
|
+
});
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.GithubV4Exception = exports.apiRequestV4 = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const graphql_tag_1 = __importDefault(require("graphql-tag"));
|
|
8
9
|
const HandledError_1 = require("../../HandledError");
|
|
9
10
|
const logger_1 = require("../../logger");
|
|
10
11
|
async function apiRequestV4({ githubApiBaseUrlV4 = 'https://api.github.com/graphql', accessToken, query, variables, }) {
|
|
@@ -46,9 +47,11 @@ async function apiRequestV4({ githubApiBaseUrlV4 = 'https://api.github.com/graph
|
|
|
46
47
|
}
|
|
47
48
|
exports.apiRequestV4 = apiRequestV4;
|
|
48
49
|
function addDebugLogs({ githubApiBaseUrlV4, query, variables, axiosResponse, didSucceed, }) {
|
|
49
|
-
|
|
50
|
+
const gqlQueryName = getGqlQueryName(query);
|
|
51
|
+
logger_1.logger.info(`POST ${githubApiBaseUrlV4} (name:${gqlQueryName}, status: ${axiosResponse.status})`);
|
|
50
52
|
const logMethod = didSucceed ? logger_1.logger.verbose : logger_1.logger.info;
|
|
51
|
-
logMethod(
|
|
53
|
+
logMethod(`Query name ${gqlQueryName}`);
|
|
54
|
+
logMethod(`Query: ${query}`);
|
|
52
55
|
logMethod('Variables:', variables);
|
|
53
56
|
logMethod('Response headers:', axiosResponse.headers);
|
|
54
57
|
logMethod('Response data:', axiosResponse.data);
|
|
@@ -63,3 +66,8 @@ class GithubV4Exception extends Error {
|
|
|
63
66
|
}
|
|
64
67
|
}
|
|
65
68
|
exports.GithubV4Exception = GithubV4Exception;
|
|
69
|
+
function getGqlQueryName(query) {
|
|
70
|
+
const ast = (0, graphql_tag_1.default)(query);
|
|
71
|
+
//@ts-expect-error
|
|
72
|
+
return ast.definitions[0].name.value;
|
|
73
|
+
}
|
|
@@ -17,13 +17,7 @@ export declare function getOptionsFromGithub(options: {
|
|
|
17
17
|
autoFixConflicts?: (({ files, directory, logger, targetBranch, }: {
|
|
18
18
|
files: string[];
|
|
19
19
|
directory: string;
|
|
20
|
-
logger:
|
|
21
|
-
error: (message: string, meta?: unknown) => void;
|
|
22
|
-
warn: (message: string, meta?: unknown) => void;
|
|
23
|
-
info: (message: string, meta?: unknown) => void;
|
|
24
|
-
verbose: (message: string, meta?: unknown) => void;
|
|
25
|
-
debug: (message: string, meta?: unknown) => void;
|
|
26
|
-
};
|
|
20
|
+
logger: import("winston").Logger;
|
|
27
21
|
targetBranch: string;
|
|
28
22
|
}) => boolean | Promise<boolean>) | undefined;
|
|
29
23
|
autoMerge?: boolean | undefined;
|
|
@@ -32,19 +32,20 @@ async function getOptionsFromGithub(options) {
|
|
|
32
32
|
(0, throwOnInvalidAccessToken_1.throwOnInvalidAccessToken)({ error, repoName, repoOwner });
|
|
33
33
|
res = swallowErrorIfConfigFileIsMissing(error);
|
|
34
34
|
}
|
|
35
|
-
// get the original repo (not the fork)
|
|
36
|
-
const repo = res.repository.isFork ? res.repository.parent : res.repository;
|
|
37
35
|
// it is not possible to have a branch named "backport"
|
|
38
|
-
if (
|
|
36
|
+
if (res.repository.illegalBackportBranch) {
|
|
39
37
|
throw new HandledError_1.HandledError('You must delete the branch "backport" to continue. See https://github.com/sqren/backport/issues/155 for details');
|
|
40
38
|
}
|
|
41
|
-
const historicalRemoteConfigs =
|
|
39
|
+
const historicalRemoteConfigs = res.repository.defaultBranchRef.target.history.edges;
|
|
42
40
|
const latestRemoteConfig = historicalRemoteConfigs[0]?.remoteConfig;
|
|
43
41
|
const skipRemoteConfig = await getSkipRemoteConfigFile(options.cwd, options.skipRemoteConfig, latestRemoteConfig);
|
|
42
|
+
const remoteConfig = skipRemoteConfig
|
|
43
|
+
? {}
|
|
44
|
+
: parseRemoteConfig(latestRemoteConfig);
|
|
44
45
|
return {
|
|
45
46
|
authenticatedUsername: res.viewer.login,
|
|
46
|
-
sourceBranch:
|
|
47
|
-
...
|
|
47
|
+
sourceBranch: res.repository.defaultBranchRef.name,
|
|
48
|
+
...remoteConfig,
|
|
48
49
|
historicalBranchLabelMappings: skipRemoteConfig
|
|
49
50
|
? []
|
|
50
51
|
: getHistoricalBranchLabelMappings(historicalRemoteConfigs),
|
|
@@ -6,33 +6,24 @@ export declare type RemoteConfig = {
|
|
|
6
6
|
};
|
|
7
7
|
};
|
|
8
8
|
};
|
|
9
|
-
declare type Repository = {
|
|
10
|
-
ref: {
|
|
11
|
-
name: string;
|
|
12
|
-
} | null;
|
|
13
|
-
defaultBranchRef: {
|
|
14
|
-
name: string;
|
|
15
|
-
target: {
|
|
16
|
-
history: {
|
|
17
|
-
edges: Array<{
|
|
18
|
-
remoteConfig: RemoteConfig;
|
|
19
|
-
}>;
|
|
20
|
-
};
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
9
|
export interface GithubConfigOptionsResponse {
|
|
25
10
|
viewer: {
|
|
26
11
|
login: string;
|
|
27
12
|
};
|
|
28
13
|
repository: {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
14
|
+
illegalBackportBranch: {
|
|
15
|
+
id: string;
|
|
16
|
+
} | null;
|
|
17
|
+
defaultBranchRef: {
|
|
18
|
+
name: string;
|
|
19
|
+
target: {
|
|
20
|
+
history: {
|
|
21
|
+
edges: Array<{
|
|
22
|
+
remoteConfig: RemoteConfig;
|
|
23
|
+
}>;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
36
28
|
}
|
|
37
|
-
export declare const query = "\n query GithubConfigOptions($repoOwner: String!, $repoName: String!) {\n viewer {\n login\n }\n repository(owner: $repoOwner, name: $repoName) {\n
|
|
38
|
-
export {};
|
|
29
|
+
export declare const query = "\n query GithubConfigOptions($repoOwner: String!, $repoName: String!) {\n viewer {\n login\n }\n repository(owner: $repoOwner, name: $repoName) {\n # check to see if a branch named \"backport\" exists\n illegalBackportBranch: ref(qualifiedName: \"refs/heads/backport\") {\n id\n }\n defaultBranchRef {\n name\n target {\n ... on Commit {\n history(first: 20, path: \".backportrc.json\") {\n edges {\n remoteConfig: node {\n committedDate\n file(path: \".backportrc.json\") {\n ... on TreeEntry {\n object {\n ... on Blob {\n text\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n";
|
|
@@ -7,32 +7,24 @@ exports.query = `
|
|
|
7
7
|
login
|
|
8
8
|
}
|
|
9
9
|
repository(owner: $repoOwner, name: $repoName) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
...Repo
|
|
10
|
+
# check to see if a branch named "backport" exists
|
|
11
|
+
illegalBackportBranch: ref(qualifiedName: "refs/heads/backport") {
|
|
12
|
+
id
|
|
14
13
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
remoteConfig: node {
|
|
30
|
-
committedDate
|
|
31
|
-
file(path: ".backportrc.json") {
|
|
32
|
-
... on TreeEntry {
|
|
33
|
-
object {
|
|
34
|
-
... on Blob {
|
|
35
|
-
text
|
|
14
|
+
defaultBranchRef {
|
|
15
|
+
name
|
|
16
|
+
target {
|
|
17
|
+
... on Commit {
|
|
18
|
+
history(first: 20, path: ".backportrc.json") {
|
|
19
|
+
edges {
|
|
20
|
+
remoteConfig: node {
|
|
21
|
+
committedDate
|
|
22
|
+
file(path: ".backportrc.json") {
|
|
23
|
+
... on TreeEntry {
|
|
24
|
+
object {
|
|
25
|
+
... on Blob {
|
|
26
|
+
text
|
|
27
|
+
}
|
|
36
28
|
}
|
|
37
29
|
}
|
|
38
30
|
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
+
import winston from 'winston';
|
|
2
|
+
export declare let logger: winston.Logger;
|
|
1
3
|
export declare function consoleLog(message: string): void;
|
|
2
|
-
export declare type Logger = typeof logger;
|
|
3
|
-
export declare const logger: {
|
|
4
|
-
error: (message: string, meta?: unknown) => void;
|
|
5
|
-
warn: (message: string, meta?: unknown) => void;
|
|
6
|
-
info: (message: string, meta?: unknown) => void;
|
|
7
|
-
verbose: (message: string, meta?: unknown) => void;
|
|
8
|
-
debug: (message: string, meta?: unknown) => void;
|
|
9
|
-
};
|
|
10
4
|
export declare function updateLogger({ accessToken, verbose, }: {
|
|
11
5
|
accessToken: string;
|
|
12
6
|
verbose?: boolean;
|
|
@@ -15,10 +9,4 @@ export declare function initLogger({ ci, accessToken, logFilePath, }: {
|
|
|
15
9
|
ci?: boolean;
|
|
16
10
|
accessToken?: string;
|
|
17
11
|
logFilePath?: string;
|
|
18
|
-
}):
|
|
19
|
-
error: (message: string, meta?: unknown) => void;
|
|
20
|
-
warn: (message: string, meta?: unknown) => void;
|
|
21
|
-
info: (message: string, meta?: unknown) => void;
|
|
22
|
-
verbose: (message: string, meta?: unknown) => void;
|
|
23
|
-
debug: (message: string, meta?: unknown) => void;
|
|
24
|
-
};
|
|
12
|
+
}): winston.Logger;
|
package/dist/services/logger.js
CHANGED
|
@@ -18,19 +18,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.initLogger = exports.updateLogger = exports.
|
|
26
|
-
const dedent_1 = __importDefault(require("dedent"));
|
|
27
|
-
const lodash_1 = require("lodash");
|
|
28
|
-
const safe_json_stringify_1 = __importDefault(require("safe-json-stringify"));
|
|
22
|
+
exports.initLogger = exports.updateLogger = exports.consoleLog = exports.logger = void 0;
|
|
29
23
|
const winston_1 = __importStar(require("winston"));
|
|
30
24
|
const redact_1 = require("../utils/redact");
|
|
31
25
|
const env_1 = require("./env");
|
|
32
|
-
const { combine } = winston_1.format;
|
|
33
|
-
let winstonInstance;
|
|
34
26
|
// wrapper around console.log
|
|
35
27
|
function consoleLog(message) {
|
|
36
28
|
// eslint-disable-next-line no-console
|
|
@@ -38,29 +30,12 @@ function consoleLog(message) {
|
|
|
38
30
|
//process.stdout.write(message);
|
|
39
31
|
}
|
|
40
32
|
exports.consoleLog = consoleLog;
|
|
41
|
-
exports.logger = {
|
|
42
|
-
error: (message, meta) => {
|
|
43
|
-
winstonInstance.error(message, null, { meta });
|
|
44
|
-
},
|
|
45
|
-
warn: (message, meta) => {
|
|
46
|
-
winstonInstance.warn(message, null, { meta });
|
|
47
|
-
},
|
|
48
|
-
info: (message, meta) => {
|
|
49
|
-
winstonInstance.info(message, null, { meta });
|
|
50
|
-
},
|
|
51
|
-
verbose: (message, meta) => {
|
|
52
|
-
winstonInstance.verbose(message, null, { meta });
|
|
53
|
-
},
|
|
54
|
-
debug: (message, meta) => {
|
|
55
|
-
winstonInstance.debug(message, null, { meta });
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
33
|
let _accessToken;
|
|
59
34
|
function updateLogger({ accessToken, verbose, }) {
|
|
60
35
|
// set access token
|
|
61
36
|
_accessToken = accessToken;
|
|
62
37
|
// set log level
|
|
63
|
-
|
|
38
|
+
exports.logger.level = verbose ? 'debug' : 'info';
|
|
64
39
|
}
|
|
65
40
|
exports.updateLogger = updateLogger;
|
|
66
41
|
function redactAccessToken(str) {
|
|
@@ -75,39 +50,24 @@ function initLogger({ ci, accessToken, logFilePath, }) {
|
|
|
75
50
|
if (accessToken) {
|
|
76
51
|
_accessToken = accessToken;
|
|
77
52
|
}
|
|
78
|
-
|
|
53
|
+
exports.logger = winston_1.default.createLogger({
|
|
54
|
+
format: winston_1.format.combine(winston_1.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
|
|
55
|
+
// Format the metadata object
|
|
56
|
+
winston_1.format.metadata({
|
|
57
|
+
fillExcept: ['message', 'level', 'timestamp', 'label'],
|
|
58
|
+
})),
|
|
79
59
|
transports: ci
|
|
80
60
|
? [fileTransport, new winston_1.default.transports.Console()]
|
|
81
61
|
: [fileTransport],
|
|
82
62
|
});
|
|
83
|
-
// wait exiting until logs have been flushed to disk
|
|
84
|
-
winstonInstance.on('finish', () => {
|
|
85
|
-
process.exit(1);
|
|
86
|
-
});
|
|
87
63
|
return exports.logger;
|
|
88
64
|
}
|
|
89
65
|
exports.initLogger = initLogger;
|
|
90
66
|
function getFileTransport({ logFilePath }) {
|
|
91
67
|
return new winston_1.default.transports.File({
|
|
92
|
-
level: 'debug',
|
|
93
|
-
format: combine(winston_1.format.splat(), winston_1.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), winston_1.default.format.metadata({
|
|
94
|
-
fillExcept: ['message', 'level', 'timestamp', 'label'],
|
|
95
|
-
}), winston_1.format.printf((info) => {
|
|
96
|
-
// format without metadata
|
|
97
|
-
if (!info.metadata.meta) {
|
|
98
|
-
return redactAccessToken(`${info.timestamp}: ${info.message}`);
|
|
99
|
-
}
|
|
100
|
-
// format when metadata is a string
|
|
101
|
-
if ((0, lodash_1.isString)(info.metadata.meta)) {
|
|
102
|
-
return redactAccessToken(`${info.timestamp}: ${info.message}\n${(0, dedent_1.default)(info.metadata.meta)}\n`);
|
|
103
|
-
}
|
|
104
|
-
if (info.metadata.meta.stack) {
|
|
105
|
-
return redactAccessToken(`${info.timestamp}: ${info.message}\n${info.metadata.meta.stack}\n`);
|
|
106
|
-
}
|
|
107
|
-
// format when metadata is an object
|
|
108
|
-
return redactAccessToken(`${info.timestamp}: ${info.message}\n${(0, safe_json_stringify_1.default)(info.metadata.meta, null, 2)}\n`);
|
|
109
|
-
})),
|
|
110
68
|
filename: (0, env_1.getLogfilePath)({ logFilePath }),
|
|
69
|
+
level: 'debug',
|
|
70
|
+
format: winston_1.format.combine(winston_1.format.json()),
|
|
111
71
|
});
|
|
112
72
|
}
|
|
113
73
|
// log levels:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PACKAGE_VERSION = "6.2
|
|
1
|
+
export declare const PACKAGE_VERSION = "6.3.0-beta-2";
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"branches",
|
|
15
15
|
"branching"
|
|
16
16
|
],
|
|
17
|
-
"version": "6.3.0-beta-
|
|
17
|
+
"version": "6.3.0-beta-3",
|
|
18
18
|
"main": "./dist/entrypoint.module.js",
|
|
19
19
|
"types": "dist/entrypoint.module.d.ts",
|
|
20
20
|
"bin": {
|
|
@@ -66,7 +66,9 @@
|
|
|
66
66
|
"axios": "^0.25.0",
|
|
67
67
|
"dedent": "^0.7.0",
|
|
68
68
|
"del": "^6.0.0",
|
|
69
|
+
"dotenv": "^16.0.0",
|
|
69
70
|
"find-up": "^5.0.0",
|
|
71
|
+
"graphql-tag": "^2.12.6",
|
|
70
72
|
"inquirer": "^8.2.0",
|
|
71
73
|
"lodash": "^4.17.21",
|
|
72
74
|
"make-dir": "^3.1.0",
|
|
@@ -97,7 +99,6 @@
|
|
|
97
99
|
"eslint-plugin-prettier": "^4.0.0",
|
|
98
100
|
"graphql": "^16.3.0",
|
|
99
101
|
"graphql-config": "^4.1.0",
|
|
100
|
-
"graphql-tag": "^2.12.6",
|
|
101
102
|
"husky": "^7.0.4",
|
|
102
103
|
"jest": "^27.4.7",
|
|
103
104
|
"jest-snapshot-serializer-ansi": "^1.0.0",
|
package/yarn.lock
CHANGED
|
@@ -2015,6 +2015,11 @@ domexception@^2.0.1:
|
|
|
2015
2015
|
dependencies:
|
|
2016
2016
|
webidl-conversions "^5.0.0"
|
|
2017
2017
|
|
|
2018
|
+
dotenv@^16.0.0:
|
|
2019
|
+
version "16.0.0"
|
|
2020
|
+
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.0.0.tgz#c619001253be89ebb638d027b609c75c26e47411"
|
|
2021
|
+
integrity sha512-qD9WU0MPM4SWLPJy/r2Be+2WgQj8plChsyrCNQzW/0WjvcJQiKQJ9mH3ZgB3fxbUUxgc/11ZJ0Fi5KiimWGz2Q==
|
|
2022
|
+
|
|
2018
2023
|
dset@^3.1.0:
|
|
2019
2024
|
version "3.1.1"
|
|
2020
2025
|
resolved "https://registry.yarnpkg.com/dset/-/dset-3.1.1.tgz#07de5af7a8d03eab337ad1a8ba77fe17bba61a8c"
|