### Development Server Setup (Bash) Source: https://context7.com/sublimehq/packagecontrol.io/llms.txt Commands to set up and run the development environment. This includes creating and activating a virtual environment, installing dependencies, and starting the development server and asset compiler. ```bash # Set up virtual environment python -m venv venv . venv/bin/activate pip install -r setup/requirements.txt pip install -r setup/dev-requirements.txt # Start development server python dev.py # Start asset compiler (CoffeeScript/SCSS) python compile.py # Or use tmux script for full dev environment ./dev.sh ``` -------------------------------- ### Install Redis using Homebrew Source: https://github.com/sublimehq/packagecontrol.io/blob/master/setup/mac.md Installs Redis, an in-memory data structure store used for caching. Homebrew is used to simplify the installation. ```bash brew install redis ``` -------------------------------- ### Setup Virtual Environment and Install Dependencies (Bash) Source: https://github.com/sublimehq/packagecontrol.io/blob/master/production.md This snippet sets up a Python virtual environment named 'venv', activates it, and installs project dependencies from 'setup/requirements.txt'. It assumes Python 3 is available. ```bash python -m venv venv . venv/bin/active pip install -r setup/requirements.txt ``` -------------------------------- ### Install PostgreSQL using Homebrew Source: https://github.com/sublimehq/packagecontrol.io/blob/master/setup/mac.md Installs PostgreSQL, the database system used by Package Control. This command leverages Homebrew for a straightforward installation process. ```bash brew install postgresql ``` -------------------------------- ### Install Git for Version Control Source: https://github.com/sublimehq/packagecontrol.io/blob/master/setup/linux.md Installs Git, a distributed version control system. It is needed to download the 'package_control_channel' repository, which is used by the project's crawler. ```bash sudo apt install git ``` -------------------------------- ### Install PostgreSQL Database Source: https://github.com/sublimehq/packagecontrol.io/blob/master/setup/linux.md Installs PostgreSQL, a powerful open-source relational database system used by the Package Control project to store its data. This command uses apt for installation. ```bash sudo apt install postgresql ``` -------------------------------- ### Install Nginx with Lua and HTTP/2 Support Source: https://github.com/sublimehq/packagecontrol.io/blob/master/setup/mac.md Installs Nginx, the web server, with specific modules including Lua, set-misc, HTTP/2, and SUB. This command uses Homebrew and a custom tap for Nginx. ```bash brew tap denji/nginx brew install nginx-full --with-lua-module --with-set-misc-module --with-http2 --with-sub ``` -------------------------------- ### Python Virtual Environment and Package Installation Source: https://github.com/sublimehq/packagecontrol.io/blob/master/setup/mac.md Sets up a Python virtual environment named 'venv' and installs project dependencies from 'requirements.txt' and 'dev-requirements.txt'. This ensures isolated package management. ```bash python -m venv venv pip install -r setup/requirements.txt pip install -r setup/dev-requirements.txt ``` -------------------------------- ### Database Creation and Schema Setup Source: https://github.com/sublimehq/packagecontrol.io/blob/master/setup/mac.md Creates the 'package_control' PostgreSQL database and applies the necessary schema using the 'up.sql' script. This involves using standard PostgreSQL command-line tools. ```bash createdb -U postgres -E 'UTF-8' package_control psql -U postgres -d package_control -f sql/up.sql ``` -------------------------------- ### Install Node.js using Homebrew Source: https://github.com/sublimehq/packagecontrol.io/blob/master/setup/mac.md Installs Node.js, which is required for compiling handlebars and coffeescript files. This command assumes Homebrew is already installed on the system. ```bash brew install nodejs ``` -------------------------------- ### Install Development Libraries Source: https://github.com/sublimehq/packagecontrol.io/blob/master/setup/linux.md Installs development libraries for libxml2 and libxslt. These are often required for compiling certain Python packages that depend on XML and XSLT processing, crucial for development environments. ```bash sudo apt install libxml2-dev libxslt-dev ``` -------------------------------- ### Install Redis for Caching Source: https://github.com/sublimehq/packagecontrol.io/blob/master/setup/linux.md Installs Redis, an in-memory data structure store often used as a cache, message broker, and database. This is utilized by the Package Control project for performance enhancements. ```bash sudo apt install redis ``` -------------------------------- ### Install Nginx Web Server Source: https://github.com/sublimehq/packagecontrol.io/blob/master/setup/linux.md Installs Nginx, a high-performance web server and reverse proxy, which serves the Package Control website. The 'nginx-full' and 'nginx-extras' packages provide comprehensive Nginx functionality. ```bash sudo apt install nginx-full nginx-extras ``` -------------------------------- ### Run Production Application (Bash) Source: https://github.com/sublimehq/packagecontrol.io/blob/master/production.md This script starts the Package Control application in production mode. It is a shell script that likely configures and launches the application server. ```bash bash prod.sh ``` -------------------------------- ### Install and Configure Python 3 using pyenv Source: https://github.com/sublimehq/packagecontrol.io/blob/master/setup/mac.md Installs Python 3.6.8 using pyenv, a tool for managing multiple Python versions. This ensures a consistent Python environment for the project. ```bash brew install pyenv pyenv install 3.6.8 ``` -------------------------------- ### Set Up Virtualenv and Install Dependencies Source: https://github.com/sublimehq/packagecontrol.io/blob/master/development.md Steps to create a Python virtual environment and install project dependencies using pip. This ensures a isolated environment for development. ```bash python -m venv venv . venv/bin/active pip install -r setup/requirements.txt pip install -r setup/dev-requirements.txt ``` -------------------------------- ### Install Node.js for Compiling Files Source: https://github.com/sublimehq/packagecontrol.io/blob/master/setup/linux.md Installs Node.js, which is required for compiling handlebars and coffeescript files within the project. This command uses apt, the package manager for Debian-based Linux distributions. ```bash sudo apt install nodejs ``` -------------------------------- ### Start File Compiler Source: https://github.com/sublimehq/packagecontrol.io/blob/master/development.md Command to start the script that automatically compiles CoffeeScript and SCSS files. This script watches for changes and regenerates JS and CSS files accordingly. ```bash python compile.py ``` -------------------------------- ### Install Python 3 and Virtual Environment Tools Source: https://github.com/sublimehq/packagecontrol.io/blob/master/setup/linux.md Installs Python 3, the 'venv' module for creating virtual environments, and 'pip' for package management. These are essential for managing project dependencies and isolating the project's Python environment. ```bash sudo apt install python3 python3-venv python3-pip ``` -------------------------------- ### Downloader Backends Configuration (JSON) Source: https://github.com/sublimehq/packagecontrol.io/blob/master/app/html/docs/settings.html Specifies the HTTP(S) request backends to use, configurable per operating system. Options include 'urllib', 'curl', 'wget', and 'wininet' (Windows-only). 'curl' and 'wget' require the respective command-line tools to be installed and in the PATH. ```json { "windows": ["wininet"], "osx": ["urllib"], "linux": ["urllib", "curl", "wget"] } ``` -------------------------------- ### Install C Libraries for lxml Source: https://github.com/sublimehq/packagecontrol.io/blob/master/development.md Commands to install the development headers for libxml2 and libxslt, which are required for the lxml Python package. These commands vary depending on the package manager used by the operating system. ```bash apt-get install libxml2-dev libxslt-dev ``` ```bash yum install libxml2-devel libxslt-devel ``` ```bash pacaur -S libxml2 libxslt ``` -------------------------------- ### Run Development Server Source: https://github.com/sublimehq/packagecontrol.io/blob/master/development.md Command to start the local development server for packagecontrol.io. This script is used for local testing and development. ```bash python dev.py ``` -------------------------------- ### Platform-Specific Release (Mac/Linux) (JSON) Source: https://github.com/sublimehq/packagecontrol.io/blob/master/app/html/docs/submitting_a_package.html This JSON snippet demonstrates how to specify platform-specific releases for a package. This example indicates that the package is intended to work on macOS and Linux operating systems. ```json { "name": "Alignment", "details": "https://github.com/wbond/sublime_alignment", "releases": [ { "sublime_text": "*", "platforms": ["osx", "linux"], "tags": true } ] } ``` -------------------------------- ### Submit Package Usage Source: https://context7.com/sublimehq/packagecontrol.io/llms.txt Records package install, upgrade, and removal operations from Package Control clients. ```APIDOC ## GET /submit ### Description Records package install, upgrade, and removal operations from Package Control clients. This endpoint is called by the Package Control client to report usage data. ### Method GET ### Endpoint /submit ### Parameters #### Query Parameters - **package** (string) - Required - The name of the package. - **operation** (string) - Required - The type of operation (e.g., `install`, `upgrade`, `remove`). - **version** (string) - Required - The new version of the package. - **old_version** (string) - Optional - The previous version of the package (if applicable). - **package_control_version** (string) - Required - The version of Package Control being used. - **sublime_platform** (string) - Required - The platform of Sublime Text (e.g., `windows`, `osx`, `linux`). - **sublime_version** (string) - Required - The version of Sublime Text being used. ### Request Example `GET /submit?package=Emmet&operation=install&version=2.0.0&sublime_platform=windows&sublime_version=4126&package_control_version=3.2.2` ### Response #### Success Response (200) - **result** (string) - Indicates the outcome of the operation, typically "success". #### Error Response (400) - **result** (string) - Indicates an error, typically "error". - **message** (string) - A description of the error. #### Response Example ```json { "result": "success" } ``` ``` -------------------------------- ### GET /search/ Source: https://context7.com/sublimehq/packagecontrol.io/llms.txt Performs a full-text search for packages, with support for filtering by Sublime Text version and platform. ```APIDOC ## GET /search/ ### Description Performs a full-text search for packages with support for filtering by Sublime Text version and platform. ### Method GET ### Endpoint /search/ ### Parameters #### Path Parameters - **terms** (string) - Required - The search terms to query for. #### Query Parameters - **st_version** (string) - Optional - Filters results by Sublime Text version (e.g., '3', '4'). - **platform** (string) - Optional - Filters results by platform (e.g., 'windows', 'osx', 'linux'). #### Request Body None ### Response #### Success Response (200) - Returns a list of packages matching the search criteria. The structure of each package object in the list is similar to the response of the `/packages/` endpoint, but may be a subset of the full details. #### Response Example ```json [ { "name": "PackageName", "description": "A brief description of the matched package.", "authors": ["Author Name"], "platforms": ["windows", "osx", "linux"], "st_versions": [3, 4] } ] ``` ``` -------------------------------- ### Configure PostgreSQL Path in Profile Source: https://github.com/sublimehq/packagecontrol.io/blob/master/setup/linux.md Adds the PostgreSQL binary directory to the system's PATH environment variable by modifying the ~/.profile file. This ensures that PostgreSQL commands can be executed from any location in the terminal. ```bash if [ -d "/usr/postgresql/13/bin" ] ; then PATH="/usr/postgresql/13/bin:$PATH" fi ``` -------------------------------- ### Record Package Usage - Python Source: https://context7.com/sublimehq/packagecontrol.io/llms.txt Logs package installation, upgrade, and removal events from clients. Updates various database tables to track usage statistics, unique users, and aggregated counts. Requires detailed event information. ```python # app/models/package/usage.py from datetime import datetime from ...lib.connection import connection def record(details): """ Records install/upgrade/remove operation :param details: Dict with keys: ip, user_agent, package, operation, version, old_version, package_control_version, platform, sublime_version Operations: install, upgrade, remove Platforms: windows, osx, linux Updates tables: - usage (raw event log) - ips (unique users by platform) - unique_package_installs (per-package unique users) - daily_install_counts (aggregated daily stats) - install_counts (total aggregated stats) """ pass ``` -------------------------------- ### Popular Packages Source: https://context7.com/sublimehq/packagecontrol.io/llms.txt Lists packages ranked by their total unique install count. ```APIDOC ## GET /browse/popular ### Description Lists packages sorted by their total unique install count in descending order. ### Method GET ### Endpoint /browse/popular ### Query Parameters - **page** (integer) - Optional - The page number for paginated results. Defaults to 1. ### Response #### Success Response (200) - **packages** (array) - A list of popular packages. - **page** (integer) - The current page number. - **count** (integer) - The number of packages on the current page. - **begin** (integer) - The starting index of the results on the current page. - **end** (integer) - The ending index of the results on the current page. - **total** (integer) - The total number of popular packages. - **pages** (integer) - The total number of pages available. - **links** (array) - Pagination links. #### Response Example ```json { "packages": [ { "name": "MostInstalled", "description": "The most installed package.", "installed_count": 100000 // ... other package details } ], "page": 1, "count": 25, "begin": 0, "end": 25, "total": 5000, "pages": 200, "links": [ {"number": 1, "href": "?", "selected": true}, {"number": 2, "href": "?page=2"} // ... other links ] } ``` ``` -------------------------------- ### GET /browse Source: https://context7.com/sublimehq/packagecontrol.io/llms.txt Retrieves aggregated package data for the homepage, including popular labels, new and recently updated packages, top downloaded, trending packages, and top authors. ```APIDOC ## GET /browse ### Description Aggregates multiple package listings including labels, new packages, recently updated, top downloaded, and trending packages along with top authors for the homepage. ### Method GET ### Endpoint /browse ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **labels** (array) - Popular category labels with package counts. - **new** (array) - Recently added packages with details like name, platforms, and supported Sublime Text versions. - **updated** (array) - Recently updated packages. - **top** (array) - Most downloaded packages. - **trending** (array) - Currently trending packages. - **authors** (array) - Most prolific authors with their package counts. #### Response Example ```json { "labels": [ {"name": "color scheme", "packages": 245}, {"name": "syntax", "packages": 198} ], "new": [ {"name": "PackageName", "platforms": ["windows", "osx", "linux"], "st_versions": [3, 4]} ], "trending": [...], "authors": [ {"name": "AuthorName", "packages": 15} ] } ``` ``` -------------------------------- ### List Popular Packages (Python) Source: https://context7.com/sublimehq/packagecontrol.io/llms.txt Lists packages sorted by their total unique install count in descending order. It retrieves popular package data and includes pagination details for the response. ```python # Route: GET /browse/popular # Sorted by unique_installs descending @route('/browse/popular', name='popular') def popular_controller(): page = get_page() per_page = 25 results = package.find.top(details=True, page=page, limit=per_page) data = build_data(results, page, per_page) return render('popular', data) ``` -------------------------------- ### Package Destination Folder (String) Source: https://github.com/sublimehq/packagecontrol.io/blob/master/app/html/docs/settings.html Specifies the target folder where a newly created package will be copied. If left blank, it defaults to the user's Desktop. Caution: Setting this to the 'Installed Packages' directory can lead to overwriting source code on Sublime Text restart. ```string "" ``` -------------------------------- ### Run Tmux Development Script Source: https://github.com/sublimehq/packagecontrol.io/blob/master/development.md Executes a tmux script that sets up multiple terminal panes for development tasks, including the server, compiler, git terminal, and PostgreSQL CLI. Requires tmux to be installed. ```bash ./dev.sh ``` -------------------------------- ### Clone Package Control Channel Repository Source: https://github.com/sublimehq/packagecontrol.io/blob/master/setup/linux.md Clones the 'package_control_channel' repository from GitHub using Git. The '--depth 1' option ensures only the latest commit is downloaded, saving time and disk space. ```bash git clone --depth 1 https://github.com/wbond/package_control_channel channel ``` -------------------------------- ### Submit Package Usage Data (Python) Source: https://context7.com/sublimehq/packagecontrol.io/llms.txt Records package install, upgrade, and removal operations from Package Control clients. It captures client details from the request query parameters and logs the usage data. Dependencies include bottle, request, and custom package models. ```python # Route: GET /submit # Query parameters from Package Control client from bottle import route, request from ..models import package @route('/submit', name='submit') def submit_controller(): data = { 'ip': request.remote_addr, 'user_agent': request.headers.get('User-Agent', ''), 'package': request.query.package, 'operation': request.query.operation, # install|upgrade|remove 'version': request.query.version, 'old_version': request.query.old_version, 'package_control_version': request.query.package_control_version, 'platform': request.query.sublime_platform, # windows|osx|linux 'sublime_version': request.query.sublime_version } try: package.usage.record(data) return {'result': 'success'} except ValueError as e: return {'result': 'error', 'message': str(e)} # Example client request: # GET /submit?package=Emmet&operation=install&version=2.0.0&sublime_platform=windows&sublime_version=4126 ``` -------------------------------- ### Nginx Configuration for uWSGI Proxy (Nginx) Source: https://github.com/sublimehq/packagecontrol.io/blob/master/production.md This Nginx configuration block sets up a server to listen on port 80 for 'packagecontrol.io'. It proxies requests to a uWSGI application running on a Unix socket, enabling static file serving and dynamic content handling. ```nginx server { listen 80; server_name packagecontrol.io; root /path/to/packagecontrol.io; gzip on; gzip_disable "msie6"; gzip_vary on; gzip_types text/plain text/css application/json text/javascript application/x-javascript text/xml application/xml application/xml+rss image/svg+xml; try_files /public/$uri /app/html/$uri @uwsgi; location @uwsgi { uwsgi_pass unix:/var/tmp/uwsgi-packagecontrol.io.socket; include uwsgi_params; } } ``` -------------------------------- ### GET /packages/ Source: https://context7.com/sublimehq/packagecontrol.io/llms.txt Retrieves comprehensive information about a single package, including metadata, version history, install counts, and daily statistics. Supports renamed packages with 301 redirects. ```APIDOC ## GET /packages/ ### Description Retrieves comprehensive information about a single package including metadata, version history, install counts, and daily statistics. Supports renamed packages with 301 redirects. ### Method GET ### Endpoint /packages/ ### Parameters #### Path Parameters - **name** (string) - Required - The name of the package to retrieve. #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **name** (string) - The name of the package. - **description** (string) - A brief description of the package. - **authors** (array) - An array of strings representing the package authors. - **homepage** (string) - The URL of the package's homepage. - **labels** (array) - An array of strings representing the package labels. - **platforms** (array) - An array of strings representing the platforms the package supports. - **st_versions** (array) - An array of integers representing the Sublime Text versions the package supports. - **versions** (array) - An array of version objects, each containing version number, prerelease status, supported platforms, and ST versions. - **installs** (object) - An object containing installation statistics, including total installs, platform-specific installs, and daily install data. #### Response Example ```json { "name": "PackageName", "description": "Package description text", "authors": ["Author One", "Author Two"], "homepage": "https://github.com/user/repo", "labels": ["syntax", "language"], "platforms": ["windows", "osx", "linux"], "st_versions": [3, 4], "versions": [ {"version": "1.2.0", "prerelease_version": null, "platforms": ["*"], "st_versions": [3, 4]} ], "installs": { "total": 125000, "windows": 75000, "osx": 35000, "linux": 15000, "daily": { "dates": ["2024-01-15", "2024-01-14"], "data": [ {"platform": "Windows", "totals": [150, 145]}, {"platform": "Mac", "totals": [80, 75]}, {"platform": "Linux", "totals": [40, 38]} ] } } } ``` ``` -------------------------------- ### Running Background Tasks (Bash) Source: https://context7.com/sublimehq/packagecontrol.io/llms.txt Demonstrates how to execute background tasks within the Package Control IO project. Tasks are run using the `tasks.py` script, specifying the task name as an argument. ```bash # Execute a background task python tasks.py # Available tasks: ``` -------------------------------- ### Package Info for Bitbucket Hosting (JSON) Source: https://github.com/sublimehq/packagecontrol.io/blob/master/app/html/docs/submitting_a_package.html This JSON structure defines package information for hosting on Bitbucket. Similar to GitHub hosting, it specifies the package name, details URL, and release configuration, including Sublime Text compatibility and tag usage. ```json { "name": "Alignment", "details": "https://bitbucket.org/wbond/sublime_alignment", "releases": [ { "sublime_text": "*", "tags": true } ] } ``` -------------------------------- ### Database Configuration (YAML) Source: https://context7.com/sublimehq/packagecontrol.io/llms.txt Defines database connection parameters for different environments (development and production). Includes database name, user, host, and password, with production using an environment variable for the password. ```yaml # config/db.yml dev: database: package_control user: package_control host: localhost prod: database: package_control user: package_control password: ${DB_PASSWORD} host: db.example.com ``` -------------------------------- ### New Packages Listing Source: https://context7.com/sublimehq/packagecontrol.io/llms.txt Retrieves a paginated list of recently created packages. ```APIDOC ## GET /browse/new ### Description Returns a paginated list of the most recently created packages. ### Method GET ### Endpoint /browse/new ### Query Parameters - **page** (integer) - Optional - The page number for paginated results. Defaults to 1. ### Response #### Success Response (200) - **packages** (array) - A list of new packages. - **page** (integer) - The current page number. - **count** (integer) - The number of packages on the current page. - **begin** (integer) - The starting index of the results on the current page. - **end** (integer) - The ending index of the results on the current page. - **total** (integer) - The total number of packages. - **pages** (integer) - The total number of pages available. - **links** (array) - Pagination links. #### Response Example ```json { "packages": [ { "name": "NewPackage1", "description": "A brand new package.", "version": "1.0.0" // ... other package details } ], "page": 1, "count": 25, "begin": 0, "end": 25, "total": 5234, "pages": 210, "links": [ {"number": 1, "href": "?", "selected": true}, {"number": 2, "href": "?page=2"} // ... other links ] } ``` ``` -------------------------------- ### Fetch Packages by Criteria - Python Source: https://context7.com/sublimehq/packagecontrol.io/llms.txt Retrieves packages based on various criteria such as creation date, last modified date, download count, trending score, or name. Supports pagination and optional detailed information. Utilizes caching for performance. ```python from ...lib.connection import connection from ... import cache @cache.region.cache_on_arguments() def new(details=False, page=1, limit=10): """ Fetches the most recently created packages :param details: Include description and authors :param page: Page number (1-indexed) :param limit: Max packages per page :return: List of package dicts or {packages, total} dict """ return _common_sql(details, "", "ps.first_seen DESC", page, limit) @cache.region.cache_on_arguments() def updated(details=False, page=1, limit=10): """Fetches most recently modified packages""" return _common_sql(details, "", "p.last_modified DESC", page, limit) @cache.region.cache_on_arguments() def top(details=False, page=1, limit=10): """Fetches most downloaded packages by unique installs""" return _common_sql(details, "AND ic.unique_installs IS NOT NULL AND ic.unique_installs > 0", "ic.unique_installs DESC", page, limit) @cache.region.cache_on_arguments() def trending(details=False, page=1, limit=10): """Fetches packages trending based on z-value score""" return _common_sql(details, "AND ps.z_value IS NOT NULL", "ps.trending_rank ASC", page, limit) def by_name(name): """ Fetches full package details including versions, installs, readme Raises NotFoundError or RenamedError as appropriate """ pass @cache.region.cache_on_arguments() def search(terms, order_by='relevance', page=1, limit=50): """ Full-text search supporting: - Name, description, author matching - Filter tags: :st2, :st3, :st4, :win, :osx, :linux - Sort by: relevance, popularity """ pass ``` -------------------------------- ### List New Packages (Python) Source: https://context7.com/sublimehq/packagecontrol.io/llms.txt Provides a paginated list of recently created packages. It fetches package data using the 'package.find.new' method and formats it for rendering with pagination details. ```python # Route: GET /browse/new # Query parameter: page (default: 1) from bottle import route from ..models import package from ..render import render from ..lib.paginating_controller import get_page, build_data @route('/browse/new', name='new') def new_controller(): page = get_page() per_page = 25 results = package.find.new(details=True, page=page, limit=per_page) data = build_data(results, page, per_page) return render('new', data) # Response includes full package details with pagination: # { # "packages": [...], # "page": 1, # "count": 25, # "begin": 0, # "end": 25, # "total": 5234, # "pages": 210, # "links": [{"number": 1, "href": "?", "selected": true}, ...] # } ``` -------------------------------- ### Compile Production Assets (Python) Source: https://github.com/sublimehq/packagecontrol.io/blob/master/production.md This command compiles JavaScript and CSS files for production use, creating minified versions in the 'public/' directory. It requires a 'compile.py' script in the project root. ```python python compile.py prod ``` -------------------------------- ### Package Profiles Configuration (JSON) Source: https://github.com/sublimehq/packagecontrol.io/blob/master/app/html/docs/settings.html Defines custom packaging profiles for different release types (e.g., platform-specific, binary-only). Each profile can override top-level settings like 'dirs_to_ignore', 'files_to_ignore', 'files_to_include', and 'package_destination'. The 'Default' profile uses the top-level settings. ```json { "Binaries Only": { "files_to_ignore": [ "*.py", ".hgignore", ".gitignore", ".bzrignore", "*.sublime-project", "*.sublime-workspace", "*.tmTheme.cache" ], "files_to_include": [ "__init__.py" ] } } ``` -------------------------------- ### Refresh Package Stats Task (Python) Source: https://context7.com/sublimehq/packagecontrol.io/llms.txt Recalculates package popularity and trending rankings. It updates the `installs_rank` based on unique installs and calculates trending using a z-value formula over a defined historical and recent window. ```python # Run: python tasks.py refresh_package_stats # app/models/package/stats.py def refresh(): """ Updates installs_rank based on unique_installs (descending) Calculates trending using z-value: z = (recent_installs - historical_mean) / historical_stddev Uses 6-week historical window, 2-day recent window Requires minimum 10 daily installs to qualify for trending """ pass ``` -------------------------------- ### Browse Packages Homepage - Python Source: https://context7.com/sublimehq/packagecontrol.io/llms.txt Aggregates and returns multiple package listings for the homepage, including labels, new, recently updated, top downloaded, and trending packages, as well as top authors. It uses the Bottle framework and custom models for data retrieval. ```python # Route: GET /browse # Returns aggregated package data for the homepage from bottle import route from ..models import package, label, author from ..render import render @route('/browse', name='browse') def browse_controller(): data = { 'labels': label.list(), # Popular category labels 'new': package.find.new(), # Recently added packages 'updated': package.find.updated(), # Recently updated packages 'top': package.find.top(), # Most downloaded packages 'trending': package.find.trending(), # Currently trending 'authors': author.list() # Most prolific authors } return render('browse', data) # Example response structure (JSON): { "labels": [ {"name": "color scheme", "packages": 245}, {"name": "syntax", "packages": 198} ], "new": [ {"name": "PackageName", "platforms": ["windows", "osx", "linux"], "st_versions": [3, 4]} ], "trending": [...], "authors": [ {"name": "AuthorName", "packages": 15} ] } ``` -------------------------------- ### Package Info for GitHub Hosting (JSON) Source: https://github.com/sublimehq/packagecontrol.io/blob/master/app/html/docs/submitting_a_package.html This JSON structure defines package information for hosting on GitHub. It includes the package name, a URL to its details repository, and release information specifying compatibility with Sublime Text versions and tag-based releases. ```json { "name": "Alignment", "details": "https://github.com/wbond/sublime_alignment", "releases": [ { "sublime_text": "*", "tags": true } ] } ``` -------------------------------- ### Gather System Stats Task (Python) Source: https://context7.com/sublimehq/packagecontrol.io/llms.txt Collects ecosystem-wide statistics for Package Control. This includes total counts of packages, authors, users, and labels, as well as breakdowns by platform, Sublime Text version, and daily installs. ```python # Run: python tasks.py gather_system_stats # Collects: # - total_packages, total_authors, total_users, total_labels # - Platform breakdown: windows_users, osx_users, linux_users # - ST version breakdown: st2_packages, st3_packages, st4_packages # - Daily installs by platform # - Cross-platform compatibility stats ``` -------------------------------- ### Generate RSS Feed for New Packages (Python) Source: https://context7.com/sublimehq/packagecontrol.io/llms.txt Generates an application/xml RSS feed for newly added packages. It fetches the latest packages, calculates MD5 hashes for package names, and renders the data using a 'rss' template. Dependencies include hashlib, datetime, bottle, and custom models/render functions. ```python import hashlib from datetime import datetime from bottle import route, response from ..models import package from ..render import render @route('/browse/new/rss', name='rss') def rss_controller(): now = datetime.utcnow() today = now.date() result = package.find.new(details=True, page=1, limit=25) for pkg in result['packages']: pkg['md5'] = hashlib.md5(pkg['name'].encode('utf-8')).hexdigest() data = { 'packages': result['packages'], 'year': today.strftime('%Y') } response.content_type = 'application/xml; charset=UTF-8' return render('rss', data) ```