|
1 | | -"use strict"; |
2 | | -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { |
3 | | - if (k2 === undefined) k2 = k; |
4 | | - var desc = Object.getOwnPropertyDescriptor(m, k); |
5 | | - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { |
6 | | - desc = { enumerable: true, get: function() { return m[k]; } }; |
7 | | - } |
8 | | - Object.defineProperty(o, k2, desc); |
9 | | -}) : (function(o, m, k, k2) { |
10 | | - if (k2 === undefined) k2 = k; |
11 | | - o[k2] = m[k]; |
12 | | -})); |
13 | | -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { |
14 | | - Object.defineProperty(o, "default", { enumerable: true, value: v }); |
15 | | -}) : function(o, v) { |
16 | | - o["default"] = v; |
17 | | -}); |
18 | | -var __importStar = (this && this.__importStar) || (function () { |
19 | | - var ownKeys = function(o) { |
20 | | - ownKeys = Object.getOwnPropertyNames || function (o) { |
21 | | - var ar = []; |
22 | | - for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; |
23 | | - return ar; |
24 | | - }; |
25 | | - return ownKeys(o); |
26 | | - }; |
27 | | - return function (mod) { |
28 | | - if (mod && mod.__esModule) return mod; |
29 | | - var result = {}; |
30 | | - if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); |
31 | | - __setModuleDefault(result, mod); |
32 | | - return result; |
33 | | - }; |
34 | | -})(); |
35 | | -Object.defineProperty(exports, "__esModule", { value: true }); |
36 | | -exports.DefaultExcludedFiles = exports.SupportedOperatingSystems = exports.OperatingSystems = exports.Status = exports.action = exports.TestFlag = void 0; |
37 | | -const core_1 = require("@actions/core"); |
38 | | -const github = __importStar(require("@actions/github")); |
39 | | -const util_1 = require("./util"); |
| 1 | +import { getInput } from '@actions/core'; |
| 2 | +import * as github from '@actions/github'; |
| 3 | +import { isNullOrUndefined, stripProtocolFromUrl } from './util.js'; |
40 | 4 | const { pusher, repository } = github.context.payload; |
41 | 5 | /* |
42 | 6 | * Flags to signal different scenarios to test cases |
43 | 7 | */ |
44 | | -var TestFlag; |
| 8 | +export var TestFlag; |
45 | 9 | (function (TestFlag) { |
46 | 10 | TestFlag[TestFlag["NONE"] = 0] = "NONE"; |
47 | 11 | TestFlag[TestFlag["HAS_CHANGED_FILES"] = 2] = "HAS_CHANGED_FILES"; |
48 | 12 | TestFlag[TestFlag["HAS_REMOTE_BRANCH"] = 4] = "HAS_REMOTE_BRANCH"; |
49 | 13 | TestFlag[TestFlag["UNABLE_TO_REMOVE_ORIGIN"] = 8] = "UNABLE_TO_REMOVE_ORIGIN"; |
50 | 14 | TestFlag[TestFlag["UNABLE_TO_UNSET_GIT_CONFIG"] = 16] = "UNABLE_TO_UNSET_GIT_CONFIG"; |
51 | 15 | TestFlag[TestFlag["HAS_REJECTED_COMMIT"] = 32] = "HAS_REJECTED_COMMIT"; // Assume commit rejection. |
52 | | -})(TestFlag || (exports.TestFlag = TestFlag = {})); |
| 16 | +})(TestFlag || (TestFlag = {})); |
53 | 17 | /* Required action data that gets initialized when running within the GitHub Actions environment. */ |
54 | | -exports.action = { |
55 | | - folder: (0, core_1.getInput)('folder'), |
56 | | - branch: (0, core_1.getInput)('branch'), |
57 | | - commitMessage: (0, core_1.getInput)('commit-message'), |
58 | | - dryRun: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('dry-run')) |
59 | | - ? (0, core_1.getInput)('dry-run').toLowerCase() === 'true' |
| 18 | +export const action = { |
| 19 | + folder: getInput('folder'), |
| 20 | + branch: getInput('branch'), |
| 21 | + commitMessage: getInput('commit-message'), |
| 22 | + dryRun: !isNullOrUndefined(getInput('dry-run')) |
| 23 | + ? getInput('dry-run').toLowerCase() === 'true' |
60 | 24 | : false, |
61 | | - force: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('force')) |
62 | | - ? (0, core_1.getInput)('force').toLowerCase() === 'true' |
| 25 | + force: !isNullOrUndefined(getInput('force')) |
| 26 | + ? getInput('force').toLowerCase() === 'true' |
63 | 27 | : true, |
64 | | - attemptLimit: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('attempt-limit')) |
65 | | - ? parseInt((0, core_1.getInput)('attempt-limit'), 10) |
| 28 | + attemptLimit: !isNullOrUndefined(getInput('attempt-limit')) |
| 29 | + ? parseInt(getInput('attempt-limit'), 10) |
66 | 30 | : 3, |
67 | | - clean: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('clean')) |
68 | | - ? (0, core_1.getInput)('clean').toLowerCase() === 'true' |
| 31 | + clean: !isNullOrUndefined(getInput('clean')) |
| 32 | + ? getInput('clean').toLowerCase() === 'true' |
69 | 33 | : false, |
70 | | - cleanExclude: ((0, core_1.getInput)('clean-exclude') || '') |
| 34 | + cleanExclude: (getInput('clean-exclude') || '') |
71 | 35 | .split('\n') |
72 | 36 | .filter(l => l !== ''), |
73 | 37 | hostname: process.env.GITHUB_SERVER_URL |
74 | | - ? (0, util_1.stripProtocolFromUrl)(process.env.GITHUB_SERVER_URL) |
| 38 | + ? stripProtocolFromUrl(process.env.GITHUB_SERVER_URL) |
75 | 39 | : 'github.com', |
76 | 40 | isTest: TestFlag.NONE, |
77 | | - email: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('git-config-email')) |
78 | | - ? (0, core_1.getInput)('git-config-email') |
| 41 | + email: !isNullOrUndefined(getInput('git-config-email')) |
| 42 | + ? getInput('git-config-email') |
79 | 43 | : pusher && pusher.email |
80 | 44 | ? pusher.email |
81 | 45 | : `${process.env.GITHUB_ACTOR || 'github-pages-deploy-action'}@users.noreply.${process.env.GITHUB_SERVER_URL |
82 | | - ? (0, util_1.stripProtocolFromUrl)(process.env.GITHUB_SERVER_URL) |
| 46 | + ? stripProtocolFromUrl(process.env.GITHUB_SERVER_URL) |
83 | 47 | : 'github.com'}`, |
84 | | - name: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('git-config-name')) |
85 | | - ? (0, core_1.getInput)('git-config-name') |
| 48 | + name: !isNullOrUndefined(getInput('git-config-name')) |
| 49 | + ? getInput('git-config-name') |
86 | 50 | : pusher && pusher.name |
87 | 51 | ? pusher.name |
88 | 52 | : process.env.GITHUB_ACTOR |
89 | 53 | ? process.env.GITHUB_ACTOR |
90 | 54 | : 'GitHub Pages Deploy Action', |
91 | | - repositoryName: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('repository-name')) |
92 | | - ? (0, core_1.getInput)('repository-name') |
| 55 | + repositoryName: !isNullOrUndefined(getInput('repository-name')) |
| 56 | + ? getInput('repository-name') |
93 | 57 | : repository && repository.full_name |
94 | 58 | ? repository.full_name |
95 | 59 | : process.env.GITHUB_REPOSITORY, |
96 | | - token: (0, core_1.getInput)('token'), |
97 | | - singleCommit: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('single-commit')) |
98 | | - ? (0, core_1.getInput)('single-commit').toLowerCase() === 'true' |
| 60 | + token: getInput('token'), |
| 61 | + singleCommit: !isNullOrUndefined(getInput('single-commit')) |
| 62 | + ? getInput('single-commit').toLowerCase() === 'true' |
99 | 63 | : false, |
100 | | - silent: !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('silent')) |
101 | | - ? (0, core_1.getInput)('silent').toLowerCase() === 'true' |
| 64 | + silent: !isNullOrUndefined(getInput('silent')) |
| 65 | + ? getInput('silent').toLowerCase() === 'true' |
102 | 66 | : false, |
103 | | - sshKey: (0, util_1.isNullOrUndefined)((0, core_1.getInput)('ssh-key')) |
| 67 | + sshKey: isNullOrUndefined(getInput('ssh-key')) |
104 | 68 | ? false |
105 | | - : !(0, util_1.isNullOrUndefined)((0, core_1.getInput)('ssh-key')) && |
106 | | - (0, core_1.getInput)('ssh-key').toLowerCase() === 'true' |
| 69 | + : !isNullOrUndefined(getInput('ssh-key')) && |
| 70 | + getInput('ssh-key').toLowerCase() === 'true' |
107 | 71 | ? true |
108 | | - : (0, core_1.getInput)('ssh-key'), |
109 | | - targetFolder: (0, core_1.getInput)('target-folder'), |
| 72 | + : getInput('ssh-key'), |
| 73 | + targetFolder: getInput('target-folder'), |
110 | 74 | workspace: process.env.GITHUB_WORKSPACE || '', |
111 | | - tag: (0, core_1.getInput)('tag') |
| 75 | + tag: getInput('tag') |
112 | 76 | }; |
113 | 77 | /** Status codes for the action. */ |
114 | | -var Status; |
| 78 | +export var Status; |
115 | 79 | (function (Status) { |
116 | 80 | Status["SUCCESS"] = "success"; |
117 | 81 | Status["FAILED"] = "failed"; |
118 | 82 | Status["SKIPPED"] = "skipped"; |
119 | 83 | Status["RUNNING"] = "running"; |
120 | | -})(Status || (exports.Status = Status = {})); |
| 84 | +})(Status || (Status = {})); |
121 | 85 | /* Platform codes. */ |
122 | | -var OperatingSystems; |
| 86 | +export var OperatingSystems; |
123 | 87 | (function (OperatingSystems) { |
124 | 88 | OperatingSystems["LINUX"] = "Linux"; |
125 | 89 | OperatingSystems["WINDOWS"] = "Windows"; |
126 | 90 | OperatingSystems["MACOS"] = "macOS"; |
127 | | -})(OperatingSystems || (exports.OperatingSystems = OperatingSystems = {})); |
128 | | -exports.SupportedOperatingSystems = [OperatingSystems.LINUX]; |
| 91 | +})(OperatingSystems || (OperatingSystems = {})); |
| 92 | +export const SupportedOperatingSystems = [OperatingSystems.LINUX]; |
129 | 93 | /* Excluded files. */ |
130 | | -var DefaultExcludedFiles; |
| 94 | +export var DefaultExcludedFiles; |
131 | 95 | (function (DefaultExcludedFiles) { |
132 | 96 | DefaultExcludedFiles["CNAME"] = "CNAME"; |
133 | 97 | DefaultExcludedFiles["NOJEKYLL"] = ".nojekyll"; |
134 | 98 | DefaultExcludedFiles["SSH"] = ".ssh"; |
135 | 99 | DefaultExcludedFiles["GIT"] = ".git"; |
136 | 100 | DefaultExcludedFiles["GITHUB"] = ".github"; |
137 | | -})(DefaultExcludedFiles || (exports.DefaultExcludedFiles = DefaultExcludedFiles = {})); |
| 101 | +})(DefaultExcludedFiles || (DefaultExcludedFiles = {})); |
0 commit comments