Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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 .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ jobs:

# Run tests
- name: Run tests
run: ./run-tests.sh
run: ./scripts/run-tests.sh
46 changes: 15 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ jobs:
- name: 'spinup'
platform: 'darwin/universal'
os: 'macos-latest'
- name: 'Spinup'
platform: 'windows/amd64'
os: 'windows-latest'
# - name: 'Spinup'
# platform: 'windows/amd64'
# os: 'windows-latest'

runs-on: ${{ matrix.build.os }}
steps:
Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
SPINUP_VERSION=$(cat ./common/.version | sed 's/^v//')
sed -i.bak "s/{{version}}/${SPINUP_VERSION}/g" wails.json && rm wails.json.bak

wails build --platform ${{ matrix.build.platform }} -webview2 ${{ env.WEBVIEW2 }} -o ${{ matrix.build.name }}-${SPINUP_VERSION}
wails build --platform ${{ matrix.build.platform }} -webview2 ${{ env.WEBVIEW2 }} -o ${{ matrix.build.name }}
shell: bash
- name: Build Windows App + Installer
if: runner.os == 'Windows'
Expand Down Expand Up @@ -133,57 +133,41 @@ jobs:
with:
key: ${{ runner.os }}-icons-${{ hashFiles('images/icon-large.png') }}
path: |
build/share/icons
build/share/pixmaps
build/unix/usr/share/icons
build/unix/usr/share/pixmaps
- name: Generate icons
# if: (runner.os == 'Linux' || runner.os == 'macOS') && steps.cache-icons.outputs.cache-hit != 'true'
if: runner.os == 'Linux' && steps.cache-icons.outputs.cache-hit != 'true'
working-directory: ${{ env.WORKING_DIRECTORY }}
run: bash ./generate-icons.sh
run: bash ./scripts/generate-icons.sh
shell: bash

# Package as .deb for Ubuntu
- name: Package as .deb for Ubuntu
if: runner.os == 'Linux'
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
SPINUP_VERSION=$(cat ./common/.version | sed 's/^v//')

for os_version in "" "-ubuntu24.04"; do
mkdir -p deb/spinup-${SPINUP_VERSION}${os_version}/DEBIAN
mkdir -p deb/spinup-${SPINUP_VERSION}${os_version}/usr/share/spinup/bin
cp build/bin/spinup-${SPINUP_VERSION}${os_version} deb/spinup-${SPINUP_VERSION}${os_version}/usr/share/spinup/bin/spinup
cp build/DEBIAN/* deb/spinup-${SPINUP_VERSION}${os_version}/DEBIAN
cp -r build/share deb/spinup-${SPINUP_VERSION}${os_version}/usr

echo -e "\nVersion: $SPINUP_VERSION" >> deb/spinup-${SPINUP_VERSION}${os_version}/DEBIAN/control

if [ "$webkit_version" -eq "40" ]; then
echo "Depends: libgtk-3-0, libwebkit2gtk-4.0-dev" >> deb/spinup-${SPINUP_VERSION}${os_version}/DEBIAN/control
else
echo "Depends: libgtk-3-0, libwebkit2gtk-4.1-dev" >> deb/spinup-${SPINUP_VERSION}${os_version}/DEBIAN/control
fi
run: bash ./scripts/release/package-deb.sh

sudo chown -R root:root deb/spinup-${SPINUP_VERSION}${os_version}

dpkg-deb --build deb/spinup-${SPINUP_VERSION}${os_version}
done
shell: bash
# Package as .zip for macOS
- name: Package as .zip for macOS
if: runner.os == 'macOS'
working-directory: ${{ env.WORKING_DIRECTORY }}
run: bash ./scripts/release/package-zip.sh

# Upload build assets
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.build.name }} (${{ runner.os }})
path: |
*/bin/*/Contents/MacOS/*
*/bin/*.exe
*\bin\*.exe
*/spinup-*.deb
*.zip
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
*/bin/*/Contents/MacOS/*
*/bin/*.exe
*/spinup-*.deb
*.zip
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Commands are templates, so we can use variables that are then defined in the pro
spinup command add example "npm run dev -- --port {{port}}"
```

`port` and `domain` are reserved variables that are used to define the port and domain of the project. These are required to be when adding a project.
`port` and `domain` are reserved variables that are used to define the port and domain (based on the name) of the project. These are required to be when adding a project.

More information on variables can be found in the [Variables](#variables) section.

Expand All @@ -83,15 +83,15 @@ More information on variables can be found in the [Variables](#variables) sectio
To add a project you can use the following command:

```bash
spinup project add <name> <domain> <port> [commands...]
spinup project add <name> <port> [commands...]
```

This will create a configuration for the project in the sqlite database for spinup located in your `.config/spinup` folder.

Example:

```bash
spinup project add example example.local 8001 example1 example2
spinup project add example 8001 example1 example2
```

#### Removing a project
Expand Down
8 changes: 4 additions & 4 deletions app/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (a *App) GetProjects() []core.Project {
return projects
}

func (a *App) AddProject(name string, domain string, port int64, commandNames []string) error {
func (a *App) AddProject(name string, port int64, commandNames []string) error {
err := a.core.FetchCommands()

if err != nil {
Expand All @@ -46,7 +46,7 @@ func (a *App) AddProject(name string, domain string, port int64, commandNames []
return fmt.Errorf("error getting projects config: %s", err)
}

msg := a.core.AddProject(name, domain, port, commandNames)
msg := a.core.AddProject(name, port, commandNames)

if _, ok := msg.(*common.ErrMsg); ok {
fmt.Println(msg.GetText())
Expand All @@ -56,7 +56,7 @@ func (a *App) AddProject(name string, domain string, port int64, commandNames []
return nil
}

func (a *App) UpdateProject(name string, domain string, port int64, commandNames []string) error {
func (a *App) UpdateProject(name string, port int64, commandNames []string) error {
err := a.core.FetchCommands()

if err != nil {
Expand All @@ -69,7 +69,7 @@ func (a *App) UpdateProject(name string, domain string, port int64, commandNames
return fmt.Errorf("error getting projects config: %s", err)
}

msg := a.core.UpdateProject(name, domain, port, commandNames)
msg := a.core.UpdateProject(name, port, commandNames)

if _, ok := msg.(*common.ErrMsg); ok {
fmt.Println(msg.GetText())
Expand Down
80 changes: 80 additions & 0 deletions build/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -1,5 +1,85 @@
#!/usr/bin/env bash

# Make sure the script is being run as root
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root" >&2
exit 1
fi

# Get the home directory of the user that ran the script
USER_HOME=$(getent passwd $SUDO_USER | cut -d: -f6)

# Make sure the user's home directory exists
if [ ! -d "$USER_HOME" ]; then
echo "The user's home directory does not exist" >&2
exit 1
fi

#####################
### General setup ###
#####################

# Remove the old symlink if it exists and create a new one
rm -f /usr/bin/spinup
ln -s /usr/share/spinup/bin/spinup /usr/bin/spinup

# Set the correct permissions on the spinup directory
chown -R root:root /usr/share/spinup

###############
### Dnsmasq ###
###############

if [ ! -d /etc/dnsmasq.d ]; then
# Create the dnsmasq.d directory if it doesn't exist
mkdir /etc/dnsmasq.d
fi

# Check if the spinup.conf already exists in the dnsmasq.d directory
if [ ! -f /etc/dnsmasq.d/spinup.conf ]; then
# Link the dnsmasq configuration file for spinup to the dnsmasq.d directory if it doesn't exist
ln -s /usr/share/spinup/config/dnsmasq.conf /etc/dnsmasq.d/spinup.conf

# Restart the dnsmasq service
systemctl restart dnsmasq
fi

#############
### Nginx ###
#############

USER_SPINUP_NGINX_DIR="$USER_HOME/.config/spinup/nginx"
SPINUP_NGINX_DIR="/usr/share/spinup/config/nginx"

# Create the user's spinup nginx directory if it doesn't exist
mkdir -p $USER_SPINUP_NGINX_DIR

if [ ! -d $SPINUP_NGINX_DIR ]; then
# Link the user's spinup nginx directory to the spinup config directory if it doesn't exist
ln -s $USER_SPINUP_NGINX_DIR $SPINUP_NGINX_DIR
fi

# Add the user's spinup nginx directory to the nginx configuration
if ! grep -q "include ${SPINUP_NGINX_DIR}/\*.conf;" /etc/nginx/nginx.conf; then
# Make a backup of the nginx configuration file
cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak

# Add the include directive to the bottom of the http section in the nginx configuration file
sed -i '/http {/!b; :a; N; /}/!ba; s/}/ include '"${SPINUP_NGINX_DIR//\//\\/}"'\/\*.conf;\n}/' /etc/nginx/nginx.conf
fi

# Restart the nginx service
systemctl restart nginx

###############
### Sudoers ###
###############

# Add an include for the sudoers.d directory to the sudoers file if it doesn't already exist
if ! grep -q "^@includedir /etc/sudoers.d[[:space:]]*$" /etc/sudoers; then
# Make a backup of the sudoers file
cp /etc/sudoers /etc/sudoers.bak

# Add the include directive to the sudoers file
echo "@includedir /etc/sudoers.d" | visudo -c -f - &>/dev/null && echo "@includedir /etc/sudoers.d" | EDITOR='tee -a' visudo &>/dev/null
fi
28 changes: 28 additions & 0 deletions build/DEBIAN/postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

# Make sure the script is being run as root
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root" >&2
exit 1
fi

# Remove the link to the binary
rm -f /usr/bin/spinup

# Remove the spinup directory
rm -rf /usr/share/spinup

# Remove the link to the dnsmasq configuration file
rm -f /etc/dnsmasq.d/spinup.conf

# Restart the dnsmasq service
systemctl restart dnsmasq

# Remove include directive in the nginx configuration file
sed -i '/include \/usr\/share\/spinup\/config\/nginx\/\*.conf;/d' /etc/nginx/nginx.conf

# Restart the nginx service
systemctl restart nginx

# Remove the sudoers file
rm -f /etc/sudoers.d/spinup
3 changes: 3 additions & 0 deletions build/unix/etc/sudoers.d/spinup
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Allow sudo users to reload nginx without having to enter a password.
%sudo ALL=(ALL) NOPASSWD: /usr/bin/systemctl reload nginx
%sudo ALL=(ALL) NOPASSWD: /usr/bin/systemctl reload nginx.service
10 changes: 10 additions & 0 deletions build/unix/usr/share/spinup/config/dnsmasq.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Spinup configuration file for dnsmasq

# Require requests to have an actual domain unless specified in /etc/hosts
domain-needed

# Prevent reverse lookups to private IP ranges from being forwarded upstream
bogus-priv

# Forward all requests with TLD '.test' to localhost
address=/test/127.0.0.1
Loading