From 0598e8a86cb84845cceb8195eedae7652411f08e Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Fri, 10 Feb 2023 08:19:40 -0500 Subject: [PATCH 1/2] Switch to using noemit on ts and just build index.ts with ncc --- build/__tests__/action.test.d.ts.map | 2 +- build/__tests__/action.test.js | 130 ----- build/__tests__/action.test.js.map | 1 - build/action.d.ts | 1 - build/action.d.ts.map | 2 +- build/action.js | 163 ------ build/action.js.map | 1 - build/index.d.ts | 1 - build/index.d.ts.map | 2 +- build/index.js | 790 +++++++++++---------------- build/index.js.map | 1 - package.json | 2 +- tsconfig.json | 3 +- 13 files changed, 317 insertions(+), 782 deletions(-) delete mode 100644 build/__tests__/action.test.js delete mode 100644 build/__tests__/action.test.js.map delete mode 100644 build/action.js delete mode 100644 build/action.js.map delete mode 100644 build/index.js.map diff --git a/build/__tests__/action.test.d.ts.map b/build/__tests__/action.test.d.ts.map index 2b7cd0a..de27b03 100644 --- a/build/__tests__/action.test.d.ts.map +++ b/build/__tests__/action.test.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"action.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/action.test.ts"],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"action.test.d.ts","sourceRoot":"","sources":["file:///Users/nalanj/Source/action/src/__tests__/action.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/build/__tests__/action.test.js b/build/__tests__/action.test.js deleted file mode 100644 index 54fbc63..0000000 --- a/build/__tests__/action.test.js +++ /dev/null @@ -1,130 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const action_1 = require("../action"); -const exec = __importStar(require("@actions/exec")); -jest.mock("@actions/exec"); -test("invalid input", async () => { - const exitCode = await (0, action_1.runAction)("optic-token", "github-token", "true", "", "", undefined, "owner", "repo", "abc123"); - expect(exitCode).toBe(1); -}); -test("failed install", async () => { - const assertFailedInstall = mockFailedInstall(); - const exitCode = await (0, action_1.runAction)("optic-token", "github-token", "true", "push", "refs/heads/main", undefined, "owner", "repo", "abc123"); - expect(exitCode).toBe(1); - assertFailedInstall(); -}); -test("pull_request event", async () => { - const assertInstall = mockInstall(); - const assertEnsureRef = mockEnsureRef("main"); - const assertDiffAll = mockDiffAll("token", "origin/main"); - const assertGitHubComment = mockGitHubComment(); - const exitCode = await (0, action_1.runAction)("optic-token", "github-token", "true", "pull_request", "refs/pulls/1/merge", "main", "owner", "repo", "abc123"); - expect(exitCode).toBe(0); - assertInstall(); - assertEnsureRef(); - assertDiffAll(); - assertGitHubComment(); -}); -test("push event", async () => { - const assertInstall = mockInstall(); - const assertDeepen = mockDeepen(); - const assertDiffAll = mockDiffAll("optic-token", "HEAD~1"); - const exitCode = await (0, action_1.runAction)("optic-token", "github-token", "true", "push", "refs/heads/main", undefined, "owner", "repo", "abc123"); - expect(exitCode).toBe(0); - assertInstall(); - assertDeepen(); - assertDiffAll(); -}); -test("push event with standards failure and standards_fail set to true", async () => { - const assertInstall = mockInstall(); - const assertDeepen = mockDeepen(); - const assertDiffAll = mockDiffAll("optic-token", "HEAD~1", true); - const exitCode = await (0, action_1.runAction)("optic-token", "github-token", "true", "push", "refs/heads/main", undefined, "owner", "repo", "abc123"); - expect(exitCode).toBe(1); - assertInstall(); - assertDeepen(); - assertDiffAll(); -}); -test("push event with standards failure but standards_fail set to false", async () => { - const assertInstall = mockInstall(); - const assertDeepen = mockDeepen(); - const assertDiffAll = mockDiffAll("optic-token", "HEAD~1", true); - const exitCode = await (0, action_1.runAction)("optic-token", "github-token", "false", "push", "refs/heads/main", undefined, "owner", "repo", "abc123"); - expect(exitCode).toBe(0); - assertInstall(); - assertDeepen(); - assertDiffAll(); -}); -function mockInstall() { - jest.mocked(exec.exec).mockResolvedValueOnce(0); - return () => expect(jest.mocked(exec.exec)).toHaveBeenCalledWith("npm", ["install", "--location=global", "@useoptic/optic"], {}); -} -function mockFailedInstall() { - jest.mocked(exec.exec).mockRejectedValue(new Error("Something broke")); - return () => expect(jest.mocked(exec.exec)).toHaveBeenCalledWith("npm", ["install", "--location=global", "@useoptic/optic"], {}); -} -function mockEnsureRef(ref) { - jest.mocked(exec.exec).mockResolvedValueOnce(0); - return () => expect(jest.mocked(exec.exec)).toHaveBeenCalledWith("git", ["fetch", "--no-tags", "--depth=1", "origin", ref], {}); -} -function mockDeepen() { - jest.mocked(exec.exec).mockResolvedValueOnce(0); - return () => expect(jest.mocked(exec.exec)).toHaveBeenCalledWith("git", ["fetch", "--deepen=1"], {}); -} -function mockDiffAll(token, from, error = false) { - if (error) { - jest.mocked(exec.exec).mockRejectedValue(new Error("Something broke")); - } - else { - jest.mocked(exec.exec).mockResolvedValueOnce(0); - } - return () => expect(jest.mocked(exec.exec)).toHaveBeenCalledWith("optic", ["diff-all", "--compare-from", from, "--check", "--upload"], expect.objectContaining({ - env: expect.objectContaining({ OPTIC_TOKEN: "optic-token" }), - })); -} -function mockGitHubComment() { - jest.mocked(exec.exec).mockResolvedValueOnce(0); - return () => { - console.log(jest.mocked(exec.exec).mock.lastCall); - expect(jest.mocked(exec.exec)).toHaveBeenCalledWith("optic", [ - "ci", - "comment", - "--provider", - "github", - "--owner", - "owner", - "--repo", - "repo", - "--pull-request", - "1", - "--sha", - "abc123", - ], expect.objectContaining({ - env: expect.objectContaining({ GITHUB_TOKEN: "github-token" }), - })); - }; -} -//# sourceMappingURL=action.test.js.map \ No newline at end of file diff --git a/build/__tests__/action.test.js.map b/build/__tests__/action.test.js.map deleted file mode 100644 index 4ab3636..0000000 --- a/build/__tests__/action.test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"action.test.js","sourceRoot":"","sources":["../../src/__tests__/action.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sCAAsC;AACtC,oDAAsC;AAEtC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AAE3B,IAAI,CAAC,eAAe,EAAE,KAAK,IAAI,EAAE;IAC/B,MAAM,QAAQ,GAAG,MAAM,IAAA,kBAAS,EAC9B,aAAa,EACb,cAAc,EACd,MAAM,EACN,EAAE,EACF,EAAE,EACF,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,CACT,CAAC;IACF,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,gBAAgB,EAAE,KAAK,IAAI,EAAE;IAChC,MAAM,mBAAmB,GAAG,iBAAiB,EAAE,CAAC;IAEhD,MAAM,QAAQ,GAAG,MAAM,IAAA,kBAAS,EAC9B,aAAa,EACb,cAAc,EACd,MAAM,EACN,MAAM,EACN,iBAAiB,EACjB,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,CACT,CAAC;IACF,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,mBAAmB,EAAE,CAAC;AACxB,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,oBAAoB,EAAE,KAAK,IAAI,EAAE;IACpC,MAAM,aAAa,GAAG,WAAW,EAAE,CAAC;IACpC,MAAM,eAAe,GAAG,a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,CAAC,CAAC,CAAC;KACjD;IAED,OAAO,GAAG,EAAE,CACV,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,oBAAoB,CACjD,OAAO,EACP,CAAC,UAAU,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,CAAC,EAC3D,MAAM,CAAC,gBAAgB,CAAC;QACtB,GAAG,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC;KAC7D,CAAC,CACH,CAAC;AACN,CAAC;AAED,SAAS,iBAAiB;IACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAEhD,OAAO,GAAG,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAClD,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,oBAAoB,CACjD,OAAO,EACP;YACE,IAAI;YACJ,SAAS;YACT,YAAY;YACZ,QAAQ;YACR,SAAS;YACT,OAAO;YACP,QAAQ;YACR,MAAM;YACN,gBAAgB;YAChB,GAAG;YACH,OAAO;YACP,QAAQ;SACT,EACD,MAAM,CAAC,gBAAgB,CAAC;YACtB,GAAG,EAAE,MAAM,CAAC,gBAAgB,CAAC,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC;SAC/D,CAAC,CACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/build/action.d.ts b/build/action.d.ts index ef551e6..b31a93b 100644 --- a/build/action.d.ts +++ b/build/action.d.ts @@ -1,2 +1 @@ export declare function runAction(opticToken: string, githubToken: string, standardsFail: string, eventName: string | undefined, headRef: string | undefined, baseRef: string | undefined, owner: string | undefined, repo: string | undefined, sha: string | undefined): Promise; -//# sourceMappingURL=action.d.ts.map \ No newline at end of file diff --git a/build/action.d.ts.map b/build/action.d.ts.map index 21516e1..6024c0d 100644 --- a/build/action.d.ts.map +++ b/build/action.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../src/action.ts"],"names":[],"mappings":"AAqBA,wBAAsB,SAAS,CAC7B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,GAAG,EAAE,MAAM,GAAG,SAAS,GACtB,OAAO,CAAC,MAAM,CAAC,CAkEjB"} \ No newline at end of file +{"version":3,"file":"","sourceRoot":"","sources":["file:///Users/nalanj/Source/action/src/action.ts"],"names":[],"mappings":"AAqBA,wBAAsB,SAAS,CAC7B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,GAAG,EAAE,MAAM,GAAG,SAAS,GACtB,OAAO,CAAC,MAAM,CAAC,CAkEjB"} \ No newline at end of file diff --git a/build/action.js b/build/action.js deleted file mode 100644 index ead7090..0000000 --- a/build/action.js +++ /dev/null @@ -1,163 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.runAction = void 0; -const core = __importStar(require("@actions/core")); -const exec = __importStar(require("@actions/exec")); -async function execCommand(command, args, options = {}, logError = true) { - try { - await exec.exec(command, args, options); - return true; - } - catch (e) { - if (e instanceof Error && logError) { - core.error(e); - } - return false; - } -} -async function runAction(opticToken, githubToken, standardsFail, eventName, headRef, baseRef, owner, repo, sha) { - const failOnCheckError = standardsFail === "true"; - const valid = verifyInput(opticToken, eventName, owner, repo); - if (!valid) { - return 1; - } - let pr = ""; - if (eventName === "pull_request") { - const prFromRef = headRef === null || headRef === void 0 ? void 0 : headRef.split("/")[2]; - if (!prFromRef) { - core.error("Could not read PR number from ref"); - return 1; - } - pr = prFromRef; - } - const installed = await install(); - if (!installed) { - return 1; - } - let from = ""; - if (eventName === "pull_request") { - const fromBranch = baseRef || ""; - from = `origin/${fromBranch}`; - if (!(await ensureRef(fromBranch))) { - core.error(`Unable to fetch ${from}`); - return 1; - } - } - else if (eventName === "push") { - from = "HEAD~1"; - if (!(await deepen())) { - core.error("Unable to fetch HEAD~1"); - return 1; - } - } - if (from === "") { - core.error("Unable to determine base for comparison."); - return 1; - } - const comparisonRun = await diffAll(opticToken, from); - if (eventName === "pull_request") { - const commentResult = await prComment(githubToken, owner || "", repo || "", pr || "", sha || ""); - if (!commentResult) { - return 1; - } - } - if (!comparisonRun) { - return failOnCheckError ? 1 : 0; - } - return 0; -} -exports.runAction = runAction; -function verifyInput(token, eventName, owner, repo) { - if (!token) { - core.error("No token was provided. You can generate a token through our app at https://app.useoptic.com"); - return false; - } - if (eventName !== "push" && eventName !== "pull_request") { - core.error("Only 'push' and 'pull_request' events are supported."); - return false; - } - if (!owner) { - core.error("Repository owner is required but was not retreived from the environment"); - return false; - } - if (!repo) { - core.error("Repo is required but was not retreived from the environment"); - return false; - } - return true; -} -async function install() { - core.info("Installing optic"); - return execCommand("npm", [ - "install", - "--location=global", - "@useoptic/optic", - ]); -} -async function ensureRef(ref) { - if (!(await execCommand("git", [ - "fetch", - "--no-tags", - "--depth=1", - "origin", - ref, - ]))) { - return false; - } - return true; -} -async function deepen() { - if (!(await execCommand("git", ["fetch", "--deepen=1"]))) { - return false; - } - return true; -} -async function diffAll(token, from) { - core.info("Running Optic diff-all"); - return execCommand("optic", ["diff-all", "--compare-from", from, "--check", "--upload"], { - env: Object.assign(Object.assign({}, process.env), { OPTIC_TOKEN: token }), - }, false); -} -async function prComment(githubToken, owner, repo, pr, sha) { - core.info("Commenting on PR"); - return execCommand("optic", [ - "ci", - "comment", - "--provider", - "github", - "--owner", - owner, - "--repo", - repo, - "--pull-request", - pr, - "--sha", - sha, - ], { - env: Object.assign(Object.assign({}, process.env), { GITHUB_TOKEN: githubToken }), - }); -} -//# sourceMappingURL=action.js.map \ No newline at end of file diff --git a/build/action.js.map b/build/action.js.map deleted file mode 100644 index 9f4031f..0000000 --- a/build/action.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"action.js","sourceRoot":"","sources":["../src/action.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AACtC,oDAAsC;AAEtC,KAAK,UAAU,WAAW,CACxB,OAAe,EACf,IAAc,EACd,UAA4B,EAAE,EAC9B,QAAQ,GAAG,IAAI;IAEf,IAAI;QACF,MAAM,IAA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AAW;IAEX,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAE9B,OAAO,WAAW,CAChB,OAAO,EACP;QACE,IAAI;QACJ,SAAS;QACT,YAAY;QACZ,QAAQ;QACR,SAAS;QACT,KAAK;QACL,QAAQ;QACR,IAAI;QACJ,gBAAgB;QAChB,EAAE;QACF,OAAO;QACP,GAAG;KACJ,EACD;QACE,GAAG,kCACE,OAAO,CAAC,GAAG,KACd,YAAY,EAAE,WAAW,GAC1B;KACF,CACF,CAAC;AACJ,CAAC"} \ No newline at end of file diff --git a/build/index.d.ts b/build/index.d.ts index e26a57a..cb0ff5c 100644 --- a/build/index.d.ts +++ b/build/index.d.ts @@ -1,2 +1 @@ export {}; -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/build/index.d.ts.map b/build/index.d.ts.map index 535b86d..9a76c41 100644 --- a/build/index.d.ts.map +++ b/build/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""} \ No newline at end of file +{"version":3,"file":"","sourceRoot":"","sources":["file:///Users/nalanj/Source/action/src/index.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/build/index.js b/build/index.js index 080b7ea..27eb6ee 100644 --- a/build/index.js +++ b/build/index.js @@ -1,236 +1,8 @@ /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ -/***/ 667: -/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { - -/******/ (() => { // webpackBootstrap -/******/ var __webpack_modules__ = ({ - -/***/ 834: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require2_) { - -"use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.runAction = void 0; -const core = __importStar(__nccwpck_require2_(186)); -const exec = __importStar(__nccwpck_require2_(514)); -async function execCommand(command, args, options = {}, logError = true) { - try { - await exec.exec(command, args, options); - return true; - } - catch (e) { - if (e instanceof Error && logError) { - core.error(e); - } - return false; - } -} -async function runAction(opticToken, githubToken, standardsFail, eventName, headRef, baseRef, owner, repo, sha) { - const failOnCheckError = standardsFail === "true"; - const valid = verifyInput(opticToken, eventName, owner, repo); - if (!valid) { - return 1; - } - let pr = ""; - if (eventName === "pull_request") { - const prFromRef = headRef === null || headRef === void 0 ? void 0 : headRef.split("/")[2]; - if (!prFromRef) { - core.error("Could not read PR number from ref"); - return 1; - } - pr = prFromRef; - } - const installed = await install(); - if (!installed) { - return 1; - } - let from = ""; - if (eventName === "pull_request") { - const fromBranch = baseRef || ""; - from = `origin/${fromBranch}`; - if (!(await ensureRef(fromBranch))) { - core.error(`Unable to fetch ${from}`); - return 1; - } - } - else if (eventName === "push") { - from = "HEAD~1"; - if (!(await deepen())) { - core.error("Unable to fetch HEAD~1"); - return 1; - } - } - if (from === "") { - core.error("Unable to determine base for comparison."); - return 1; - } - const comparisonRun = await diffAll(opticToken, from); - if (eventName === "pull_request") { - const commentResult = await prComment(githubToken, owner || "", repo || "", pr || "", sha || ""); - if (!commentResult) { - return 1; - } - } - if (!comparisonRun) { - return failOnCheckError ? 1 : 0; - } - return 0; -} -exports.runAction = runAction; -function verifyInput(token, eventName, owner, repo) { - if (!token) { - core.error("No token was provided. You can generate a token through our app at https://app.useoptic.com"); - return false; - } - if (eventName !== "push" && eventName !== "pull_request") { - core.error("Only 'push' and 'pull_request' events are supported."); - return false; - } - if (!owner) { - core.error("Repository owner is required but was not retreived from the environment"); - return false; - } - if (!repo) { - core.error("Repo is required but was not retreived from the environment"); - return false; - } - return true; -} -async function install() { - core.info("Installing optic"); - return execCommand("npm", [ - "install", - "--location=global", - "@useoptic/optic", - ]); -} -async function ensureRef(ref) { - if (!(await execCommand("git", [ - "fetch", - "--no-tags", - "--depth=1", - "origin", - ref, - ]))) { - return false; - } - return true; -} -async function deepen() { - if (!(await execCommand("git", ["fetch", "--deepen=1"]))) { - return false; - } - return true; -} -async function diffAll(token, from) { - core.info("Running Optic diff-all"); - return execCommand("optic", ["diff-all", "--compare-from", from, "--check"], { - env: Object.assign(Object.assign({}, process.env), { OPTIC_TOKEN: token }), - }, false); -} -async function prComment(githubToken, owner, repo, pr, sha) { - core.info("Commenting on PR"); - return execCommand("optic", [ - "ci", - "comment", - "--provider", - "github", - "--owner", - owner, - "--repo", - repo, - "--pull-request", - pr, - "--sha", - sha, - ], { - env: Object.assign(Object.assign({}, process.env), { GITHUB_TOKEN: githubToken }), - }); -} -//# sourceMappingURL=action.js.map - -/***/ }), - -/***/ 667: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require2_) { - -"use strict"; - -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var _a; -Object.defineProperty(exports, "__esModule", ({ value: true })); -const core = __importStar(__nccwpck_require2_(186)); -const action_1 = __nccwpck_require2_(834); -const opticToken = core.getInput("optic_token"); -const githubToken = core.getInput("github_token"); -const standardsFail = core.getInput("standards_fail"); -const eventName = process.env.GITHUB_EVENT_NAME; -const headRef = process.env.GITHUB_REF; -const baseRef = process.env.GITHUB_BASE_REF; -const owner = process.env.GITHUB_REPOSITORY_OWNER; -const repo = (_a = process.env.GITHUB_REPOSITORY) === null || _a === void 0 ? void 0 : _a.split("/")[1]; -const sha = process.env.GITHUB_SHA; -(0, action_1.runAction)(opticToken, githubToken, standardsFail, eventName, headRef, baseRef, owner, repo, sha) - .then((exitCode) => { - return process.exit(exitCode); -}) - .catch(() => { - return process.exit(1); -}); -//# sourceMappingURL=index.js.map - -/***/ }), - /***/ 351: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require2_) { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -255,8 +27,8 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.issue = exports.issueCommand = void 0; -const os = __importStar(__nccwpck_require2_(37)); -const utils_1 = __nccwpck_require2_(278); +const os = __importStar(__nccwpck_require__(37)); +const utils_1 = __nccwpck_require__(278); /** * Commands * @@ -329,7 +101,7 @@ function escapeProperty(s) { /***/ }), /***/ 186: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require2_) { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -363,12 +135,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.getIDToken = exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0; -const command_1 = __nccwpck_require2_(351); -const file_command_1 = __nccwpck_require2_(717); -const utils_1 = __nccwpck_require2_(278); -const os = __importStar(__nccwpck_require2_(37)); -const path = __importStar(__nccwpck_require2_(17)); -const oidc_utils_1 = __nccwpck_require2_(41); +const command_1 = __nccwpck_require__(351); +const file_command_1 = __nccwpck_require__(717); +const utils_1 = __nccwpck_require__(278); +const os = __importStar(__nccwpck_require__(37)); +const path = __importStar(__nccwpck_require__(17)); +const oidc_utils_1 = __nccwpck_require__(41); /** * The code to exit an action */ @@ -653,17 +425,17 @@ exports.getIDToken = getIDToken; /** * Summary exports */ -var summary_1 = __nccwpck_require2_(327); +var summary_1 = __nccwpck_require__(327); Object.defineProperty(exports, "summary", ({ enumerable: true, get: function () { return summary_1.summary; } })); /** * @deprecated use core.summary */ -var summary_2 = __nccwpck_require2_(327); +var summary_2 = __nccwpck_require__(327); Object.defineProperty(exports, "markdownSummary", ({ enumerable: true, get: function () { return summary_2.markdownSummary; } })); /** * Path exports */ -var path_utils_1 = __nccwpck_require2_(981); +var path_utils_1 = __nccwpck_require__(981); Object.defineProperty(exports, "toPosixPath", ({ enumerable: true, get: function () { return path_utils_1.toPosixPath; } })); Object.defineProperty(exports, "toWin32Path", ({ enumerable: true, get: function () { return path_utils_1.toWin32Path; } })); Object.defineProperty(exports, "toPlatformPath", ({ enumerable: true, get: function () { return path_utils_1.toPlatformPath; } })); @@ -672,7 +444,7 @@ Object.defineProperty(exports, "toPlatformPath", ({ enumerable: true, get: funct /***/ }), /***/ 717: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require2_) { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -700,10 +472,10 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; // We use any as a valid input type /* eslint-disable @typescript-eslint/no-explicit-any */ -const fs = __importStar(__nccwpck_require2_(147)); -const os = __importStar(__nccwpck_require2_(37)); -const uuid_1 = __nccwpck_require2_(840); -const utils_1 = __nccwpck_require2_(278); +const fs = __importStar(__nccwpck_require__(147)); +const os = __importStar(__nccwpck_require__(37)); +const uuid_1 = __nccwpck_require__(840); +const utils_1 = __nccwpck_require__(278); function issueFileCommand(command, message) { const filePath = process.env[`GITHUB_${command}`]; if (!filePath) { @@ -737,7 +509,7 @@ exports.prepareKeyValueMessage = prepareKeyValueMessage; /***/ }), /***/ 41: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require2_) { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -752,9 +524,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.OidcClient = void 0; -const http_client_1 = __nccwpck_require2_(255); -const auth_1 = __nccwpck_require2_(526); -const core_1 = __nccwpck_require2_(186); +const http_client_1 = __nccwpck_require__(255); +const auth_1 = __nccwpck_require__(526); +const core_1 = __nccwpck_require__(186); class OidcClient { static createHttpClient(allowRetry = true, maxRetry = 10) { const requestOptions = { @@ -821,7 +593,7 @@ exports.OidcClient = OidcClient; /***/ }), /***/ 981: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require2_) { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -846,7 +618,7 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = void 0; -const path = __importStar(__nccwpck_require2_(17)); +const path = __importStar(__nccwpck_require__(17)); /** * toPosixPath converts the given path to the posix form. On Windows, \\ will be * replaced with /. @@ -886,7 +658,7 @@ exports.toPlatformPath = toPlatformPath; /***/ }), /***/ 327: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require2_) { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -901,8 +673,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0; -const os_1 = __nccwpck_require2_(37); -const fs_1 = __nccwpck_require2_(147); +const os_1 = __nccwpck_require__(37); +const fs_1 = __nccwpck_require__(147); const { access, appendFile, writeFile } = fs_1.promises; exports.SUMMARY_ENV_VAR = 'GITHUB_STEP_SUMMARY'; exports.SUMMARY_DOCS_URL = 'https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary'; @@ -1223,7 +995,7 @@ exports.toCommandProperties = toCommandProperties; /***/ }), /***/ 514: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require2_) { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -1257,8 +1029,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.getExecOutput = exports.exec = void 0; -const string_decoder_1 = __nccwpck_require2_(576); -const tr = __importStar(__nccwpck_require2_(159)); +const string_decoder_1 = __nccwpck_require__(576); +const tr = __importStar(__nccwpck_require__(159)); /** * Exec a command. * Output will be streamed to the live console. @@ -1333,7 +1105,7 @@ exports.getExecOutput = getExecOutput; /***/ }), /***/ 159: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require2_) { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -1367,13 +1139,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.argStringToArray = exports.ToolRunner = void 0; -const os = __importStar(__nccwpck_require2_(37)); -const events = __importStar(__nccwpck_require2_(361)); -const child = __importStar(__nccwpck_require2_(81)); -const path = __importStar(__nccwpck_require2_(17)); -const io = __importStar(__nccwpck_require2_(436)); -const ioUtil = __importStar(__nccwpck_require2_(962)); -const timers_1 = __nccwpck_require2_(512); +const os = __importStar(__nccwpck_require__(37)); +const events = __importStar(__nccwpck_require__(361)); +const child = __importStar(__nccwpck_require__(81)); +const path = __importStar(__nccwpck_require__(17)); +const io = __importStar(__nccwpck_require__(436)); +const ioUtil = __importStar(__nccwpck_require__(962)); +const timers_1 = __nccwpck_require__(512); /* eslint-disable @typescript-eslint/unbound-method */ const IS_WINDOWS = process.platform === 'win32'; /* @@ -2046,7 +1818,7 @@ exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHand /***/ }), /***/ 255: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require2_) { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -2081,10 +1853,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.HttpClient = exports.isHttps = exports.HttpClientResponse = exports.HttpClientError = exports.getProxyUrl = exports.MediaTypes = exports.Headers = exports.HttpCodes = void 0; -const http = __importStar(__nccwpck_require2_(685)); -const https = __importStar(__nccwpck_require2_(687)); -const pm = __importStar(__nccwpck_require2_(835)); -const tunnel = __importStar(__nccwpck_require2_(294)); +const http = __importStar(__nccwpck_require__(685)); +const https = __importStar(__nccwpck_require__(687)); +const pm = __importStar(__nccwpck_require__(835)); +const tunnel = __importStar(__nccwpck_require__(294)); var HttpCodes; (function (HttpCodes) { HttpCodes[HttpCodes["OK"] = 200] = "OK"; @@ -2726,7 +2498,7 @@ exports.checkBypass = checkBypass; /***/ }), /***/ 962: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require2_) { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -2761,8 +2533,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge var _a; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.getCmdPath = exports.tryGetExecutablePath = exports.isRooted = exports.isDirectory = exports.exists = exports.IS_WINDOWS = exports.unlink = exports.symlink = exports.stat = exports.rmdir = exports.rename = exports.readlink = exports.readdir = exports.mkdir = exports.lstat = exports.copyFile = exports.chmod = void 0; -const fs = __importStar(__nccwpck_require2_(147)); -const path = __importStar(__nccwpck_require2_(17)); +const fs = __importStar(__nccwpck_require__(147)); +const path = __importStar(__nccwpck_require__(17)); _a = fs.promises, exports.chmod = _a.chmod, exports.copyFile = _a.copyFile, exports.lstat = _a.lstat, exports.mkdir = _a.mkdir, exports.readdir = _a.readdir, exports.readlink = _a.readlink, exports.rename = _a.rename, exports.rmdir = _a.rmdir, exports.stat = _a.stat, exports.symlink = _a.symlink, exports.unlink = _a.unlink; exports.IS_WINDOWS = process.platform === 'win32'; function exists(fsPath) { @@ -2910,7 +2682,7 @@ exports.getCmdPath = getCmdPath; /***/ }), /***/ 436: -/***/ (function(__unused_webpack_module, exports, __nccwpck_require2_) { +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -2944,11 +2716,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.findInPath = exports.which = exports.mkdirP = exports.rmRF = exports.mv = exports.cp = void 0; -const assert_1 = __nccwpck_require2_(491); -const childProcess = __importStar(__nccwpck_require2_(81)); -const path = __importStar(__nccwpck_require2_(17)); -const util_1 = __nccwpck_require2_(837); -const ioUtil = __importStar(__nccwpck_require2_(962)); +const assert_1 = __nccwpck_require__(491); +const childProcess = __importStar(__nccwpck_require__(81)); +const path = __importStar(__nccwpck_require__(17)); +const util_1 = __nccwpck_require__(837); +const ioUtil = __importStar(__nccwpck_require__(962)); const exec = util_1.promisify(childProcess.exec); const execFile = util_1.promisify(childProcess.execFile); /** @@ -3258,26 +3030,26 @@ function copyFile(srcFile, destFile, force) { /***/ }), /***/ 294: -/***/ ((module, __unused_webpack_exports, __nccwpck_require2_) => { +/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { -module.exports = __nccwpck_require2_(219); +module.exports = __nccwpck_require__(219); /***/ }), /***/ 219: -/***/ ((__unused_webpack_module, exports, __nccwpck_require2_) => { +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; -var net = __nccwpck_require2_(808); -var tls = __nccwpck_require2_(404); -var http = __nccwpck_require2_(685); -var https = __nccwpck_require2_(687); -var events = __nccwpck_require2_(361); -var assert = __nccwpck_require2_(491); -var util = __nccwpck_require2_(837); +var net = __nccwpck_require__(808); +var tls = __nccwpck_require__(404); +var http = __nccwpck_require__(685); +var https = __nccwpck_require__(687); +var events = __nccwpck_require__(361); +var assert = __nccwpck_require__(491); +var util = __nccwpck_require__(837); exports.httpOverHttp = httpOverHttp; @@ -3538,7 +3310,7 @@ exports.debug = debug; // for test /***/ }), /***/ 840: -/***/ ((__unused_webpack_module, exports, __nccwpck_require2_) => { +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -3601,30 +3373,30 @@ Object.defineProperty(exports, "parse", ({ } })); -var _v = _interopRequireDefault(__nccwpck_require2_(628)); +var _v = _interopRequireDefault(__nccwpck_require__(628)); -var _v2 = _interopRequireDefault(__nccwpck_require2_(409)); +var _v2 = _interopRequireDefault(__nccwpck_require__(409)); -var _v3 = _interopRequireDefault(__nccwpck_require2_(122)); +var _v3 = _interopRequireDefault(__nccwpck_require__(122)); -var _v4 = _interopRequireDefault(__nccwpck_require2_(120)); +var _v4 = _interopRequireDefault(__nccwpck_require__(120)); -var _nil = _interopRequireDefault(__nccwpck_require2_(332)); +var _nil = _interopRequireDefault(__nccwpck_require__(332)); -var _version = _interopRequireDefault(__nccwpck_require2_(595)); +var _version = _interopRequireDefault(__nccwpck_require__(595)); -var _validate = _interopRequireDefault(__nccwpck_require2_(900)); +var _validate = _interopRequireDefault(__nccwpck_require__(900)); -var _stringify = _interopRequireDefault(__nccwpck_require2_(950)); +var _stringify = _interopRequireDefault(__nccwpck_require__(950)); -var _parse = _interopRequireDefault(__nccwpck_require2_(746)); +var _parse = _interopRequireDefault(__nccwpck_require__(746)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /***/ }), /***/ 569: -/***/ ((__unused_webpack_module, exports, __nccwpck_require2_) => { +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -3634,7 +3406,7 @@ Object.defineProperty(exports, "__esModule", ({ })); exports["default"] = void 0; -var _crypto = _interopRequireDefault(__nccwpck_require2_(113)); +var _crypto = _interopRequireDefault(__nccwpck_require__(113)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -3669,7 +3441,7 @@ exports["default"] = _default; /***/ }), /***/ 746: -/***/ ((__unused_webpack_module, exports, __nccwpck_require2_) => { +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -3679,7 +3451,7 @@ Object.defineProperty(exports, "__esModule", ({ })); exports["default"] = void 0; -var _validate = _interopRequireDefault(__nccwpck_require2_(900)); +var _validate = _interopRequireDefault(__nccwpck_require__(900)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -3736,7 +3508,7 @@ exports["default"] = _default; /***/ }), /***/ 807: -/***/ ((__unused_webpack_module, exports, __nccwpck_require2_) => { +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -3746,7 +3518,7 @@ Object.defineProperty(exports, "__esModule", ({ })); exports["default"] = rng; -var _crypto = _interopRequireDefault(__nccwpck_require2_(113)); +var _crypto = _interopRequireDefault(__nccwpck_require__(113)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -3767,7 +3539,7 @@ function rng() { /***/ }), /***/ 274: -/***/ ((__unused_webpack_module, exports, __nccwpck_require2_) => { +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -3777,7 +3549,7 @@ Object.defineProperty(exports, "__esModule", ({ })); exports["default"] = void 0; -var _crypto = _interopRequireDefault(__nccwpck_require2_(113)); +var _crypto = _interopRequireDefault(__nccwpck_require__(113)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -3797,7 +3569,7 @@ exports["default"] = _default; /***/ }), /***/ 950: -/***/ ((__unused_webpack_module, exports, __nccwpck_require2_) => { +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -3807,7 +3579,7 @@ Object.defineProperty(exports, "__esModule", ({ })); exports["default"] = void 0; -var _validate = _interopRequireDefault(__nccwpck_require2_(900)); +var _validate = _interopRequireDefault(__nccwpck_require__(900)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -3843,7 +3615,7 @@ exports["default"] = _default; /***/ }), /***/ 628: -/***/ ((__unused_webpack_module, exports, __nccwpck_require2_) => { +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -3853,9 +3625,9 @@ Object.defineProperty(exports, "__esModule", ({ })); exports["default"] = void 0; -var _rng = _interopRequireDefault(__nccwpck_require2_(807)); +var _rng = _interopRequireDefault(__nccwpck_require__(807)); -var _stringify = _interopRequireDefault(__nccwpck_require2_(950)); +var _stringify = _interopRequireDefault(__nccwpck_require__(950)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -3957,7 +3729,7 @@ exports["default"] = _default; /***/ }), /***/ 409: -/***/ ((__unused_webpack_module, exports, __nccwpck_require2_) => { +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -3967,9 +3739,9 @@ Object.defineProperty(exports, "__esModule", ({ })); exports["default"] = void 0; -var _v = _interopRequireDefault(__nccwpck_require2_(998)); +var _v = _interopRequireDefault(__nccwpck_require__(998)); -var _md = _interopRequireDefault(__nccwpck_require2_(569)); +var _md = _interopRequireDefault(__nccwpck_require__(569)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -3980,7 +3752,7 @@ exports["default"] = _default; /***/ }), /***/ 998: -/***/ ((__unused_webpack_module, exports, __nccwpck_require2_) => { +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -3991,9 +3763,9 @@ Object.defineProperty(exports, "__esModule", ({ exports["default"] = _default; exports.URL = exports.DNS = void 0; -var _stringify = _interopRequireDefault(__nccwpck_require2_(950)); +var _stringify = _interopRequireDefault(__nccwpck_require__(950)); -var _parse = _interopRequireDefault(__nccwpck_require2_(746)); +var _parse = _interopRequireDefault(__nccwpck_require__(746)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -4065,7 +3837,7 @@ function _default(name, version, hashfunc) { /***/ }), /***/ 122: -/***/ ((__unused_webpack_module, exports, __nccwpck_require2_) => { +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -4075,9 +3847,9 @@ Object.defineProperty(exports, "__esModule", ({ })); exports["default"] = void 0; -var _rng = _interopRequireDefault(__nccwpck_require2_(807)); +var _rng = _interopRequireDefault(__nccwpck_require__(807)); -var _stringify = _interopRequireDefault(__nccwpck_require2_(950)); +var _stringify = _interopRequireDefault(__nccwpck_require__(950)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -4109,7 +3881,7 @@ exports["default"] = _default; /***/ }), /***/ 120: -/***/ ((__unused_webpack_module, exports, __nccwpck_require2_) => { +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -4119,9 +3891,9 @@ Object.defineProperty(exports, "__esModule", ({ })); exports["default"] = void 0; -var _v = _interopRequireDefault(__nccwpck_require2_(998)); +var _v = _interopRequireDefault(__nccwpck_require__(998)); -var _sha = _interopRequireDefault(__nccwpck_require2_(274)); +var _sha = _interopRequireDefault(__nccwpck_require__(274)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -4132,7 +3904,7 @@ exports["default"] = _default; /***/ }), /***/ 900: -/***/ ((__unused_webpack_module, exports, __nccwpck_require2_) => { +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -4142,7 +3914,7 @@ Object.defineProperty(exports, "__esModule", ({ })); exports["default"] = void 0; -var _regex = _interopRequireDefault(__nccwpck_require2_(814)); +var _regex = _interopRequireDefault(__nccwpck_require__(814)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -4156,7 +3928,7 @@ exports["default"] = _default; /***/ }), /***/ 595: -/***/ ((__unused_webpack_module, exports, __nccwpck_require2_) => { +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { "use strict"; @@ -4166,7 +3938,7 @@ Object.defineProperty(exports, "__esModule", ({ })); exports["default"] = void 0; -var _validate = _interopRequireDefault(__nccwpck_require2_(900)); +var _validate = _interopRequireDefault(__nccwpck_require__(900)); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } @@ -4183,165 +3955,225 @@ exports["default"] = _default; /***/ }), -/***/ 491: -/***/ ((module) => { - -"use strict"; -module.exports = __nccwpck_require__(491); - -/***/ }), - -/***/ 81: -/***/ ((module) => { - -"use strict"; -module.exports = __nccwpck_require__(81); - -/***/ }), - -/***/ 113: -/***/ ((module) => { - -"use strict"; -module.exports = __nccwpck_require__(113); - -/***/ }), - -/***/ 361: -/***/ ((module) => { - -"use strict"; -module.exports = __nccwpck_require__(361); - -/***/ }), - -/***/ 147: -/***/ ((module) => { - -"use strict"; -module.exports = __nccwpck_require__(147); - -/***/ }), - -/***/ 685: -/***/ ((module) => { +/***/ 672: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; -module.exports = __nccwpck_require__(685); -/***/ }), - -/***/ 687: -/***/ ((module) => { - -"use strict"; -module.exports = __nccwpck_require__(687); - -/***/ }), - -/***/ 808: -/***/ ((module) => { - -"use strict"; -module.exports = __nccwpck_require__(808); - -/***/ }), - -/***/ 37: -/***/ ((module) => { - -"use strict"; -module.exports = __nccwpck_require__(37); - -/***/ }), - -/***/ 17: -/***/ ((module) => { - -"use strict"; -module.exports = __nccwpck_require__(17); - -/***/ }), - -/***/ 576: -/***/ ((module) => { - -"use strict"; -module.exports = __nccwpck_require__(576); - -/***/ }), - -/***/ 512: -/***/ ((module) => { - -"use strict"; -module.exports = __nccwpck_require__(512); - -/***/ }), - -/***/ 404: -/***/ ((module) => { +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.runAction = void 0; +const core = __importStar(__nccwpck_require__(186)); +const exec = __importStar(__nccwpck_require__(514)); +async function execCommand(command, args, options = {}, logError = true) { + try { + await exec.exec(command, args, options); + return true; + } + catch (e) { + if (e instanceof Error && logError) { + core.error(e); + } + return false; + } +} +async function runAction(opticToken, githubToken, standardsFail, eventName, headRef, baseRef, owner, repo, sha) { + const failOnCheckError = standardsFail === "true"; + const valid = verifyInput(opticToken, eventName, owner, repo); + if (!valid) { + return 1; + } + let pr = ""; + if (eventName === "pull_request") { + const prFromRef = headRef === null || headRef === void 0 ? void 0 : headRef.split("/")[2]; + if (!prFromRef) { + core.error("Could not read PR number from ref"); + return 1; + } + pr = prFromRef; + } + const installed = await install(); + if (!installed) { + return 1; + } + let from = ""; + if (eventName === "pull_request") { + const fromBranch = baseRef || ""; + from = `origin/${fromBranch}`; + if (!(await ensureRef(fromBranch))) { + core.error(`Unable to fetch ${from}`); + return 1; + } + } + else if (eventName === "push") { + from = "HEAD~1"; + if (!(await deepen())) { + core.error("Unable to fetch HEAD~1"); + return 1; + } + } + if (from === "") { + core.error("Unable to determine base for comparison."); + return 1; + } + const comparisonRun = await diffAll(opticToken, from); + if (eventName === "pull_request") { + const commentResult = await prComment(githubToken, owner || "", repo || "", pr || "", sha || ""); + if (!commentResult) { + return 1; + } + } + if (!comparisonRun) { + return failOnCheckError ? 1 : 0; + } + return 0; +} +exports.runAction = runAction; +function verifyInput(token, eventName, owner, repo) { + if (!token) { + core.error("No token was provided. You can generate a token through our app at https://app.useoptic.com"); + return false; + } + if (eventName !== "push" && eventName !== "pull_request") { + core.error("Only 'push' and 'pull_request' events are supported."); + return false; + } + if (!owner) { + core.error("Repository owner is required but was not retreived from the environment"); + return false; + } + if (!repo) { + core.error("Repo is required but was not retreived from the environment"); + return false; + } + return true; +} +async function install() { + core.info("Installing optic"); + return execCommand("npm", [ + "install", + "--location=global", + "@useoptic/optic", + ]); +} +async function ensureRef(ref) { + if (!(await execCommand("git", [ + "fetch", + "--no-tags", + "--depth=1", + "origin", + ref, + ]))) { + return false; + } + return true; +} +async function deepen() { + if (!(await execCommand("git", ["fetch", "--deepen=1"]))) { + return false; + } + return true; +} +async function diffAll(token, from) { + core.info("Running Optic diff-all"); + return execCommand("optic", ["diff-all", "--compare-from", from, "--check", "--upload"], { + env: Object.assign(Object.assign({}, process.env), { OPTIC_TOKEN: token }), + }, false); +} +async function prComment(githubToken, owner, repo, pr, sha) { + core.info("Commenting on PR"); + return execCommand("optic", [ + "ci", + "comment", + "--provider", + "github", + "--owner", + owner, + "--repo", + repo, + "--pull-request", + pr, + "--sha", + sha, + ], { + env: Object.assign(Object.assign({}, process.env), { GITHUB_TOKEN: githubToken }), + }); +} -"use strict"; -module.exports = __nccwpck_require__(404); /***/ }), -/***/ 837: -/***/ ((module) => { +/***/ 144: +/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; -module.exports = __nccwpck_require__(837); -/***/ }) +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +var _a; +Object.defineProperty(exports, "__esModule", ({ value: true })); +const core = __importStar(__nccwpck_require__(186)); +const action_1 = __nccwpck_require__(672); +const opticToken = core.getInput("optic_token"); +const githubToken = core.getInput("github_token"); +const standardsFail = core.getInput("standards_fail"); +const eventName = process.env.GITHUB_EVENT_NAME; +const headRef = process.env.GITHUB_REF; +const baseRef = process.env.GITHUB_BASE_REF; +const owner = process.env.GITHUB_REPOSITORY_OWNER; +const repo = (_a = process.env.GITHUB_REPOSITORY) === null || _a === void 0 ? void 0 : _a.split("/")[1]; +const sha = process.env.GITHUB_SHA; +(0, action_1.runAction)(opticToken, githubToken, standardsFail, eventName, headRef, baseRef, owner, repo, sha) + .then((exitCode) => { + return process.exit(exitCode); +}) + .catch(() => { + return process.exit(1); +}); -/******/ }); -/************************************************************************/ -/******/ // The module cache -/******/ var __webpack_module_cache__ = {}; -/******/ -/******/ // The require function -/******/ function __nccwpck_require2_(moduleId) { -/******/ // Check if module is in cache -/******/ var cachedModule = __webpack_module_cache__[moduleId]; -/******/ if (cachedModule !== undefined) { -/******/ return cachedModule.exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = __webpack_module_cache__[moduleId] = { -/******/ // no module.id needed -/******/ // no module.loaded needed -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ var threw = true; -/******/ try { -/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __nccwpck_require2_); -/******/ threw = false; -/******/ } finally { -/******/ if(threw) delete __webpack_module_cache__[moduleId]; -/******/ } -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/************************************************************************/ -/******/ /* webpack/runtime/compat */ -/******/ -/******/ if (typeof __nccwpck_require2_ !== 'undefined') __nccwpck_require2_.ab = __dirname + "/"; -/******/ -/************************************************************************/ -/******/ -/******/ // startup -/******/ // Load entry module and return exports -/******/ // This entry module is referenced by other modules so it can't be inlined -/******/ var __webpack_exports__ = __nccwpck_require2_(667); -/******/ module.exports = __webpack_exports__; -/******/ -/******/ })() -; /***/ }), @@ -4479,7 +4311,7 @@ module.exports = require("util"); /******/ // Execute the module function /******/ var threw = true; /******/ try { -/******/ __webpack_modules__[moduleId](module, module.exports, __nccwpck_require__); +/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __nccwpck_require__); /******/ threw = false; /******/ } finally { /******/ if(threw) delete __webpack_module_cache__[moduleId]; @@ -4499,7 +4331,7 @@ module.exports = require("util"); /******/ // startup /******/ // Load entry module and return exports /******/ // This entry module is referenced by other modules so it can't be inlined -/******/ var __webpack_exports__ = __nccwpck_require__(667); +/******/ var __webpack_exports__ = __nccwpck_require__(144); /******/ module.exports = __webpack_exports__; /******/ /******/ })() diff --git a/build/index.js.map b/build/index.js.map deleted file mode 100644 index 149f646..0000000 --- a/build/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsC;AACtC,qCAAqC;AAErC,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;AAChD,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;AAClD,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AAEtD,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;AAChD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;AACvC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;AAC5C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;AAClD,MAAM,IAAI,GAAG,MAAA,OAAO,CAAC,GAAG,CAAC,iBAAiB,0CAAE,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;AAC1D,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;AAEnC,IAAA,kBAAS,EACP,UAAU,EACV,WAAW,EACX,aAAa,EACb,SAAS,EACT,OAAO,EACP,OAAO,EACP,KAAK,EACL,IAAI,EACJ,GAAG,CACJ;KACE,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;IACjB,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC,CAAC;KACD,KAAK,CAAC,GAAG,EAAE;IACV,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/package.json b/package.json index 5973688..f65e540 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "license": "MIT", "scripts": { "clean": "rm -rf build && rm -f tsconfig.tsbuildinfo", - "build": "yarn run tsc --build --verbose && ncc build -o build", + "build": "yarn run tsc --build --verbose && ncc build src/index.ts -o build", "ci:build": "yarn build", "test": "ENVIRONMENT=test yarn jest", "ci:test": "yarn test", diff --git a/tsconfig.json b/tsconfig.json index e63ff38..a7fa09f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,7 +13,8 @@ "lib": ["es2017", "dom", "es2019"], "outDir": "build", "resolveJsonModule": true, - "rootDir": "src" + "rootDir": "src", + "noEmit": true }, "include": ["src/**/*"], "typeRoots": [ From f3423d9e26857390830abab1b0b3b4026ba5b402 Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Fri, 10 Feb 2023 08:25:50 -0500 Subject: [PATCH 2/2] Clean up tsconfig so we only output a single index.js --- build/__tests__/action.test.d.ts | 2 -- build/__tests__/action.test.d.ts.map | 1 - build/action.d.ts | 1 - build/action.d.ts.map | 1 - build/index.d.ts | 1 - build/index.d.ts.map | 1 - package.json | 2 +- tsconfig.json | 4 ---- 8 files changed, 1 insertion(+), 12 deletions(-) delete mode 100644 build/__tests__/action.test.d.ts delete mode 100644 build/__tests__/action.test.d.ts.map delete mode 100644 build/action.d.ts delete mode 100644 build/action.d.ts.map delete mode 100644 build/index.d.ts delete mode 100644 build/index.d.ts.map diff --git a/build/__tests__/action.test.d.ts b/build/__tests__/action.test.d.ts deleted file mode 100644 index 06a3170..0000000 --- a/build/__tests__/action.test.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export {}; -//# sourceMappingURL=action.test.d.ts.map \ No newline at end of file diff --git a/build/__tests__/action.test.d.ts.map b/build/__tests__/action.test.d.ts.map deleted file mode 100644 index de27b03..0000000 --- a/build/__tests__/action.test.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"action.test.d.ts","sourceRoot":"","sources":["file:///Users/nalanj/Source/action/src/__tests__/action.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/build/action.d.ts b/build/action.d.ts deleted file mode 100644 index b31a93b..0000000 --- a/build/action.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare function runAction(opticToken: string, githubToken: string, standardsFail: string, eventName: string | undefined, headRef: string | undefined, baseRef: string | undefined, owner: string | undefined, repo: string | undefined, sha: string | undefined): Promise; diff --git a/build/action.d.ts.map b/build/action.d.ts.map deleted file mode 100644 index 6024c0d..0000000 --- a/build/action.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"","sourceRoot":"","sources":["file:///Users/nalanj/Source/action/src/action.ts"],"names":[],"mappings":"AAqBA,wBAAsB,SAAS,CAC7B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,GAAG,EAAE,MAAM,GAAG,SAAS,GACtB,OAAO,CAAC,MAAM,CAAC,CAkEjB"} \ No newline at end of file diff --git a/build/index.d.ts b/build/index.d.ts deleted file mode 100644 index cb0ff5c..0000000 --- a/build/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/build/index.d.ts.map b/build/index.d.ts.map deleted file mode 100644 index 9a76c41..0000000 --- a/build/index.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"","sourceRoot":"","sources":["file:///Users/nalanj/Source/action/src/index.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/package.json b/package.json index f65e540..1d8114f 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "license": "MIT", "scripts": { "clean": "rm -rf build && rm -f tsconfig.tsbuildinfo", - "build": "yarn run tsc --build --verbose && ncc build src/index.ts -o build", + "build": "yarn run tsc && ncc build src/index.ts -o build", "ci:build": "yarn build", "test": "ENVIRONMENT=test yarn jest", "ci:test": "yarn test", diff --git a/tsconfig.json b/tsconfig.json index a7fa09f..b2c8fea 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,9 +1,5 @@ { "compilerOptions": { - "composite": true, - "sourceMap": true, - "declaration": true, - "declarationMap": true, "module": "commonjs", "moduleResolution": "node", "esModuleInterop": true,