Skip to content

Commit

Permalink
Bump to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
Reggionick committed Nov 9, 2020
1 parent b38d3e6 commit ba71e59
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 26 deletions.
124 changes: 99 additions & 25 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -953,13 +953,75 @@ class ExecState extends events.EventEmitter {

/***/ }),

/***/ 82:
/***/ (function(__unusedmodule, exports) {

"use strict";

// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string
*/
function toCommandValue(input) {
if (input === null || input === undefined) {
return '';
}
else if (typeof input === 'string' || input instanceof String) {
return input;
}
return JSON.stringify(input);
}
exports.toCommandValue = toCommandValue;
//# sourceMappingURL=utils.js.map

/***/ }),

/***/ 87:
/***/ (function(module) {

module.exports = require("os");

/***/ }),

/***/ 102:
/***/ (function(__unusedmodule, exports, __webpack_require__) {

"use strict";

// For internal use, subject to change.
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
const fs = __importStar(__webpack_require__(747));
const os = __importStar(__webpack_require__(87));
const utils_1 = __webpack_require__(82);
function issueCommand(command, message) {
const filePath = process.env[`GITHUB_${command}`];
if (!filePath) {
throw new Error(`Unable to find environment variable for file command ${command}`);
}
if (!fs.existsSync(filePath)) {
throw new Error(`Missing file at path: ${filePath}`);
}
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
encoding: 'utf8'
});
}
exports.issueCommand = issueCommand;
//# sourceMappingURL=file-command.js.map

/***/ }),

/***/ 104:
/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) {

Expand All @@ -974,8 +1036,10 @@ async function run() {
const distId = core.getInput('dist-id');
const invalidation = core.getInput('invalidation') || '/';
const deleteRemoved = core.getInput('delete-removed') || false;
const noCache = core.getInput('no-cache') || false;
const private = core.getInput('private') || false;

await deploy({ folder, bucket, bucketRegion, distId, invalidation, deleteRemoved });
await deploy({ folder, bucket, bucketRegion, distId, invalidation, deleteRemoved, noCache, private });
} catch (error) {
core.setFailed(error.message);
}
Expand Down Expand Up @@ -1008,21 +1072,28 @@ const exec = __webpack_require__(986);

let deploy = function (params) {
return new Promise((resolve, reject) => {
const { folder, bucket, bucketRegion, distId, invalidation, deleteRemoved } = params;
const { folder, bucket, bucketRegion, distId, invalidation, deleteRemoved, noCache, private } = params;

const deleteRemovedArg = deleteRemoved ? `--deleteRemoved ${deleteRemoved}` : '';
const deleteRemovedArg = deleteRemoved && !/false/i.test(deleteRemoved)
? /true/i.test(deleteRemoved)
? `--deleteRemoved`
: `--deleteRemoved ${deleteRemoved}`
: '';
const noCacheArg = noCache ? '--noCache' : '';
const privateArg = private ? '--private' : '';

try {
const command = `npx [email protected] ./** \
--bucket ${bucket} \
--region ${bucketRegion} \
--cwd . \
--cwd ./ \
--distId ${distId} \
--etag \
--gzip xml,html,htm,js,css,ttf,otf,svg,txt \
--invalidate "${invalidation}" \
--noCache \
${deleteRemovedArg} `;
${deleteRemovedArg} \
${noCacheArg} \
${privateArg} `;

const cwd = path.resolve(folder);
exec.exec(command, [], { cwd }).then(resolve).catch(reject);
Expand Down Expand Up @@ -1051,6 +1122,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const os = __importStar(__webpack_require__(87));
const utils_1 = __webpack_require__(82);
/**
* Commands
*
Expand Down Expand Up @@ -1104,28 +1176,14 @@ class Command {
return cmdStr;
}
}
/**
* Sanitizes an input into a string so it can be passed into issueCommand safely
* @param input input to sanitize into a string
*/
function toCommandValue(input) {
if (input === null || input === undefined) {
return '';
}
else if (typeof input === 'string' || input instanceof String) {
return input;
}
return JSON.stringify(input);
}
exports.toCommandValue = toCommandValue;
function escapeData(s) {
return toCommandValue(s)
return utils_1.toCommandValue(s)
.replace(/%/g, '%25')
.replace(/\r/g, '%0D')
.replace(/\n/g, '%0A');
}
function escapeProperty(s) {
return toCommandValue(s)
return utils_1.toCommandValue(s)
.replace(/%/g, '%25')
.replace(/\r/g, '%0D')
.replace(/\n/g, '%0A')
Expand Down Expand Up @@ -1159,6 +1217,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
};
Object.defineProperty(exports, "__esModule", { value: true });
const command_1 = __webpack_require__(431);
const file_command_1 = __webpack_require__(102);
const utils_1 = __webpack_require__(82);
const os = __importStar(__webpack_require__(87));
const path = __importStar(__webpack_require__(622));
/**
Expand All @@ -1185,9 +1245,17 @@ var ExitCode;
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function exportVariable(name, val) {
const convertedVal = command_1.toCommandValue(val);
const convertedVal = utils_1.toCommandValue(val);
process.env[name] = convertedVal;
command_1.issueCommand('set-env', { name }, convertedVal);
const filePath = process.env['GITHUB_ENV'] || '';
if (filePath) {
const delimiter = '_GitHubActionsFileCommandDelimeter_';
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
file_command_1.issueCommand('ENV', commandValue);
}
else {
command_1.issueCommand('set-env', { name }, convertedVal);
}
}
exports.exportVariable = exportVariable;
/**
Expand All @@ -1203,7 +1271,13 @@ exports.setSecret = setSecret;
* @param inputPath
*/
function addPath(inputPath) {
command_1.issueCommand('add-path', {}, inputPath);
const filePath = process.env['GITHUB_PATH'] || '';
if (filePath) {
file_command_1.issueCommand('PATH', inputPath);
}
else {
command_1.issueCommand('add-path', {}, inputPath);
}
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
}
exports.addPath = addPath;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "github-action-s3-deploy",
"version": "2.0.1",
"version": "3.0.0",
"description": "Easily deploy a static website to AWS S3 and invalidate CloudFront distribution",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit ba71e59

Please sign in to comment.