From a25881abb277496469d602a163e29b9bf55d9c95 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Sat, 20 Apr 2024 21:59:46 -0300 Subject: [PATCH 1/6] Copy linux-release-info into repo --- .eslintignore | 1 + dist/index.js | 144 ++++++++++++++++++++++-- dist/index.js.map | 2 +- package.json | 1 - pnpm-lock.yaml | 8 -- src/actions-core-platform.ts | 2 +- src/linux-release-info.ts | 207 +++++++++++++++++++++++++++++++++++ tsup.config.ts | 1 - 8 files changed, 342 insertions(+), 24 deletions(-) create mode 100644 .eslintignore create mode 100644 src/linux-release-info.ts diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..4aa57e2 --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +src/linux-release-info.ts diff --git a/dist/index.js b/dist/index.js index 23e26a9..8363cec 100644 --- a/dist/index.js +++ b/dist/index.js @@ -7,11 +7,121 @@ var __export = (target, all) => { // package.json var version = "1.0.0"; +// src/linux-release-info.ts +import * as fs from "node:fs"; +import * as os from "node:os"; +import { promisify } from "node:util"; +var readFileAsync = promisify(fs.readFile); +var linuxReleaseInfoOptionsDefaults = { + mode: "async", + custom_file: null, + debug: false +}; +function releaseInfo(options) { + options = { ...linuxReleaseInfoOptionsDefaults, ...options }; + const searchOsreleaseFileList = osreleaseFileList( + options.custom_file + ); + async function readAsyncOsreleaseFile(searchOsreleaseFileList2, options2) { + let fileData = null; + for (let os_release_file of searchOsreleaseFileList2) { + try { + if (options2.debug) { + console.log(`Trying to read '${os_release_file}'...`); + } + fileData = await readFileAsync(os_release_file, "binary"); + if (options2.debug) { + console.log("Read data:\n" + fileData); + } + break; + } catch (error2) { + if (options2.debug) { + console.error(error2); + } + } + } + if (fileData === null) { + throw new Error("Cannot read os-release file!"); + } + return formatFileData(getOsInfo(), fileData); + } + function readSyncOsreleaseFile(searchOsreleaseFileList2, options2) { + let fileData = null; + for (let os_release_file of searchOsreleaseFileList2) { + try { + if (options2.debug) { + console.log(`Trying to read '${os_release_file}'...`); + } + fileData = fs.readFileSync(os_release_file, "binary"); + if (options2.debug) { + console.log("Read data:\n" + fileData); + } + break; + } catch (error2) { + if (options2.debug) { + console.error(error2); + } + } + } + if (fileData === null) { + throw new Error("Cannot read os-release file!"); + } + return formatFileData(getOsInfo(), fileData); + } + if (os.type() !== "Linux") { + if (options.mode === "sync") { + return getOsInfo(); + } else { + return Promise.resolve(getOsInfo()); + } + } + if (options.mode === "sync") { + return readSyncOsreleaseFile(searchOsreleaseFileList, options); + } else { + return Promise.resolve( + readAsyncOsreleaseFile(searchOsreleaseFileList, options) + ); + } +} +function formatFileData(sourceData, srcParseData) { + const lines = srcParseData.split("\n"); + lines.forEach((element) => { + const linedata = element.split("="); + if (linedata.length === 2) { + linedata[1] = linedata[1].replace(/["'\r]/gi, ""); + Object.defineProperty(sourceData, linedata[0].toLowerCase(), { + value: linedata[1], + writable: true, + enumerable: true, + configurable: true + }); + } + }); + return sourceData; +} +function osreleaseFileList(customFile) { + const DEFAULT_OS_RELEASE_FILES = ["/etc/os-release", "/usr/lib/os-release"]; + if (!customFile) { + return DEFAULT_OS_RELEASE_FILES; + } else { + return Array(customFile); + } +} +function getOsInfo() { + const osInfo = { + type: os.type(), + platform: os.platform(), + hostname: os.hostname(), + arch: os.arch(), + release: os.release() + }; + return osInfo; +} + // src/actions-core-platform.ts import * as core from "@actions/core"; import * as exec from "@actions/exec"; -import { releaseInfo } from "linux-release-info"; -import os from "os"; +import os2 from "os"; var getWindowsInfo = async () => { const { stdout: version2 } = await exec.getExecOutput( 'powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Version"', @@ -83,16 +193,16 @@ function getPropertyWithDefault(data, name, defaultValue) { } return value; } -var platform = os.platform(); -var arch = os.arch(); -var isWindows = platform === "win32"; -var isMacOS = platform === "darwin"; -var isLinux = platform === "linux"; +var platform2 = os2.platform(); +var arch2 = os2.arch(); +var isWindows = platform2 === "win32"; +var isMacOS = platform2 === "darwin"; +var isLinux = platform2 === "linux"; async function getDetails() { return { ...await (isWindows ? getWindowsInfo() : isMacOS ? getMacOsInfo() : getLinuxInfo()), - platform, - arch, + platform: platform2, + arch: arch2, isWindows, isMacOS, isLinux @@ -318,7 +428,7 @@ import * as actionsCore5 from "@actions/core"; import got from "got"; import { randomUUID } from "node:crypto"; import { createWriteStream } from "node:fs"; -import fs, { chmod, copyFile, mkdir } from "node:fs/promises"; +import fs2, { chmod, copyFile, mkdir } from "node:fs/promises"; import { tmpdir } from "node:os"; import * as path from "node:path"; import { pipeline } from "node:stream/promises"; @@ -519,7 +629,7 @@ var IdsToolbox = class { } async fetchExecutable() { const binaryPath = await this.fetch(); - await chmod(binaryPath, fs.constants.S_IXUSR | fs.constants.S_IXGRP); + await chmod(binaryPath, fs2.constants.S_IXUSR | fs2.constants.S_IXGRP); return binaryPath; } async complete() { @@ -605,7 +715,7 @@ var IdsToolbox = class { for (const location of pathParts) { const candidateNix = path.join(location, "nix"); try { - await fs.access(candidateNix, fs.constants.X_OK); + await fs2.access(candidateNix, fs2.constants.X_OK); actionsCore5.debug(`Found Nix at ${candidateNix}`); nixLocation = candidateNix; } catch { @@ -744,4 +854,14 @@ export { inputs_exports as inputs, platform_exports as platform }; +/*! + * linux-release-info + * Get Linux release info (distribution name, version, arch, release, etc.) + * from '/etc/os-release' or '/usr/lib/os-release' files and from native os + * module. On Windows and Darwin platforms it only returns common node os module + * info (platform, hostname, release, and arch) + * + * Licensed under MIT + * Copyright (c) 2018-2020 [Samuel Carreira] + */ //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map index 2c980b9..3f41f9f 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../package.json","../src/actions-core-platform.ts","../src/correlation.ts","../src/platform.ts","../src/inputs.ts","../src/sourcedef.ts","../src/index.ts"],"sourcesContent":["{\n \"name\": \"detsys-ts\",\n \"version\": \"1.0.0\",\n \"description\": \"TypeScript goodies for DetSys projects\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"check-fmt\": \"prettier --check .\",\n \"format\": \"prettier --write .\",\n \"lint\": \"eslint src/**/*.ts\",\n \"docs\": \"typedoc src/index.ts\",\n \"all\": \"rm -rf dist && 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\": \"MIT\",\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.1\",\n \"@actions/exec\": \"^1.1.1\",\n \"got\": \"^14.2.1\"\n },\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/node\": \"^20.12.7\",\n \"@typescript-eslint/eslint-plugin\": \"^7.6.0\",\n \"eslint\": \"^8.57.0\",\n \"eslint-import-resolver-typescript\": \"^3.6.1\",\n \"eslint-plugin-github\": \"^4.10.2\",\n \"eslint-plugin-import\": \"^2.29.1\",\n \"eslint-plugin-prettier\": \"^5.1.3\",\n \"linux-release-info\": \"^3.0.0\",\n \"prettier\": \"^3.2.5\",\n \"tsup\": \"^8.0.2\",\n \"typedoc\": \"^0.25.13\",\n \"typescript\": \"^5.4.5\"\n }\n}\n","// MIT, mostly lifted from https://github.com/actions/toolkit/blob/5a736647a123ecf8582376bdaee833fbae5b3847/packages/core/src/platform.ts\n// since it isn't in @actions/core 1.10.1 which is their current release as 2024-04-19.\n// Changes: Replaced the lsb_release call in Linux with `linux-release-info` to parse the os-release file directly.\nimport * as core from \"@actions/core\";\nimport * as exec from \"@actions/exec\";\nimport { releaseInfo } from \"linux-release-info\";\nimport os from \"os\";\n\n/**\n * The name and version of the Action runner's system.\n */\ntype SystemInfo = {\n name: string;\n version: string;\n};\n\n/**\n * Get the name and version of the current Windows system.\n */\nconst getWindowsInfo = async (): Promise => {\n const { stdout: version } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Version\"',\n undefined,\n {\n silent: true,\n },\n );\n\n const { stdout: name } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Caption\"',\n undefined,\n {\n silent: true,\n },\n );\n\n return {\n name: name.trim(),\n version: version.trim(),\n };\n};\n\n/**\n * Get the name and version of the current macOS system.\n */\nconst getMacOsInfo = async (): Promise => {\n const { stdout } = await exec.getExecOutput(\"sw_vers\", undefined, {\n silent: true,\n });\n\n const version = stdout.match(/ProductVersion:\\s*(.+)/)?.[1] ?? \"\";\n const name = stdout.match(/ProductName:\\s*(.+)/)?.[1] ?? \"\";\n\n return {\n name,\n version,\n };\n};\n\n/**\n * Get the name and version of the current Linux system.\n */\nconst getLinuxInfo = async (): Promise => {\n let data: object = {};\n\n try {\n data = releaseInfo({ mode: \"sync\" });\n // eslint-disable-next-line no-console\n console.log(data);\n } catch (e) {\n core.debug(`Error collecting release info: ${e}`);\n }\n\n return {\n name: getPropertyViaWithDefault(\n data,\n [\"id\", \"name\", \"pretty_name\", \"id_like\"],\n \"unknown\",\n ),\n version: getPropertyViaWithDefault(\n data,\n [\"version_id\", \"version\", \"version_codename\"],\n \"unknown\",\n ),\n };\n};\n\nfunction getPropertyViaWithDefault(\n data: object,\n names: Property[],\n defaultValue: T,\n): T {\n for (const name of names) {\n const ret: T = getPropertyWithDefault(data, name, defaultValue);\n\n if (ret !== defaultValue) {\n return ret;\n }\n }\n\n return defaultValue;\n}\n\nfunction getPropertyWithDefault(\n data: object,\n name: Property,\n defaultValue: T,\n): T {\n if (!data.hasOwnProperty(name)) {\n return defaultValue;\n }\n\n const value = (data as { [K in Property]: T })[name];\n\n // NB. this check won't work for object instances\n if (typeof value !== typeof defaultValue) {\n return defaultValue;\n }\n\n return value;\n}\n\n/**\n * The Action runner's platform.\n */\nexport const platform = os.platform();\n\n/**\n * The Action runner's architecture.\n */\nexport const arch = os.arch();\n\n/**\n * Whether the Action runner is a Windows system.\n */\nexport const isWindows = platform === \"win32\";\n\n/**\n * Whether the Action runner is a macOS system.\n */\nexport const isMacOS = platform === \"darwin\";\n\n/**\n * Whether the Action runner is a Linux system.\n */\nexport const isLinux = platform === \"linux\";\n\n/**\n * System-level information about the current host (platform, architecture, etc.).\n */\ntype SystemDetails = {\n name: string;\n platform: string;\n arch: string;\n version: string;\n isWindows: boolean;\n isMacOS: boolean;\n isLinux: boolean;\n};\n\n/**\n * Get system-level information about the current host (platform, architecture, etc.).\n */\nexport async function getDetails(): Promise {\n return {\n ...(await (isWindows\n ? getWindowsInfo()\n : isMacOS\n ? getMacOsInfo()\n : getLinuxInfo())),\n platform,\n arch,\n isWindows,\n isMacOS,\n isLinux,\n };\n}\n","import * as actionsCore from \"@actions/core\";\nimport { createHash } from \"node:crypto\";\n\nconst OPTIONAL_VARIABLES = [\"INVOCATION_ID\"];\n\n// JSON sent to server\n/* eslint-disable camelcase */\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 job: hashEnvironmentVariables(\"GHWJ\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n ]),\n run: hashEnvironmentVariables(\"GHWJR\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n ]),\n run_differentiator: hashEnvironmentVariables(\"GHWJA\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n \"GITHUB_RUN_NUMBER\",\n \"GITHUB_RUN_ATTEMPT\",\n \"INVOCATION_ID\",\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 let value = process.env[varName];\n\n if (value === undefined) {\n if (OPTIONAL_VARIABLES.includes(varName)) {\n actionsCore.debug(\n `Optional environment variable not set: ${varName} -- substituting with the variable name`,\n );\n value = varName;\n } else {\n actionsCore.debug(\n `Environment variable not set: ${varName} -- can't generate the requested identity`,\n );\n return undefined;\n }\n }\n\n hash.update(value);\n hash.update(\"\\0\");\n }\n\n return `${prefix}-${hash.digest(\"hex\")}`;\n}\n","/**\n * @packageDocumentation\n * Helpers for determining system attributes of the current runner.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get the current architecture plus OS. Examples include `X64-Linux` and `ARM64-macOS`.\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\n/**\n * Get the current Nix system. Examples include `x86_64-linux` and `aarch64-darwin`.\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","/**\n * @packageDocumentation\n * Helpers for getting values from an Action's configuration.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get a Boolean input from the Action's configuration by name.\n */\nconst getBool = (name: string): boolean => {\n return actionsCore.getBooleanInput(name);\n};\n\n/**\n * Get a multi-line string input from the Action's configuration by name or return `null` if not set.\n */\nconst getMultilineStringOrNull = (name: string): string[] | null => {\n const value = actionsCore.getMultilineInput(name);\n if (value.length === 0) {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a number input from the Action's configuration by name or return `null` if not set.\n */\nconst getNumberOrNull = (name: string): number | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return Number(value);\n }\n};\n\n/**\n * Get a string input from the Action's configuration.\n */\nconst getString = (name: string): string => {\n return actionsCore.getInput(name);\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `null` if not set.\n */\nconst getStringOrNull = (name: string): string | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `undefined` if not set.\n */\nconst getStringOrUndefined = (name: string): string | undefined => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return undefined;\n } else {\n return value;\n }\n};\n\nexport {\n getBool,\n getMultilineStringOrNull,\n getNumberOrNull,\n getString,\n getStringOrNull,\n getStringOrUndefined,\n};\n","import { getStringOrUndefined } from \"./inputs.js\";\nimport * 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 = getStringOrUndefined(`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 = getStringOrUndefined(`${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","/**\n * @packageDocumentation\n * Determinate Systems' TypeScript library for creating GitHub Actions logic.\n */\nimport { version as pkgVersion } from \"../package.json\";\nimport * as ghActionsCorePlatform from \"./actions-core-platform.js\";\nimport * as correlation from \"./correlation.js\";\nimport * as platform from \"./platform.js\";\nimport { SourceDef, constructSourceParameters } from \"./sourcedef.js\";\nimport * as actionsCache from \"@actions/cache\";\nimport * as actionsCore from \"@actions/core\";\nimport got, { Got } from \"got\";\nimport { UUID, randomUUID } from \"node:crypto\";\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\";\n\nconst DEFAULT_IDS_HOST = \"https://install.determinate.systems\";\nconst IDS_HOST = process.env[\"IDS_HOST\"] ?? DEFAULT_IDS_HOST;\n\nconst EVENT_EXCEPTION = \"exception\";\nconst EVENT_ARTIFACT_CACHE_HIT = \"artifact_cache_hit\";\nconst EVENT_ARTIFACT_CACHE_MISS = \"artifact_cache_miss\";\n\nconst FACT_ENDED_WITH_EXCEPTION = \"ended_with_exception\";\nconst FACT_FINAL_EXCEPTION = \"final_exception\";\n\nexport type FetchSuffixStyle = \"nix-style\" | \"gh-env-style\" | \"universal\";\nexport type ExecutionPhase = \"main\" | \"post\";\nexport type NixRequirementHandling = \"fail\" | \"warn\" | \"ignore\";\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 // Check if Nix is installed before running this action.\n // If Nix isn't installed, this action will not fail, and will instead do nothing.\n // The action will emit a user-visible warning instructing them to install Nix.\n requireNix: NixRequirementHandling;\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 requireNix: NixRequirementHandling;\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 uuid: UUID;\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 private hookMain?: () => Promise;\n private hookPost?: () => Promise;\n\n constructor(actionOptions: ActionOptions) {\n this.actionOptions = makeOptionsConfident(actionOptions);\n this.hookMain = undefined;\n this.hookPost = undefined;\n\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 // JSON sent to server\n /* eslint-disable camelcase */\n this.facts = {\n $lib: \"idslib\",\n $lib_version: pkgVersion,\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 ghActionsCorePlatform\n .getDetails()\n // eslint-disable-next-line github/no-then\n .then((details) => {\n if (details.name !== \"unknown\") {\n this.addFact(\"$os\", details.name);\n }\n if (details.version !== \"unknown\") {\n this.addFact(\"$os_version\", details.version);\n }\n })\n // eslint-disable-next-line github/no-then\n .catch((e) => {\n actionsCore.debug(`Failure getting platform details: ${e}`);\n });\n }\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 onMain(callback: () => Promise): void {\n this.hookMain = callback;\n }\n\n onPost(callback: () => Promise): void {\n this.hookPost = callback;\n }\n\n execute(): void {\n // eslint-disable-next-line github/no-then\n this.executeAsync().catch((error: Error) => {\n // eslint-disable-next-line no-console\n console.log(error);\n process.exitCode = 1;\n });\n }\n\n private async executeAsync(): Promise {\n try {\n process.env.DETSYS_CORRELATION = JSON.stringify(\n this.getCorrelationHashes(),\n );\n\n if (!(await this.preflightRequireNix())) {\n this.recordEvent(\"preflight-require-nix-denied\");\n return;\n }\n\n if (this.executionPhase === \"main\" && this.hookMain) {\n await this.hookMain();\n } else if (this.executionPhase === \"post\" && this.hookPost) {\n await this.hookPost();\n }\n this.addFact(FACT_ENDED_WITH_EXCEPTION, false);\n } catch (error) {\n this.addFact(FACT_ENDED_WITH_EXCEPTION, true);\n\n const reportable =\n error instanceof Error || typeof error == \"string\"\n ? error.toString()\n : JSON.stringify(error);\n\n this.addFact(FACT_FINAL_EXCEPTION, reportable);\n\n if (this.executionPhase === \"post\") {\n actionsCore.warning(reportable);\n } else {\n actionsCore.setFailed(reportable);\n }\n\n this.recordEvent(EVENT_EXCEPTION);\n } finally {\n await this.complete();\n }\n }\n\n addFact(key: string, value: string | boolean): void {\n this.facts[key] = value;\n }\n\n getDiagnosticsUrl(): URL | undefined {\n return this.actionOptions.diagnosticsUrl;\n }\n\n getUniqueId(): string {\n return (\n this.identity.run_differentiator ||\n process.env.RUNNER_TRACKING_ID ||\n randomUUID()\n );\n }\n\n getCorrelationHashes(): correlation.AnonymizedCorrelationHashes {\n return this.identity;\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 uuid: randomUUID(),\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 this.client.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 = this.client.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 private 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(EVENT_ARTIFACT_CACHE_HIT);\n return `${tempDir}/${this.actionOptions.name}`;\n }\n\n this.recordEvent(EVENT_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(EVENT_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 preflightRequireNix(): Promise {\n let nixLocation: string | undefined;\n\n const pathParts = (process.env[\"PATH\"] || \"\").split(\":\");\n for (const location of pathParts) {\n const candidateNix = path.join(location, \"nix\");\n\n try {\n await fs.access(candidateNix, fs.constants.X_OK);\n actionsCore.debug(`Found Nix at ${candidateNix}`);\n nixLocation = candidateNix;\n } catch {\n actionsCore.debug(`Nix not at ${candidateNix}`);\n }\n }\n this.addFact(\"nix_location\", nixLocation || \"\");\n\n if (this.actionOptions.requireNix === \"ignore\") {\n return true;\n }\n\n const currentNotFoundState = actionsCore.getState(\n \"idstoolbox_nix_not_found\",\n );\n if (currentNotFoundState === \"not-found\") {\n // It was previously not found, so don't run subsequent actions\n return false;\n }\n\n if (nixLocation !== undefined) {\n return true;\n }\n actionsCore.saveState(\"idstoolbox_nix_not_found\", \"not-found\");\n\n switch (this.actionOptions.requireNix) {\n case \"fail\":\n actionsCore.setFailed(\n \"This action can only be used when Nix is installed.\" +\n \" Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n );\n break;\n case \"warn\":\n actionsCore.warning(\n \"This action is in no-op mode because Nix is not installed.\" +\n \" Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n );\n break;\n }\n\n return false;\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 this.client.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}-${randomUUID()}`);\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 requireNix: actionOptions.requireNix,\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\n// Public exports from other files\nexport * as inputs from \"./inputs.js\";\nexport * as platform from \"./platform.js\";\n"],"mappings":";;;;;;;AAEE,cAAW;;;ACCb,YAAY,UAAU;AACtB,YAAY,UAAU;AACtB,SAAS,mBAAmB;AAC5B,OAAO,QAAQ;AAaf,IAAM,iBAAiB,YAAiC;AACtD,QAAM,EAAE,QAAQA,SAAQ,IAAI,MAAW;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,QAAM,EAAE,QAAQ,KAAK,IAAI,MAAW;AAAA,IAClC;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,SAAO;AAAA,IACL,MAAM,KAAK,KAAK;AAAA,IAChB,SAASA,SAAQ,KAAK;AAAA,EACxB;AACF;AAKA,IAAM,eAAe,YAAiC;AACpD,QAAM,EAAE,OAAO,IAAI,MAAW,mBAAc,WAAW,QAAW;AAAA,IAChE,QAAQ;AAAA,EACV,CAAC;AAED,QAAMA,WAAU,OAAO,MAAM,wBAAwB,IAAI,CAAC,KAAK;AAC/D,QAAM,OAAO,OAAO,MAAM,qBAAqB,IAAI,CAAC,KAAK;AAEzD,SAAO;AAAA,IACL;AAAA,IACA,SAAAA;AAAA,EACF;AACF;AAKA,IAAM,eAAe,YAAiC;AACpD,MAAI,OAAe,CAAC;AAEpB,MAAI;AACF,WAAO,YAAY,EAAE,MAAM,OAAO,CAAC;AAEnC,YAAQ,IAAI,IAAI;AAAA,EAClB,SAAS,GAAG;AACV,IAAK,WAAM,kCAAkC,CAAC,EAAE;AAAA,EAClD;AAEA,SAAO;AAAA,IACL,MAAM;AAAA,MACJ;AAAA,MACA,CAAC,MAAM,QAAQ,eAAe,SAAS;AAAA,MACvC;AAAA,IACF;AAAA,IACA,S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"]} \ No newline at end of file +{"version":3,"sources":["../package.json","../src/linux-release-info.ts","../src/actions-core-platform.ts","../src/correlation.ts","../src/platform.ts","../src/inputs.ts","../src/sourcedef.ts","../src/index.ts"],"sourcesContent":["{\n \"name\": \"detsys-ts\",\n \"version\": \"1.0.0\",\n \"description\": \"TypeScript goodies for DetSys projects\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"check-fmt\": \"prettier --check .\",\n \"format\": \"prettier --write .\",\n \"lint\": \"eslint src/**/*.ts\",\n \"docs\": \"typedoc src/index.ts\",\n \"all\": \"rm -rf dist && 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\": \"MIT\",\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.1\",\n \"@actions/exec\": \"^1.1.1\",\n \"got\": \"^14.2.1\"\n },\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/node\": \"^20.12.7\",\n \"@typescript-eslint/eslint-plugin\": \"^7.6.0\",\n \"eslint\": \"^8.57.0\",\n \"eslint-import-resolver-typescript\": \"^3.6.1\",\n \"eslint-plugin-github\": \"^4.10.2\",\n \"eslint-plugin-import\": \"^2.29.1\",\n \"eslint-plugin-prettier\": \"^5.1.3\",\n \"prettier\": \"^3.2.5\",\n \"tsup\": \"^8.0.2\",\n \"typedoc\": \"^0.25.13\",\n \"typescript\": \"^5.4.5\"\n }\n}\n","/*!\n * linux-release-info\n * Get Linux release info (distribution name, version, arch, release, etc.)\n * from '/etc/os-release' or '/usr/lib/os-release' files and from native os\n * module. On Windows and Darwin platforms it only returns common node os module\n * info (platform, hostname, release, and arch)\n *\n * Licensed under MIT\n * Copyright (c) 2018-2020 [Samuel Carreira]\n */\n// NOTE: we depend on this directly to get around some un-fun issues with mixing CommonJS\n// and ESM in the bundle.\nimport * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport { promisify } from \"node:util\";\n\nconst readFileAsync = promisify(fs.readFile);\n\nexport interface LinuxReleaseInfoOptions {\n /**\n * read mode, possible values: 'async' and 'sync'\n *\n * @default 'async'\n */\n mode?: \"async\" | \"sync\";\n /**\n * custom complete file path with os info default null/none\n * if not provided the system will search on the '/etc/os-release'\n * and '/usr/lib/os-release' files\n *\n * @default null\n */\n custom_file?: string | null | undefined;\n /**\n * if true, show console debug messages\n *\n * @default false\n */\n debug?: boolean;\n}\n\nconst linuxReleaseInfoOptionsDefaults: LinuxReleaseInfoOptions = {\n mode: \"async\",\n custom_file: null,\n debug: false,\n};\n\n/**\n * Get OS release info from 'os-release' file and from native os module\n * on Windows or Darwin it only returns common os module info\n * (uses native fs module)\n * @returns {object} info from the current os\n */\nexport function releaseInfo(options: LinuxReleaseInfoOptions): object {\n options = { ...linuxReleaseInfoOptionsDefaults, ...options };\n\n const searchOsreleaseFileList: string[] = osreleaseFileList(\n options.custom_file,\n );\n\n async function readAsyncOsreleaseFile(\n searchOsreleaseFileList: string[],\n options: LinuxReleaseInfoOptions,\n ) {\n let fileData = null;\n\n for (let os_release_file of searchOsreleaseFileList) {\n try {\n if (options.debug) {\n console.log(`Trying to read '${os_release_file}'...`);\n }\n\n fileData = await readFileAsync(os_release_file, \"binary\");\n\n if (options.debug) {\n console.log(\"Read data:\\n\" + fileData);\n }\n\n break;\n } catch (error) {\n if (options.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n }\n\n function readSyncOsreleaseFile(\n searchOsreleaseFileList: string[],\n options: LinuxReleaseInfoOptions,\n ) {\n let fileData = null;\n\n for (let os_release_file of searchOsreleaseFileList) {\n try {\n if (options.debug) {\n console.log(`Trying to read '${os_release_file}'...`);\n }\n\n fileData = fs.readFileSync(os_release_file, \"binary\");\n\n if (options.debug) {\n console.log(\"Read data:\\n\" + fileData);\n }\n\n break;\n } catch (error) {\n if (options.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n }\n\n if (os.type() !== \"Linux\") {\n if (options.mode === \"sync\") {\n return getOsInfo();\n } else {\n return Promise.resolve(getOsInfo());\n }\n }\n\n if (options.mode === \"sync\") {\n return readSyncOsreleaseFile(searchOsreleaseFileList, options);\n } else {\n return Promise.resolve(\n readAsyncOsreleaseFile(searchOsreleaseFileList, options),\n );\n }\n}\n\n/**\n * Format file data: convert data to object keys/values\n *\n * @param {object} sourceData Source object to be appended\n * @param {string} srcParseData Input file data to be parsed\n * @returns {object} Formated object\n */\nfunction formatFileData(sourceData: any, srcParseData: any): any {\n const lines = srcParseData.split(\"\\n\");\n\n // @ts-ignore\n lines.forEach((element) => {\n const linedata = element.split(\"=\");\n\n if (linedata.length === 2) {\n linedata[1] = linedata[1].replace(/[\"'\\r]/gi, \"\"); // remove quotes and return character\n\n Object.defineProperty(sourceData, linedata[0].toLowerCase(), {\n value: linedata[1],\n writable: true,\n enumerable: true,\n configurable: true,\n });\n }\n });\n\n return sourceData;\n}\n\n/**\n * Export a list of os-release files\n *\n * @param {string} customFile optional custom complete filepath\n * @returns {array} list of os-release files\n */\nfunction osreleaseFileList(customFile: string | null | undefined): string[] {\n const DEFAULT_OS_RELEASE_FILES = [\"/etc/os-release\", \"/usr/lib/os-release\"];\n\n if (!customFile) {\n return DEFAULT_OS_RELEASE_FILES;\n } else {\n return Array(customFile);\n }\n}\n\n/**\n * Get OS Basic Info\n * (uses node 'os' native module)\n *\n * @returns {object} os basic info\n */\nfunction getOsInfo() {\n const osInfo = {\n type: os.type(),\n platform: os.platform(),\n hostname: os.hostname(),\n arch: os.arch(),\n release: os.release(),\n };\n\n return osInfo;\n}\n","// MIT, mostly lifted from https://github.com/actions/toolkit/blob/5a736647a123ecf8582376bdaee833fbae5b3847/packages/core/src/platform.ts\n// since it isn't in @actions/core 1.10.1 which is their current release as 2024-04-19.\n// Changes: Replaced the lsb_release call in Linux with `linux-release-info` to parse the os-release file directly.\nimport { releaseInfo } from \"./linux-release-info.js\";\nimport * as core from \"@actions/core\";\nimport * as exec from \"@actions/exec\";\nimport os from \"os\";\n\n/**\n * The name and version of the Action runner's system.\n */\ntype SystemInfo = {\n name: string;\n version: string;\n};\n\n/**\n * Get the name and version of the current Windows system.\n */\nconst getWindowsInfo = async (): Promise => {\n const { stdout: version } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Version\"',\n undefined,\n {\n silent: true,\n },\n );\n\n const { stdout: name } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Caption\"',\n undefined,\n {\n silent: true,\n },\n );\n\n return {\n name: name.trim(),\n version: version.trim(),\n };\n};\n\n/**\n * Get the name and version of the current macOS system.\n */\nconst getMacOsInfo = async (): Promise => {\n const { stdout } = await exec.getExecOutput(\"sw_vers\", undefined, {\n silent: true,\n });\n\n const version = stdout.match(/ProductVersion:\\s*(.+)/)?.[1] ?? \"\";\n const name = stdout.match(/ProductName:\\s*(.+)/)?.[1] ?? \"\";\n\n return {\n name,\n version,\n };\n};\n\n/**\n * Get the name and version of the current Linux system.\n */\nconst getLinuxInfo = async (): Promise => {\n let data: object = {};\n\n try {\n data = releaseInfo({ mode: \"sync\" });\n // eslint-disable-next-line no-console\n console.log(data);\n } catch (e) {\n core.debug(`Error collecting release info: ${e}`);\n }\n\n return {\n name: getPropertyViaWithDefault(\n data,\n [\"id\", \"name\", \"pretty_name\", \"id_like\"],\n \"unknown\",\n ),\n version: getPropertyViaWithDefault(\n data,\n [\"version_id\", \"version\", \"version_codename\"],\n \"unknown\",\n ),\n };\n};\n\nfunction getPropertyViaWithDefault(\n data: object,\n names: Property[],\n defaultValue: T,\n): T {\n for (const name of names) {\n const ret: T = getPropertyWithDefault(data, name, defaultValue);\n\n if (ret !== defaultValue) {\n return ret;\n }\n }\n\n return defaultValue;\n}\n\nfunction getPropertyWithDefault(\n data: object,\n name: Property,\n defaultValue: T,\n): T {\n if (!data.hasOwnProperty(name)) {\n return defaultValue;\n }\n\n const value = (data as { [K in Property]: T })[name];\n\n // NB. this check won't work for object instances\n if (typeof value !== typeof defaultValue) {\n return defaultValue;\n }\n\n return value;\n}\n\n/**\n * The Action runner's platform.\n */\nexport const platform = os.platform();\n\n/**\n * The Action runner's architecture.\n */\nexport const arch = os.arch();\n\n/**\n * Whether the Action runner is a Windows system.\n */\nexport const isWindows = platform === \"win32\";\n\n/**\n * Whether the Action runner is a macOS system.\n */\nexport const isMacOS = platform === \"darwin\";\n\n/**\n * Whether the Action runner is a Linux system.\n */\nexport const isLinux = platform === \"linux\";\n\n/**\n * System-level information about the current host (platform, architecture, etc.).\n */\ntype SystemDetails = {\n name: string;\n platform: string;\n arch: string;\n version: string;\n isWindows: boolean;\n isMacOS: boolean;\n isLinux: boolean;\n};\n\n/**\n * Get system-level information about the current host (platform, architecture, etc.).\n */\nexport async function getDetails(): Promise {\n return {\n ...(await (isWindows\n ? getWindowsInfo()\n : isMacOS\n ? getMacOsInfo()\n : getLinuxInfo())),\n platform,\n arch,\n isWindows,\n isMacOS,\n isLinux,\n };\n}\n","import * as actionsCore from \"@actions/core\";\nimport { createHash } from \"node:crypto\";\n\nconst OPTIONAL_VARIABLES = [\"INVOCATION_ID\"];\n\n// JSON sent to server\n/* eslint-disable camelcase */\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 job: hashEnvironmentVariables(\"GHWJ\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n ]),\n run: hashEnvironmentVariables(\"GHWJR\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n ]),\n run_differentiator: hashEnvironmentVariables(\"GHWJA\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n \"GITHUB_RUN_NUMBER\",\n \"GITHUB_RUN_ATTEMPT\",\n \"INVOCATION_ID\",\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 let value = process.env[varName];\n\n if (value === undefined) {\n if (OPTIONAL_VARIABLES.includes(varName)) {\n actionsCore.debug(\n `Optional environment variable not set: ${varName} -- substituting with the variable name`,\n );\n value = varName;\n } else {\n actionsCore.debug(\n `Environment variable not set: ${varName} -- can't generate the requested identity`,\n );\n return undefined;\n }\n }\n\n hash.update(value);\n hash.update(\"\\0\");\n }\n\n return `${prefix}-${hash.digest(\"hex\")}`;\n}\n","/**\n * @packageDocumentation\n * Helpers for determining system attributes of the current runner.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get the current architecture plus OS. Examples include `X64-Linux` and `ARM64-macOS`.\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\n/**\n * Get the current Nix system. Examples include `x86_64-linux` and `aarch64-darwin`.\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","/**\n * @packageDocumentation\n * Helpers for getting values from an Action's configuration.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get a Boolean input from the Action's configuration by name.\n */\nconst getBool = (name: string): boolean => {\n return actionsCore.getBooleanInput(name);\n};\n\n/**\n * Get a multi-line string input from the Action's configuration by name or return `null` if not set.\n */\nconst getMultilineStringOrNull = (name: string): string[] | null => {\n const value = actionsCore.getMultilineInput(name);\n if (value.length === 0) {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a number input from the Action's configuration by name or return `null` if not set.\n */\nconst getNumberOrNull = (name: string): number | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return Number(value);\n }\n};\n\n/**\n * Get a string input from the Action's configuration.\n */\nconst getString = (name: string): string => {\n return actionsCore.getInput(name);\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `null` if not set.\n */\nconst getStringOrNull = (name: string): string | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `undefined` if not set.\n */\nconst getStringOrUndefined = (name: string): string | undefined => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return undefined;\n } else {\n return value;\n }\n};\n\nexport {\n getBool,\n getMultilineStringOrNull,\n getNumberOrNull,\n getString,\n getStringOrNull,\n getStringOrUndefined,\n};\n","import { getStringOrUndefined } from \"./inputs.js\";\nimport * 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 = getStringOrUndefined(`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 = getStringOrUndefined(`${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","/**\n * @packageDocumentation\n * Determinate Systems' TypeScript library for creating GitHub Actions logic.\n */\nimport { version as pkgVersion } from \"../package.json\";\nimport * as ghActionsCorePlatform from \"./actions-core-platform.js\";\nimport * as correlation from \"./correlation.js\";\nimport * as platform from \"./platform.js\";\nimport { SourceDef, constructSourceParameters } from \"./sourcedef.js\";\nimport * as actionsCache from \"@actions/cache\";\nimport * as actionsCore from \"@actions/core\";\nimport got, { Got } from \"got\";\nimport { UUID, randomUUID } from \"node:crypto\";\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\";\n\nconst DEFAULT_IDS_HOST = \"https://install.determinate.systems\";\nconst IDS_HOST = process.env[\"IDS_HOST\"] ?? DEFAULT_IDS_HOST;\n\nconst EVENT_EXCEPTION = \"exception\";\nconst EVENT_ARTIFACT_CACHE_HIT = \"artifact_cache_hit\";\nconst EVENT_ARTIFACT_CACHE_MISS = \"artifact_cache_miss\";\n\nconst FACT_ENDED_WITH_EXCEPTION = \"ended_with_exception\";\nconst FACT_FINAL_EXCEPTION = \"final_exception\";\n\nexport type FetchSuffixStyle = \"nix-style\" | \"gh-env-style\" | \"universal\";\nexport type ExecutionPhase = \"main\" | \"post\";\nexport type NixRequirementHandling = \"fail\" | \"warn\" | \"ignore\";\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 // Check if Nix is installed before running this action.\n // If Nix isn't installed, this action will not fail, and will instead do nothing.\n // The action will emit a user-visible warning instructing them to install Nix.\n requireNix: NixRequirementHandling;\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 requireNix: NixRequirementHandling;\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 uuid: UUID;\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 private hookMain?: () => Promise;\n private hookPost?: () => Promise;\n\n constructor(actionOptions: ActionOptions) {\n this.actionOptions = makeOptionsConfident(actionOptions);\n this.hookMain = undefined;\n this.hookPost = undefined;\n\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 // JSON sent to server\n /* eslint-disable camelcase */\n this.facts = {\n $lib: \"idslib\",\n $lib_version: pkgVersion,\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 ghActionsCorePlatform\n .getDetails()\n // eslint-disable-next-line github/no-then\n .then((details) => {\n if (details.name !== \"unknown\") {\n this.addFact(\"$os\", details.name);\n }\n if (details.version !== \"unknown\") {\n this.addFact(\"$os_version\", details.version);\n }\n })\n // eslint-disable-next-line github/no-then\n .catch((e) => {\n actionsCore.debug(`Failure getting platform details: ${e}`);\n });\n }\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 onMain(callback: () => Promise): void {\n this.hookMain = callback;\n }\n\n onPost(callback: () => Promise): void {\n this.hookPost = callback;\n }\n\n execute(): void {\n // eslint-disable-next-line github/no-then\n this.executeAsync().catch((error: Error) => {\n // eslint-disable-next-line no-console\n console.log(error);\n process.exitCode = 1;\n });\n }\n\n private async executeAsync(): Promise {\n try {\n process.env.DETSYS_CORRELATION = JSON.stringify(\n this.getCorrelationHashes(),\n );\n\n if (!(await this.preflightRequireNix())) {\n this.recordEvent(\"preflight-require-nix-denied\");\n return;\n }\n\n if (this.executionPhase === \"main\" && this.hookMain) {\n await this.hookMain();\n } else if (this.executionPhase === \"post\" && this.hookPost) {\n await this.hookPost();\n }\n this.addFact(FACT_ENDED_WITH_EXCEPTION, false);\n } catch (error) {\n this.addFact(FACT_ENDED_WITH_EXCEPTION, true);\n\n const reportable =\n error instanceof Error || typeof error == \"string\"\n ? error.toString()\n : JSON.stringify(error);\n\n this.addFact(FACT_FINAL_EXCEPTION, reportable);\n\n if (this.executionPhase === \"post\") {\n actionsCore.warning(reportable);\n } else {\n actionsCore.setFailed(reportable);\n }\n\n this.recordEvent(EVENT_EXCEPTION);\n } finally {\n await this.complete();\n }\n }\n\n addFact(key: string, value: string | boolean): void {\n this.facts[key] = value;\n }\n\n getDiagnosticsUrl(): URL | undefined {\n return this.actionOptions.diagnosticsUrl;\n }\n\n getUniqueId(): string {\n return (\n this.identity.run_differentiator ||\n process.env.RUNNER_TRACKING_ID ||\n randomUUID()\n );\n }\n\n getCorrelationHashes(): correlation.AnonymizedCorrelationHashes {\n return this.identity;\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 uuid: randomUUID(),\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 this.client.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 = this.client.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 private 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(EVENT_ARTIFACT_CACHE_HIT);\n return `${tempDir}/${this.actionOptions.name}`;\n }\n\n this.recordEvent(EVENT_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(EVENT_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 preflightRequireNix(): Promise {\n let nixLocation: string | undefined;\n\n const pathParts = (process.env[\"PATH\"] || \"\").split(\":\");\n for (const location of pathParts) {\n const candidateNix = path.join(location, \"nix\");\n\n try {\n await fs.access(candidateNix, fs.constants.X_OK);\n actionsCore.debug(`Found Nix at ${candidateNix}`);\n nixLocation = candidateNix;\n } catch {\n actionsCore.debug(`Nix not at ${candidateNix}`);\n }\n }\n this.addFact(\"nix_location\", nixLocation || \"\");\n\n if (this.actionOptions.requireNix === \"ignore\") {\n return true;\n }\n\n const currentNotFoundState = actionsCore.getState(\n \"idstoolbox_nix_not_found\",\n );\n if (currentNotFoundState === \"not-found\") {\n // It was previously not found, so don't run subsequent actions\n return false;\n }\n\n if (nixLocation !== undefined) {\n return true;\n }\n actionsCore.saveState(\"idstoolbox_nix_not_found\", \"not-found\");\n\n switch (this.actionOptions.requireNix) {\n case \"fail\":\n actionsCore.setFailed(\n \"This action can only be used when Nix is installed.\" +\n \" Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n );\n break;\n case \"warn\":\n actionsCore.warning(\n \"This action is in no-op mode because Nix is not installed.\" +\n \" Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n );\n break;\n }\n\n return false;\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 this.client.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}-${randomUUID()}`);\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 requireNix: actionOptions.requireNix,\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\n// Public exports from other files\nexport * as inputs from \"./inputs.js\";\nexport * as platform from \"./platform.js\";\n"],"mappings":";;;;;;;AAEE,cAAW;;;ACUb,YAAY,QAAQ;AACpB,YAAY,QAAQ;AACpB,SAAS,iBAAiB;AAE1B,IAAM,gBAAgB,UAAa,WAAQ;AAyB3C,IAAM,kCAA2D;AAAA,EAC/D,MAAM;AAAA,EACN,aAAa;AAAA,EACb,OAAO;AACT;AAQO,SAAS,YAAY,SAA0C;AACpE,YAAU,EAAE,GAAG,iCAAiC,GAAG,QAAQ;AAE3D,QAAM,0BAAoC;AAAA,IACxC,QAAQ;AAAA,EACV;AAEA,iBAAe,uBACbA,0BACAC,UACA;AACA,QAAI,WAAW;AAEf,aAAS,mBAAmBD,0BAAyB;AACnD,UAAI;AACF,YAAIC,SAAQ,OAAO;AACjB,kBAAQ,IAAI,mBAAmB,eAAe,MAAM;AAAA,QACtD;AAEA,mBAAW,MAAM,cAAc,iBAAiB,QAAQ;AAExD,YAAIA,SAAQ,OAAO;AACjB,kBAAQ,IAAI,iBAAiB,QAAQ;AAAA,QACvC;AAEA;AAAA,MACF,SAASC,QAAO;AACd,YAAID,SAAQ,OAAO;AACjB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AACF,UAAM,iBAAiB,IAAI,IAAI,gBAAgB;AAC/C,UAAM,iBAAiB,IAAI,IAAI,QAAQ;AAEvC,QAAI,SAAS,WAAW,eAAe,QAAQ;AAC7C,aAAO;AAAA,IACT;AAEA,aAAS,WAAW,eAAe;AACnC,aAAS,OAAO,eAAe;AAC/B,aAAS,WAAW,eAAe;AACnC,aAAS,WAAW,eAAe;AAEnC,WAAO;AAAA,EACT,SAAS,GAAG;AACV,IAAY,kBAAK,qDAAqD,CAAC,EAAE;AAAA,EAC3E;AAEA,SAAO;AACT;","names":["searchOsreleaseFileList","options","error","os","version","platform","arch","actionsCore","actionsCore","actionsCore","actionsCore","fs","error","version"]} \ No newline at end of file diff --git a/package.json b/package.json index cc8e642..3143776 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,6 @@ "eslint-plugin-github": "^4.10.2", "eslint-plugin-import": "^2.29.1", "eslint-plugin-prettier": "^5.1.3", - "linux-release-info": "^3.0.0", "prettier": "^3.2.5", "tsup": "^8.0.2", "typedoc": "^0.25.13", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 28b5fa6..db8454f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -43,9 +43,6 @@ devDependencies: eslint-plugin-prettier: specifier: ^5.1.3 version: 5.1.3(eslint-config-prettier@9.1.0)(eslint@8.57.0)(prettier@3.2.5) - linux-release-info: - specifier: ^3.0.0 - version: 3.0.0 prettier: specifier: ^3.2.5 version: 3.2.5 @@ -2726,11 +2723,6 @@ packages: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} dev: true - /linux-release-info@3.0.0: - resolution: {integrity: sha512-qVARfxfp2uOM8XTlb+ZkzqVqvNDd6djySW7JL0ec+cnpB/SKZO2O/NJc9XR699fE7Wg1ERWN6aKcPm5Ejioj3A==} - engines: {node: '>=8.0'} - dev: true - /load-tsconfig@0.2.5: resolution: {integrity: sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} diff --git a/src/actions-core-platform.ts b/src/actions-core-platform.ts index a59e5cf..3e24762 100644 --- a/src/actions-core-platform.ts +++ b/src/actions-core-platform.ts @@ -1,9 +1,9 @@ // MIT, mostly lifted from https://github.com/actions/toolkit/blob/5a736647a123ecf8582376bdaee833fbae5b3847/packages/core/src/platform.ts // since it isn't in @actions/core 1.10.1 which is their current release as 2024-04-19. // Changes: Replaced the lsb_release call in Linux with `linux-release-info` to parse the os-release file directly. +import { releaseInfo } from "./linux-release-info.js"; import * as core from "@actions/core"; import * as exec from "@actions/exec"; -import { releaseInfo } from "linux-release-info"; import os from "os"; /** diff --git a/src/linux-release-info.ts b/src/linux-release-info.ts new file mode 100644 index 0000000..d43f7dd --- /dev/null +++ b/src/linux-release-info.ts @@ -0,0 +1,207 @@ +/*! + * linux-release-info + * Get Linux release info (distribution name, version, arch, release, etc.) + * from '/etc/os-release' or '/usr/lib/os-release' files and from native os + * module. On Windows and Darwin platforms it only returns common node os module + * info (platform, hostname, release, and arch) + * + * Licensed under MIT + * Copyright (c) 2018-2020 [Samuel Carreira] + */ +// NOTE: we depend on this directly to get around some un-fun issues with mixing CommonJS +// and ESM in the bundle. +import * as fs from "node:fs"; +import * as os from "node:os"; +import { promisify } from "node:util"; + +const readFileAsync = promisify(fs.readFile); + +export interface LinuxReleaseInfoOptions { + /** + * read mode, possible values: 'async' and 'sync' + * + * @default 'async' + */ + mode?: "async" | "sync"; + /** + * custom complete file path with os info default null/none + * if not provided the system will search on the '/etc/os-release' + * and '/usr/lib/os-release' files + * + * @default null + */ + custom_file?: string | null | undefined; + /** + * if true, show console debug messages + * + * @default false + */ + debug?: boolean; +} + +const linuxReleaseInfoOptionsDefaults: LinuxReleaseInfoOptions = { + mode: "async", + custom_file: null, + debug: false, +}; + +/** + * Get OS release info from 'os-release' file and from native os module + * on Windows or Darwin it only returns common os module info + * (uses native fs module) + * @returns {object} info from the current os + */ +export function releaseInfo(options: LinuxReleaseInfoOptions): object { + options = { ...linuxReleaseInfoOptionsDefaults, ...options }; + + const searchOsreleaseFileList: string[] = osreleaseFileList( + options.custom_file, + ); + + async function readAsyncOsreleaseFile( + searchOsreleaseFileList: string[], + options: LinuxReleaseInfoOptions, + ) { + let fileData = null; + + for (let os_release_file of searchOsreleaseFileList) { + try { + if (options.debug) { + console.log(`Trying to read '${os_release_file}'...`); + } + + fileData = await readFileAsync(os_release_file, "binary"); + + if (options.debug) { + console.log("Read data:\n" + fileData); + } + + break; + } catch (error) { + if (options.debug) { + console.error(error); + } + } + } + + if (fileData === null) { + throw new Error("Cannot read os-release file!"); + //return getOsInfo(); + } + + return formatFileData(getOsInfo(), fileData); + } + + function readSyncOsreleaseFile( + searchOsreleaseFileList: string[], + options: LinuxReleaseInfoOptions, + ) { + let fileData = null; + + for (let os_release_file of searchOsreleaseFileList) { + try { + if (options.debug) { + console.log(`Trying to read '${os_release_file}'...`); + } + + fileData = fs.readFileSync(os_release_file, "binary"); + + if (options.debug) { + console.log("Read data:\n" + fileData); + } + + break; + } catch (error) { + if (options.debug) { + console.error(error); + } + } + } + + if (fileData === null) { + throw new Error("Cannot read os-release file!"); + //return getOsInfo(); + } + + return formatFileData(getOsInfo(), fileData); + } + + if (os.type() !== "Linux") { + if (options.mode === "sync") { + return getOsInfo(); + } else { + return Promise.resolve(getOsInfo()); + } + } + + if (options.mode === "sync") { + return readSyncOsreleaseFile(searchOsreleaseFileList, options); + } else { + return Promise.resolve( + readAsyncOsreleaseFile(searchOsreleaseFileList, options), + ); + } +} + +/** + * Format file data: convert data to object keys/values + * + * @param {object} sourceData Source object to be appended + * @param {string} srcParseData Input file data to be parsed + * @returns {object} Formated object + */ +function formatFileData(sourceData: any, srcParseData: any): any { + const lines = srcParseData.split("\n"); + + // @ts-ignore + lines.forEach((element) => { + const linedata = element.split("="); + + if (linedata.length === 2) { + linedata[1] = linedata[1].replace(/["'\r]/gi, ""); // remove quotes and return character + + Object.defineProperty(sourceData, linedata[0].toLowerCase(), { + value: linedata[1], + writable: true, + enumerable: true, + configurable: true, + }); + } + }); + + return sourceData; +} + +/** + * Export a list of os-release files + * + * @param {string} customFile optional custom complete filepath + * @returns {array} list of os-release files + */ +function osreleaseFileList(customFile: string | null | undefined): string[] { + const DEFAULT_OS_RELEASE_FILES = ["/etc/os-release", "/usr/lib/os-release"]; + + if (!customFile) { + return DEFAULT_OS_RELEASE_FILES; + } else { + return Array(customFile); + } +} + +/** + * Get OS Basic Info + * (uses node 'os' native module) + * + * @returns {object} os basic info + */ +function getOsInfo() { + const osInfo = { + type: os.type(), + platform: os.platform(), + hostname: os.hostname(), + arch: os.arch(), + release: os.release(), + }; + + return osInfo; +} diff --git a/tsup.config.ts b/tsup.config.ts index 259a5cc..14b9b14 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -5,7 +5,6 @@ export default defineConfig({ entry: ["src/index.ts"], format: ["esm"], target: "node20", - external: ["linux-release-info"], bundle: true, splitting: false, sourcemap: true, From d699a01b74cdc4260d10222eab2727c60bf24434 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Sat, 20 Apr 2024 22:17:29 -0300 Subject: [PATCH 2/6] Fix TS and ESLint issues in linux-release-info --- .eslintignore | 1 - dist/index.js | 65 +++++++++++++------------- dist/index.js.map | 2 +- src/linux-release-info.ts | 97 +++++++++++++++++++++------------------ 4 files changed, 87 insertions(+), 78 deletions(-) delete mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 4aa57e2..0000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -src/linux-release-info.ts diff --git a/dist/index.js b/dist/index.js index 8363cec..6cce2a6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -14,28 +14,29 @@ import { promisify } from "node:util"; var readFileAsync = promisify(fs.readFile); var linuxReleaseInfoOptionsDefaults = { mode: "async", - custom_file: null, + customFile: null, debug: false }; -function releaseInfo(options) { - options = { ...linuxReleaseInfoOptionsDefaults, ...options }; - const searchOsreleaseFileList = osreleaseFileList( - options.custom_file +function releaseInfo(infoOptions) { + const options = { ...linuxReleaseInfoOptionsDefaults, ...infoOptions }; + const searchOsReleaseFileList = osreleaseFileList( + options.customFile ); - async function readAsyncOsreleaseFile(searchOsreleaseFileList2, options2) { + async function readAsyncOsReleaseFile(fileList, releaseInfoOptions) { let fileData = null; - for (let os_release_file of searchOsreleaseFileList2) { + for (const osReleaseFile of fileList) { try { - if (options2.debug) { - console.log(`Trying to read '${os_release_file}'...`); + if (releaseInfoOptions.debug) { + console.log(`Trying to read '${osReleaseFile}'...`); } - fileData = await readFileAsync(os_release_file, "binary"); - if (options2.debug) { - console.log("Read data:\n" + fileData); + fileData = await readFileAsync(osReleaseFile, "binary"); + if (releaseInfoOptions.debug) { + console.log(`Read data: +${fileData}`); } break; } catch (error2) { - if (options2.debug) { + if (releaseInfoOptions.debug) { console.error(error2); } } @@ -45,20 +46,21 @@ function releaseInfo(options) { } return formatFileData(getOsInfo(), fileData); } - function readSyncOsreleaseFile(searchOsreleaseFileList2, options2) { + function readSyncOsreleaseFile(releaseFileList, releaseInfoOptions) { let fileData = null; - for (let os_release_file of searchOsreleaseFileList2) { + for (const osReleaseFile of releaseFileList) { try { - if (options2.debug) { - console.log(`Trying to read '${os_release_file}'...`); + if (releaseInfoOptions.debug) { + console.log(`Trying to read '${osReleaseFile}'...`); } - fileData = fs.readFileSync(os_release_file, "binary"); - if (options2.debug) { - console.log("Read data:\n" + fileData); + fileData = fs.readFileSync(osReleaseFile, "binary"); + if (releaseInfoOptions.debug) { + console.log(`Read data: +${fileData}`); } break; } catch (error2) { - if (options2.debug) { + if (releaseInfoOptions.debug) { console.error(error2); } } @@ -76,27 +78,27 @@ function releaseInfo(options) { } } if (options.mode === "sync") { - return readSyncOsreleaseFile(searchOsreleaseFileList, options); + return readSyncOsreleaseFile(searchOsReleaseFileList, options); } else { return Promise.resolve( - readAsyncOsreleaseFile(searchOsreleaseFileList, options) + readAsyncOsReleaseFile(searchOsReleaseFileList, options) ); } } function formatFileData(sourceData, srcParseData) { const lines = srcParseData.split("\n"); - lines.forEach((element) => { - const linedata = element.split("="); - if (linedata.length === 2) { - linedata[1] = linedata[1].replace(/["'\r]/gi, ""); - Object.defineProperty(sourceData, linedata[0].toLowerCase(), { - value: linedata[1], + for (const line of lines) { + const lineData = line.split("="); + if (lineData.length === 2) { + lineData[1] = lineData[1].replace(/["'\r]/gi, ""); + Object.defineProperty(sourceData, lineData[0].toLowerCase(), { + value: lineData[1], writable: true, enumerable: true, configurable: true }); } - }); + } return sourceData; } function osreleaseFileList(customFile) { @@ -108,14 +110,13 @@ function osreleaseFileList(customFile) { } } function getOsInfo() { - const osInfo = { + return { type: os.type(), platform: os.platform(), hostname: os.hostname(), arch: os.arch(), release: os.release() }; - return osInfo; } // src/actions-core-platform.ts diff --git a/dist/index.js.map b/dist/index.js.map index 3f41f9f..3af0336 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../package.json","../src/linux-release-info.ts","../src/actions-core-platform.ts","../src/correlation.ts","../src/platform.ts","../src/inputs.ts","../src/sourcedef.ts","../src/index.ts"],"sourcesContent":["{\n \"name\": \"detsys-ts\",\n \"version\": \"1.0.0\",\n \"description\": \"TypeScript goodies for DetSys projects\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"check-fmt\": \"prettier --check .\",\n \"format\": \"prettier --write .\",\n \"lint\": \"eslint src/**/*.ts\",\n \"docs\": \"typedoc src/index.ts\",\n \"all\": \"rm -rf dist && 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\": \"MIT\",\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.1\",\n \"@actions/exec\": \"^1.1.1\",\n \"got\": \"^14.2.1\"\n },\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/node\": \"^20.12.7\",\n \"@typescript-eslint/eslint-plugin\": \"^7.6.0\",\n \"eslint\": \"^8.57.0\",\n \"eslint-import-resolver-typescript\": \"^3.6.1\",\n \"eslint-plugin-github\": \"^4.10.2\",\n \"eslint-plugin-import\": \"^2.29.1\",\n \"eslint-plugin-prettier\": \"^5.1.3\",\n \"prettier\": \"^3.2.5\",\n \"tsup\": \"^8.0.2\",\n \"typedoc\": \"^0.25.13\",\n \"typescript\": \"^5.4.5\"\n }\n}\n","/*!\n * linux-release-info\n * Get Linux release info (distribution name, version, arch, release, etc.)\n * from '/etc/os-release' or '/usr/lib/os-release' files and from native os\n * module. On Windows and Darwin platforms it only returns common node os module\n * info (platform, hostname, release, and arch)\n *\n * Licensed under MIT\n * Copyright (c) 2018-2020 [Samuel Carreira]\n */\n// NOTE: we depend on this directly to get around some un-fun issues with mixing CommonJS\n// and ESM in the bundle.\nimport * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport { promisify } from \"node:util\";\n\nconst readFileAsync = promisify(fs.readFile);\n\nexport interface LinuxReleaseInfoOptions {\n /**\n * read mode, possible values: 'async' and 'sync'\n *\n * @default 'async'\n */\n mode?: \"async\" | \"sync\";\n /**\n * custom complete file path with os info default null/none\n * if not provided the system will search on the '/etc/os-release'\n * and '/usr/lib/os-release' files\n *\n * @default null\n */\n custom_file?: string | null | undefined;\n /**\n * if true, show console debug messages\n *\n * @default false\n */\n debug?: boolean;\n}\n\nconst linuxReleaseInfoOptionsDefaults: LinuxReleaseInfoOptions = {\n mode: \"async\",\n custom_file: null,\n debug: false,\n};\n\n/**\n * Get OS release info from 'os-release' file and from native os module\n * on Windows or Darwin it only returns common os module info\n * (uses native fs module)\n * @returns {object} info from the current os\n */\nexport function releaseInfo(options: LinuxReleaseInfoOptions): object {\n options = { ...linuxReleaseInfoOptionsDefaults, ...options };\n\n const searchOsreleaseFileList: string[] = osreleaseFileList(\n options.custom_file,\n );\n\n async function readAsyncOsreleaseFile(\n searchOsreleaseFileList: string[],\n options: LinuxReleaseInfoOptions,\n ) {\n let fileData = null;\n\n for (let os_release_file of searchOsreleaseFileList) {\n try {\n if (options.debug) {\n console.log(`Trying to read '${os_release_file}'...`);\n }\n\n fileData = await readFileAsync(os_release_file, \"binary\");\n\n if (options.debug) {\n console.log(\"Read data:\\n\" + fileData);\n }\n\n break;\n } catch (error) {\n if (options.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n }\n\n function readSyncOsreleaseFile(\n searchOsreleaseFileList: string[],\n options: LinuxReleaseInfoOptions,\n ) {\n let fileData = null;\n\n for (let os_release_file of searchOsreleaseFileList) {\n try {\n if (options.debug) {\n console.log(`Trying to read '${os_release_file}'...`);\n }\n\n fileData = fs.readFileSync(os_release_file, \"binary\");\n\n if (options.debug) {\n console.log(\"Read data:\\n\" + fileData);\n }\n\n break;\n } catch (error) {\n if (options.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n }\n\n if (os.type() !== \"Linux\") {\n if (options.mode === \"sync\") {\n return getOsInfo();\n } else {\n return Promise.resolve(getOsInfo());\n }\n }\n\n if (options.mode === \"sync\") {\n return readSyncOsreleaseFile(searchOsreleaseFileList, options);\n } else {\n return Promise.resolve(\n readAsyncOsreleaseFile(searchOsreleaseFileList, options),\n );\n }\n}\n\n/**\n * Format file data: convert data to object keys/values\n *\n * @param {object} sourceData Source object to be appended\n * @param {string} srcParseData Input file data to be parsed\n * @returns {object} Formated object\n */\nfunction formatFileData(sourceData: any, srcParseData: any): any {\n const lines = srcParseData.split(\"\\n\");\n\n // @ts-ignore\n lines.forEach((element) => {\n const linedata = element.split(\"=\");\n\n if (linedata.length === 2) {\n linedata[1] = linedata[1].replace(/[\"'\\r]/gi, \"\"); // remove quotes and return character\n\n Object.defineProperty(sourceData, linedata[0].toLowerCase(), {\n value: linedata[1],\n writable: true,\n enumerable: true,\n configurable: true,\n });\n }\n });\n\n return sourceData;\n}\n\n/**\n * Export a list of os-release files\n *\n * @param {string} customFile optional custom complete filepath\n * @returns {array} list of os-release files\n */\nfunction osreleaseFileList(customFile: string | null | undefined): string[] {\n const DEFAULT_OS_RELEASE_FILES = [\"/etc/os-release\", \"/usr/lib/os-release\"];\n\n if (!customFile) {\n return DEFAULT_OS_RELEASE_FILES;\n } else {\n return Array(customFile);\n }\n}\n\n/**\n * Get OS Basic Info\n * (uses node 'os' native module)\n *\n * @returns {object} os basic info\n */\nfunction getOsInfo() {\n const osInfo = {\n type: os.type(),\n platform: os.platform(),\n hostname: os.hostname(),\n arch: os.arch(),\n release: os.release(),\n };\n\n return osInfo;\n}\n","// MIT, mostly lifted from https://github.com/actions/toolkit/blob/5a736647a123ecf8582376bdaee833fbae5b3847/packages/core/src/platform.ts\n// since it isn't in @actions/core 1.10.1 which is their current release as 2024-04-19.\n// Changes: Replaced the lsb_release call in Linux with `linux-release-info` to parse the os-release file directly.\nimport { releaseInfo } from \"./linux-release-info.js\";\nimport * as core from \"@actions/core\";\nimport * as exec from \"@actions/exec\";\nimport os from \"os\";\n\n/**\n * The name and version of the Action runner's system.\n */\ntype SystemInfo = {\n name: string;\n version: string;\n};\n\n/**\n * Get the name and version of the current Windows system.\n */\nconst getWindowsInfo = async (): Promise => {\n const { stdout: version } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Version\"',\n undefined,\n {\n silent: true,\n },\n );\n\n const { stdout: name } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Caption\"',\n undefined,\n {\n silent: true,\n },\n );\n\n return {\n name: name.trim(),\n version: version.trim(),\n };\n};\n\n/**\n * Get the name and version of the current macOS system.\n */\nconst getMacOsInfo = async (): Promise => {\n const { stdout } = await exec.getExecOutput(\"sw_vers\", undefined, {\n silent: true,\n });\n\n const version = stdout.match(/ProductVersion:\\s*(.+)/)?.[1] ?? \"\";\n const name = stdout.match(/ProductName:\\s*(.+)/)?.[1] ?? \"\";\n\n return {\n name,\n version,\n };\n};\n\n/**\n * Get the name and version of the current Linux system.\n */\nconst getLinuxInfo = async (): Promise => {\n let data: object = {};\n\n try {\n data = releaseInfo({ mode: \"sync\" });\n // eslint-disable-next-line no-console\n console.log(data);\n } catch (e) {\n core.debug(`Error collecting release info: ${e}`);\n }\n\n return {\n name: getPropertyViaWithDefault(\n data,\n [\"id\", \"name\", \"pretty_name\", \"id_like\"],\n \"unknown\",\n ),\n version: getPropertyViaWithDefault(\n data,\n [\"version_id\", \"version\", \"version_codename\"],\n \"unknown\",\n ),\n };\n};\n\nfunction getPropertyViaWithDefault(\n data: object,\n names: Property[],\n defaultValue: T,\n): T {\n for (const name of names) {\n const ret: T = getPropertyWithDefault(data, name, defaultValue);\n\n if (ret !== defaultValue) {\n return ret;\n }\n }\n\n return defaultValue;\n}\n\nfunction getPropertyWithDefault(\n data: object,\n name: Property,\n defaultValue: T,\n): T {\n if (!data.hasOwnProperty(name)) {\n return defaultValue;\n }\n\n const value = (data as { [K in Property]: T })[name];\n\n // NB. this check won't work for object instances\n if (typeof value !== typeof defaultValue) {\n return defaultValue;\n }\n\n return value;\n}\n\n/**\n * The Action runner's platform.\n */\nexport const platform = os.platform();\n\n/**\n * The Action runner's architecture.\n */\nexport const arch = os.arch();\n\n/**\n * Whether the Action runner is a Windows system.\n */\nexport const isWindows = platform === \"win32\";\n\n/**\n * Whether the Action runner is a macOS system.\n */\nexport const isMacOS = platform === \"darwin\";\n\n/**\n * Whether the Action runner is a Linux system.\n */\nexport const isLinux = platform === \"linux\";\n\n/**\n * System-level information about the current host (platform, architecture, etc.).\n */\ntype SystemDetails = {\n name: string;\n platform: string;\n arch: string;\n version: string;\n isWindows: boolean;\n isMacOS: boolean;\n isLinux: boolean;\n};\n\n/**\n * Get system-level information about the current host (platform, architecture, etc.).\n */\nexport async function getDetails(): Promise {\n return {\n ...(await (isWindows\n ? getWindowsInfo()\n : isMacOS\n ? getMacOsInfo()\n : getLinuxInfo())),\n platform,\n arch,\n isWindows,\n isMacOS,\n isLinux,\n };\n}\n","import * as actionsCore from \"@actions/core\";\nimport { createHash } from \"node:crypto\";\n\nconst OPTIONAL_VARIABLES = [\"INVOCATION_ID\"];\n\n// JSON sent to server\n/* eslint-disable camelcase */\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 job: hashEnvironmentVariables(\"GHWJ\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n ]),\n run: hashEnvironmentVariables(\"GHWJR\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n ]),\n run_differentiator: hashEnvironmentVariables(\"GHWJA\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n \"GITHUB_RUN_NUMBER\",\n \"GITHUB_RUN_ATTEMPT\",\n \"INVOCATION_ID\",\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 let value = process.env[varName];\n\n if (value === undefined) {\n if (OPTIONAL_VARIABLES.includes(varName)) {\n actionsCore.debug(\n `Optional environment variable not set: ${varName} -- substituting with the variable name`,\n );\n value = varName;\n } else {\n actionsCore.debug(\n `Environment variable not set: ${varName} -- can't generate the requested identity`,\n );\n return undefined;\n }\n }\n\n hash.update(value);\n hash.update(\"\\0\");\n }\n\n return `${prefix}-${hash.digest(\"hex\")}`;\n}\n","/**\n * @packageDocumentation\n * Helpers for determining system attributes of the current runner.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get the current architecture plus OS. Examples include `X64-Linux` and `ARM64-macOS`.\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\n/**\n * Get the current Nix system. Examples include `x86_64-linux` and `aarch64-darwin`.\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","/**\n * @packageDocumentation\n * Helpers for getting values from an Action's configuration.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get a Boolean input from the Action's configuration by name.\n */\nconst getBool = (name: string): boolean => {\n return actionsCore.getBooleanInput(name);\n};\n\n/**\n * Get a multi-line string input from the Action's configuration by name or return `null` if not set.\n */\nconst getMultilineStringOrNull = (name: string): string[] | null => {\n const value = actionsCore.getMultilineInput(name);\n if (value.length === 0) {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a number input from the Action's configuration by name or return `null` if not set.\n */\nconst getNumberOrNull = (name: string): number | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return Number(value);\n }\n};\n\n/**\n * Get a string input from the Action's configuration.\n */\nconst getString = (name: string): string => {\n return actionsCore.getInput(name);\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `null` if not set.\n */\nconst getStringOrNull = (name: string): string | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `undefined` if not set.\n */\nconst getStringOrUndefined = (name: string): string | undefined => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return undefined;\n } else {\n return value;\n }\n};\n\nexport {\n getBool,\n getMultilineStringOrNull,\n getNumberOrNull,\n getString,\n getStringOrNull,\n getStringOrUndefined,\n};\n","import { getStringOrUndefined } from \"./inputs.js\";\nimport * 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 = getStringOrUndefined(`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 = getStringOrUndefined(`${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","/**\n * @packageDocumentation\n * Determinate Systems' TypeScript library for creating GitHub Actions logic.\n */\nimport { version as pkgVersion } from \"../package.json\";\nimport * as ghActionsCorePlatform from \"./actions-core-platform.js\";\nimport * as correlation from \"./correlation.js\";\nimport * as platform from \"./platform.js\";\nimport { SourceDef, constructSourceParameters } from \"./sourcedef.js\";\nimport * as actionsCache from \"@actions/cache\";\nimport * as actionsCore from \"@actions/core\";\nimport got, { Got } from \"got\";\nimport { UUID, randomUUID } from \"node:crypto\";\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\";\n\nconst DEFAULT_IDS_HOST = \"https://install.determinate.systems\";\nconst IDS_HOST = process.env[\"IDS_HOST\"] ?? DEFAULT_IDS_HOST;\n\nconst EVENT_EXCEPTION = \"exception\";\nconst EVENT_ARTIFACT_CACHE_HIT = \"artifact_cache_hit\";\nconst EVENT_ARTIFACT_CACHE_MISS = \"artifact_cache_miss\";\n\nconst FACT_ENDED_WITH_EXCEPTION = \"ended_with_exception\";\nconst FACT_FINAL_EXCEPTION = \"final_exception\";\n\nexport type FetchSuffixStyle = \"nix-style\" | \"gh-env-style\" | \"universal\";\nexport type ExecutionPhase = \"main\" | \"post\";\nexport type NixRequirementHandling = \"fail\" | \"warn\" | \"ignore\";\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 // Check if Nix is installed before running this action.\n // If Nix isn't installed, this action will not fail, and will instead do nothing.\n // The action will emit a user-visible warning instructing them to install Nix.\n requireNix: NixRequirementHandling;\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 requireNix: NixRequirementHandling;\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 uuid: UUID;\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 private hookMain?: () => Promise;\n private hookPost?: () => Promise;\n\n constructor(actionOptions: ActionOptions) {\n this.actionOptions = makeOptionsConfident(actionOptions);\n this.hookMain = undefined;\n this.hookPost = undefined;\n\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 // JSON sent to server\n /* eslint-disable camelcase */\n this.facts = {\n $lib: \"idslib\",\n $lib_version: pkgVersion,\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 ghActionsCorePlatform\n .getDetails()\n // eslint-disable-next-line github/no-then\n .then((details) => {\n if (details.name !== \"unknown\") {\n this.addFact(\"$os\", details.name);\n }\n if (details.version !== \"unknown\") {\n this.addFact(\"$os_version\", details.version);\n }\n })\n // eslint-disable-next-line github/no-then\n .catch((e) => {\n actionsCore.debug(`Failure getting platform details: ${e}`);\n });\n }\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 onMain(callback: () => Promise): void {\n this.hookMain = callback;\n }\n\n onPost(callback: () => Promise): void {\n this.hookPost = callback;\n }\n\n execute(): void {\n // eslint-disable-next-line github/no-then\n this.executeAsync().catch((error: Error) => {\n // eslint-disable-next-line no-console\n console.log(error);\n process.exitCode = 1;\n });\n }\n\n private async executeAsync(): Promise {\n try {\n process.env.DETSYS_CORRELATION = JSON.stringify(\n this.getCorrelationHashes(),\n );\n\n if (!(await this.preflightRequireNix())) {\n this.recordEvent(\"preflight-require-nix-denied\");\n return;\n }\n\n if (this.executionPhase === \"main\" && this.hookMain) {\n await this.hookMain();\n } else if (this.executionPhase === \"post\" && this.hookPost) {\n await this.hookPost();\n }\n this.addFact(FACT_ENDED_WITH_EXCEPTION, false);\n } catch (error) {\n this.addFact(FACT_ENDED_WITH_EXCEPTION, true);\n\n const reportable =\n error instanceof Error || typeof error == \"string\"\n ? error.toString()\n : JSON.stringify(error);\n\n this.addFact(FACT_FINAL_EXCEPTION, reportable);\n\n if (this.executionPhase === \"post\") {\n actionsCore.warning(reportable);\n } else {\n actionsCore.setFailed(reportable);\n }\n\n this.recordEvent(EVENT_EXCEPTION);\n } finally {\n await this.complete();\n }\n }\n\n addFact(key: string, value: string | boolean): void {\n this.facts[key] = value;\n }\n\n getDiagnosticsUrl(): URL | undefined {\n return this.actionOptions.diagnosticsUrl;\n }\n\n getUniqueId(): string {\n return (\n this.identity.run_differentiator ||\n process.env.RUNNER_TRACKING_ID ||\n randomUUID()\n );\n }\n\n getCorrelationHashes(): correlation.AnonymizedCorrelationHashes {\n return this.identity;\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 uuid: randomUUID(),\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 this.client.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 = this.client.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 private 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(EVENT_ARTIFACT_CACHE_HIT);\n return `${tempDir}/${this.actionOptions.name}`;\n }\n\n this.recordEvent(EVENT_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(EVENT_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 preflightRequireNix(): Promise {\n let nixLocation: string | undefined;\n\n const pathParts = (process.env[\"PATH\"] || \"\").split(\":\");\n for (const location of pathParts) {\n const candidateNix = path.join(location, \"nix\");\n\n try {\n await fs.access(candidateNix, fs.constants.X_OK);\n actionsCore.debug(`Found Nix at ${candidateNix}`);\n nixLocation = candidateNix;\n } catch {\n actionsCore.debug(`Nix not at ${candidateNix}`);\n }\n }\n this.addFact(\"nix_location\", nixLocation || \"\");\n\n if (this.actionOptions.requireNix === \"ignore\") {\n return true;\n }\n\n const currentNotFoundState = actionsCore.getState(\n \"idstoolbox_nix_not_found\",\n );\n if (currentNotFoundState === \"not-found\") {\n // It was previously not found, so don't run subsequent actions\n return false;\n }\n\n if (nixLocation !== undefined) {\n return true;\n }\n actionsCore.saveState(\"idstoolbox_nix_not_found\", \"not-found\");\n\n switch (this.actionOptions.requireNix) {\n case \"fail\":\n actionsCore.setFailed(\n \"This action can only be used when Nix is installed.\" +\n \" Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n );\n break;\n case \"warn\":\n actionsCore.warning(\n \"This action is in no-op mode because Nix is not installed.\" +\n \" Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n );\n break;\n }\n\n return false;\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 this.client.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}-${randomUUID()}`);\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 requireNix: actionOptions.requireNix,\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\n// Public exports from other files\nex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AO;AACT;AAEA,SAAS,wBACP,gBACA,WACiB;AACjB,MAAI,cAAc,MAAM;AAEtB,WAAO;AAAA,EACT;AAEA,MAAI,cAAc,QAAW;AAE3B,WAAO;AAAA,EACT;AAEA;AAKE,UAAM,6BAA6B,QAAQ,IAAI,2BAA2B;AAC1E,QAAI,+BAA+B,IAAI;AAErC,aAAO;AAAA,IACT;AAEA,QAAI,+BAA+B,QAAW;AAC5C,UAAI;AACF,eAAO,wBAAwB,IAAI,IAAI,0BAA0B,CAAC;AAAA,MACpE,SAAS,GAAG;AACV,QAAY;AAAA,UACV,+DAA+D,CAAC;AAAA,QAClE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,MAAI;AACF,UAAM,gBAAgB,IAAI,IAAI,QAAQ;AACtC,kBAAc,YAAY;AAC1B,kBAAc,YAAY;AAC1B,WAAO;AAAA,EACT,SAAS,GAAG;AACV,IAAY;AAAA,MACV,2DAA2D,CAAC;AAAA,IAC9D;AAAA,EACF;AAEA,SAAO;AACT;AAEA,SAAS,wBAAwB,UAAoB;AACnD,MAAI,qBAAqB,UAAU;AACjC,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,iBAAiB,IAAI,IAAI,gBAAgB;AAC/C,UAAM,iBAAiB,IAAI,IAAI,QAAQ;AAEvC,QAAI,SAAS,WAAW,eAAe,QAAQ;AAC7C,aAAO;AAAA,IACT;AAEA,aAAS,WAAW,eAAe;AACnC,aAAS,OAAO,eAAe;AAC/B,aAAS,WAAW,eAAe;AACnC,aAAS,WAAW,eAAe;AAEnC,WAAO;AAAA,EACT,SAAS,GAAG;AACV,IAAY,kBAAK,qDAAqD,CAAC,EAAE;AAAA,EAC3E;AAEA,SAAO;AACT;","names":["searchOsreleaseFileList","options","error","os","version","platform","arch","actionsCore","actionsCore","actionsCore","actionsCore","fs","error","version"]} \ No newline at end of file +{"version":3,"sources":["../package.json","../src/linux-release-info.ts","../src/actions-core-platform.ts","../src/correlation.ts","../src/platform.ts","../src/inputs.ts","../src/sourcedef.ts","../src/index.ts"],"sourcesContent":["{\n \"name\": \"detsys-ts\",\n \"version\": \"1.0.0\",\n \"description\": \"TypeScript goodies for DetSys projects\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"check-fmt\": \"prettier --check .\",\n \"format\": \"prettier --write .\",\n \"lint\": \"eslint src/**/*.ts\",\n \"docs\": \"typedoc src/index.ts\",\n \"all\": \"rm -rf dist && 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\": \"MIT\",\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.1\",\n \"@actions/exec\": \"^1.1.1\",\n \"got\": \"^14.2.1\"\n },\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/node\": \"^20.12.7\",\n \"@typescript-eslint/eslint-plugin\": \"^7.6.0\",\n \"eslint\": \"^8.57.0\",\n \"eslint-import-resolver-typescript\": \"^3.6.1\",\n \"eslint-plugin-github\": \"^4.10.2\",\n \"eslint-plugin-import\": \"^2.29.1\",\n \"eslint-plugin-prettier\": \"^5.1.3\",\n \"prettier\": \"^3.2.5\",\n \"tsup\": \"^8.0.2\",\n \"typedoc\": \"^0.25.13\",\n \"typescript\": \"^5.4.5\"\n }\n}\n","/*!\n * linux-release-info\n * Get Linux release info (distribution name, version, arch, release, etc.)\n * from '/etc/os-release' or '/usr/lib/os-release' files and from native os\n * module. On Windows and Darwin platforms it only returns common node os module\n * info (platform, hostname, release, and arch)\n *\n * Licensed under MIT\n * Copyright (c) 2018-2020 [Samuel Carreira]\n */\n// NOTE: we depend on this directly to get around some un-fun issues with mixing CommonJS\n// and ESM in the bundle.\nimport * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport { promisify } from \"node:util\";\n\nconst readFileAsync = promisify(fs.readFile);\n\nexport interface LinuxReleaseInfoOptions {\n /**\n * read mode, possible values: 'async' and 'sync'\n *\n * @default 'async'\n */\n mode?: \"async\" | \"sync\";\n /**\n * custom complete file path with os info default null/none\n * if not provided the system will search on the '/etc/os-release'\n * and '/usr/lib/os-release' files\n *\n * @default null\n */\n customFile?: string | null | undefined;\n /**\n * if true, show console debug messages\n *\n * @default false\n */\n debug?: boolean;\n}\n\nconst linuxReleaseInfoOptionsDefaults: LinuxReleaseInfoOptions = {\n mode: \"async\",\n customFile: null,\n debug: false,\n};\n\n/**\n * Get OS release info from 'os-release' file and from native os module\n * on Windows or Darwin it only returns common os module info\n * (uses native fs module)\n * @returns {object} info from the current os\n */\nexport function releaseInfo(infoOptions: LinuxReleaseInfoOptions): object {\n const options = { ...linuxReleaseInfoOptionsDefaults, ...infoOptions };\n\n const searchOsReleaseFileList: string[] = osreleaseFileList(\n options.customFile,\n );\n\n async function readAsyncOsReleaseFile(\n fileList: string[],\n releaseInfoOptions: LinuxReleaseInfoOptions,\n ): Promise {\n let fileData = null;\n\n for (const osReleaseFile of fileList) {\n try {\n if (releaseInfoOptions.debug) {\n /* eslint-disable no-console */\n console.log(`Trying to read '${osReleaseFile}'...`);\n }\n\n fileData = await readFileAsync(osReleaseFile, \"binary\");\n\n if (releaseInfoOptions.debug) {\n console.log(`Read data:\\n${fileData}`);\n }\n\n break;\n } catch (error) {\n if (releaseInfoOptions.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n }\n\n function readSyncOsreleaseFile(\n releaseFileList: string[],\n releaseInfoOptions: LinuxReleaseInfoOptions,\n ): OsInfo {\n let fileData = null;\n\n for (const osReleaseFile of releaseFileList) {\n try {\n if (releaseInfoOptions.debug) {\n console.log(`Trying to read '${osReleaseFile}'...`);\n }\n\n fileData = fs.readFileSync(osReleaseFile, \"binary\");\n\n if (releaseInfoOptions.debug) {\n console.log(`Read data:\\n${fileData}`);\n }\n\n break;\n } catch (error) {\n if (releaseInfoOptions.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n }\n\n if (os.type() !== \"Linux\") {\n if (options.mode === \"sync\") {\n return getOsInfo();\n } else {\n return Promise.resolve(getOsInfo());\n }\n }\n\n if (options.mode === \"sync\") {\n return readSyncOsreleaseFile(searchOsReleaseFileList, options);\n } else {\n return Promise.resolve(\n readAsyncOsReleaseFile(searchOsReleaseFileList, options),\n );\n }\n}\n\n/**\n * Format file data: convert data to object keys/values\n *\n * @param {object} sourceData Source object to be appended\n * @param {string} srcParseData Input file data to be parsed\n * @returns {object} Formated object\n */\nfunction formatFileData(sourceData: OsInfo, srcParseData: string): OsInfo {\n const lines: string[] = srcParseData.split(\"\\n\");\n\n for (const line of lines) {\n const lineData = line.split(\"=\");\n\n if (lineData.length === 2) {\n lineData[1] = lineData[1].replace(/[\"'\\r]/gi, \"\"); // remove quotes and return character\n\n Object.defineProperty(sourceData, lineData[0].toLowerCase(), {\n value: lineData[1],\n writable: true,\n enumerable: true,\n configurable: true,\n });\n }\n }\n\n return sourceData;\n}\n\n/**\n * Export a list of os-release files\n *\n * @param {string} customFile optional custom complete filepath\n * @returns {array} list of os-release files\n */\nfunction osreleaseFileList(customFile: string | null | undefined): string[] {\n const DEFAULT_OS_RELEASE_FILES = [\"/etc/os-release\", \"/usr/lib/os-release\"];\n\n if (!customFile) {\n return DEFAULT_OS_RELEASE_FILES;\n } else {\n return Array(customFile);\n }\n}\n\n/**\n * Operating system info.\n */\ntype OsInfo = {\n type: string;\n platform: string;\n hostname: string;\n arch: string;\n release: string;\n};\n\n/**\n * Get OS Basic Info\n * (uses node 'os' native module)\n *\n * @returns {OsInfo} os basic info\n */\nfunction getOsInfo(): OsInfo {\n return {\n type: os.type(),\n platform: os.platform(),\n hostname: os.hostname(),\n arch: os.arch(),\n release: os.release(),\n };\n}\n","// MIT, mostly lifted from https://github.com/actions/toolkit/blob/5a736647a123ecf8582376bdaee833fbae5b3847/packages/core/src/platform.ts\n// since it isn't in @actions/core 1.10.1 which is their current release as 2024-04-19.\n// Changes: Replaced the lsb_release call in Linux with `linux-release-info` to parse the os-release file directly.\nimport { releaseInfo } from \"./linux-release-info.js\";\nimport * as core from \"@actions/core\";\nimport * as exec from \"@actions/exec\";\nimport os from \"os\";\n\n/**\n * The name and version of the Action runner's system.\n */\ntype SystemInfo = {\n name: string;\n version: string;\n};\n\n/**\n * Get the name and version of the current Windows system.\n */\nconst getWindowsInfo = async (): Promise => {\n const { stdout: version } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Version\"',\n undefined,\n {\n silent: true,\n },\n );\n\n const { stdout: name } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Caption\"',\n undefined,\n {\n silent: true,\n },\n );\n\n return {\n name: name.trim(),\n version: version.trim(),\n };\n};\n\n/**\n * Get the name and version of the current macOS system.\n */\nconst getMacOsInfo = async (): Promise => {\n const { stdout } = await exec.getExecOutput(\"sw_vers\", undefined, {\n silent: true,\n });\n\n const version = stdout.match(/ProductVersion:\\s*(.+)/)?.[1] ?? \"\";\n const name = stdout.match(/ProductName:\\s*(.+)/)?.[1] ?? \"\";\n\n return {\n name,\n version,\n };\n};\n\n/**\n * Get the name and version of the current Linux system.\n */\nconst getLinuxInfo = async (): Promise => {\n let data: object = {};\n\n try {\n data = releaseInfo({ mode: \"sync\" });\n // eslint-disable-next-line no-console\n console.log(data);\n } catch (e) {\n core.debug(`Error collecting release info: ${e}`);\n }\n\n return {\n name: getPropertyViaWithDefault(\n data,\n [\"id\", \"name\", \"pretty_name\", \"id_like\"],\n \"unknown\",\n ),\n version: getPropertyViaWithDefault(\n data,\n [\"version_id\", \"version\", \"version_codename\"],\n \"unknown\",\n ),\n };\n};\n\nfunction getPropertyViaWithDefault(\n data: object,\n names: Property[],\n defaultValue: T,\n): T {\n for (const name of names) {\n const ret: T = getPropertyWithDefault(data, name, defaultValue);\n\n if (ret !== defaultValue) {\n return ret;\n }\n }\n\n return defaultValue;\n}\n\nfunction getPropertyWithDefault(\n data: object,\n name: Property,\n defaultValue: T,\n): T {\n if (!data.hasOwnProperty(name)) {\n return defaultValue;\n }\n\n const value = (data as { [K in Property]: T })[name];\n\n // NB. this check won't work for object instances\n if (typeof value !== typeof defaultValue) {\n return defaultValue;\n }\n\n return value;\n}\n\n/**\n * The Action runner's platform.\n */\nexport const platform = os.platform();\n\n/**\n * The Action runner's architecture.\n */\nexport const arch = os.arch();\n\n/**\n * Whether the Action runner is a Windows system.\n */\nexport const isWindows = platform === \"win32\";\n\n/**\n * Whether the Action runner is a macOS system.\n */\nexport const isMacOS = platform === \"darwin\";\n\n/**\n * Whether the Action runner is a Linux system.\n */\nexport const isLinux = platform === \"linux\";\n\n/**\n * System-level information about the current host (platform, architecture, etc.).\n */\ntype SystemDetails = {\n name: string;\n platform: string;\n arch: string;\n version: string;\n isWindows: boolean;\n isMacOS: boolean;\n isLinux: boolean;\n};\n\n/**\n * Get system-level information about the current host (platform, architecture, etc.).\n */\nexport async function getDetails(): Promise {\n return {\n ...(await (isWindows\n ? getWindowsInfo()\n : isMacOS\n ? getMacOsInfo()\n : getLinuxInfo())),\n platform,\n arch,\n isWindows,\n isMacOS,\n isLinux,\n };\n}\n","import * as actionsCore from \"@actions/core\";\nimport { createHash } from \"node:crypto\";\n\nconst OPTIONAL_VARIABLES = [\"INVOCATION_ID\"];\n\n// JSON sent to server\n/* eslint-disable camelcase */\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 job: hashEnvironmentVariables(\"GHWJ\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n ]),\n run: hashEnvironmentVariables(\"GHWJR\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n ]),\n run_differentiator: hashEnvironmentVariables(\"GHWJA\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n \"GITHUB_RUN_NUMBER\",\n \"GITHUB_RUN_ATTEMPT\",\n \"INVOCATION_ID\",\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 let value = process.env[varName];\n\n if (value === undefined) {\n if (OPTIONAL_VARIABLES.includes(varName)) {\n actionsCore.debug(\n `Optional environment variable not set: ${varName} -- substituting with the variable name`,\n );\n value = varName;\n } else {\n actionsCore.debug(\n `Environment variable not set: ${varName} -- can't generate the requested identity`,\n );\n return undefined;\n }\n }\n\n hash.update(value);\n hash.update(\"\\0\");\n }\n\n return `${prefix}-${hash.digest(\"hex\")}`;\n}\n","/**\n * @packageDocumentation\n * Helpers for determining system attributes of the current runner.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get the current architecture plus OS. Examples include `X64-Linux` and `ARM64-macOS`.\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\n/**\n * Get the current Nix system. Examples include `x86_64-linux` and `aarch64-darwin`.\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","/**\n * @packageDocumentation\n * Helpers for getting values from an Action's configuration.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get a Boolean input from the Action's configuration by name.\n */\nconst getBool = (name: string): boolean => {\n return actionsCore.getBooleanInput(name);\n};\n\n/**\n * Get a multi-line string input from the Action's configuration by name or return `null` if not set.\n */\nconst getMultilineStringOrNull = (name: string): string[] | null => {\n const value = actionsCore.getMultilineInput(name);\n if (value.length === 0) {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a number input from the Action's configuration by name or return `null` if not set.\n */\nconst getNumberOrNull = (name: string): number | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return Number(value);\n }\n};\n\n/**\n * Get a string input from the Action's configuration.\n */\nconst getString = (name: string): string => {\n return actionsCore.getInput(name);\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `null` if not set.\n */\nconst getStringOrNull = (name: string): string | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `undefined` if not set.\n */\nconst getStringOrUndefined = (name: string): string | undefined => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return undefined;\n } else {\n return value;\n }\n};\n\nexport {\n getBool,\n getMultilineStringOrNull,\n getNumberOrNull,\n getString,\n getStringOrNull,\n getStringOrUndefined,\n};\n","import { getStringOrUndefined } from \"./inputs.js\";\nimport * 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 = getStringOrUndefined(`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 = getStringOrUndefined(`${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","/**\n * @packageDocumentation\n * Determinate Systems' TypeScript library for creating GitHub Actions logic.\n */\nimport { version as pkgVersion } from \"../package.json\";\nimport * as ghActionsCorePlatform from \"./actions-core-platform.js\";\nimport * as correlation from \"./correlation.js\";\nimport * as platform from \"./platform.js\";\nimport { SourceDef, constructSourceParameters } from \"./sourcedef.js\";\nimport * as actionsCache from \"@actions/cache\";\nimport * as actionsCore from \"@actions/core\";\nimport got, { Got } from \"got\";\nimport { UUID, randomUUID } from \"node:crypto\";\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\";\n\nconst DEFAULT_IDS_HOST = \"https://install.determinate.systems\";\nconst IDS_HOST = process.env[\"IDS_HOST\"] ?? DEFAULT_IDS_HOST;\n\nconst EVENT_EXCEPTION = \"exception\";\nconst EVENT_ARTIFACT_CACHE_HIT = \"artifact_cache_hit\";\nconst EVENT_ARTIFACT_CACHE_MISS = \"artifact_cache_miss\";\n\nconst FACT_ENDED_WITH_EXCEPTION = \"ended_with_exception\";\nconst FACT_FINAL_EXCEPTION = \"final_exception\";\n\nexport type FetchSuffixStyle = \"nix-style\" | \"gh-env-style\" | \"universal\";\nexport type ExecutionPhase = \"main\" | \"post\";\nexport type NixRequirementHandling = \"fail\" | \"warn\" | \"ignore\";\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 // Check if Nix is installed before running this action.\n // If Nix isn't installed, this action will not fail, and will instead do nothing.\n // The action will emit a user-visible warning instructing them to install Nix.\n requireNix: NixRequirementHandling;\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 requireNix: NixRequirementHandling;\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 uuid: UUID;\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 private hookMain?: () => Promise;\n private hookPost?: () => Promise;\n\n constructor(actionOptions: ActionOptions) {\n this.actionOptions = makeOptionsConfident(actionOptions);\n this.hookMain = undefined;\n this.hookPost = undefined;\n\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 // JSON sent to server\n /* eslint-disable camelcase */\n this.facts = {\n $lib: \"idslib\",\n $lib_version: pkgVersion,\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 ghActionsCorePlatform\n .getDetails()\n // eslint-disable-next-line github/no-then\n .then((details) => {\n if (details.name !== \"unknown\") {\n this.addFact(\"$os\", details.name);\n }\n if (details.version !== \"unknown\") {\n this.addFact(\"$os_version\", details.version);\n }\n })\n // eslint-disable-next-line github/no-then\n .catch((e) => {\n actionsCore.debug(`Failure getting platform details: ${e}`);\n });\n }\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 onMain(callback: () => Promise): void {\n this.hookMain = callback;\n }\n\n onPost(callback: () => Promise): void {\n this.hookPost = callback;\n }\n\n execute(): void {\n // eslint-disable-next-line github/no-then\n this.executeAsync().catch((error: Error) => {\n // eslint-disable-next-line no-console\n console.log(error);\n process.exitCode = 1;\n });\n }\n\n private async executeAsync(): Promise {\n try {\n process.env.DETSYS_CORRELATION = JSON.stringify(\n this.getCorrelationHashes(),\n );\n\n if (!(await this.preflightRequireNix())) {\n this.recordEvent(\"preflight-require-nix-denied\");\n return;\n }\n\n if (this.executionPhase === \"main\" && this.hookMain) {\n await this.hookMain();\n } else if (this.executionPhase === \"post\" && this.hookPost) {\n await this.hookPost();\n }\n this.addFact(FACT_ENDED_WITH_EXCEPTION, false);\n } catch (error) {\n this.addFact(FACT_ENDED_WITH_EXCEPTION, true);\n\n const reportable =\n error instanceof Error || typeof error == \"string\"\n ? error.toString()\n : JSON.stringify(error);\n\n this.addFact(FACT_FINAL_EXCEPTION, reportable);\n\n if (this.executionPhase === \"post\") {\n actionsCore.warning(reportable);\n } else {\n actionsCore.setFailed(reportable);\n }\n\n this.recordEvent(EVENT_EXCEPTION);\n } finally {\n await this.complete();\n }\n }\n\n addFact(key: string, value: string | boolean): void {\n this.facts[key] = value;\n }\n\n getDiagnosticsUrl(): URL | undefined {\n return this.actionOptions.diagnosticsUrl;\n }\n\n getUniqueId(): string {\n return (\n this.identity.run_differentiator ||\n process.env.RUNNER_TRACKING_ID ||\n randomUUID()\n );\n }\n\n getCorrelationHashes(): correlation.AnonymizedCorrelationHashes {\n return this.identity;\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 uuid: randomUUID(),\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 this.client.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 = this.client.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 private 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(EVENT_ARTIFACT_CACHE_HIT);\n return `${tempDir}/${this.actionOptions.name}`;\n }\n\n this.recordEvent(EVENT_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(EVENT_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 preflightRequireNix(): Promise {\n let nixLocation: string | undefined;\n\n const pathParts = (process.env[\"PATH\"] || \"\").split(\":\");\n for (const location of pathParts) {\n const candidateNix = path.join(location, \"nix\");\n\n try {\n await fs.access(candidateNix, fs.constants.X_OK);\n actionsCore.debug(`Found Nix at ${candidateNix}`);\n nixLocation = candidateNix;\n } catch {\n actionsCore.debug(`Nix not at ${candidateNix}`);\n }\n }\n this.addFact(\"nix_location\", nixLocation || \"\");\n\n if (this.actionOptions.requireNix === \"ignore\") {\n return true;\n }\n\n const currentNotFoundState = actionsCore.getState(\n \"idstoolbox_nix_not_found\",\n );\n if (currentNotFoundState === \"not-found\") {\n // It was previously not found, so don't run subsequent actions\n return false;\n }\n\n if (nixLocation !== undefined) {\n return true;\n }\n actionsCore.saveState(\"idstoolbox_nix_not_found\", \"not-found\");\n\n switch (this.actionOptions.requireNix) {\n case \"fail\":\n actionsCore.setFailed(\n \"This action can only be used when Nix is installed.\" +\n \" Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n );\n break;\n case \"warn\":\n actionsCore.warning(\n \"This action is in no-op mode because Nix is not installed.\" +\n \" Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n );\n break;\n }\n\n return false;\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 this.client.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}-${randomUUID()}`);\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 requireNix: actionOptions.requireNix,\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\n// Public exports from other files\nexport * as inputs from \"./inputs.js\";\nexport * as platform from \"./platform.js\";\n"],"mappings":";;;;;;;AAEE,cAAW;;;ACUb,YAAY,QAAQ;AACpB,YAAY,QAAQ;AACpB,SAAS,iBAAiB;AAE1B,IAAM,gBAAgB,UAAa,WAAQ;AAyB3C,IAAM,kCAA2D;AAAA,EAC/D,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,OAAO;AACT;AAQO,SAAS,YAAY,aAA8C;AACxE,QAAM,UAAU,EAAE,GAAG,iCAAiC,GAAG,YAAY;AAErE,QAAM,0BAAoC;AAAA,IACxC,QAAQ;AAAA,EACV;AAEA,iBAAe,uBACb,UACA,oBACiB;AACjB,QAAI,WAAW;AAEf,eAAW,iBAAiB,UAAU;AACpC,UAAI;AACF,YAAI,mBAAmB,OAAO;AAE5B,kBAAQ,IAAI,mBAAmB,aAAa,MAAM;AAAA,QACpD;AAEA,mBAAW,MAAM,cAAc,eAAe,QAAQ;AAEtD,YAAI,mBAAmB,OAAO;AAC5B,kBAAQ,IAAI;AAAA,EAAe,QAAQ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oB;AACnD,MAAI,qBAAqB,UAAU;AACjC,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,iBAAiB,IAAI,IAAI,gBAAgB;AAC/C,UAAM,iBAAiB,IAAI,IAAI,QAAQ;AAEvC,QAAI,SAAS,WAAW,eAAe,QAAQ;AAC7C,aAAO;AAAA,IACT;AAEA,aAAS,WAAW,eAAe;AACnC,aAAS,OAAO,eAAe;AAC/B,aAAS,WAAW,eAAe;AACnC,aAAS,WAAW,eAAe;AAEnC,WAAO;AAAA,EACT,SAAS,GAAG;AACV,IAAY,kBAAK,qDAAqD,CAAC,EAAE;AAAA,EAC3E;AAEA,SAAO;AACT;","names":["error","os","version","platform","arch","actionsCore","actionsCore","actionsCore","actionsCore","fs","error","version"]} \ No newline at end of file diff --git a/src/linux-release-info.ts b/src/linux-release-info.ts index d43f7dd..5ff11a0 100644 --- a/src/linux-release-info.ts +++ b/src/linux-release-info.ts @@ -30,7 +30,7 @@ export interface LinuxReleaseInfoOptions { * * @default null */ - custom_file?: string | null | undefined; + customFile?: string | null | undefined; /** * if true, show console debug messages * @@ -41,7 +41,7 @@ export interface LinuxReleaseInfoOptions { const linuxReleaseInfoOptionsDefaults: LinuxReleaseInfoOptions = { mode: "async", - custom_file: null, + customFile: null, debug: false, }; @@ -51,34 +51,35 @@ const linuxReleaseInfoOptionsDefaults: LinuxReleaseInfoOptions = { * (uses native fs module) * @returns {object} info from the current os */ -export function releaseInfo(options: LinuxReleaseInfoOptions): object { - options = { ...linuxReleaseInfoOptionsDefaults, ...options }; +export function releaseInfo(infoOptions: LinuxReleaseInfoOptions): object { + const options = { ...linuxReleaseInfoOptionsDefaults, ...infoOptions }; - const searchOsreleaseFileList: string[] = osreleaseFileList( - options.custom_file, + const searchOsReleaseFileList: string[] = osreleaseFileList( + options.customFile, ); - async function readAsyncOsreleaseFile( - searchOsreleaseFileList: string[], - options: LinuxReleaseInfoOptions, - ) { + async function readAsyncOsReleaseFile( + fileList: string[], + releaseInfoOptions: LinuxReleaseInfoOptions, + ): Promise { let fileData = null; - for (let os_release_file of searchOsreleaseFileList) { + for (const osReleaseFile of fileList) { try { - if (options.debug) { - console.log(`Trying to read '${os_release_file}'...`); + if (releaseInfoOptions.debug) { + /* eslint-disable no-console */ + console.log(`Trying to read '${osReleaseFile}'...`); } - fileData = await readFileAsync(os_release_file, "binary"); + fileData = await readFileAsync(osReleaseFile, "binary"); - if (options.debug) { - console.log("Read data:\n" + fileData); + if (releaseInfoOptions.debug) { + console.log(`Read data:\n${fileData}`); } break; } catch (error) { - if (options.debug) { + if (releaseInfoOptions.debug) { console.error(error); } } @@ -93,26 +94,26 @@ export function releaseInfo(options: LinuxReleaseInfoOptions): object { } function readSyncOsreleaseFile( - searchOsreleaseFileList: string[], - options: LinuxReleaseInfoOptions, - ) { + releaseFileList: string[], + releaseInfoOptions: LinuxReleaseInfoOptions, + ): OsInfo { let fileData = null; - for (let os_release_file of searchOsreleaseFileList) { + for (const osReleaseFile of releaseFileList) { try { - if (options.debug) { - console.log(`Trying to read '${os_release_file}'...`); + if (releaseInfoOptions.debug) { + console.log(`Trying to read '${osReleaseFile}'...`); } - fileData = fs.readFileSync(os_release_file, "binary"); + fileData = fs.readFileSync(osReleaseFile, "binary"); - if (options.debug) { - console.log("Read data:\n" + fileData); + if (releaseInfoOptions.debug) { + console.log(`Read data:\n${fileData}`); } break; } catch (error) { - if (options.debug) { + if (releaseInfoOptions.debug) { console.error(error); } } @@ -135,10 +136,10 @@ export function releaseInfo(options: LinuxReleaseInfoOptions): object { } if (options.mode === "sync") { - return readSyncOsreleaseFile(searchOsreleaseFileList, options); + return readSyncOsreleaseFile(searchOsReleaseFileList, options); } else { return Promise.resolve( - readAsyncOsreleaseFile(searchOsreleaseFileList, options), + readAsyncOsReleaseFile(searchOsReleaseFileList, options), ); } } @@ -150,24 +151,23 @@ export function releaseInfo(options: LinuxReleaseInfoOptions): object { * @param {string} srcParseData Input file data to be parsed * @returns {object} Formated object */ -function formatFileData(sourceData: any, srcParseData: any): any { - const lines = srcParseData.split("\n"); +function formatFileData(sourceData: OsInfo, srcParseData: string): OsInfo { + const lines: string[] = srcParseData.split("\n"); - // @ts-ignore - lines.forEach((element) => { - const linedata = element.split("="); + for (const line of lines) { + const lineData = line.split("="); - if (linedata.length === 2) { - linedata[1] = linedata[1].replace(/["'\r]/gi, ""); // remove quotes and return character + if (lineData.length === 2) { + lineData[1] = lineData[1].replace(/["'\r]/gi, ""); // remove quotes and return character - Object.defineProperty(sourceData, linedata[0].toLowerCase(), { - value: linedata[1], + Object.defineProperty(sourceData, lineData[0].toLowerCase(), { + value: lineData[1], writable: true, enumerable: true, configurable: true, }); } - }); + } return sourceData; } @@ -188,20 +188,29 @@ function osreleaseFileList(customFile: string | null | undefined): string[] { } } +/** + * Operating system info. + */ +type OsInfo = { + type: string; + platform: string; + hostname: string; + arch: string; + release: string; +}; + /** * Get OS Basic Info * (uses node 'os' native module) * - * @returns {object} os basic info + * @returns {OsInfo} os basic info */ -function getOsInfo() { - const osInfo = { +function getOsInfo(): OsInfo { + return { type: os.type(), platform: os.platform(), hostname: os.hostname(), arch: os.arch(), release: os.release(), }; - - return osInfo; } From e3d9109f7e09a0433faf4733d858305582406ed8 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Sat, 20 Apr 2024 22:18:57 -0300 Subject: [PATCH 3/6] Move inline functions into top level --- dist/index.js | 100 +++++++++++++------------- dist/index.js.map | 2 +- src/linux-release-info.ts | 144 +++++++++++++++++++------------------- 3 files changed, 124 insertions(+), 122 deletions(-) diff --git a/dist/index.js b/dist/index.js index 6cce2a6..1836c0d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -19,57 +19,9 @@ var linuxReleaseInfoOptionsDefaults = { }; function releaseInfo(infoOptions) { const options = { ...linuxReleaseInfoOptionsDefaults, ...infoOptions }; - const searchOsReleaseFileList = osreleaseFileList( + const searchOsReleaseFileList = osReleaseFileList( options.customFile ); - async function readAsyncOsReleaseFile(fileList, releaseInfoOptions) { - let fileData = null; - for (const osReleaseFile of fileList) { - try { - if (releaseInfoOptions.debug) { - console.log(`Trying to read '${osReleaseFile}'...`); - } - fileData = await readFileAsync(osReleaseFile, "binary"); - if (releaseInfoOptions.debug) { - console.log(`Read data: -${fileData}`); - } - break; - } catch (error2) { - if (releaseInfoOptions.debug) { - console.error(error2); - } - } - } - if (fileData === null) { - throw new Error("Cannot read os-release file!"); - } - return formatFileData(getOsInfo(), fileData); - } - function readSyncOsreleaseFile(releaseFileList, releaseInfoOptions) { - let fileData = null; - for (const osReleaseFile of releaseFileList) { - try { - if (releaseInfoOptions.debug) { - console.log(`Trying to read '${osReleaseFile}'...`); - } - fileData = fs.readFileSync(osReleaseFile, "binary"); - if (releaseInfoOptions.debug) { - console.log(`Read data: -${fileData}`); - } - break; - } catch (error2) { - if (releaseInfoOptions.debug) { - console.error(error2); - } - } - } - if (fileData === null) { - throw new Error("Cannot read os-release file!"); - } - return formatFileData(getOsInfo(), fileData); - } if (os.type() !== "Linux") { if (options.mode === "sync") { return getOsInfo(); @@ -101,7 +53,7 @@ function formatFileData(sourceData, srcParseData) { } return sourceData; } -function osreleaseFileList(customFile) { +function osReleaseFileList(customFile) { const DEFAULT_OS_RELEASE_FILES = ["/etc/os-release", "/usr/lib/os-release"]; if (!customFile) { return DEFAULT_OS_RELEASE_FILES; @@ -118,6 +70,54 @@ function getOsInfo() { release: os.release() }; } +async function readAsyncOsReleaseFile(fileList, releaseInfoOptions) { + let fileData = null; + for (const osReleaseFile of fileList) { + try { + if (releaseInfoOptions.debug) { + console.log(`Trying to read '${osReleaseFile}'...`); + } + fileData = await readFileAsync(osReleaseFile, "binary"); + if (releaseInfoOptions.debug) { + console.log(`Read data: +${fileData}`); + } + break; + } catch (error2) { + if (releaseInfoOptions.debug) { + console.error(error2); + } + } + } + if (fileData === null) { + throw new Error("Cannot read os-release file!"); + } + return formatFileData(getOsInfo(), fileData); +} +function readSyncOsreleaseFile(releaseFileList, releaseInfoOptions) { + let fileData = null; + for (const osReleaseFile of releaseFileList) { + try { + if (releaseInfoOptions.debug) { + console.log(`Trying to read '${osReleaseFile}'...`); + } + fileData = fs.readFileSync(osReleaseFile, "binary"); + if (releaseInfoOptions.debug) { + console.log(`Read data: +${fileData}`); + } + break; + } catch (error2) { + if (releaseInfoOptions.debug) { + console.error(error2); + } + } + } + if (fileData === null) { + throw new Error("Cannot read os-release file!"); + } + return formatFileData(getOsInfo(), fileData); +} // src/actions-core-platform.ts import * as core from "@actions/core"; diff --git a/dist/index.js.map b/dist/index.js.map index 3af0336..62d9ed3 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../package.json","../src/linux-release-info.ts","../src/actions-core-platform.ts","../src/correlation.ts","../src/platform.ts","../src/inputs.ts","../src/sourcedef.ts","../src/index.ts"],"sourcesContent":["{\n \"name\": \"detsys-ts\",\n \"version\": \"1.0.0\",\n \"description\": \"TypeScript goodies for DetSys projects\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"check-fmt\": \"prettier --check .\",\n \"format\": \"prettier --write .\",\n \"lint\": \"eslint src/**/*.ts\",\n \"docs\": \"typedoc src/index.ts\",\n \"all\": \"rm -rf dist && 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\": \"MIT\",\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.1\",\n \"@actions/exec\": \"^1.1.1\",\n \"got\": \"^14.2.1\"\n },\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/node\": \"^20.12.7\",\n \"@typescript-eslint/eslint-plugin\": \"^7.6.0\",\n \"eslint\": \"^8.57.0\",\n \"eslint-import-resolver-typescript\": \"^3.6.1\",\n \"eslint-plugin-github\": \"^4.10.2\",\n \"eslint-plugin-import\": \"^2.29.1\",\n \"eslint-plugin-prettier\": \"^5.1.3\",\n \"prettier\": \"^3.2.5\",\n \"tsup\": \"^8.0.2\",\n \"typedoc\": \"^0.25.13\",\n \"typescript\": \"^5.4.5\"\n }\n}\n","/*!\n * linux-release-info\n * Get Linux release info (distribution name, version, arch, release, etc.)\n * from '/etc/os-release' or '/usr/lib/os-release' files and from native os\n * module. On Windows and Darwin platforms it only returns common node os module\n * info (platform, hostname, release, and arch)\n *\n * Licensed under MIT\n * Copyright (c) 2018-2020 [Samuel Carreira]\n */\n// NOTE: we depend on this directly to get around some un-fun issues with mixing CommonJS\n// and ESM in the bundle.\nimport * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport { promisify } from \"node:util\";\n\nconst readFileAsync = promisify(fs.readFile);\n\nexport interface LinuxReleaseInfoOptions {\n /**\n * read mode, possible values: 'async' and 'sync'\n *\n * @default 'async'\n */\n mode?: \"async\" | \"sync\";\n /**\n * custom complete file path with os info default null/none\n * if not provided the system will search on the '/etc/os-release'\n * and '/usr/lib/os-release' files\n *\n * @default null\n */\n customFile?: string | null | undefined;\n /**\n * if true, show console debug messages\n *\n * @default false\n */\n debug?: boolean;\n}\n\nconst linuxReleaseInfoOptionsDefaults: LinuxReleaseInfoOptions = {\n mode: \"async\",\n customFile: null,\n debug: false,\n};\n\n/**\n * Get OS release info from 'os-release' file and from native os module\n * on Windows or Darwin it only returns common os module info\n * (uses native fs module)\n * @returns {object} info from the current os\n */\nexport function releaseInfo(infoOptions: LinuxReleaseInfoOptions): object {\n const options = { ...linuxReleaseInfoOptionsDefaults, ...infoOptions };\n\n const searchOsReleaseFileList: string[] = osreleaseFileList(\n options.customFile,\n );\n\n async function readAsyncOsReleaseFile(\n fileList: string[],\n releaseInfoOptions: LinuxReleaseInfoOptions,\n ): Promise {\n let fileData = null;\n\n for (const osReleaseFile of fileList) {\n try {\n if (releaseInfoOptions.debug) {\n /* eslint-disable no-console */\n console.log(`Trying to read '${osReleaseFile}'...`);\n }\n\n fileData = await readFileAsync(osReleaseFile, \"binary\");\n\n if (releaseInfoOptions.debug) {\n console.log(`Read data:\\n${fileData}`);\n }\n\n break;\n } catch (error) {\n if (releaseInfoOptions.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n }\n\n function readSyncOsreleaseFile(\n releaseFileList: string[],\n releaseInfoOptions: LinuxReleaseInfoOptions,\n ): OsInfo {\n let fileData = null;\n\n for (const osReleaseFile of releaseFileList) {\n try {\n if (releaseInfoOptions.debug) {\n console.log(`Trying to read '${osReleaseFile}'...`);\n }\n\n fileData = fs.readFileSync(osReleaseFile, \"binary\");\n\n if (releaseInfoOptions.debug) {\n console.log(`Read data:\\n${fileData}`);\n }\n\n break;\n } catch (error) {\n if (releaseInfoOptions.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n }\n\n if (os.type() !== \"Linux\") {\n if (options.mode === \"sync\") {\n return getOsInfo();\n } else {\n return Promise.resolve(getOsInfo());\n }\n }\n\n if (options.mode === \"sync\") {\n return readSyncOsreleaseFile(searchOsReleaseFileList, options);\n } else {\n return Promise.resolve(\n readAsyncOsReleaseFile(searchOsReleaseFileList, options),\n );\n }\n}\n\n/**\n * Format file data: convert data to object keys/values\n *\n * @param {object} sourceData Source object to be appended\n * @param {string} srcParseData Input file data to be parsed\n * @returns {object} Formated object\n */\nfunction formatFileData(sourceData: OsInfo, srcParseData: string): OsInfo {\n const lines: string[] = srcParseData.split(\"\\n\");\n\n for (const line of lines) {\n const lineData = line.split(\"=\");\n\n if (lineData.length === 2) {\n lineData[1] = lineData[1].replace(/[\"'\\r]/gi, \"\"); // remove quotes and return character\n\n Object.defineProperty(sourceData, lineData[0].toLowerCase(), {\n value: lineData[1],\n writable: true,\n enumerable: true,\n configurable: true,\n });\n }\n }\n\n return sourceData;\n}\n\n/**\n * Export a list of os-release files\n *\n * @param {string} customFile optional custom complete filepath\n * @returns {array} list of os-release files\n */\nfunction osreleaseFileList(customFile: string | null | undefined): string[] {\n const DEFAULT_OS_RELEASE_FILES = [\"/etc/os-release\", \"/usr/lib/os-release\"];\n\n if (!customFile) {\n return DEFAULT_OS_RELEASE_FILES;\n } else {\n return Array(customFile);\n }\n}\n\n/**\n * Operating system info.\n */\ntype OsInfo = {\n type: string;\n platform: string;\n hostname: string;\n arch: string;\n release: string;\n};\n\n/**\n * Get OS Basic Info\n * (uses node 'os' native module)\n *\n * @returns {OsInfo} os basic info\n */\nfunction getOsInfo(): OsInfo {\n return {\n type: os.type(),\n platform: os.platform(),\n hostname: os.hostname(),\n arch: os.arch(),\n release: os.release(),\n };\n}\n","// MIT, mostly lifted from https://github.com/actions/toolkit/blob/5a736647a123ecf8582376bdaee833fbae5b3847/packages/core/src/platform.ts\n// since it isn't in @actions/core 1.10.1 which is their current release as 2024-04-19.\n// Changes: Replaced the lsb_release call in Linux with `linux-release-info` to parse the os-release file directly.\nimport { releaseInfo } from \"./linux-release-info.js\";\nimport * as core from \"@actions/core\";\nimport * as exec from \"@actions/exec\";\nimport os from \"os\";\n\n/**\n * The name and version of the Action runner's system.\n */\ntype SystemInfo = {\n name: string;\n version: string;\n};\n\n/**\n * Get the name and version of the current Windows system.\n */\nconst getWindowsInfo = async (): Promise => {\n const { stdout: version } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Version\"',\n undefined,\n {\n silent: true,\n },\n );\n\n const { stdout: name } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Caption\"',\n undefined,\n {\n silent: true,\n },\n );\n\n return {\n name: name.trim(),\n version: version.trim(),\n };\n};\n\n/**\n * Get the name and version of the current macOS system.\n */\nconst getMacOsInfo = async (): Promise => {\n const { stdout } = await exec.getExecOutput(\"sw_vers\", undefined, {\n silent: true,\n });\n\n const version = stdout.match(/ProductVersion:\\s*(.+)/)?.[1] ?? \"\";\n const name = stdout.match(/ProductName:\\s*(.+)/)?.[1] ?? \"\";\n\n return {\n name,\n version,\n };\n};\n\n/**\n * Get the name and version of the current Linux system.\n */\nconst getLinuxInfo = async (): Promise => {\n let data: object = {};\n\n try {\n data = releaseInfo({ mode: \"sync\" });\n // eslint-disable-next-line no-console\n console.log(data);\n } catch (e) {\n core.debug(`Error collecting release info: ${e}`);\n }\n\n return {\n name: getPropertyViaWithDefault(\n data,\n [\"id\", \"name\", \"pretty_name\", \"id_like\"],\n \"unknown\",\n ),\n version: getPropertyViaWithDefault(\n data,\n [\"version_id\", \"version\", \"version_codename\"],\n \"unknown\",\n ),\n };\n};\n\nfunction getPropertyViaWithDefault(\n data: object,\n names: Property[],\n defaultValue: T,\n): T {\n for (const name of names) {\n const ret: T = getPropertyWithDefault(data, name, defaultValue);\n\n if (ret !== defaultValue) {\n return ret;\n }\n }\n\n return defaultValue;\n}\n\nfunction getPropertyWithDefault(\n data: object,\n name: Property,\n defaultValue: T,\n): T {\n if (!data.hasOwnProperty(name)) {\n return defaultValue;\n }\n\n const value = (data as { [K in Property]: T })[name];\n\n // NB. this check won't work for object instances\n if (typeof value !== typeof defaultValue) {\n return defaultValue;\n }\n\n return value;\n}\n\n/**\n * The Action runner's platform.\n */\nexport const platform = os.platform();\n\n/**\n * The Action runner's architecture.\n */\nexport const arch = os.arch();\n\n/**\n * Whether the Action runner is a Windows system.\n */\nexport const isWindows = platform === \"win32\";\n\n/**\n * Whether the Action runner is a macOS system.\n */\nexport const isMacOS = platform === \"darwin\";\n\n/**\n * Whether the Action runner is a Linux system.\n */\nexport const isLinux = platform === \"linux\";\n\n/**\n * System-level information about the current host (platform, architecture, etc.).\n */\ntype SystemDetails = {\n name: string;\n platform: string;\n arch: string;\n version: string;\n isWindows: boolean;\n isMacOS: boolean;\n isLinux: boolean;\n};\n\n/**\n * Get system-level information about the current host (platform, architecture, etc.).\n */\nexport async function getDetails(): Promise {\n return {\n ...(await (isWindows\n ? getWindowsInfo()\n : isMacOS\n ? getMacOsInfo()\n : getLinuxInfo())),\n platform,\n arch,\n isWindows,\n isMacOS,\n isLinux,\n };\n}\n","import * as actionsCore from \"@actions/core\";\nimport { createHash } from \"node:crypto\";\n\nconst OPTIONAL_VARIABLES = [\"INVOCATION_ID\"];\n\n// JSON sent to server\n/* eslint-disable camelcase */\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 job: hashEnvironmentVariables(\"GHWJ\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n ]),\n run: hashEnvironmentVariables(\"GHWJR\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n ]),\n run_differentiator: hashEnvironmentVariables(\"GHWJA\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n \"GITHUB_RUN_NUMBER\",\n \"GITHUB_RUN_ATTEMPT\",\n \"INVOCATION_ID\",\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 let value = process.env[varName];\n\n if (value === undefined) {\n if (OPTIONAL_VARIABLES.includes(varName)) {\n actionsCore.debug(\n `Optional environment variable not set: ${varName} -- substituting with the variable name`,\n );\n value = varName;\n } else {\n actionsCore.debug(\n `Environment variable not set: ${varName} -- can't generate the requested identity`,\n );\n return undefined;\n }\n }\n\n hash.update(value);\n hash.update(\"\\0\");\n }\n\n return `${prefix}-${hash.digest(\"hex\")}`;\n}\n","/**\n * @packageDocumentation\n * Helpers for determining system attributes of the current runner.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get the current architecture plus OS. Examples include `X64-Linux` and `ARM64-macOS`.\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\n/**\n * Get the current Nix system. Examples include `x86_64-linux` and `aarch64-darwin`.\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","/**\n * @packageDocumentation\n * Helpers for getting values from an Action's configuration.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get a Boolean input from the Action's configuration by name.\n */\nconst getBool = (name: string): boolean => {\n return actionsCore.getBooleanInput(name);\n};\n\n/**\n * Get a multi-line string input from the Action's configuration by name or return `null` if not set.\n */\nconst getMultilineStringOrNull = (name: string): string[] | null => {\n const value = actionsCore.getMultilineInput(name);\n if (value.length === 0) {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a number input from the Action's configuration by name or return `null` if not set.\n */\nconst getNumberOrNull = (name: string): number | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return Number(value);\n }\n};\n\n/**\n * Get a string input from the Action's configuration.\n */\nconst getString = (name: string): string => {\n return actionsCore.getInput(name);\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `null` if not set.\n */\nconst getStringOrNull = (name: string): string | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `undefined` if not set.\n */\nconst getStringOrUndefined = (name: string): string | undefined => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return undefined;\n } else {\n return value;\n }\n};\n\nexport {\n getBool,\n getMultilineStringOrNull,\n getNumberOrNull,\n getString,\n getStringOrNull,\n getStringOrUndefined,\n};\n","import { getStringOrUndefined } from \"./inputs.js\";\nimport * 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 = getStringOrUndefined(`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 = getStringOrUndefined(`${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","/**\n * @packageDocumentation\n * Determinate Systems' TypeScript library for creating GitHub Actions logic.\n */\nimport { version as pkgVersion } from \"../package.json\";\nimport * as ghActionsCorePlatform from \"./actions-core-platform.js\";\nimport * as correlation from \"./correlation.js\";\nimport * as platform from \"./platform.js\";\nimport { SourceDef, constructSourceParameters } from \"./sourcedef.js\";\nimport * as actionsCache from \"@actions/cache\";\nimport * as actionsCore from \"@actions/core\";\nimport got, { Got } from \"got\";\nimport { UUID, randomUUID } from \"node:crypto\";\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\";\n\nconst DEFAULT_IDS_HOST = \"https://install.determinate.systems\";\nconst IDS_HOST = process.env[\"IDS_HOST\"] ?? DEFAULT_IDS_HOST;\n\nconst EVENT_EXCEPTION = \"exception\";\nconst EVENT_ARTIFACT_CACHE_HIT = \"artifact_cache_hit\";\nconst EVENT_ARTIFACT_CACHE_MISS = \"artifact_cache_miss\";\n\nconst FACT_ENDED_WITH_EXCEPTION = \"ended_with_exception\";\nconst FACT_FINAL_EXCEPTION = \"final_exception\";\n\nexport type FetchSuffixStyle = \"nix-style\" | \"gh-env-style\" | \"universal\";\nexport type ExecutionPhase = \"main\" | \"post\";\nexport type NixRequirementHandling = \"fail\" | \"warn\" | \"ignore\";\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 // Check if Nix is installed before running this action.\n // If Nix isn't installed, this action will not fail, and will instead do nothing.\n // The action will emit a user-visible warning instructing them to install Nix.\n requireNix: NixRequirementHandling;\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 requireNix: NixRequirementHandling;\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 uuid: UUID;\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 private hookMain?: () => Promise;\n private hookPost?: () => Promise;\n\n constructor(actionOptions: ActionOptions) {\n this.actionOptions = makeOptionsConfident(actionOptions);\n this.hookMain = undefined;\n this.hookPost = undefined;\n\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 // JSON sent to server\n /* eslint-disable camelcase */\n this.facts = {\n $lib: \"idslib\",\n $lib_version: pkgVersion,\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 ghActionsCorePlatform\n .getDetails()\n // eslint-disable-next-line github/no-then\n .then((details) => {\n if (details.name !== \"unknown\") {\n this.addFact(\"$os\", details.name);\n }\n if (details.version !== \"unknown\") {\n this.addFact(\"$os_version\", details.version);\n }\n })\n // eslint-disable-next-line github/no-then\n .catch((e) => {\n actionsCore.debug(`Failure getting platform details: ${e}`);\n });\n }\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 onMain(callback: () => Promise): void {\n this.hookMain = callback;\n }\n\n onPost(callback: () => Promise): void {\n this.hookPost = callback;\n }\n\n execute(): void {\n // eslint-disable-next-line github/no-then\n this.executeAsync().catch((error: Error) => {\n // eslint-disable-next-line no-console\n console.log(error);\n process.exitCode = 1;\n });\n }\n\n private async executeAsync(): Promise {\n try {\n process.env.DETSYS_CORRELATION = JSON.stringify(\n this.getCorrelationHashes(),\n );\n\n if (!(await this.preflightRequireNix())) {\n this.recordEvent(\"preflight-require-nix-denied\");\n return;\n }\n\n if (this.executionPhase === \"main\" && this.hookMain) {\n await this.hookMain();\n } else if (this.executionPhase === \"post\" && this.hookPost) {\n await this.hookPost();\n }\n this.addFact(FACT_ENDED_WITH_EXCEPTION, false);\n } catch (error) {\n this.addFact(FACT_ENDED_WITH_EXCEPTION, true);\n\n const reportable =\n error instanceof Error || typeof error == \"string\"\n ? error.toString()\n : JSON.stringify(error);\n\n this.addFact(FACT_FINAL_EXCEPTION, reportable);\n\n if (this.executionPhase === \"post\") {\n actionsCore.warning(reportable);\n } else {\n actionsCore.setFailed(reportable);\n }\n\n this.recordEvent(EVENT_EXCEPTION);\n } finally {\n await this.complete();\n }\n }\n\n addFact(key: string, value: string | boolean): void {\n this.facts[key] = value;\n }\n\n getDiagnosticsUrl(): URL | undefined {\n return this.actionOptions.diagnosticsUrl;\n }\n\n getUniqueId(): string {\n return (\n this.identity.run_differentiator ||\n process.env.RUNNER_TRACKING_ID ||\n randomUUID()\n );\n }\n\n getCorrelationHashes(): correlation.AnonymizedCorrelationHashes {\n return this.identity;\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 uuid: randomUUID(),\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 this.client.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 = this.client.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 private 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(EVENT_ARTIFACT_CACHE_HIT);\n return `${tempDir}/${this.actionOptions.name}`;\n }\n\n this.recordEvent(EVENT_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(EVENT_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 preflightRequireNix(): Promise {\n let nixLocation: string | undefined;\n\n const pathParts = (process.env[\"PATH\"] || \"\").split(\":\");\n for (const location of pathParts) {\n const candidateNix = path.join(location, \"nix\");\n\n try {\n await fs.access(candidateNix, fs.constants.X_OK);\n actionsCore.debug(`Found Nix at ${candidateNix}`);\n nixLocation = candidateNix;\n } catch {\n actionsCore.debug(`Nix not at ${candidateNix}`);\n }\n }\n this.addFact(\"nix_location\", nixLocation || \"\");\n\n if (this.actionOptions.requireNix === \"ignore\") {\n return true;\n }\n\n const currentNotFoundState = actionsCore.getState(\n \"idstoolbox_nix_not_found\",\n );\n if (currentNotFoundState === \"not-found\") {\n // It was previously not found, so don't run subsequent actions\n return false;\n }\n\n if (nixLocation !== undefined) {\n return true;\n }\n actionsCore.saveState(\"idstoolbox_nix_not_found\", \"not-found\");\n\n switch (this.actionOptions.requireNix) {\n case \"fail\":\n actionsCore.setFailed(\n \"This action can only be used when Nix is installed.\" +\n \" Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n );\n break;\n case \"warn\":\n actionsCore.warning(\n \"This action is in no-op mode because Nix is not installed.\" +\n \" Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n );\n break;\n }\n\n return false;\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 this.client.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}-${randomUUID()}`);\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 requireNix: actionOptions.requireNix,\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\n// Public exports from other files\nexport * as inputs from \"./inputs.js\";\nexport * as platform from \"./platform.js\";\n"],"mappings":";;;;;;;AAEE,cAAW;;;ACUb,YAAY,QAAQ;AACpB,YAAY,QAAQ;AACpB,SAAS,iBAAiB;AAE1B,IAAM,gBAAgB,UAAa,WAAQ;AAy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2BAA2B;AAC1E,QAAI,+BAA+B,IAAI;AAErC,aAAO;AAAA,IACT;AAEA,QAAI,+BAA+B,QAAW;AAC5C,UAAI;AACF,eAAO,wBAAwB,IAAI,IAAI,0BAA0B,CAAC;AAAA,MACpE,SAAS,GAAG;AACV,QAAY;AAAA,UACV,+DAA+D,CAAC;AAAA,QAClE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,MAAI;AACF,UAAM,gBAAgB,IAAI,IAAI,QAAQ;AACtC,kBAAc,YAAY;AAC1B,kBAAc,YAAY;AAC1B,WAAO;AAAA,EACT,SAAS,GAAG;AACV,IAAY;AAAA,MACV,2DAA2D,CAAC;AAAA,IAC9D;AAAA,EACF;AAEA,SAAO;AACT;AAEA,SAAS,wBAAwB,UAAoB;AACnD,MAAI,qBAAqB,UAAU;AACjC,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,iBAAiB,IAAI,IAAI,gBAAgB;AAC/C,UAAM,iBAAiB,IAAI,IAAI,QAAQ;AAEvC,QAAI,SAAS,WAAW,eAAe,QAAQ;AAC7C,aAAO;AAAA,IACT;AAEA,aAAS,WAAW,eAAe;AACnC,aAAS,OAAO,eAAe;AAC/B,aAAS,WAAW,eAAe;AACnC,aAAS,WAAW,eAAe;AAEnC,WAAO;AAAA,EACT,SAAS,GAAG;AACV,IAAY,kBAAK,qDAAqD,CAAC,EAAE;AAAA,EAC3E;AAEA,SAAO;AACT;","names":["error","os","version","platform","arch","actionsCore","actionsCore","actionsCore","actionsCore","fs","error","version"]} \ No newline at end of file +{"version":3,"sources":["../package.json","../src/linux-release-info.ts","../src/actions-core-platform.ts","../src/correlation.ts","../src/platform.ts","../src/inputs.ts","../src/sourcedef.ts","../src/index.ts"],"sourcesContent":["{\n \"name\": \"detsys-ts\",\n \"version\": \"1.0.0\",\n \"description\": \"TypeScript goodies for DetSys projects\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"check-fmt\": \"prettier --check .\",\n \"format\": \"prettier --write .\",\n \"lint\": \"eslint src/**/*.ts\",\n \"docs\": \"typedoc src/index.ts\",\n \"all\": \"rm -rf dist && 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\": \"MIT\",\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.1\",\n \"@actions/exec\": \"^1.1.1\",\n \"got\": \"^14.2.1\"\n },\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/node\": \"^20.12.7\",\n \"@typescript-eslint/eslint-plugin\": \"^7.6.0\",\n \"eslint\": \"^8.57.0\",\n \"eslint-import-resolver-typescript\": \"^3.6.1\",\n \"eslint-plugin-github\": \"^4.10.2\",\n \"eslint-plugin-import\": \"^2.29.1\",\n \"eslint-plugin-prettier\": \"^5.1.3\",\n \"prettier\": \"^3.2.5\",\n \"tsup\": \"^8.0.2\",\n \"typedoc\": \"^0.25.13\",\n \"typescript\": \"^5.4.5\"\n }\n}\n","/*!\n * linux-release-info\n * Get Linux release info (distribution name, version, arch, release, etc.)\n * from '/etc/os-release' or '/usr/lib/os-release' files and from native os\n * module. On Windows and Darwin platforms it only returns common node os module\n * info (platform, hostname, release, and arch)\n *\n * Licensed under MIT\n * Copyright (c) 2018-2020 [Samuel Carreira]\n */\n// NOTE: we depend on this directly to get around some un-fun issues with mixing CommonJS\n// and ESM in the bundle.\nimport * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport { promisify } from \"node:util\";\n\nconst readFileAsync = promisify(fs.readFile);\n\nexport interface LinuxReleaseInfoOptions {\n /**\n * read mode, possible values: 'async' and 'sync'\n *\n * @default 'async'\n */\n mode?: \"async\" | \"sync\";\n /**\n * custom complete file path with os info default null/none\n * if not provided the system will search on the '/etc/os-release'\n * and '/usr/lib/os-release' files\n *\n * @default null\n */\n customFile?: string | null | undefined;\n /**\n * if true, show console debug messages\n *\n * @default false\n */\n debug?: boolean;\n}\n\nconst linuxReleaseInfoOptionsDefaults: LinuxReleaseInfoOptions = {\n mode: \"async\",\n customFile: null,\n debug: false,\n};\n\n/**\n * Get OS release info from 'os-release' file and from native os module\n * on Windows or Darwin it only returns common os module info\n * (uses native fs module)\n * @returns {object} info from the current os\n */\nexport function releaseInfo(infoOptions: LinuxReleaseInfoOptions): object {\n const options = { ...linuxReleaseInfoOptionsDefaults, ...infoOptions };\n\n const searchOsReleaseFileList: string[] = osReleaseFileList(\n options.customFile,\n );\n\n if (os.type() !== \"Linux\") {\n if (options.mode === \"sync\") {\n return getOsInfo();\n } else {\n return Promise.resolve(getOsInfo());\n }\n }\n\n if (options.mode === \"sync\") {\n return readSyncOsreleaseFile(searchOsReleaseFileList, options);\n } else {\n return Promise.resolve(\n readAsyncOsReleaseFile(searchOsReleaseFileList, options),\n );\n }\n}\n\n/**\n * Format file data: convert data to object keys/values\n *\n * @param {object} sourceData Source object to be appended\n * @param {string} srcParseData Input file data to be parsed\n * @returns {object} Formated object\n */\nfunction formatFileData(sourceData: OsInfo, srcParseData: string): OsInfo {\n const lines: string[] = srcParseData.split(\"\\n\");\n\n for (const line of lines) {\n const lineData = line.split(\"=\");\n\n if (lineData.length === 2) {\n lineData[1] = lineData[1].replace(/[\"'\\r]/gi, \"\"); // remove quotes and return character\n\n Object.defineProperty(sourceData, lineData[0].toLowerCase(), {\n value: lineData[1],\n writable: true,\n enumerable: true,\n configurable: true,\n });\n }\n }\n\n return sourceData;\n}\n\n/**\n * Export a list of os-release files\n *\n * @param {string} customFile optional custom complete filepath\n * @returns {array} list of os-release files\n */\nfunction osReleaseFileList(customFile: string | null | undefined): string[] {\n const DEFAULT_OS_RELEASE_FILES = [\"/etc/os-release\", \"/usr/lib/os-release\"];\n\n if (!customFile) {\n return DEFAULT_OS_RELEASE_FILES;\n } else {\n return Array(customFile);\n }\n}\n\n/**\n * Operating system info.\n */\ntype OsInfo = {\n type: string;\n platform: string;\n hostname: string;\n arch: string;\n release: string;\n};\n\n/**\n * Get OS Basic Info\n * (uses node 'os' native module)\n *\n * @returns {OsInfo} os basic info\n */\nfunction getOsInfo(): OsInfo {\n return {\n type: os.type(),\n platform: os.platform(),\n hostname: os.hostname(),\n arch: os.arch(),\n release: os.release(),\n };\n}\n\n/* Helper functions */\n\nasync function readAsyncOsReleaseFile(\n fileList: string[],\n releaseInfoOptions: LinuxReleaseInfoOptions,\n): Promise {\n let fileData = null;\n\n for (const osReleaseFile of fileList) {\n try {\n if (releaseInfoOptions.debug) {\n /* eslint-disable no-console */\n console.log(`Trying to read '${osReleaseFile}'...`);\n }\n\n fileData = await readFileAsync(osReleaseFile, \"binary\");\n\n if (releaseInfoOptions.debug) {\n console.log(`Read data:\\n${fileData}`);\n }\n\n break;\n } catch (error) {\n if (releaseInfoOptions.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n}\n\nfunction readSyncOsreleaseFile(\n releaseFileList: string[],\n releaseInfoOptions: LinuxReleaseInfoOptions,\n): OsInfo {\n let fileData = null;\n\n for (const osReleaseFile of releaseFileList) {\n try {\n if (releaseInfoOptions.debug) {\n console.log(`Trying to read '${osReleaseFile}'...`);\n }\n\n fileData = fs.readFileSync(osReleaseFile, \"binary\");\n\n if (releaseInfoOptions.debug) {\n console.log(`Read data:\\n${fileData}`);\n }\n\n break;\n } catch (error) {\n if (releaseInfoOptions.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n}\n","// MIT, mostly lifted from https://github.com/actions/toolkit/blob/5a736647a123ecf8582376bdaee833fbae5b3847/packages/core/src/platform.ts\n// since it isn't in @actions/core 1.10.1 which is their current release as 2024-04-19.\n// Changes: Replaced the lsb_release call in Linux with `linux-release-info` to parse the os-release file directly.\nimport { releaseInfo } from \"./linux-release-info.js\";\nimport * as core from \"@actions/core\";\nimport * as exec from \"@actions/exec\";\nimport os from \"os\";\n\n/**\n * The name and version of the Action runner's system.\n */\ntype SystemInfo = {\n name: string;\n version: string;\n};\n\n/**\n * Get the name and version of the current Windows system.\n */\nconst getWindowsInfo = async (): Promise => {\n const { stdout: version } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Version\"',\n undefined,\n {\n silent: true,\n },\n );\n\n const { stdout: name } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Caption\"',\n undefined,\n {\n silent: true,\n },\n );\n\n return {\n name: name.trim(),\n version: version.trim(),\n };\n};\n\n/**\n * Get the name and version of the current macOS system.\n */\nconst getMacOsInfo = async (): Promise => {\n const { stdout } = await exec.getExecOutput(\"sw_vers\", undefined, {\n silent: true,\n });\n\n const version = stdout.match(/ProductVersion:\\s*(.+)/)?.[1] ?? \"\";\n const name = stdout.match(/ProductName:\\s*(.+)/)?.[1] ?? \"\";\n\n return {\n name,\n version,\n };\n};\n\n/**\n * Get the name and version of the current Linux system.\n */\nconst getLinuxInfo = async (): Promise => {\n let data: object = {};\n\n try {\n data = releaseInfo({ mode: \"sync\" });\n // eslint-disable-next-line no-console\n console.log(data);\n } catch (e) {\n core.debug(`Error collecting release info: ${e}`);\n }\n\n return {\n name: getPropertyViaWithDefault(\n data,\n [\"id\", \"name\", \"pretty_name\", \"id_like\"],\n \"unknown\",\n ),\n version: getPropertyViaWithDefault(\n data,\n [\"version_id\", \"version\", \"version_codename\"],\n \"unknown\",\n ),\n };\n};\n\nfunction getPropertyViaWithDefault(\n data: object,\n names: Property[],\n defaultValue: T,\n): T {\n for (const name of names) {\n const ret: T = getPropertyWithDefault(data, name, defaultValue);\n\n if (ret !== defaultValue) {\n return ret;\n }\n }\n\n return defaultValue;\n}\n\nfunction getPropertyWithDefault(\n data: object,\n name: Property,\n defaultValue: T,\n): T {\n if (!data.hasOwnProperty(name)) {\n return defaultValue;\n }\n\n const value = (data as { [K in Property]: T })[name];\n\n // NB. this check won't work for object instances\n if (typeof value !== typeof defaultValue) {\n return defaultValue;\n }\n\n return value;\n}\n\n/**\n * The Action runner's platform.\n */\nexport const platform = os.platform();\n\n/**\n * The Action runner's architecture.\n */\nexport const arch = os.arch();\n\n/**\n * Whether the Action runner is a Windows system.\n */\nexport const isWindows = platform === \"win32\";\n\n/**\n * Whether the Action runner is a macOS system.\n */\nexport const isMacOS = platform === \"darwin\";\n\n/**\n * Whether the Action runner is a Linux system.\n */\nexport const isLinux = platform === \"linux\";\n\n/**\n * System-level information about the current host (platform, architecture, etc.).\n */\ntype SystemDetails = {\n name: string;\n platform: string;\n arch: string;\n version: string;\n isWindows: boolean;\n isMacOS: boolean;\n isLinux: boolean;\n};\n\n/**\n * Get system-level information about the current host (platform, architecture, etc.).\n */\nexport async function getDetails(): Promise {\n return {\n ...(await (isWindows\n ? getWindowsInfo()\n : isMacOS\n ? getMacOsInfo()\n : getLinuxInfo())),\n platform,\n arch,\n isWindows,\n isMacOS,\n isLinux,\n };\n}\n","import * as actionsCore from \"@actions/core\";\nimport { createHash } from \"node:crypto\";\n\nconst OPTIONAL_VARIABLES = [\"INVOCATION_ID\"];\n\n// JSON sent to server\n/* eslint-disable camelcase */\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 job: hashEnvironmentVariables(\"GHWJ\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n ]),\n run: hashEnvironmentVariables(\"GHWJR\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n ]),\n run_differentiator: hashEnvironmentVariables(\"GHWJA\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n \"GITHUB_RUN_NUMBER\",\n \"GITHUB_RUN_ATTEMPT\",\n \"INVOCATION_ID\",\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 let value = process.env[varName];\n\n if (value === undefined) {\n if (OPTIONAL_VARIABLES.includes(varName)) {\n actionsCore.debug(\n `Optional environment variable not set: ${varName} -- substituting with the variable name`,\n );\n value = varName;\n } else {\n actionsCore.debug(\n `Environment variable not set: ${varName} -- can't generate the requested identity`,\n );\n return undefined;\n }\n }\n\n hash.update(value);\n hash.update(\"\\0\");\n }\n\n return `${prefix}-${hash.digest(\"hex\")}`;\n}\n","/**\n * @packageDocumentation\n * Helpers for determining system attributes of the current runner.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get the current architecture plus OS. Examples include `X64-Linux` and `ARM64-macOS`.\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\n/**\n * Get the current Nix system. Examples include `x86_64-linux` and `aarch64-darwin`.\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","/**\n * @packageDocumentation\n * Helpers for getting values from an Action's configuration.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get a Boolean input from the Action's configuration by name.\n */\nconst getBool = (name: string): boolean => {\n return actionsCore.getBooleanInput(name);\n};\n\n/**\n * Get a multi-line string input from the Action's configuration by name or return `null` if not set.\n */\nconst getMultilineStringOrNull = (name: string): string[] | null => {\n const value = actionsCore.getMultilineInput(name);\n if (value.length === 0) {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a number input from the Action's configuration by name or return `null` if not set.\n */\nconst getNumberOrNull = (name: string): number | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return Number(value);\n }\n};\n\n/**\n * Get a string input from the Action's configuration.\n */\nconst getString = (name: string): string => {\n return actionsCore.getInput(name);\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `null` if not set.\n */\nconst getStringOrNull = (name: string): string | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `undefined` if not set.\n */\nconst getStringOrUndefined = (name: string): string | undefined => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return undefined;\n } else {\n return value;\n }\n};\n\nexport {\n getBool,\n getMultilineStringOrNull,\n getNumberOrNull,\n getString,\n getStringOrNull,\n getStringOrUndefined,\n};\n","import { getStringOrUndefined } from \"./inputs.js\";\nimport * 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 = getStringOrUndefined(`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 = getStringOrUndefined(`${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","/**\n * @packageDocumentation\n * Determinate Systems' TypeScript library for creating GitHub Actions logic.\n */\nimport { version as pkgVersion } from \"../package.json\";\nimport * as ghActionsCorePlatform from \"./actions-core-platform.js\";\nimport * as correlation from \"./correlation.js\";\nimport * as platform from \"./platform.js\";\nimport { SourceDef, constructSourceParameters } from \"./sourcedef.js\";\nimport * as actionsCache from \"@actions/cache\";\nimport * as actionsCore from \"@actions/core\";\nimport got, { Got } from \"got\";\nimport { UUID, randomUUID } from \"node:crypto\";\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\";\n\nconst DEFAULT_IDS_HOST = \"https://install.determinate.systems\";\nconst IDS_HOST = process.env[\"IDS_HOST\"] ?? DEFAULT_IDS_HOST;\n\nconst EVENT_EXCEPTION = \"exception\";\nconst EVENT_ARTIFACT_CACHE_HIT = \"artifact_cache_hit\";\nconst EVENT_ARTIFACT_CACHE_MISS = \"artifact_cache_miss\";\n\nconst FACT_ENDED_WITH_EXCEPTION = \"ended_with_exception\";\nconst FACT_FINAL_EXCEPTION = \"final_exception\";\n\nexport type FetchSuffixStyle = \"nix-style\" | \"gh-env-style\" | \"universal\";\nexport type ExecutionPhase = \"main\" | \"post\";\nexport type NixRequirementHandling = \"fail\" | \"warn\" | \"ignore\";\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 // Check if Nix is installed before running this action.\n // If Nix isn't installed, this action will not fail, and will instead do nothing.\n // The action will emit a user-visible warning instructing them to install Nix.\n requireNix: NixRequirementHandling;\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 requireNix: NixRequirementHandling;\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 uuid: UUID;\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 private hookMain?: () => Promise;\n private hookPost?: () => Promise;\n\n constructor(actionOptions: ActionOptions) {\n this.actionOptions = makeOptionsConfident(actionOptions);\n this.hookMain = undefined;\n this.hookPost = undefined;\n\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 // JSON sent to server\n /* eslint-disable camelcase */\n this.facts = {\n $lib: \"idslib\",\n $lib_version: pkgVersion,\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 ghActionsCorePlatform\n .getDetails()\n // eslint-disable-next-line github/no-then\n .then((details) => {\n if (details.name !== \"unknown\") {\n this.addFact(\"$os\", details.name);\n }\n if (details.version !== \"unknown\") {\n this.addFact(\"$os_version\", details.version);\n }\n })\n // eslint-disable-next-line github/no-then\n .catch((e) => {\n actionsCore.debug(`Failure getting platform details: ${e}`);\n });\n }\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 onMain(callback: () => Promise): void {\n this.hookMain = callback;\n }\n\n onPost(callback: () => Promise): void {\n this.hookPost = callback;\n }\n\n execute(): void {\n // eslint-disable-next-line github/no-then\n this.executeAsync().catch((error: Error) => {\n // eslint-disable-next-line no-console\n console.log(error);\n process.exitCode = 1;\n });\n }\n\n private async executeAsync(): Promise {\n try {\n process.env.DETSYS_CORRELATION = JSON.stringify(\n this.getCorrelationHashes(),\n );\n\n if (!(await this.preflightRequireNix())) {\n this.recordEvent(\"preflight-require-nix-denied\");\n return;\n }\n\n if (this.executionPhase === \"main\" && this.hookMain) {\n await this.hookMain();\n } else if (this.executionPhase === \"post\" && this.hookPost) {\n await this.hookPost();\n }\n this.addFact(FACT_ENDED_WITH_EXCEPTION, false);\n } catch (error) {\n this.addFact(FACT_ENDED_WITH_EXCEPTION, true);\n\n const reportable =\n error instanceof Error || typeof error == \"string\"\n ? error.toString()\n : JSON.stringify(error);\n\n this.addFact(FACT_FINAL_EXCEPTION, reportable);\n\n if (this.executionPhase === \"post\") {\n actionsCore.warning(reportable);\n } else {\n actionsCore.setFailed(reportable);\n }\n\n this.recordEvent(EVENT_EXCEPTION);\n } finally {\n await this.complete();\n }\n }\n\n addFact(key: string, value: string | boolean): void {\n this.facts[key] = value;\n }\n\n getDiagnosticsUrl(): URL | undefined {\n return this.actionOptions.diagnosticsUrl;\n }\n\n getUniqueId(): string {\n return (\n this.identity.run_differentiator ||\n process.env.RUNNER_TRACKING_ID ||\n randomUUID()\n );\n }\n\n getCorrelationHashes(): correlation.AnonymizedCorrelationHashes {\n return this.identity;\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 uuid: randomUUID(),\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 this.client.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 = this.client.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 private 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(EVENT_ARTIFACT_CACHE_HIT);\n return `${tempDir}/${this.actionOptions.name}`;\n }\n\n this.recordEvent(EVENT_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(EVENT_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 preflightRequireNix(): Promise {\n let nixLocation: string | undefined;\n\n const pathParts = (process.env[\"PATH\"] || \"\").split(\":\");\n for (const location of pathParts) {\n const candidateNix = path.join(location, \"nix\");\n\n try {\n await fs.access(candidateNix, fs.constants.X_OK);\n actionsCore.debug(`Found Nix at ${candidateNix}`);\n nixLocation = candidateNix;\n } catch {\n actionsCore.debug(`Nix not at ${candidateNix}`);\n }\n }\n this.addFact(\"nix_location\", nixLocation || \"\");\n\n if (this.actionOptions.requireNix === \"ignore\") {\n return true;\n }\n\n const currentNotFoundState = actionsCore.getState(\n \"idstoolbox_nix_not_found\",\n );\n if (currentNotFoundState === \"not-found\") {\n // It was previously not found, so don't run subsequent actions\n return false;\n }\n\n if (nixLocation !== undefined) {\n return true;\n }\n actionsCore.saveState(\"idstoolbox_nix_not_found\", \"not-found\");\n\n switch (this.actionOptions.requireNix) {\n case \"fail\":\n actionsCore.setFailed(\n \"This action can only be used when Nix is installed.\" +\n \" Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n );\n break;\n case \"warn\":\n actionsCore.warning(\n \"This action is in no-op mode because Nix is not installed.\" +\n \" Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n );\n break;\n }\n\n return false;\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 this.client.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}-${randomUUID()}`);\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 requireNix: actionOptions.requireNix,\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\n// Public exports from other files\nexport * as inputs from \"./inputs.js\";\nexport * as platform from \"./platform.js\";\n"],"mappings":";;;;;;;AAEE,cAAW;;;ACUb,YAAY,QAAQ;AACpB,YAAY,QAAQ;AACpB,SAAS,iBAAiB;AAE1B,IAAM,gBAAgB,UAAa,WAAQ;AAyB3C,IAAM,kCAA2D;AAAA,EAC/D,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,OAAO;AACT;AAQO,SAAS,YAAY,aAA8C;AACxE,QAAM,UAAU,EAAE,GAAG,iCAAiC,GAAG,YAAY;AAErE,QAAM,0BAAoC;AAAA,IACxC,QAAQ;AAAA,EACV;AAEA,MAAO,QAAK,MAAM,SAAS;AACzB,QAAI,QAAQ,SAAS,QAAQ;AAC3B,aAAO,UAAU;AAAA,IACnB,OAAO;AACL,aAAO,QAAQ,QAAQ,UAAU,CAAC;AAAA,IACpC;AAAA,EACF;AAEA,MAAI,QAAQ,SAAS,QAAQ;AAC3B,WAAO,sBAAsB,yBAAyB,OAAO;AAAA,EAC/D,OAAO;AACL,WAAO,QAAQ;AAAA,MACb,uBAAuB,yBAAyB,OAAO;AAAA,IACzD;AAAA,EACF;AACF;AASA,SAAS,eAAe,YAAoB,cAA8B;AACxE,QAAM,QAAkB,aAAa,MAAM,IAAI;AAE/C,aAAW,QAAQ,OAAO;AACxB,UAAM,WAAW,KAAK,M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C,aAAO;AAAA,IACT;AAEA,aAAS,WAAW,eAAe;AACnC,aAAS,OAAO,eAAe;AAC/B,aAAS,WAAW,eAAe;AACnC,aAAS,WAAW,eAAe;AAEnC,WAAO;AAAA,EACT,SAAS,GAAG;AACV,IAAY,kBAAK,qDAAqD,CAAC,EAAE;AAAA,EAC3E;AAEA,SAAO;AACT;","names":["error","os","version","platform","arch","actionsCore","actionsCore","actionsCore","actionsCore","fs","error","version"]} \ No newline at end of file diff --git a/src/linux-release-info.ts b/src/linux-release-info.ts index 5ff11a0..07d114e 100644 --- a/src/linux-release-info.ts +++ b/src/linux-release-info.ts @@ -54,79 +54,10 @@ const linuxReleaseInfoOptionsDefaults: LinuxReleaseInfoOptions = { export function releaseInfo(infoOptions: LinuxReleaseInfoOptions): object { const options = { ...linuxReleaseInfoOptionsDefaults, ...infoOptions }; - const searchOsReleaseFileList: string[] = osreleaseFileList( + const searchOsReleaseFileList: string[] = osReleaseFileList( options.customFile, ); - async function readAsyncOsReleaseFile( - fileList: string[], - releaseInfoOptions: LinuxReleaseInfoOptions, - ): Promise { - let fileData = null; - - for (const osReleaseFile of fileList) { - try { - if (releaseInfoOptions.debug) { - /* eslint-disable no-console */ - console.log(`Trying to read '${osReleaseFile}'...`); - } - - fileData = await readFileAsync(osReleaseFile, "binary"); - - if (releaseInfoOptions.debug) { - console.log(`Read data:\n${fileData}`); - } - - break; - } catch (error) { - if (releaseInfoOptions.debug) { - console.error(error); - } - } - } - - if (fileData === null) { - throw new Error("Cannot read os-release file!"); - //return getOsInfo(); - } - - return formatFileData(getOsInfo(), fileData); - } - - function readSyncOsreleaseFile( - releaseFileList: string[], - releaseInfoOptions: LinuxReleaseInfoOptions, - ): OsInfo { - let fileData = null; - - for (const osReleaseFile of releaseFileList) { - try { - if (releaseInfoOptions.debug) { - console.log(`Trying to read '${osReleaseFile}'...`); - } - - fileData = fs.readFileSync(osReleaseFile, "binary"); - - if (releaseInfoOptions.debug) { - console.log(`Read data:\n${fileData}`); - } - - break; - } catch (error) { - if (releaseInfoOptions.debug) { - console.error(error); - } - } - } - - if (fileData === null) { - throw new Error("Cannot read os-release file!"); - //return getOsInfo(); - } - - return formatFileData(getOsInfo(), fileData); - } - if (os.type() !== "Linux") { if (options.mode === "sync") { return getOsInfo(); @@ -178,7 +109,7 @@ function formatFileData(sourceData: OsInfo, srcParseData: string): OsInfo { * @param {string} customFile optional custom complete filepath * @returns {array} list of os-release files */ -function osreleaseFileList(customFile: string | null | undefined): string[] { +function osReleaseFileList(customFile: string | null | undefined): string[] { const DEFAULT_OS_RELEASE_FILES = ["/etc/os-release", "/usr/lib/os-release"]; if (!customFile) { @@ -214,3 +145,74 @@ function getOsInfo(): OsInfo { release: os.release(), }; } + +/* Helper functions */ + +async function readAsyncOsReleaseFile( + fileList: string[], + releaseInfoOptions: LinuxReleaseInfoOptions, +): Promise { + let fileData = null; + + for (const osReleaseFile of fileList) { + try { + if (releaseInfoOptions.debug) { + /* eslint-disable no-console */ + console.log(`Trying to read '${osReleaseFile}'...`); + } + + fileData = await readFileAsync(osReleaseFile, "binary"); + + if (releaseInfoOptions.debug) { + console.log(`Read data:\n${fileData}`); + } + + break; + } catch (error) { + if (releaseInfoOptions.debug) { + console.error(error); + } + } + } + + if (fileData === null) { + throw new Error("Cannot read os-release file!"); + //return getOsInfo(); + } + + return formatFileData(getOsInfo(), fileData); +} + +function readSyncOsreleaseFile( + releaseFileList: string[], + releaseInfoOptions: LinuxReleaseInfoOptions, +): OsInfo { + let fileData = null; + + for (const osReleaseFile of releaseFileList) { + try { + if (releaseInfoOptions.debug) { + console.log(`Trying to read '${osReleaseFile}'...`); + } + + fileData = fs.readFileSync(osReleaseFile, "binary"); + + if (releaseInfoOptions.debug) { + console.log(`Read data:\n${fileData}`); + } + + break; + } catch (error) { + if (releaseInfoOptions.debug) { + console.error(error); + } + } + } + + if (fileData === null) { + throw new Error("Cannot read os-release file!"); + //return getOsInfo(); + } + + return formatFileData(getOsInfo(), fileData); +} From c9ffcf170f0b4a14216bf86c325409372f600399 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Sun, 21 Apr 2024 11:37:26 -0300 Subject: [PATCH 4/6] Streamline variable naming --- dist/index.js | 16 ++++++++-------- dist/index.js.map | 2 +- src/linux-release-info.ts | 16 ++++++++-------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/dist/index.js b/dist/index.js index 1836c0d..05c42e9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -70,21 +70,21 @@ function getOsInfo() { release: os.release() }; } -async function readAsyncOsReleaseFile(fileList, releaseInfoOptions) { +async function readAsyncOsReleaseFile(fileList, options) { let fileData = null; for (const osReleaseFile of fileList) { try { - if (releaseInfoOptions.debug) { + if (options.debug) { console.log(`Trying to read '${osReleaseFile}'...`); } fileData = await readFileAsync(osReleaseFile, "binary"); - if (releaseInfoOptions.debug) { + if (options.debug) { console.log(`Read data: ${fileData}`); } break; } catch (error2) { - if (releaseInfoOptions.debug) { + if (options.debug) { console.error(error2); } } @@ -94,21 +94,21 @@ ${fileData}`); } return formatFileData(getOsInfo(), fileData); } -function readSyncOsreleaseFile(releaseFileList, releaseInfoOptions) { +function readSyncOsreleaseFile(releaseFileList, options) { let fileData = null; for (const osReleaseFile of releaseFileList) { try { - if (releaseInfoOptions.debug) { + if (options.debug) { console.log(`Trying to read '${osReleaseFile}'...`); } fileData = fs.readFileSync(osReleaseFile, "binary"); - if (releaseInfoOptions.debug) { + if (options.debug) { console.log(`Read data: ${fileData}`); } break; } catch (error2) { - if (releaseInfoOptions.debug) { + if (options.debug) { console.error(error2); } } diff --git a/dist/index.js.map b/dist/index.js.map index 62d9ed3..fafa570 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../package.json","../src/linux-release-info.ts","../src/actions-core-platform.ts","../src/correlation.ts","../src/platform.ts","../src/inputs.ts","../src/sourcedef.ts","../src/index.ts"],"sourcesContent":["{\n \"name\": \"detsys-ts\",\n \"version\": \"1.0.0\",\n \"description\": \"TypeScript goodies for DetSys projects\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"check-fmt\": \"prettier --check .\",\n \"format\": \"prettier --write .\",\n \"lint\": \"eslint src/**/*.ts\",\n \"docs\": \"typedoc src/index.ts\",\n \"all\": \"rm -rf dist && 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\": \"MIT\",\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.1\",\n \"@actions/exec\": \"^1.1.1\",\n \"got\": \"^14.2.1\"\n },\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/node\": \"^20.12.7\",\n \"@typescript-eslint/eslint-plugin\": \"^7.6.0\",\n \"eslint\": \"^8.57.0\",\n \"eslint-import-resolver-typescript\": \"^3.6.1\",\n \"eslint-plugin-github\": \"^4.10.2\",\n \"eslint-plugin-import\": \"^2.29.1\",\n \"eslint-plugin-prettier\": \"^5.1.3\",\n \"prettier\": \"^3.2.5\",\n \"tsup\": \"^8.0.2\",\n \"typedoc\": \"^0.25.13\",\n \"typescript\": \"^5.4.5\"\n }\n}\n","/*!\n * linux-release-info\n * Get Linux release info (distribution name, version, arch, release, etc.)\n * from '/etc/os-release' or '/usr/lib/os-release' files and from native os\n * module. On Windows and Darwin platforms it only returns common node os module\n * info (platform, hostname, release, and arch)\n *\n * Licensed under MIT\n * Copyright (c) 2018-2020 [Samuel Carreira]\n */\n// NOTE: we depend on this directly to get around some un-fun issues with mixing CommonJS\n// and ESM in the bundle.\nimport * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport { promisify } from \"node:util\";\n\nconst readFileAsync = promisify(fs.readFile);\n\nexport interface LinuxReleaseInfoOptions {\n /**\n * read mode, possible values: 'async' and 'sync'\n *\n * @default 'async'\n */\n mode?: \"async\" | \"sync\";\n /**\n * custom complete file path with os info default null/none\n * if not provided the system will search on the '/etc/os-release'\n * and '/usr/lib/os-release' files\n *\n * @default null\n */\n customFile?: string | null | undefined;\n /**\n * if true, show console debug messages\n *\n * @default false\n */\n debug?: boolean;\n}\n\nconst linuxReleaseInfoOptionsDefaults: LinuxReleaseInfoOptions = {\n mode: \"async\",\n customFile: null,\n debug: false,\n};\n\n/**\n * Get OS release info from 'os-release' file and from native os module\n * on Windows or Darwin it only returns common os module info\n * (uses native fs module)\n * @returns {object} info from the current os\n */\nexport function releaseInfo(infoOptions: LinuxReleaseInfoOptions): object {\n const options = { ...linuxReleaseInfoOptionsDefaults, ...infoOptions };\n\n const searchOsReleaseFileList: string[] = osReleaseFileList(\n options.customFile,\n );\n\n if (os.type() !== \"Linux\") {\n if (options.mode === \"sync\") {\n return getOsInfo();\n } else {\n return Promise.resolve(getOsInfo());\n }\n }\n\n if (options.mode === \"sync\") {\n return readSyncOsreleaseFile(searchOsReleaseFileList, options);\n } else {\n return Promise.resolve(\n readAsyncOsReleaseFile(searchOsReleaseFileList, options),\n );\n }\n}\n\n/**\n * Format file data: convert data to object keys/values\n *\n * @param {object} sourceData Source object to be appended\n * @param {string} srcParseData Input file data to be parsed\n * @returns {object} Formated object\n */\nfunction formatFileData(sourceData: OsInfo, srcParseData: string): OsInfo {\n const lines: string[] = srcParseData.split(\"\\n\");\n\n for (const line of lines) {\n const lineData = line.split(\"=\");\n\n if (lineData.length === 2) {\n lineData[1] = lineData[1].replace(/[\"'\\r]/gi, \"\"); // remove quotes and return character\n\n Object.defineProperty(sourceData, lineData[0].toLowerCase(), {\n value: lineData[1],\n writable: true,\n enumerable: true,\n configurable: true,\n });\n }\n }\n\n return sourceData;\n}\n\n/**\n * Export a list of os-release files\n *\n * @param {string} customFile optional custom complete filepath\n * @returns {array} list of os-release files\n */\nfunction osReleaseFileList(customFile: string | null | undefined): string[] {\n const DEFAULT_OS_RELEASE_FILES = [\"/etc/os-release\", \"/usr/lib/os-release\"];\n\n if (!customFile) {\n return DEFAULT_OS_RELEASE_FILES;\n } else {\n return Array(customFile);\n }\n}\n\n/**\n * Operating system info.\n */\ntype OsInfo = {\n type: string;\n platform: string;\n hostname: string;\n arch: string;\n release: string;\n};\n\n/**\n * Get OS Basic Info\n * (uses node 'os' native module)\n *\n * @returns {OsInfo} os basic info\n */\nfunction getOsInfo(): OsInfo {\n return {\n type: os.type(),\n platform: os.platform(),\n hostname: os.hostname(),\n arch: os.arch(),\n release: os.release(),\n };\n}\n\n/* Helper functions */\n\nasync function readAsyncOsReleaseFile(\n fileList: string[],\n releaseInfoOptions: LinuxReleaseInfoOptions,\n): Promise {\n let fileData = null;\n\n for (const osReleaseFile of fileList) {\n try {\n if (releaseInfoOptions.debug) {\n /* eslint-disable no-console */\n console.log(`Trying to read '${osReleaseFile}'...`);\n }\n\n fileData = await readFileAsync(osReleaseFile, \"binary\");\n\n if (releaseInfoOptions.debug) {\n console.log(`Read data:\\n${fileData}`);\n }\n\n break;\n } catch (error) {\n if (releaseInfoOptions.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n}\n\nfunction readSyncOsreleaseFile(\n releaseFileList: string[],\n releaseInfoOptions: LinuxReleaseInfoOptions,\n): OsInfo {\n let fileData = null;\n\n for (const osReleaseFile of releaseFileList) {\n try {\n if (releaseInfoOptions.debug) {\n console.log(`Trying to read '${osReleaseFile}'...`);\n }\n\n fileData = fs.readFileSync(osReleaseFile, \"binary\");\n\n if (releaseInfoOptions.debug) {\n console.log(`Read data:\\n${fileData}`);\n }\n\n break;\n } catch (error) {\n if (releaseInfoOptions.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n}\n","// MIT, mostly lifted from https://github.com/actions/toolkit/blob/5a736647a123ecf8582376bdaee833fbae5b3847/packages/core/src/platform.ts\n// since it isn't in @actions/core 1.10.1 which is their current release as 2024-04-19.\n// Changes: Replaced the lsb_release call in Linux with `linux-release-info` to parse the os-release file directly.\nimport { releaseInfo } from \"./linux-release-info.js\";\nimport * as core from \"@actions/core\";\nimport * as exec from \"@actions/exec\";\nimport os from \"os\";\n\n/**\n * The name and version of the Action runner's system.\n */\ntype SystemInfo = {\n name: string;\n version: string;\n};\n\n/**\n * Get the name and version of the current Windows system.\n */\nconst getWindowsInfo = async (): Promise => {\n const { stdout: version } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Version\"',\n undefined,\n {\n silent: true,\n },\n );\n\n const { stdout: name } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Caption\"',\n undefined,\n {\n silent: true,\n },\n );\n\n return {\n name: name.trim(),\n version: version.trim(),\n };\n};\n\n/**\n * Get the name and version of the current macOS system.\n */\nconst getMacOsInfo = async (): Promise => {\n const { stdout } = await exec.getExecOutput(\"sw_vers\", undefined, {\n silent: true,\n });\n\n const version = stdout.match(/ProductVersion:\\s*(.+)/)?.[1] ?? \"\";\n const name = stdout.match(/ProductName:\\s*(.+)/)?.[1] ?? \"\";\n\n return {\n name,\n version,\n };\n};\n\n/**\n * Get the name and version of the current Linux system.\n */\nconst getLinuxInfo = async (): Promise => {\n let data: object = {};\n\n try {\n data = releaseInfo({ mode: \"sync\" });\n // eslint-disable-next-line no-console\n console.log(data);\n } catch (e) {\n core.debug(`Error collecting release info: ${e}`);\n }\n\n return {\n name: getPropertyViaWithDefault(\n data,\n [\"id\", \"name\", \"pretty_name\", \"id_like\"],\n \"unknown\",\n ),\n version: getPropertyViaWithDefault(\n data,\n [\"version_id\", \"version\", \"version_codename\"],\n \"unknown\",\n ),\n };\n};\n\nfunction getPropertyViaWithDefault(\n data: object,\n names: Property[],\n defaultValue: T,\n): T {\n for (const name of names) {\n const ret: T = getPropertyWithDefault(data, name, defaultValue);\n\n if (ret !== defaultValue) {\n return ret;\n }\n }\n\n return defaultValue;\n}\n\nfunction getPropertyWithDefault(\n data: object,\n name: Property,\n defaultValue: T,\n): T {\n if (!data.hasOwnProperty(name)) {\n return defaultValue;\n }\n\n const value = (data as { [K in Property]: T })[name];\n\n // NB. this check won't work for object instances\n if (typeof value !== typeof defaultValue) {\n return defaultValue;\n }\n\n return value;\n}\n\n/**\n * The Action runner's platform.\n */\nexport const platform = os.platform();\n\n/**\n * The Action runner's architecture.\n */\nexport const arch = os.arch();\n\n/**\n * Whether the Action runner is a Windows system.\n */\nexport const isWindows = platform === \"win32\";\n\n/**\n * Whether the Action runner is a macOS system.\n */\nexport const isMacOS = platform === \"darwin\";\n\n/**\n * Whether the Action runner is a Linux system.\n */\nexport const isLinux = platform === \"linux\";\n\n/**\n * System-level information about the current host (platform, architecture, etc.).\n */\ntype SystemDetails = {\n name: string;\n platform: string;\n arch: string;\n version: string;\n isWindows: boolean;\n isMacOS: boolean;\n isLinux: boolean;\n};\n\n/**\n * Get system-level information about the current host (platform, architecture, etc.).\n */\nexport async function getDetails(): Promise {\n return {\n ...(await (isWindows\n ? getWindowsInfo()\n : isMacOS\n ? getMacOsInfo()\n : getLinuxInfo())),\n platform,\n arch,\n isWindows,\n isMacOS,\n isLinux,\n };\n}\n","import * as actionsCore from \"@actions/core\";\nimport { createHash } from \"node:crypto\";\n\nconst OPTIONAL_VARIABLES = [\"INVOCATION_ID\"];\n\n// JSON sent to server\n/* eslint-disable camelcase */\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 job: hashEnvironmentVariables(\"GHWJ\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n ]),\n run: hashEnvironmentVariables(\"GHWJR\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n ]),\n run_differentiator: hashEnvironmentVariables(\"GHWJA\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n \"GITHUB_RUN_NUMBER\",\n \"GITHUB_RUN_ATTEMPT\",\n \"INVOCATION_ID\",\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 let value = process.env[varName];\n\n if (value === undefined) {\n if (OPTIONAL_VARIABLES.includes(varName)) {\n actionsCore.debug(\n `Optional environment variable not set: ${varName} -- substituting with the variable name`,\n );\n value = varName;\n } else {\n actionsCore.debug(\n `Environment variable not set: ${varName} -- can't generate the requested identity`,\n );\n return undefined;\n }\n }\n\n hash.update(value);\n hash.update(\"\\0\");\n }\n\n return `${prefix}-${hash.digest(\"hex\")}`;\n}\n","/**\n * @packageDocumentation\n * Helpers for determining system attributes of the current runner.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get the current architecture plus OS. Examples include `X64-Linux` and `ARM64-macOS`.\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\n/**\n * Get the current Nix system. Examples include `x86_64-linux` and `aarch64-darwin`.\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","/**\n * @packageDocumentation\n * Helpers for getting values from an Action's configuration.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get a Boolean input from the Action's configuration by name.\n */\nconst getBool = (name: string): boolean => {\n return actionsCore.getBooleanInput(name);\n};\n\n/**\n * Get a multi-line string input from the Action's configuration by name or return `null` if not set.\n */\nconst getMultilineStringOrNull = (name: string): string[] | null => {\n const value = actionsCore.getMultilineInput(name);\n if (value.length === 0) {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a number input from the Action's configuration by name or return `null` if not set.\n */\nconst getNumberOrNull = (name: string): number | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return Number(value);\n }\n};\n\n/**\n * Get a string input from the Action's configuration.\n */\nconst getString = (name: string): string => {\n return actionsCore.getInput(name);\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `null` if not set.\n */\nconst getStringOrNull = (name: string): string | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `undefined` if not set.\n */\nconst getStringOrUndefined = (name: string): string | undefined => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return undefined;\n } else {\n return value;\n }\n};\n\nexport {\n getBool,\n getMultilineStringOrNull,\n getNumberOrNull,\n getString,\n getStringOrNull,\n getStringOrUndefined,\n};\n","import { getStringOrUndefined } from \"./inputs.js\";\nimport * 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 = getStringOrUndefined(`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 = getStringOrUndefined(`${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","/**\n * @packageDocumentation\n * Determinate Systems' TypeScript library for creating GitHub Actions logic.\n */\nimport { version as pkgVersion } from \"../package.json\";\nimport * as ghActionsCorePlatform from \"./actions-core-platform.js\";\nimport * as correlation from \"./correlation.js\";\nimport * as platform from \"./platform.js\";\nimport { SourceDef, constructSourceParameters } from \"./sourcedef.js\";\nimport * as actionsCache from \"@actions/cache\";\nimport * as actionsCore from \"@actions/core\";\nimport got, { Got } from \"got\";\nimport { UUID, randomUUID } from \"node:crypto\";\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\";\n\nconst DEFAULT_IDS_HOST = \"https://install.determinate.systems\";\nconst IDS_HOST = process.env[\"IDS_HOST\"] ?? DEFAULT_IDS_HOST;\n\nconst EVENT_EXCEPTION = \"exception\";\nconst EVENT_ARTIFACT_CACHE_HIT = \"artifact_cache_hit\";\nconst EVENT_ARTIFACT_CACHE_MISS = \"artifact_cache_miss\";\n\nconst FACT_ENDED_WITH_EXCEPTION = \"ended_with_exception\";\nconst FACT_FINAL_EXCEPTION = \"final_exception\";\n\nexport type FetchSuffixStyle = \"nix-style\" | \"gh-env-style\" | \"universal\";\nexport type ExecutionPhase = \"main\" | \"post\";\nexport type NixRequirementHandling = \"fail\" | \"warn\" | \"ignore\";\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 // Check if Nix is installed before running this action.\n // If Nix isn't installed, this action will not fail, and will instead do nothing.\n // The action will emit a user-visible warning instructing them to install Nix.\n requireNix: NixRequirementHandling;\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 requireNix: NixRequirementHandling;\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 uuid: UUID;\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 private hookMain?: () => Promise;\n private hookPost?: () => Promise;\n\n constructor(actionOptions: ActionOptions) {\n this.actionOptions = makeOptionsConfident(actionOptions);\n this.hookMain = undefined;\n this.hookPost = undefined;\n\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 // JSON sent to server\n /* eslint-disable camelcase */\n this.facts = {\n $lib: \"idslib\",\n $lib_version: pkgVersion,\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 ghActionsCorePlatform\n .getDetails()\n // eslint-disable-next-line github/no-then\n .then((details) => {\n if (details.name !== \"unknown\") {\n this.addFact(\"$os\", details.name);\n }\n if (details.version !== \"unknown\") {\n this.addFact(\"$os_version\", details.version);\n }\n })\n // eslint-disable-next-line github/no-then\n .catch((e) => {\n actionsCore.debug(`Failure getting platform details: ${e}`);\n });\n }\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 onMain(callback: () => Promise): void {\n this.hookMain = callback;\n }\n\n onPost(callback: () => Promise): void {\n this.hookPost = callback;\n }\n\n execute(): void {\n // eslint-disable-next-line github/no-then\n this.executeAsync().catch((error: Error) => {\n // eslint-disable-next-line no-console\n console.log(error);\n process.exitCode = 1;\n });\n }\n\n private async executeAsync(): Promise {\n try {\n process.env.DETSYS_CORRELATION = JSON.stringify(\n this.getCorrelationHashes(),\n );\n\n if (!(await this.preflightRequireNix())) {\n this.recordEvent(\"preflight-require-nix-denied\");\n return;\n }\n\n if (this.executionPhase === \"main\" && this.hookMain) {\n await this.hookMain();\n } else if (this.executionPhase === \"post\" && this.hookPost) {\n await this.hookPost();\n }\n this.addFact(FACT_ENDED_WITH_EXCEPTION, false);\n } catch (error) {\n this.addFact(FACT_ENDED_WITH_EXCEPTION, true);\n\n const reportable =\n error instanceof Error || typeof error == \"string\"\n ? error.toString()\n : JSON.stringify(error);\n\n this.addFact(FACT_FINAL_EXCEPTION, reportable);\n\n if (this.executionPhase === \"post\") {\n actionsCore.warning(reportable);\n } else {\n actionsCore.setFailed(reportable);\n }\n\n this.recordEvent(EVENT_EXCEPTION);\n } finally {\n await this.complete();\n }\n }\n\n addFact(key: string, value: string | boolean): void {\n this.facts[key] = value;\n }\n\n getDiagnosticsUrl(): URL | undefined {\n return this.actionOptions.diagnosticsUrl;\n }\n\n getUniqueId(): string {\n return (\n this.identity.run_differentiator ||\n process.env.RUNNER_TRACKING_ID ||\n randomUUID()\n );\n }\n\n getCorrelationHashes(): correlation.AnonymizedCorrelationHashes {\n return this.identity;\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 uuid: randomUUID(),\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 this.client.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 = this.client.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 private 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(EVENT_ARTIFACT_CACHE_HIT);\n return `${tempDir}/${this.actionOptions.name}`;\n }\n\n this.recordEvent(EVENT_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(EVENT_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 preflightRequireNix(): Promise {\n let nixLocation: string | undefined;\n\n const pathParts = (process.env[\"PATH\"] || \"\").split(\":\");\n for (const location of pathParts) {\n const candidateNix = path.join(location, \"nix\");\n\n try {\n await fs.access(candidateNix, fs.constants.X_OK);\n actionsCore.debug(`Found Nix at ${candidateNix}`);\n nixLocation = candidateNix;\n } catch {\n actionsCore.debug(`Nix not at ${candidateNix}`);\n }\n }\n this.addFact(\"nix_location\", nixLocation || \"\");\n\n if (this.actionOptions.requireNix === \"ignore\") {\n return true;\n }\n\n const currentNotFoundState = actionsCore.getState(\n \"idstoolbox_nix_not_found\",\n );\n if (currentNotFoundState === \"not-found\") {\n // It was previously not found, so don't run subsequent actions\n return false;\n }\n\n if (nixLocation !== undefined) {\n return true;\n }\n actionsCore.saveState(\"idstoolbox_nix_not_found\", \"not-found\");\n\n switch (this.actionOptions.requireNix) {\n case \"fail\":\n actionsCore.setFailed(\n \"This action can only be used when Nix is installed.\" +\n \" Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n );\n break;\n case \"warn\":\n actionsCore.warning(\n \"This action is in no-op mode because Nix is not installed.\" +\n \" Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n );\n break;\n }\n\n return false;\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 this.client.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}-${randomUUID()}`);\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 requireNix: actionOptions.requireNix,\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\n// Public exports from other files\nexport * as inputs from \"./inputs.js\";\nexport * as platform from \"./platform.js\";\n"],"mappings":";;;;;;;AAEE,cAAW;;;ACUb,YAAY,QAAQ;AACpB,YAAY,QAAQ;AACpB,SAAS,iBAAiB;AAE1B,IAAM,gBAAgB,UAAa,WAAQ;AAyB3C,IAAM,kCAA2D;AAAA,EAC/D,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,OAAO;AACT;AAQO,SAAS,YAAY,aAA8C;AACxE,QAAM,UAAU,EAAE,GAAG,iCAAiC,GAAG,YAAY;AAErE,QAAM,0BAAoC;AAAA,IACxC,QAAQ;AAAA,EACV;AAEA,MAAO,QAAK,MAAM,SAAS;AACzB,QAAI,QAAQ,SAAS,QAAQ;AAC3B,aAAO,UAAU;AAAA,IACnB,OAAO;AACL,aAAO,QAAQ,QAAQ,UAAU,CAAC;AAAA,IACpC;AAAA,EACF;AAEA,MAAI,QAAQ,SAAS,QAAQ;AAC3B,WAAO,sBAAsB,yBAAyB,OAAO;AAAA,EAC/D,OAAO;AACL,WAAO,QAAQ;AAAA,MACb,uBAAuB,yBAAyB,OAAO;AAAA,IACzD;AAAA,EACF;AACF;AASA,SAA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BAAiB,IAAI,IAAI,gBAAgB;AAC/C,UAAM,iBAAiB,IAAI,IAAI,QAAQ;AAEvC,QAAI,SAAS,WAAW,eAAe,QAAQ;AAC7C,aAAO;AAAA,IACT;AAEA,aAAS,WAAW,eAAe;AACnC,aAAS,OAAO,eAAe;AAC/B,aAAS,WAAW,eAAe;AACnC,aAAS,WAAW,eAAe;AAEnC,WAAO;AAAA,EACT,SAAS,GAAG;AACV,IAAY,kBAAK,qDAAqD,CAAC,EAAE;AAAA,EAC3E;AAEA,SAAO;AACT;","names":["error","os","version","platform","arch","actionsCore","actionsCore","actionsCore","actionsCore","fs","error","version"]} \ No newline at end of file +{"version":3,"sources":["../package.json","../src/linux-release-info.ts","../src/actions-core-platform.ts","../src/correlation.ts","../src/platform.ts","../src/inputs.ts","../src/sourcedef.ts","../src/index.ts"],"sourcesContent":["{\n \"name\": \"detsys-ts\",\n \"version\": \"1.0.0\",\n \"description\": \"TypeScript goodies for DetSys projects\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"check-fmt\": \"prettier --check .\",\n \"format\": \"prettier --write .\",\n \"lint\": \"eslint src/**/*.ts\",\n \"docs\": \"typedoc src/index.ts\",\n \"all\": \"rm -rf dist && 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\": \"MIT\",\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.1\",\n \"@actions/exec\": \"^1.1.1\",\n \"got\": \"^14.2.1\"\n },\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/node\": \"^20.12.7\",\n \"@typescript-eslint/eslint-plugin\": \"^7.6.0\",\n \"eslint\": \"^8.57.0\",\n \"eslint-import-resolver-typescript\": \"^3.6.1\",\n \"eslint-plugin-github\": \"^4.10.2\",\n \"eslint-plugin-import\": \"^2.29.1\",\n \"eslint-plugin-prettier\": \"^5.1.3\",\n \"prettier\": \"^3.2.5\",\n \"tsup\": \"^8.0.2\",\n \"typedoc\": \"^0.25.13\",\n \"typescript\": \"^5.4.5\"\n }\n}\n","/*!\n * linux-release-info\n * Get Linux release info (distribution name, version, arch, release, etc.)\n * from '/etc/os-release' or '/usr/lib/os-release' files and from native os\n * module. On Windows and Darwin platforms it only returns common node os module\n * info (platform, hostname, release, and arch)\n *\n * Licensed under MIT\n * Copyright (c) 2018-2020 [Samuel Carreira]\n */\n// NOTE: we depend on this directly to get around some un-fun issues with mixing CommonJS\n// and ESM in the bundle.\nimport * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport { promisify } from \"node:util\";\n\nconst readFileAsync = promisify(fs.readFile);\n\nexport interface LinuxReleaseInfoOptions {\n /**\n * read mode, possible values: 'async' and 'sync'\n *\n * @default 'async'\n */\n mode?: \"async\" | \"sync\";\n /**\n * custom complete file path with os info default null/none\n * if not provided the system will search on the '/etc/os-release'\n * and '/usr/lib/os-release' files\n *\n * @default null\n */\n customFile?: string | null | undefined;\n /**\n * if true, show console debug messages\n *\n * @default false\n */\n debug?: boolean;\n}\n\nconst linuxReleaseInfoOptionsDefaults: LinuxReleaseInfoOptions = {\n mode: \"async\",\n customFile: null,\n debug: false,\n};\n\n/**\n * Get OS release info from 'os-release' file and from native os module\n * on Windows or Darwin it only returns common os module info\n * (uses native fs module)\n * @returns {object} info from the current os\n */\nexport function releaseInfo(infoOptions: LinuxReleaseInfoOptions): object {\n const options = { ...linuxReleaseInfoOptionsDefaults, ...infoOptions };\n\n const searchOsReleaseFileList: string[] = osReleaseFileList(\n options.customFile,\n );\n\n if (os.type() !== \"Linux\") {\n if (options.mode === \"sync\") {\n return getOsInfo();\n } else {\n return Promise.resolve(getOsInfo());\n }\n }\n\n if (options.mode === \"sync\") {\n return readSyncOsreleaseFile(searchOsReleaseFileList, options);\n } else {\n return Promise.resolve(\n readAsyncOsReleaseFile(searchOsReleaseFileList, options),\n );\n }\n}\n\n/**\n * Format file data: convert data to object keys/values\n *\n * @param {object} sourceData Source object to be appended\n * @param {string} srcParseData Input file data to be parsed\n * @returns {object} Formated object\n */\nfunction formatFileData(sourceData: OsInfo, srcParseData: string): OsInfo {\n const lines: string[] = srcParseData.split(\"\\n\");\n\n for (const line of lines) {\n const lineData = line.split(\"=\");\n\n if (lineData.length === 2) {\n lineData[1] = lineData[1].replace(/[\"'\\r]/gi, \"\"); // remove quotes and return character\n\n Object.defineProperty(sourceData, lineData[0].toLowerCase(), {\n value: lineData[1],\n writable: true,\n enumerable: true,\n configurable: true,\n });\n }\n }\n\n return sourceData;\n}\n\n/**\n * Export a list of os-release files\n *\n * @param {string} customFile optional custom complete filepath\n * @returns {array} list of os-release files\n */\nfunction osReleaseFileList(customFile: string | null | undefined): string[] {\n const DEFAULT_OS_RELEASE_FILES = [\"/etc/os-release\", \"/usr/lib/os-release\"];\n\n if (!customFile) {\n return DEFAULT_OS_RELEASE_FILES;\n } else {\n return Array(customFile);\n }\n}\n\n/**\n * Operating system info.\n */\ntype OsInfo = {\n type: string;\n platform: string;\n hostname: string;\n arch: string;\n release: string;\n};\n\n/**\n * Get OS Basic Info\n * (uses node 'os' native module)\n *\n * @returns {OsInfo} os basic info\n */\nfunction getOsInfo(): OsInfo {\n return {\n type: os.type(),\n platform: os.platform(),\n hostname: os.hostname(),\n arch: os.arch(),\n release: os.release(),\n };\n}\n\n/* Helper functions */\n\nasync function readAsyncOsReleaseFile(\n fileList: string[],\n options: LinuxReleaseInfoOptions,\n): Promise {\n let fileData = null;\n\n for (const osReleaseFile of fileList) {\n try {\n if (options.debug) {\n /* eslint-disable no-console */\n console.log(`Trying to read '${osReleaseFile}'...`);\n }\n\n fileData = await readFileAsync(osReleaseFile, \"binary\");\n\n if (options.debug) {\n console.log(`Read data:\\n${fileData}`);\n }\n\n break;\n } catch (error) {\n if (options.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n}\n\nfunction readSyncOsreleaseFile(\n releaseFileList: string[],\n options: LinuxReleaseInfoOptions,\n): OsInfo {\n let fileData = null;\n\n for (const osReleaseFile of releaseFileList) {\n try {\n if (options.debug) {\n console.log(`Trying to read '${osReleaseFile}'...`);\n }\n\n fileData = fs.readFileSync(osReleaseFile, \"binary\");\n\n if (options.debug) {\n console.log(`Read data:\\n${fileData}`);\n }\n\n break;\n } catch (error) {\n if (options.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n}\n","// MIT, mostly lifted from https://github.com/actions/toolkit/blob/5a736647a123ecf8582376bdaee833fbae5b3847/packages/core/src/platform.ts\n// since it isn't in @actions/core 1.10.1 which is their current release as 2024-04-19.\n// Changes: Replaced the lsb_release call in Linux with `linux-release-info` to parse the os-release file directly.\nimport { releaseInfo } from \"./linux-release-info.js\";\nimport * as core from \"@actions/core\";\nimport * as exec from \"@actions/exec\";\nimport os from \"os\";\n\n/**\n * The name and version of the Action runner's system.\n */\ntype SystemInfo = {\n name: string;\n version: string;\n};\n\n/**\n * Get the name and version of the current Windows system.\n */\nconst getWindowsInfo = async (): Promise => {\n const { stdout: version } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Version\"',\n undefined,\n {\n silent: true,\n },\n );\n\n const { stdout: name } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Caption\"',\n undefined,\n {\n silent: true,\n },\n );\n\n return {\n name: name.trim(),\n version: version.trim(),\n };\n};\n\n/**\n * Get the name and version of the current macOS system.\n */\nconst getMacOsInfo = async (): Promise => {\n const { stdout } = await exec.getExecOutput(\"sw_vers\", undefined, {\n silent: true,\n });\n\n const version = stdout.match(/ProductVersion:\\s*(.+)/)?.[1] ?? \"\";\n const name = stdout.match(/ProductName:\\s*(.+)/)?.[1] ?? \"\";\n\n return {\n name,\n version,\n };\n};\n\n/**\n * Get the name and version of the current Linux system.\n */\nconst getLinuxInfo = async (): Promise => {\n let data: object = {};\n\n try {\n data = releaseInfo({ mode: \"sync\" });\n // eslint-disable-next-line no-console\n console.log(data);\n } catch (e) {\n core.debug(`Error collecting release info: ${e}`);\n }\n\n return {\n name: getPropertyViaWithDefault(\n data,\n [\"id\", \"name\", \"pretty_name\", \"id_like\"],\n \"unknown\",\n ),\n version: getPropertyViaWithDefault(\n data,\n [\"version_id\", \"version\", \"version_codename\"],\n \"unknown\",\n ),\n };\n};\n\nfunction getPropertyViaWithDefault(\n data: object,\n names: Property[],\n defaultValue: T,\n): T {\n for (const name of names) {\n const ret: T = getPropertyWithDefault(data, name, defaultValue);\n\n if (ret !== defaultValue) {\n return ret;\n }\n }\n\n return defaultValue;\n}\n\nfunction getPropertyWithDefault(\n data: object,\n name: Property,\n defaultValue: T,\n): T {\n if (!data.hasOwnProperty(name)) {\n return defaultValue;\n }\n\n const value = (data as { [K in Property]: T })[name];\n\n // NB. this check won't work for object instances\n if (typeof value !== typeof defaultValue) {\n return defaultValue;\n }\n\n return value;\n}\n\n/**\n * The Action runner's platform.\n */\nexport const platform = os.platform();\n\n/**\n * The Action runner's architecture.\n */\nexport const arch = os.arch();\n\n/**\n * Whether the Action runner is a Windows system.\n */\nexport const isWindows = platform === \"win32\";\n\n/**\n * Whether the Action runner is a macOS system.\n */\nexport const isMacOS = platform === \"darwin\";\n\n/**\n * Whether the Action runner is a Linux system.\n */\nexport const isLinux = platform === \"linux\";\n\n/**\n * System-level information about the current host (platform, architecture, etc.).\n */\ntype SystemDetails = {\n name: string;\n platform: string;\n arch: string;\n version: string;\n isWindows: boolean;\n isMacOS: boolean;\n isLinux: boolean;\n};\n\n/**\n * Get system-level information about the current host (platform, architecture, etc.).\n */\nexport async function getDetails(): Promise {\n return {\n ...(await (isWindows\n ? getWindowsInfo()\n : isMacOS\n ? getMacOsInfo()\n : getLinuxInfo())),\n platform,\n arch,\n isWindows,\n isMacOS,\n isLinux,\n };\n}\n","import * as actionsCore from \"@actions/core\";\nimport { createHash } from \"node:crypto\";\n\nconst OPTIONAL_VARIABLES = [\"INVOCATION_ID\"];\n\n// JSON sent to server\n/* eslint-disable camelcase */\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 job: hashEnvironmentVariables(\"GHWJ\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n ]),\n run: hashEnvironmentVariables(\"GHWJR\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n ]),\n run_differentiator: hashEnvironmentVariables(\"GHWJA\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n \"GITHUB_RUN_NUMBER\",\n \"GITHUB_RUN_ATTEMPT\",\n \"INVOCATION_ID\",\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 let value = process.env[varName];\n\n if (value === undefined) {\n if (OPTIONAL_VARIABLES.includes(varName)) {\n actionsCore.debug(\n `Optional environment variable not set: ${varName} -- substituting with the variable name`,\n );\n value = varName;\n } else {\n actionsCore.debug(\n `Environment variable not set: ${varName} -- can't generate the requested identity`,\n );\n return undefined;\n }\n }\n\n hash.update(value);\n hash.update(\"\\0\");\n }\n\n return `${prefix}-${hash.digest(\"hex\")}`;\n}\n","/**\n * @packageDocumentation\n * Helpers for determining system attributes of the current runner.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get the current architecture plus OS. Examples include `X64-Linux` and `ARM64-macOS`.\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\n/**\n * Get the current Nix system. Examples include `x86_64-linux` and `aarch64-darwin`.\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","/**\n * @packageDocumentation\n * Helpers for getting values from an Action's configuration.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get a Boolean input from the Action's configuration by name.\n */\nconst getBool = (name: string): boolean => {\n return actionsCore.getBooleanInput(name);\n};\n\n/**\n * Get a multi-line string input from the Action's configuration by name or return `null` if not set.\n */\nconst getMultilineStringOrNull = (name: string): string[] | null => {\n const value = actionsCore.getMultilineInput(name);\n if (value.length === 0) {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a number input from the Action's configuration by name or return `null` if not set.\n */\nconst getNumberOrNull = (name: string): number | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return Number(value);\n }\n};\n\n/**\n * Get a string input from the Action's configuration.\n */\nconst getString = (name: string): string => {\n return actionsCore.getInput(name);\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `null` if not set.\n */\nconst getStringOrNull = (name: string): string | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `undefined` if not set.\n */\nconst getStringOrUndefined = (name: string): string | undefined => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return undefined;\n } else {\n return value;\n }\n};\n\nexport {\n getBool,\n getMultilineStringOrNull,\n getNumberOrNull,\n getString,\n getStringOrNull,\n getStringOrUndefined,\n};\n","import { getStringOrUndefined } from \"./inputs.js\";\nimport * 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 = getStringOrUndefined(`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 = getStringOrUndefined(`${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","/**\n * @packageDocumentation\n * Determinate Systems' TypeScript library for creating GitHub Actions logic.\n */\nimport { version as pkgVersion } from \"../package.json\";\nimport * as ghActionsCorePlatform from \"./actions-core-platform.js\";\nimport * as correlation from \"./correlation.js\";\nimport * as platform from \"./platform.js\";\nimport { SourceDef, constructSourceParameters } from \"./sourcedef.js\";\nimport * as actionsCache from \"@actions/cache\";\nimport * as actionsCore from \"@actions/core\";\nimport got, { Got } from \"got\";\nimport { UUID, randomUUID } from \"node:crypto\";\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\";\n\nconst DEFAULT_IDS_HOST = \"https://install.determinate.systems\";\nconst IDS_HOST = process.env[\"IDS_HOST\"] ?? DEFAULT_IDS_HOST;\n\nconst EVENT_EXCEPTION = \"exception\";\nconst EVENT_ARTIFACT_CACHE_HIT = \"artifact_cache_hit\";\nconst EVENT_ARTIFACT_CACHE_MISS = \"artifact_cache_miss\";\n\nconst FACT_ENDED_WITH_EXCEPTION = \"ended_with_exception\";\nconst FACT_FINAL_EXCEPTION = \"final_exception\";\n\nexport type FetchSuffixStyle = \"nix-style\" | \"gh-env-style\" | \"universal\";\nexport type ExecutionPhase = \"main\" | \"post\";\nexport type NixRequirementHandling = \"fail\" | \"warn\" | \"ignore\";\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 // Check if Nix is installed before running this action.\n // If Nix isn't installed, this action will not fail, and will instead do nothing.\n // The action will emit a user-visible warning instructing them to install Nix.\n requireNix: NixRequirementHandling;\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 requireNix: NixRequirementHandling;\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 uuid: UUID;\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 private hookMain?: () => Promise;\n private hookPost?: () => Promise;\n\n constructor(actionOptions: ActionOptions) {\n this.actionOptions = makeOptionsConfident(actionOptions);\n this.hookMain = undefined;\n this.hookPost = undefined;\n\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 // JSON sent to server\n /* eslint-disable camelcase */\n this.facts = {\n $lib: \"idslib\",\n $lib_version: pkgVersion,\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 ghActionsCorePlatform\n .getDetails()\n // eslint-disable-next-line github/no-then\n .then((details) => {\n if (details.name !== \"unknown\") {\n this.addFact(\"$os\", details.name);\n }\n if (details.version !== \"unknown\") {\n this.addFact(\"$os_version\", details.version);\n }\n })\n // eslint-disable-next-line github/no-then\n .catch((e) => {\n actionsCore.debug(`Failure getting platform details: ${e}`);\n });\n }\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 onMain(callback: () => Promise): void {\n this.hookMain = callback;\n }\n\n onPost(callback: () => Promise): void {\n this.hookPost = callback;\n }\n\n execute(): void {\n // eslint-disable-next-line github/no-then\n this.executeAsync().catch((error: Error) => {\n // eslint-disable-next-line no-console\n console.log(error);\n process.exitCode = 1;\n });\n }\n\n private async executeAsync(): Promise {\n try {\n process.env.DETSYS_CORRELATION = JSON.stringify(\n this.getCorrelationHashes(),\n );\n\n if (!(await this.preflightRequireNix())) {\n this.recordEvent(\"preflight-require-nix-denied\");\n return;\n }\n\n if (this.executionPhase === \"main\" && this.hookMain) {\n await this.hookMain();\n } else if (this.executionPhase === \"post\" && this.hookPost) {\n await this.hookPost();\n }\n this.addFact(FACT_ENDED_WITH_EXCEPTION, false);\n } catch (error) {\n this.addFact(FACT_ENDED_WITH_EXCEPTION, true);\n\n const reportable =\n error instanceof Error || typeof error == \"string\"\n ? error.toString()\n : JSON.stringify(error);\n\n this.addFact(FACT_FINAL_EXCEPTION, reportable);\n\n if (this.executionPhase === \"post\") {\n actionsCore.warning(reportable);\n } else {\n actionsCore.setFailed(reportable);\n }\n\n this.recordEvent(EVENT_EXCEPTION);\n } finally {\n await this.complete();\n }\n }\n\n addFact(key: string, value: string | boolean): void {\n this.facts[key] = value;\n }\n\n getDiagnosticsUrl(): URL | undefined {\n return this.actionOptions.diagnosticsUrl;\n }\n\n getUniqueId(): string {\n return (\n this.identity.run_differentiator ||\n process.env.RUNNER_TRACKING_ID ||\n randomUUID()\n );\n }\n\n getCorrelationHashes(): correlation.AnonymizedCorrelationHashes {\n return this.identity;\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 uuid: randomUUID(),\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 this.client.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 = this.client.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 private 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(EVENT_ARTIFACT_CACHE_HIT);\n return `${tempDir}/${this.actionOptions.name}`;\n }\n\n this.recordEvent(EVENT_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(EVENT_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 preflightRequireNix(): Promise {\n let nixLocation: string | undefined;\n\n const pathParts = (process.env[\"PATH\"] || \"\").split(\":\");\n for (const location of pathParts) {\n const candidateNix = path.join(location, \"nix\");\n\n try {\n await fs.access(candidateNix, fs.constants.X_OK);\n actionsCore.debug(`Found Nix at ${candidateNix}`);\n nixLocation = candidateNix;\n } catch {\n actionsCore.debug(`Nix not at ${candidateNix}`);\n }\n }\n this.addFact(\"nix_location\", nixLocation || \"\");\n\n if (this.actionOptions.requireNix === \"ignore\") {\n return true;\n }\n\n const currentNotFoundState = actionsCore.getState(\n \"idstoolbox_nix_not_found\",\n );\n if (currentNotFoundState === \"not-found\") {\n // It was previously not found, so don't run subsequent actions\n return false;\n }\n\n if (nixLocation !== undefined) {\n return true;\n }\n actionsCore.saveState(\"idstoolbox_nix_not_found\", \"not-found\");\n\n switch (this.actionOptions.requireNix) {\n case \"fail\":\n actionsCore.setFailed(\n \"This action can only be used when Nix is installed.\" +\n \" Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n );\n break;\n case \"warn\":\n actionsCore.warning(\n \"This action is in no-op mode because Nix is not installed.\" +\n \" Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n );\n break;\n }\n\n return false;\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 this.client.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}-${randomUUID()}`);\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 requireNix: actionOptions.requireNix,\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\n// Public exports from other files\nexport * as inputs from \"./inputs.js\";\nexport * as platform from \"./platform.js\";\n"],"mappings":";;;;;;;AAEE,cAAW;;;ACUb,YAAY,QAAQ;AACpB,YAAY,QAAQ;AACpB,SAAS,iBAAiB;AAE1B,IAAM,gBAAgB,UAAa,WAAQ;AAyB3C,IAAM,kCAA2D;AAAA,EAC/D,MAAM;AAAA,EACN,Y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QAAW;AAC5C,UAAI;AACF,eAAO,wBAAwB,IAAI,IAAI,0BAA0B,CAAC;AAAA,MACpE,SAAS,GAAG;AACV,QAAY;AAAA,UACV,+DAA+D,CAAC;AAAA,QAClE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,MAAI;AACF,UAAM,gBAAgB,IAAI,IAAI,QAAQ;AACtC,kBAAc,YAAY;AAC1B,kBAAc,YAAY;AAC1B,WAAO;AAAA,EACT,SAAS,GAAG;AACV,IAAY;AAAA,MACV,2DAA2D,CAAC;AAAA,IAC9D;AAAA,EACF;AAEA,SAAO;AACT;AAEA,SAAS,wBAAwB,UAAoB;AACnD,MAAI,qBAAqB,UAAU;AACjC,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,iBAAiB,IAAI,IAAI,gBAAgB;AAC/C,UAAM,iBAAiB,IAAI,IAAI,QAAQ;AAEvC,QAAI,SAAS,WAAW,eAAe,QAAQ;AAC7C,aAAO;AAAA,IACT;AAEA,aAAS,WAAW,eAAe;AACnC,aAAS,OAAO,eAAe;AAC/B,aAAS,WAAW,eAAe;AACnC,aAAS,WAAW,eAAe;AAEnC,WAAO;AAAA,EACT,SAAS,GAAG;AACV,IAAY,kBAAK,qDAAqD,CAAC,EAAE;AAAA,EAC3E;AAEA,SAAO;AACT;","names":["error","os","version","platform","arch","actionsCore","actionsCore","actionsCore","actionsCore","fs","error","version"]} \ No newline at end of file diff --git a/src/linux-release-info.ts b/src/linux-release-info.ts index 07d114e..40cbcd2 100644 --- a/src/linux-release-info.ts +++ b/src/linux-release-info.ts @@ -150,26 +150,26 @@ function getOsInfo(): OsInfo { async function readAsyncOsReleaseFile( fileList: string[], - releaseInfoOptions: LinuxReleaseInfoOptions, + options: LinuxReleaseInfoOptions, ): Promise { let fileData = null; for (const osReleaseFile of fileList) { try { - if (releaseInfoOptions.debug) { + if (options.debug) { /* eslint-disable no-console */ console.log(`Trying to read '${osReleaseFile}'...`); } fileData = await readFileAsync(osReleaseFile, "binary"); - if (releaseInfoOptions.debug) { + if (options.debug) { console.log(`Read data:\n${fileData}`); } break; } catch (error) { - if (releaseInfoOptions.debug) { + if (options.debug) { console.error(error); } } @@ -185,25 +185,25 @@ async function readAsyncOsReleaseFile( function readSyncOsreleaseFile( releaseFileList: string[], - releaseInfoOptions: LinuxReleaseInfoOptions, + options: LinuxReleaseInfoOptions, ): OsInfo { let fileData = null; for (const osReleaseFile of releaseFileList) { try { - if (releaseInfoOptions.debug) { + if (options.debug) { console.log(`Trying to read '${osReleaseFile}'...`); } fileData = fs.readFileSync(osReleaseFile, "binary"); - if (releaseInfoOptions.debug) { + if (options.debug) { console.log(`Read data:\n${fileData}`); } break; } catch (error) { - if (releaseInfoOptions.debug) { + if (options.debug) { console.error(error); } } From 3ac3d7aebcce4d3658f33ebbdf09ce578e29e1f7 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Sun, 21 Apr 2024 12:43:19 -0300 Subject: [PATCH 5/6] Update comment at top of file --- src/linux-release-info.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/linux-release-info.ts b/src/linux-release-info.ts index 40cbcd2..16d9ae1 100644 --- a/src/linux-release-info.ts +++ b/src/linux-release-info.ts @@ -9,7 +9,9 @@ * Copyright (c) 2018-2020 [Samuel Carreira] */ // NOTE: we depend on this directly to get around some un-fun issues with mixing CommonJS -// and ESM in the bundle. +// and ESM in the bundle. We've modified the original logic to improve things like typing +// and fixing ESLint issues. Originally drawn from: +// https://github.com/samuelcarreira/linux-release-info/blob/84a91aa5442b47900da03020c590507545d3dc74/src/index.ts import * as fs from "node:fs"; import * as os from "node:os"; import { promisify } from "node:util"; From e6587f7812bf7ebece280e89bce704dd2d2eb6f2 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Sun, 21 Apr 2024 12:45:14 -0300 Subject: [PATCH 6/6] Regenerate dist --- dist/index.js.map | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/index.js.map b/dist/index.js.map index fafa570..bd1c2c2 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"sources":["../package.json","../src/linux-release-info.ts","../src/actions-core-platform.ts","../src/correlation.ts","../src/platform.ts","../src/inputs.ts","../src/sourcedef.ts","../src/index.ts"],"sourcesContent":["{\n \"name\": \"detsys-ts\",\n \"version\": \"1.0.0\",\n \"description\": \"TypeScript goodies for DetSys projects\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"check-fmt\": \"prettier --check .\",\n \"format\": \"prettier --write .\",\n \"lint\": \"eslint src/**/*.ts\",\n \"docs\": \"typedoc src/index.ts\",\n \"all\": \"rm -rf dist && 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\": \"MIT\",\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.1\",\n \"@actions/exec\": \"^1.1.1\",\n \"got\": \"^14.2.1\"\n },\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/node\": \"^20.12.7\",\n \"@typescript-eslint/eslint-plugin\": \"^7.6.0\",\n \"eslint\": \"^8.57.0\",\n \"eslint-import-resolver-typescript\": \"^3.6.1\",\n \"eslint-plugin-github\": \"^4.10.2\",\n \"eslint-plugin-import\": \"^2.29.1\",\n \"eslint-plugin-prettier\": \"^5.1.3\",\n \"prettier\": \"^3.2.5\",\n \"tsup\": \"^8.0.2\",\n \"typedoc\": \"^0.25.13\",\n \"typescript\": \"^5.4.5\"\n }\n}\n","/*!\n * linux-release-info\n * Get Linux release info (distribution name, version, arch, release, etc.)\n * from '/etc/os-release' or '/usr/lib/os-release' files and from native os\n * module. On Windows and Darwin platforms it only returns common node os module\n * info (platform, hostname, release, and arch)\n *\n * Licensed under MIT\n * Copyright (c) 2018-2020 [Samuel Carreira]\n */\n// NOTE: we depend on this directly to get around some un-fun issues with mixing CommonJS\n// and ESM in the bundle.\nimport * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport { promisify } from \"node:util\";\n\nconst readFileAsync = promisify(fs.readFile);\n\nexport interface LinuxReleaseInfoOptions {\n /**\n * read mode, possible values: 'async' and 'sync'\n *\n * @default 'async'\n */\n mode?: \"async\" | \"sync\";\n /**\n * custom complete file path with os info default null/none\n * if not provided the system will search on the '/etc/os-release'\n * and '/usr/lib/os-release' files\n *\n * @default null\n */\n customFile?: string | null | undefined;\n /**\n * if true, show console debug messages\n *\n * @default false\n */\n debug?: boolean;\n}\n\nconst linuxReleaseInfoOptionsDefaults: LinuxReleaseInfoOptions = {\n mode: \"async\",\n customFile: null,\n debug: false,\n};\n\n/**\n * Get OS release info from 'os-release' file and from native os module\n * on Windows or Darwin it only returns common os module info\n * (uses native fs module)\n * @returns {object} info from the current os\n */\nexport function releaseInfo(infoOptions: LinuxReleaseInfoOptions): object {\n const options = { ...linuxReleaseInfoOptionsDefaults, ...infoOptions };\n\n const searchOsReleaseFileList: string[] = osReleaseFileList(\n options.customFile,\n );\n\n if (os.type() !== \"Linux\") {\n if (options.mode === \"sync\") {\n return getOsInfo();\n } else {\n return Promise.resolve(getOsInfo());\n }\n }\n\n if (options.mode === \"sync\") {\n return readSyncOsreleaseFile(searchOsReleaseFileList, options);\n } else {\n return Promise.resolve(\n readAsyncOsReleaseFile(searchOsReleaseFileList, options),\n );\n }\n}\n\n/**\n * Format file data: convert data to object keys/values\n *\n * @param {object} sourceData Source object to be appended\n * @param {string} srcParseData Input file data to be parsed\n * @returns {object} Formated object\n */\nfunction formatFileData(sourceData: OsInfo, srcParseData: string): OsInfo {\n const lines: string[] = srcParseData.split(\"\\n\");\n\n for (const line of lines) {\n const lineData = line.split(\"=\");\n\n if (lineData.length === 2) {\n lineData[1] = lineData[1].replace(/[\"'\\r]/gi, \"\"); // remove quotes and return character\n\n Object.defineProperty(sourceData, lineData[0].toLowerCase(), {\n value: lineData[1],\n writable: true,\n enumerable: true,\n configurable: true,\n });\n }\n }\n\n return sourceData;\n}\n\n/**\n * Export a list of os-release files\n *\n * @param {string} customFile optional custom complete filepath\n * @returns {array} list of os-release files\n */\nfunction osReleaseFileList(customFile: string | null | undefined): string[] {\n const DEFAULT_OS_RELEASE_FILES = [\"/etc/os-release\", \"/usr/lib/os-release\"];\n\n if (!customFile) {\n return DEFAULT_OS_RELEASE_FILES;\n } else {\n return Array(customFile);\n }\n}\n\n/**\n * Operating system info.\n */\ntype OsInfo = {\n type: string;\n platform: string;\n hostname: string;\n arch: string;\n release: string;\n};\n\n/**\n * Get OS Basic Info\n * (uses node 'os' native module)\n *\n * @returns {OsInfo} os basic info\n */\nfunction getOsInfo(): OsInfo {\n return {\n type: os.type(),\n platform: os.platform(),\n hostname: os.hostname(),\n arch: os.arch(),\n release: os.release(),\n };\n}\n\n/* Helper functions */\n\nasync function readAsyncOsReleaseFile(\n fileList: string[],\n options: LinuxReleaseInfoOptions,\n): Promise {\n let fileData = null;\n\n for (const osReleaseFile of fileList) {\n try {\n if (options.debug) {\n /* eslint-disable no-console */\n console.log(`Trying to read '${osReleaseFile}'...`);\n }\n\n fileData = await readFileAsync(osReleaseFile, \"binary\");\n\n if (options.debug) {\n console.log(`Read data:\\n${fileData}`);\n }\n\n break;\n } catch (error) {\n if (options.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n}\n\nfunction readSyncOsreleaseFile(\n releaseFileList: string[],\n options: LinuxReleaseInfoOptions,\n): OsInfo {\n let fileData = null;\n\n for (const osReleaseFile of releaseFileList) {\n try {\n if (options.debug) {\n console.log(`Trying to read '${osReleaseFile}'...`);\n }\n\n fileData = fs.readFileSync(osReleaseFile, \"binary\");\n\n if (options.debug) {\n console.log(`Read data:\\n${fileData}`);\n }\n\n break;\n } catch (error) {\n if (options.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n}\n","// MIT, mostly lifted from https://github.com/actions/toolkit/blob/5a736647a123ecf8582376bdaee833fbae5b3847/packages/core/src/platform.ts\n// since it isn't in @actions/core 1.10.1 which is their current release as 2024-04-19.\n// Changes: Replaced the lsb_release call in Linux with `linux-release-info` to parse the os-release file directly.\nimport { releaseInfo } from \"./linux-release-info.js\";\nimport * as core from \"@actions/core\";\nimport * as exec from \"@actions/exec\";\nimport os from \"os\";\n\n/**\n * The name and version of the Action runner's system.\n */\ntype SystemInfo = {\n name: string;\n version: string;\n};\n\n/**\n * Get the name and version of the current Windows system.\n */\nconst getWindowsInfo = async (): Promise => {\n const { stdout: version } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Version\"',\n undefined,\n {\n silent: true,\n },\n );\n\n const { stdout: name } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Caption\"',\n undefined,\n {\n silent: true,\n },\n );\n\n return {\n name: name.trim(),\n version: version.trim(),\n };\n};\n\n/**\n * Get the name and version of the current macOS system.\n */\nconst getMacOsInfo = async (): Promise => {\n const { stdout } = await exec.getExecOutput(\"sw_vers\", undefined, {\n silent: true,\n });\n\n const version = stdout.match(/ProductVersion:\\s*(.+)/)?.[1] ?? \"\";\n const name = stdout.match(/ProductName:\\s*(.+)/)?.[1] ?? \"\";\n\n return {\n name,\n version,\n };\n};\n\n/**\n * Get the name and version of the current Linux system.\n */\nconst getLinuxInfo = async (): Promise => {\n let data: object = {};\n\n try {\n data = releaseInfo({ mode: \"sync\" });\n // eslint-disable-next-line no-console\n console.log(data);\n } catch (e) {\n core.debug(`Error collecting release info: ${e}`);\n }\n\n return {\n name: getPropertyViaWithDefault(\n data,\n [\"id\", \"name\", \"pretty_name\", \"id_like\"],\n \"unknown\",\n ),\n version: getPropertyViaWithDefault(\n data,\n [\"version_id\", \"version\", \"version_codename\"],\n \"unknown\",\n ),\n };\n};\n\nfunction getPropertyViaWithDefault(\n data: object,\n names: Property[],\n defaultValue: T,\n): T {\n for (const name of names) {\n const ret: T = getPropertyWithDefault(data, name, defaultValue);\n\n if (ret !== defaultValue) {\n return ret;\n }\n }\n\n return defaultValue;\n}\n\nfunction getPropertyWithDefault(\n data: object,\n name: Property,\n defaultValue: T,\n): T {\n if (!data.hasOwnProperty(name)) {\n return defaultValue;\n }\n\n const value = (data as { [K in Property]: T })[name];\n\n // NB. this check won't work for object instances\n if (typeof value !== typeof defaultValue) {\n return defaultValue;\n }\n\n return value;\n}\n\n/**\n * The Action runner's platform.\n */\nexport const platform = os.platform();\n\n/**\n * The Action runner's architecture.\n */\nexport const arch = os.arch();\n\n/**\n * Whether the Action runner is a Windows system.\n */\nexport const isWindows = platform === \"win32\";\n\n/**\n * Whether the Action runner is a macOS system.\n */\nexport const isMacOS = platform === \"darwin\";\n\n/**\n * Whether the Action runner is a Linux system.\n */\nexport const isLinux = platform === \"linux\";\n\n/**\n * System-level information about the current host (platform, architecture, etc.).\n */\ntype SystemDetails = {\n name: string;\n platform: string;\n arch: string;\n version: string;\n isWindows: boolean;\n isMacOS: boolean;\n isLinux: boolean;\n};\n\n/**\n * Get system-level information about the current host (platform, architecture, etc.).\n */\nexport async function getDetails(): Promise {\n return {\n ...(await (isWindows\n ? getWindowsInfo()\n : isMacOS\n ? getMacOsInfo()\n : getLinuxInfo())),\n platform,\n arch,\n isWindows,\n isMacOS,\n isLinux,\n };\n}\n","import * as actionsCore from \"@actions/core\";\nimport { createHash } from \"node:crypto\";\n\nconst OPTIONAL_VARIABLES = [\"INVOCATION_ID\"];\n\n// JSON sent to server\n/* eslint-disable camelcase */\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 job: hashEnvironmentVariables(\"GHWJ\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n ]),\n run: hashEnvironmentVariables(\"GHWJR\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n ]),\n run_differentiator: hashEnvironmentVariables(\"GHWJA\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n \"GITHUB_RUN_NUMBER\",\n \"GITHUB_RUN_ATTEMPT\",\n \"INVOCATION_ID\",\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 let value = process.env[varName];\n\n if (value === undefined) {\n if (OPTIONAL_VARIABLES.includes(varName)) {\n actionsCore.debug(\n `Optional environment variable not set: ${varName} -- substituting with the variable name`,\n );\n value = varName;\n } else {\n actionsCore.debug(\n `Environment variable not set: ${varName} -- can't generate the requested identity`,\n );\n return undefined;\n }\n }\n\n hash.update(value);\n hash.update(\"\\0\");\n }\n\n return `${prefix}-${hash.digest(\"hex\")}`;\n}\n","/**\n * @packageDocumentation\n * Helpers for determining system attributes of the current runner.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get the current architecture plus OS. Examples include `X64-Linux` and `ARM64-macOS`.\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\n/**\n * Get the current Nix system. Examples include `x86_64-linux` and `aarch64-darwin`.\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","/**\n * @packageDocumentation\n * Helpers for getting values from an Action's configuration.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get a Boolean input from the Action's configuration by name.\n */\nconst getBool = (name: string): boolean => {\n return actionsCore.getBooleanInput(name);\n};\n\n/**\n * Get a multi-line string input from the Action's configuration by name or return `null` if not set.\n */\nconst getMultilineStringOrNull = (name: string): string[] | null => {\n const value = actionsCore.getMultilineInput(name);\n if (value.length === 0) {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a number input from the Action's configuration by name or return `null` if not set.\n */\nconst getNumberOrNull = (name: string): number | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return Number(value);\n }\n};\n\n/**\n * Get a string input from the Action's configuration.\n */\nconst getString = (name: string): string => {\n return actionsCore.getInput(name);\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `null` if not set.\n */\nconst getStringOrNull = (name: string): string | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `undefined` if not set.\n */\nconst getStringOrUndefined = (name: string): string | undefined => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return undefined;\n } else {\n return value;\n }\n};\n\nexport {\n getBool,\n getMultilineStringOrNull,\n getNumberOrNull,\n getString,\n getStringOrNull,\n getStringOrUndefined,\n};\n","import { getStringOrUndefined } from \"./inputs.js\";\nimport * 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 = getStringOrUndefined(`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 = getStringOrUndefined(`${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","/**\n * @packageDocumentation\n * Determinate Systems' TypeScript library for creating GitHub Actions logic.\n */\nimport { version as pkgVersion } from \"../package.json\";\nimport * as ghActionsCorePlatform from \"./actions-core-platform.js\";\nimport * as correlation from \"./correlation.js\";\nimport * as platform from \"./platform.js\";\nimport { SourceDef, constructSourceParameters } from \"./sourcedef.js\";\nimport * as actionsCache from \"@actions/cache\";\nimport * as actionsCore from \"@actions/core\";\nimport got, { Got } from \"got\";\nimport { UUID, randomUUID } from \"node:crypto\";\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\";\n\nconst DEFAULT_IDS_HOST = \"https://install.determinate.systems\";\nconst IDS_HOST = process.env[\"IDS_HOST\"] ?? DEFAULT_IDS_HOST;\n\nconst EVENT_EXCEPTION = \"exception\";\nconst EVENT_ARTIFACT_CACHE_HIT = \"artifact_cache_hit\";\nconst EVENT_ARTIFACT_CACHE_MISS = \"artifact_cache_miss\";\n\nconst FACT_ENDED_WITH_EXCEPTION = \"ended_with_exception\";\nconst FACT_FINAL_EXCEPTION = \"final_exception\";\n\nexport type FetchSuffixStyle = \"nix-style\" | \"gh-env-style\" | \"universal\";\nexport type ExecutionPhase = \"main\" | \"post\";\nexport type NixRequirementHandling = \"fail\" | \"warn\" | \"ignore\";\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 // Check if Nix is installed before running this action.\n // If Nix isn't installed, this action will not fail, and will instead do nothing.\n // The action will emit a user-visible warning instructing them to install Nix.\n requireNix: NixRequirementHandling;\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 requireNix: NixRequirementHandling;\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 uuid: UUID;\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 private hookMain?: () => Promise;\n private hookPost?: () => Promise;\n\n constructor(actionOptions: ActionOptions) {\n this.actionOptions = makeOptionsConfident(actionOptions);\n this.hookMain = undefined;\n this.hookPost = undefined;\n\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 // JSON sent to server\n /* eslint-disable camelcase */\n this.facts = {\n $lib: \"idslib\",\n $lib_version: pkgVersion,\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 ghActionsCorePlatform\n .getDetails()\n // eslint-disable-next-line github/no-then\n .then((details) => {\n if (details.name !== \"unknown\") {\n this.addFact(\"$os\", details.name);\n }\n if (details.version !== \"unknown\") {\n this.addFact(\"$os_version\", details.version);\n }\n })\n // eslint-disable-next-line github/no-then\n .catch((e) => {\n actionsCore.debug(`Failure getting platform details: ${e}`);\n });\n }\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 onMain(callback: () => Promise): void {\n this.hookMain = callback;\n }\n\n onPost(callback: () => Promise): void {\n this.hookPost = callback;\n }\n\n execute(): void {\n // eslint-disable-next-line github/no-then\n this.executeAsync().catch((error: Error) => {\n // eslint-disable-next-line no-console\n console.log(error);\n process.exitCode = 1;\n });\n }\n\n private async executeAsync(): Promise {\n try {\n process.env.DETSYS_CORRELATION = JSON.stringify(\n this.getCorrelationHashes(),\n );\n\n if (!(await this.preflightRequireNix())) {\n this.recordEvent(\"preflight-require-nix-denied\");\n return;\n }\n\n if (this.executionPhase === \"main\" && this.hookMain) {\n await this.hookMain();\n } else if (this.executionPhase === \"post\" && this.hookPost) {\n await this.hookPost();\n }\n this.addFact(FACT_ENDED_WITH_EXCEPTION, false);\n } catch (error) {\n this.addFact(FACT_ENDED_WITH_EXCEPTION, true);\n\n const reportable =\n error instanceof Error || typeof error == \"string\"\n ? error.toString()\n : JSON.stringify(error);\n\n this.addFact(FACT_FINAL_EXCEPTION, reportable);\n\n if (this.executionPhase === \"post\") {\n actionsCore.warning(reportable);\n } else {\n actionsCore.setFailed(reportable);\n }\n\n this.recordEvent(EVENT_EXCEPTION);\n } finally {\n await this.complete();\n }\n }\n\n addFact(key: string, value: string | boolean): void {\n this.facts[key] = value;\n }\n\n getDiagnosticsUrl(): URL | undefined {\n return this.actionOptions.diagnosticsUrl;\n }\n\n getUniqueId(): string {\n return (\n this.identity.run_differentiator ||\n process.env.RUNNER_TRACKING_ID ||\n randomUUID()\n );\n }\n\n getCorrelationHashes(): correlation.AnonymizedCorrelationHashes {\n return this.identity;\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 uuid: randomUUID(),\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 this.client.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 = this.client.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 private 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(EVENT_ARTIFACT_CACHE_HIT);\n return `${tempDir}/${this.actionOptions.name}`;\n }\n\n this.recordEvent(EVENT_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(EVENT_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 preflightRequireNix(): Promise {\n let nixLocation: string | undefined;\n\n const pathParts = (process.env[\"PATH\"] || \"\").split(\":\");\n for (const location of pathParts) {\n const candidateNix = path.join(location, \"nix\");\n\n try {\n await fs.access(candidateNix, fs.constants.X_OK);\n actionsCore.debug(`Found Nix at ${candidateNix}`);\n nixLocation = candidateNix;\n } catch {\n actionsCore.debug(`Nix not at ${candidateNix}`);\n }\n }\n this.addFact(\"nix_location\", nixLocation || \"\");\n\n if (this.actionOptions.requireNix === \"ignore\") {\n return true;\n }\n\n const currentNotFoundState = actionsCore.getState(\n \"idstoolbox_nix_not_found\",\n );\n if (currentNotFoundState === \"not-found\") {\n // It was previously not found, so don't run subsequent actions\n return false;\n }\n\n if (nixLocation !== undefined) {\n return true;\n }\n actionsCore.saveState(\"idstoolbox_nix_not_found\", \"not-found\");\n\n switch (this.actionOptions.requireNix) {\n case \"fail\":\n actionsCore.setFailed(\n \"This action can only be used when Nix is installed.\" +\n \" Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n );\n break;\n case \"warn\":\n actionsCore.warning(\n \"This action is in no-op mode because Nix is not installed.\" +\n \" Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n );\n break;\n }\n\n return false;\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 this.client.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}-${randomUUID()}`);\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 requireNix: actionOptions.requireNix,\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\n// Public exports from other files\nexport * as inputs from \"./inputs.js\";\nexport * as platform from \"./platform.js\";\n"],"mappings":";;;;;;;AAEE,cAAW;;;ACUb,YAAY,QAAQ;AACpB,YAAY,QAAQ;AACpB,SAAS,iBAAiB;AAE1B,IAAM,gBAAgB,UAAa,WAAQ;AAyB3C,IAAM,kCAA2D;AAAA,EAC/D,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,OAAO;AACT;AAQO,SAAS,YAAY,aAA8C;AACxE,QAAM,UAAU,EAAE,GAAG,iCAAiC,GAAG,YAAY;AAErE,QAAM,0BAAoC;AAAA,IACxC,QAAQ;AAAA,EACV;AAEA,MAAO,QAAK,MAAM,SAAS;AACzB,QAAI,QAAQ,SAAS,QAAQ;AAC3B,aAAO,UAAU;AAAA,IACnB,OAAO;AACL,aAAO,QAAQ,QAAQ,UAAU,CAAC;AAAA,IACpC;AAAA,EACF;AAEA,MAAI,QAAQ,SAAS,Q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C9D;AAAA,EACF;AAEA,SAAO;AACT;AAEA,SAAS,wBAAwB,UAAoB;AACnD,MAAI,qBAAqB,UAAU;AACjC,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,iBAAiB,IAAI,IAAI,gBAAgB;AAC/C,UAAM,iBAAiB,IAAI,IAAI,QAAQ;AAEvC,QAAI,SAAS,WAAW,eAAe,QAAQ;AAC7C,aAAO;AAAA,IACT;AAEA,aAAS,WAAW,eAAe;AACnC,aAAS,OAAO,eAAe;AAC/B,aAAS,WAAW,eAAe;AACnC,aAAS,WAAW,eAAe;AAEnC,WAAO;AAAA,EACT,SAAS,GAAG;AACV,IAAY,kBAAK,qDAAqD,CAAC,EAAE;AAAA,EAC3E;AAEA,SAAO;AACT;","names":["error","os","version","platform","arch","actionsCore","actionsCore","actionsCore","actionsCore","fs","error","version"]} \ No newline at end of file +{"version":3,"sources":["../package.json","../src/linux-release-info.ts","../src/actions-core-platform.ts","../src/correlation.ts","../src/platform.ts","../src/inputs.ts","../src/sourcedef.ts","../src/index.ts"],"sourcesContent":["{\n \"name\": \"detsys-ts\",\n \"version\": \"1.0.0\",\n \"description\": \"TypeScript goodies for DetSys projects\",\n \"main\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"type\": \"module\",\n \"scripts\": {\n \"build\": \"tsup\",\n \"check-fmt\": \"prettier --check .\",\n \"format\": \"prettier --write .\",\n \"lint\": \"eslint src/**/*.ts\",\n \"docs\": \"typedoc src/index.ts\",\n \"all\": \"rm -rf dist && 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\": \"MIT\",\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.1\",\n \"@actions/exec\": \"^1.1.1\",\n \"got\": \"^14.2.1\"\n },\n \"devDependencies\": {\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/node\": \"^20.12.7\",\n \"@typescript-eslint/eslint-plugin\": \"^7.6.0\",\n \"eslint\": \"^8.57.0\",\n \"eslint-import-resolver-typescript\": \"^3.6.1\",\n \"eslint-plugin-github\": \"^4.10.2\",\n \"eslint-plugin-import\": \"^2.29.1\",\n \"eslint-plugin-prettier\": \"^5.1.3\",\n \"prettier\": \"^3.2.5\",\n \"tsup\": \"^8.0.2\",\n \"typedoc\": \"^0.25.13\",\n \"typescript\": \"^5.4.5\"\n }\n}\n","/*!\n * linux-release-info\n * Get Linux release info (distribution name, version, arch, release, etc.)\n * from '/etc/os-release' or '/usr/lib/os-release' files and from native os\n * module. On Windows and Darwin platforms it only returns common node os module\n * info (platform, hostname, release, and arch)\n *\n * Licensed under MIT\n * Copyright (c) 2018-2020 [Samuel Carreira]\n */\n// NOTE: we depend on this directly to get around some un-fun issues with mixing CommonJS\n// and ESM in the bundle. We've modified the original logic to improve things like typing\n// and fixing ESLint issues. Originally drawn from:\n// https://github.com/samuelcarreira/linux-release-info/blob/84a91aa5442b47900da03020c590507545d3dc74/src/index.ts\nimport * as fs from \"node:fs\";\nimport * as os from \"node:os\";\nimport { promisify } from \"node:util\";\n\nconst readFileAsync = promisify(fs.readFile);\n\nexport interface LinuxReleaseInfoOptions {\n /**\n * read mode, possible values: 'async' and 'sync'\n *\n * @default 'async'\n */\n mode?: \"async\" | \"sync\";\n /**\n * custom complete file path with os info default null/none\n * if not provided the system will search on the '/etc/os-release'\n * and '/usr/lib/os-release' files\n *\n * @default null\n */\n customFile?: string | null | undefined;\n /**\n * if true, show console debug messages\n *\n * @default false\n */\n debug?: boolean;\n}\n\nconst linuxReleaseInfoOptionsDefaults: LinuxReleaseInfoOptions = {\n mode: \"async\",\n customFile: null,\n debug: false,\n};\n\n/**\n * Get OS release info from 'os-release' file and from native os module\n * on Windows or Darwin it only returns common os module info\n * (uses native fs module)\n * @returns {object} info from the current os\n */\nexport function releaseInfo(infoOptions: LinuxReleaseInfoOptions): object {\n const options = { ...linuxReleaseInfoOptionsDefaults, ...infoOptions };\n\n const searchOsReleaseFileList: string[] = osReleaseFileList(\n options.customFile,\n );\n\n if (os.type() !== \"Linux\") {\n if (options.mode === \"sync\") {\n return getOsInfo();\n } else {\n return Promise.resolve(getOsInfo());\n }\n }\n\n if (options.mode === \"sync\") {\n return readSyncOsreleaseFile(searchOsReleaseFileList, options);\n } else {\n return Promise.resolve(\n readAsyncOsReleaseFile(searchOsReleaseFileList, options),\n );\n }\n}\n\n/**\n * Format file data: convert data to object keys/values\n *\n * @param {object} sourceData Source object to be appended\n * @param {string} srcParseData Input file data to be parsed\n * @returns {object} Formated object\n */\nfunction formatFileData(sourceData: OsInfo, srcParseData: string): OsInfo {\n const lines: string[] = srcParseData.split(\"\\n\");\n\n for (const line of lines) {\n const lineData = line.split(\"=\");\n\n if (lineData.length === 2) {\n lineData[1] = lineData[1].replace(/[\"'\\r]/gi, \"\"); // remove quotes and return character\n\n Object.defineProperty(sourceData, lineData[0].toLowerCase(), {\n value: lineData[1],\n writable: true,\n enumerable: true,\n configurable: true,\n });\n }\n }\n\n return sourceData;\n}\n\n/**\n * Export a list of os-release files\n *\n * @param {string} customFile optional custom complete filepath\n * @returns {array} list of os-release files\n */\nfunction osReleaseFileList(customFile: string | null | undefined): string[] {\n const DEFAULT_OS_RELEASE_FILES = [\"/etc/os-release\", \"/usr/lib/os-release\"];\n\n if (!customFile) {\n return DEFAULT_OS_RELEASE_FILES;\n } else {\n return Array(customFile);\n }\n}\n\n/**\n * Operating system info.\n */\ntype OsInfo = {\n type: string;\n platform: string;\n hostname: string;\n arch: string;\n release: string;\n};\n\n/**\n * Get OS Basic Info\n * (uses node 'os' native module)\n *\n * @returns {OsInfo} os basic info\n */\nfunction getOsInfo(): OsInfo {\n return {\n type: os.type(),\n platform: os.platform(),\n hostname: os.hostname(),\n arch: os.arch(),\n release: os.release(),\n };\n}\n\n/* Helper functions */\n\nasync function readAsyncOsReleaseFile(\n fileList: string[],\n options: LinuxReleaseInfoOptions,\n): Promise {\n let fileData = null;\n\n for (const osReleaseFile of fileList) {\n try {\n if (options.debug) {\n /* eslint-disable no-console */\n console.log(`Trying to read '${osReleaseFile}'...`);\n }\n\n fileData = await readFileAsync(osReleaseFile, \"binary\");\n\n if (options.debug) {\n console.log(`Read data:\\n${fileData}`);\n }\n\n break;\n } catch (error) {\n if (options.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n}\n\nfunction readSyncOsreleaseFile(\n releaseFileList: string[],\n options: LinuxReleaseInfoOptions,\n): OsInfo {\n let fileData = null;\n\n for (const osReleaseFile of releaseFileList) {\n try {\n if (options.debug) {\n console.log(`Trying to read '${osReleaseFile}'...`);\n }\n\n fileData = fs.readFileSync(osReleaseFile, \"binary\");\n\n if (options.debug) {\n console.log(`Read data:\\n${fileData}`);\n }\n\n break;\n } catch (error) {\n if (options.debug) {\n console.error(error);\n }\n }\n }\n\n if (fileData === null) {\n throw new Error(\"Cannot read os-release file!\");\n //return getOsInfo();\n }\n\n return formatFileData(getOsInfo(), fileData);\n}\n","// MIT, mostly lifted from https://github.com/actions/toolkit/blob/5a736647a123ecf8582376bdaee833fbae5b3847/packages/core/src/platform.ts\n// since it isn't in @actions/core 1.10.1 which is their current release as 2024-04-19.\n// Changes: Replaced the lsb_release call in Linux with `linux-release-info` to parse the os-release file directly.\nimport { releaseInfo } from \"./linux-release-info.js\";\nimport * as core from \"@actions/core\";\nimport * as exec from \"@actions/exec\";\nimport os from \"os\";\n\n/**\n * The name and version of the Action runner's system.\n */\ntype SystemInfo = {\n name: string;\n version: string;\n};\n\n/**\n * Get the name and version of the current Windows system.\n */\nconst getWindowsInfo = async (): Promise => {\n const { stdout: version } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Version\"',\n undefined,\n {\n silent: true,\n },\n );\n\n const { stdout: name } = await exec.getExecOutput(\n 'powershell -command \"(Get-CimInstance -ClassName Win32_OperatingSystem).Caption\"',\n undefined,\n {\n silent: true,\n },\n );\n\n return {\n name: name.trim(),\n version: version.trim(),\n };\n};\n\n/**\n * Get the name and version of the current macOS system.\n */\nconst getMacOsInfo = async (): Promise => {\n const { stdout } = await exec.getExecOutput(\"sw_vers\", undefined, {\n silent: true,\n });\n\n const version = stdout.match(/ProductVersion:\\s*(.+)/)?.[1] ?? \"\";\n const name = stdout.match(/ProductName:\\s*(.+)/)?.[1] ?? \"\";\n\n return {\n name,\n version,\n };\n};\n\n/**\n * Get the name and version of the current Linux system.\n */\nconst getLinuxInfo = async (): Promise => {\n let data: object = {};\n\n try {\n data = releaseInfo({ mode: \"sync\" });\n // eslint-disable-next-line no-console\n console.log(data);\n } catch (e) {\n core.debug(`Error collecting release info: ${e}`);\n }\n\n return {\n name: getPropertyViaWithDefault(\n data,\n [\"id\", \"name\", \"pretty_name\", \"id_like\"],\n \"unknown\",\n ),\n version: getPropertyViaWithDefault(\n data,\n [\"version_id\", \"version\", \"version_codename\"],\n \"unknown\",\n ),\n };\n};\n\nfunction getPropertyViaWithDefault(\n data: object,\n names: Property[],\n defaultValue: T,\n): T {\n for (const name of names) {\n const ret: T = getPropertyWithDefault(data, name, defaultValue);\n\n if (ret !== defaultValue) {\n return ret;\n }\n }\n\n return defaultValue;\n}\n\nfunction getPropertyWithDefault(\n data: object,\n name: Property,\n defaultValue: T,\n): T {\n if (!data.hasOwnProperty(name)) {\n return defaultValue;\n }\n\n const value = (data as { [K in Property]: T })[name];\n\n // NB. this check won't work for object instances\n if (typeof value !== typeof defaultValue) {\n return defaultValue;\n }\n\n return value;\n}\n\n/**\n * The Action runner's platform.\n */\nexport const platform = os.platform();\n\n/**\n * The Action runner's architecture.\n */\nexport const arch = os.arch();\n\n/**\n * Whether the Action runner is a Windows system.\n */\nexport const isWindows = platform === \"win32\";\n\n/**\n * Whether the Action runner is a macOS system.\n */\nexport const isMacOS = platform === \"darwin\";\n\n/**\n * Whether the Action runner is a Linux system.\n */\nexport const isLinux = platform === \"linux\";\n\n/**\n * System-level information about the current host (platform, architecture, etc.).\n */\ntype SystemDetails = {\n name: string;\n platform: string;\n arch: string;\n version: string;\n isWindows: boolean;\n isMacOS: boolean;\n isLinux: boolean;\n};\n\n/**\n * Get system-level information about the current host (platform, architecture, etc.).\n */\nexport async function getDetails(): Promise {\n return {\n ...(await (isWindows\n ? getWindowsInfo()\n : isMacOS\n ? getMacOsInfo()\n : getLinuxInfo())),\n platform,\n arch,\n isWindows,\n isMacOS,\n isLinux,\n };\n}\n","import * as actionsCore from \"@actions/core\";\nimport { createHash } from \"node:crypto\";\n\nconst OPTIONAL_VARIABLES = [\"INVOCATION_ID\"];\n\n// JSON sent to server\n/* eslint-disable camelcase */\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 job: hashEnvironmentVariables(\"GHWJ\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n ]),\n run: hashEnvironmentVariables(\"GHWJR\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n ]),\n run_differentiator: hashEnvironmentVariables(\"GHWJA\", [\n \"GITHUB_SERVER_URL\",\n \"GITHUB_REPOSITORY_OWNER\",\n \"GITHUB_REPOSITORY_OWNER_ID\",\n \"GITHUB_REPOSITORY\",\n \"GITHUB_REPOSITORY_ID\",\n \"GITHUB_WORKFLOW\",\n \"GITHUB_JOB\",\n \"GITHUB_RUN_ID\",\n \"GITHUB_RUN_NUMBER\",\n \"GITHUB_RUN_ATTEMPT\",\n \"INVOCATION_ID\",\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 let value = process.env[varName];\n\n if (value === undefined) {\n if (OPTIONAL_VARIABLES.includes(varName)) {\n actionsCore.debug(\n `Optional environment variable not set: ${varName} -- substituting with the variable name`,\n );\n value = varName;\n } else {\n actionsCore.debug(\n `Environment variable not set: ${varName} -- can't generate the requested identity`,\n );\n return undefined;\n }\n }\n\n hash.update(value);\n hash.update(\"\\0\");\n }\n\n return `${prefix}-${hash.digest(\"hex\")}`;\n}\n","/**\n * @packageDocumentation\n * Helpers for determining system attributes of the current runner.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get the current architecture plus OS. Examples include `X64-Linux` and `ARM64-macOS`.\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\n/**\n * Get the current Nix system. Examples include `x86_64-linux` and `aarch64-darwin`.\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","/**\n * @packageDocumentation\n * Helpers for getting values from an Action's configuration.\n */\nimport * as actionsCore from \"@actions/core\";\n\n/**\n * Get a Boolean input from the Action's configuration by name.\n */\nconst getBool = (name: string): boolean => {\n return actionsCore.getBooleanInput(name);\n};\n\n/**\n * Get a multi-line string input from the Action's configuration by name or return `null` if not set.\n */\nconst getMultilineStringOrNull = (name: string): string[] | null => {\n const value = actionsCore.getMultilineInput(name);\n if (value.length === 0) {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a number input from the Action's configuration by name or return `null` if not set.\n */\nconst getNumberOrNull = (name: string): number | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return Number(value);\n }\n};\n\n/**\n * Get a string input from the Action's configuration.\n */\nconst getString = (name: string): string => {\n return actionsCore.getInput(name);\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `null` if not set.\n */\nconst getStringOrNull = (name: string): string | null => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return null;\n } else {\n return value;\n }\n};\n\n/**\n * Get a string input from the Action's configuration by name or return `undefined` if not set.\n */\nconst getStringOrUndefined = (name: string): string | undefined => {\n const value = actionsCore.getInput(name);\n if (value === \"\") {\n return undefined;\n } else {\n return value;\n }\n};\n\nexport {\n getBool,\n getMultilineStringOrNull,\n getNumberOrNull,\n getString,\n getStringOrNull,\n getStringOrUndefined,\n};\n","import { getStringOrUndefined } from \"./inputs.js\";\nimport * 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 = getStringOrUndefined(`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 = getStringOrUndefined(`${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","/**\n * @packageDocumentation\n * Determinate Systems' TypeScript library for creating GitHub Actions logic.\n */\nimport { version as pkgVersion } from \"../package.json\";\nimport * as ghActionsCorePlatform from \"./actions-core-platform.js\";\nimport * as correlation from \"./correlation.js\";\nimport * as platform from \"./platform.js\";\nimport { SourceDef, constructSourceParameters } from \"./sourcedef.js\";\nimport * as actionsCache from \"@actions/cache\";\nimport * as actionsCore from \"@actions/core\";\nimport got, { Got } from \"got\";\nimport { UUID, randomUUID } from \"node:crypto\";\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\";\n\nconst DEFAULT_IDS_HOST = \"https://install.determinate.systems\";\nconst IDS_HOST = process.env[\"IDS_HOST\"] ?? DEFAULT_IDS_HOST;\n\nconst EVENT_EXCEPTION = \"exception\";\nconst EVENT_ARTIFACT_CACHE_HIT = \"artifact_cache_hit\";\nconst EVENT_ARTIFACT_CACHE_MISS = \"artifact_cache_miss\";\n\nconst FACT_ENDED_WITH_EXCEPTION = \"ended_with_exception\";\nconst FACT_FINAL_EXCEPTION = \"final_exception\";\n\nexport type FetchSuffixStyle = \"nix-style\" | \"gh-env-style\" | \"universal\";\nexport type ExecutionPhase = \"main\" | \"post\";\nexport type NixRequirementHandling = \"fail\" | \"warn\" | \"ignore\";\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 // Check if Nix is installed before running this action.\n // If Nix isn't installed, this action will not fail, and will instead do nothing.\n // The action will emit a user-visible warning instructing them to install Nix.\n requireNix: NixRequirementHandling;\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 requireNix: NixRequirementHandling;\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 uuid: UUID;\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 private hookMain?: () => Promise;\n private hookPost?: () => Promise;\n\n constructor(actionOptions: ActionOptions) {\n this.actionOptions = makeOptionsConfident(actionOptions);\n this.hookMain = undefined;\n this.hookPost = undefined;\n\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 // JSON sent to server\n /* eslint-disable camelcase */\n this.facts = {\n $lib: \"idslib\",\n $lib_version: pkgVersion,\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 ghActionsCorePlatform\n .getDetails()\n // eslint-disable-next-line github/no-then\n .then((details) => {\n if (details.name !== \"unknown\") {\n this.addFact(\"$os\", details.name);\n }\n if (details.version !== \"unknown\") {\n this.addFact(\"$os_version\", details.version);\n }\n })\n // eslint-disable-next-line github/no-then\n .catch((e) => {\n actionsCore.debug(`Failure getting platform details: ${e}`);\n });\n }\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 onMain(callback: () => Promise): void {\n this.hookMain = callback;\n }\n\n onPost(callback: () => Promise): void {\n this.hookPost = callback;\n }\n\n execute(): void {\n // eslint-disable-next-line github/no-then\n this.executeAsync().catch((error: Error) => {\n // eslint-disable-next-line no-console\n console.log(error);\n process.exitCode = 1;\n });\n }\n\n private async executeAsync(): Promise {\n try {\n process.env.DETSYS_CORRELATION = JSON.stringify(\n this.getCorrelationHashes(),\n );\n\n if (!(await this.preflightRequireNix())) {\n this.recordEvent(\"preflight-require-nix-denied\");\n return;\n }\n\n if (this.executionPhase === \"main\" && this.hookMain) {\n await this.hookMain();\n } else if (this.executionPhase === \"post\" && this.hookPost) {\n await this.hookPost();\n }\n this.addFact(FACT_ENDED_WITH_EXCEPTION, false);\n } catch (error) {\n this.addFact(FACT_ENDED_WITH_EXCEPTION, true);\n\n const reportable =\n error instanceof Error || typeof error == \"string\"\n ? error.toString()\n : JSON.stringify(error);\n\n this.addFact(FACT_FINAL_EXCEPTION, reportable);\n\n if (this.executionPhase === \"post\") {\n actionsCore.warning(reportable);\n } else {\n actionsCore.setFailed(reportable);\n }\n\n this.recordEvent(EVENT_EXCEPTION);\n } finally {\n await this.complete();\n }\n }\n\n addFact(key: string, value: string | boolean): void {\n this.facts[key] = value;\n }\n\n getDiagnosticsUrl(): URL | undefined {\n return this.actionOptions.diagnosticsUrl;\n }\n\n getUniqueId(): string {\n return (\n this.identity.run_differentiator ||\n process.env.RUNNER_TRACKING_ID ||\n randomUUID()\n );\n }\n\n getCorrelationHashes(): correlation.AnonymizedCorrelationHashes {\n return this.identity;\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 uuid: randomUUID(),\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 this.client.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 = this.client.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 private 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(EVENT_ARTIFACT_CACHE_HIT);\n return `${tempDir}/${this.actionOptions.name}`;\n }\n\n this.recordEvent(EVENT_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(EVENT_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 preflightRequireNix(): Promise {\n let nixLocation: string | undefined;\n\n const pathParts = (process.env[\"PATH\"] || \"\").split(\":\");\n for (const location of pathParts) {\n const candidateNix = path.join(location, \"nix\");\n\n try {\n await fs.access(candidateNix, fs.constants.X_OK);\n actionsCore.debug(`Found Nix at ${candidateNix}`);\n nixLocation = candidateNix;\n } catch {\n actionsCore.debug(`Nix not at ${candidateNix}`);\n }\n }\n this.addFact(\"nix_location\", nixLocation || \"\");\n\n if (this.actionOptions.requireNix === \"ignore\") {\n return true;\n }\n\n const currentNotFoundState = actionsCore.getState(\n \"idstoolbox_nix_not_found\",\n );\n if (currentNotFoundState === \"not-found\") {\n // It was previously not found, so don't run subsequent actions\n return false;\n }\n\n if (nixLocation !== undefined) {\n return true;\n }\n actionsCore.saveState(\"idstoolbox_nix_not_found\", \"not-found\");\n\n switch (this.actionOptions.requireNix) {\n case \"fail\":\n actionsCore.setFailed(\n \"This action can only be used when Nix is installed.\" +\n \" Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n );\n break;\n case \"warn\":\n actionsCore.warning(\n \"This action is in no-op mode because Nix is not installed.\" +\n \" Add `- uses: DeterminateSystems/nix-installer-action@main` earlier in your workflow.\",\n );\n break;\n }\n\n return false;\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 this.client.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}-${randomUUID()}`);\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 requireNix: actionOptions.requireNix,\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;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AAEA,SAAS,wBACP,gBACA,WACiB;AACjB,MAAI,cAAc,MAAM;AAEtB,WAAO;AAAA,EACT;AAEA,MAAI,cAAc,QAAW;AAE3B,WAAO;AAAA,EACT;AAEA;AAKE,UAAM,6BAA6B,QAAQ,IAAI,2BAA2B;AAC1E,QAAI,+BAA+B,IAAI;AAErC,aAAO;AAAA,IACT;AAEA,QAAI,+BAA+B,QAAW;AAC5C,UAAI;AACF,eAAO,wBAAwB,IAAI,IAAI,0BAA0B,CAAC;AAAA,MACpE,SAAS,GAAG;AACV,QAAY;AAAA,UACV,+DAA+D,CAAC;AAAA,QAClE;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,MAAI;AACF,UAAM,gBAAgB,IAAI,IAAI,QAAQ;AACtC,kBAAc,YAAY;AAC1B,kBAAc,YAAY;AAC1B,WAAO;AAAA,EACT,SAAS,GAAG;AACV,IAAY;AAAA,MACV,2DAA2D,CAAC;AAAA,IAC9D;AAAA,EACF;AAEA,SAAO;AACT;AAEA,SAAS,wBAAwB,UAAoB;AACnD,MAAI,qBAAqB,UAAU;AACjC,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,iBAAiB,IAAI,IAAI,gBAAgB;AAC/C,UAAM,iBAAiB,IAAI,IAAI,QAAQ;AAEvC,QAAI,SAAS,WAAW,eAAe,QAAQ;AAC7C,aAAO;AAAA,IACT;AAEA,aAAS,WAAW,eAAe;AACnC,aAAS,OAAO,eAAe;AAC/B,aAAS,WAAW,eAAe;AACnC,aAAS,WAAW,eAAe;AAEnC,WAAO;AAAA,EACT,SAAS,GAAG;AACV,IAAY,kBAAK,qDAAqD,CAAC,EAAE;AAAA,EAC3E;AAEA,SAAO;AACT;","names":["error","os","version","platform","arch","actionsCore","actionsCore","actionsCore","actionsCore","fs","error","version"]} \ No newline at end of file