@@ -32666,26 +32666,36 @@ var tool_cache = __nccwpck_require__(3472);
3266632666
3266732667
3266832668
32669+ // maps OS architecture names to 1Password CLI installer architecture names
3266932670const archMap = {
3267032671 ia32: "386",
32671- x32: "386",
32672- x86: "386",
3267332672 x64: "amd64",
3267432673 arm: "arm",
3267532674 arm64: "arm64",
3267632675};
32676+ // Builds the download URL for the 1Password CLI based on the platform and version.
32677+ const cliUrlBuilder = {
32678+ linux: (version, arch) => `https://cache.agilebits.com/dist/1P/op2/pkg/${version}/op_linux_${arch}_${version}.zip`,
32679+ darwin: (version) => `https://cache.agilebits.com/dist/1P/op2/pkg/${version}/op_apple_universal_${version}.pkg`,
32680+ win32: (version, arch) => `https://cache.agilebits.com/dist/1P/op2/pkg/${version}/op_windows_${arch}_${version}.zip`,
32681+ };
3267732682class CliInstaller {
32678- async install(downloadUrl) {
32679- console.info(`Downloading 1Password CLI from: ${downloadUrl}`);
32680- const downloadPath = await tool_cache.downloadTool(downloadUrl);
32683+ version;
32684+ arch;
32685+ constructor(version) {
32686+ this.version = version;
32687+ this.arch = this.getArch();
32688+ }
32689+ async install(url) {
32690+ console.info(`Downloading 1Password CLI from: ${url}`);
32691+ const downloadPath = await tool_cache.downloadTool(url);
3268132692 console.info("Installing 1Password CLI");
3268232693 const extractedPath = await tool_cache.extractZip(downloadPath);
3268332694 core.addPath(extractedPath);
3268432695 core.info("1Password CLI installed");
3268532696 }
32686- // possible values for GitHub hosted runners (process.env.RUNNER_ARCH) can be found here: https://docs.github.com/en/actions/reference/variables-reference#default-environment-variables
3268732697 getArch() {
32688- const arch = archMap[process.env.RUNNER_ARCH?.toLowerCase() || external_os_default().arch()];
32698+ const arch = archMap[external_os_default().arch()];
3268932699 if (!arch) {
3269032700 throw new Error("Unsupported architecture");
3269132701 }
@@ -32695,21 +32705,14 @@ class CliInstaller {
3269532705
3269632706;// CONCATENATED MODULE: ./src/cli-installer/linux.ts
3269732707
32698-
3269932708class LinuxInstaller extends CliInstaller {
32700- arch;
32701- version;
32709+ platform = "linux"; // Node.js platform identifier for Linux
3270232710 constructor(version) {
32703- super();
32704- this.version = version;
32705- this.arch = super.getArch();
32711+ super(version);
3270632712 }
3270732713 async installCli() {
32708- const downloadUrl = this.downloadUrl();
32709- await super.install(downloadUrl);
32710- }
32711- downloadUrl() {
32712- return `https://cache.agilebits.com/dist/1P/op2/pkg/${this.version}/op_linux_${this.arch}_${this.version}.zip`;
32714+ const urlBuilder = cliUrlBuilder[this.platform];
32715+ await super.install(urlBuilder(this.version, this.arch));
3271332716 }
3271432717}
3271532718
@@ -32732,18 +32735,13 @@ var external_util_ = __nccwpck_require__(9023);
3273232735
3273332736const execAsync = (0,external_util_.promisify)(external_child_process_.exec);
3273432737class MacOsInstaller extends CliInstaller {
32735- version;
32738+ platform = "darwin"; // Node.js platform identifier for macOS
3273632739 constructor(version) {
32737- super();
32738- this.version = version;
32740+ super(version);
3273932741 }
3274032742 async installCli() {
32741- const downloadUrl = this.downloadUrl();
32742- core.info(`Downloading 1Password CLI ${this.version} from ${downloadUrl}`);
32743- await this.install(downloadUrl);
32744- }
32745- downloadUrl() {
32746- return `https://cache.agilebits.com/dist/1P/op2/pkg/${this.version}/op_apple_universal_${this.version}.pkg`;
32743+ const urlBuilder = cliUrlBuilder[this.platform];
32744+ await this.install(urlBuilder(this.version));
3274732745 }
3274832746 // @actions/tool-cache package does not support .pkg files, so we need to handle the installation manually
3274932747 async install(downloadUrl) {
@@ -32766,36 +32764,37 @@ class MacOsInstaller extends CliInstaller {
3276632764;// CONCATENATED MODULE: ./src/cli-installer/windows.ts
3276732765
3276832766class WindowsInstaller extends CliInstaller {
32769- arch;
32770- version;
32767+ platform = "win32"; // Node.js platform identifier for Windows
3277132768 constructor(version) {
32772- super();
32773- this.version = version;
32774- this.arch = super.getArch();
32769+ super(version);
3277532770 }
3277632771 async installCli() {
32777- const downloadUrl = this.downloadUrl();
32778- await super.install(downloadUrl);
32779- }
32780- downloadUrl() {
32781- return `https://cache.agilebits.com/dist/1P/op2/pkg/${this.version}/op_windows_${this.arch}_${this.version}.zip`;
32772+ const urlBuilder = cliUrlBuilder[this.platform];
32773+ await super.install(urlBuilder(this.version, this.arch));
3278232774 }
3278332775}
3278432776
32785- ;// CONCATENATED MODULE: ./src/cli-installer/index .ts
32777+ ;// CONCATENATED MODULE: ./src/cli-installer/installer .ts
3278632778
3278732779
3278832780
32789- /* eslint-disable @typescript-eslint/naming-convention */
32790- // RunnerOS defines the operating system of the runner executing the job.
32791- // Look `RUNNER_OS` for possible values (https://docs.github.com/en/actions/reference/variables-reference).
32792- var RunnerOS;
32793- (function (RunnerOS) {
32794- RunnerOS["Linux"] = "Linux";
32795- RunnerOS["MacOS"] = "macOS";
32796- RunnerOS["Windows"] = "Windows";
32797- })(RunnerOS || (RunnerOS = {}));
32798- /* eslint-enable @typescript-eslint/naming-convention */
32781+
32782+ const newCliInstaller = (version) => {
32783+ const platform = external_os_default().platform();
32784+ switch (platform) {
32785+ case "linux":
32786+ return new LinuxInstaller(version);
32787+ case "darwin":
32788+ return new MacOsInstaller(version);
32789+ case "win32":
32790+ return new WindowsInstaller(version);
32791+ default:
32792+ throw new Error(`Unsupported platform: ${platform}`);
32793+ }
32794+ };
32795+
32796+ ;// CONCATENATED MODULE: ./src/cli-installer/index.ts
32797+
3279932798
3280032799;// CONCATENATED MODULE: ./src/version/constants.ts
3280132800/* eslint-disable @typescript-eslint/naming-convention */
@@ -32900,21 +32899,7 @@ const run = async () => {
3290032899 try {
3290132900 const versionResolver = new VersionResolver(core.getInput("version"));
3290232901 await versionResolver.resolve();
32903- let installer;
32904- switch (process.env.RUNNER_OS) {
32905- case RunnerOS.Linux:
32906- installer = new LinuxInstaller(versionResolver.get());
32907- break;
32908- case RunnerOS.MacOS:
32909- installer = new MacOsInstaller(versionResolver.get());
32910- break;
32911- case RunnerOS.Windows:
32912- installer = new WindowsInstaller(versionResolver.get());
32913- break;
32914- default:
32915- core.setFailed(`Unsupported platform: ${process.env.RUNNER_OS}`);
32916- return;
32917- }
32902+ const installer = newCliInstaller(versionResolver.get());
3291832903 await installer.installCli();
3291932904 }
3292032905 catch (error) {
0 commit comments