1 | "use strict";
|
2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3 | if (k2 === undefined) k2 = k;
|
4 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5 | }) : (function(o, m, k, k2) {
|
6 | if (k2 === undefined) k2 = k;
|
7 | o[k2] = m[k];
|
8 | }));
|
9 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
10 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
11 | }) : function(o, v) {
|
12 | o["default"] = v;
|
13 | });
|
14 | var __importStar = (this && this.__importStar) || function (mod) {
|
15 | if (mod && mod.__esModule) return mod;
|
16 | var result = {};
|
17 | if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
18 | __setModuleDefault(result, mod);
|
19 | return result;
|
20 | };
|
21 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
22 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
23 | return new (P || (P = Promise))(function (resolve, reject) {
|
24 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
25 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
26 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
27 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
28 | });
|
29 | };
|
30 | Object.defineProperty(exports, "__esModule", { value: true });
|
31 | 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;
|
32 | const command_1 = require("./command");
|
33 | const file_command_1 = require("./file-command");
|
34 | const utils_1 = require("./utils");
|
35 | const os = __importStar(require("os"));
|
36 | const path = __importStar(require("path"));
|
37 | const oidc_utils_1 = require("./oidc-utils");
|
38 |
|
39 |
|
40 |
|
41 | var ExitCode;
|
42 | (function (ExitCode) {
|
43 | |
44 |
|
45 |
|
46 | ExitCode[ExitCode["Success"] = 0] = "Success";
|
47 | |
48 |
|
49 |
|
50 | ExitCode[ExitCode["Failure"] = 1] = "Failure";
|
51 | })(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 | function exportVariable(name, val) {
|
62 | const convertedVal = utils_1.toCommandValue(val);
|
63 | process.env[name] = convertedVal;
|
64 | const filePath = process.env['GITHUB_ENV'] || '';
|
65 | if (filePath) {
|
66 | return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
|
67 | }
|
68 | command_1.issueCommand('set-env', { name }, convertedVal);
|
69 | }
|
70 | exports.exportVariable = exportVariable;
|
71 |
|
72 |
|
73 |
|
74 |
|
75 | function setSecret(secret) {
|
76 | command_1.issueCommand('add-mask', {}, secret);
|
77 | }
|
78 | exports.setSecret = setSecret;
|
79 |
|
80 |
|
81 |
|
82 |
|
83 | function addPath(inputPath) {
|
84 | const filePath = process.env['GITHUB_PATH'] || '';
|
85 | if (filePath) {
|
86 | file_command_1.issueFileCommand('PATH', inputPath);
|
87 | }
|
88 | else {
|
89 | command_1.issueCommand('add-path', {}, inputPath);
|
90 | }
|
91 | process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
|
92 | }
|
93 | exports.addPath = addPath;
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 | function getInput(name, options) {
|
104 | const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
|
105 | if (options && options.required && !val) {
|
106 | throw new Error(`Input required and not supplied: ${name}`);
|
107 | }
|
108 | if (options && options.trimWhitespace === false) {
|
109 | return val;
|
110 | }
|
111 | return val.trim();
|
112 | }
|
113 | exports.getInput = getInput;
|
114 |
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 | function getMultilineInput(name, options) {
|
123 | const inputs = getInput(name, options)
|
124 | .split('\n')
|
125 | .filter(x => x !== '');
|
126 | if (options && options.trimWhitespace === false) {
|
127 | return inputs;
|
128 | }
|
129 | return inputs.map(input => input.trim());
|
130 | }
|
131 | exports.getMultilineInput = getMultilineInput;
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 | function getBooleanInput(name, options) {
|
143 | const trueValue = ['true', 'True', 'TRUE'];
|
144 | const falseValue = ['false', 'False', 'FALSE'];
|
145 | const val = getInput(name, options);
|
146 | if (trueValue.includes(val))
|
147 | return true;
|
148 | if (falseValue.includes(val))
|
149 | return false;
|
150 | throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` +
|
151 | `Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
|
152 | }
|
153 | exports.getBooleanInput = getBooleanInput;
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 | function setOutput(name, value) {
|
162 | const filePath = process.env['GITHUB_OUTPUT'] || '';
|
163 | if (filePath) {
|
164 | return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
|
165 | }
|
166 | process.stdout.write(os.EOL);
|
167 | command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value));
|
168 | }
|
169 | exports.setOutput = setOutput;
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 | function setCommandEcho(enabled) {
|
176 | command_1.issue('echo', enabled ? 'on' : 'off');
|
177 | }
|
178 | exports.setCommandEcho = setCommandEcho;
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 | function setFailed(message) {
|
188 | process.exitCode = ExitCode.Failure;
|
189 | error(message);
|
190 | }
|
191 | exports.setFailed = setFailed;
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 |
|
198 | function isDebug() {
|
199 | return process.env['RUNNER_DEBUG'] === '1';
|
200 | }
|
201 | exports.isDebug = isDebug;
|
202 |
|
203 |
|
204 |
|
205 |
|
206 | function debug(message) {
|
207 | command_1.issueCommand('debug', {}, message);
|
208 | }
|
209 | exports.debug = debug;
|
210 |
|
211 |
|
212 |
|
213 |
|
214 |
|
215 | function error(message, properties = {}) {
|
216 | command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
217 | }
|
218 | exports.error = error;
|
219 |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 | function warning(message, properties = {}) {
|
225 | command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
226 | }
|
227 | exports.warning = warning;
|
228 |
|
229 |
|
230 |
|
231 |
|
232 |
|
233 | function notice(message, properties = {}) {
|
234 | command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
|
235 | }
|
236 | exports.notice = notice;
|
237 |
|
238 |
|
239 |
|
240 |
|
241 | function info(message) {
|
242 | process.stdout.write(message + os.EOL);
|
243 | }
|
244 | exports.info = info;
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 | function startGroup(name) {
|
253 | command_1.issue('group', name);
|
254 | }
|
255 | exports.startGroup = startGroup;
|
256 |
|
257 |
|
258 |
|
259 | function endGroup() {
|
260 | command_1.issue('endgroup');
|
261 | }
|
262 | exports.endGroup = endGroup;
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 | function group(name, fn) {
|
272 | return __awaiter(this, void 0, void 0, function* () {
|
273 | startGroup(name);
|
274 | let result;
|
275 | try {
|
276 | result = yield fn();
|
277 | }
|
278 | finally {
|
279 | endGroup();
|
280 | }
|
281 | return result;
|
282 | });
|
283 | }
|
284 | exports.group = group;
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 | function saveState(name, value) {
|
296 | const filePath = process.env['GITHUB_STATE'] || '';
|
297 | if (filePath) {
|
298 | return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
|
299 | }
|
300 | command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
|
301 | }
|
302 | exports.saveState = saveState;
|
303 |
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 | function getState(name) {
|
310 | return process.env[`STATE_${name}`] || '';
|
311 | }
|
312 | exports.getState = getState;
|
313 | function getIDToken(aud) {
|
314 | return __awaiter(this, void 0, void 0, function* () {
|
315 | return yield oidc_utils_1.OidcClient.getIDToken(aud);
|
316 | });
|
317 | }
|
318 | exports.getIDToken = getIDToken;
|
319 |
|
320 |
|
321 |
|
322 | var summary_1 = require("./summary");
|
323 | Object.defineProperty(exports, "summary", { enumerable: true, get: function () { return summary_1.summary; } });
|
324 |
|
325 |
|
326 |
|
327 | var summary_2 = require("./summary");
|
328 | Object.defineProperty(exports, "markdownSummary", { enumerable: true, get: function () { return summary_2.markdownSummary; } });
|
329 |
|
330 |
|
331 |
|
332 | var path_utils_1 = require("./path-utils");
|
333 | Object.defineProperty(exports, "toPosixPath", { enumerable: true, get: function () { return path_utils_1.toPosixPath; } });
|
334 | Object.defineProperty(exports, "toWin32Path", { enumerable: true, get: function () { return path_utils_1.toWin32Path; } });
|
335 | Object.defineProperty(exports, "toPlatformPath", { enumerable: true, get: function () { return path_utils_1.toPlatformPath; } });
|
336 |
|
\ | No newline at end of file |