Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
flagarde committed Jul 15, 2024
1 parent 02f9ba1 commit ac014b0
Show file tree
Hide file tree
Showing 4 changed files with 291 additions and 14 deletions.
233 changes: 224 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3059,6 +3059,109 @@ function copyFile(srcFile, destFile, force) {
}
//# sourceMappingURL=io.js.map

/***/ }),

/***/ 3455:
/***/ (function(module, exports, __nccwpck_require__) {

"use strict";

var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getInput = void 0;
var dotenv_1 = __importDefault(__nccwpck_require__(8603));
dotenv_1.default.config();
var VALID_TYPES = ['string', 'array', 'boolean', 'number'];
var DEFAULT_OPTIONS = {
required: false,
type: 'string',
disableable: false
};
var getEnvVar = function (key) {
var parsed = process.env["INPUT_".concat(key.replace(/ /g, '_').toUpperCase())];
var raw = process.env[key];
return parsed || raw || undefined;
};
var parseArray = function (val) {
var array = val.split('\n').join(',').split(',');
var filtered = array.filter(function (n) { return n; });
return filtered.map(function (n) { return n.trim(); });
};
var parseBoolean = function (val) {
var trueValue = ['true', 'True', 'TRUE'];
var falseValue = ['false', 'False', 'FALSE'];
if (trueValue.includes(val))
return true;
if (falseValue.includes(val))
return false;
throw new Error('boolean input has to be one of \`true | True | TRUE | false | False | FALSE\`');
};
var parseNumber = function (val) {
var parsed = Number(val);
if (isNaN(parsed))
throw new Error('input has to be a valid number');
return parsed;
};
var parseValue = function (val, type) {
if (type === 'array') {
return parseArray(val);
}
if (type === 'boolean') {
return parseBoolean(val);
}
if (type === 'number') {
return parseNumber(val);
}
return val.trim();
};
var getInput = function (key, opts) {
var parsedOptions;
if (typeof key === 'string' || Array.isArray(key)) {
parsedOptions = __assign({ key: key }, opts);
}
else if (typeof key === 'object') {
parsedOptions = key;
}
else {
throw new Error('No key for input specified');
}
if (!parsedOptions.key)
throw new Error('No key for input specified');
var options = Object.assign({}, DEFAULT_OPTIONS, parsedOptions);
if (VALID_TYPES.includes(options.type) === false)
throw new Error('option type has to be one of `string | array | boolean | number`');
var val = typeof options.key === 'string' ? getEnvVar(options.key) : options.key.map(function (key) { return getEnvVar(key); }).filter(function (item) { return item; })[0];
if (options.disableable && val === 'false')
return undefined;
var parsed = val !== undefined ? parseValue(val, options.type) : undefined;
if (parsed === undefined) {
if (options.required)
throw new Error("Input `".concat(options.key, "` is required but was not provided."));
if (options.default !== undefined)
return options.default;
return undefined;
}
if (options.modifier)
return options.modifier(parsed);
return parsed;
};
exports.getInput = getInput;
module.exports.getInput = exports.getInput;


/***/ }),

/***/ 7568:
Expand Down Expand Up @@ -3281,6 +3384,126 @@ function copyFile(srcFile, destFile, force) {
//# sourceMappingURL=index.js.map


/***/ }),

/***/ 8603:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

/* @flow */
/*::

type DotenvParseOptions = {
debug?: boolean
}

// keys and values from src
type DotenvParseOutput = { [string]: string }

type DotenvConfigOptions = {
path?: string, // path to .env file
encoding?: string, // encoding of .env file
debug?: string // turn on logging for debugging purposes
}

type DotenvConfigOutput = {
parsed?: DotenvParseOutput,
error?: Error
}

*/

const fs = __nccwpck_require__(7147)
const path = __nccwpck_require__(1017)

function log (message /*: string */) {
console.log(`[dotenv][DEBUG] ${message}`)
}

const NEWLINE = '\n'
const RE_INI_KEY_VAL = /^\s*([\w.-]+)\s*=\s*(.*)?\s*$/
const RE_NEWLINES = /\\n/g
const NEWLINES_MATCH = /\n|\r|\r\n/

// Parses src into an Object
function parse (src /*: string | Buffer */, options /*: ?DotenvParseOptions */) /*: DotenvParseOutput */ {
const debug = Boolean(options && options.debug)
const obj = {}

// convert Buffers before splitting into lines and processing
src.toString().split(NEWLINES_MATCH).forEach(function (line, idx) {
// matching "KEY' and 'VAL' in 'KEY=VAL'
const keyValueArr = line.match(RE_INI_KEY_VAL)
// matched?
if (keyValueArr != null) {
const key = keyValueArr[1]
// default undefined or missing values to empty string
let val = (keyValueArr[2] || '')
const end = val.length - 1
const isDoubleQuoted = val[0] === '"' && val[end] === '"'
const isSingleQuoted = val[0] === "'" && val[end] === "'"

// if single or double quoted, remove quotes
if (isSingleQuoted || isDoubleQuoted) {
val = val.substring(1, end)

// if double quoted, expand newlines
if (isDoubleQuoted) {
val = val.replace(RE_NEWLINES, NEWLINE)
}
} else {
// remove surrounding whitespace
val = val.trim()
}

obj[key] = val
} else if (debug) {
log(`did not match key and value when parsing line ${idx + 1}: ${line}`)
}
})

return obj
}

// Populates process.env from .env file
function config (options /*: ?DotenvConfigOptions */) /*: DotenvConfigOutput */ {
let dotenvPath = path.resolve(process.cwd(), '.env')
let encoding /*: string */ = 'utf8'
let debug = false

if (options) {
if (options.path != null) {
dotenvPath = options.path
}
if (options.encoding != null) {
encoding = options.encoding
}
if (options.debug != null) {
debug = true
}
}

try {
// specifying an encoding returns a string instead of a buffer
const parsed = parse(fs.readFileSync(dotenvPath, { encoding }), { debug })

Object.keys(parsed).forEach(function (key) {
if (!Object.prototype.hasOwnProperty.call(process.env, key)) {
process.env[key] = parsed[key]
} else if (debug) {
log(`"${key}" is already defined in \`process.env\` and will not be overwritten`)
}
})

return { parsed }
} catch (e) {
return { error: e }
}
}

module.exports.config = config
module.exports.parse = parse


/***/ }),

/***/ 7582:
Expand Down Expand Up @@ -26367,14 +26590,6 @@ function version(uuid) {
var _default = version;
exports["default"] = _default;

/***/ }),

/***/ 8614:
/***/ ((module) => {

module.exports = eval("require")("action-input-parser");


/***/ }),

/***/ 9491:
Expand Down Expand Up @@ -28285,7 +28500,7 @@ var __webpack_exports__ = {};
(() => {
const exec = __nccwpck_require__(1372)
const compare_version = __nccwpck_require__(7568)
const parser = __nccwpck_require__(8614)
const parser = __nccwpck_require__(3455)
const core = __nccwpck_require__(6519);

/*const which = require('which')
Expand Down
52 changes: 47 additions & 5 deletions dist/licenses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,30 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.

@vercel/ncc
action-input-parser
MIT
Copyright 2018 ZEIT, Inc.
MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Copyright (c) 2021 Maximilian Schiller

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

compare-versions
MIT
Expand All @@ -116,6 +131,33 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


dotenv
BSD-2-Clause
Copyright (c) 2015, Scott Motte
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


tunnel
MIT
The MIT License (MIT)
Expand Down
19 changes: 19 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/exec": "^1.1.1",
"action-input-parser": "^1.2.38",
"compare-versions": "^6.1.1"
}
}

0 comments on commit ac014b0

Please sign in to comment.