Merge pull request #151 from actions/prettier-2.3.0

Update prettier to the latest version and re-prettify everything
This commit is contained in:
Patrick Ellis
2021-06-04 16:23:48 -04:00
committed by GitHub
6 changed files with 52 additions and 52 deletions

View File

@@ -1,32 +1,32 @@
export const context = { export const context = {
payload: { payload: {
pull_request: { pull_request: {
number: 123 number: 123,
} },
}, },
repo: { repo: {
owner: "monalisa", owner: "monalisa",
repo: "helloworld" repo: "helloworld",
} },
}; };
const mockApi = { const mockApi = {
issues: { issues: {
addLabels: jest.fn(), addLabels: jest.fn(),
removeLabel: jest.fn() removeLabel: jest.fn(),
}, },
paginate: jest.fn(), paginate: jest.fn(),
pulls: { pulls: {
get: jest.fn().mockResolvedValue({}), get: jest.fn().mockResolvedValue({}),
listFiles: { listFiles: {
endpoint: { endpoint: {
merge: jest.fn().mockReturnValue({}) merge: jest.fn().mockReturnValue({}),
} },
} },
}, },
repos: { repos: {
getContents: jest.fn() getContents: jest.fn(),
} },
}; };
export const GitHub = jest.fn().mockImplementation(() => mockApi); export const GitHub = jest.fn().mockImplementation(() => mockApi);

View File

@@ -15,7 +15,7 @@ const paginateMock = jest.spyOn(gh, "paginate");
const getPullMock = jest.spyOn(gh.pulls, "get"); const getPullMock = jest.spyOn(gh.pulls, "get");
const yamlFixtures = { const yamlFixtures = {
"only_pdfs.yml": fs.readFileSync("__tests__/fixtures/only_pdfs.yml") "only_pdfs.yml": fs.readFileSync("__tests__/fixtures/only_pdfs.yml"),
}; };
afterAll(() => jest.restoreAllMocks()); afterAll(() => jest.restoreAllMocks());
@@ -33,7 +33,7 @@ describe("run", () => {
owner: "monalisa", owner: "monalisa",
repo: "helloworld", repo: "helloworld",
issue_number: 123, issue_number: 123,
labels: ["touched-a-pdf-file"] labels: ["touched-a-pdf-file"],
}); });
}); });
@@ -51,7 +51,7 @@ describe("run", () => {
let mockInput = { let mockInput = {
"repo-token": "foo", "repo-token": "foo",
"configuration-path": "bar", "configuration-path": "bar",
"sync-labels": true "sync-labels": true,
}; };
jest jest
@@ -62,8 +62,8 @@ describe("run", () => {
mockGitHubResponseChangedFiles("foo.txt"); mockGitHubResponseChangedFiles("foo.txt");
getPullMock.mockResolvedValue(<any>{ getPullMock.mockResolvedValue(<any>{
data: { data: {
labels: [{ name: "touched-a-pdf-file" }] labels: [{ name: "touched-a-pdf-file" }],
} },
}); });
await run(); await run();
@@ -74,7 +74,7 @@ describe("run", () => {
owner: "monalisa", owner: "monalisa",
repo: "helloworld", repo: "helloworld",
issue_number: 123, issue_number: 123,
name: "touched-a-pdf-file" name: "touched-a-pdf-file",
}); });
}); });
@@ -82,7 +82,7 @@ describe("run", () => {
let mockInput = { let mockInput = {
"repo-token": "foo", "repo-token": "foo",
"configuration-path": "bar", "configuration-path": "bar",
"sync-labels": false "sync-labels": false,
}; };
jest jest
@@ -93,8 +93,8 @@ describe("run", () => {
mockGitHubResponseChangedFiles("foo.txt"); mockGitHubResponseChangedFiles("foo.txt");
getPullMock.mockResolvedValue(<any>{ getPullMock.mockResolvedValue(<any>{
data: { data: {
labels: [{ name: "touched-a-pdf-file" }] labels: [{ name: "touched-a-pdf-file" }],
} },
}); });
await run(); await run();
@@ -106,11 +106,11 @@ describe("run", () => {
function usingLabelerConfigYaml(fixtureName: keyof typeof yamlFixtures): void { function usingLabelerConfigYaml(fixtureName: keyof typeof yamlFixtures): void {
reposMock.mockResolvedValue(<any>{ reposMock.mockResolvedValue(<any>{
data: { content: yamlFixtures[fixtureName], encoding: "utf8" } data: { content: yamlFixtures[fixtureName], encoding: "utf8" },
}); });
} }
function mockGitHubResponseChangedFiles(...files: string[]): void { function mockGitHubResponseChangedFiles(...files: string[]): void {
const returnValue = files.map(f => ({ filename: f })); const returnValue = files.map((f) => ({ filename: f }));
paginateMock.mockReturnValue(<any>returnValue); paginateMock.mockReturnValue(<any>returnValue);
} }

22
dist/index.js vendored
View File

@@ -19859,7 +19859,7 @@ function run() {
const { data: pullRequest } = yield client.pulls.get({ const { data: pullRequest } = yield client.pulls.get({
owner: github.context.repo.owner, owner: github.context.repo.owner,
repo: github.context.repo.repo, repo: github.context.repo.repo,
pull_number: prNumber pull_number: prNumber,
}); });
core.debug(`fetching changed files for pr #${prNumber}`); core.debug(`fetching changed files for pr #${prNumber}`);
const changedFiles = yield getChangedFiles(client, prNumber); const changedFiles = yield getChangedFiles(client, prNumber);
@@ -19871,7 +19871,7 @@ function run() {
if (checkGlobs(changedFiles, globs)) { if (checkGlobs(changedFiles, globs)) {
labels.push(label); labels.push(label);
} }
else if (pullRequest.labels.find(l => l.name === label)) { else if (pullRequest.labels.find((l) => l.name === label)) {
labelsToRemove.push(label); labelsToRemove.push(label);
} }
} }
@@ -19901,10 +19901,10 @@ function getChangedFiles(client, prNumber) {
const listFilesOptions = client.pulls.listFiles.endpoint.merge({ const listFilesOptions = client.pulls.listFiles.endpoint.merge({
owner: github.context.repo.owner, owner: github.context.repo.owner,
repo: github.context.repo.repo, repo: github.context.repo.repo,
pull_number: prNumber pull_number: prNumber,
}); });
const listFilesResponse = yield client.paginate(listFilesOptions); const listFilesResponse = yield client.paginate(listFilesOptions);
const changedFiles = listFilesResponse.map(f => f.filename); const changedFiles = listFilesResponse.map((f) => f.filename);
core.debug("found changed files:"); core.debug("found changed files:");
for (const file of changedFiles) { for (const file of changedFiles) {
core.debug(" " + file); core.debug(" " + file);
@@ -19927,7 +19927,7 @@ function fetchContent(client, repoPath) {
owner: github.context.repo.owner, owner: github.context.repo.owner,
repo: github.context.repo.repo, repo: github.context.repo.repo,
path: repoPath, path: repoPath,
ref: github.context.sha ref: github.context.sha,
}); });
return Buffer.from(response.data.content, response.data.encoding).toString(); return Buffer.from(response.data.content, response.data.encoding).toString();
}); });
@@ -19950,7 +19950,7 @@ function getLabelGlobMapFromObject(configObject) {
function toMatchConfig(config) { function toMatchConfig(config) {
if (typeof config === "string") { if (typeof config === "string") {
return { return {
any: [config] any: [config],
}; };
} }
return config; return config;
@@ -19983,7 +19983,7 @@ function isMatch(changedFile, matchers) {
} }
// equivalent to "Array.some()" but expanded for debugging and clarity // equivalent to "Array.some()" but expanded for debugging and clarity
function checkAny(changedFiles, globs) { function checkAny(changedFiles, globs) {
const matchers = globs.map(g => new minimatch_1.Minimatch(g)); const matchers = globs.map((g) => new minimatch_1.Minimatch(g));
core.debug(` checking "any" patterns`); core.debug(` checking "any" patterns`);
for (const changedFile of changedFiles) { for (const changedFile of changedFiles) {
if (isMatch(changedFile, matchers)) { if (isMatch(changedFile, matchers)) {
@@ -19996,7 +19996,7 @@ function checkAny(changedFiles, globs) {
} }
// equivalent to "Array.every()" but expanded for debugging and clarity // equivalent to "Array.every()" but expanded for debugging and clarity
function checkAll(changedFiles, globs) { function checkAll(changedFiles, globs) {
const matchers = globs.map(g => new minimatch_1.Minimatch(g)); const matchers = globs.map((g) => new minimatch_1.Minimatch(g));
core.debug(` checking "all" patterns`); core.debug(` checking "all" patterns`);
for (const changedFile of changedFiles) { for (const changedFile of changedFiles) {
if (!isMatch(changedFile, matchers)) { if (!isMatch(changedFile, matchers)) {
@@ -20026,17 +20026,17 @@ function addLabels(client, prNumber, labels) {
owner: github.context.repo.owner, owner: github.context.repo.owner,
repo: github.context.repo.repo, repo: github.context.repo.repo,
issue_number: prNumber, issue_number: prNumber,
labels: labels labels: labels,
}); });
}); });
} }
function removeLabels(client, prNumber, labels) { function removeLabels(client, prNumber, labels) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
yield Promise.all(labels.map(label => client.issues.removeLabel({ yield Promise.all(labels.map((label) => client.issues.removeLabel({
owner: github.context.repo.owner, owner: github.context.repo.owner,
repo: github.context.repo.repo, repo: github.context.repo.repo,
issue_number: prNumber, issue_number: prNumber,
name: label name: label,
}))); })));
}); });
} }

16
package-lock.json generated
View File

@@ -23,7 +23,7 @@
"@vercel/ncc": "^0.23.0", "@vercel/ncc": "^0.23.0",
"jest": "^24.8.0", "jest": "^24.8.0",
"jest-circus": "^24.7.1", "jest-circus": "^24.7.1",
"prettier": "^1.17.1", "prettier": "^2.3.0",
"ts-jest": "^24.0.2", "ts-jest": "^24.0.2",
"typescript": "^3.5.1" "typescript": "^3.5.1"
} }
@@ -5013,15 +5013,15 @@
} }
}, },
"node_modules/prettier": { "node_modules/prettier": {
"version": "1.19.1", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.0.tgz",
"integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", "integrity": "sha512-kXtO4s0Lz/DW/IJ9QdWhAf7/NmPWQXkFr/r/WkR3vyI+0v8amTDxiaQSLzs8NBlytfLWX/7uQUMIW677yLKl4w==",
"dev": true, "dev": true,
"bin": { "bin": {
"prettier": "bin-prettier.js" "prettier": "bin-prettier.js"
}, },
"engines": { "engines": {
"node": ">=4" "node": ">=10.13.0"
} }
}, },
"node_modules/pretty-format": { "node_modules/pretty-format": {
@@ -10536,9 +10536,9 @@
"dev": true "dev": true
}, },
"prettier": { "prettier": {
"version": "1.19.1", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.0.tgz",
"integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", "integrity": "sha512-kXtO4s0Lz/DW/IJ9QdWhAf7/NmPWQXkFr/r/WkR3vyI+0v8amTDxiaQSLzs8NBlytfLWX/7uQUMIW677yLKl4w==",
"dev": true "dev": true
}, },
"pretty-format": { "pretty-format": {

View File

@@ -37,7 +37,7 @@
"@vercel/ncc": "^0.23.0", "@vercel/ncc": "^0.23.0",
"jest": "^24.8.0", "jest": "^24.8.0",
"jest-circus": "^24.7.1", "jest-circus": "^24.7.1",
"prettier": "^1.17.1", "prettier": "^2.3.0",
"ts-jest": "^24.0.2", "ts-jest": "^24.0.2",
"typescript": "^3.5.1" "typescript": "^3.5.1"
} }

View File

@@ -27,7 +27,7 @@ export async function run() {
const { data: pullRequest } = await client.pulls.get({ const { data: pullRequest } = await client.pulls.get({
owner: github.context.repo.owner, owner: github.context.repo.owner,
repo: github.context.repo.repo, repo: github.context.repo.repo,
pull_number: prNumber pull_number: prNumber,
}); });
core.debug(`fetching changed files for pr #${prNumber}`); core.debug(`fetching changed files for pr #${prNumber}`);
@@ -43,7 +43,7 @@ export async function run() {
core.debug(`processing ${label}`); core.debug(`processing ${label}`);
if (checkGlobs(changedFiles, globs)) { if (checkGlobs(changedFiles, globs)) {
labels.push(label); labels.push(label);
} else if (pullRequest.labels.find(l => l.name === label)) { } else if (pullRequest.labels.find((l) => l.name === label)) {
labelsToRemove.push(label); labelsToRemove.push(label);
} }
} }
@@ -77,11 +77,11 @@ async function getChangedFiles(
const listFilesOptions = client.pulls.listFiles.endpoint.merge({ const listFilesOptions = client.pulls.listFiles.endpoint.merge({
owner: github.context.repo.owner, owner: github.context.repo.owner,
repo: github.context.repo.repo, repo: github.context.repo.repo,
pull_number: prNumber pull_number: prNumber,
}); });
const listFilesResponse = await client.paginate(listFilesOptions); const listFilesResponse = await client.paginate(listFilesOptions);
const changedFiles = listFilesResponse.map(f => f.filename); const changedFiles = listFilesResponse.map((f) => f.filename);
core.debug("found changed files:"); core.debug("found changed files:");
for (const file of changedFiles) { for (const file of changedFiles) {
@@ -115,7 +115,7 @@ async function fetchContent(
owner: github.context.repo.owner, owner: github.context.repo.owner,
repo: github.context.repo.repo, repo: github.context.repo.repo,
path: repoPath, path: repoPath,
ref: github.context.sha ref: github.context.sha,
}); });
return Buffer.from(response.data.content, response.data.encoding).toString(); return Buffer.from(response.data.content, response.data.encoding).toString();
@@ -143,7 +143,7 @@ function getLabelGlobMapFromObject(
function toMatchConfig(config: StringOrMatchConfig): MatchConfig { function toMatchConfig(config: StringOrMatchConfig): MatchConfig {
if (typeof config === "string") { if (typeof config === "string") {
return { return {
any: [config] any: [config],
}; };
} }
@@ -184,7 +184,7 @@ function isMatch(changedFile: string, matchers: IMinimatch[]): boolean {
// equivalent to "Array.some()" but expanded for debugging and clarity // equivalent to "Array.some()" but expanded for debugging and clarity
function checkAny(changedFiles: string[], globs: string[]): boolean { function checkAny(changedFiles: string[], globs: string[]): boolean {
const matchers = globs.map(g => new Minimatch(g)); const matchers = globs.map((g) => new Minimatch(g));
core.debug(` checking "any" patterns`); core.debug(` checking "any" patterns`);
for (const changedFile of changedFiles) { for (const changedFile of changedFiles) {
if (isMatch(changedFile, matchers)) { if (isMatch(changedFile, matchers)) {
@@ -199,7 +199,7 @@ function checkAny(changedFiles: string[], globs: string[]): boolean {
// equivalent to "Array.every()" but expanded for debugging and clarity // equivalent to "Array.every()" but expanded for debugging and clarity
function checkAll(changedFiles: string[], globs: string[]): boolean { function checkAll(changedFiles: string[], globs: string[]): boolean {
const matchers = globs.map(g => new Minimatch(g)); const matchers = globs.map((g) => new Minimatch(g));
core.debug(` checking "all" patterns`); core.debug(` checking "all" patterns`);
for (const changedFile of changedFiles) { for (const changedFile of changedFiles) {
if (!isMatch(changedFile, matchers)) { if (!isMatch(changedFile, matchers)) {
@@ -237,7 +237,7 @@ async function addLabels(
owner: github.context.repo.owner, owner: github.context.repo.owner,
repo: github.context.repo.repo, repo: github.context.repo.repo,
issue_number: prNumber, issue_number: prNumber,
labels: labels labels: labels,
}); });
} }
@@ -247,12 +247,12 @@ async function removeLabels(
labels: string[] labels: string[]
) { ) {
await Promise.all( await Promise.all(
labels.map(label => labels.map((label) =>
client.issues.removeLabel({ client.issues.removeLabel({
owner: github.context.repo.owner, owner: github.context.repo.owner,
repo: github.context.repo.repo, repo: github.context.repo.repo,
issue_number: prNumber, issue_number: prNumber,
name: label name: label,
}) })
) )
); );