skuba 3.15.2 → 3.16.2
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/lib/api/github/checkRun.d.ts +22 -0
- package/lib/api/github/checkRun.js +111 -0
- package/lib/api/github/checkRun.js.map +1 -0
- package/lib/api/github/environment.d.ts +3 -0
- package/lib/api/github/environment.js +21 -0
- package/lib/api/github/environment.js.map +1 -0
- package/lib/api/github/index.d.ts +2 -0
- package/lib/api/github/index.js +6 -0
- package/lib/api/github/index.js.map +1 -0
- package/lib/cli/adapter/eslint.d.ts +7 -0
- package/lib/cli/adapter/eslint.js +21 -9
- package/lib/cli/adapter/eslint.js.map +1 -1
- package/lib/cli/adapter/prettier.d.ts +21 -0
- package/lib/cli/adapter/prettier.js +49 -17
- package/lib/cli/adapter/prettier.js.map +1 -1
- package/lib/cli/configure/refreshIgnoreFiles.d.ts +2 -0
- package/lib/cli/configure/refreshIgnoreFiles.js +55 -0
- package/lib/cli/configure/refreshIgnoreFiles.js.map +1 -0
- package/lib/cli/format.js +2 -0
- package/lib/cli/format.js.map +1 -1
- package/lib/cli/init/getConfig.d.ts +1 -1
- package/lib/cli/lint/annotate/buildkite/eslint.d.ts +2 -0
- package/lib/cli/lint/annotate/buildkite/eslint.js +26 -0
- package/lib/cli/lint/annotate/buildkite/eslint.js.map +1 -0
- package/lib/cli/lint/annotate/buildkite/index.d.ts +4 -0
- package/lib/cli/lint/annotate/buildkite/index.js +53 -0
- package/lib/cli/lint/annotate/buildkite/index.js.map +1 -0
- package/lib/cli/lint/annotate/buildkite/prettier.d.ts +2 -0
- package/lib/cli/lint/annotate/buildkite/prettier.js +33 -0
- package/lib/cli/lint/annotate/buildkite/prettier.js.map +1 -0
- package/lib/cli/lint/annotate/buildkite/tsc.d.ts +2 -0
- package/lib/cli/lint/annotate/buildkite/tsc.js +37 -0
- package/lib/cli/lint/annotate/buildkite/tsc.js.map +1 -0
- package/lib/cli/lint/annotate/github/eslint.d.ts +3 -0
- package/lib/cli/lint/annotate/github/eslint.js +13 -0
- package/lib/cli/lint/annotate/github/eslint.js.map +1 -0
- package/lib/cli/lint/annotate/github/index.d.ts +4 -0
- package/lib/cli/lint/annotate/github/index.js +61 -0
- package/lib/cli/lint/annotate/github/index.js.map +1 -0
- package/lib/cli/lint/annotate/github/prettier.d.ts +3 -0
- package/lib/cli/lint/annotate/github/prettier.js +16 -0
- package/lib/cli/lint/annotate/github/prettier.js.map +1 -0
- package/lib/cli/lint/annotate/github/tsc.d.ts +3 -0
- package/lib/cli/lint/annotate/github/tsc.js +59 -0
- package/lib/cli/lint/annotate/github/tsc.js.map +1 -0
- package/lib/cli/lint/annotate/index.d.ts +4 -0
- package/lib/cli/lint/annotate/index.js +22 -0
- package/lib/cli/lint/annotate/index.js.map +1 -0
- package/lib/cli/lint/external.d.ts +7 -0
- package/lib/cli/lint/external.js +13 -36
- package/lib/cli/lint/external.js.map +1 -1
- package/lib/cli/lint/index.js +2 -0
- package/lib/cli/lint/index.js.map +1 -1
- package/lib/cli/lint/types.d.ts +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/utils/args.d.ts +1 -1
- package/lib/utils/logging.d.ts +1 -2
- package/lib/utils/logging.js +3 -2
- package/lib/utils/logging.js.map +1 -1
- package/lib/utils/worker.d.ts +0 -1
- package/lib/wrapper/functionHandler.js +4 -1
- package/lib/wrapper/functionHandler.js.map +1 -1
- package/package.json +15 -8
- package/template/base/_.gitignore +1 -0
- package/template/base/_.prettierignore +2 -0
- package/template/express-rest-api/.buildkite/pipeline.yml +4 -4
- package/template/express-rest-api/.nvmrc +1 -1
- package/template/express-rest-api/Dockerfile +1 -1
- package/template/express-rest-api/Dockerfile.dev-deps +1 -1
- package/template/express-rest-api/docker-compose.yml +4 -2
- package/template/express-rest-api/package.json +5 -5
- package/template/express-rest-api/src/framework/logging.ts +2 -1
- package/template/greeter/.buildkite/pipeline.yml +1 -1
- package/template/greeter/.nvmrc +1 -1
- package/template/greeter/Dockerfile +1 -1
- package/template/greeter/docker-compose.yml +4 -2
- package/template/greeter/package.json +2 -2
- package/template/koa-rest-api/.buildkite/pipeline.yml +4 -4
- package/template/koa-rest-api/.nvmrc +1 -1
- package/template/koa-rest-api/Dockerfile +1 -1
- package/template/koa-rest-api/Dockerfile.dev-deps +1 -1
- package/template/koa-rest-api/docker-compose.yml +4 -2
- package/template/koa-rest-api/package.json +11 -11
- package/template/koa-rest-api/src/framework/logging.ts +2 -1
- package/template/lambda-sqs-worker/.buildkite/pipeline.yml +2 -2
- package/template/lambda-sqs-worker/docker-compose.yml +3 -1
- package/template/lambda-sqs-worker/package.json +9 -9
- package/template/lambda-sqs-worker/serverless.yml +1 -0
- package/template/lambda-sqs-worker/src/framework/handler.ts +2 -2
- package/template/lambda-sqs-worker/src/framework/logging.ts +2 -1
- package/template/lambda-sqs-worker-cdk/.buildkite/pipeline.yml +2 -2
- package/template/lambda-sqs-worker-cdk/docker-compose.yml +3 -1
- package/template/lambda-sqs-worker-cdk/package.json +2 -2
- package/template/oss-npm-package/.github/workflows/release.yml +2 -2
- package/template/oss-npm-package/.github/workflows/validate.yml +2 -2
- package/template/oss-npm-package/.nvmrc +1 -1
- package/template/oss-npm-package/_package.json +1 -1
- package/template/private-npm-package/.nvmrc +1 -1
- package/template/private-npm-package/_package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Endpoints } from '@octokit/types';
|
|
2
|
+
declare type Output = NonNullable<Endpoints['POST /repos/{owner}/{repo}/check-runs']['parameters']['output']>;
|
|
3
|
+
export declare type Annotation = NonNullable<Output['annotations']>[number];
|
|
4
|
+
interface CreateCheckRunParameters {
|
|
5
|
+
annotations: Annotation[];
|
|
6
|
+
conclusion: 'failure' | 'success';
|
|
7
|
+
name: string;
|
|
8
|
+
summary: string;
|
|
9
|
+
title: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Asynchronously creates a GitHub [check run] with annotations.
|
|
13
|
+
*
|
|
14
|
+
* The first 50 `annotations` are written in full to GitHub.
|
|
15
|
+
*
|
|
16
|
+
* A `GITHUB_API_TOKEN` or `GITHUB_TOKEN` with the `checks:write` permission
|
|
17
|
+
* must be present on the environment.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
*/
|
|
21
|
+
export declare const createCheckRun: ({ annotations, conclusion, name, summary, title, }: CreateCheckRunParameters) => Promise<void>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.createCheckRun = void 0;
|
|
16
|
+
const rest_1 = require("@octokit/rest");
|
|
17
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
18
|
+
const isomorphic_git_1 = __importDefault(require("isomorphic-git"));
|
|
19
|
+
const logging_1 = require("../../utils/logging");
|
|
20
|
+
const GITHUB_MAX_ANNOTATIONS = 50;
|
|
21
|
+
/**
|
|
22
|
+
* Matches the owner and repository names in a GitHub repository URL.
|
|
23
|
+
*
|
|
24
|
+
* For example, given the following input strings:
|
|
25
|
+
*
|
|
26
|
+
* ```console
|
|
27
|
+
* git@github.com:seek-oss/skuba.git
|
|
28
|
+
* https://github.com/seek-oss/skuba.git
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* This pattern will produce the following matches:
|
|
32
|
+
*
|
|
33
|
+
* 1. seek-oss
|
|
34
|
+
* 2. skuba
|
|
35
|
+
*/
|
|
36
|
+
const ownerRepoRegex = /github.com(?::|\/)(.+)\/(.+).git$/;
|
|
37
|
+
const getOwnerRepo = (dir) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
const remotes = yield isomorphic_git_1.default.listRemotes({ dir, fs: fs_extra_1.default });
|
|
39
|
+
for (const { url } of remotes) {
|
|
40
|
+
const match = ownerRepoRegex.exec(url);
|
|
41
|
+
const owner = match === null || match === void 0 ? void 0 : match[1];
|
|
42
|
+
const repo = match === null || match === void 0 ? void 0 : match[2];
|
|
43
|
+
if (owner && repo) {
|
|
44
|
+
return { owner, repo };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
throw new Error('Could not find a GitHub remote');
|
|
48
|
+
});
|
|
49
|
+
const getHeadSha = (dir) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
const [commit] = yield isomorphic_git_1.default.log({ depth: 1, dir, fs: fs_extra_1.default });
|
|
51
|
+
return commit.oid;
|
|
52
|
+
});
|
|
53
|
+
/**
|
|
54
|
+
* Suffixes the title with the number of annotations added, e.g.
|
|
55
|
+
*
|
|
56
|
+
* ```text
|
|
57
|
+
* Build #12 failed (24 annotations added)
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
const suffixTitle = (title, inputAnnotations) => {
|
|
61
|
+
const addedAnnotations = inputAnnotations > GITHUB_MAX_ANNOTATIONS
|
|
62
|
+
? GITHUB_MAX_ANNOTATIONS
|
|
63
|
+
: inputAnnotations;
|
|
64
|
+
return `${title} (${(0, logging_1.pluralise)(addedAnnotations, 'annotation')} added)`;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Enriches the summary with more context about the check run.
|
|
68
|
+
*/
|
|
69
|
+
const createEnrichedSummary = (summary, inputAnnotations) => [
|
|
70
|
+
summary,
|
|
71
|
+
...(inputAnnotations > GITHUB_MAX_ANNOTATIONS
|
|
72
|
+
? [
|
|
73
|
+
`${inputAnnotations} annotations were provided, but only the first ${GITHUB_MAX_ANNOTATIONS} are visible in GitHub.`,
|
|
74
|
+
]
|
|
75
|
+
: []),
|
|
76
|
+
].join('\n\n');
|
|
77
|
+
/**
|
|
78
|
+
* Asynchronously creates a GitHub [check run] with annotations.
|
|
79
|
+
*
|
|
80
|
+
* The first 50 `annotations` are written in full to GitHub.
|
|
81
|
+
*
|
|
82
|
+
* A `GITHUB_API_TOKEN` or `GITHUB_TOKEN` with the `checks:write` permission
|
|
83
|
+
* must be present on the environment.
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
*/
|
|
87
|
+
const createCheckRun = ({ annotations, conclusion, name, summary, title, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
|
+
var _a;
|
|
89
|
+
const dir = process.cwd();
|
|
90
|
+
const [headSha, { owner, repo }] = yield Promise.all([
|
|
91
|
+
getHeadSha(dir),
|
|
92
|
+
getOwnerRepo(dir),
|
|
93
|
+
]);
|
|
94
|
+
const client = new rest_1.Octokit({
|
|
95
|
+
auth: (_a = process.env.GITHUB_API_TOKEN) !== null && _a !== void 0 ? _a : process.env.GITHUB_TOKEN,
|
|
96
|
+
});
|
|
97
|
+
yield client.checks.create({
|
|
98
|
+
conclusion,
|
|
99
|
+
head_sha: headSha,
|
|
100
|
+
name,
|
|
101
|
+
output: {
|
|
102
|
+
annotations: annotations.slice(0, GITHUB_MAX_ANNOTATIONS),
|
|
103
|
+
summary: createEnrichedSummary(summary, annotations.length),
|
|
104
|
+
title: suffixTitle(title, annotations.length),
|
|
105
|
+
},
|
|
106
|
+
owner,
|
|
107
|
+
repo,
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
exports.createCheckRun = createCheckRun;
|
|
111
|
+
//# sourceMappingURL=checkRun.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkRun.js","sourceRoot":"","sources":["../../../src/api/github/checkRun.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wCAAwC;AAExC,wDAA0B;AAC1B,oEAAiC;AAEjC,iDAAgD;AAQhD,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAElC;;;;;;;;;;;;;;GAcG;AACH,MAAM,cAAc,GAAG,mCAAmC,CAAC;AAE3D,MAAM,YAAY,GAAG,CACnB,GAAW,EAC+B,EAAE;IAC5C,MAAM,OAAO,GAAG,MAAM,wBAAG,CAAC,WAAW,CAAC,EAAE,GAAG,EAAE,EAAE,EAAF,kBAAE,EAAE,CAAC,CAAC;IAEnD,KAAK,MAAM,EAAE,GAAG,EAAE,IAAI,OAAO,EAAE;QAC7B,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEvC,MAAM,KAAK,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAG,CAAC,CAAC,CAAC;QACzB,MAAM,IAAI,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAG,CAAC,CAAC,CAAC;QAExB,IAAI,KAAK,IAAI,IAAI,EAAE;YACjB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;SACxB;KACF;IAED,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;AACpD,CAAC,CAAA,CAAC;AAEF,MAAM,UAAU,GAAG,CAAO,GAAW,EAAmB,EAAE;IACxD,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,wBAAG,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAF,kBAAE,EAAE,CAAC,CAAC;IAEtD,OAAO,MAAM,CAAC,GAAG,CAAC;AACpB,CAAC,CAAA,CAAC;AAEF;;;;;;GAMG;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E,sBAAsB,CAAC;YACzD,OAAO,EAAE,qBAAqB,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC;YAC3D,KAAK,EAAE,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC;SAC9C;QACD,KAAK;QACL,IAAI;KACL,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AA9BW,QAAA,cAAc,kBA8BzB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enabledFromEnvironment = exports.buildNameFromEnvironment = void 0;
|
|
4
|
+
const buildNameFromEnvironment = (env = process.env) => {
|
|
5
|
+
var _a;
|
|
6
|
+
if (env.BUILDKITE_BUILD_NUMBER) {
|
|
7
|
+
return `Build #${env.BUILDKITE_BUILD_NUMBER}`;
|
|
8
|
+
}
|
|
9
|
+
if (env.GITHUB_RUN_NUMBER) {
|
|
10
|
+
return `${(_a = env.GITHUB_WORKFLOW) !== null && _a !== void 0 ? _a : 'Build'} #${env.GITHUB_RUN_NUMBER}`;
|
|
11
|
+
}
|
|
12
|
+
return 'Build';
|
|
13
|
+
};
|
|
14
|
+
exports.buildNameFromEnvironment = buildNameFromEnvironment;
|
|
15
|
+
const enabledFromEnvironment = (env = process.env) =>
|
|
16
|
+
// Running in a CI environment.
|
|
17
|
+
Boolean(env.BUILDKITE || env.CI || env.GITHUB_ACTIONS) &&
|
|
18
|
+
// Has an API token at the ready.
|
|
19
|
+
Boolean(env.GITHUB_API_TOKEN || env.GITHUB_TOKEN);
|
|
20
|
+
exports.enabledFromEnvironment = enabledFromEnvironment;
|
|
21
|
+
//# sourceMappingURL=environment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../src/api/github/environment.ts"],"names":[],"mappings":";;;AAAO,MAAM,wBAAwB,GAAG,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,EAAU,EAAE;;IACpE,IAAI,GAAG,CAAC,sBAAsB,EAAE;QAC9B,OAAO,UAAU,GAAG,CAAC,sBAAsB,EAAE,CAAC;KAC/C;IAED,IAAI,GAAG,CAAC,iBAAiB,EAAE;QACzB,OAAO,GAAG,MAAA,GAAG,CAAC,eAAe,mCAAI,OAAO,KAAK,GAAG,CAAC,iBAAiB,EAAE,CAAC;KACtE;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAVW,QAAA,wBAAwB,4BAUnC;AAEK,MAAM,sBAAsB,GAAG,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,EAAW,EAAE;AACnE,+BAA+B;AAC/B,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,cAAc,CAAC;IACtD,iCAAiC;IACjC,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;AAJvC,QAAA,sBAAsB,0BAIiB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCheckRun = void 0;
|
|
4
|
+
var checkRun_1 = require("./checkRun");
|
|
5
|
+
Object.defineProperty(exports, "createCheckRun", { enumerable: true, get: function () { return checkRun_1.createCheckRun; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/github/index.ts"],"names":[],"mappings":";;;AACA,uCAA4C;AAAnC,0GAAA,cAAc,OAAA"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import { Linter } from 'eslint';
|
|
1
2
|
import { Logger } from '../../utils/logging';
|
|
3
|
+
export interface ESLintResult {
|
|
4
|
+
messages: Linter.LintMessage[];
|
|
5
|
+
filePath: string;
|
|
6
|
+
}
|
|
2
7
|
export interface ESLintOutput {
|
|
8
|
+
errors: ESLintResult[];
|
|
9
|
+
warnings: ESLintResult[];
|
|
3
10
|
ok: boolean;
|
|
4
11
|
output: string;
|
|
5
12
|
}
|
|
@@ -16,6 +16,7 @@ exports.runESLint = void 0;
|
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
17
|
const chalk_1 = __importDefault(require("chalk"));
|
|
18
18
|
const eslint_1 = require("eslint");
|
|
19
|
+
const logging_1 = require("../../utils/logging");
|
|
19
20
|
const symbolForResult = (result) => {
|
|
20
21
|
if (result.errorCount) {
|
|
21
22
|
return chalk_1.default.red('○');
|
|
@@ -25,9 +26,7 @@ const symbolForResult = (result) => {
|
|
|
25
26
|
const runESLint = (mode, logger) => __awaiter(void 0, void 0, void 0, function* () {
|
|
26
27
|
logger.debug('Initialising ESLint...');
|
|
27
28
|
const engine = new eslint_1.ESLint({
|
|
28
|
-
|
|
29
|
-
// everyone can apply to update their `.gitignore` files.
|
|
30
|
-
// cache: true,
|
|
29
|
+
cache: true,
|
|
31
30
|
extensions: ['js', 'ts', 'tsx'],
|
|
32
31
|
fix: mode === 'format',
|
|
33
32
|
reportUnusedDisableDirectives: 'error',
|
|
@@ -40,19 +39,32 @@ const runESLint = (mode, logger) => __awaiter(void 0, void 0, void 0, function*
|
|
|
40
39
|
engine.lintFiles('.'),
|
|
41
40
|
]);
|
|
42
41
|
const end = process.hrtime.bigint();
|
|
43
|
-
logger.plain(`Processed ${
|
|
44
|
-
|
|
42
|
+
logger.plain(`Processed ${(0, logging_1.pluralise)(results.length, 'file')} in ${logger.timing(start, end)}.`);
|
|
43
|
+
const errors = [];
|
|
44
|
+
const warnings = [];
|
|
45
45
|
for (const result of results) {
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
const relativePath = path_1.default.relative(cwd, result.filePath);
|
|
47
|
+
if (result.errorCount) {
|
|
48
|
+
errors.push({
|
|
49
|
+
filePath: relativePath,
|
|
50
|
+
messages: result.messages,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (result.warningCount) {
|
|
54
|
+
warnings.push({
|
|
55
|
+
filePath: relativePath,
|
|
56
|
+
messages: result.messages,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
logger.debug(symbolForResult(result), relativePath);
|
|
48
60
|
}
|
|
49
|
-
const ok = errors === 0;
|
|
61
|
+
const ok = errors.length === 0;
|
|
50
62
|
yield eslint_1.ESLint.outputFixes(results);
|
|
51
63
|
const output = formatter.format(results);
|
|
52
64
|
if (output) {
|
|
53
65
|
logger.plain(output);
|
|
54
66
|
}
|
|
55
|
-
return { ok, output };
|
|
67
|
+
return { ok, output, errors, warnings };
|
|
56
68
|
});
|
|
57
69
|
exports.runESLint = runESLint;
|
|
58
70
|
//# sourceMappingURL=eslint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslint.js","sourceRoot":"","sources":["../../../src/cli/adapter/eslint.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAAwB;AAExB,kDAA0B;AAC1B,
|
|
1
|
+
{"version":3,"file":"eslint.js","sourceRoot":"","sources":["../../../src/cli/adapter/eslint.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAAwB;AAExB,kDAA0B;AAC1B,mCAAwC;AAExC,iDAAwD;AAExD,MAAM,eAAe,GAAG,CAAC,MAAyB,EAAE,EAAE;IACpD,IAAI,MAAM,CAAC,UAAU,EAAE;QACrB,OAAO,eAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;KACvB;IAED,OAAO,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,eAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,eAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACpE,CAAC,CAAC;AAcK,MAAM,SAAS,GAAG,CACvB,IAAuB,EACvB,MAAc,EACS,EAAE;IACzB,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAEvC,MAAM,MAAM,GAAG,IA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AE,MAAM,CAAC,QAAQ;aAC1B,CAAC,CAAC;SACJ;QAED,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,CAAC;KACrD;IAED,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC;IAE/B,MAAM,eAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAElC,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAEzC,IAAI,MAAM,EAAE;QACV,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;KACtB;IAED,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC1C,CAAC,CAAA,CAAC;AAlEW,QAAA,SAAS,aAkEpB"}
|
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
import { Logger } from '../../utils/logging';
|
|
2
|
+
/**
|
|
3
|
+
* Infers a parser for the specified filepath.
|
|
4
|
+
*
|
|
5
|
+
* This is a cut-down version of Prettier's built-in function of the same name;
|
|
6
|
+
* ours operates purely on the `filepath` string and does not perform file I/O.
|
|
7
|
+
* Prettier's internal `getInterpreter` function can open a file to read the
|
|
8
|
+
* shebang, and its file descriptor usage can throw warnings on worker threads:
|
|
9
|
+
*
|
|
10
|
+
* ```console
|
|
11
|
+
* Warning: File descriptor 123 closed but not opened in unmanaged mode
|
|
12
|
+
* at Object.closeSync (node:fs:530:11)
|
|
13
|
+
* at Object.closeSync (node_modules/graceful-fs/graceful-fs.js:74:20)
|
|
14
|
+
* ...
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* References:
|
|
18
|
+
*
|
|
19
|
+
* - https://github.com/prettier/prettier/blob/2.4.1/src/main/options.js#L167
|
|
20
|
+
* - seek-oss/skuba#659
|
|
21
|
+
*/
|
|
22
|
+
export declare const inferParser: (filepath: string) => string | undefined;
|
|
2
23
|
interface Result {
|
|
3
24
|
count: number;
|
|
4
25
|
errored: Array<{
|
|
@@ -12,19 +12,46 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.runPrettier = void 0;
|
|
15
|
+
exports.runPrettier = exports.inferParser = void 0;
|
|
16
16
|
const path_1 = __importDefault(require("path"));
|
|
17
17
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
18
18
|
const prettier_1 = require("prettier");
|
|
19
19
|
const dir_1 = require("../../utils/dir");
|
|
20
|
+
const logging_1 = require("../../utils/logging");
|
|
20
21
|
const manifest_1 = require("../../utils/manifest");
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
let languages;
|
|
23
|
+
/**
|
|
24
|
+
* Infers a parser for the specified filepath.
|
|
25
|
+
*
|
|
26
|
+
* This is a cut-down version of Prettier's built-in function of the same name;
|
|
27
|
+
* ours operates purely on the `filepath` string and does not perform file I/O.
|
|
28
|
+
* Prettier's internal `getInterpreter` function can open a file to read the
|
|
29
|
+
* shebang, and its file descriptor usage can throw warnings on worker threads:
|
|
30
|
+
*
|
|
31
|
+
* ```console
|
|
32
|
+
* Warning: File descriptor 123 closed but not opened in unmanaged mode
|
|
33
|
+
* at Object.closeSync (node:fs:530:11)
|
|
34
|
+
* at Object.closeSync (node_modules/graceful-fs/graceful-fs.js:74:20)
|
|
35
|
+
* ...
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* References:
|
|
39
|
+
*
|
|
40
|
+
* - https://github.com/prettier/prettier/blob/2.4.1/src/main/options.js#L167
|
|
41
|
+
* - seek-oss/skuba#659
|
|
42
|
+
*/
|
|
43
|
+
const inferParser = (filepath) => {
|
|
44
|
+
const filename = path_1.default.basename(filepath).toLowerCase();
|
|
45
|
+
languages !== null && languages !== void 0 ? languages : (languages = (0, prettier_1.getSupportInfo)().languages.filter((language) => language.since));
|
|
46
|
+
const firstLanguage = languages.find((language) => {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
return ((_a = language.extensions) === null || _a === void 0 ? void 0 : _a.some((extension) => filename.endsWith(extension))) ||
|
|
49
|
+
((_b = language.filenames) === null || _b === void 0 ? void 0 : _b.some((name) => name.toLowerCase() === filename));
|
|
50
|
+
});
|
|
51
|
+
return firstLanguage === null || firstLanguage === void 0 ? void 0 : firstLanguage.parsers[0];
|
|
52
|
+
};
|
|
53
|
+
exports.inferParser = inferParser;
|
|
54
|
+
const formatOrLintFile = ({ data, filepath, options }, mode, result) => {
|
|
28
55
|
if (mode === 'lint') {
|
|
29
56
|
let ok;
|
|
30
57
|
try {
|
|
@@ -75,7 +102,7 @@ const runPrettier = (mode, logger) => __awaiter(void 0, void 0, void 0, function
|
|
|
75
102
|
// This avoids exhibiting different behaviour than a Prettier IDE integration,
|
|
76
103
|
// and the headache of conflicting `.gitignore` and `.prettierignore` rules.
|
|
77
104
|
const filepaths = yield (0, dir_1.crawlDirectory)(directory, '.prettierignore');
|
|
78
|
-
logger.debug(`Discovered ${
|
|
105
|
+
logger.debug(`Discovered ${(0, logging_1.pluralise)(filepaths.length, 'file')}.`);
|
|
79
106
|
const result = {
|
|
80
107
|
count: filepaths.length,
|
|
81
108
|
errored: [],
|
|
@@ -84,33 +111,38 @@ const runPrettier = (mode, logger) => __awaiter(void 0, void 0, void 0, function
|
|
|
84
111
|
};
|
|
85
112
|
logger.debug(mode === 'format' ? 'Formatting' : 'Linting', 'files...');
|
|
86
113
|
for (const filepath of filepaths) {
|
|
87
|
-
|
|
114
|
+
// Infer parser upfront so we can skip unsupported files.
|
|
115
|
+
const parser = (0, exports.inferParser)(filepath);
|
|
116
|
+
logger.debug(filepath);
|
|
117
|
+
logger.debug(' parser:', parser !== null && parser !== void 0 ? parser : '-');
|
|
118
|
+
if (!parser) {
|
|
119
|
+
result.unparsed.push(filepath);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const [config, data] = yield Promise.all([
|
|
88
123
|
(0, prettier_1.resolveConfig)(filepath),
|
|
89
124
|
fs_extra_1.default.promises.readFile(filepath, 'utf-8'),
|
|
90
|
-
// Infer parser upfront so we can know to ignore unsupported file types.
|
|
91
|
-
(0, prettier_1.getFileInfo)(filepath, { resolveConfig: false }),
|
|
92
125
|
]);
|
|
93
126
|
const file = {
|
|
94
127
|
data,
|
|
95
128
|
filepath,
|
|
96
129
|
options: Object.assign(Object.assign({}, config), { filepath }),
|
|
97
|
-
parser: fileInfo.inferredParser,
|
|
98
130
|
};
|
|
99
|
-
const formatted = formatOrLintFile(file,
|
|
131
|
+
const formatted = formatOrLintFile(file, mode, result);
|
|
100
132
|
if (typeof formatted === 'string') {
|
|
101
133
|
yield fs_extra_1.default.promises.writeFile(filepath, formatted);
|
|
102
134
|
}
|
|
103
135
|
}
|
|
104
136
|
const end = process.hrtime.bigint();
|
|
105
|
-
logger.plain(`Processed ${
|
|
137
|
+
logger.plain(`Processed ${(0, logging_1.pluralise)(result.count - result.unparsed.length, 'file')} in ${logger.timing(start, end)}.`);
|
|
106
138
|
if (result.touched.length) {
|
|
107
|
-
logger.plain(`Formatted ${
|
|
139
|
+
logger.plain(`Formatted ${(0, logging_1.pluralise)(result.touched.length, 'file')}:`);
|
|
108
140
|
for (const filepath of result.touched) {
|
|
109
141
|
logger.warn(filepath);
|
|
110
142
|
}
|
|
111
143
|
}
|
|
112
144
|
if (result.errored.length) {
|
|
113
|
-
logger.plain(`Flagged ${
|
|
145
|
+
logger.plain(`Flagged ${(0, logging_1.pluralise)(result.errored.length, 'file')}:`);
|
|
114
146
|
for (const { err, filepath } of result.errored) {
|
|
115
147
|
logger.warn(filepath, ...(err ? [String(err)] : []));
|
|
116
148
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prettier.js","sourceRoot":"","sources":["../../../src/cli/adapter/prettier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CAAC,EAAE,CAAC,CAAC,CAAC;SACtD;KACF;IAED,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;AACrD,CAAC,CAAA,CAAC;AA5FW,QAAA,WAAW,eA4FtB"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.tryRefreshIgnoreFiles = exports.refreshIgnoreFiles = void 0;
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
18
|
+
const logging_1 = require("../../utils/logging");
|
|
19
|
+
const template_1 = require("../../utils/template");
|
|
20
|
+
const package_1 = require("./analysis/package");
|
|
21
|
+
const project_1 = require("./analysis/project");
|
|
22
|
+
const ignoreFile_1 = require("./processing/ignoreFile");
|
|
23
|
+
const refreshIgnoreFiles = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
const manifest = yield (0, package_1.getDestinationManifest)();
|
|
25
|
+
const destinationRoot = path_1.default.dirname(manifest.path);
|
|
26
|
+
const readDestinationFile = (0, project_1.createDestinationFileReader)(destinationRoot);
|
|
27
|
+
const refreshIgnoreFile = (filename) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
|
+
const [inputFile, templateFile] = yield Promise.all([
|
|
29
|
+
readDestinationFile(filename),
|
|
30
|
+
(0, template_1.readBaseTemplateFile)(`_${filename}`),
|
|
31
|
+
]);
|
|
32
|
+
const data = inputFile
|
|
33
|
+
? (0, ignoreFile_1.mergeWithIgnoreFile)(templateFile)(inputFile)
|
|
34
|
+
: templateFile;
|
|
35
|
+
const filepath = path_1.default.join(destinationRoot, filename);
|
|
36
|
+
yield fs_extra_1.default.promises.writeFile(filepath, data);
|
|
37
|
+
});
|
|
38
|
+
yield Promise.all([
|
|
39
|
+
refreshIgnoreFile('.eslintignore'),
|
|
40
|
+
refreshIgnoreFile('.gitignore'),
|
|
41
|
+
refreshIgnoreFile('.prettierignore'),
|
|
42
|
+
]);
|
|
43
|
+
});
|
|
44
|
+
exports.refreshIgnoreFiles = refreshIgnoreFiles;
|
|
45
|
+
const tryRefreshIgnoreFiles = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
try {
|
|
47
|
+
yield (0, exports.refreshIgnoreFiles)();
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
logging_1.log.warn('Failed to refresh ignore files.');
|
|
51
|
+
logging_1.log.warn(err);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
exports.tryRefreshIgnoreFiles = tryRefreshIgnoreFiles;
|
|
55
|
+
//# sourceMappingURL=refreshIgnoreFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refreshIgnoreFiles.js","sourceRoot":"","sources":["../../../src/cli/configure/refreshIgnoreFiles.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAAwB;AAExB,wDAA0B;AAE1B,iDAA0C;AAC1C,mDAA4D;AAE5D,gDAA4D;AAC5D,gDAAiE;AACjE,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,CAAC;KACf;AACH,CAAC,CAAA,CAAC;AAPW,QAAA,qBAAqB,yBAOhC"}
|
package/lib/cli/format.js
CHANGED
|
@@ -18,7 +18,9 @@ const args_1 = require("../utils/args");
|
|
|
18
18
|
const logging_1 = require("../utils/logging");
|
|
19
19
|
const eslint_1 = require("./adapter/eslint");
|
|
20
20
|
const prettier_1 = require("./adapter/prettier");
|
|
21
|
+
const refreshIgnoreFiles_1 = require("./configure/refreshIgnoreFiles");
|
|
21
22
|
const format = (args = process.argv) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
yield (0, refreshIgnoreFiles_1.tryRefreshIgnoreFiles)();
|
|
22
24
|
const debug = (0, args_1.hasDebugFlag)(args);
|
|
23
25
|
logging_1.log.plain(chalk_1.default.magenta('ESLint'));
|
|
24
26
|
const eslint = yield (0, eslint_1.runESLint)('format', (0, logging_1.createLogger)(debug));
|
package/lib/cli/format.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/cli/format.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAE1B,wCAA6C;AAC7C,8CAAqD;AAErD,6CAA6C;AAC7C,iDAAiD;
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/cli/format.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAE1B,wCAA6C;AAC7C,8CAAqD;AAErD,6CAA6C;AAC7C,iDAAiD;AACjD,uEAAuE;AAEhE,MAAM,MAAM,GAAG,CAAO,IAAI,GAAG,OAAO,CAAC,IAAI,EAAE,EAAE;IAClD,MAAM,IAAA,0CAAqB,GAAE,CAAC;IAE9B,MAAM,KAAK,GAAG,IAAA,mBAAY,EAAC,IAAI,CAAC,CAAC;IAEjC,aAAG,CAAC,KAAK,CAAC,eAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEnC,MAAM,MAAM,GAAG,MAAM,IAAA,kBAAS,EAAC,QAAQ,EAAE,IAAA,sBAAY,EAAC,KAAK,CAAC,CAAC,CAAC;IAE9D,aAAG,CAAC,OAAO,EAAE,CAAC;IACd,aAAG,CAAC,KAAK,CAAC,eAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IAElC,MAAM,QAAQ,GAAG,MAAM,IAAA,sBAAW,EAAC,QAAQ,EAAE,IAAA,sBAAY,EAAC,KAAK,CAAC,CAAC,CAAC;IAElE,IAAI,MAAM,CAAC,EAAE,IAAI,QAAQ,CAAC,EAAE,EAAE;QAC5B,OAAO;KACR;IAED,MAAM,KAAK,GAAG;QACZ,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;QAChC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;KACrC,CAAC;IAEF,aAAG,CAAC,OAAO,EAAE,CAAC;IACd,aAAG,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,mCAAmC,CAAC,CAAC;IAE/D,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAA,CAAC;AA3BW,QAAA,MAAM,UA2BjB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
exports.createEslintAnnotations = void 0;
|
|
23
|
+
const Buildkite = __importStar(require("../../../../api/buildkite"));
|
|
24
|
+
const createEslintAnnotations = (eslint) => !eslint.ok ? ['**ESLint**', Buildkite.md.terminal(eslint.output.trim())] : [];
|
|
25
|
+
exports.createEslintAnnotations = createEslintAnnotations;
|
|
26
|
+
//# sourceMappingURL=eslint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eslint.js","sourceRoot":"","sources":["../../../../../src/cli/lint/annotate/buildkite/eslint.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,qEAAuD;AAGhD,MAAM,uBAAuB,GAAG,CAAC,MAAoB,EAAY,EAAE,CACxE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,SAAS,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AADnE,QAAA,uBAAuB,2BAC4C"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ESLintOutput } from '../../../../cli/adapter/eslint';
|
|
2
|
+
import { PrettierOutput } from '../../../../cli/adapter/prettier';
|
|
3
|
+
import { StreamInterceptor } from '../../../../cli/lint/external';
|
|
4
|
+
export declare const createBuildkiteAnnotations: (eslint: ESLintOutput, prettier: PrettierOutput, tscOk: boolean, tscOutputStream: StreamInterceptor) => Promise<void>;
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.createBuildkiteAnnotations = void 0;
|
|
32
|
+
const Buildkite = __importStar(require("../../../../api/buildkite"));
|
|
33
|
+
const eslint_1 = require("./eslint");
|
|
34
|
+
const prettier_1 = require("./prettier");
|
|
35
|
+
const tsc_1 = require("./tsc");
|
|
36
|
+
const createBuildkiteAnnotations = (eslint, prettier, tscOk, tscOutputStream) => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
+
if (eslint.ok && prettier.ok && tscOk) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const buildkiteOutput = [
|
|
41
|
+
'`skuba lint` found issues that require triage:',
|
|
42
|
+
...(0, eslint_1.createEslintAnnotations)(eslint),
|
|
43
|
+
...(0, prettier_1.createPrettierAnnotations)(prettier),
|
|
44
|
+
...(0, tsc_1.createTscAnnotations)(tscOk, tscOutputStream),
|
|
45
|
+
].join('\n\n');
|
|
46
|
+
yield Buildkite.annotate(buildkiteOutput, {
|
|
47
|
+
context: 'skuba-lint-external',
|
|
48
|
+
scopeContextToStep: true,
|
|
49
|
+
style: 'error',
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
exports.createBuildkiteAnnotations = createBuildkiteAnnotations;
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/cli/lint/annotate/buildkite/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qEAAuD;AAKvD,qCAAmD;AACnD,yCAAuD;AACvD,+BAA6C;AAEtC,MAAM,0BAA0B,GAAG,CACxC,MAAoB,EACpB,QAAwB,EACxB,KAAc,EACd,eAAkC,EACnB,EAAE;IACjB,IAAI,MAAM,CAAC,EAAE,IAAI,QAAQ,CAAC,EAAE,IAAI,KAAK,EAAE;QACrC,OAAO;KACR;IAED,MAAM,eAAe,GAAW;QAC9B,gDAAgD;QAChD,GAAG,IAAA,gCAAuB,EAAC,MAAM,CAAC;QAClC,GAAG,IAAA,oCAAyB,EAAC,QAAQ,CAAC;QACtC,GAAG,IAAA,0BAAoB,EAAC,KAAK,EAAE,eAAe,CAAC;KAChD,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEf,MAAM,SAAS,CAAC,QAAQ,CAAC,eAAe,EAAE;QACxC,OAAO,EAAE,qBAAqB;QAC9B,kBAAkB,EAAE,IAAI;QACxB,KAAK,EAAE,OAAO;KACf,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAtBW,QAAA,0BAA0B,8BAsBrC"}
|