This module provides utilities for installing applications. It handles creating the necessary directory structure, moving the executable, copying the icon, and creating a .desktop file for Linux systems (or appropriate shortcuts on other OSes). It also includes functionality for listing and uninstalling installed applications, and initializing a new project.
Usage:
Installation:
deno run -A jsr:@sigmasd/install-app install <executable>Where <executable> is the compiled executable of your application.
You can also add this as a task to deno.json which can be more convenient:
{
"tasks": {
"compile": "deno compile --output my-app src/main.ts",
"install": "deno task compile && deno run -A jsr:@sigmasd/install-app install my-app"
}
}Listing Installed Applications:
deno run -A jsr:@sigmasd/install-app listUninstalling an Application:
deno run -A jsr:@sigmasd/install-app uninstall <app_name>Where <app_name> is the name of the application as specified in its
install.json file.
Initializing a new project:
deno run -A jsr:@sigmasd/install-app init <app_name>Where <app_name> is desired name for your application. This command will:
- Create an
assetsdirectory in the current working directory. - Create a default
install.jsonfile inside theassetsdirectory, pre-populated with the provided<app_name>. - Create a placeholder
icon.svgfile inside theassetsdirectory. - Print instructions for next steps (creating your application's entrypoint, compiling, customizing the icon and install.json, and running the install command).
Project Structure:
Your project should have the following structure:
my-app/
├── assets/
│ ├── install.json (Installation metadata)
│ └── <icon_name>.svg (Your application's icon, referenced in install.json)
├── src/
│ └── <entrypoint>.ts (Your application's main entry point)
└── ... other files ...
install.json Format:
Create a file named install.json within the assets directory. This file
contains metadata about your application:
name: The user-visible name of your application (e.g., "My Awesome App"). This is used in the.desktopfile. The executable file itself will be named based on a sanitized version of this name (or the sanitizedidif provided).id(Optional): A unique identifier for your application, typically in reverse domain name notation (e.g.,com.example.MyApp). Required for standard Linux integration. If provided:- The icon file (must be
.svg) will be installed to the standard system icon location (~/.local/share/icons/hicolor/scalable/apps/<id>.svg). - The
.desktopfile will be named<id>.desktopin~/.local/share/applications/. - The
Icon=field in the.desktopfile will use theid. - The internal installation directory will still use the sanitized
name.
- The icon file (must be
version: The version of your application (e.g., "1.0.0").description: A short description of your application.icon: The filename of your application's icon file (e.g., "my-app-icon.svg"). This file must be located in theassetsdirectory. Ifidis provided, this icon file must be an SVG.
Installation Process (Linux):
- Directory Creation: A base directory
deno-installed-appsis created within the user's data directory (~/.local/share/deno-installed-apps). Inside this, a directory for the application is created using the sanitizednamefrominstall.json(e.g.,~/.local/share/deno-installed-apps/my_awesome_app). Standard directories like~/.local/share/applicationsand~/.local/share/icons/hicolor/scalable/appsare ensured to exist. - File Placement:
- The compiled executable is moved into the application's specific directory
(
deno-installed-apps/<sanitized_name>/<sanitized_name>). - A
metadata.jsonfile (containing the contents ofinstall.json) is saved in the application's specific directory. - Icon:
- If
idis provided ininstall.json, the SVG icon is copied to~/.local/share/icons/hicolor/scalable/apps/<id>.svg. - If
idis not provided, the icon (any format) is copied into the application's specific directory (deno-installed-apps/<sanitized_name>/<icon_name>).
- If
- The compiled executable is moved into the application's specific directory
(
- Shortcut Creation (.desktop file):
- A
.desktopfile is created in~/.local/share/applications/. - Filename: Named
<id>.desktopifidis provided, otherwise<sanitized_name>.desktop. - Contents: Includes
Name,Exec(pointing to the executable indeno-installed-apps),Type,Categories, andIcon.- If
idis provided,Icon=<id>. - If
idis not provided,Icon=<full_path_to_icon_in_deno-installed-apps>.
- If
- A
Other OSes: Installation currently only supports Linux. A warning is printed on other operating systems.
Example:
Given install.json:
{
"name": "My App",
"id": "com.example.my_app",
"version": "1.0.0",
"description": "My awesome app",
"icon": "icon.svg"
}And executable my-app-bin.
Running deno run -A jsr:@sigmasd/install-app install my-app-bin on Linux will:
- Create
~/.local/share/deno-installed-apps/My_App/. - Move
my-app-binto~/.local/share/deno-installed-apps/My_App/My_App. - Copy
assets/icon.svgto~/.local/share/icons/hicolor/scalable/apps/com.example.my_app.svg. - Create
~/.local/share/applications/com.example.my_app.desktopwithName=My App,Exec=.../My_App/My_App, andIcon=com.example.my_app. - You might need to log out and log back to see the icon correctly in your application menu.
{ "name": "<app_name>", // The user-visible name of your application "id": "<app_id>", // Optional: Linux Application ID (e.g., com.example.MyApp), The id is important for the icon to work correctly. "version": "<version_string>", // The version of your application (informational) "description": "<description>", // A short description of your application (informational) "icon": "<icon_name>.svg" // The filename of your application's icon (within the assets directory) }