mirror of
https://github.com/DeterminateSystems/magic-nix-cache-action.git
synced 2024-12-27 01:30:35 +01:00
test platform
This commit is contained in:
parent
a1129905cc
commit
08791372c3
5 changed files with 278 additions and 0 deletions
107
dist/index.js
generated
vendored
107
dist/index.js
generated
vendored
|
@ -87434,6 +87434,34 @@ module.exports = JSON.parse('[[[0,44],"disallowed_STD3_valid"],[[45,46],"valid"]
|
||||||
/******/ }
|
/******/ }
|
||||||
/******/
|
/******/
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
/******/ /* webpack/runtime/define property getters */
|
||||||
|
/******/ (() => {
|
||||||
|
/******/ // define getter functions for harmony exports
|
||||||
|
/******/ __nccwpck_require__.d = (exports, definition) => {
|
||||||
|
/******/ for(var key in definition) {
|
||||||
|
/******/ if(__nccwpck_require__.o(definition, key) && !__nccwpck_require__.o(exports, key)) {
|
||||||
|
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
||||||
|
/******/ }
|
||||||
|
/******/ }
|
||||||
|
/******/ };
|
||||||
|
/******/ })();
|
||||||
|
/******/
|
||||||
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
||||||
|
/******/ (() => {
|
||||||
|
/******/ __nccwpck_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||||
|
/******/ })();
|
||||||
|
/******/
|
||||||
|
/******/ /* webpack/runtime/make namespace object */
|
||||||
|
/******/ (() => {
|
||||||
|
/******/ // define __esModule on exports
|
||||||
|
/******/ __nccwpck_require__.r = (exports) => {
|
||||||
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||||
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||||
|
/******/ }
|
||||||
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||||
|
/******/ };
|
||||||
|
/******/ })();
|
||||||
|
/******/
|
||||||
/******/ /* webpack/runtime/compat */
|
/******/ /* webpack/runtime/compat */
|
||||||
/******/
|
/******/
|
||||||
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = new URL('.', import.meta.url).pathname.slice(import.meta.url.match(/^file:\/\/\/\w:/) ? 1 : 0, -1) + "/";
|
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = new URL('.', import.meta.url).pathname.slice(import.meta.url.match(/^file:\/\/\/\w:/) ? 1 : 0, -1) + "/";
|
||||||
|
@ -87443,6 +87471,18 @@ var __webpack_exports__ = {};
|
||||||
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
||||||
(() => {
|
(() => {
|
||||||
|
|
||||||
|
// NAMESPACE OBJECT: ./dist/platform.js
|
||||||
|
var dist_platform_namespaceObject = {};
|
||||||
|
__nccwpck_require__.r(dist_platform_namespaceObject);
|
||||||
|
__nccwpck_require__.d(dist_platform_namespaceObject, {
|
||||||
|
"arch": () => (arch),
|
||||||
|
"getDetails": () => (getDetails),
|
||||||
|
"isLinux": () => (isLinux),
|
||||||
|
"isMacOS": () => (isMacOS),
|
||||||
|
"isWindows": () => (isWindows),
|
||||||
|
"platform": () => (platform)
|
||||||
|
});
|
||||||
|
|
||||||
;// CONCATENATED MODULE: external "node:fs/promises"
|
;// CONCATENATED MODULE: external "node:fs/promises"
|
||||||
const promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:fs/promises");
|
const promises_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:fs/promises");
|
||||||
// EXTERNAL MODULE: external "node:os"
|
// EXTERNAL MODULE: external "node:os"
|
||||||
|
@ -95085,6 +95125,68 @@ function mungeDiagnosticEndpoint(inputUrl) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// EXTERNAL MODULE: external "os"
|
||||||
|
var external_os_ = __nccwpck_require__(2037);
|
||||||
|
// EXTERNAL MODULE: ./node_modules/.pnpm/@actions+exec@1.1.1/node_modules/@actions/exec/lib/exec.js
|
||||||
|
var exec = __nccwpck_require__(7775);
|
||||||
|
;// CONCATENATED MODULE: ./dist/platform.js
|
||||||
|
// MIT, 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
|
||||||
|
|
||||||
|
|
||||||
|
const getWindowsInfo = async () => {
|
||||||
|
const { stdout: version } = await exec.getExecOutput('powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Version"', undefined, {
|
||||||
|
silent: true,
|
||||||
|
});
|
||||||
|
const { stdout: name } = await exec.getExecOutput('powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Caption"', undefined, {
|
||||||
|
silent: true,
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
name: name.trim(),
|
||||||
|
version: version.trim(),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
const getMacOsInfo = async () => {
|
||||||
|
const { stdout } = await exec.getExecOutput("sw_vers", undefined, {
|
||||||
|
silent: true,
|
||||||
|
});
|
||||||
|
const version = stdout.match(/ProductVersion:\s*(.+)/)?.[1] ?? "";
|
||||||
|
const name = stdout.match(/ProductName:\s*(.+)/)?.[1] ?? "";
|
||||||
|
return {
|
||||||
|
name,
|
||||||
|
version,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
const getLinuxInfo = async () => {
|
||||||
|
const { stdout } = await exec.getExecOutput("lsb_release", ["-i", "-r", "-s"], {
|
||||||
|
silent: true,
|
||||||
|
});
|
||||||
|
const [name, version] = stdout.trim().split("\n");
|
||||||
|
return {
|
||||||
|
name,
|
||||||
|
version,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
const platform = external_os_.platform();
|
||||||
|
const arch = external_os_.arch();
|
||||||
|
const isWindows = platform === "win32";
|
||||||
|
const isMacOS = platform === "darwin";
|
||||||
|
const isLinux = platform === "linux";
|
||||||
|
async function getDetails() {
|
||||||
|
return {
|
||||||
|
...(await (isWindows
|
||||||
|
? getWindowsInfo()
|
||||||
|
: isMacOS
|
||||||
|
? getMacOsInfo()
|
||||||
|
: getLinuxInfo())),
|
||||||
|
platform,
|
||||||
|
arch,
|
||||||
|
isWindows,
|
||||||
|
isMacOS,
|
||||||
|
isLinux,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
;// CONCATENATED MODULE: ./dist/index.js
|
;// CONCATENATED MODULE: ./dist/index.js
|
||||||
|
|
||||||
|
|
||||||
|
@ -95097,6 +95199,7 @@ function mungeDiagnosticEndpoint(inputUrl) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const ENV_CACHE_DAEMONDIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
const ENV_CACHE_DAEMONDIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
||||||
const gotClient = got_dist_source.extend({
|
const gotClient = got_dist_source.extend({
|
||||||
retry: {
|
retry: {
|
||||||
|
@ -95350,6 +95453,10 @@ const idslib = new IdsToolbox({
|
||||||
requireNix: "warn",
|
requireNix: "warn",
|
||||||
});
|
});
|
||||||
idslib.onMain(async () => {
|
idslib.onMain(async () => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(dist_platform_namespaceObject);
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(getDetails());
|
||||||
await setUpAutoCache(idslib);
|
await setUpAutoCache(idslib);
|
||||||
await notifyAutoCache();
|
await notifyAutoCache();
|
||||||
});
|
});
|
||||||
|
|
15
dist/platform.d.ts
generated
vendored
Normal file
15
dist/platform.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
/// <reference types="node" resolution-mode="require"/>
|
||||||
|
export declare const platform: NodeJS.Platform;
|
||||||
|
export declare const arch: string;
|
||||||
|
export declare const isWindows: boolean;
|
||||||
|
export declare const isMacOS: boolean;
|
||||||
|
export declare const isLinux: boolean;
|
||||||
|
export declare function getDetails(): Promise<{
|
||||||
|
name: string;
|
||||||
|
platform: string;
|
||||||
|
arch: string;
|
||||||
|
version: string;
|
||||||
|
isWindows: boolean;
|
||||||
|
isMacOS: boolean;
|
||||||
|
isLinux: boolean;
|
||||||
|
}>;
|
56
dist/platform.js
generated
vendored
Normal file
56
dist/platform.js
generated
vendored
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
// MIT, 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
|
||||||
|
import os from "os";
|
||||||
|
import * as exec from "@actions/exec";
|
||||||
|
const getWindowsInfo = async () => {
|
||||||
|
const { stdout: version } = await exec.getExecOutput('powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Version"', undefined, {
|
||||||
|
silent: true,
|
||||||
|
});
|
||||||
|
const { stdout: name } = await exec.getExecOutput('powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Caption"', undefined, {
|
||||||
|
silent: true,
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
name: name.trim(),
|
||||||
|
version: version.trim(),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
const getMacOsInfo = async () => {
|
||||||
|
const { stdout } = await exec.getExecOutput("sw_vers", undefined, {
|
||||||
|
silent: true,
|
||||||
|
});
|
||||||
|
const version = stdout.match(/ProductVersion:\s*(.+)/)?.[1] ?? "";
|
||||||
|
const name = stdout.match(/ProductName:\s*(.+)/)?.[1] ?? "";
|
||||||
|
return {
|
||||||
|
name,
|
||||||
|
version,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
const getLinuxInfo = async () => {
|
||||||
|
const { stdout } = await exec.getExecOutput("lsb_release", ["-i", "-r", "-s"], {
|
||||||
|
silent: true,
|
||||||
|
});
|
||||||
|
const [name, version] = stdout.trim().split("\n");
|
||||||
|
return {
|
||||||
|
name,
|
||||||
|
version,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
export const platform = os.platform();
|
||||||
|
export const arch = os.arch();
|
||||||
|
export const isWindows = platform === "win32";
|
||||||
|
export const isMacOS = platform === "darwin";
|
||||||
|
export const isLinux = platform === "linux";
|
||||||
|
export async function getDetails() {
|
||||||
|
return {
|
||||||
|
...(await (isWindows
|
||||||
|
? getWindowsInfo()
|
||||||
|
: isMacOS
|
||||||
|
? getMacOsInfo()
|
||||||
|
: getLinuxInfo())),
|
||||||
|
platform,
|
||||||
|
arch,
|
||||||
|
isWindows,
|
||||||
|
isMacOS,
|
||||||
|
isLinux,
|
||||||
|
};
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ import * as core from "@actions/core";
|
||||||
import { Tail } from "tail";
|
import { Tail } from "tail";
|
||||||
import got from "got";
|
import got from "got";
|
||||||
import { IdsToolbox } from "detsys-ts";
|
import { IdsToolbox } from "detsys-ts";
|
||||||
|
import * as platform from "./platform.js";
|
||||||
|
|
||||||
const ENV_CACHE_DAEMONDIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
const ENV_CACHE_DAEMONDIR = "MAGIC_NIX_CACHE_DAEMONDIR";
|
||||||
|
|
||||||
|
@ -309,6 +310,11 @@ const idslib = new IdsToolbox({
|
||||||
});
|
});
|
||||||
|
|
||||||
idslib.onMain(async () => {
|
idslib.onMain(async () => {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(platform);
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(platform.getDetails());
|
||||||
await setUpAutoCache(idslib);
|
await setUpAutoCache(idslib);
|
||||||
await notifyAutoCache();
|
await notifyAutoCache();
|
||||||
});
|
});
|
||||||
|
|
94
src/platform.ts
Normal file
94
src/platform.ts
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
// MIT, 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
|
||||||
|
|
||||||
|
import os from "os";
|
||||||
|
import * as exec from "@actions/exec";
|
||||||
|
|
||||||
|
const getWindowsInfo = async (): Promise<{ name: string; version: string }> => {
|
||||||
|
const { stdout: version } = await exec.getExecOutput(
|
||||||
|
'powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Version"',
|
||||||
|
undefined,
|
||||||
|
{
|
||||||
|
silent: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const { stdout: name } = await exec.getExecOutput(
|
||||||
|
'powershell -command "(Get-CimInstance -ClassName Win32_OperatingSystem).Caption"',
|
||||||
|
undefined,
|
||||||
|
{
|
||||||
|
silent: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: name.trim(),
|
||||||
|
version: version.trim(),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const getMacOsInfo = async (): Promise<{
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
}> => {
|
||||||
|
const { stdout } = await exec.getExecOutput("sw_vers", undefined, {
|
||||||
|
silent: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
const version = stdout.match(/ProductVersion:\s*(.+)/)?.[1] ?? "";
|
||||||
|
const name = stdout.match(/ProductName:\s*(.+)/)?.[1] ?? "";
|
||||||
|
|
||||||
|
return {
|
||||||
|
name,
|
||||||
|
version,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const getLinuxInfo = async (): Promise<{
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
}> => {
|
||||||
|
const { stdout } = await exec.getExecOutput(
|
||||||
|
"lsb_release",
|
||||||
|
["-i", "-r", "-s"],
|
||||||
|
{
|
||||||
|
silent: true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const [name, version] = stdout.trim().split("\n");
|
||||||
|
|
||||||
|
return {
|
||||||
|
name,
|
||||||
|
version,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const platform = os.platform();
|
||||||
|
export const arch = os.arch();
|
||||||
|
export const isWindows = platform === "win32";
|
||||||
|
export const isMacOS = platform === "darwin";
|
||||||
|
export const isLinux = platform === "linux";
|
||||||
|
|
||||||
|
export async function getDetails(): Promise<{
|
||||||
|
name: string;
|
||||||
|
platform: string;
|
||||||
|
arch: string;
|
||||||
|
version: string;
|
||||||
|
isWindows: boolean;
|
||||||
|
isMacOS: boolean;
|
||||||
|
isLinux: boolean;
|
||||||
|
}> {
|
||||||
|
return {
|
||||||
|
...(await (isWindows
|
||||||
|
? getWindowsInfo()
|
||||||
|
: isMacOS
|
||||||
|
? getMacOsInfo()
|
||||||
|
: getLinuxInfo())),
|
||||||
|
platform,
|
||||||
|
arch,
|
||||||
|
isWindows,
|
||||||
|
isMacOS,
|
||||||
|
isLinux,
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue