Skip to content

Commit

Permalink
fix: enable strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
keroxp committed Nov 11, 2020
1 parent 45d5dab commit 9e29598
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 43 deletions.
18 changes: 9 additions & 9 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12052,7 +12052,7 @@ function aggregateDeploymentParams({ environment, ref, token, repository }) {
!ref && missings.push("--github-ref");
!token && missings.push("--github-token");
!repository && missings.push("--github-repository");
if (missings.length > 0) {
if (!environment || !ref || !token || !repository) {
throw new Error(`${missings.join(",")} are required if --create-deployment specified.`);
}
const [owner, repo] = repository.split("/");
Expand All @@ -12067,14 +12067,14 @@ function aggregateDeploymentParams({ environment, ref, token, repository }) {
}
exports.aggregateDeploymentParams = aggregateDeploymentParams;
function deploy({ deployContext, region, deployment, idleDuration }) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const o = github_1.getOctokit((_a = deployment === null || deployment === void 0 ? void 0 : deployment.token) !== null && _a !== void 0 ? _a : "");
let github;
let deployId;
if (deployment) {
github = github_1.getOctokit(deployment.token);
const { owner, repo, ref, environment } = deployment;
console.log("Creating deployment...", owner, repo, ref, environment);
const resp = yield o.repos.createDeployment({
const resp = yield github.repos.createDeployment({
owner,
repo,
required_contexts: [],
Expand All @@ -12093,9 +12093,9 @@ function deploy({ deployContext, region, deployment, idleDuration }) {
let code = 1;
try {
console.log(`Start rolling out...`);
if (deployId) {
if (github && deployment && deployId) {
const { owner, repo } = deployment;
yield o.repos.createDeploymentStatus({
yield github.repos.createDeploymentStatus({
owner,
repo,
deployment_id: deployId,
Expand All @@ -12117,11 +12117,11 @@ function deploy({ deployContext, region, deployment, idleDuration }) {
core.setFailed(e.message);
}
finally {
if (deployId) {
if (github && deployment && deployId) {
const { owner, repo } = deployment;
if (code === 0) {
console.log(`Updating deployment state to 'success'...`);
yield o.repos.createDeploymentStatus({
yield github.repos.createDeploymentStatus({
owner,
repo,
auto_inactive: true,
Expand All @@ -12134,7 +12134,7 @@ function deploy({ deployContext, region, deployment, idleDuration }) {
}
else {
console.log(`Updating deployment state to 'failure'...`);
yield o.repos.createDeploymentStatus({
yield github.repos.createDeploymentStatus({
owner,
repo,
deployment_id: deployId,
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
"@actions/tool-cache": "^1.1.2"
},
"devDependencies": {
"@types/jest": "^26.0.10",
"@types/node": "^12.12.7",
"@types/jest": "^26.0.15",
"@types/node": "^14.14.7",
"@zeit/ncc": "^0.22.3",
"jest": "^26.4.0",
"prettier": "^1.19.1",
"ts-jest": "^26.2.0",
"typescript": "^3.9.7"
"prettier": "^2.1.2",
"ts-jest": "^26.4.4",
"typescript": "^4.0.5"
}
}
19 changes: 11 additions & 8 deletions src/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { getOctokit } from "@actions/github";
import * as exec from "@actions/exec";
import * as tc from "@actions/tool-cache";
import * as core from "@actions/core";
import type * as gh from "@actions/github/lib/utils"
type Github = InstanceType<typeof gh.GitHub>

export function parseRef(ref: string): string {
// refs/heads/master -> master
Expand Down Expand Up @@ -41,7 +43,7 @@ export function aggregateDeploymentParams({
!ref && missings.push("--github-ref");
!token && missings.push("--github-token");
!repository && missings.push("--github-repository");
if (missings.length > 0) {
if (!environment || !ref || !token || !repository) {
throw new Error(
`${missings.join(",")} are required if --create-deployment specified.`
);
Expand Down Expand Up @@ -76,12 +78,13 @@ export async function deploy({
idleDuration?: string;
deployment?: GithubDeploymentParams;
}) {
const o = getOctokit(deployment?.token ?? "");
let github: Github|undefined
let deployId: number | undefined;
if (deployment) {
github = getOctokit(deployment.token)
const { owner, repo, ref, environment } = deployment;
console.log("Creating deployment...", owner, repo, ref, environment);
const resp = await o.repos.createDeployment({
const resp = await github.repos.createDeployment({
owner,
repo,
required_contexts: [],
Expand All @@ -100,9 +103,9 @@ export async function deploy({
let code = 1;
try {
console.log(`Start rolling out...`);
if (deployId) {
if (github && deployment && deployId) {
const { owner, repo } = deployment;
await o.repos.createDeploymentStatus({
await github.repos.createDeploymentStatus({
owner,
repo,
deployment_id: deployId,
Expand All @@ -122,11 +125,11 @@ export async function deploy({
console.error(e);
core.setFailed(e.message);
} finally {
if (deployId) {
if (github && deployment && deployId) {
const { owner, repo } = deployment;
if (code === 0) {
console.log(`Updating deployment state to 'success'...`);
await o.repos.createDeploymentStatus({
await github.repos.createDeploymentStatus({
owner,
repo,
auto_inactive: true,
Expand All @@ -139,7 +142,7 @@ export async function deploy({
});
} else {
console.log(`Updating deployment state to 'failure'...`);
await o.repos.createDeploymentStatus({
await github.repos.createDeploymentStatus({
owner,
repo,
deployment_id: deployId,
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"compilerOptions": {
"module": "commonjs",
"allowSyntheticDefaultImports": true,
"strictNullChecks": true,
"strict": true,
"target": "es2015",
"outDir": "dist",
"skipLibCheck": true
Expand Down
108 changes: 87 additions & 21 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,17 @@
"@types/yargs" "^15.0.0"
chalk "^4.0.0"

"@jest/types@^26.6.2":
version "26.6.2"
resolved "https://registry.yarnpkg.com/@jest/types/-/types-26.6.2.tgz#bef5a532030e1d88a2f5a6d933f84e97226ed48e"
integrity sha512-fC6QCp7Sc5sX6g8Tvbmj4XUTbyrik0akgRy03yjXbQaBWWNWGE7SGtJk98m0N8nzegD/7SggrUlivxo5ax4KWQ==
dependencies:
"@types/istanbul-lib-coverage" "^2.0.0"
"@types/istanbul-reports" "^3.0.0"
"@types/node" "*"
"@types/yargs" "^15.0.0"
chalk "^4.0.0"

"@octokit/auth-token@^2.4.0":
version "2.4.2"
resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.4.2.tgz#10d0ae979b100fa6b72fa0e8e63e27e6d0dbff8a"
Expand Down Expand Up @@ -697,14 +708,22 @@
dependencies:
"@types/istanbul-lib-report" "*"

"@types/[email protected]", "@types/jest@^26.0.10":
"@types/[email protected]":
version "26.0.10"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.10.tgz#8faf7e9756c033c39014ae76a7329efea00ea607"
integrity sha512-i2m0oyh8w/Lum7wWK/YOZJakYF8Mx08UaKA1CtbmFeDquVhAEdA7znacsVSf2hJ1OQ/OfVMGN90pw/AtzF8s/Q==
dependencies:
jest-diff "^25.2.1"
pretty-format "^25.2.1"

"@types/jest@^26.0.15":
version "26.0.15"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-26.0.15.tgz#12e02c0372ad0548e07b9f4e19132b834cb1effe"
integrity sha512-s2VMReFXRg9XXxV+CW9e5Nz8fH2K1aEhwgjUqPPbQd7g95T0laAcvLv032EhFHIa5GHsZ8W7iJEQVaJq6k3Gog==
dependencies:
jest-diff "^26.0.0"
pretty-format "^26.0.0"

"@types/node@*":
version "14.6.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.6.0.tgz#7d4411bf5157339337d7cff864d9ff45f177b499"
Expand All @@ -715,10 +734,10 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.11.tgz#bec2961975888d964196bf0016a2f984d793d3ce"
integrity sha512-O+x6uIpa6oMNTkPuHDa9MhMMehlxLAd5QcOvKRjAFsBVpeFWTOPnXbDvILvFgFFZfQ1xh1EZi1FbXxUix+zpsQ==

"@types/node@^12.12.7":
version "12.12.7"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.12.7.tgz#01e4ea724d9e3bd50d90c11fd5980ba317d8fa11"
integrity sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w==
"@types/node@^14.14.7":
version "14.14.7"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.7.tgz#8ea1e8f8eae2430cf440564b98c6dfce1ec5945d"
integrity sha512-Zw1vhUSQZYw+7u5dAwNbIA9TuTotpzY/OF7sJM9FqPOF3SPjKnxrjoTktXDZgUjybf4cWVBP7O8wvKdSaGHweg==

"@types/normalize-package-data@^2.4.0":
version "2.4.0"
Expand Down Expand Up @@ -1348,6 +1367,11 @@ diff-sequences@^26.3.0:
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-26.3.0.tgz#62a59b1b29ab7fd27cef2a33ae52abe73042d0a2"
integrity sha512-5j5vdRcw3CNctePNYN0Wy2e/JbWT6cAYnXv5OuqPhDpyCGc0uLu2TK0zOCJWNB9kOIfYMSpIulRaDgIi4HJ6Ig==

diff-sequences@^26.6.2:
version "26.6.2"
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-26.6.2.tgz#48ba99157de1923412eed41db6b6d4aa9ca7c0b1"
integrity sha512-Mv/TDa3nZ9sbc5soK+OoA74BsS3mL37yixCvUAQkiuA4Wz6YtwP/K47n2rv2ovzHZvoiQeA5FTQOschKkEwB0Q==

domexception@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/domexception/-/domexception-2.0.1.tgz#fb44aefba793e1574b0af6aed2801d057529f304"
Expand Down Expand Up @@ -2086,6 +2110,16 @@ jest-diff@^25.2.1:
jest-get-type "^25.2.6"
pretty-format "^25.5.0"

jest-diff@^26.0.0:
version "26.6.2"
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-26.6.2.tgz#1aa7468b52c3a68d7d5c5fdcdfcd5e49bd164394"
integrity sha512-6m+9Z3Gv9wN0WFVasqjCL/06+EFCMTqDEUl/b87HYK2rAPTyfz4ZIuSlPhY51PIQRWx5TaxeF1qmXKe9gfN3sA==
dependencies:
chalk "^4.0.0"
diff-sequences "^26.6.2"
jest-get-type "^26.3.0"
pretty-format "^26.6.2"

jest-diff@^26.4.0:
version "26.4.0"
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-26.4.0.tgz#d073a0a11952b5bd9f1ff39bb9ad24304a0c55f7"
Expand Down Expand Up @@ -2354,7 +2388,19 @@ jest-snapshot@^26.4.0:
pretty-format "^26.4.0"
semver "^7.3.2"

[email protected], jest-util@^26.3.0:
jest-util@^26.1.0:
version "26.6.2"
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-26.6.2.tgz#907535dbe4d5a6cb4c47ac9b926f6af29576cbc1"
integrity sha512-MDW0fKfsn0OI7MS7Euz6h8HNDXVQ0gaM9uW6RjfDmd1DAFcaxX9OqIakHIqhbnmF08Cf2DLDG+ulq8YQQ0Lp0Q==
dependencies:
"@jest/types" "^26.6.2"
"@types/node" "*"
chalk "^4.0.0"
graceful-fs "^4.2.4"
is-ci "^2.0.0"
micromatch "^4.0.2"

jest-util@^26.3.0:
version "26.3.0"
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-26.3.0.tgz#a8974b191df30e2bf523ebbfdbaeb8efca535b3e"
integrity sha512-4zpn6bwV0+AMFN0IYhH/wnzIQzRaYVrz1A8sYnRnj4UXDXbOVtWmlaZkO9mipFqZ13okIfN87aDoJWB7VH6hcw==
Expand Down Expand Up @@ -2949,10 +2995,10 @@ prelude-ls@~1.1.2:
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=

prettier@^1.19.1:
version "1.19.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==
prettier@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.2.tgz#3050700dae2e4c8b67c4c3f666cdb8af405e1ce5"
integrity sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==

pretty-format@^25.2.1, pretty-format@^25.5.0:
version "25.5.0"
Expand All @@ -2964,6 +3010,16 @@ pretty-format@^25.2.1, pretty-format@^25.5.0:
ansi-styles "^4.0.0"
react-is "^16.12.0"

pretty-format@^26.0.0, pretty-format@^26.6.2:
version "26.6.2"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-26.6.2.tgz#e35c2705f14cb7fe2fe94fa078345b444120fc93"
integrity sha512-7AeGuCYNGmycyQbCqd/3PWH4eOoX/OiCa0uphp57NVTeAGdJGaAliecxwBDHYQCIvrW7aDBZCYeNTP/WX69mkg==
dependencies:
"@jest/types" "^26.6.2"
ansi-regex "^5.0.0"
ansi-styles "^4.0.0"
react-is "^17.0.1"

pretty-format@^26.4.0:
version "26.4.0"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-26.4.0.tgz#c08073f531429e9e5024049446f42ecc9f933a3b"
Expand Down Expand Up @@ -3010,6 +3066,11 @@ react-is@^16.12.0:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==

react-is@^17.0.1:
version "17.0.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.1.tgz#5b3531bd76a645a4c9fb6e693ed36419e3301339"
integrity sha512-NAnt2iGDXohE5LI7uBnLnqvLQMtzhkiAOLXTmv+qnF9Ky7xAPcX8Up/xWIhxvLVGJvuLiNc4xQLtuqDRzb4fSA==

read-pkg-up@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-7.0.1.tgz#f3a6135758459733ae2b95638056e1854e7ef507"
Expand Down Expand Up @@ -3559,22 +3620,22 @@ tr46@^2.0.2:
dependencies:
punycode "^2.1.1"

ts-jest@^26.2.0:
version "26.2.0"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.2.0.tgz#7ec22faceb05ee1467fdb5265d1b33c27441f163"
integrity sha512-9+y2qwzXdAImgLSYLXAb/Rhq9+K4rbt0417b8ai987V60g2uoNWBBmMkYgutI7D8Zhu+IbCSHbBtrHxB9d7xyA==
ts-jest@^26.4.4:
version "26.4.4"
resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-26.4.4.tgz#61f13fb21ab400853c532270e52cc0ed7e502c49"
integrity sha512-3lFWKbLxJm34QxyVNNCgXX1u4o/RV0myvA2y2Bxm46iGIjKlaY0own9gIckbjZJPn+WaJEnfPPJ20HHGpoq4yg==
dependencies:
"@types/jest" "26.x"
bs-logger "0.x"
buffer-from "1.x"
fast-json-stable-stringify "2.x"
jest-util "26.x"
jest-util "^26.1.0"
json5 "2.x"
lodash.memoize "4.x"
make-error "1.x"
mkdirp "1.x"
semver "7.x"
yargs-parser "18.x"
yargs-parser "20.x"

tunnel-agent@^0.6.0:
version "0.6.0"
Expand Down Expand Up @@ -3640,10 +3701,10 @@ typedarray-to-buffer@^3.1.5:
dependencies:
is-typedarray "^1.0.0"

typescript@^3.9.7:
version "3.9.7"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa"
integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==
typescript@^4.0.5:
version "4.0.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.5.tgz#ae9dddfd1069f1cb5beb3ef3b2170dd7c1332389"
integrity sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==

[email protected]:
version "1.8.3"
Expand Down Expand Up @@ -3846,7 +3907,12 @@ y18n@^4.0.0:
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b"
integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==

[email protected], yargs-parser@^18.1.2:
[email protected]:
version "20.2.4"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54"
integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==

yargs-parser@^18.1.2:
version "18.1.3"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0"
integrity sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==
Expand Down

0 comments on commit 9e29598

Please sign in to comment.