diff --git a/index.js b/index.js index 363ca92..0eacb69 100644 --- a/index.js +++ b/index.js @@ -1,9 +1,9 @@ -const core = require('@actions/core'); -const github = require('@actions/github'); +const core = require("@actions/core"); +const github = require("@actions/github"); const { SkynetClient, genKeyPairFromSeed, -} = require('@skynetlabs/skynet-nodejs'); +} = require("@skynetlabs/skynet-nodejs"); function outputAxiosErrorMessage(error) { if (error.response) { @@ -13,16 +13,16 @@ function outputAxiosErrorMessage(error) { console.log( `${method.toUpperCase()} ${path} failed with status ${status}: ${statusText}` ); - console.log(error.response.data || 'Response contained no data'); + console.log(error.response.data || "Response contained no data"); } } function prepareClientOptions() { const options = {}; - if (core.getInput('skynet-jwt')) { + if (core.getInput("skynet-jwt")) { // transform skynet-jwt into a cookie accepted format - options.customCookie = `skynet-jwt=${core.getInput('skynet-jwt')}`; + options.customCookie = `skynet-jwt=${core.getInput("skynet-jwt")}`; } return options; @@ -31,16 +31,16 @@ function prepareClientOptions() { function prepareUploadOptions() { const options = {}; - if (core.getInput('try-files')) { + if (core.getInput("try-files")) { // transform try-files input which is space separated list // of file paths into an array of those paths - options.tryFiles = core.getInput('try-files').split(/\s+/); + options.tryFiles = core.getInput("try-files").split(/\s+/); } - if (core.getInput('not-found-page')) { + if (core.getInput("not-found-page")) { // transform not-found-page input which is a single file path into // an object with a 404 key and its value being the specified path - options.errorPages = { 404: core.getInput('not-found-page') }; + options.errorPages = { 404: core.getInput("not-found-page") }; } return options; @@ -50,11 +50,11 @@ function prepareUploadOptions() { try { // upload to skynet const skynetClient = new SkynetClient( - core.getInput('portal-url'), + core.getInput("portal-url"), prepareClientOptions() ); const skylink = await skynetClient.uploadDirectory( - core.getInput('upload-dir'), + core.getInput("upload-dir"), prepareUploadOptions() ); @@ -63,17 +63,17 @@ function prepareUploadOptions() { subdomain: true, }); - core.setOutput('skylink', skylink); + core.setOutput("skylink", skylink); console.log(`Skylink: ${skylink}`); - core.setOutput('skylink-url', skylinkUrl); + core.setOutput("skylink-url", skylinkUrl); console.log(`Deployed to: ${skylinkUrl}`); // if registry is properly configured, update the skylink in the entry - if (core.getInput('registry-seed') && core.getInput('registry-datakey')) { + if (core.getInput("registry-seed") && core.getInput("registry-datakey")) { try { - const seed = core.getInput('registry-seed'); - const dataKey = core.getInput('registry-datakey'); + const seed = core.getInput("registry-seed"); + const dataKey = core.getInput("registry-datakey"); const { publicKey, privateKey } = genKeyPairFromSeed(seed); const [entryUrl, resolverSkylink] = await Promise.all([ @@ -87,10 +87,10 @@ function prepareUploadOptions() { console.log(`Registry entry updated: ${entryUrl}`); - core.setOutput('resolver-skylink-url', resolverUrl); + core.setOutput("resolver-skylink-url", resolverUrl); console.log(`Resolver Skylink Url: ${resolverUrl}`); - core.setOutput('resolver-skylink', resolverSkylink); + core.setOutput("resolver-skylink", resolverSkylink); console.log(`Resolver Skylink: ${resolverSkylink}`); } catch (error) { outputAxiosErrorMessage(error); @@ -101,7 +101,7 @@ function prepareUploadOptions() { // put a skylink in a pull request comment if available if (github.context.issue.number) { - const gitHubToken = core.getInput('github-token'); + const gitHubToken = core.getInput("github-token"); const octokit = github.getOctokit(gitHubToken); try {