|
1 | | -import os from "os"; |
2 | | -import * as core from "@actions/core"; |
3 | | -import * as tc from "@actions/tool-cache"; |
| 1 | +"use strict"; |
| 2 | +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { |
| 3 | + if (k2 === undefined) k2 = k; |
| 4 | + var desc = Object.getOwnPropertyDescriptor(m, k); |
| 5 | + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { |
| 6 | + desc = { enumerable: true, get: function() { return m[k]; } }; |
| 7 | + } |
| 8 | + Object.defineProperty(o, k2, desc); |
| 9 | +}) : (function(o, m, k, k2) { |
| 10 | + if (k2 === undefined) k2 = k; |
| 11 | + o[k2] = m[k]; |
| 12 | +})); |
| 13 | +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { |
| 14 | + Object.defineProperty(o, "default", { enumerable: true, value: v }); |
| 15 | +}) : function(o, v) { |
| 16 | + o["default"] = v; |
| 17 | +}); |
| 18 | +var __importStar = (this && this.__importStar) || (function () { |
| 19 | + var ownKeys = function(o) { |
| 20 | + ownKeys = Object.getOwnPropertyNames || function (o) { |
| 21 | + var ar = []; |
| 22 | + for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; |
| 23 | + return ar; |
| 24 | + }; |
| 25 | + return ownKeys(o); |
| 26 | + }; |
| 27 | + return function (mod) { |
| 28 | + if (mod && mod.__esModule) return mod; |
| 29 | + var result = {}; |
| 30 | + if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); |
| 31 | + __setModuleDefault(result, mod); |
| 32 | + return result; |
| 33 | + }; |
| 34 | +})(); |
| 35 | +var __importDefault = (this && this.__importDefault) || function (mod) { |
| 36 | + return (mod && mod.__esModule) ? mod : { "default": mod }; |
| 37 | +}; |
| 38 | +Object.defineProperty(exports, "__esModule", { value: true }); |
| 39 | +exports.CliInstaller = exports.cliUrlBuilder = exports.archMap = void 0; |
| 40 | +const os_1 = __importDefault(require("os")); |
| 41 | +const core = __importStar(require("@actions/core")); |
| 42 | +const tc = __importStar(require("@actions/tool-cache")); |
4 | 43 | // maps OS architecture names to 1Password CLI installer architecture names |
5 | | -export const archMap = { |
6 | | - ia32: "386", |
7 | | - x64: "amd64", |
8 | | - arm: "arm", |
9 | | - arm64: "arm64", |
| 44 | +exports.archMap = { |
| 45 | + ia32: "386", |
| 46 | + x64: "amd64", |
| 47 | + arm: "arm", |
| 48 | + arm64: "arm64", |
10 | 49 | }; |
11 | 50 | // Builds the download URL for the 1Password CLI based on the platform and version. |
12 | | -export const cliUrlBuilder = { |
13 | | - linux: (version, arch) => |
14 | | - `https://cache.agilebits.com/dist/1P/op2/pkg/${version}/op_linux_${arch}_${version}.zip`, |
15 | | - darwin: (version) => |
16 | | - `https://cache.agilebits.com/dist/1P/op2/pkg/${version}/op_apple_universal_${version}.pkg`, |
17 | | - win32: (version, arch) => |
18 | | - `https://cache.agilebits.com/dist/1P/op2/pkg/${version}/op_windows_${arch}_${version}.zip`, |
| 51 | +exports.cliUrlBuilder = { |
| 52 | + linux: (version, arch) => `https://cache.agilebits.com/dist/1P/op2/pkg/${version}/op_linux_${arch}_${version}.zip`, |
| 53 | + darwin: (version) => `https://cache.agilebits.com/dist/1P/op2/pkg/${version}/op_apple_universal_${version}.pkg`, |
| 54 | + win32: (version, arch) => `https://cache.agilebits.com/dist/1P/op2/pkg/${version}/op_windows_${arch}_${version}.zip`, |
19 | 55 | }; |
20 | | -export class CliInstaller { |
21 | | - version; |
22 | | - arch; |
23 | | - constructor(version) { |
24 | | - this.version = version; |
25 | | - this.arch = this.getArch(); |
26 | | - } |
27 | | - async install(url) { |
28 | | - console.info(`Downloading 1Password CLI from: ${url}`); |
29 | | - const downloadPath = await tc.downloadTool(url); |
30 | | - console.info("Installing 1Password CLI"); |
31 | | - const extractedPath = await tc.extractZip(downloadPath); |
32 | | - core.addPath(extractedPath); |
33 | | - core.info("1Password CLI installed"); |
34 | | - } |
35 | | - getArch() { |
36 | | - const arch = archMap[os.arch()]; |
37 | | - if (!arch) { |
38 | | - throw new Error("Unsupported architecture"); |
39 | | - } |
40 | | - return arch; |
41 | | - } |
| 56 | +class CliInstaller { |
| 57 | + constructor(version) { |
| 58 | + this.version = version; |
| 59 | + this.arch = this.getArch(); |
| 60 | + } |
| 61 | + async install(url) { |
| 62 | + console.info(`Downloading 1Password CLI from: ${url}`); |
| 63 | + const downloadPath = await tc.downloadTool(url); |
| 64 | + console.info("Installing 1Password CLI"); |
| 65 | + const extractedPath = await tc.extractZip(downloadPath); |
| 66 | + core.addPath(extractedPath); |
| 67 | + core.info("1Password CLI installed"); |
| 68 | + } |
| 69 | + getArch() { |
| 70 | + const arch = exports.archMap[os_1.default.arch()]; |
| 71 | + if (!arch) { |
| 72 | + throw new Error("Unsupported architecture"); |
| 73 | + } |
| 74 | + return arch; |
| 75 | + } |
42 | 76 | } |
| 77 | +exports.CliInstaller = CliInstaller; |
0 commit comments