diff --git a/dist/main.cjs b/dist/main.cjs index 624d752..730f1ae 100644 --- a/dist/main.cjs +++ b/dist/main.cjs @@ -1,2 +1,2 @@ -"use strict";var x=Object.create;var u=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var W=(i,e)=>{for(var t in e)u(i,t,{get:e[t],enumerable:!0})},y=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of B(e))!D.call(i,n)&&n!==t&&u(i,n,{get:()=>e[n],enumerable:!(r=A(e,n))||r.enumerable});return i};var a=(i,e,t)=>(t=i!=null?x(w(i)):{},y(e||!i||!i.__esModule?u(t,"default",{value:i,enumerable:!0}):t,i)),L=i=>y(u({},"__esModule",{value:!0}),i);var M={};W(M,{IdsToolbox:()=>v});module.exports=L(M);var g=a(require("@actions/core"),1),S=require("crypto");function E(i){let e={correlation_source:"github-actions",repository:h("GHR",["GITHUB_SERVER_URL","GITHUB_REPOSITORY_OWNER","GITHUB_REPOSITORY_OWNER_ID","GITHUB_REPOSITORY","GITHUB_REPOSITORY_ID"]),workflow:h("GHW",["GITHUB_SERVER_URL","GITHUB_REPOSITORY_OWNER","GITHUB_REPOSITORY_OWNER_ID","GITHUB_REPOSITORY","GITHUB_REPOSITORY_ID","GITHUB_WORKFLOW"]),run:h("GHWR",["GITHUB_SERVER_URL","GITHUB_REPOSITORY_OWNER","GITHUB_REPOSITORY_OWNER_ID","GITHUB_REPOSITORY","GITHUB_REPOSITORY_ID","GITHUB_RUN_ID"]),run_differentiator:h("GHWA",["GITHUB_SERVER_URL","GITHUB_REPOSITORY_OWNER","GITHUB_REPOSITORY_OWNER_ID","GITHUB_REPOSITORY","GITHUB_REPOSITORY_ID","GITHUB_RUN_ID","GITHUB_RUN_NUMBER","GITHUB_RUN_ATTEMPT"]),groups:{ci:"github-actions",project:i,github_organization:h("GHO",["GITHUB_SERVER_URL","GITHUB_REPOSITORY_OWNER","GITHUB_REPOSITORY_OWNER_ID"])}};return g.debug("Correlation data:"),g.debug(JSON.stringify(e,null,2)),e}function h(i,e){let t=(0,S.createHash)("sha256");for(let r of e){let n=process.env[r];if(n===void 0){g.debug(`Environment variable not set: ${r} -- can't generate the requested identity`);return}else t.update(n),t.update("\0")}return`${i}-${t.digest("hex")}`}var U={name:"detsys-ts",version:"1.0.0",description:"TypeScript goodies for DetSys projects",main:"./lib/main.js",types:"./lib/main.d.ts",type:"module",scripts:{build:"tsc",format:"prettier --write .",lint:"eslint src/**/*.ts",prebuild:"cp package.json ./src/package.json",package:"ncc build --license licenses.txt",all:"npm run build && npm run format && npm run lint && npm run package"},repository:{type:"git",url:"git+https://github.com/DeterminateSystems/detsys-ts.git"},keywords:[],author:"",license:"ISC",bugs:{url:"https://github.com/DeterminateSystems/detsys-ts/issues"},homepage:"https://github.com/DeterminateSystems/detsys-ts#readme",dependencies:{"@actions/cache":"^3.2.4","@actions/core":"^1.10.0","@actions/exec":"^1.1.1","@actions/github":"^5.1.1","fetch-retry":"^5.0.6",got:"^14.2.1","string-argv":"^0.3.2",uuid:"^9.0.1"},devDependencies:{"@trivago/prettier-plugin-sort-imports":"^4.3.0","@types/node":"^18.19.30","@types/uuid":"^9.0.8","@typescript-eslint/eslint-plugin":"^7.2.0","@vercel/ncc":"^0.36.1",eslint:"^8.57.0","eslint-import-resolver-typescript":"^3.6.1","eslint-plugin-github":"^4.3.6","eslint-plugin-import":"^2.29.1","eslint-plugin-prettier":"^5.0.0-alpha.1",prettier:"^3.0.0",typescript:"^5.1.6"}};var l=a(require("@actions/core"),1);function I(){let i=process.env.RUNNER_ARCH,e=process.env.RUNNER_OS;if(i&&e)return`${i}-${e}`;throw l.error(`Can't identify the platform: RUNNER_ARCH or RUNNER_OS undefined (${i}-${e})`),new Error("RUNNER_ARCH and/or RUNNER_OS is not defined")}function T(i){let t=new Map([["X64-macOS","x86_64-darwin"],["ARM64-macOS","aarch64-darwin"],["X64-Linux","x86_64-linux"],["ARM64-Linux","aarch64-linux"]]).get(i);if(t)return t;throw l.error(`ArchOs (${i}) doesn't map to a supported Nix platform.`),new Error(`Cannot convert ArchOs (${i}) to a supported Nix platform.`)}var p=a(require("@actions/core"),1);function P(i){let e=t=>{let r=C(`source-${t}`);if(!i)return r;let n=C(`${i}-${t}`);return r&&n?(p.warning(`The supported option source-${t} and the legacy option ${i}-${t} are both set. Preferring source-${t}. Please stop setting ${i}-${t}.`),r):n?(p.warning(`The legacy option ${i}-${t} is set. Please migrate to source-${t}.`),n):r};return{path:e("path"),url:e("url"),tag:e("tag"),pr:e("pr"),branch:e("branch"),revision:e("revision")}}function C(i){let e=p.getInput(i);if(e!=="")return e}var m=a(require("@actions/cache"),1),s=a(require("@actions/core"),1),O=a(require("got"),1),H=require("fs"),o=a(require("fs/promises"),1),N=require("os"),b=a(require("path"),1),G=require("stream/promises"),$=require("uuid"),R="https://install.determinate.systems",f=process.env.IDS_HOST??R,_=O.default.extend({retry:{limit:3,methods:["GET","HEAD"]},hooks:{beforeRetry:[(i,e)=>{s.info(`Retrying after error ${i.code}, retry #: ${e}`)}]}}),v=class{constructor(e){this.actionOptions=j(e),this.events=[],this.client=O.default.extend({retry:{limit:3,methods:["GET","HEAD"]},hooks:{beforeRetry:[(r,n)=>{s.info(`Retrying after error ${r.code}, retry #: ${n}`)}]}}),this.facts={$lib:"idslib",$lib_version:U.version,project:this.actionOptions.name,ids_project:this.actionOptions.idsProjectName};let t=[["github_action_ref","GITHUB_ACTION_REF"],["github_action_repository","GITHUB_ACTION_REPOSITORY"],["github_event_name","GITHUB_EVENT_NAME"],["$os","RUNNER_OS"],["arch","RUNNER_ARCH"]];for(let[r,n]of t){let c=process.env[n];c&&(this.facts[r]=c)}if(this.identity=E(this.actionOptions.name),this.archOs=I(),this.nixSystem=T(this.archOs),this.facts.arch_os=this.archOs,this.facts.nix_system=this.nixSystem,s.getState("idstoolbox_execution_phase")===""?(s.saveState("idstoolbox_execution_phase","post"),this.executionPhase="main"):this.executionPhase="post",this.facts.execution_phase=this.executionPhase,this.actionOptions.fetchStyle==="gh-env-style")this.architectureFetchSuffix=this.archOs;else if(this.actionOptions.fetchStyle==="nix-style")this.architectureFetchSuffix=this.nixSystem;else if(this.actionOptions.fetchStyle==="universal")this.architectureFetchSuffix="universal";else throw new Error(`fetchStyle ${this.actionOptions.fetchStyle} is not a valid style`);this.sourceParameters=P(this.actionOptions.legacySourcePrefix),this.recordEvent(`begin_${this.executionPhase}`)}recordEvent(e,t={}){this.events.push({event_name:`${this.actionOptions.eventPrefix}${e}`,context:t,correlation:this.identity,facts:this.facts,timestamp:new Date})}async fetch(){s.info(`Fetching from ${this.getUrl()}`);let e=this.getUrl();e.searchParams.set("ci","github"),e.searchParams.set("correlation",JSON.stringify(this.identity));let t=await _.head(e);if(t.headers.etag){let c=t.headers.etag;s.debug(`Checking the tool cache for ${this.getUrl()} at ${c}`);let d=await this.getCachedVersion(c);if(d)return this.facts.artifact_fetched_from_cache=!0,s.debug("Tool cache hit."),d}this.facts.artifact_fetched_from_cache=!1,s.debug(`No match from the cache, re-fetching from the redirect: ${t.url}`);let r=this.getTemporaryName(),n=_.stream(t.url);if(await(0,G.pipeline)(n,(0,H.createWriteStream)(r,{encoding:"binary",mode:493})),n.response?.headers.etag){let c=n.response.headers.etag;try{await this.saveCachedVersion(c,r)}catch(d){s.debug(`Error caching the artifact: ${d}`)}}return r}async fetchExecutable(){let e=await this.fetch();return await(0,o.chmod)(e,o.default.constants.S_IXUSR|o.default.constants.S_IXGRP),e}async complete(){this.recordEvent(`complete_${this.executionPhase}`),await this.submitEvents()}getUrl(){let e=this.sourceParameters;if(e.url)return new URL(e.url);let t=new URL(f);return t.pathname+=this.actionOptions.idsProjectName,e.tag?t.pathname+=`/tag/${e.tag}`:e.pr?t.pathname+=`/pr/${e.pr}`:e.branch?t.pathname+=`/branch/${e.branch}`:e.revision?t.pathname+=`/rev/${e.revision}`:t.pathname+="/stable",t.pathname+=`/${this.architectureFetchSuffix}`,t}cacheKey(e){let t=e.replace(/[^a-zA-Z0-9-+.]/g,"");return`determinatesystem-${this.actionOptions.name}-${this.architectureFetchSuffix}-${t}`}async getCachedVersion(e){let t=process.cwd();try{let r=this.getTemporaryName();if(await(0,o.mkdir)(r),process.chdir(r),process.env.GITHUB_WORKSPACE_BACKUP=process.env.GITHUB_WORKSPACE,delete process.env.GITHUB_WORKSPACE,await m.restoreCache([this.actionOptions.name],this.cacheKey(e),[],void 0,!0))return this.recordEvent("artifact_cache_hit"),`${r}/${this.actionOptions.name}`;this.recordEvent("artifact_cache_miss");return}finally{process.env.GITHUB_WORKSPACE=process.env.GITHUB_WORKSPACE_BACKUP,delete process.env.GITHUB_WORKSPACE_BACKUP,process.chdir(t)}}async saveCachedVersion(e,t){let r=process.cwd();try{let n=this.getTemporaryName();await(0,o.mkdir)(n),process.chdir(n),await(0,o.copyFile)(t,`${n}/${this.actionOptions.name}`),process.env.GITHUB_WORKSPACE_BACKUP=process.env.GITHUB_WORKSPACE,delete process.env.GITHUB_WORKSPACE,await m.saveCache([this.actionOptions.name],this.cacheKey(e),void 0,!0),this.recordEvent("artifact_cache_hit")}finally{process.env.GITHUB_WORKSPACE=process.env.GITHUB_WORKSPACE_BACKUP,delete process.env.GITHUB_WORKSPACE_BACKUP,process.chdir(r)}}async submitEvents(){if(!this.actionOptions.diagnosticsUrl){s.debug("Diagnostics are disabled. Not sending the following events:"),s.debug(JSON.stringify(this.events,void 0,2));return}let e={type:"eventlog",sent_at:new Date,events:this.events};try{await _.post(this.actionOptions.diagnosticsUrl,{json:e})}catch(t){s.debug(`Error submitting diagnostics event: ${t}`)}this.events=[]}getTemporaryName(){let e=process.env.RUNNER_TEMP||(0,N.tmpdir)();return b.join(e,`${this.actionOptions.name}-${(0,$.v4)()}`)}};function j(i){let e=i.idsProjectName??i.name,t={name:i.name,idsProjectName:e,eventPrefix:i.eventPrefix||"action:",fetchStyle:i.fetchStyle,legacySourcePrefix:i.legacySourcePrefix,diagnosticsUrl:F(e,i.diagnosticsUrl)};return s.debug("idslib options:"),s.debug(JSON.stringify(t,void 0,2)),t}function F(i,e){if(e!==null){if(e!==void 0)return e;{let t=process.env["INPUT_DIAGNOSTIC-ENDPOINT"];if(t==="")return;if(t!==void 0)try{return V(new URL(t))}catch(r){s.info(`User-provided diagnostic endpoint ignored: not a valid URL: ${r}`)}}try{let t=new URL(f);return t.pathname+=i,t.pathname+="/diagnostics",t}catch(t){s.info(`Generated diagnostic endpoint ignored: not a valid URL: ${t}`)}}}function V(i){if(R===f)return i;try{let e=new URL(R),t=new URL(f);return i.origin!==e.origin||(i.protocol=t.protocol,i.host=t.host,i.username=t.username,i.password=t.password),i}catch(e){s.info(`Default or overridden IDS host isn't a valid URL: ${e}`)}return i}0&&(module.exports={IdsToolbox}); +"use strict";var x=Object.create;var u=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var W=(i,e)=>{for(var t in e)u(i,t,{get:e[t],enumerable:!0})},y=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of B(e))!D.call(i,n)&&n!==t&&u(i,n,{get:()=>e[n],enumerable:!(r=A(e,n))||r.enumerable});return i};var a=(i,e,t)=>(t=i!=null?x(w(i)):{},y(e||!i||!i.__esModule?u(t,"default",{value:i,enumerable:!0}):t,i)),L=i=>y(u({},"__esModule",{value:!0}),i);var M={};W(M,{IdsToolbox:()=>O});module.exports=L(M);var f=a(require("@actions/core"),1),S=require("crypto");function E(i){let e={correlation_source:"github-actions",repository:h("GHR",["GITHUB_SERVER_URL","GITHUB_REPOSITORY_OWNER","GITHUB_REPOSITORY_OWNER_ID","GITHUB_REPOSITORY","GITHUB_REPOSITORY_ID"]),workflow:h("GHW",["GITHUB_SERVER_URL","GITHUB_REPOSITORY_OWNER","GITHUB_REPOSITORY_OWNER_ID","GITHUB_REPOSITORY","GITHUB_REPOSITORY_ID","GITHUB_WORKFLOW"]),run:h("GHWR",["GITHUB_SERVER_URL","GITHUB_REPOSITORY_OWNER","GITHUB_REPOSITORY_OWNER_ID","GITHUB_REPOSITORY","GITHUB_REPOSITORY_ID","GITHUB_RUN_ID"]),run_differentiator:h("GHWA",["GITHUB_SERVER_URL","GITHUB_REPOSITORY_OWNER","GITHUB_REPOSITORY_OWNER_ID","GITHUB_REPOSITORY","GITHUB_REPOSITORY_ID","GITHUB_RUN_ID","GITHUB_RUN_NUMBER","GITHUB_RUN_ATTEMPT"]),groups:{ci:"github-actions",project:i,github_organization:h("GHO",["GITHUB_SERVER_URL","GITHUB_REPOSITORY_OWNER","GITHUB_REPOSITORY_OWNER_ID"])}};return f.debug("Correlation data:"),f.debug(JSON.stringify(e,null,2)),e}function h(i,e){let t=(0,S.createHash)("sha256");for(let r of e){let n=process.env[r];if(n===void 0){f.debug(`Environment variable not set: ${r} -- can't generate the requested identity`);return}else t.update(n),t.update("\0")}return`${i}-${t.digest("hex")}`}var U={name:"detsys-ts",version:"1.0.0",description:"TypeScript goodies for DetSys projects",main:"./dist/main.cjs",types:"./dist/main.d.cts",type:"module",scripts:{build:"tsup",format:"prettier --write .",lint:"pnpm run prebuild && eslint src/**/*.ts",prebuild:"cp package.json ./src/package.json",all:"pnpm run format && pnpm run lint && pnpm run build"},repository:{type:"git",url:"git+https://github.com/DeterminateSystems/detsys-ts.git"},keywords:[],author:"",license:"ISC",bugs:{url:"https://github.com/DeterminateSystems/detsys-ts/issues"},homepage:"https://github.com/DeterminateSystems/detsys-ts#readme",dependencies:{"@actions/cache":"^3.2.4","@actions/core":"^1.10.0","@actions/exec":"^1.1.1","@actions/github":"^5.1.1","fetch-retry":"^5.0.6",got:"^14.2.1","string-argv":"^0.3.2",uuid:"^9.0.1"},devDependencies:{"@trivago/prettier-plugin-sort-imports":"^4.3.0","@types/node":"^18.19.30","@types/uuid":"^9.0.8","@typescript-eslint/eslint-plugin":"^7.2.0",eslint:"^8.57.0","eslint-import-resolver-typescript":"^3.6.1","eslint-plugin-github":"^4.3.6","eslint-plugin-import":"^2.29.1","eslint-plugin-prettier":"^5.0.0-alpha.1",prettier:"^3.0.0",tsup:"^8.0.2",typescript:"^5.1.6"}};var l=a(require("@actions/core"),1);function I(){let i=process.env.RUNNER_ARCH,e=process.env.RUNNER_OS;if(i&&e)return`${i}-${e}`;throw l.error(`Can't identify the platform: RUNNER_ARCH or RUNNER_OS undefined (${i}-${e})`),new Error("RUNNER_ARCH and/or RUNNER_OS is not defined")}function T(i){let t=new Map([["X64-macOS","x86_64-darwin"],["ARM64-macOS","aarch64-darwin"],["X64-Linux","x86_64-linux"],["ARM64-Linux","aarch64-linux"]]).get(i);if(t)return t;throw l.error(`ArchOs (${i}) doesn't map to a supported Nix platform.`),new Error(`Cannot convert ArchOs (${i}) to a supported Nix platform.`)}var p=a(require("@actions/core"),1);function P(i){let e=t=>{let r=C(`source-${t}`);if(!i)return r;let n=C(`${i}-${t}`);return r&&n?(p.warning(`The supported option source-${t} and the legacy option ${i}-${t} are both set. Preferring source-${t}. Please stop setting ${i}-${t}.`),r):n?(p.warning(`The legacy option ${i}-${t} is set. Please migrate to source-${t}.`),n):r};return{path:e("path"),url:e("url"),tag:e("tag"),pr:e("pr"),branch:e("branch"),revision:e("revision")}}function C(i){let e=p.getInput(i);if(e!=="")return e}var m=a(require("@actions/cache"),1),s=a(require("@actions/core"),1),v=a(require("got"),1),H=require("fs"),o=a(require("fs/promises"),1),N=require("os"),b=a(require("path"),1),G=require("stream/promises"),$=require("uuid"),R="https://install.determinate.systems",g=process.env.IDS_HOST??R,_=v.default.extend({retry:{limit:3,methods:["GET","HEAD"]},hooks:{beforeRetry:[(i,e)=>{s.info(`Retrying after error ${i.code}, retry #: ${e}`)}]}}),O=class{constructor(e){this.actionOptions=F(e),this.events=[],this.client=v.default.extend({retry:{limit:3,methods:["GET","HEAD"]},hooks:{beforeRetry:[(r,n)=>{s.info(`Retrying after error ${r.code}, retry #: ${n}`)}]}}),this.facts={$lib:"idslib",$lib_version:U.version,project:this.actionOptions.name,ids_project:this.actionOptions.idsProjectName};let t=[["github_action_ref","GITHUB_ACTION_REF"],["github_action_repository","GITHUB_ACTION_REPOSITORY"],["github_event_name","GITHUB_EVENT_NAME"],["$os","RUNNER_OS"],["arch","RUNNER_ARCH"]];for(let[r,n]of t){let c=process.env[n];c&&(this.facts[r]=c)}if(this.identity=E(this.actionOptions.name),this.archOs=I(),this.nixSystem=T(this.archOs),this.facts.arch_os=this.archOs,this.facts.nix_system=this.nixSystem,s.getState("idstoolbox_execution_phase")===""?(s.saveState("idstoolbox_execution_phase","post"),this.executionPhase="main"):this.executionPhase="post",this.facts.execution_phase=this.executionPhase,this.actionOptions.fetchStyle==="gh-env-style")this.architectureFetchSuffix=this.archOs;else if(this.actionOptions.fetchStyle==="nix-style")this.architectureFetchSuffix=this.nixSystem;else if(this.actionOptions.fetchStyle==="universal")this.architectureFetchSuffix="universal";else throw new Error(`fetchStyle ${this.actionOptions.fetchStyle} is not a valid style`);this.sourceParameters=P(this.actionOptions.legacySourcePrefix),this.recordEvent(`begin_${this.executionPhase}`)}recordEvent(e,t={}){this.events.push({event_name:`${this.actionOptions.eventPrefix}${e}`,context:t,correlation:this.identity,facts:this.facts,timestamp:new Date})}async fetch(){s.info(`Fetching from ${this.getUrl()}`);let e=this.getUrl();e.searchParams.set("ci","github"),e.searchParams.set("correlation",JSON.stringify(this.identity));let t=await _.head(e);if(t.headers.etag){let c=t.headers.etag;s.debug(`Checking the tool cache for ${this.getUrl()} at ${c}`);let d=await this.getCachedVersion(c);if(d)return this.facts.artifact_fetched_from_cache=!0,s.debug("Tool cache hit."),d}this.facts.artifact_fetched_from_cache=!1,s.debug(`No match from the cache, re-fetching from the redirect: ${t.url}`);let r=this.getTemporaryName(),n=_.stream(t.url);if(await(0,G.pipeline)(n,(0,H.createWriteStream)(r,{encoding:"binary",mode:493})),n.response?.headers.etag){let c=n.response.headers.etag;try{await this.saveCachedVersion(c,r)}catch(d){s.debug(`Error caching the artifact: ${d}`)}}return r}async fetchExecutable(){let e=await this.fetch();return await(0,o.chmod)(e,o.default.constants.S_IXUSR|o.default.constants.S_IXGRP),e}async complete(){this.recordEvent(`complete_${this.executionPhase}`),await this.submitEvents()}getUrl(){let e=this.sourceParameters;if(e.url)return new URL(e.url);let t=new URL(g);return t.pathname+=this.actionOptions.idsProjectName,e.tag?t.pathname+=`/tag/${e.tag}`:e.pr?t.pathname+=`/pr/${e.pr}`:e.branch?t.pathname+=`/branch/${e.branch}`:e.revision?t.pathname+=`/rev/${e.revision}`:t.pathname+="/stable",t.pathname+=`/${this.architectureFetchSuffix}`,t}cacheKey(e){let t=e.replace(/[^a-zA-Z0-9-+.]/g,"");return`determinatesystem-${this.actionOptions.name}-${this.architectureFetchSuffix}-${t}`}async getCachedVersion(e){let t=process.cwd();try{let r=this.getTemporaryName();if(await(0,o.mkdir)(r),process.chdir(r),process.env.GITHUB_WORKSPACE_BACKUP=process.env.GITHUB_WORKSPACE,delete process.env.GITHUB_WORKSPACE,await m.restoreCache([this.actionOptions.name],this.cacheKey(e),[],void 0,!0))return this.recordEvent("artifact_cache_hit"),`${r}/${this.actionOptions.name}`;this.recordEvent("artifact_cache_miss");return}finally{process.env.GITHUB_WORKSPACE=process.env.GITHUB_WORKSPACE_BACKUP,delete process.env.GITHUB_WORKSPACE_BACKUP,process.chdir(t)}}async saveCachedVersion(e,t){let r=process.cwd();try{let n=this.getTemporaryName();await(0,o.mkdir)(n),process.chdir(n),await(0,o.copyFile)(t,`${n}/${this.actionOptions.name}`),process.env.GITHUB_WORKSPACE_BACKUP=process.env.GITHUB_WORKSPACE,delete process.env.GITHUB_WORKSPACE,await m.saveCache([this.actionOptions.name],this.cacheKey(e),void 0,!0),this.recordEvent("artifact_cache_hit")}finally{process.env.GITHUB_WORKSPACE=process.env.GITHUB_WORKSPACE_BACKUP,delete process.env.GITHUB_WORKSPACE_BACKUP,process.chdir(r)}}async submitEvents(){if(!this.actionOptions.diagnosticsUrl){s.debug("Diagnostics are disabled. Not sending the following events:"),s.debug(JSON.stringify(this.events,void 0,2));return}let e={type:"eventlog",sent_at:new Date,events:this.events};try{await _.post(this.actionOptions.diagnosticsUrl,{json:e})}catch(t){s.debug(`Error submitting diagnostics event: ${t}`)}this.events=[]}getTemporaryName(){let e=process.env.RUNNER_TEMP||(0,N.tmpdir)();return b.join(e,`${this.actionOptions.name}-${(0,$.v4)()}`)}};function F(i){let e=i.idsProjectName??i.name,t={name:i.name,idsProjectName:e,eventPrefix:i.eventPrefix||"action:",fetchStyle:i.fetchStyle,legacySourcePrefix:i.legacySourcePrefix,diagnosticsUrl:k(e,i.diagnosticsUrl)};return s.debug("idslib options:"),s.debug(JSON.stringify(t,void 0,2)),t}function k(i,e){if(e!==null){if(e!==void 0)return e;{let t=process.env["INPUT_DIAGNOSTIC-ENDPOINT"];if(t==="")return;if(t!==void 0)try{return V(new URL(t))}catch(r){s.info(`User-provided diagnostic endpoint ignored: not a valid URL: ${r}`)}}try{let t=new URL(g);return t.pathname+=i,t.pathname+="/diagnostics",t}catch(t){s.info(`Generated diagnostic endpoint ignored: not a valid URL: ${t}`)}}}function V(i){if(R===g)return i;try{let e=new URL(R),t=new URL(g);return i.origin!==e.origin||(i.protocol=t.protocol,i.host=t.host,i.username=t.username,i.password=t.password),i}catch(e){s.info(`Default or overridden IDS host isn't a valid URL: ${e}`)}return i}0&&(module.exports={IdsToolbox}); //# sourceMappingURL=main.cjs.map \ No newline at end of file diff --git a/dist/main.cjs.map b/dist/main.cjs.map index e03fbe1..8588e19 100644 --- a/dist/main.cjs.map +++ b/dist/main.cjs.map @@ -1 +1 @@ -{"version":3,"sources":["../src/main.ts","../src/correlation.ts","../src/package.json","../src/platform.ts","../src/sourcedef.ts"],"sourcesContent":["import * as correlation from \"./correlation\";\n// eslint-disable-next-line import/extensions\nimport pkg from \"./package.json\";\nimport * as platform from \"./platform\";\nimport { SourceDef, constructSourceParameters } from \"./sourcedef\";\nimport * as actionsCache from \"@actions/cache\";\nimport * as actionsCore from \"@actions/core\";\nimport got, { Got } from \"got\";\nimport { createWriteStream } from \"node:fs\";\nimport fs, { chmod, copyFile, mkdir } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport * as path from \"node:path\";\nimport { pipeline } from \"node:stream/promises\";\nimport { v4 as uuidV4 } from \"uuid\";\n\nconst DEFAULT_IDS_HOST = \"https://install.determinate.systems\";\nconst IDS_HOST = process.env[\"IDS_HOST\"] ?? DEFAULT_IDS_HOST;\n\nconst gotClient = got.extend({\n retry: {\n limit: 3,\n methods: [\"GET\", \"HEAD\"],\n },\n hooks: {\n beforeRetry: [\n (error, retryCount) => {\n actionsCore.info(\n `Retrying after error ${error.code}, retry #: ${retryCount}`,\n );\n },\n ],\n },\n});\n\nexport type FetchSuffixStyle = \"nix-style\" | \"gh-env-style\" | \"universal\";\nexport type ExecutionPhase = \"main\" | \"post\";\n\nexport type ActionOptions = {\n // Name of the project generally, and the name of the binary on disk.\n name: string;\n\n // Defaults to `name`, Corresponds to the ProjectHost entry on i.d.s.\n idsProjectName?: string;\n\n // Defaults to `action:`\n eventPrefix?: string;\n\n // The \"architecture\" URL component expected by I.D.S. for the ProjectHost.\n fetchStyle: FetchSuffixStyle;\n\n // IdsToolbox assumes the GitHub Action exposes source overrides, like branch/pr/etc. to be named `source-*`.\n // This prefix adds a fallback name, prefixed by `${legacySourcePrefix}-`.\n // Users who configure legacySourcePrefix will get warnings asking them to change to `source-*`.\n legacySourcePrefix?: string;\n\n // The URL to send diagnostics events to.\n // Specifically:\n // * `undefined` -> Attempt to read the `diagnostic-enpdoint` action input, and calculate the default diagnostics URL for IDS from there.\n // * `null` -> Disable sending diagnostics altogether.\n // * URL(...) -> Send diagnostics to this other URL instead\n diagnosticsUrl?: URL | null;\n};\n\n// A confident version of Options, where defaults have been resolved into final values\ntype ConfidentActionOptions = {\n name: string;\n idsProjectName: string;\n eventPrefix: string;\n fetchStyle: FetchSuffixStyle;\n legacySourcePrefix?: string;\n diagnosticsUrl?: URL;\n};\n\ntype DiagnosticEvent = {\n event_name: string;\n correlation: correlation.AnonymizedCorrelationHashes;\n facts: Record;\n context: Record;\n timestamp: Date;\n};\n\nexport class IdsToolbox {\n private identity: correlation.AnonymizedCorrelationHashes;\n private actionOptions: ConfidentActionOptions;\n private archOs: string;\n private nixSystem: string;\n private architectureFetchSuffix: string;\n private executionPhase: ExecutionPhase;\n private sourceParameters: SourceDef;\n private facts: Record;\n private events: DiagnosticEvent[];\n private client: Got;\n\n constructor(actionOptions: ActionOptions) {\n this.actionOptions = makeOptionsConfident(actionOptions);\n this.events = [];\n this.client = got.extend({\n retry: {\n limit: 3,\n methods: [\"GET\", \"HEAD\"],\n },\n hooks: {\n beforeRetry: [\n (error, retryCount) => {\n actionsCore.info(\n `Retrying after error ${error.code}, retry #: ${retryCount}`,\n );\n },\n ],\n },\n });\n\n this.facts = {\n $lib: \"idslib\",\n $lib_version: pkg.version,\n project: this.actionOptions.name,\n ids_project: this.actionOptions.idsProjectName,\n };\n\n const params = [\n [\"github_action_ref\", \"GITHUB_ACTION_REF\"],\n [\"github_action_repository\", \"GITHUB_ACTION_REPOSITORY\"],\n [\"github_event_name\", \"GITHUB_EVENT_NAME\"],\n [\"$os\", \"RUNNER_OS\"],\n [\"arch\", \"RUNNER_ARCH\"],\n ];\n for (const [target, env] of params) {\n const value = process.env[env];\n if (value) {\n this.facts[target] = value;\n }\n }\n\n this.identity = correlation.identify(this.actionOptions.name);\n this.archOs = platform.getArchOs();\n this.nixSystem = platform.getNixPlatform(this.archOs);\n\n this.facts.arch_os = this.archOs;\n this.facts.nix_system = this.nixSystem;\n\n {\n const phase = actionsCore.getState(\"idstoolbox_execution_phase\");\n if (phase === \"\") {\n actionsCore.saveState(\"idstoolbox_execution_phase\", \"post\");\n this.executionPhase = \"main\";\n } else {\n this.executionPhase = \"post\";\n }\n this.facts.execution_phase = this.executionPhase;\n }\n\n if (this.actionOptions.fetchStyle === \"gh-env-style\") {\n this.architectureFetchSuffix = this.archOs;\n } else if (this.actionOptions.fetchStyle === \"nix-style\") {\n this.architectureFetchSuffix = this.nixSystem;\n } else if (this.actionOptions.fetchStyle === \"universal\") {\n this.architectureFetchSuffix = \"universal\";\n } else {\n throw new Error(\n `fetchStyle ${this.actionOptions.fetchStyle} is not a valid style`,\n );\n }\n\n this.sourceParameters = constructSourceParameters(\n this.actionOptions.legacySourcePrefix,\n );\n\n this.recordEvent(`begin_${this.executionPhase}`);\n }\n\n recordEvent(eventName: string, context: Record = {}): void {\n this.events.push({\n event_name: `${this.actionOptions.eventPrefix}${eventName}`,\n context,\n correlation: this.identity,\n facts: this.facts,\n timestamp: new Date(),\n });\n }\n\n async fetch(): Promise {\n actionsCore.info(`Fetching from ${this.getUrl()}`);\n\n const correlatedUrl = this.getUrl();\n correlatedUrl.searchParams.set(\"ci\", \"github\");\n correlatedUrl.searchParams.set(\n \"correlation\",\n JSON.stringify(this.identity),\n );\n\n const versionCheckup = await gotClient.head(correlatedUrl);\n if (versionCheckup.headers.etag) {\n const v = versionCheckup.headers.etag;\n\n actionsCore.debug(`Checking the tool cache for ${this.getUrl()} at ${v}`);\n const cached = await this.getCachedVersion(v);\n if (cached) {\n this.facts[\"artifact_fetched_from_cache\"] = true;\n actionsCore.debug(`Tool cache hit.`);\n return cached;\n }\n }\n\n this.facts[\"artifact_fetched_from_cache\"] = false;\n\n actionsCore.debug(\n `No match from the cache, re-fetching from the redirect: ${versionCheckup.url}`,\n );\n\n const destFile = this.getTemporaryName();\n const fetchStream = gotClient.stream(versionCheckup.url);\n\n await pipeline(\n fetchStream,\n createWriteStream(destFile, {\n encoding: \"binary\",\n mode: 0o755,\n }),\n );\n\n if (fetchStream.response?.headers.etag) {\n const v = fetchStream.response.headers.etag;\n\n try {\n await this.saveCachedVersion(v, destFile);\n } catch (e) {\n actionsCore.debug(`Error caching the artifact: ${e}`);\n }\n }\n\n return destFile;\n }\n\n async fetchExecutable(): Promise {\n const binaryPath = await this.fetch();\n await chmod(binaryPath, fs.constants.S_IXUSR | fs.constants.S_IXGRP);\n return binaryPath;\n }\n\n async complete(): Promise {\n this.recordEvent(`complete_${this.executionPhase}`);\n await this.submitEvents();\n }\n\n private getUrl(): URL {\n const p = this.sourceParameters;\n\n if (p.url) {\n return new URL(p.url);\n }\n\n const fetchUrl = new URL(IDS_HOST);\n fetchUrl.pathname += this.actionOptions.idsProjectName;\n\n if (p.tag) {\n fetchUrl.pathname += `/tag/${p.tag}`;\n } else if (p.pr) {\n fetchUrl.pathname += `/pr/${p.pr}`;\n } else if (p.branch) {\n fetchUrl.pathname += `/branch/${p.branch}`;\n } else if (p.revision) {\n fetchUrl.pathname += `/rev/${p.revision}`;\n } else {\n fetchUrl.pathname += `/stable`;\n }\n\n fetchUrl.pathname += `/${this.architectureFetchSuffix}`;\n\n return fetchUrl;\n }\n\n private cacheKey(version: string): string {\n const cleanedVersion = version.replace(/[^a-zA-Z0-9-+.]/g, \"\");\n return `determinatesystem-${this.actionOptions.name}-${this.architectureFetchSuffix}-${cleanedVersion}`;\n }\n\n private async getCachedVersion(version: string): Promise {\n const startCwd = process.cwd();\n\n try {\n const tempDir = this.getTemporaryName();\n await mkdir(tempDir);\n process.chdir(tempDir);\n\n // extremely evil shit right here:\n process.env.GITHUB_WORKSPACE_BACKUP = process.env.GITHUB_WORKSPACE;\n delete process.env.GITHUB_WORKSPACE;\n\n if (\n await actionsCache.restoreCache(\n [this.actionOptions.name],\n this.cacheKey(version),\n [],\n undefined,\n true,\n )\n ) {\n this.recordEvent(\"artifact_cache_hit\");\n return `${tempDir}/${this.actionOptions.name}`;\n }\n\n this.recordEvent(\"artifact_cache_miss\");\n return undefined;\n } finally {\n process.env.GITHUB_WORKSPACE = process.env.GITHUB_WORKSPACE_BACKUP;\n delete process.env.GITHUB_WORKSPACE_BACKUP;\n process.chdir(startCwd);\n }\n }\n\n private async saveCachedVersion(\n version: string,\n toolPath: string,\n ): Promise {\n const startCwd = process.cwd();\n\n try {\n const tempDir = this.getTemporaryName();\n await mkdir(tempDir);\n process.chdir(tempDir);\n await copyFile(toolPath, `${tempDir}/${this.actionOptions.name}`);\n\n // extremely evil shit right here:\n process.env.GITHUB_WORKSPACE_BACKUP = process.env.GITHUB_WORKSPACE;\n delete process.env.GITHUB_WORKSPACE;\n\n await actionsCache.saveCache(\n [this.actionOptions.name],\n this.cacheKey(version),\n undefined,\n true,\n );\n this.recordEvent(\"artifact_cache_hit\");\n } finally {\n process.env.GITHUB_WORKSPACE = process.env.GITHUB_WORKSPACE_BACKUP;\n delete process.env.GITHUB_WORKSPACE_BACKUP;\n process.chdir(startCwd);\n }\n }\n\n private async submitEvents(): Promise {\n if (!this.actionOptions.diagnosticsUrl) {\n actionsCore.debug(\n \"Diagnostics are disabled. Not sending the following events:\",\n );\n actionsCore.debug(JSON.stringify(this.events, undefined, 2));\n return;\n }\n\n const batch = {\n type: \"eventlog\",\n sent_at: new Date(),\n events: this.events,\n };\n\n try {\n await gotClient.post(this.actionOptions.diagnosticsUrl, {\n json: batch,\n });\n } catch (error) {\n actionsCore.debug(`Error submitting diagnostics event: ${error}`);\n }\n this.events = [];\n }\n\n private getTemporaryName(): string {\n const _tmpdir = process.env[\"RUNNER_TEMP\"] || tmpdir();\n return path.join(_tmpdir, `${this.actionOptions.name}-${uuidV4()}`);\n }\n}\n\nfunction makeOptionsConfident(\n actionOptions: ActionOptions,\n): ConfidentActionOptions {\n const idsProjectName = actionOptions.idsProjectName ?? actionOptions.name;\n\n const finalOpts: ConfidentActionOptions = {\n name: actionOptions.name,\n idsProjectName,\n eventPrefix: actionOptions.eventPrefix || \"action:\",\n fetchStyle: actionOptions.fetchStyle,\n legacySourcePrefix: actionOptions.legacySourcePrefix,\n diagnosticsUrl: determineDiagnosticsUrl(\n idsProjectName,\n actionOptions.diagnosticsUrl,\n ),\n };\n\n actionsCore.debug(\"idslib options:\");\n actionsCore.debug(JSON.stringify(finalOpts, undefined, 2));\n\n return finalOpts;\n}\n\nfunction determineDiagnosticsUrl(\n idsProjectName: string,\n urlOption?: URL | null,\n): undefined | URL {\n if (urlOption === null) {\n // Disable diagnostict events\n return undefined;\n }\n\n if (urlOption !== undefined) {\n // Caller specified a specific diagnostics URL\n return urlOption;\n }\n\n {\n // Attempt to use the action input's diagnostic-endpoint option.\n\n // Note: we don't use actionsCore.getInput('diagnostic-endpoint') on purpose:\n // getInput silently converts absent data to an empty string.\n const providedDiagnosticEndpoint = process.env[\"INPUT_DIAGNOSTIC-ENDPOINT\"];\n if (providedDiagnosticEndpoint === \"\") {\n // User probably explicitly turned it off\n return undefined;\n }\n\n if (providedDiagnosticEndpoint !== undefined) {\n try {\n return mungeDiagnosticEndpoint(new URL(providedDiagnosticEndpoint));\n } catch (e) {\n actionsCore.info(\n `User-provided diagnostic endpoint ignored: not a valid URL: ${e}`,\n );\n }\n }\n }\n\n try {\n const diagnosticUrl = new URL(IDS_HOST);\n diagnosticUrl.pathname += idsProjectName;\n diagnosticUrl.pathname += \"/diagnostics\";\n return diagnosticUrl;\n } catch (e) {\n actionsCore.info(\n `Generated diagnostic endpoint ignored: not a valid URL: ${e}`,\n );\n }\n\n return undefined;\n}\n\nfunction mungeDiagnosticEndpoint(inputUrl: URL): URL {\n if (DEFAULT_IDS_HOST === IDS_HOST) {\n return inputUrl;\n }\n\n try {\n const defaultIdsHost = new URL(DEFAULT_IDS_HOST);\n const currentIdsHost = new URL(IDS_HOST);\n\n if (inputUrl.origin !== defaultIdsHost.origin) {\n return inputUrl;\n }\n\n inputUrl.protocol = currentIdsHost.protocol;\n inputUrl.host = currentIdsHost.host;\n inputUrl.username = currentIdsHost.username;\n inputUrl.password = currentIdsHost.password;\n\n return inputUrl;\n } catch (e) {\n actionsCore.info(`Default or overridden IDS host isn't a valid URL: ${e}`);\n }\n\n return inputUrl;\n}\n","import * as actionsCore from \"@actions/core\";\nimport { createHash } from \"node:crypto\";\n\nexport type AnonymizedCorrelationHashes = {\n correlation_source: string;\n repository?: string;\n run?: string;\n run_differentiator?: string;\n workflow?: string;\n groups: Record;\n};\n\nexport function identify(projectName: string): AnonymizedCorrelationHashes {\n const ident = {\n correlation_source: \"github-actions\",\n\n repository: hashEnvironmentVariables(\"GHR\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n ]),\n workflow: hashEnvironmentVariables(\"GHW\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n ]),\n run: hashEnvironmentVariables(\"GHWR\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_RUN_ID\",\n ]),\n run_differentiator: hashEnvironmentVariables(\"GHWA\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_RUN_ID\",\n \"GITHUB_RUN_NUMBER\",\n \"GITHUB_RUN_ATTEMPT\",\n ]),\n groups: {\n ci: \"github-actions\",\n project: projectName,\n github_organization: hashEnvironmentVariables(\"GHO\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n ]),\n },\n };\n\n actionsCore.debug(\"Correlation data:\");\n actionsCore.debug(JSON.stringify(ident, null, 2));\n\n return ident;\n}\n\nfunction hashEnvironmentVariables(\n prefix: string,\n variables: string[],\n): undefined | string {\n const hash = createHash(\"sha256\");\n\n for (const varName of variables) {\n const value = process.env[varName];\n if (value === undefined) {\n actionsCore.debug(\n `Environment variable not set: ${varName} -- can't generate the requested identity`,\n );\n return undefined;\n } else {\n hash.update(value);\n hash.update(\"\\0\");\n }\n }\n\n return `${prefix}-${hash.digest(\"hex\")}`;\n}\n","{\n \"name\": \"detsys-ts\",\n \"version\": \"1.0.0\",\n \"description\": \"TypeScript goodies for DetSys projects\",\n \"main\": \"./lib/main.js\",\n \"types\": \"./lib/main.d.ts\",\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"tsc\",\n \"format\": \"prettier --write .\",\n \"lint\": \"eslint src/**/*.ts\",\n \"prebuild\": \"cp package.json ./src/package.json\",\n \"package\": \"ncc build --license licenses.txt\",\n \"all\": \"npm run build && npm run format && npm run lint && npm run package\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/DeterminateSystems/detsys-ts.git\"\n },\n \"keywords\": [],\n \"author\": \"\",\n \"license\": \"ISC\",\n \"bugs\": {\n \"url\": \"https://github.com/DeterminateSystems/detsys-ts/issues\"\n },\n \"homepage\": \"https://github.com/DeterminateSystems/detsys-ts#readme\",\n \"dependencies\": {\n \"@actions/cache\": \"^3.2.4\",\n \"@actions/core\": \"^1.10.0\",\n \"@actions/exec\": \"^1.1.1\",\n \"@actions/github\": \"^5.1.1\",\n \"fetch-retry\": \"^5.0.6\",\n \"got\": \"^14.2.1\",\n \"string-argv\": \"^0.3.2\",\n \"uuid\": \"^9.0.1\"\n },\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/node\": \"^18.19.30\",\n \"@types/uuid\": \"^9.0.8\",\n \"@typescript-eslint/eslint-plugin\": \"^7.2.0\",\n \"@vercel/ncc\": \"^0.36.1\",\n \"eslint\": \"^8.57.0\",\n \"eslint-import-resolver-typescript\": \"^3.6.1\",\n \"eslint-plugin-github\": \"^4.3.6\",\n \"eslint-plugin-import\": \"^2.29.1\",\n \"eslint-plugin-prettier\": \"^5.0.0-alpha.1\",\n \"prettier\": \"^3.0.0\",\n \"typescript\": \"^5.1.6\"\n }\n}\n","import * as actionsCore from \"@actions/core\";\n\nexport function getArchOs(): string {\n const envArch = process.env.RUNNER_ARCH;\n const envOs = process.env.RUNNER_OS;\n\n if (envArch && envOs) {\n return `${envArch}-${envOs}`;\n } else {\n actionsCore.error(\n `Can't identify the platform: RUNNER_ARCH or RUNNER_OS undefined (${envArch}-${envOs})`,\n );\n throw new Error(\"RUNNER_ARCH and/or RUNNER_OS is not defined\");\n }\n}\n\nexport function getNixPlatform(archOs: string): string {\n const archOsMap: Map = new Map([\n [\"X64-macOS\", \"x86_64-darwin\"],\n [\"ARM64-macOS\", \"aarch64-darwin\"],\n [\"X64-Linux\", \"x86_64-linux\"],\n [\"ARM64-Linux\", \"aarch64-linux\"],\n ]);\n\n const mappedTo = archOsMap.get(archOs);\n if (mappedTo) {\n return mappedTo;\n } else {\n actionsCore.error(\n `ArchOs (${archOs}) doesn't map to a supported Nix platform.`,\n );\n throw new Error(\n `Cannot convert ArchOs (${archOs}) to a supported Nix platform.`,\n );\n }\n}\n","import * as actionsCore from \"@actions/core\";\n\nexport type SourceDef = {\n path?: string;\n url?: string;\n tag?: string;\n pr?: string;\n branch?: string;\n revision?: string;\n};\n\nexport function constructSourceParameters(legacyPrefix?: string): SourceDef {\n const noisilyGetInput = (suffix: string): string | undefined => {\n const preferredInput = inputStringOrUndef(`source-${suffix}`);\n\n if (!legacyPrefix) {\n return preferredInput;\n }\n\n // Remaining is for handling cases where the legacy prefix\n // should be examined.\n const legacyInput = inputStringOrUndef(`${legacyPrefix}-${suffix}`);\n\n if (preferredInput && legacyInput) {\n actionsCore.warning(\n `The supported option source-${suffix} and the legacy option ${legacyPrefix}-${suffix} are both set. Preferring source-${suffix}. Please stop setting ${legacyPrefix}-${suffix}.`,\n );\n return preferredInput;\n } else if (legacyInput) {\n actionsCore.warning(\n `The legacy option ${legacyPrefix}-${suffix} is set. Please migrate to source-${suffix}.`,\n );\n return legacyInput;\n } else {\n return preferredInput;\n }\n };\n\n return {\n path: noisilyGetInput(\"path\"),\n url: noisilyGetInput(\"url\"),\n tag: noisilyGetInput(\"tag\"),\n pr: noisilyGetInput(\"pr\"),\n branch: noisilyGetInput(\"branch\"),\n revision: noisilyGetInput(\"revision\"),\n };\n}\n\nfunction inputStringOrUndef(name: string): string | undefined {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return undefined;\n } else {\n return value;\n }\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,IAAA,eAAAC,EAAAH,GCAA,IAAAI,EAA6B,8BAC7BC,EAA2B,kBAWpB,SAASC,EAASC,EAAkD,CACzE,IAAMC,EAAQ,CACZ,mBAAoB,iBAEpB,WAAYC,EAAyB,MAAO,CAC1C,oBACA,0BACA,6BACA,oBACA,sBACF,CAAC,EACD,SAAUA,EAAyB,MAAO,CACxC,oBACA,0BACA,6BACA,oBACA,uBACA,iBACF,CAAC,EACD,IAAKA,EAAyB,OAAQ,CACpC,oBACA,0BACA,6BACA,oBACA,uBACA,eACF,CAAC,EACD,mBAAoBA,EAAyB,OAAQ,CACnD,oBACA,0BACA,6BACA,oBACA,uBACA,gBACA,oBACA,oBACF,CAAC,EACD,OAAQ,CACN,GAAI,iBACJ,QAASF,EACT,oBAAqBE,EAAyB,MAAO,CACnD,oBACA,0BACA,4BACF,CAAC,CACH,CACF,EAEA,OAAY,QAAM,mBAAmB,EACzB,QAAM,KAAK,UAAUD,EAAO,KAAM,CAAC,CAAC,EAEzCA,CACT,CAEA,SAASC,EACPC,EACAC,EACoB,CACpB,IAAMC,KAAO,cAAW,QAAQ,EAEhC,QAAWC,KAAWF,EAAW,CAC/B,IAAMG,EAAQ,QAAQ,IAAID,CAAO,EACjC,GAAIC,IAAU,OAAW,CACX,QACV,iCAAiCD,CAAO,2CAC1C,EACA,MACF,MACED,EAAK,OAAOE,CAAK,EACjBF,EAAK,OAAO,IAAI,CAEpB,CAEA,MAAO,GAAGF,CAAM,IAAIE,EAAK,OAAO,K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B,mBAAoBA,EAAc,mBAClC,eAAgBkC,EACdF,EACAhC,EAAc,cAChB,CACF,EAEA,OAAY,QAAM,iBAAiB,EACvB,QAAM,KAAK,UAAUiC,EAAW,OAAW,CAAC,CAAC,EAElDA,CACT,CAEA,SAASC,EACPF,EACAG,EACiB,CACjB,GAAIA,IAAc,KAKlB,IAAIA,IAAc,OAEhB,OAAOA,EAGT,CAKE,IAAMC,EAA6B,QAAQ,IAAI,2BAA2B,EAC1E,GAAIA,IAA+B,GAEjC,OAGF,GAAIA,IAA+B,OACjC,GAAI,CACF,OAAOC,EAAwB,IAAI,IAAID,CAA0B,CAAC,CACpE,OAASjB,EAAG,CACE,OACV,+DAA+DA,CAAC,EAClE,CACF,CAEJ,CAEA,GAAI,CACF,IAAMmB,EAAgB,IAAI,IAAI5C,CAAQ,EACtC,OAAA4C,EAAc,UAAYN,EAC1BM,EAAc,UAAY,eACnBA,CACT,OAASnB,EAAG,CACE,OACV,2DAA2DA,CAAC,EAC9D,CACF,EAGF,CAEA,SAASkB,EAAwBE,EAAoB,CACnD,GAAI9C,IAAqBC,EACvB,OAAO6C,EAGT,GAAI,CACF,IAAMC,EAAiB,IAAI,IAAI/C,CAAgB,EACzCgD,EAAiB,IAAI,IAAI/C,CAAQ,EAEvC,OAAI6C,EAAS,SAAWC,EAAe,SAIvCD,EAAS,SAAWE,EAAe,SACnCF,EAAS,KAAOE,EAAe,KAC/BF,EAAS,SAAWE,EAAe,SACnCF,EAAS,SAAWE,EAAe,UAE5BF,CACT,OAAS,EAAG,CACE,OAAK,qDAAqD,CAAC,EAAE,CAC3E,CAEA,OAAOA,CACT","names":["main_exports","__export","IdsToolbox","__toCommonJS","actionsCore","import_node_crypto","identify","projectName","ident","hashEnvironmentVariables","prefix","variables","hash","varName","value","package_default","actionsCore","getArchOs","envArch","envOs","getNixPlatform","archOs","mappedTo","actionsCore","constructSourceParameters","legacyPrefix","noisilyGetInput","suffix","preferredInput","inputStringOrUndef","legacyInput","name","value","actionsCache","actionsCore","import_got","import_node_fs","import_promises","import_node_os","path","import_uuid","DEFAULT_IDS_HOST","IDS_HOST","gotClient","got","error","retryCount","IdsToolbox","actionOptions","makeOptionsConfident","package_default","params","target","env","value","identify","getArchOs","getNixPlatform","constructSourceParameters","eventName","context","correlatedUrl","versionCheckup","v","cached","destFile","fetchStream","e","binaryPath","fs","p","fetchUrl","version","cleanedVersion","startCwd","tempDir","toolPath","batch","_tmpdir","uuidV4","idsProjectName","finalOpts","determineDiagnosticsUrl","urlOption","providedDiagnosticEndpoint","mungeDiagnosticEndpoint","diagnosticUrl","inputUrl","defaultIdsHost","currentIdsHost"]} \ No newline at end of file +{"version":3,"sources":["../src/main.ts","../src/correlation.ts","../src/package.json","../src/platform.ts","../src/sourcedef.ts"],"sourcesContent":["import * as correlation from \"./correlation\";\n// eslint-disable-next-line import/extensions\nimport pkg from \"./package.json\";\nimport * as platform from \"./platform\";\nimport { SourceDef, constructSourceParameters } from \"./sourcedef\";\nimport * as actionsCache from \"@actions/cache\";\nimport * as actionsCore from \"@actions/core\";\nimport got, { Got } from \"got\";\nimport { createWriteStream } from \"node:fs\";\nimport fs, { chmod, copyFile, mkdir } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport * as path from \"node:path\";\nimport { pipeline } from \"node:stream/promises\";\nimport { v4 as uuidV4 } from \"uuid\";\n\nconst DEFAULT_IDS_HOST = \"https://install.determinate.systems\";\nconst IDS_HOST = process.env[\"IDS_HOST\"] ?? DEFAULT_IDS_HOST;\n\nconst gotClient = got.extend({\n retry: {\n limit: 3,\n methods: [\"GET\", \"HEAD\"],\n },\n hooks: {\n beforeRetry: [\n (error, retryCount) => {\n actionsCore.info(\n `Retrying after error ${error.code}, retry #: ${retryCount}`,\n );\n },\n ],\n },\n});\n\nexport type FetchSuffixStyle = \"nix-style\" | \"gh-env-style\" | \"universal\";\nexport type ExecutionPhase = \"main\" | \"post\";\n\nexport type ActionOptions = {\n // Name of the project generally, and the name of the binary on disk.\n name: string;\n\n // Defaults to `name`, Corresponds to the ProjectHost entry on i.d.s.\n idsProjectName?: string;\n\n // Defaults to `action:`\n eventPrefix?: string;\n\n // The \"architecture\" URL component expected by I.D.S. for the ProjectHost.\n fetchStyle: FetchSuffixStyle;\n\n // IdsToolbox assumes the GitHub Action exposes source overrides, like branch/pr/etc. to be named `source-*`.\n // This prefix adds a fallback name, prefixed by `${legacySourcePrefix}-`.\n // Users who configure legacySourcePrefix will get warnings asking them to change to `source-*`.\n legacySourcePrefix?: string;\n\n // The URL to send diagnostics events to.\n // Specifically:\n // * `undefined` -> Attempt to read the `diagnostic-enpdoint` action input, and calculate the default diagnostics URL for IDS from there.\n // * `null` -> Disable sending diagnostics altogether.\n // * URL(...) -> Send diagnostics to this other URL instead\n diagnosticsUrl?: URL | null;\n};\n\n// A confident version of Options, where defaults have been resolved into final values\ntype ConfidentActionOptions = {\n name: string;\n idsProjectName: string;\n eventPrefix: string;\n fetchStyle: FetchSuffixStyle;\n legacySourcePrefix?: string;\n diagnosticsUrl?: URL;\n};\n\ntype DiagnosticEvent = {\n event_name: string;\n correlation: correlation.AnonymizedCorrelationHashes;\n facts: Record;\n context: Record;\n timestamp: Date;\n};\n\nexport class IdsToolbox {\n private identity: correlation.AnonymizedCorrelationHashes;\n private actionOptions: ConfidentActionOptions;\n private archOs: string;\n private nixSystem: string;\n private architectureFetchSuffix: string;\n private executionPhase: ExecutionPhase;\n private sourceParameters: SourceDef;\n private facts: Record;\n private events: DiagnosticEvent[];\n private client: Got;\n\n constructor(actionOptions: ActionOptions) {\n this.actionOptions = makeOptionsConfident(actionOptions);\n this.events = [];\n this.client = got.extend({\n retry: {\n limit: 3,\n methods: [\"GET\", \"HEAD\"],\n },\n hooks: {\n beforeRetry: [\n (error, retryCount) => {\n actionsCore.info(\n `Retrying after error ${error.code}, retry #: ${retryCount}`,\n );\n },\n ],\n },\n });\n\n this.facts = {\n $lib: \"idslib\",\n $lib_version: pkg.version,\n project: this.actionOptions.name,\n ids_project: this.actionOptions.idsProjectName,\n };\n\n const params = [\n [\"github_action_ref\", \"GITHUB_ACTION_REF\"],\n [\"github_action_repository\", \"GITHUB_ACTION_REPOSITORY\"],\n [\"github_event_name\", \"GITHUB_EVENT_NAME\"],\n [\"$os\", \"RUNNER_OS\"],\n [\"arch\", \"RUNNER_ARCH\"],\n ];\n for (const [target, env] of params) {\n const value = process.env[env];\n if (value) {\n this.facts[target] = value;\n }\n }\n\n this.identity = correlation.identify(this.actionOptions.name);\n this.archOs = platform.getArchOs();\n this.nixSystem = platform.getNixPlatform(this.archOs);\n\n this.facts.arch_os = this.archOs;\n this.facts.nix_system = this.nixSystem;\n\n {\n const phase = actionsCore.getState(\"idstoolbox_execution_phase\");\n if (phase === \"\") {\n actionsCore.saveState(\"idstoolbox_execution_phase\", \"post\");\n this.executionPhase = \"main\";\n } else {\n this.executionPhase = \"post\";\n }\n this.facts.execution_phase = this.executionPhase;\n }\n\n if (this.actionOptions.fetchStyle === \"gh-env-style\") {\n this.architectureFetchSuffix = this.archOs;\n } else if (this.actionOptions.fetchStyle === \"nix-style\") {\n this.architectureFetchSuffix = this.nixSystem;\n } else if (this.actionOptions.fetchStyle === \"universal\") {\n this.architectureFetchSuffix = \"universal\";\n } else {\n throw new Error(\n `fetchStyle ${this.actionOptions.fetchStyle} is not a valid style`,\n );\n }\n\n this.sourceParameters = constructSourceParameters(\n this.actionOptions.legacySourcePrefix,\n );\n\n this.recordEvent(`begin_${this.executionPhase}`);\n }\n\n recordEvent(eventName: string, context: Record = {}): void {\n this.events.push({\n event_name: `${this.actionOptions.eventPrefix}${eventName}`,\n context,\n correlation: this.identity,\n facts: this.facts,\n timestamp: new Date(),\n });\n }\n\n async fetch(): Promise {\n actionsCore.info(`Fetching from ${this.getUrl()}`);\n\n const correlatedUrl = this.getUrl();\n correlatedUrl.searchParams.set(\"ci\", \"github\");\n correlatedUrl.searchParams.set(\n \"correlation\",\n JSON.stringify(this.identity),\n );\n\n const versionCheckup = await gotClient.head(correlatedUrl);\n if (versionCheckup.headers.etag) {\n const v = versionCheckup.headers.etag;\n\n actionsCore.debug(`Checking the tool cache for ${this.getUrl()} at ${v}`);\n const cached = await this.getCachedVersion(v);\n if (cached) {\n this.facts[\"artifact_fetched_from_cache\"] = true;\n actionsCore.debug(`Tool cache hit.`);\n return cached;\n }\n }\n\n this.facts[\"artifact_fetched_from_cache\"] = false;\n\n actionsCore.debug(\n `No match from the cache, re-fetching from the redirect: ${versionCheckup.url}`,\n );\n\n const destFile = this.getTemporaryName();\n const fetchStream = gotClient.stream(versionCheckup.url);\n\n await pipeline(\n fetchStream,\n createWriteStream(destFile, {\n encoding: \"binary\",\n mode: 0o755,\n }),\n );\n\n if (fetchStream.response?.headers.etag) {\n const v = fetchStream.response.headers.etag;\n\n try {\n await this.saveCachedVersion(v, destFile);\n } catch (e) {\n actionsCore.debug(`Error caching the artifact: ${e}`);\n }\n }\n\n return destFile;\n }\n\n async fetchExecutable(): Promise {\n const binaryPath = await this.fetch();\n await chmod(binaryPath, fs.constants.S_IXUSR | fs.constants.S_IXGRP);\n return binaryPath;\n }\n\n async complete(): Promise {\n this.recordEvent(`complete_${this.executionPhase}`);\n await this.submitEvents();\n }\n\n private getUrl(): URL {\n const p = this.sourceParameters;\n\n if (p.url) {\n return new URL(p.url);\n }\n\n const fetchUrl = new URL(IDS_HOST);\n fetchUrl.pathname += this.actionOptions.idsProjectName;\n\n if (p.tag) {\n fetchUrl.pathname += `/tag/${p.tag}`;\n } else if (p.pr) {\n fetchUrl.pathname += `/pr/${p.pr}`;\n } else if (p.branch) {\n fetchUrl.pathname += `/branch/${p.branch}`;\n } else if (p.revision) {\n fetchUrl.pathname += `/rev/${p.revision}`;\n } else {\n fetchUrl.pathname += `/stable`;\n }\n\n fetchUrl.pathname += `/${this.architectureFetchSuffix}`;\n\n return fetchUrl;\n }\n\n private cacheKey(version: string): string {\n const cleanedVersion = version.replace(/[^a-zA-Z0-9-+.]/g, \"\");\n return `determinatesystem-${this.actionOptions.name}-${this.architectureFetchSuffix}-${cleanedVersion}`;\n }\n\n private async getCachedVersion(version: string): Promise {\n const startCwd = process.cwd();\n\n try {\n const tempDir = this.getTemporaryName();\n await mkdir(tempDir);\n process.chdir(tempDir);\n\n // extremely evil shit right here:\n process.env.GITHUB_WORKSPACE_BACKUP = process.env.GITHUB_WORKSPACE;\n delete process.env.GITHUB_WORKSPACE;\n\n if (\n await actionsCache.restoreCache(\n [this.actionOptions.name],\n this.cacheKey(version),\n [],\n undefined,\n true,\n )\n ) {\n this.recordEvent(\"artifact_cache_hit\");\n return `${tempDir}/${this.actionOptions.name}`;\n }\n\n this.recordEvent(\"artifact_cache_miss\");\n return undefined;\n } finally {\n process.env.GITHUB_WORKSPACE = process.env.GITHUB_WORKSPACE_BACKUP;\n delete process.env.GITHUB_WORKSPACE_BACKUP;\n process.chdir(startCwd);\n }\n }\n\n private async saveCachedVersion(\n version: string,\n toolPath: string,\n ): Promise {\n const startCwd = process.cwd();\n\n try {\n const tempDir = this.getTemporaryName();\n await mkdir(tempDir);\n process.chdir(tempDir);\n await copyFile(toolPath, `${tempDir}/${this.actionOptions.name}`);\n\n // extremely evil shit right here:\n process.env.GITHUB_WORKSPACE_BACKUP = process.env.GITHUB_WORKSPACE;\n delete process.env.GITHUB_WORKSPACE;\n\n await actionsCache.saveCache(\n [this.actionOptions.name],\n this.cacheKey(version),\n undefined,\n true,\n );\n this.recordEvent(\"artifact_cache_hit\");\n } finally {\n process.env.GITHUB_WORKSPACE = process.env.GITHUB_WORKSPACE_BACKUP;\n delete process.env.GITHUB_WORKSPACE_BACKUP;\n process.chdir(startCwd);\n }\n }\n\n private async submitEvents(): Promise {\n if (!this.actionOptions.diagnosticsUrl) {\n actionsCore.debug(\n \"Diagnostics are disabled. Not sending the following events:\",\n );\n actionsCore.debug(JSON.stringify(this.events, undefined, 2));\n return;\n }\n\n const batch = {\n type: \"eventlog\",\n sent_at: new Date(),\n events: this.events,\n };\n\n try {\n await gotClient.post(this.actionOptions.diagnosticsUrl, {\n json: batch,\n });\n } catch (error) {\n actionsCore.debug(`Error submitting diagnostics event: ${error}`);\n }\n this.events = [];\n }\n\n private getTemporaryName(): string {\n const _tmpdir = process.env[\"RUNNER_TEMP\"] || tmpdir();\n return path.join(_tmpdir, `${this.actionOptions.name}-${uuidV4()}`);\n }\n}\n\nfunction makeOptionsConfident(\n actionOptions: ActionOptions,\n): ConfidentActionOptions {\n const idsProjectName = actionOptions.idsProjectName ?? actionOptions.name;\n\n const finalOpts: ConfidentActionOptions = {\n name: actionOptions.name,\n idsProjectName,\n eventPrefix: actionOptions.eventPrefix || \"action:\",\n fetchStyle: actionOptions.fetchStyle,\n legacySourcePrefix: actionOptions.legacySourcePrefix,\n diagnosticsUrl: determineDiagnosticsUrl(\n idsProjectName,\n actionOptions.diagnosticsUrl,\n ),\n };\n\n actionsCore.debug(\"idslib options:\");\n actionsCore.debug(JSON.stringify(finalOpts, undefined, 2));\n\n return finalOpts;\n}\n\nfunction determineDiagnosticsUrl(\n idsProjectName: string,\n urlOption?: URL | null,\n): undefined | URL {\n if (urlOption === null) {\n // Disable diagnostict events\n return undefined;\n }\n\n if (urlOption !== undefined) {\n // Caller specified a specific diagnostics URL\n return urlOption;\n }\n\n {\n // Attempt to use the action input's diagnostic-endpoint option.\n\n // Note: we don't use actionsCore.getInput('diagnostic-endpoint') on purpose:\n // getInput silently converts absent data to an empty string.\n const providedDiagnosticEndpoint = process.env[\"INPUT_DIAGNOSTIC-ENDPOINT\"];\n if (providedDiagnosticEndpoint === \"\") {\n // User probably explicitly turned it off\n return undefined;\n }\n\n if (providedDiagnosticEndpoint !== undefined) {\n try {\n return mungeDiagnosticEndpoint(new URL(providedDiagnosticEndpoint));\n } catch (e) {\n actionsCore.info(\n `User-provided diagnostic endpoint ignored: not a valid URL: ${e}`,\n );\n }\n }\n }\n\n try {\n const diagnosticUrl = new URL(IDS_HOST);\n diagnosticUrl.pathname += idsProjectName;\n diagnosticUrl.pathname += \"/diagnostics\";\n return diagnosticUrl;\n } catch (e) {\n actionsCore.info(\n `Generated diagnostic endpoint ignored: not a valid URL: ${e}`,\n );\n }\n\n return undefined;\n}\n\nfunction mungeDiagnosticEndpoint(inputUrl: URL): URL {\n if (DEFAULT_IDS_HOST === IDS_HOST) {\n return inputUrl;\n }\n\n try {\n const defaultIdsHost = new URL(DEFAULT_IDS_HOST);\n const currentIdsHost = new URL(IDS_HOST);\n\n if (inputUrl.origin !== defaultIdsHost.origin) {\n return inputUrl;\n }\n\n inputUrl.protocol = currentIdsHost.protocol;\n inputUrl.host = currentIdsHost.host;\n inputUrl.username = currentIdsHost.username;\n inputUrl.password = currentIdsHost.password;\n\n return inputUrl;\n } catch (e) {\n actionsCore.info(`Default or overridden IDS host isn't a valid URL: ${e}`);\n }\n\n return inputUrl;\n}\n","import * as actionsCore from \"@actions/core\";\nimport { createHash } from \"node:crypto\";\n\nexport type AnonymizedCorrelationHashes = {\n correlation_source: string;\n repository?: string;\n run?: string;\n run_differentiator?: string;\n workflow?: string;\n groups: Record;\n};\n\nexport function identify(projectName: string): AnonymizedCorrelationHashes {\n const ident = {\n correlation_source: \"github-actions\",\n\n repository: hashEnvironmentVariables(\"GHR\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n ]),\n workflow: hashEnvironmentVariables(\"GHW\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n ]),\n run: hashEnvironmentVariables(\"GHWR\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_RUN_ID\",\n ]),\n run_differentiator: hashEnvironmentVariables(\"GHWA\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_RUN_ID\",\n \"GITHUB_RUN_NUMBER\",\n \"GITHUB_RUN_ATTEMPT\",\n ]),\n groups: {\n ci: \"github-actions\",\n project: projectName,\n github_organization: hashEnvironmentVariables(\"GHO\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n ]),\n },\n };\n\n actionsCore.debug(\"Correlation data:\");\n actionsCore.debug(JSON.stringify(ident, null, 2));\n\n return ident;\n}\n\nfunction hashEnvironmentVariables(\n prefix: string,\n variables: string[],\n): undefined | string {\n const hash = createHash(\"sha256\");\n\n for (const varName of variables) {\n const value = process.env[varName];\n if (value === undefined) {\n actionsCore.debug(\n `Environment variable not set: ${varName} -- can't generate the requested identity`,\n );\n return undefined;\n } else {\n hash.update(value);\n hash.update(\"\\0\");\n }\n }\n\n return `${prefix}-${hash.digest(\"hex\")}`;\n}\n","{\n \"name\": \"detsys-ts\",\n \"version\": \"1.0.0\",\n \"description\": \"TypeScript goodies for DetSys projects\",\n \"main\": \"./dist/main.cjs\",\n \"types\": \"./dist/main.d.cts\",\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"format\": \"prettier --write .\",\n \"lint\": \"pnpm run prebuild && eslint src/**/*.ts\",\n \"prebuild\": \"cp package.json ./src/package.json\",\n \"all\": \"pnpm run format && pnpm run lint && pnpm run build\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/DeterminateSystems/detsys-ts.git\"\n },\n \"keywords\": [],\n \"author\": \"\",\n \"license\": \"ISC\",\n \"bugs\": {\n \"url\": \"https://github.com/DeterminateSystems/detsys-ts/issues\"\n },\n \"homepage\": \"https://github.com/DeterminateSystems/detsys-ts#readme\",\n \"dependencies\": {\n \"@actions/cache\": \"^3.2.4\",\n \"@actions/core\": \"^1.10.0\",\n \"@actions/exec\": \"^1.1.1\",\n \"@actions/github\": \"^5.1.1\",\n \"fetch-retry\": \"^5.0.6\",\n \"got\": \"^14.2.1\",\n \"string-argv\": \"^0.3.2\",\n \"uuid\": \"^9.0.1\"\n },\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/node\": \"^18.19.30\",\n \"@types/uuid\": \"^9.0.8\",\n \"@typescript-eslint/eslint-plugin\": \"^7.2.0\",\n \"eslint\": \"^8.57.0\",\n \"eslint-import-resolver-typescript\": \"^3.6.1\",\n \"eslint-plugin-github\": \"^4.3.6\",\n \"eslint-plugin-import\": \"^2.29.1\",\n \"eslint-plugin-prettier\": \"^5.0.0-alpha.1\",\n \"prettier\": \"^3.0.0\",\n \"tsup\": \"^8.0.2\",\n \"typescript\": \"^5.1.6\"\n }\n}\n","import * as actionsCore from \"@actions/core\";\n\nexport function getArchOs(): string {\n const envArch = process.env.RUNNER_ARCH;\n const envOs = process.env.RUNNER_OS;\n\n if (envArch && envOs) {\n return `${envArch}-${envOs}`;\n } else {\n actionsCore.error(\n `Can't identify the platform: RUNNER_ARCH or RUNNER_OS undefined (${envArch}-${envOs})`,\n );\n throw new Error(\"RUNNER_ARCH and/or RUNNER_OS is not defined\");\n }\n}\n\nexport function getNixPlatform(archOs: string): string {\n const archOsMap: Map = new Map([\n [\"X64-macOS\", \"x86_64-darwin\"],\n [\"ARM64-macOS\", \"aarch64-darwin\"],\n [\"X64-Linux\", \"x86_64-linux\"],\n [\"ARM64-Linux\", \"aarch64-linux\"],\n ]);\n\n const mappedTo = archOsMap.get(archOs);\n if (mappedTo) {\n return mappedTo;\n } else {\n actionsCore.error(\n `ArchOs (${archOs}) doesn't map to a supported Nix platform.`,\n );\n throw new Error(\n `Cannot convert ArchOs (${archOs}) to a supported Nix platform.`,\n );\n }\n}\n","import * as actionsCore from \"@actions/core\";\n\nexport type SourceDef = {\n path?: string;\n url?: string;\n tag?: string;\n pr?: string;\n branch?: string;\n revision?: string;\n};\n\nexport function constructSourceParameters(legacyPrefix?: string): SourceDef {\n const noisilyGetInput = (suffix: string): string | undefined => {\n const preferredInput = inputStringOrUndef(`source-${suffix}`);\n\n if (!legacyPrefix) {\n return preferredInput;\n }\n\n // Remaining is for handling cases where the legacy prefix\n // should be examined.\n const legacyInput = inputStringOrUndef(`${legacyPrefix}-${suffix}`);\n\n if (preferredInput && legacyInput) {\n actionsCore.warning(\n `The supported option source-${suffix} and the legacy option ${legacyPrefix}-${suffix} are both set. Preferring source-${suffix}. Please stop setting ${legacyPrefix}-${suffix}.`,\n );\n return preferredInput;\n } else if (legacyInput) {\n actionsCore.warning(\n `The legacy option ${legacyPrefix}-${suffix} is set. Please migrate to source-${suffix}.`,\n );\n return legacyInput;\n } else {\n return preferredInput;\n }\n };\n\n return {\n path: noisilyGetInput(\"path\"),\n url: noisilyGetInput(\"url\"),\n tag: noisilyGetInput(\"tag\"),\n pr: noisilyGetInput(\"pr\"),\n branch: noisilyGetInput(\"branch\"),\n revision: noisilyGetInput(\"revision\"),\n };\n}\n\nfunction inputStringOrUndef(name: string): string | undefined {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return undefined;\n } else {\n return value;\n }\n}\n"],"mappings":"0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,IAAA,eAAAC,EAAAH,GCAA,IAAAI,EAA6B,8BAC7BC,EAA2B,kBAWpB,SAASC,EAASC,EAAkD,CACzE,IAAMC,EAAQ,CACZ,mBAAoB,iBAEpB,WAAYC,EAAyB,MAAO,CAC1C,oBACA,0BACA,6BACA,oBACA,sBACF,CAAC,EACD,SAAUA,EAAyB,MAAO,CACxC,oBACA,0BACA,6BACA,oBACA,uBACA,iBACF,CAAC,EACD,IAAKA,EAAyB,OAAQ,CACpC,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F,EAGF,CAEA,SAASkB,EAAwBE,EAAoB,CACnD,GAAI9C,IAAqBC,EACvB,OAAO6C,EAGT,GAAI,CACF,IAAMC,EAAiB,IAAI,IAAI/C,CAAgB,EACzCgD,EAAiB,IAAI,IAAI/C,CAAQ,EAEvC,OAAI6C,EAAS,SAAWC,EAAe,SAIvCD,EAAS,SAAWE,EAAe,SACnCF,EAAS,KAAOE,EAAe,KAC/BF,EAAS,SAAWE,EAAe,SACnCF,EAAS,SAAWE,EAAe,UAE5BF,CACT,OAAS,EAAG,CACE,OAAK,qDAAqD,CAAC,EAAE,CAC3E,CAEA,OAAOA,CACT","names":["main_exports","__export","IdsToolbox","__toCommonJS","actionsCore","import_node_crypto","identify","projectName","ident","hashEnvironmentVariables","prefix","variables","hash","varName","value","package_default","actionsCore","getArchOs","envArch","envOs","getNixPlatform","archOs","mappedTo","actionsCore","constructSourceParameters","legacyPrefix","noisilyGetInput","suffix","preferredInput","inputStringOrUndef","legacyInput","name","value","actionsCache","actionsCore","import_got","import_node_fs","import_promises","import_node_os","path","import_uuid","DEFAULT_IDS_HOST","IDS_HOST","gotClient","got","error","retryCount","IdsToolbox","actionOptions","makeOptionsConfident","package_default","params","target","env","value","identify","getArchOs","getNixPlatform","constructSourceParameters","eventName","context","correlatedUrl","versionCheckup","v","cached","destFile","fetchStream","e","binaryPath","fs","p","fetchUrl","version","cleanedVersion","startCwd","tempDir","toolPath","batch","_tmpdir","uuidV4","idsProjectName","finalOpts","determineDiagnosticsUrl","urlOption","providedDiagnosticEndpoint","mungeDiagnosticEndpoint","diagnosticUrl","inputUrl","defaultIdsHost","currentIdsHost"]} \ No newline at end of file