-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fixed typo and improved function * fixed typo and improved function * fixed typo and improved function * fixed typo and improved function * fixed typo and improved function * fixed typo and improved function * fixed typo and improved function * fixed typo and improved function * fixed typo and improved function * Changes to be committed: modified: .gitignore * Add flake for brewy project with local package - Created flake.nix to define the flake structure. - Included default.nix for the local package definition. - Used callPackage to integrate the local package into the flake. - Set up default package for easy building and running. * removed * Changes to be committed: modified: flake.nix * updated and implemented new feature
- Loading branch information
1 parent
69803ea
commit d55083f
Showing
15 changed files
with
301 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ pkgs ? import <nixpkgs> {} }: | ||
|
||
let | ||
# Define the version and the base URL for the binaries | ||
version = "1.0.0"; | ||
baseUrl = "https://github.com/transgirllucy/brewy/releases/download/${version}"; | ||
|
||
# Function to determine the binary URL and SHA256 based on the system | ||
getBinaryInfo = pkgs: { | ||
inherit (pkgs.stdenv) isDarwin isAarch64; | ||
|
||
url = if isDarwin then | ||
if isAarch64 then "${baseUrl}/brewy-darwin-arm64" | ||
else "${baseUrl}/brewy-darwin-x64" | ||
else "${baseUrl}/brewy-linux-x64"; | ||
|
||
sha256 = if isDarwin then | ||
if isAarch64 then "672e8250fe54a41675f029eadb053bb238268ecda93bbe4803503c8a523a1726" | ||
else "653192ecfa71ce38a31dc1bc57729c278e4cdcb891560d20c58c326b7bb61df3" | ||
else "7dc8659cd61fe62f68293de13f53168c83bb77dd3294ba50cdb9d1e6f721e8c2"; | ||
}; | ||
|
||
binaryInfo = getBinaryInfo pkgs; | ||
|
||
in | ||
|
||
pkgs.stdenv.mkDerivation { | ||
pname = "brewy"; | ||
inherit version; | ||
|
||
src = pkgs.fetchurl { | ||
url = binaryInfo.url; | ||
sha256 = binaryInfo.sha256; | ||
}; | ||
|
||
installPhase = '' | ||
mkdir -p $out/bin | ||
cp $src $out/bin/brewy | ||
chmod +x $out/bin/brewy | ||
''; | ||
|
||
meta = with pkgs.lib; { | ||
description = "A description of your project"; | ||
homepage = "https://github.com/transgirllucy/brewy"; | ||
license = licenses.mit; # Adjust this to the actual license of your project | ||
maintainers = with maintainers; [ yourName ]; # Replace with your name or GitHub handle | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
description = "A flake for the brewy project"; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | ||
}; | ||
|
||
outputs = { self, nixpkgs }: let | ||
# Import the local package | ||
brewy = nixpkgs.callPackage ./default.nix {}; | ||
|
||
in { | ||
# Expose the package for building and running | ||
packages.x86_64-linux = brewy; | ||
packages.darwin = brewy; | ||
|
||
# Default app to run | ||
defaultPackage.x86_64-linux = brewy; | ||
defaultPackage.aarch64-linux = brewy; | ||
defaultPackage.darwin = brewy; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
{ | ||
"name": "brewy", | ||
"version": "1.0.0", | ||
"module": "src/index.ts", | ||
"type": "module", | ||
"scripts": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
import { exec } from 'child_process'; | ||
import { consola } from 'consola'; | ||
import consola from 'consola'; | ||
|
||
export function runCommand(command: string): Promise<string> { | ||
export function runCommand(command: string, options?: { cwd?: string }): Promise<string> { | ||
return new Promise((resolve, reject) => { | ||
exec(command, (error, stdout, stderr) => { | ||
exec(command, options, (error, stdout, stderr) => { | ||
if (error) { | ||
reject(`❌ Error: ${stderr}`); | ||
consola.error(`❌ Error executing command: "${command}"\n${stderr}`); | ||
reject(`Error: ${stderr}`); | ||
} else { | ||
resolve(`✅ Success: ${stdout}`); | ||
// consola.success(`✅ Command executed successfully: "${command}"`); | ||
resolve(stdout.toString().trim()); | ||
} | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { runCommand } from "../command"; // Assuming runCommand is a function that executes shell commands | ||
import { consola } from "consola"; | ||
import ora from "ora"; | ||
|
||
interface ServiceOptions { | ||
all?: boolean; | ||
json?: boolean; | ||
debug?: boolean; | ||
quiet?: boolean; | ||
verbose?: boolean; | ||
file?: string; | ||
serviceUser ?: string; | ||
maxWait?: number; | ||
noWait?: boolean; | ||
} | ||
|
||
export async function handleServices(subcommand: string, formula?: string, options?: ServiceOptions) { | ||
const spinner = ora(`🔄 Executing brew services ${subcommand}...`).start(); // Start spinner with emoji | ||
|
||
try { | ||
let command = `brew services ${subcommand}`; | ||
|
||
// Handle options | ||
if (options) { | ||
if (options.all) command += ' --all'; | ||
if (options.json) command += ' --json'; | ||
if (options.debug) command += ' --debug'; | ||
if (options.quiet) command += ' --quiet'; | ||
if (options.verbose) command += ' --verbose'; | ||
if (options.file) command += ` --file=${options.file}`; | ||
if (options.serviceUser ) command += ` --sudo-service-user=${options.serviceUser }`; | ||
if (options.maxWait !== undefined) command += ` --max-wait=${options.maxWait}`; | ||
if (options.noWait) command += ' --no-wait'; | ||
} | ||
|
||
if (formula) { | ||
command += ` ${formula}`; | ||
} | ||
|
||
const result = await runCommand(command); | ||
spinner.succeed(`✅ Successfully executed: ${command}`); // Success message with emoji | ||
|
||
// Output the result | ||
if (!options?.quiet) { | ||
consola.info(`📜 ${result}`); // Output result with an emoji | ||
} | ||
} catch (error: any) { | ||
spinner.fail(`❌ Error executing brew services ${subcommand}: ${error.message}`); // Error message with emoji | ||
} | ||
} |
Oops, something went wrong.