From 345c864e90ad72b9900b7d7db6a6886ef40ee0d2 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 11 Feb 2020 18:02:51 +0000 Subject: [PATCH] feat: Build for release --- build.json | 2 +- node_modules/.yarn-integrity | 34 +-- .../github-action-helper/README.ja.md | 6 +- .../github-action-helper/README.md | 6 +- .../github-action-helper/dist/api-helper.d.ts | 15 +- .../github-action-helper/dist/api-helper.js | 74 +++--- .../dist/context-helper.d.ts | 1 + .../dist/context-helper.js | 3 + .../github-action-helper/dist/git-helper.d.ts | 60 +++-- .../github-action-helper/dist/git-helper.js | 213 ++++++++---------- .../github-action-helper/dist/utils.d.ts | 8 + .../github-action-helper/dist/utils.js | 23 +- .../github-action-helper/package.json | 8 +- 13 files changed, 259 insertions(+), 194 deletions(-) diff --git a/build.json b/build.json index fb75e5d4..c130ae6e 100644 --- a/build.json +++ b/build.json @@ -1 +1 @@ -{"owner":"technote-space","repo":"assign-author","sha":"ba9c2dbab42040dd7327496da234412862ffe19f","ref":"refs/tags/v1.2.7","tagName":"v1.2.7","branch":"gh-actions","tags":["v1.2.7","v1.2","v1"],"updated_at":"2020-02-06T09:38:47.341Z"} \ No newline at end of file +{"owner":"technote-space","repo":"assign-author","sha":"f17da6f49a92db0b983c3931e17a8eba63664472","ref":"refs/tags/v1.2.8","tagName":"v1.2.8","branch":"gh-actions","tags":["v1.2.8","v1.2","v1"],"updated_at":"2020-02-11T18:02:50.792Z"} \ No newline at end of file diff --git a/node_modules/.yarn-integrity b/node_modules/.yarn-integrity index 9d1c9b5d..1ab3df89 100644 --- a/node_modules/.yarn-integrity +++ b/node_modules/.yarn-integrity @@ -11,16 +11,16 @@ "@actions/core@^1.2.2", "@actions/github@^2.1.0", "@technote-space/filter-github-action@^0.2.1", - "@technote-space/github-action-helper@^0.8.4", - "@technote-space/github-action-test-helper@^0.2.0", - "@types/jest@^25.1.1", + "@technote-space/github-action-helper@^1.0.6", + "@technote-space/github-action-test-helper@^0.2.1", + "@types/jest@^25.1.2", "@types/node@^13.7.0", - "@typescript-eslint/eslint-plugin@^2.19.0", - "@typescript-eslint/parser@^2.19.0", + "@typescript-eslint/eslint-plugin@^2.19.2", + "@typescript-eslint/parser@^2.19.2", "eslint@^6.8.0", "jest-circus@^25.1.0", "jest@^25.1.0", - "nock@^11.7.2", + "nock@^11.8.2", "ts-jest@^25.2.0", "typescript@^3.7.5" ], @@ -83,8 +83,8 @@ "@octokit/types@^2.0.1": "https://registry.yarnpkg.com/@octokit/types/-/types-2.1.1.tgz#77e80d1b663c5f1f829e5377b728fa3c4fe5a97d", "@sinonjs/commons@^1.7.0": "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.7.0.tgz#f90ffc52a2e519f018b13b6c4da03cbff36ebed6", "@technote-space/filter-github-action@^0.2.1": "https://registry.yarnpkg.com/@technote-space/filter-github-action/-/filter-github-action-0.2.1.tgz#2ea8e53b14828deafce4570ff94963601c086a83", - "@technote-space/github-action-helper@^0.8.4": "https://registry.yarnpkg.com/@technote-space/github-action-helper/-/github-action-helper-0.8.4.tgz#1d0a1cc2898adc72f1be21fa24d2130130c8d798", - "@technote-space/github-action-test-helper@^0.2.0": "https://registry.yarnpkg.com/@technote-space/github-action-test-helper/-/github-action-test-helper-0.2.0.tgz#6a5dc8599fac75c19c3b7562a278427d44b17d7f", + "@technote-space/github-action-helper@^1.0.6": "https://registry.yarnpkg.com/@technote-space/github-action-helper/-/github-action-helper-1.0.6.tgz#c0af0b7cfd6a120393550d027ddc92a263921ce0", + "@technote-space/github-action-test-helper@^0.2.1": "https://registry.yarnpkg.com/@technote-space/github-action-test-helper/-/github-action-test-helper-0.2.1.tgz#06869400e36b32a93eb73ab15cfd2a6354e9358e", "@types/babel__core@^7.1.0": "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.3.tgz#e441ea7df63cd080dfcd02ab199e6d16a735fc30", "@types/babel__generator@*": "https://registry.yarnpkg.com/@types/babel__generator/-/babel__generator-7.6.1.tgz#4901767b397e8711aeb99df8d396d7ba7b7f0e04", "@types/babel__template@*": "https://registry.yarnpkg.com/@types/babel__template/-/babel__template-7.0.2.tgz#4ff63d6b52eddac1de7b975a5223ed32ecea9307", @@ -97,17 +97,17 @@ "@types/istanbul-lib-coverage@^2.0.1": "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz#42995b446db9a48a11a07ec083499a860e9138ff", "@types/istanbul-lib-report@*": "https://registry.yarnpkg.com/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz#c14c24f18ea8190c118ee7562b7ff99a36552686", "@types/istanbul-reports@^1.1.1": "https://registry.yarnpkg.com/@types/istanbul-reports/-/istanbul-reports-1.1.1.tgz#7a8cbf6a406f36c8add871625b278eaf0b0d255a", - "@types/jest@^25.1.1": "https://registry.yarnpkg.com/@types/jest/-/jest-25.1.1.tgz#dcf65a8ee315b91ad39c0d358ae0ddc5602ab0e9", + "@types/jest@^25.1.2": "https://registry.yarnpkg.com/@types/jest/-/jest-25.1.2.tgz#1c4c8770c27906c7d8def5d2033df9dbd39f60da", "@types/json-schema@^7.0.3": "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.4.tgz#38fd73ddfd9b55abb1e1b2ed578cb55bd7b7d339", "@types/node@>= 8": "https://registry.yarnpkg.com/@types/node/-/node-13.7.0.tgz#b417deda18cf8400f278733499ad5547ed1abec4", "@types/node@^13.7.0": "https://registry.yarnpkg.com/@types/node/-/node-13.7.0.tgz#b417deda18cf8400f278733499ad5547ed1abec4", "@types/stack-utils@^1.0.1": "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e", "@types/yargs-parser@*": "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-15.0.0.tgz#cb3f9f741869e20cce330ffbeb9271590483882d", "@types/yargs@^15.0.0": "https://registry.yarnpkg.com/@types/yargs/-/yargs-15.0.3.tgz#41453a0bc7ab393e995d1f5451455638edbd2baf", - "@typescript-eslint/eslint-plugin@^2.19.0": "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.19.0.tgz#bf743448a4633e4b52bee0c40148ba072ab3adbd", - "@typescript-eslint/experimental-utils@2.19.0": "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.19.0.tgz#d5ca732f22c009e515ba09fcceb5f2127d841568", - "@typescript-eslint/parser@^2.19.0": "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.19.0.tgz#912160d9425395d09857dcd5382352bc98be11ae", - "@typescript-eslint/typescript-estree@2.19.0": "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.19.0.tgz#6bd7310b9827e04756fe712909f26956aac4b196", + "@typescript-eslint/eslint-plugin@^2.19.2": "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.19.2.tgz#e279aaae5d5c1f2547b4cff99204e1250bc7a058", + "@typescript-eslint/experimental-utils@2.19.2": "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.19.2.tgz#4611d44cf0f0cb460c26aa7676fc0a787281e233", + "@typescript-eslint/parser@^2.19.2": "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.19.2.tgz#21f42c0694846367e7d6a907feb08ab2f89c0879", + "@typescript-eslint/typescript-estree@2.19.2": "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.19.2.tgz#67485b00172f400474d243c6c0be27581a579350", "abab@^2.0.0": "https://registry.yarnpkg.com/abab/-/abab-2.0.3.tgz#623e2075e02eb2d3f2475e49f99c91846467907a", "acorn-globals@^4.3.2": "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-4.3.4.tgz#9fa1926addc11c97308c4e66d7add0d40c3272e7", "acorn-jsx@^5.1.0": "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.1.0.tgz#294adb71b57398b0680015f0a38c563ee1db5384", @@ -458,7 +458,7 @@ "nanomatch@^1.2.9": "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119", "natural-compare@^1.4.0": "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7", "nice-try@^1.0.4": "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366", - "nock@^11.7.2": "https://registry.yarnpkg.com/nock/-/nock-11.7.2.tgz#4cee4fa838dc3635c074c5b3436bcdec7f7ee213", + "nock@^11.8.2": "https://registry.yarnpkg.com/nock/-/nock-11.8.2.tgz#7845608d57769f41375b63521a7e6b554f4cdbb2", "node-fetch@^2.3.0": "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd", "node-int64@^0.4.0": "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b", "node-modules-regexp@^1.0.0": "https://registry.yarnpkg.com/node-modules-regexp/-/node-modules-regexp-1.0.0.tgz#8d9dbe28964a4ac5712e9131642107c71e90ec40", @@ -546,7 +546,7 @@ "restore-cursor@^3.1.0": "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-3.1.0.tgz#39f67c54b3a7a58cea5236d95cf0034239631f7e", "ret@~0.1.10": "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc", "rimraf@2.6.3": "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab", - "rimraf@^3.0.0": "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.1.tgz#48d3d4cb46c80d388ab26cd61b1b466ae9ae225a", + "rimraf@^3.0.0": "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a", "rsvp@^4.8.4": "https://registry.yarnpkg.com/rsvp/-/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734", "run-async@^2.2.0": "https://registry.yarnpkg.com/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0", "rxjs@^6.5.3": "https://registry.yarnpkg.com/rxjs/-/rxjs-6.5.4.tgz#e0777fe0d184cec7872df147f303572d414e211c", @@ -617,7 +617,7 @@ "supports-color@^5.3.0": "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f", "supports-color@^7.0.0": "https://registry.yarnpkg.com/supports-color/-/supports-color-7.1.0.tgz#68e32591df73e25ad1c4b49108a2ec507962bfd1", "supports-color@^7.1.0": "https://registry.yarnpkg.com/supports-color/-/supports-color-7.1.0.tgz#68e32591df73e25ad1c4b49108a2ec507962bfd1", - "supports-hyperlinks@^2.0.0": "https://registry.yarnpkg.com/supports-hyperlinks/-/supports-hyperlinks-2.0.0.tgz#b1b94a159e9df00b0a554b2d5f0e0a89690334b0", + "supports-hyperlinks@^2.0.0": "https://registry.yarnpkg.com/supports-hyperlinks/-/supports-hyperlinks-2.1.0.tgz#f663df252af5f37c5d49bbd7eeefa9e0b9e59e47", "symbol-tree@^3.2.2": "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2", "table@^5.2.3": "https://registry.yarnpkg.com/table/-/table-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e", "terminal-link@^2.0.0": "https://registry.yarnpkg.com/terminal-link/-/terminal-link-2.1.1.tgz#14a64a27ab3c0df933ea546fba55f2d078edc994", @@ -659,7 +659,7 @@ "util.promisify@^1.0.0": "https://registry.yarnpkg.com/util.promisify/-/util.promisify-1.0.1.tgz#6baf7774b80eeb0f7520d8b81d07982a59abbaee", "uuid@^3.3.2": "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee", "v8-compile-cache@^2.0.3": "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.1.0.tgz#e14de37b31a6d194f5690d67efc4e7f6fc6ab30e", - "v8-to-istanbul@^4.0.1": "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-4.0.1.tgz#d6a2a3823b8ff49bdf2167ff2a45d82dff81d02f", + "v8-to-istanbul@^4.0.1": "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-4.1.2.tgz#387d173be5383dbec209d21af033dcb892e3ac82", "verror@1.10.0": "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400", "w3c-hr-time@^1.0.1": "https://registry.yarnpkg.com/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz#82ac2bff63d950ea9e3189a58a65625fedf19045", "w3c-xmlserializer@^1.1.2": "https://registry.yarnpkg.com/w3c-xmlserializer/-/w3c-xmlserializer-1.1.2.tgz#30485ca7d70a6fd052420a3d12fd90e6339ce794", diff --git a/node_modules/@technote-space/github-action-helper/README.ja.md b/node_modules/@technote-space/github-action-helper/README.ja.md index 9a4d3e6d..4c0532bb 100644 --- a/node_modules/@technote-space/github-action-helper/README.ja.md +++ b/node_modules/@technote-space/github-action-helper/README.ja.md @@ -10,9 +10,12 @@ GitHub Actions 用のヘルパー +## Table of Contents + -**Table of Contents** +
+Details - [使用方法](#%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95) - [Logger](#logger) @@ -23,6 +26,7 @@ GitHub Actions 用のヘルパー - [ContextHelper](#contexthelper) - [Author](#author) +
## 使用方法 diff --git a/node_modules/@technote-space/github-action-helper/README.md b/node_modules/@technote-space/github-action-helper/README.md index 6cbca706..ac6d9182 100644 --- a/node_modules/@technote-space/github-action-helper/README.md +++ b/node_modules/@technote-space/github-action-helper/README.md @@ -10,9 +10,12 @@ Helper for GitHub Actions. +## Table of Contents + -**Table of Contents** +
+Details - [Usage](#usage) - [Logger](#logger) @@ -23,6 +26,7 @@ Helper for GitHub Actions. - [ContextHelper](#contexthelper) - [Author](#author) +
## Usage diff --git a/node_modules/@technote-space/github-action-helper/dist/api-helper.d.ts b/node_modules/@technote-space/github-action-helper/dist/api-helper.d.ts index e9030e80..26e4ff17 100644 --- a/node_modules/@technote-space/github-action-helper/dist/api-helper.d.ts +++ b/node_modules/@technote-space/github-action-helper/dist/api-helper.d.ts @@ -31,7 +31,7 @@ declare type PullsListParams = { export default class ApiHelper { private readonly octokit; private readonly context; - private readonly logger; + private readonly logger?; private readonly branch?; private readonly sender?; private readonly suppressBPError?; @@ -47,12 +47,16 @@ export default class ApiHelper { * @param {string|undefined} options.refForUpdate ref for update * @param {boolean|undefined} options.suppressBPError suppress branch protection error? */ - constructor(octokit: Octokit, context: Context, logger: Logger, options?: { + constructor(octokit: Octokit, context: Context, logger?: Logger | undefined, options?: { branch?: string; sender?: string; refForUpdate?: string; suppressBPError?: boolean; }); + /** + * @param {function} caller caller + */ + private callLogger; /** * @return {string|boolean} sender */ @@ -157,6 +161,12 @@ export default class ApiHelper { headName: string; refName: string; }; + /** + * @param {string} createBranchName branch name + * @param {PullsCreateParams} detail detail + * @return {Promise} info + */ + private createPulls; /** * @param {string} createBranchName branch name * @param {PullsCreateParams} detail detail @@ -222,5 +232,6 @@ export default class ApiHelper { name: string; id: number; }>; + getDefaultBranch: () => Promise; } export {}; diff --git a/node_modules/@technote-space/github-action-helper/dist/api-helper.js b/node_modules/@technote-space/github-action-helper/dist/api-helper.js index 95893ec3..4093cb0e 100644 --- a/node_modules/@technote-space/github-action-helper/dist/api-helper.js +++ b/node_modules/@technote-space/github-action-helper/dist/api-helper.js @@ -65,6 +65,14 @@ class ApiHelper { this.suppressBPError = undefined; this.refForUpdate = undefined; this.prCache = {}; + /** + * @param {function} caller caller + */ + this.callLogger = (caller) => { + if (this.logger) { + caller(this.logger); + } + }; /** * @return {string|boolean} sender */ @@ -194,7 +202,7 @@ class ApiHelper { } catch (error) { if (this.suppressBPError === true && this.isProtectedBranchError(error)) { - this.logger.warn('Branch is protected.'); + this.callLogger(logger => logger.warn('Branch is protected.')); } else { throw error; @@ -267,6 +275,17 @@ class ApiHelper { const refName = `refs/${headName}`; return { branchName, headName, refName }; }; + /** + * @param {string} createBranchName branch name + * @param {PullsCreateParams} detail detail + * @return {Promise} info + */ + this.createPulls = (createBranchName, detail) => __awaiter(this, void 0, void 0, function* () { + this.callLogger((logger) => __awaiter(this, void 0, void 0, function* () { return logger.startProcess('Creating PullRequest... [%s] -> [%s]', utils_1.getBranch(createBranchName, false), yield this.getRefForUpdate(false)); })); + const created = yield this.pullsCreate(createBranchName, detail); + this.callLogger(logger => logger.endProcess()); + return Object.assign({ isPrCreated: true }, created.data); + }); /** * @param {string} createBranchName branch name * @param {PullsCreateParams} detail detail @@ -275,17 +294,12 @@ class ApiHelper { this.pullsCreateOrUpdate = (createBranchName, detail) => __awaiter(this, void 0, void 0, function* () { const pullRequest = yield this.findPullRequest(createBranchName); if (pullRequest) { - this.logger.startProcess('Updating PullRequest... [%s] -> [%s]', utils_1.getBranch(createBranchName, false), yield this.getRefForUpdate(false)); + this.callLogger((logger) => __awaiter(this, void 0, void 0, function* () { return logger.startProcess('Updating PullRequest... [%s] -> [%s]', utils_1.getBranch(createBranchName, false), yield this.getRefForUpdate(false)); })); const updated = yield this.pullsUpdate(pullRequest.number, detail); - this.logger.endProcess(); + this.callLogger(logger => logger.endProcess()); return Object.assign({ isPrCreated: false }, updated.data); } - else { - this.logger.startProcess('Creating PullRequest... [%s] -> [%s]', utils_1.getBranch(createBranchName, false), yield this.getRefForUpdate(false)); - const created = yield this.pullsCreate(createBranchName, detail); - this.logger.endProcess(); - return Object.assign({ isPrCreated: true }, created.data); - } + return this.createPulls(createBranchName, detail); }); /** * @param {string} createBranchName branch name @@ -295,17 +309,12 @@ class ApiHelper { this.pullsCreateOrComment = (createBranchName, detail) => __awaiter(this, void 0, void 0, function* () { const pullRequest = yield this.findPullRequest(createBranchName); if (pullRequest) { - this.logger.startProcess('Creating comment to PullRequest... [%s] -> [%s]', utils_1.getBranch(createBranchName, false), yield this.getRefForUpdate(false)); + this.callLogger((logger) => __awaiter(this, void 0, void 0, function* () { return logger.startProcess('Creating comment to PullRequest... [%s] -> [%s]', utils_1.getBranch(createBranchName, false), yield this.getRefForUpdate(false)); })); yield this.createCommentToPr(createBranchName, detail.body); - this.logger.endProcess(); + this.callLogger(logger => logger.endProcess()); return Object.assign({ isPrCreated: false }, pullRequest); } - else { - this.logger.startProcess('Creating PullRequest... [%s] -> [%s]', utils_1.getBranch(createBranchName, false), yield this.getRefForUpdate(false)); - const created = yield this.pullsCreate(createBranchName, detail); - this.logger.endProcess(); - return Object.assign({ isPrCreated: true }, created.data); - } + return this.createPulls(createBranchName, detail); }); /** * @param {string} branch branch @@ -339,7 +348,7 @@ class ApiHelper { */ this.checkDiff = (files) => { if (!files.length) { - this.logger.info('There is no diff.'); + this.callLogger(logger => logger.info('There is no diff.')); return false; } return true; @@ -351,11 +360,11 @@ class ApiHelper { * @return {Promise>} commit */ this.prepareCommit = (rootDir, commitMessage, files) => __awaiter(this, void 0, void 0, function* () { - this.logger.startProcess('Creating blobs...'); + this.callLogger(logger => logger.startProcess('Creating blobs...')); const blobs = yield this.filesToBlobs(rootDir, files); - this.logger.startProcess('Creating tree...'); + this.callLogger(logger => logger.startProcess('Creating tree...')); const tree = yield this.createTree(blobs); - this.logger.startProcess('Creating commit... [%s]', tree.data.sha); + this.callLogger(logger => logger.startProcess('Creating commit... [%s]', tree.data.sha)); return this.createCommit(commitMessage, tree); }); /** @@ -370,12 +379,12 @@ class ApiHelper { } const commit = yield this.prepareCommit(rootDir, commitMessage, files); const ref = yield this.getRefForUpdate(true); - this.logger.startProcess('Updating ref... [%s] [%s]', ref, commit.data.sha); + this.callLogger(logger => logger.startProcess('Updating ref... [%s] [%s]', ref, commit.data.sha)); if (yield this.updateRef(commit, ref, false)) { process.env.GITHUB_SHA = commit.data.sha; core_1.exportVariable('GITHUB_SHA', commit.data.sha); } - this.logger.endProcess(); + this.callLogger(logger => logger.endProcess()); return true; }); /** @@ -394,11 +403,11 @@ class ApiHelper { const commit = yield this.prepareCommit(rootDir, commitMessage, files); const ref = yield this.getRef(headName); if (null === ref) { - this.logger.startProcess('Creating reference... [%s] [%s]', refName, commit.data.sha); + this.callLogger(logger => logger.startProcess('Creating reference... [%s] [%s]', refName, commit.data.sha)); yield this.createRef(commit, refName); } else { - this.logger.startProcess('Updating reference... [%s] [%s]', refName, commit.data.sha); + this.callLogger(logger => logger.startProcess('Updating reference... [%s] [%s]', refName, commit.data.sha)); yield this.updateRef(commit, headName, true); } return this.pullsCreateOrUpdate(branchName, detail); @@ -411,7 +420,7 @@ class ApiHelper { const { branchName, headName, refName } = this.getBranchInfo(createBranchName); const pullRequest = yield this.findPullRequest(branchName); if (pullRequest) { - this.logger.startProcess('Closing PullRequest... [%s]', branchName); + this.callLogger(logger => logger.startProcess('Closing PullRequest... [%s]', branchName)); if (message) { yield this.createCommentToPr(branchName, message); } @@ -421,16 +430,16 @@ class ApiHelper { }); } else { - this.logger.info('There is no PullRequest named [%s]', branchName); + this.callLogger(logger => logger.info('There is no PullRequest named [%s]', branchName)); const ref = yield this.getRef(headName); if (!ref) { - this.logger.info('There is no reference named [%s]', refName); + this.callLogger(logger => logger.info('There is no reference named [%s]', refName)); return; } } - this.logger.startProcess('Deleting reference... [%s]', refName); + this.callLogger(logger => logger.startProcess('Deleting reference... [%s]', refName)); yield this.deleteRef(headName); - this.logger.endProcess(); + this.callLogger(logger => logger.endProcess()); }); /** * @return {Promise<{ login: string, email: string, name: string, id: number }>} user @@ -450,6 +459,11 @@ class ApiHelper { id: user.id, }; }); + // eslint-disable-next-line camelcase + this.getDefaultBranch = () => __awaiter(this, void 0, void 0, function* () { var _e, _f; return _f = (_e = this.context.payload.repository) === null || _e === void 0 ? void 0 : _e.default_branch, (_f !== null && _f !== void 0 ? _f : (yield this.octokit.repos.get({ + owner: this.context.repo.owner, + repo: this.context.repo.repo, + })).data.default_branch); }); this.branch = (_a = options) === null || _a === void 0 ? void 0 : _a.branch; this.sender = (_b = options) === null || _b === void 0 ? void 0 : _b.sender; this.refForUpdate = (_c = options) === null || _c === void 0 ? void 0 : _c.refForUpdate; diff --git a/node_modules/@technote-space/github-action-helper/dist/context-helper.d.ts b/node_modules/@technote-space/github-action-helper/dist/context-helper.d.ts index fd0f8007..6d233c8d 100644 --- a/node_modules/@technote-space/github-action-helper/dist/context-helper.d.ts +++ b/node_modules/@technote-space/github-action-helper/dist/context-helper.d.ts @@ -6,6 +6,7 @@ export declare const isPr: (context: Context) => boolean; export declare const isIssue: (context: Context) => boolean; export declare const isCron: (context: Context) => boolean; export declare const isCustomEvent: (context: Context) => boolean; +export declare const isCreateTag: (context: Context) => boolean; export declare const getTagName: (context: Context) => string; export declare const getSender: (context: Context) => string | false; export declare const getRepository: (context: Context) => string; diff --git a/node_modules/@technote-space/github-action-helper/dist/context-helper.js b/node_modules/@technote-space/github-action-helper/dist/context-helper.js index 399a9975..2821fb1e 100644 --- a/node_modules/@technote-space/github-action-helper/dist/context-helper.js +++ b/node_modules/@technote-space/github-action-helper/dist/context-helper.js @@ -11,6 +11,7 @@ exports.isPr = (context) => 'pull_request' === context.eventName; exports.isIssue = (context) => 'issues' === context.eventName; exports.isCron = (context) => 'schedule' === context.eventName; exports.isCustomEvent = (context) => 'repository_dispatch' === context.eventName; +exports.isCreateTag = (context) => 'create' === context.eventName && 'tag' === context.payload.ref_type; exports.getTagName = (context) => exports.isRelease(context) ? context.payload.release.tag_name : (/^refs\/tags\//.test(context.ref) ? context.ref.replace(/^refs\/tags\//, '') : ''); exports.getSender = (context) => context.payload.sender && context.payload.sender.type === 'User' ? context.payload.sender.login : false; exports.getRepository = (context) => `${context.repo.owner}/${context.repo.repo}`; @@ -26,9 +27,11 @@ exports.showActionInfo = (rootDir, logger, context) => { if (false !== info) { if ('owner' in info) { logger.log('Version: %s/%s@%s', info.owner, info.repo, info.tagName); + logger.log(' %s', info.sha); } else { logger.log('Version: %s', info.tagName); + logger.log(' %s', info.sha); } } logger.log('Event: %s', context.eventName); diff --git a/node_modules/@technote-space/github-action-helper/dist/git-helper.d.ts b/node_modules/@technote-space/github-action-helper/dist/git-helper.d.ts index 47c8fee0..90550256 100644 --- a/node_modules/@technote-space/github-action-helper/dist/git-helper.d.ts +++ b/node_modules/@technote-space/github-action-helper/dist/git-helper.d.ts @@ -51,24 +51,34 @@ export default class GitHelper { }[]>; /** * @param {string} workDir work dir - * @param {Context} context context + * @param {boolean} refresh refresh? * @return {Promise} void */ - addOrigin: (workDir: string, context: Context) => Promise; + private initialize; /** * @param {string|boolean} origin origin * @param {boolean} quiet quiet? */ useOrigin: (origin: string | boolean, quiet?: boolean | undefined) => void; /** - * @return {boolean} is quiet? + * @return {string} origin name */ - private isQuiet; + getRemoteName: () => string; /** * @param {Context} context context * @return {string} origin */ - private getOrigin; + private getRemote; + /** + * @param {string} workDir work dir + * @param {Context} context context + * @return {Promise} void + */ + addOrigin: (workDir: string, context: Context) => Promise; + /** + * @return {boolean} is quiet? + */ + private isQuiet; /** * @param {string} workDir work dir * @return {Promise} branch name @@ -93,17 +103,6 @@ export default class GitHelper { * @return {Promise} void */ clone: (workDir: string, context: Context) => Promise; - /** - * @param {string} workDir work dir - * @param {Context} context context - * @return {Promise} void - */ - checkout: (workDir: string, context: Context) => Promise; - /** - * @param {string} workDir work dir - * @return {Promise} void - */ - private initialize; /** * @param {string} workDir work dir * @param {string} branch branch @@ -118,6 +117,12 @@ export default class GitHelper { * @return {Promise} void */ fetchOrigin: (workDir: string, context: Context, options?: string[] | undefined, refspec?: string[] | undefined) => Promise; + /** + * @param {string} workDir work dir + * @param {Context} context context + * @return {Promise} void + */ + checkout: (workDir: string, context: Context) => Promise; /** * @param {string} workDir work dir * @param {string} branch branch @@ -166,14 +171,23 @@ export default class GitHelper { /** * @param {string} workDir work dir * @param {string} message message + * @param {object} options options */ - commit: (workDir: string, message: string) => Promise; + commit: (workDir: string, message: string, options?: { + count?: number | undefined; + allowEmpty?: boolean | undefined; + args?: string[] | undefined; + } | undefined) => Promise; /** * @param {string} workDir work dir * @param {string} message message - * @param {number} count stat count + * @param {object} options options */ - makeCommit: (workDir: string, message: string, count?: number) => Promise; + makeCommit: (workDir: string, message: string, options?: { + count?: number | undefined; + allowEmpty?: boolean | undefined; + args?: string[] | undefined; + } | undefined) => Promise; /** * @param {string} workDir work dir * @return {Promise} tags @@ -212,11 +226,15 @@ export default class GitHelper { /** * @param {string} workDir work dir * @param {string} branch branch - * @param {boolean} withTag with tag? * @param {Context} context context + * @param {object} options options * @return {Promise} void */ - push: (workDir: string, branch: string, withTag: boolean, context: Context) => Promise; + push: (workDir: string, branch: string, context: Context, options?: { + withTag?: boolean | undefined; + force?: boolean | undefined; + args?: string[] | undefined; + } | undefined) => Promise; /** * @param {string} workDir work dir * @param {string} branch branch diff --git a/node_modules/@technote-space/github-action-helper/dist/git-helper.js b/node_modules/@technote-space/github-action-helper/dist/git-helper.js index d2eaae73..dfcbb83f 100644 --- a/node_modules/@technote-space/github-action-helper/dist/git-helper.js +++ b/node_modules/@technote-space/github-action-helper/dist/git-helper.js @@ -67,19 +67,18 @@ class GitHelper { }); /** * @param {string} workDir work dir - * @param {Context} context context + * @param {boolean} refresh refresh? * @return {Promise} void */ - this.addOrigin = (workDir, context) => __awaiter(this, void 0, void 0, function* () { - const url = this.getOrigin(context); - yield this.initialize(workDir); - yield this.runCommand(workDir, { - command: 'git remote add', - args: ['origin', url], - quiet: this.isQuiet(), - altCommand: 'git remote add origin', - suppressError: true, - }); + this.initialize = (workDir, refresh = true) => __awaiter(this, void 0, void 0, function* () { + if (utils_1.isCloned(workDir) && !refresh) { + return; + } + if (fs_1.default.existsSync(workDir)) { + yield this.runCommand(workDir, { command: 'rm', args: ['-rdf', workDir] }); + } + fs_1.default.mkdirSync(workDir, { recursive: true }); + yield this.runCommand(workDir, { command: 'git init', args: ['.'] }); }); /** * @param {string|boolean} origin origin @@ -92,14 +91,33 @@ class GitHelper { } }; /** - * @return {boolean} is quiet? + * @return {string} origin name */ - this.isQuiet = () => !this.origin || this.quietIfNotOrigin; + this.getRemoteName = () => { var _a; return _a = this.origin, (_a !== null && _a !== void 0 ? _a : 'origin'); }; /** * @param {Context} context context * @return {string} origin */ - this.getOrigin = (context) => { var _a; return _a = this.origin, (_a !== null && _a !== void 0 ? _a : context_helper_1.getGitUrlWithToken(context, this.token)); }; + this.getRemote = (context) => { var _a; return _a = this.origin, (_a !== null && _a !== void 0 ? _a : context_helper_1.getGitUrlWithToken(context, this.token)); }; + /** + * @param {string} workDir work dir + * @param {Context} context context + * @return {Promise} void + */ + this.addOrigin = (workDir, context) => __awaiter(this, void 0, void 0, function* () { + yield this.initialize(workDir, false); + yield this.runCommand(workDir, { + command: 'git remote add', + args: [this.getRemoteName(), context_helper_1.getGitUrlWithToken(context, this.token)], + quiet: this.isQuiet(), + altCommand: `git remote add ${this.getRemoteName()}`, + suppressError: true, + }); + }); + /** + * @return {boolean} is quiet? + */ + this.isQuiet = () => !this.origin || this.quietIfNotOrigin; /** * @param {string} workDir work dir * @return {Promise} branch name @@ -123,10 +141,9 @@ class GitHelper { * @return {Promise} void */ this.cloneBranch = (workDir, branch, context) => __awaiter(this, void 0, void 0, function* () { - const url = this.getOrigin(context); yield this.runCommand(workDir, { command: 'git clone', - args: [`--branch=${branch}`, this.cloneDepth, url, '.'], + args: [`--branch=${branch}`, this.cloneDepth, this.getRemote(context), '.'], quiet: this.isQuiet(), altCommand: `git clone --branch=${branch}`, suppressError: true, @@ -138,23 +155,25 @@ class GitHelper { * @return {Promise} void */ this.clonePR = (workDir, context) => __awaiter(this, void 0, void 0, function* () { - const url = this.getOrigin(context); yield this.runCommand(workDir, [ { command: 'git clone', - args: [this.cloneDepth, url, '.'], + args: [this.cloneDepth, this.getRemote(context), '.'], quiet: this.isQuiet(), altCommand: 'git clone', suppressError: true, }, { command: 'git fetch', - args: [url, `+${context.ref}`], + args: [this.getRemote(context), `+${context.ref}`], quiet: this.isQuiet(), - altCommand: `git fetch origin ${context.ref}`, + altCommand: `git fetch ${this.getRemoteName()} ${context.ref}`, stderrToStdout: true, }, - 'git checkout -qf FETCH_HEAD', + { + command: 'git checkout', + args: ['-qf', 'FETCH_HEAD'], + }, ]); }); /** @@ -176,63 +195,6 @@ class GitHelper { yield this.checkout(workDir, context); } }); - /** - * @param {string} workDir work dir - * @param {Context} context context - * @return {Promise} void - */ - this.checkout = (workDir, context) => __awaiter(this, void 0, void 0, function* () { - const url = this.getOrigin(context); - if (this.cloneDepth && context.sha) { - yield this.runCommand(workDir, [ - { - command: 'git clone', - args: [this.cloneDepth, url, '.'], - quiet: this.isQuiet(), - altCommand: 'git clone', - }, - { - command: 'git fetch', - args: [url, context.ref], - quiet: this.isQuiet(), - altCommand: `git fetch origin ${context.ref}`, - }, - { - command: 'git checkout', - args: ['-qf', context.sha], - }, - ]); - } - else { - const checkout = context.sha || utils_1.getBranch(context) || context.ref; - if (!checkout) { - throw new Error('Invalid context.'); - } - yield this.runCommand(workDir, [ - { - command: 'git clone', - args: [url, '.'], - quiet: this.isQuiet(), - altCommand: 'git clone', - }, - { - command: 'git checkout', - args: ['-qf', checkout], - }, - ]); - } - }); - /** - * @param {string} workDir work dir - * @return {Promise} void - */ - this.initialize = (workDir) => __awaiter(this, void 0, void 0, function* () { - if (fs_1.default.existsSync(workDir)) { - yield this.runCommand(workDir, { command: 'rm', args: ['-rdf', workDir] }); - } - fs_1.default.mkdirSync(workDir, { recursive: true }); - yield this.runCommand(workDir, { command: 'git init', args: ['.'] }); - }); /** * @param {string} workDir work dir * @param {string} branch branch @@ -255,13 +217,28 @@ class GitHelper { command: 'git fetch', args: [ ...((options !== null && options !== void 0 ? options : [])), - 'origin', + this.getRemoteName(), ...((refspec !== null && refspec !== void 0 ? refspec : [])), ], suppressError: true, stderrToStdout: true, }); }); + /** + * @param {string} workDir work dir + * @param {Context} context context + * @return {Promise} void + */ + this.checkout = (workDir, context) => __awaiter(this, void 0, void 0, function* () { + yield this.fetchOrigin(workDir, context, ['--no-tags'], [utils_1.getRefspec(context)]); + yield this.runCommand(workDir, [ + { + command: 'git checkout', + args: ['-qf', context.sha], + stderrToStdout: true, + }, + ]); + }); /** * @param {string} workDir work dir * @param {string} branch branch @@ -269,13 +246,12 @@ class GitHelper { * @return {Promise} void */ this.fetchBranch = (workDir, branch, context) => __awaiter(this, void 0, void 0, function* () { - const url = this.getOrigin(context); const branchName = utils_1.getBranch(branch, false); yield this.runCommand(workDir, { command: 'git fetch', - args: ['--prune', '--no-recurse-submodules', this.cloneDepth, url, `+refs/heads/${branchName}:refs/remotes/origin/${branchName}`], + args: ['--prune', '--no-recurse-submodules', this.cloneDepth, this.getRemote(context), `+refs/heads/${branchName}:refs/remotes/${this.getRemoteName()}/${branchName}`], quiet: this.isQuiet(), - altCommand: `git fetch --prune --no-recurse-submodules${this.cloneDepth} origin +refs/heads/${branchName}:refs/remotes/origin/${branchName}`, + altCommand: `git fetch --prune --no-recurse-submodules${this.cloneDepth} ${this.getRemoteName()} +refs/heads/${branchName}:refs/remotes/${this.getRemoteName()}/${branchName}`, suppressError: true, }); }); @@ -295,7 +271,7 @@ class GitHelper { this.switchBranch = (workDir, branch) => __awaiter(this, void 0, void 0, function* () { yield this.runCommand(workDir, { command: 'git checkout', - args: ['-b', branch, `origin/${branch}`], + args: ['-b', branch, `${this.getRemoteName()}/${branch}`], suppressError: true, stderrToStdout: true, }); @@ -338,7 +314,7 @@ class GitHelper { * @return {Promise} diff */ this.getRefDiff = (workDir, baseRef, compareRef, diffFilter, dot) => __awaiter(this, void 0, void 0, function* () { - const toDiffRef = (ref) => 'HEAD' === ref ? 'HEAD' : (utils_1.isPrRef(ref) ? ref.replace(/^refs\//, '') : `origin/${utils_1.getBranch(ref, false)}`); + const toDiffRef = (ref) => 'HEAD' === ref ? 'HEAD' : (utils_1.isPrRef(ref) ? ref.replace(/^refs\//, '') : `${this.getRemoteName()}/${utils_1.getBranch(ref, false)}`); return (yield this.runCommand(workDir, { command: 'git diff', args: [`${toDiffRef(baseRef)}${(dot !== null && dot !== void 0 ? dot : '...')}${toDiffRef(compareRef)}`, '--name-only', diffFilter ? `--diff-filter=${diffFilter}` : ''], @@ -353,26 +329,32 @@ class GitHelper { /** * @param {string} workDir work dir * @param {string} message message + * @param {object} options options */ - this.commit = (workDir, message) => __awaiter(this, void 0, void 0, function* () { + this.commit = (workDir, message, options) => __awaiter(this, void 0, void 0, function* () { + var _e; yield this.runCommand(workDir, { command: 'git add', args: ['--all'] }); - if (!(yield this.checkDiff(workDir))) { + if (!((_e = options) === null || _e === void 0 ? void 0 : _e.allowEmpty) && !(yield this.checkDiff(workDir))) { this.logger.info('There is no diff.'); return false; } - yield this.makeCommit(workDir, message); + yield this.makeCommit(workDir, message, options); return true; }); /** * @param {string} workDir work dir * @param {string} message message - * @param {number} count stat count + * @param {object} options options */ - this.makeCommit = (workDir, message, count = 10) => __awaiter(this, void 0, void 0, function* () { + this.makeCommit = (workDir, message, options) => __awaiter(this, void 0, void 0, function* () { + var _f, _g, _h, _j, _k, _l; + const count = (_g = (_f = options) === null || _f === void 0 ? void 0 : _f.count, (_g !== null && _g !== void 0 ? _g : 10)); // eslint-disable-line no-magic-numbers + const allowEmpty = (_j = (_h = options) === null || _h === void 0 ? void 0 : _h.allowEmpty, (_j !== null && _j !== void 0 ? _j : false)); + const args = (_l = (_k = options) === null || _k === void 0 ? void 0 : _k.args, (_l !== null && _l !== void 0 ? _l : [])); yield this.runCommand(workDir, [ { command: 'git commit', - args: ['-qm', message], + args: [allowEmpty ? '--allow-empty' : '', ...args, '-qm', message], }, { command: 'git show', @@ -397,7 +379,6 @@ class GitHelper { * @see https://qiita.com/ngyuki/items/ca7bed067d7e538fd0cd */ this.fetchTags = (workDir, context, splitSize = 20) => __awaiter(this, void 0, void 0, function* () { - const url = this.getOrigin(context); yield this.runCommand(workDir, [ ...utils_1.arrayChunk(yield this.getTags(workDir), splitSize).map(tags => ({ command: 'git tag', @@ -407,9 +388,9 @@ class GitHelper { })), { command: 'git fetch', - args: [url, '--tags'], + args: [this.getRemote(context), '--tags'], quiet: this.isQuiet(), - altCommand: 'git fetch origin --tags', + altCommand: `git fetch ${this.getRemoteName()} --tags`, }, ]); }); @@ -421,16 +402,15 @@ class GitHelper { * @return {Promise} void */ this.deleteTag = (workDir, tags, context, splitSize = 20) => __awaiter(this, void 0, void 0, function* () { - const url = this.getOrigin(context); const regexp = /^(refs\/)?tags\//; const getTagRef = (tag) => regexp.test(tag) ? tag : `tags/${tag}`; const getTag = (tag) => tag.replace(regexp, ''); yield this.runCommand(workDir, [ ...utils_1.arrayChunk((typeof tags === 'string' ? [tags] : tags).map(getTagRef), splitSize).map(tags => ({ command: 'git push', - args: [url, '--delete', ...tags], + args: [this.getRemote(context), '--delete', ...tags], quiet: this.isQuiet(), - altCommand: `git push origin --delete ${tags.join(' ')}`, + altCommand: `git push ${this.getRemoteName()} --delete ${tags.join(' ')}`, suppressError: true, })), ...utils_1.arrayChunk((typeof tags === 'string' ? [tags] : tags).map(getTag), splitSize).map(tags => ({ @@ -449,7 +429,6 @@ class GitHelper { * @return {Promise} void */ this.copyTag = (workDir, newTag, fromTag, context) => __awaiter(this, void 0, void 0, function* () { - const url = this.getOrigin(context); yield this.deleteTag(workDir, newTag, context); yield this.runCommand(workDir, [ { @@ -458,9 +437,9 @@ class GitHelper { }, { command: 'git push', - args: [url, `refs/tags/${newTag}`], + args: [this.getRemote(context), `refs/tags/${newTag}`], quiet: this.isQuiet(), - altCommand: `git push origin refs/tags/${newTag}`, + altCommand: `git push ${this.getRemoteName()} refs/tags/${newTag}`, }, ]); }); @@ -482,18 +461,28 @@ class GitHelper { /** * @param {string} workDir work dir * @param {string} branch branch - * @param {boolean} withTag with tag? * @param {Context} context context + * @param {object} options options * @return {Promise} void */ - this.push = (workDir, branch, withTag, context) => __awaiter(this, void 0, void 0, function* () { - const url = this.getOrigin(context); - const tags = withTag ? ' --tags' : ''; + this.push = (workDir, branch, context, options) => __awaiter(this, void 0, void 0, function* () { + var _m, _o, _p; + const args = []; + if ((_m = options) === null || _m === void 0 ? void 0 : _m.withTag) { + args.push('--tags'); + } + if ((_o = options) === null || _o === void 0 ? void 0 : _o.force) { + args.push('--force'); + } + if ((_p = options) === null || _p === void 0 ? void 0 : _p.args) { + args.push(...options.args); + } yield this.runCommand(workDir, { command: 'git push', - args: [withTag ? '--tags' : '', url, `${branch}:refs/heads/${branch}`], + args: args.concat([this.getRemote(context), `${branch}:refs/heads/${branch}`]), quiet: this.isQuiet(), - altCommand: `git push${tags} origin ${branch}:refs/heads/${branch}`, + altCommand: `git push ${args.concat([this.getRemoteName(), `${branch}:refs/heads/${branch}`]).join(' ')}`, + suppressError: true, }); }); /** @@ -502,27 +491,19 @@ class GitHelper { * @param {Context} context context * @return {Promise} void */ - this.forcePush = (workDir, branch, context) => __awaiter(this, void 0, void 0, function* () { - const url = this.getOrigin(context); - yield this.runCommand(workDir, { - command: 'git push', - args: ['--force', url, `${branch}:refs/heads/${branch}`], - quiet: this.isQuiet(), - altCommand: `git push --force origin ${branch}:refs/heads/${branch}`, - }); - }); + this.forcePush = (workDir, branch, context) => __awaiter(this, void 0, void 0, function* () { return this.push(workDir, branch, context, { force: true }); }); /** * @param {string} workDir work dir * @return {string} tag */ this.getLastTag = (workDir) => __awaiter(this, void 0, void 0, function* () { - var _e, _f; + var _q, _r; if (!utils_1.isCloned(workDir)) { throw new Error('Not a git repository'); } const tags = (yield this.getTags(workDir)).filter(tag => /^v?\d+(\.\d+)*$/.test(tag)); const compareTag = (tag1, tag2) => utils_1.versionCompare(tag1, tag2); - return 'v' + (_f = (_e = tags.slice().sort(compareTag).reverse()[0]) === null || _e === void 0 ? void 0 : _e.replace(/^v/, ''), (_f !== null && _f !== void 0 ? _f : '0.0.0')); + return 'v' + (_r = (_q = tags.slice().sort(compareTag).reverse()[0]) === null || _q === void 0 ? void 0 : _q.replace(/^v/, ''), (_r !== null && _r !== void 0 ? _r : '0.0.0')); }); /** * @param {string} workDir work dir diff --git a/node_modules/@technote-space/github-action-helper/dist/utils.d.ts b/node_modules/@technote-space/github-action-helper/dist/utils.d.ts index 5cf5ba6e..66e2bba6 100644 --- a/node_modules/@technote-space/github-action-helper/dist/utils.d.ts +++ b/node_modules/@technote-space/github-action-helper/dist/utils.d.ts @@ -12,7 +12,9 @@ export declare const getBuildInfo: (filepath: string) => false | { }; export declare const isCloned: (workDir: string) => boolean; export declare const isSemanticVersioningTagName: (tagName: string) => boolean; +export declare const isRef: (ref: string | Context) => boolean; export declare const isBranch: (ref: string | Context) => boolean; +export declare const isTagRef: (ref: string | Context) => boolean; export declare const isRemoteBranch: (ref: string | Context) => boolean; export declare const isPrRef: (ref: string | Context) => boolean; export declare const getPrMergeRef: (ref: string | Context) => string; @@ -20,6 +22,12 @@ export declare const getPrHeadRef: (ref: string | Context) => string; export declare const getRefForUpdate: (ref: string | Context) => string; export declare const getBranch: (ref: string | Context, defaultIsEmpty?: boolean) => string; export declare const getPrBranch: (context: Context) => string; +export declare const normalizeRef: (ref: string | Context) => string; +export declare const trimRef: (ref: string | Context) => string; +export declare const getTag: (ref: string | Context) => string; +export declare const getRemoteRefspec: (ref: string | Context) => string; +export declare const getLocalRefspec: (ref: string | Context, origin?: string) => string; +export declare const getRefspec: (ref: string | Context, origin?: string) => string; export declare const getAccessToken: (required: boolean) => string; export declare const getOctokit: (token?: string | undefined) => Octokit; export declare const getActor: () => string; diff --git a/node_modules/@technote-space/github-action-helper/dist/utils.js b/node_modules/@technote-space/github-action-helper/dist/utils.js index 6a24cea4..52493b93 100644 --- a/node_modules/@technote-space/github-action-helper/dist/utils.js +++ b/node_modules/@technote-space/github-action-helper/dist/utils.js @@ -30,7 +30,9 @@ exports.getBuildInfo = (filepath) => { }; exports.isCloned = (workDir) => fs_1.default.existsSync(path_1.default.resolve(workDir, '.git')); exports.isSemanticVersioningTagName = (tagName) => /^v?\d+(\.\d+)*$/i.test(tagName); -exports.isBranch = (ref) => /^(refs\/)?heads/.test(getRef(ref)); +exports.isRef = (ref) => /^refs\//.test(getRef(ref)); +exports.isBranch = (ref) => /^(refs\/)?heads\//.test(getRef(ref)); +exports.isTagRef = (ref) => /^refs\/?tags\//.test(getRef(ref)); exports.isRemoteBranch = (ref) => /^(refs\/)?remotes\/origin\//.test(getRef(ref)); exports.isPrRef = (ref) => /^refs\/pull\/\d+\/(merge|head)$/.test(getRef(ref)); exports.getPrMergeRef = (ref) => getRef(ref).replace(/^refs\/pull\/(\d+)\/(merge|head)$/, 'refs/pull/$1/merge'); @@ -41,6 +43,25 @@ exports.getBranch = (ref, defaultIsEmpty = true) => exports.isBranch(ref) ? (exports.isRemoteBranch(ref) ? getRef(ref).replace(/^(refs\/)?remotes\/origin\//, '') : (defaultIsEmpty ? '' : exports.getRefForUpdate(ref))); exports.getPrBranch = (context) => { var _a, _b; return _b = (_a = context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.head.ref, (_b !== null && _b !== void 0 ? _b : ''); }; +exports.normalizeRef = (ref) => exports.isRef(ref) ? getRef(ref) : `refs/heads/${getRef(ref)}`; +exports.trimRef = (ref) => getRef(ref).replace(/^refs\/(heads|tags|pull)\//, ''); +exports.getTag = (ref) => exports.isTagRef(ref) ? exports.trimRef(ref) : ''; +const saveTarget = (ref, origin) => exports.isTagRef(ref) ? 'tags' : exports.isPrRef(ref) ? 'pull' : origin; +// e.g. +// refs/heads/master +// refs/pull/123/merge +// refs/tags/v1.2.3 +exports.getRemoteRefspec = (ref) => exports.normalizeRef(ref); +// e.g. +// origin/master +// pull/123/merge +// tags/v1.2.3 +exports.getLocalRefspec = (ref, origin = 'origin') => `${saveTarget(ref, origin)}/${exports.trimRef(ref)}`; +// e.g. +// refs/heads/master:refs/remotes/origin/master +// refs/pull/123/merge:refs/pull/123/merge +// refs/tags/v1.2.3:refs/tags/v1.2.3 +exports.getRefspec = (ref, origin = 'origin') => `${exports.getRemoteRefspec(ref)}:refs/${exports.getLocalRefspec(ref, `remotes/${origin}`)}`; exports.getAccessToken = (required) => core_1.getInput('GITHUB_TOKEN', { required }); // eslint-disable-next-line @typescript-eslint/ban-ts-ignore // @ts-ignore diff --git a/node_modules/@technote-space/github-action-helper/package.json b/node_modules/@technote-space/github-action-helper/package.json index c79dc88e..4ac63433 100644 --- a/node_modules/@technote-space/github-action-helper/package.json +++ b/node_modules/@technote-space/github-action-helper/package.json @@ -1,6 +1,6 @@ { "name": "@technote-space/github-action-helper", - "version": "0.8.4", + "version": "1.0.6", "description": "Helper to filter GitHub Action.", "author": { "name": "Technote", @@ -32,15 +32,15 @@ "sprintf-js": "^1.1.2" }, "devDependencies": { - "@technote-space/github-action-test-helper": "^0.1.5", - "@types/jest": "^25.1.1", + "@technote-space/github-action-test-helper": "^0.2.1", + "@types/jest": "^25.1.2", "@types/node": "^13.7.0", "@typescript-eslint/eslint-plugin": "^2.19.0", "@typescript-eslint/parser": "^2.19.0", "eslint": "^6.8.0", "jest": "^25.1.0", "jest-circus": "^25.1.0", - "nock": "^11.7.2", + "nock": "^11.8.2", "ts-jest": "^25.2.0", "typescript": "^3.7.5" },