Skip to content

Commit

Permalink
Add support for compiling SEA
Browse files Browse the repository at this point in the history
  • Loading branch information
jtsmedley committed Mar 9, 2024
1 parent 41b855d commit d4cea1c
Show file tree
Hide file tree
Showing 12 changed files with 1,309 additions and 78 deletions.
148 changes: 148 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
name: Build CLI

on: [push]

jobs:
build-ubuntu-x64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '21.x'
- run: yarn install --frozen-lockfile
- run: yarn run build
- run: yarn run package
- run: cp $(command -v node) ndjson-downloader
- run: npx postject ndjson-downloader NODE_SEA_BLOB sea-prep.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
- name: Move Scripts
run: cp scripts/* .
- uses: actions/upload-artifact@v4
with:
name: ndjson-downloader_linux_x64
path: |
install.sh
install.zsh
install.fish
ndjson-downloader
README.md
LICENSE
- name: Compress Archive
run: zip ndjson-downloader_linux_x64.zip ndjson-downloader README.md LICENSE install.sh install.zsh install.fish
if: startsWith(github.ref, 'refs/tags/')
- name: Upload Release Artifact
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ndjson-downloader_linux_x64.zip

build-macos-x64:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '21.x'
- run: yarn install --frozen-lockfile
- run: yarn run build
- run: yarn run package
- run: cp $(command -v node) ndjson-downloader
- run: codesign --remove-signature ndjson-downloader
- run: npx postject ndjson-downloader NODE_SEA_BLOB sea-prep.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 --macho-segment-name NODE_SEA
- run: codesign --sign - ndjson-downloader
- name: Move Scripts
run: cp scripts/* .
- uses: actions/upload-artifact@v4
with:
name: ndjson-downloader_macos_x64
path: |
install.sh
install.zsh
install.fish
ndjson-downloader
README.md
LICENSE
- name: Compress Archive
run: zip ndjson-downloader_macos_x64.zip ndjson-downloader README.md LICENSE install.sh install.zsh install.fish
if: startsWith(github.ref, 'refs/tags/')
- name: Upload Release Artifact
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ndjson-downloader_macos_x64.zip

build-macos-arm64:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '21.x'
- run: yarn install --frozen-lockfile
- run: yarn run build
- run: yarn run package
- run: cp $(command -v node) ndjson-downloader
- run: codesign --remove-signature ndjson-downloader
- run: npx postject ndjson-downloader NODE_SEA_BLOB sea-prep.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 --macho-segment-name NODE_SEA
- run: codesign --sign - ndjson-downloader
- name: Move Scripts
run: cp scripts/* .
- uses: actions/upload-artifact@v4
with:
name: ndjson-downloader_macos_arm64
path: |
install.sh
install.zsh
install.fish
ndjson-downloader
README.md
LICENSE
- name: Compress Archive
run: zip ndjson-downloader_macos_arm64.zip ndjson-downloader README.md LICENSE install.sh install.zsh install.fish
if: startsWith(github.ref, 'refs/tags/')
- name: Upload Release Artifact
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ndjson-downloader_macos_arm64.zip

build-windows-x64:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '21.x'
- run: yarn install --frozen-lockfile
- run: yarn run build
- run: yarn run package
- run: node -e "require('fs').copyFileSync(process.execPath, 'ndjson-downloader.exe')"
- uses: GuillaumeFalourd/setup-windows10-sdk-action@v2
with:
sdk-version: 22621
- run: '& "C:\Program Files (x86)\Windows Kits\10\bin\10.0.22621.0\x86\signtool.exe" remove /s .\ndjson-downloader.exe'
- run: npx postject ndjson-downloader.exe NODE_SEA_BLOB sea-prep.blob --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2
- name: Move Scripts
run: cp scripts/* .
- uses: actions/upload-artifact@v4
with:
name: ndjson-downloader_windows_x64
path: |
install.bat
install.ps1
ndjson-downloader.exe
README.md
LICENSE
- name: Compress Archive
run: Compress-Archive -Path ".\ndjson-downloader.exe", ".\README.md", ".\LICENSE", ".\install.bat", ".\install.ps1" ndjson-downloader_windows_x64.zip
if: startsWith(github.ref, 'refs/tags/')
- name: Upload Release Artifact
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: ndjson-downloader_windows_x64.zip

43 changes: 0 additions & 43 deletions index.js

This file was deleted.

19 changes: 16 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,20 @@
"version": "1.0.0",
"type": "module",
"description": "",
"main": "index.js",
"main": "dist/index.js",
"files": [
"dist"
],
"bin": {
"filebase": "dist/index.js"
},
"engines": {
"node": ">=16.0.0",
"npm": ">=8.0.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"build": "tsup src/index.js",
"package": "node --experimental-sea-config sea-config.json"
},
"repository": {
"type": "git",
Expand All @@ -18,6 +29,8 @@
"p-queue": "8.0.1"
},
"devDependencies": {
"prettier": "3.2.5"
"prettier": "3.2.5",
"tsup": "8.0.2",
"typescript": "5.3.3"
}
}
2 changes: 0 additions & 2 deletions scripts/data.ndjson

This file was deleted.

21 changes: 21 additions & 0 deletions scripts/install.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@echo off
setlocal

:: Define the application executable name and its current location
set "appName=filebase.exe"
set "currentAppPath=%appName%"

:: Define the target installation directory in Program Files
set "installPath=%ProgramFiles%\filebase"

:: Create the target directory if it doesn't exist
if not exist "%installPath%" mkdir "%installPath%"

:: Copy the application executable to the target directory
copy ./filebase.exe "%installPath%"

:: Add the application's directory to the system PATH environment variable
:: This allows the application to be run from anywhere in the terminal
setx PATH "%PATH%;%installPath%" /M

echo Installation and configuration complete. You can now run %appName% from the terminal.
30 changes: 30 additions & 0 deletions scripts/install.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env fish

# Define the application executable name and its current location
set appName "filebase"
set currentAppPath "../$appName"

# Function to check if a path is in the PATH environment variable
function isInPath
echo ":$PATH:" | grep -Fq ":$argv[1]:"
end

# Determine the installation path based on what's available in PATH
if isInPath "/usr/local/bin"
set installPath "/usr/local/bin"
else if isInPath "/usr/bin"
set installPath "/usr/bin"
else if isInPath "/bin"
set installPath "/bin"
else
echo "Error: None of the preferred installation paths are in your PATH."
exit 1
end

# Copy the application executable to the target directory
sudo cp "$currentAppPath" "$installPath/$appName"

# Make sure the executable has execution permissions
sudo chmod +x "$installPath/$appName"

echo "Installation complete. You can now run $appName from the terminal."
24 changes: 24 additions & 0 deletions scripts/install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Define the application executable name and its current location
$appName = "filebase.exe"
$currentAppPath = "$appName"

# Define the target installation directory in Program Files
$installPath = Join-Path -Path $Env:ProgramFiles -ChildPath "filebase"

# Create the target directory if it doesn't exist
if (-not (Test-Path -Path $installPath)) {
New-Item -ItemType Directory -Path $installPath | Out-Null
}

# Copy the application executable to the target directory
Copy-Item -Path $currentAppPath -Destination $installPath

# Add the application's directory to the system PATH environment variable
# This allows the application to be run from anywhere in the terminal
$systemPath = [System.Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine)
if (-not ($systemPath.Split(';') -contains $installPath)) {
$newPath = $systemPath + ";" + $installPath
[System.Environment]::SetEnvironmentVariable("Path", $newPath, [System.EnvironmentVariableTarget]::Machine)
}

Write-Output "Installation and configuration complete. You can now run $appName from the terminal."
30 changes: 30 additions & 0 deletions scripts/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Define the application executable name and its current location
appName="filebase"
currentAppPath="$appName"

# Function to check if a path is in the PATH environment variable
function isInPath() {
echo ":$PATH:" | grep -Fq ":$1:"
}

# Determine the installation path based on what's available in PATH
if isInPath "/usr/local/bin"; then
installPath="/usr/local/bin"
elif isInPath "/usr/bin"; then
installPath="/usr/bin"
elif isInPath "/bin"; then
installPath="/bin"
else
echo "Error: None of the preferred installation paths are in your PATH."
exit 1
fi

# Copy the application executable to the target directory
sudo cp "$currentAppPath" "$installPath/$appName"

# Make sure the executable has execution permissions
sudo chmod +x "$installPath/$appName"

echo "Installation complete. You can now run $appName from the terminal."
30 changes: 30 additions & 0 deletions scripts/install.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/zsh

# Define the application executable name and its current location
appName="filebase"
currentAppPath="$appName"

# Function to check if a path is in the PATH environment variable
function isInPath() {
echo ":$PATH:" | grep -Fq ":$1:"
}

# Determine the installation path based on what's available in PATH
if isInPath "/usr/local/bin"; then
installPath="/usr/local/bin"
elif isInPath "/usr/bin"; then
installPath="/usr/bin"
elif isInPath "/bin"; then
installPath="/bin"
else
echo "Error: None of the preferred installation paths are in your PATH."
return 1
fi

# Copy the application executable to the target directory
sudo cp "$currentAppPath" "$installPath/$appName"

# Make sure the executable has execution permissions
sudo chmod +x "$installPath/$appName"

echo "Installation complete. You can now run $appName from the terminal."
Loading

0 comments on commit d4cea1c

Please sign in to comment.