Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ before:
builds:
- env:
- CGO_ENABLED=0
main: ./internal/numscript/numscript.go
main: ./cmd/numscript/main.go
goos:
- linux
- windows
Expand Down
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ The language server features include:
- Detect document symbols
- Go to definition

### Build locally
If you have the golang toolchain installed locally, you can run `go install ./internal/numscript/numscript.go` to build the cli from source, which you'll be able to run by executing the `numscript` command
Otherwise, you can download it from this repo's [releases](https://github.com/formancehq/numscript/releases)
### Installation

You can install the `numscript` cli with one of the following ways:

**Using curl**

```sh
curl -sSf https://raw.githubusercontent.com/formancehq/numscript/main/install.sh | bash
```

**Using golang toolchain**

```sh
go install github.com/formancehq/numscript/cmd/numscript@latest
```
File renamed without changes.
67 changes: 67 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
set -e

echo "👉 Detecting platform..."

# Detect OS
OS="$(uname -s)"
case "$OS" in
Linux*) PLATFORM="Linux";;
Darwin*) PLATFORM="Darwin";;
MINGW*|MSYS*|CYGWIN*|Windows_NT) PLATFORM="Windows";;
*) echo "❌ Unsupported OS: $OS"; exit 1;;
esac

# Detect architecture
ARCH="$(uname -m)"
case "$ARCH" in
x86_64) ARCH="x86_64";;
amd64) ARCH="x86_64";; # Just in case
arm64|aarch64) ARCH="arm64";;
*) echo "❌ Unsupported architecture: $ARCH"; exit 1;;
esac

echo "✅ Platform: $PLATFORM"
echo "✅ Architecture: $ARCH"


# https://github.com/formancehq/numscript/releases/download/v0.0.18/numscript_.0.0.18_Darwin_arm64.tar.gz
# Get latest release tag
LATEST_TAG=$(curl -sI https://github.com/formancehq/numscript/releases/latest | grep -i location | awk -F '/' '{print $NF}' | tr -d '\r')

echo "📦 Latest tag: $LATEST_TAG"

# Determine file extension
if [ "$PLATFORM" = "Windows" ]; then
EXT="zip"
else
EXT="tar.gz"
fi

# Build file name and URL
FILENAME="numscript_.${LATEST_TAG#v}_${PLATFORM}_${ARCH}.${EXT}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the dot normal?

URL="https://github.com/formancehq/numscript/releases/download/$LATEST_TAG/$FILENAME"

echo "⬇️ Downloading: $URL"
curl -L -o "$FILENAME" "$URL"

# Extract and install
if [ "$PLATFORM" = "Windows" ]; then
unzip "$FILENAME"
BIN="numscript.exe"
else
tar -xf "$FILENAME" numscript
BIN="numscript"
fi
Comment on lines +53 to +55
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Extraction will fail: missing -z flag for .tar.gz archives
tar -xf cannot decompress gzip streams; the command will exit with “gzip: stdin: not in gzip format”.

-    tar -xf "$FILENAME" numscript
+    tar -xzf "$FILENAME" numscript
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
tar -xf "$FILENAME" numscript
BIN="numscript"
fi
tar -xzf "$FILENAME" numscript
BIN="numscript"
fi
🤖 Prompt for AI Agents
In install.sh around lines 53 to 55, the tar extraction command is missing the
-z flag needed for decompressing .tar.gz files. Update the tar command to
include the -z option (tar -xzf) to properly handle gzip compressed archives and
avoid extraction errors.



INSTALL_PATH="$HOME/.local/bin"
mkdir -p "$INSTALL_PATH"

mv "$BIN" "$INSTALL_PATH"
chmod +x "$INSTALL_PATH/$BIN"

Comment on lines +58 to +63
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Installation path & chmod are not Windows-friendly
For the Windows branch the script:

  1. Installs to $HOME/.local/bin, a Unix-style path that is rarely on PATH in Git-Bash/PowerShell.
  2. Runs chmod, which is a no-op (or errors) on native Windows.

Consider computing a platform-specific default such as:

if [ "$PLATFORM" = "Windows" ]; then
    INSTALL_PATH="$USERPROFILE/bin"
    mkdir -p "$INSTALL_PATH"
    mv "$BIN" "$INSTALL_PATH"
else
    INSTALL_PATH="$HOME/.local/bin"
    mkdir -p "$INSTALL_PATH"
    mv "$BIN" "$INSTALL_PATH"
    chmod +x "$INSTALL_PATH/$BIN"
fi
🤖 Prompt for AI Agents
In install.sh around lines 58 to 63, the script uses a Unix-style installation
path and runs chmod, which are not appropriate for Windows. Modify the script to
detect if PLATFORM is Windows; if so, set INSTALL_PATH to "$USERPROFILE/bin",
create the directory, and move the binary there without running chmod. For other
platforms, keep the existing behavior of installing to "$HOME/.local/bin",
creating the directory, moving the binary, and running chmod to make it
executable.

rm "$FILENAME"

echo "✅ Installed $BIN to $INSTALL_PATH"
echo "🎉 Done!"
Loading