diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fc4c7e9..2047d36 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,6 +2,7 @@ name: CI on: push: { branches: [master] } workflow_dispatch: +permissions: write-all jobs: build: @@ -32,7 +33,7 @@ jobs: echo VERSION=`git describe --tags --abbrev=0 --match "v*" | tail -c +2` >> $GITHUB_ENV echo FULL_VERSION=`git describe --tags --match "v*" | tail -c +2` >> $GITHUB_ENV echo ARCH=${{ matrix.config.arch }}-${{ matrix.config.platform }} >> $GITHUB_ENV - echo BIN=lpm.${{ matrix.config.arch }}-${{ matrix.config.platform }}${{ matrix.config.suffix }} >> $GITHUB_ENV + echo BIN=ppm.${{ matrix.config.arch }}-${{ matrix.config.platform }}${{ matrix.config.suffix }} >> $GITHUB_ENV echo HOSTCC=gcc >> $GITHUB_ENV - name: Setup (Linux) @@ -85,19 +86,19 @@ jobs: - name: Build run: | - ./build.sh clean && ./build.sh -DLPM_STATIC -DLPM_VERSION='"'$FULL_VERSION-$ARCH'"' -static -O3 + ./build.sh clean && ./build.sh -DPPM_STATIC -DPPM_VERSION='"'$FULL_VERSION-$ARCH'"' -static -O3 - - name: Run Tests - if: ${{ matrix.config.native }} - run: | - cp $BIN lpm && ./lpm test t/run.lua + # - name: Run Tests + # if: ${{ matrix.config.native }} + # run: | + # cp $BIN ppm && ./ppm test t/run.lua # - name: Package Debian/Ubuntu - # env: { ARCH: "amd64", DESCRIPTION: "A plugin manager for the lite-xl text editor.", MAINTAINER: "Adam Harrison " } + # env: { ARCH: "amd64", DESCRIPTION: "A plugin manager for the pragtical text editor.", MAINTAINER: "Adam Harrison " } # run: | - # export NAME=lpm_$VERSION.0-$REV""_$ARCH - # mkdir -p $NAME/usr/bin $NAME/DEBIAN && cp lpm $NAME/usr/bin - # printf "Package: lpm\nVersion: $VERSION\nArchitecture: $ARCH\nMaintainer: $MAINTAINER\nDescription: $DESCRIPTION\n" > $NAME/DEBIAN/control + # export NAME=ppm_$VERSION.0-$REV""_$ARCH + # mkdir -p $NAME/usr/bin $NAME/DEBIAN && cp ppm $NAME/usr/bin + # printf "Package: ppm\nVersion: $VERSION\nArchitecture: $ARCH\nMaintainer: $MAINTAINER\nDescription: $DESCRIPTION\n" > $NAME/DEBIAN/control # dpkg-deb --build --root-owner-group $NAME - name: Upload Artifacts @@ -128,11 +129,11 @@ jobs: echo VERSION=`git describe --tags --abbrev=0 --match "v*" | tail -c +2` >> $GITHUB_ENV echo REV=$((`git describe --tags --match "v*" | sed 's/.*-\([0-9]*\)-.*/\1/' | sed s/^v.*//` + 1)) >> $GITHUB_ENV echo ARCH=${{ matrix.config.arch }}-darwin >> $GITHUB_ENV - echo BIN=lpm.${{ matrix.config.arch }}-darwin >> $GITHUB_ENV + echo BIN=ppm.${{ matrix.config.arch }}-darwin >> $GITHUB_ENV - name: Build run: | - ./build.sh clean && ./build.sh -DLPM_STATIC -DLPM_VERSION='"'$FULL_VERSION-$ARCH'"' -O3 + ./build.sh clean && ./build.sh -DPPM_STATIC -DPPM_VERSION='"'$FULL_VERSION-$ARCH'"' -O3 - name: Upload Artifacts uses: actions/upload-artifact@v4 @@ -158,7 +159,7 @@ jobs: - name: Download Artifacts uses: actions/download-artifact@v4 with: - pattern: lpm.* + pattern: ppm.* path: artifacts merge-multiple: true @@ -179,11 +180,3 @@ jobs: fi git tag -f continuous git push -f origin refs/tags/continuous - - - name: Discord Notification - env: { DISCORD_WEBHOOK: "${{ secrets.DISCORD_WEBHOOK }}" } - run: | - if [[ -n "$DISCORD_WEBHOOK" ]] && [[ `git tag --points-at HEAD v* | head -c 1` == "v" ]]; then - perl -e 'use JSON qw(encode_json from_json); $/ = undef; print encode_json({ content => "## Lite XL Plugin Manager $ENV{VERSION} has been released!\nhttps://github.com/lite-xl/lite-xl-plugin-manager/releases/tag/v$ENV{VERSION}\n@release:lpm\n### Changes in $ENV{VERSION}:\n" . <> })' < NOTES.md | - curl -H 'Content-Type:application/json' $DISCORD_WEBHOOK -X POST -d "$( 100 character filenames. Thank you @Gaspartcho! * Fixed bug that tried to uninstall core depednencies. Thanks @Gaspartcho! -* Fixed issue with `lpm` not correctly renaming bottles, or moving files around. +* Fixed issue with `ppm` not correctly renaming bottles, or moving files around. * Added in ability to `--mask`, so that you can explicitly cut out dependencies that you think aren't requried on install/uninstall. * Made `--ephemeral` bottles have distinct hashes from non-epehemeral ones. * Fixed a bug where we tried to double-install depdendencies if they were explicitly specified in the install command. @@ -91,10 +91,10 @@ * Added in `font` as a new `type` for addons. * Fixed a bug that made it so that complex plugins that didn't specify a path would clone their repos, instead of just downloading the listed files. -* Fixed bugs around specifying a lite-xl to add to the system. -* Added documentation for `lpm hash`. -* Added in ability to automatically update checksums in manifests under certain circumstances with `lpm update-checksums`. -* Improved handling around adding disparate versions of lite-xl with binary, data and user directories in different places. +* Fixed bugs around specifying a pragtical to add to the system. +* Added documentation for `ppm hash`. +* Added in ability to automatically update checksums in manifests under certain circumstances with `ppm update-checksums`. +* Improved handling around adding disparate versions of pragtical with binary, data and user directories in different places. # 1.0.14 @@ -106,9 +106,9 @@ # 1.0.13 * Merged in `welcome.lua` as a plugin. -* Added in ability to specify `--ephemeral` when running bottles; cleans up the bottle when lite-xl exits. +* Added in ability to specify `--ephemeral` when running bottles; cleans up the bottle when pragtical exits. * Improved error handling by removing unecessary line numbers. -* Made running of `lpm` more deterministic. +* Made running of `ppm` more deterministic. * Made it so that we only `fetch` when necessary in order to speed things up. * Fixed some errors where cache wasn't being invaldiated approprirately. * Allowed for short looks up when referencing commit ids. @@ -139,9 +139,9 @@ # 1.0.9 -* `lpm` now automatically extracts and chmod's `.gz` files. +* `ppm` now automatically extracts and chmod's `.gz` files. * Added in preprocessor guard for shallow cloning to allow non-bleeding-edge `libgit2` linkings. -* Fixed bug where dangling symlinks of lite binaries in `$PATH` would cause an error. +* Fixed bug where dangling symlinks of pragtical binaries in `$PATH` would cause an error. # 1.0.8 @@ -149,8 +149,8 @@ * Added method to grab and install orphan plugins from one-off repos. * Passed debug build status through to underlying libraries. * Fixed bug where we compared sizes of folders to determined if they were the same. -* Made it so you can set the define LPM_DEFAULT_REPOSITORY if you want to build a custom manager. -* Made it so tests run more smoothly, and will always use the lpm you compiled, instead of system lpm. +* Made it so you can set the define PPM_DEFAULT_REPOSITORY if you want to build a custom manager. +* Made it so tests run more smoothly, and will always use the ppm you compiled, instead of system ppm. * Normalized paths on windows to backslashes for consistency. # 1.0.7 @@ -164,7 +164,7 @@ * Allowed for dashes in auto-generated ids. * Fixed a bug that stopped things form working when explicitly calling `init`. * Allowed `run` to use `--remotes`. -* Fixed bug for auto-detecting data directories, when determining system `lite-xl`. +* Fixed bug for auto-detecting data directories, when determining system `pragtical`. # 1.0.6 @@ -174,7 +174,7 @@ # 1.0.5 -* Marked `lpm` for `plugin_manager` as optional. +* Marked `ppm` for `plugin_manager` as optional. * Made `--help` and `help` output on `stdout`, rather than `stderr`, following convention. * Removed system configuration search paths for `git`. * Removed `xxd` as a build dependency. @@ -186,7 +186,7 @@ # 1.0.4 * Added in metapackage support into manifest and SPEC. -* Fixed issue with system lite-xls not being detected correctly. +* Fixed issue with system pragticals not being detected correctly. * Colorized output by default. * Added in NO_COLOR standard. * Updated SPEC and fixed a few spelling/grammatical errors. @@ -201,14 +201,14 @@ * Suppresses the progress bar by default if we're not on a TTY. * Added `url` as a field to `SPEC.md`. * Modified `run` so that it'll use the system version if you don't specify one. -* Added the ability to specify a repo url as part of `run`, so you can easily test new plugin branches and their plugins without actually modifying your lpm state. +* Added the ability to specify a repo url as part of `run`, so you can easily test new plugin branches and their plugins without actually modifying your ppm state. * Fixed a few typos. * Fixed issue with `run` not handling cases where plugins were either orphaned or core plugins, which would cause the bottle to be incorrectly constructed. -* Fixed issue where you could add non-numeric lite versions. -* Fixed issue where tables generated with lpm didn't annotate non-remote url plugins with \*. +* Fixed issue where you could add non-numeric pragtical versions. +* Fixed issue where tables generated with ppm didn't annotate non-remote url plugins with \*. * Fixed a memory leak. * Added in warning to let people know when stubs are mismatching versions. -* Added in warning when we cannot acquire an lpm global lock, and also made it so we do not lock upon running something. +* Added in warning when we cannot acquire an ppm global lock, and also made it so we do not lock upon running something. * Better error handling for invalid manifests, specifically when paths for plugins don't exist. * Fixed issue with permissions not being recorded correctly when extracting from a zip file. * Added in --reinstall flag. @@ -223,28 +223,28 @@ # 1.0.0 -Initial release of `lpm`. +Initial release of `ppm`. ``` -Usage: lpm COMMAND [...ARGUMENTS] [--json] [--userdir=directory] +Usage: ppm COMMAND [...ARGUMENTS] [--json] [--userdir=directory] [--cachedir=directory] [--quiet] [--version] [--help] [--remotes] [--ssl-certs=directory/file] [--force] [--arch=x86_64-linux] [--assume-yes] [--no-install-optional] [--verbose] [--mod-version=3] [--datadir=directory] [--binary=path] [--symlink] [--post] -LPM is a package manager for `lite-xl`, written in C (and packed-in lua). +PPM is a package manager for `pragtical`, written in C (and packed-in lua). It's designed to install packages from our central github repository (and -affiliated repositories), directly into your lite-xl user directory. It can -be called independently, for from the lite-xl `addon_manager` addon. +affiliated repositories), directly into your pragtical user directory. It can +be called independently, for from the pragtical `addon_manager` addon. -LPM will always use https://github.com/lite-xl/lite-xl-plugin-manager as its base +PPM will always use https://github.com/pragtical/plugin-manager as its base repository, if none are present, and the cache directory does't exist, but others can be added, and this base one can be removed. It has the following commands: - lpm init [repo 1] [repo 2] [...] Implicitly called before all commands + ppm init [repo 1] [repo 2] [...] Implicitly called before all commands if necessary, but can be called independently to save time later, or to set things up differently. @@ -258,74 +258,74 @@ It has the following commands: If "none" is specified, initializes an empty repository list. - lpm repo list List all extant repos. - lpm [repo] add Add a source repository. + ppm repo list List all extant repos. + ppm [repo] add Add a source repository. [...] - lpm [repo] rm Remove a source repository. + ppm [repo] rm Remove a source repository. [...] - lpm [repo] update [] Update all/the specified repos. + ppm [repo] update [] Update all/the specified repos. [...] - lpm [plugin|library|color] install Install specific addons. + ppm [plugin|library|color] install Install specific addons. [:] If installed, upgrades. [...:] - lpm [plugin|library|color] uninstall Uninstall the specific addon. + ppm [plugin|library|color] uninstall Uninstall the specific addon. [...] - lpm [plugin|library|color] reinstall Uninstall and installs the specific addon. + ppm [plugin|library|color] reinstall Uninstall and installs the specific addon. [...] - lpm [plugin|library|color] list List all/associated addons. + ppm [plugin|library|color] list List all/associated addons. [...] - lpm upgrade Upgrades all installed addons + ppm upgrade Upgrades all installed addons to new version if applicable. - lpm [lite-xl] install Installs lite-xl. Infers the + ppm [pragtical] install Installs pragtical. Infers the [binary] [datadir] paths on your system if not supplied. Automatically switches to be your system default if path auto inferred. - lpm lite-xl add Adds a local version of lite-xl to + ppm pragtical add Adds a local version of pragtical to the managed list, allowing it to be easily bottled. - lpm lite-xl remove Removes a local version of lite-xl + ppm pragtical remove Removes a local version of pragtical from the managed list. - lpm [lite-xl] switch [] Sets the active version of lite-xl + ppm [pragtical] switch [] Sets the active version of pragtical to be the specified version. Auto-detects - current install of lite-xl; if none found + current install of pragtical; if none found path can be specified. - lpm lite-xl list [name pattern] Lists all installed versions of - [...filters] lite-xl. Can specify the flags listed + ppm pragtical list [name pattern] Lists all installed versions of + [...filters] pragtical. Can specify the flags listed in the filtering seciton. - lpm run [...addons] Sets up a "bottle" to run the specified - lite version, with the specified addons + ppm run [...addons] Sets up a "bottle" to run the specified + pragtical version, with the specified addons and then opens it. - lpm describe [bottle] Describes the bottle specified in the form + ppm describe [bottle] Describes the bottle specified in the form of a list of commands, that allow someone else to run your configuration. - lpm table [readme path] Formats a markdown table of all specified + ppm table [readme path] Formats a markdown table of all specified addons. Dumps to stdout normally, but if supplied a readme, will remove all tables from the readme, and append the new one. - lpm purge Completely purge all state for LPM. - lpm - Read these commands from stdin in + ppm purge Completely purge all state for PPM. + ppm - Read these commands from stdin in an interactive print-eval loop. - lpm help Displays this help text. + ppm help Displays this help text. Flags have the following effects: --json Performs all communication in JSON. - --userdir=directory Sets the lite-xl userdir manually. - If omitted, uses the normal lite-xl logic. + --userdir=directory Sets the pragtical userdir manually. + If omitted, uses the normal pragtical logic. --cachedir=directory Sets the directory to store all repositories. --tmpdir=directory During install, sets the staging area. --datadir=directory Sets the data directory where core addons are located - for the system lite-xl. - --binary=path Sets the lite-xl binary path for the system lite-xl. + for the system pragtical. + --binary=path Sets the pragtical binary path for the system pragtical. --verbose Spits out more information, including intermediate steps to install and whatnot. --quiet Outputs nothing but explicit responses. - --mod-version=version Sets the mod version of lite-xl to install addons. + --mod-version=version Sets the mod version of pragtical to install addons. --version Returns version information. --help Displays this help text. --ssl-certs Sets the SSL certificate store. Can be a directory, @@ -375,12 +375,12 @@ in any circumstance unless explicitly supplied. There exist also other debug commands that are potentially useful, but are not commonly used publically. - lpm test [test file] Runs the specified test suite. - lpm table [...filters] Generates markdown table for the given + ppm test [test file] Runs the specified test suite. + ppm table [...filters] Generates markdown table for the given manifest. Used by repositories to build READMEs. - lpm download [target] Downloads the specified URL to stdout, + ppm download [target] Downloads the specified URL to stdout, or to the specified target file. - lpm extract Extracts the specified archive at + ppm extract Extracts the specified archive at [target] target, or the current working directory. ``` diff --git a/LICENSE b/LICENSE index 808d59d..140052b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ -## LPM License +## PPM License -Copyright (c) 2022 lite-xl Team +Copyright (c) 2022 pragtical Team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/README.md b/README.md index 8688614..b93747d 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,19 @@ -# Lite XL Plugin Manager (lpm) +**Warning:** This repository could be regularly rebased + +# Pragtical Plugin Manager (ppm) ![image](https://user-images.githubusercontent.com/1034518/216748882-3ae8c8d4-a767-4d97-acc4-c1cde7e3e331.png) A standalone binary that provides an easy way of installing, and uninstalling -plugins from lite-xl, as well as different version of lite-xl. +plugins from pragtical, as well as different version of pragtical. Can be used by a package manager plugin that works from inside the editor and calls this binary. -Also contains a `plugin_manager.lua` plugin to integrate the binary with lite-xl in +Also contains a `plugin_manager.lua` plugin to integrate the binary with pragtical in the form of an easy-to-use GUI. -By default in releases, `lpm` will automatically consume the `manifest.json` +By default in releases, `ppm` will automatically consume the `manifest.json` in the `latest` branch of this repository, which corresponds to the most recent versioned release. @@ -19,26 +21,26 @@ Conforms to [SCPS3](https://github.com/adamharrison/straightforward-c-project-st ## Status -`lpm` 1.0 has been just released, and so may still contain bugs, but is generally feature-complete. +`ppm` 1.0 has been just released, and so may still contain bugs, but is generally feature-complete. ## Specification -For details about the `manifest.json` files that `lpm` consumes, +For details about the `manifest.json` files that `ppm` consumes, [see here](SPEC.md). ## Quickstart -The fastest way to get started with lpm is to simply pull a release. +The fastest way to get started with ppm is to simply pull a release. ``` -wget https://github.com/lite-xl/lite-xl-plugin-manager/releases/download/latest/lpm.x86_64-linux -O lpm && chmod +x lpm +wget https://github.com/pragtical/plugin-manager/releases/download/latest/ppm.x86_64-linux -O ppm && chmod +x ppm ``` -If you want to get the GUI version installed with lite-xl, you can tell `lpm` to install `plugin_manager`, which will allow -you to access `Plugin Manager: Show` in the command palette in `lite-xl`. +If you want to get the GUI version installed with pragtical, you can tell `ppm` to install `plugin_manager`, which will allow +you to access `Plugin Manager: Show` in the command palette in `pragtical`. ``` -./lpm install plugin_manager --assume-yes +./ppm install plugin_manager --assume-yes ``` ### Compilation @@ -47,46 +49,46 @@ If you have a C compiler, and `git`, and want to compile from scratch, you can do: ``` -git clone https://github.com/lite-xl/lite-xl-plugin-manager.git \ - --shallow-submodules --recurse-submodules && cd lite-xl-plugin-manager &&\ - ./build.sh -DLPM_STATIC && ./lpm +git clone https://github.com/pragtical/plugin-manager.git \ + --shallow-submodules --recurse-submodules && cd plugin-manager &&\ + ./build.sh -DPPM_STATIC && ./ppm ```` If you want to build it quickly, and have the right modules installed, you can do: ``` -./build.sh -lgit2 -lzip -llua -lm -lmbedtls -lmbedx509 -lmbedcrypto -lz -DLPM_STATIC +./build.sh -lgit2 -lzip -llua -lm -lmbedtls -lmbedx509 -lmbedcrypto -lz -DPPM_STATIC ``` OR ``` -gcc src/lpm.c lib/microtar/src/microtar.c -Ilib/microtar/src -lz -lgit2 \ - -lzip -llua -lm -lmbedtls -lmbedx509 -lmbedcrypto -o lpm +gcc src/ppm.c lib/microtar/src/microtar.c -Ilib/microtar/src -lz -lgit2 \ + -lzip -llua -lm -lmbedtls -lmbedx509 -lmbedcrypto -o ppm ``` CI is enabled on this repository, so you can grab Windows and Linux builds from the -`continuous` [release page](https://github.com/lite-xl/lite-xl-plugin-manager/releases/tag/continuous), -which is a nightly, or the `latest` [release page](https://github.com/lite-xl/lite-xl-plugin-manager/releases/tag/latest), +`continuous` [release page](https://github.com/pragtical/plugin-manager/releases/tag/continuous), +which is a nightly, or the `latest` [release page](https://github.com/pragtical/plugin-manager/releases/tag/latest), which holds the most recent released version. There are also tagged releases, for specified versions. -You can get a feel for how to use `lpm` by typing `./lpm --help`. +You can get a feel for how to use `ppm` by typing `./ppm --help`. -You can also use `scoop` to grab `lpm`: +You can also use `scoop` to grab `ppm`: ``` -scoop install https://raw.githubusercontent.com/lite-xl/lite-xl-plugin-manager/refs/heads/master/lite-xl-plugin-manager.json +scoop install https://raw.githubusercontent.com/pragtical/plugin-manager/refs/heads/master/pragtical-plugin-manager.json ``` -Please note, that _meson_ is _not_ necessarily the best way to compile `lpm`. If you have troubles with it, please do consider using the build.sh script. +Please note, that _meson_ is _not_ necessarily the best way to compile `ppm`. If you have troubles with it, please do consider using the build.sh script. ## Supporting Libraries / Dependencies As seen in the `lib` folder, the following external libraries are used to -build `lpm` as git submodules: +build `ppm` as git submodules: * `lua` (core program written in) * `mbedtls` (https/SSL support) @@ -95,12 +97,12 @@ build `lpm` as git submodules: * `libzip` (for unpacking .zip files) * `libmicrotar` (for unpacking .tar.gz files) -To build, `lpm` only requires a C compiler. To run the underlying build process +To build, `ppm` only requires a C compiler. To run the underlying build process for `mbedtls` and `libgit2`, `cmake` is also required. ## Supported Platforms -`lpm` should work on all platforms `lite-xl` works on; but releases are offered for the following: +`ppm` should work on all platforms `pragtical` works on; but releases are offered for the following: * Windows x86_64 * Linux x86_64 @@ -118,23 +120,23 @@ Experimental support (i.e. doesn't work) exists for the following platforms: ## Use in CI -To make pre-fab lite builds, you can easily use `lpm` in CI. If you had a linux build container, you could do something like: +To make pre-fab pragtical builds, you can easily use `ppm` in CI. If you had a linux build container, you could do something like: ```sh -curl https://github.com/adamharrison/lite-xl-plugin-manager/releases/download/v0.1/lpm.x86_64-linux > lpm -export LITE_USERDIR=lite-xl/data && export LPM_CACHE=/tmp/cache -./lpm add https://github.com/adamharrison/lite-xl-plugin-manager && ./lpm install plugin_manager lsp +curl https://github.com/pragtical/plugin-manager/releases/download/v0.1/ppm.x86_64-linux > ppm +export PRAGTICAL_USERDIR=pragtical/data && export PPM_CACHE=/tmp/cache +./ppm add https://github.com/pragtical/plugin-manager && ./ppm install plugin_manager lsp ``` ## Usage ```sh -lpm install aligncarets -lpm uninstall aligncarets +ppm install aligncarets +ppm uninstall aligncarets ``` ```sh -lpm --help +ppm --help ``` ## Building & Running @@ -142,7 +144,7 @@ lpm --help ### Linux & MacOS & Windows MSYS ``` -./build.sh clean && ./build.sh -DLPM_STATIC && ./lpm +./build.sh clean && ./build.sh -DPPM_STATIC && ./ppm ``` ### Linux -> Windows @@ -150,12 +152,12 @@ lpm --help ``` ./build.sh clean && CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-gcc-ar WINDRES=x86_64-w64-mingw32-windres \ CMAKE_DEFAULT_FLAGS="-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER\ -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=NEVER -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_SYSTEM_INCLUDE_PATH=/usr/share/mingw-w64/include"\ - GIT2_CONFIGURE="-DDLLTOOL=x86_64-w64-mingw32-dlltool" ./build.sh -DLPM_STATIC -DLPM_VERSION='"'$VERSION-x86_64-windows-`git rev-parse --short HEAD`'"' + GIT2_CONFIGURE="-DDLLTOOL=x86_64-w64-mingw32-dlltool" ./build.sh -DPPM_STATIC -DPPM_VERSION='"'$VERSION-x86_64-windows-`git rev-parse --short HEAD`'"' ``` ## Tests -To run the test suite, you can use `lpm` to execute the test by doing `./lpm test t/run.lua`. use `FAST=1 ./lpm test t/run.lua` to avoid the costs of tearing down and building up suites each time. +To run the test suite, you can use `ppm` to execute the test by doing `./ppm test t/run.lua`. use `FAST=1 ./ppm test t/run.lua` to avoid the costs of tearing down and building up suites each time. ## Extra Features @@ -172,5 +174,5 @@ An array of files to be marked as executable (after extraction, if applicable). If you find a bug, please create an issue with the following information: * Your operating system. -* The commit or version of LPM you're using (`lpm --version` for releases). -* The exact steps to reproduce in LPM invocations, if possible from a fresh LPM install (targeting an empty folder with `--userdir`). +* The commit or version of PPM you're using (`ppm --version` for releases). +* The exact steps to reproduce in PPM invocations, if possible from a fresh PPM install (targeting an empty folder with `--userdir`). diff --git a/SPEC.md b/SPEC.md index 71ca2a9..354b4a2 100644 --- a/SPEC.md +++ b/SPEC.md @@ -1,17 +1,17 @@ # Manifest Specification -A lite-xl manifest is a JSON file containing three different keys: +A pragtical manifest is a JSON file containing three different keys: * Remotes * Addons -* Lite-XLs +* Pragticals ## Remotes A simple array of string repository identifiers. A repository identifier takes the form of a git remote url, i.e. `:`. An example would be: -`https://github.com/lite-xl/lite-xl-plugin-manager.git:latest` +`https://github.com/pragtical/plugin-manager.git:latest` ## Addons @@ -108,7 +108,7 @@ can also optionally contain the `arch` and `path` keys. * `checksum` is the sha256hex checksum for the file. If `"SKIP"` is specified, the check is skipped. This is fine for development purposes, but any publically accessible manifest, should specify a checksum. -* `arch` is the lite-xl/clang architecture tuple that the file is relevant for. +* `arch` is the pragtical/clang architecture tuple that the file is relevant for. if omitted, file is to be assumed to be valid for all arhcitectures. Can be an array. * `path` is the location to install this file inside the addon's directory. * `optional` is a boolean that determines whether the file is an optional addition; @@ -117,20 +117,20 @@ can also optionally contain the `arch` and `path` keys. If a file is an archive, of either `.zip`, `.gz` or `.tar.gz`, it will automatically be extracted inside the addon's directory. -## Lite-XLs +## Pragticals -Lite-XLs represent different version of lite-xl that are registered in this -repository. Lite-XLs has the following metadata, as well as a `files` array. +Pragticals represent different version of pragtical that are registered in this +repository. Pragticals has the following metadata, as well as a `files` array. * `version`: A version specifier. Must take the form of x(.x)\*(-suffix). - Suffixes can be used to denote different flavours of lite-xl. + Suffixes can be used to denote different flavours of pragtical. * `mod_version`: The modversion the binary corresponds to. ### Files The files array is identical to that of the `files` array under `addons`. Conventionally, there should be a single file per architecture that is a -`.tar.gz` or `.zip` containing all necessary files for `lite-xl` to run. +`.tar.gz` or `.zip` containing all necessary files for `pragtical` to run. ## Version Specifiers @@ -146,7 +146,7 @@ that any version greater than `0.1` can be used. { "id": "plugin_manager", # Unique name, used to reference the plugin. "version": "0.1", # Semantic version. - "description": "A GUI interface to the Adam's lite plugin manager.", # English description of the plugin. + "description": "A GUI interface to the Adam's pragtical plugin manager.", # English description of the plugin. "path": "plugins/plugin_manager", # The path to the plugin in this repository. "mod_version": "3", # The mod_version this plugin corresponds to. "provides": [ # A list of small strings that represent functionalities this plugin provides. @@ -154,12 +154,12 @@ that any version greater than `0.1` can be used. ], "files": [ # A list of files (usually binaries) this plugin requires to function. { - "url": "https://github.com/adamharrison/lite-xl-plugin-manager/releases/download/v0.1/lpm.x86_64-linux", # A publically accessible URL to download from. - "arch": "x86_64-linux", # The lite-xl/clang target tuple that represents the architecture this file is for. + "url": "https://github.com/pragtical/plugin-manager/releases/download/v0.1/ppm.x86_64-linux", # A publically accessible URL to download from. + "arch": "x86_64-linux", # The pragtical/clang target tuple that represents the architecture this file is for. "checksum": "d27f03c850bacdf808436722cd16e2d7649683e017fe6267934eeeedbcd21096" # the sha256hex checksum that corresponds to this file. }, { - "url": "https://github.com/adamharrison/lite-xl-plugin-manager/releases/download/v0.1/lpm.x86_64-windows.exe", + "url": "https://github.com/pragtical/plugin-manager/releases/download/v0.1/ppm.x86_64-windows.exe", "arch": "x86_64-windows", "checksum": "2ed993ed4376e1840b0824d7619f2d3447891d3aa234459378fcf9387c4e4680" } @@ -196,7 +196,7 @@ that any version greater than `0.1` can be used. "description": "Syntax for .gitignore, .dockerignore and some other `.*ignore` files", "version": "1.0", "mod_version": "3", - "remote": "https://github.com/anthonyaxenov/lite-xl-ignore-syntax:2ed993ed4376e1840b0824d7619f2d3447891d3aa234459378fcf9387c4e4680", # The remote to be used for this plugin. + "remote": "https://github.com/anthonyaxenov/pragtical-ignore-syntax:2ed993ed4376e1840b0824d7619f2d3447891d3aa234459378fcf9387c4e4680", # The remote to be used for this plugin. "id": "language_ignore", "post": {"x86-linux":"cp language_ignore.lua /tmp/somewhere-else", "x86-windows":"COPY language_ignore.lua C:\\Users\\Someone\\ignore.lua"} # Post download steps to run to fully set up the plugin. Does not run by default, requires --post. }, @@ -213,26 +213,26 @@ that any version greater than `0.1` can be used. }, { "description": "Syntax for Kaitai struct files", - "url": "https://raw.githubusercontent.com/whiteh0le/lite-plugins/main/plugins/language_ksy.lua?raw=1", # URL directly to the singleton plugin file. + "url": "https://raw.githubusercontent.com/whiteh0le/pragtical-plugins/main/plugins/language_ksy.lua?raw=1", # URL directly to the singleton plugin file. "id": "language_ksy", "version": "1.0", "mod_version": "3", "checksum": "08a9f8635b09a98cec9dfca8bb65f24fd7b6585c7e8308773e7ddff9a3e5a60f", # Checksum for this particular URL. } ], - "lite-xls": [ # An array of lite-xl releases. + "pragticals": [ # An array of pragtical releases. { "version": "2.1-simplified", # The version, followed by a release suffix defining the release flavour. The only releases that are permitted to not have suffixes are official relases. "mod_version": "3", # The mod_version this release corresponds to. "files": [ # Identical to `files` under `addons`, although these are usually simply archives to be extracted. { "arch": "x86_64-linux", - "url": "https://github.com/adamharrison/lite-xl-simplified/releases/download/v2.1/lite-xl-2.1.0-simplified-x86_64-linux.tar.gz", + "url": "https://github.com/adamharrison/lite-xl-simplified/releases/download/v2.1/pragtical-2.1.0-simplified-x86_64-linux.tar.gz", "checksum": "b5087bd03fb491c9424485ba5cb16fe3bb0a6473fdc801704e43f82cdf960448" }, { "arch": "x86_64-windows", - "url": "https://github.com/adamharrison/lite-xl-simplified/releases/download/v2.1/lite-xl-2.1.0-simplified-x86_64-windows.zip", + "url": "https://github.com/adamharrison/lite-xl-simplified/releases/download/v2.1/pragtical-2.1.0-simplified-x86_64-windows.zip", "checksum": "f12cc1c172299dd25575ae1b7473599a21431f9c4e14e73b271ff1429913275d" } ] @@ -243,21 +243,20 @@ that any version greater than `0.1` can be used. "files": [ { "arch": "x86_64-linux", - "url": "https://github.com/adamharrison/lite-xl-simplified/releases/download/v2.1/lite-xl-2.1.0-simplified-x86_64-linux-enhanced.tar.gz", + "url": "https://github.com/adamharrison/lite-xl-simplified/releases/download/v2.1/pragtical-2.1.0-simplified-x86_64-linux-enhanced.tar.gz", "checksum": "4625c7aac70a2834ef5ce5ba501af2d72d203441303e56147dcf8bcc4b889e40" }, { "arch": "x86_64-windows", - "url": "https://github.com/adamharrison/lite-xl-simplified/releases/download/v2.1/lite-xl-2.1.0-simplified-x86_64-windows-enhanced.zip", + "url": "https://github.com/adamharrison/lite-xl-simplified/releases/download/v2.1/pragtical-2.1.0-simplified-x86_64-windows-enhanced.zip", "checksum": "5ac009e3d5a5c99ca7fbd4f6b5bd4e25612909bf59c0925eddb41fe294ce28a4" } ] } ], "remotes": [ # A list of remote specifiers. The plugin manager will pull these in and add them as additional repositories if specified to do so with a flag. - "https://github.com/lite-xl/lite-xl-plugins.git:2.1", + "https://github.com/pragtical/plugins.git:2.1", "https://github.com/adamharrison/lite-xl-simplified.git:v2.1" ] } ``` - diff --git a/build.sh b/build.sh index f5c13d4..12d22b0 100755 --- a/build.sh +++ b/build.sh @@ -4,14 +4,14 @@ : ${HOSTCC=$CC} : ${AR=ar} : ${MAKE=make} -: ${BIN=lpm} +: ${BIN=ppm} : ${JOBS=4} SRCS="src/*.c" COMPILE_FLAGS="$CFLAGS -Ilib/prefix/include" # We specifically rename this and LDFLAGS, because exotic build environments export these to subprcoesses. LINK_FLAGS="$LDFLAGS -lm -Llib/prefix/lib -Llib/prefix/lib64" # And ideally we don't want to mess with the underlying build processes, unless we're explicit about it. -[[ "$@" == "clean" ]] && rm -rf lib/libgit2/build lib/zlib/build lib/libzip/build lib/mbedtls/build lib/prefix lua $BIN *.exe src/lpm.luac src/lpm.lua.c && exit 0 +[[ "$@" == "clean" ]] && rm -rf lib/libgit2/build lib/zlib/build lib/libzip/build lib/mbedtls/build lib/prefix lua $BIN *.exe src/ppm.luac src/ppm.lua.c && exit 0 cmake --version >/dev/null 2>/dev/null || { echo "Please ensure that you have cmake installed." && exit -1; } # Build supporting libraries, libz, libmbedtls, libmbedcrypto, libgit2, libzip, libmicrotar, liblua @@ -39,9 +39,9 @@ fi [[ "$@" != *"-llua"* ]] && COMPILE_FLAGS="$COMPILE_FLAGS -Ilib/lua -DMAKE_LIB=1" && SRCS="$SRCS lib/lua/onelua.c" # Build the pre-packaged lua file into the executbale. -if [[ "$@" == *"-DLPM_STATIC"* ]]; then +if [[ "$@" == *"-DPPM_STATIC"* ]]; then [[ ! -e "lua.exe" ]] && { $HOSTCC -Ilib/lua -o lua.exe lib/lua/onelua.c -lm || exit -1; } - ./lua.exe -e 'io.open("src/lpm.lua.c", "wb"):write("unsigned char lpm_luac[] = \""..string.dump(load(io.lines("src/lpm.lua","L"), "=lpm.lua")):gsub(".",function(c) return string.format("\\x%02X",string.byte(c)) end).."\";unsigned int lpm_luac_len = sizeof(lpm_luac)-1;")' + ./lua.exe -e 'io.open("src/ppm.lua.c", "wb"):write("unsigned char ppm_luac[] = \""..string.dump(load(io.lines("src/ppm.lua","L"), "=ppm.lua")):gsub(".",function(c) return string.format("\\x%02X",string.byte(c)) end).."\";unsigned int ppm_luac_len = sizeof(ppm_luac)-1;")' fi [[ $OSTYPE != 'msys'* && $CC != *'mingw'* && $CC != "emcc" ]] && COMPILE_FLAGS="$COMPILE_FLAGS -DLUA_USE_LINUX" && LINK_FLAGS="$LINK_FLAGS -ldl" diff --git a/libraries/json.lua b/libraries/json.lua index c463440..805550b 100644 --- a/libraries/json.lua +++ b/libraries/json.lua @@ -1,4 +1,4 @@ --- mod-version:3 --lite-xl 2.1 +-- mod-version:3 --pragtical 2.1 -- -- json.lua -- diff --git a/lite-xl-plugin-manager.json b/lite-xl-plugin-manager.json deleted file mode 100644 index f93d11a..0000000 --- a/lite-xl-plugin-manager.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "version": "latest", - "description": "Plugin and package manager for Lite XL editor.", - "homepage": "https://github.com/lite-xl/lite-xl-plugin-manager", - "license": "LPM", - "architecture": { - "64bit": { - "url": "https://github.com/lite-xl/lite-xl-plugin-manager/releases/download/latest/lpm.x86_64-windows.exe#/lpm.exe", - "checksum": "SKIP" - } - }, - "bin": "lpm.exe", - "shortcuts": [ - [ - "lpm.exe", - "Lite-XL Plugin Manager" - ] - ], - "checkver": { - "url": "https://github.com/lite-xl/lite-xl-plugin-manager/tags", - "regex": "/releases/tag/(?:v|V)?([\\d.]+)" - }, - "autoupdate": { - "architecture": { - "64bit": { - "url": "https://github.com/lite-xl/lite-xl-plugin-manager/releases/download/latest/lpm.x86_64-windows.exe" - } - } - } -} diff --git a/manifest.json b/manifest.json index f21d73e..495f9be 100644 --- a/manifest.json +++ b/manifest.json @@ -3,60 +3,61 @@ { "id": "plugin_manager", "version": "0.1", - "description": "A GUI interface to Adam's lite-xl plugin manager.", + "description": "A GUI interface to Adam's pragtical plugin manager.", + "type": "plugin", "path": "plugins/plugin_manager", "mod_version": 3, "files": [ { - "url": "https://github.com/lite-xl/lite-xl-plugin-manager/releases/download/latest/lpm.x86_64-linux", + "url": "https://github.com/pragtical/plugin-manager/releases/download/latest/ppm.x86_64-linux", "arch": "x86_64-linux", "checksum": "SKIP", "optional": true }, { - "url": "https://github.com/lite-xl/lite-xl-plugin-manager/releases/download/latest/lpm.aarch64-linux", + "url": "https://github.com/pragtical/plugin-manager/releases/download/latest/ppm.aarch64-linux", "arch": "aarch64-linux", "checksum": "SKIP", "optional": true }, { - "url": "https://github.com/lite-xl/lite-xl-plugin-manager/releases/download/latest/lpm.x86_64-windows.exe", + "url": "https://github.com/pragtical/plugin-manager/releases/download/latest/ppm.x86_64-windows.exe", "arch": "x86_64-windows", "checksum": "SKIP", "optional": true }, { - "url": "https://github.com/lite-xl/lite-xl-plugin-manager/releases/download/latest/lpm.x86_64-darwin", + "url": "https://github.com/pragtical/plugin-manager/releases/download/latest/ppm.x86_64-darwin", "arch": "x86_64-darwin", "checksum": "SKIP", "optional": true }, { - "url": "https://github.com/lite-xl/lite-xl-plugin-manager/releases/download/latest/lpm.aarch64-darwin", + "url": "https://github.com/pragtical/plugin-manager/releases/download/latest/ppm.aarch64-darwin", "arch": "aarch64-darwin", "checksum": "SKIP", "optional": true }, { - "url": "https://github.com/lite-xl/lite-xl-plugin-manager/releases/download/latest/lpm.aarch64-android", + "url": "https://github.com/pragtical/plugin-manager/releases/download/latest/ppm.aarch64-android", "arch": "aarch64-android", "checksum": "SKIP", "optional": true }, { - "url": "https://github.com/lite-xl/lite-xl-plugin-manager/releases/download/latest/lpm.arm-android", + "url": "https://github.com/pragtical/plugin-manager/releases/download/latest/ppm.arm-android", "arch": "arm-android", "checksum": "SKIP", "optional": true }, { - "url": "https://github.com/lite-xl/lite-xl-plugin-manager/releases/download/latest/lpm.x86-android", + "url": "https://github.com/pragtical/plugin-manager/releases/download/latest/ppm.x86-android", "arch": "x86-android", "checksum": "SKIP", "optional": true }, { - "url": "https://github.com/lite-xl/lite-xl-plugin-manager/releases/download/latest/lpm.x86_64-android", + "url": "https://github.com/pragtical/plugin-manager/releases/download/latest/ppm.x86_64-android", "arch": "x86_64-android", "checksum": "SKIP", "optional": true @@ -84,31 +85,8 @@ "path": "libraries/json.lua" } ], - "lite-xls": [ - { - "version": "2.1.1-simplified", - "mod_version": 3, - "files": [ - { - "arch": "x86_64-linux", - "url": "https://github.com/adamharrison/lite-xl-simplified/releases/download/v2.1.1-simplified/lite-xl-v2.1.1-simplified-x86_64-linux.tar.gz", - "checksum": "6a0589cf822e04563330bcf4d26b70be9a59ac268fbbd15073ae45ebb292917e" - }, - { - "arch": "x86_64-windows", - "url": "https://github.com/adamharrison/lite-xl-simplified/releases/download/v2.1.1-simplified/lite-xl-v2.1.1-simplified-x86_64-windows.zip", - "checksum": "15aca182dbf3768c6f9366d3715cca2154b1a1fbce8d79794aa350f9e24ca2bf" - }, - { - "arch": "x86_64-darwin", - "url": "https://github.com/adamharrison/lite-xl-simplified/releases/download/v2.1.1-simplified/lite-xl-v2.1.1-simplified-x86_64-darwin.tar.gz", - "checksum": "222f227adede48eb41fe98a800e3c67256a48ba2cc68bc8a9cce36ff9866e26c" - } - ] - } - ], "remotes": [ - "https://github.com/lite-xl/lite-xl-plugins.git:master", - "https://github.com/lite-xl/lite-xl-colors.git:master" + "https://github.com/pragtical/plugins.git:master", + "https://github.com/pragtical/colors.git:master" ] } diff --git a/meson.build b/meson.build index 2dc4ea1..ebab89c 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,7 @@ -project('lpm', +project('ppm', ['c'], - license : 'LPM', + license : 'PPM', + version : '1.2.0', meson_version : '>= 0.56', ) @@ -43,18 +44,18 @@ microtar_dep = declare_dependency( include_directories: ['lib/microtar/src'] ) -lpm_source = files('src/lpm.c') +ppm_source = files('src/ppm.c') cflags = [] if get_option('static') lua_exe = find_program('lua') - lpm_source += configure_file( + ppm_source += configure_file( capture: false, - command: [lua_exe, '-e', 'f = string.dump(assert(load(io.lines("@INPUT0@", "L"), "=lpm.lua"))) io.open("@OUTPUT0@", "wb"):write("unsigned char lpm_luac[] = \"" .. f:gsub(".", function (c) return string.format("\\\x%02X",string.byte(c)) end) .. "\";unsigned int lpm_luac_len = " .. #f .. ";")'], - input: files('src/lpm.lua'), - output: 'lpm.lua.c' + command: [lua_exe, '-e', 'f = string.dump(assert(load(io.lines("@INPUT0@", "L"), "=ppm.lua"))) io.open("@OUTPUT0@", "wb"):write("unsigned char ppm_luac[] = \"" .. f:gsub(".", function (c) return string.format("\\\x%02X",string.byte(c)) end) .. "\";unsigned int ppm_luac_len = " .. #f .. ";")'], + input: files('src/ppm.lua'), + output: 'ppm.lua.c' ) - cflags += '-DLPM_STATIC' + cflags += '-DPPM_STATIC' endif -executable('lpm', lpm_source, dependencies: [zlib_dep, mbedtls_dep, libgit2_dep, libzip_dep, lua_dep, microtar_dep], c_args: cflags) +executable('ppm', ppm_source, dependencies: [zlib_dep, mbedtls_dep, libgit2_dep, libzip_dep, lua_dep, microtar_dep], c_args: cflags) diff --git a/plugins/plugin_manager/init.lua b/plugins/plugin_manager/init.lua index 2b27d3a..c629354 100644 --- a/plugins/plugin_manager/init.lua +++ b/plugins/plugin_manager/init.lua @@ -1,4 +1,4 @@ --- mod-version:3 --lite-xl 2.1 --priority:5 +-- mod-version:3 --priority:5 local core = require "core" local common = require "core.common" @@ -14,47 +14,47 @@ local PluginManager = { } local binary_extension = (PLATFORM == "Windows" and ".exe" or (PLATFORM == "Android" and ".so" or "")) config.plugins.plugin_manager = common.merge({ - lpm_binary_name = "lpm." .. ARCH .. binary_extension, - lpm_binary_path = nil, + ppm_binary_name = "ppm." .. ARCH .. binary_extension, + ppm_binary_path = nil, -- Restarts the plugin manager on changes. restart_on_change = true, -- Path to a local copy of all repositories. - cachdir = USERDIR .. PATHSEP .. "lpm", + cachdir = USERDIR .. PATHSEP .. "ppm", -- Path to the folder that holds user-specified plugins. userdir = USERDIR, -- Path to ssl certificate directory or bunde. Nil will auto-detect. ssl_certs = nil, -- Whether or not to force install things. force = false, - -- Dumps commands that run to stdout, as well as responses from lpm. + -- Dumps commands that run to stdout, as well as responses from ppm. debug = false, -- A list of addons to apply to the system bottle. addons = nil }, config.plugins.plugin_manager) -if not config.plugins.plugin_manager.lpm_binary_path then +if not config.plugins.plugin_manager.ppm_binary_path then local paths = { - DATADIR .. PATHSEP .. "plugins" .. PATHSEP .. "plugin_manager" .. PATHSEP .. config.plugins.plugin_manager.lpm_binary_name, - USERDIR .. PATHSEP .. "plugins" .. PATHSEP .. "plugin_manager" .. PATHSEP .. config.plugins.plugin_manager.lpm_binary_name, - DATADIR .. PATHSEP .. "plugins" .. PATHSEP .. "plugin_manager" .. PATHSEP .. "lpm" .. binary_extension, - USERDIR .. PATHSEP .. "plugins" .. PATHSEP .. "plugin_manager" .. PATHSEP .. "lpm" .. binary_extension, + DATADIR .. PATHSEP .. "plugins" .. PATHSEP .. "plugin_manager" .. PATHSEP .. config.plugins.plugin_manager.ppm_binary_name, + USERDIR .. PATHSEP .. "plugins" .. PATHSEP .. "plugin_manager" .. PATHSEP .. config.plugins.plugin_manager.ppm_binary_name, + DATADIR .. PATHSEP .. "plugins" .. PATHSEP .. "plugin_manager" .. PATHSEP .. "ppm" .. binary_extension, + USERDIR .. PATHSEP .. "plugins" .. PATHSEP .. "plugin_manager" .. PATHSEP .. "ppm" .. binary_extension, } local path, s = os.getenv("PATH"), 1 while true do local _, e = path:find(":", s) - table.insert(paths, path:sub(s, e and (e-1) or #path) .. PATHSEP .. config.plugins.plugin_manager.lpm_binary_name) - table.insert(paths, path:sub(s, e and (e-1) or #path) .. PATHSEP .. "lpm" .. binary_extension) + table.insert(paths, path:sub(s, e and (e-1) or #path) .. PATHSEP .. config.plugins.plugin_manager.ppm_binary_name) + table.insert(paths, path:sub(s, e and (e-1) or #path) .. PATHSEP .. "ppm" .. binary_extension) if not e then break end s = e + 1 end for i, path in ipairs(paths) do if system.get_file_info(path) then - config.plugins.plugin_manager.lpm_binary_path = path + config.plugins.plugin_manager.ppm_binary_path = path break end end end -if not config.plugins.plugin_manager.lpm_binary_path then error("can't find lpm binary, please supply one with config.plugins.plugin_manager.lpm_binary_path") end +if not config.plugins.plugin_manager.ppm_binary_path then error("can't find ppm binary, please supply one with config.plugins.plugin_manager.ppm_binary_path") end local Promise = { } function Promise:__index(idx) return rawget(self, idx) or Promise[idx] end @@ -89,7 +89,7 @@ end local function run(cmd, options) options = options or {} - table.insert(cmd, 1, config.plugins.plugin_manager.lpm_binary_path) + table.insert(cmd, 1, config.plugins.plugin_manager.ppm_binary_path) table.insert(cmd, "--json") table.insert(cmd, "--quiet") table.insert(cmd, "--progress") @@ -337,7 +337,7 @@ if config.plugins.plugin_manager.addons then return result end - local function lpm_load_plugins() + local function ppm_load_plugins() package.cpath = replace_string(package.cpath, USERDIR, target_plugin_directory) package.path = replace_string(package.path, USERDIR, target_plugin_directory) @@ -449,10 +449,10 @@ if config.plugins.plugin_manager.addons then end end local plugins = system.list_dir(USERDIR .. PATHSEP .. "plugins") - run({ "apply", table.unpack(addons), }, { userdir = target_plugin_directory, cachedir = USERDIR .. PATHSEP .. "lpm" }):done(function(status) + run({ "apply", table.unpack(addons), }, { userdir = target_plugin_directory, cachedir = USERDIR .. PATHSEP .. "ppm" }):done(function(status) if json.decode(status)["changed"] then command.perform("core:restart") end end) - lpm_load_plugins() + ppm_load_plugins() local old_configs = {} for i,v in ipairs(plugins or {}) do local id = v:gsub("%.lua$", "") @@ -545,7 +545,7 @@ command.add(nil, { end, ["plugin-manager:refresh"] = function() PluginManager:refresh({ progress = PluginManager.view.progress_callback }):done(function() core.log("Successfully refreshed plugin listing.") end) end, ["plugin-manager:upgrade"] = function() PluginManager:upgrade({ progress = PluginManager.view.progress_callback }):done(function() core.log("Successfully upgraded installed plugins.") end) end, - ["plugin-manager:purge"] = function() PluginManager:purge({ progress = PluginManager.view.progress_callback }):done(function() core.log("Successfully purged lpm directory.") end) end, + ["plugin-manager:purge"] = function() PluginManager:purge({ progress = PluginManager.view.progress_callback }):done(function() core.log("Successfully purged ppm directory.") end) end, ["plugin-manager:show"] = function() local node = core.root_view:get_active_node_default() node:add_view(PluginManager.view(PluginManager)) @@ -559,7 +559,7 @@ if pcall(require, "plugins.terminal") then local arguments = { "-", "--userdir=" .. USERDIR } for i,v in ipairs(default_arguments) do table.insert(arguments, v) end local tv = terminal.class(common.merge(config.plugins.terminal, { - shell = config.plugins.plugin_manager.lpm_binary_path, + shell = config.plugins.plugin_manager.ppm_binary_path, arguments = arguments })) core.root_view:get_active_node_default():add_view(tv) @@ -567,4 +567,50 @@ if pcall(require, "plugins.terminal") then }) end +local cli = require "core.cli" + +cli.register { + command = "pm", + description = "Access to the plugin manager.", + usage = "[options] [subcommands]", + skip_arguments_check = true, + exit_editor = true, + execute = function() + if not config.plugins.plugin_manager.ppm_binary_path then + print(cli.colorize("Can't find ppm binary, please supply one with config.plugins.plugin_manager.ppm_binary_path", "red")) + else + local start = 0; + for i=0, #ARGS do + if ARGS[i] == "pm" then + start = i + 1 + break + end + end + if PLATFORM ~= "Windows" then + local exit_code = os.execute( + '"' .. config.plugins.plugin_manager.ppm_binary_path .. '" ' + .. table.concat(ARGS, " ", start) + ) + os.exit(exit_code or 0) + else + -- compatibility with pragtical.com binary under Windows + local cmd = {config.plugins.plugin_manager.ppm_binary_path} + for i=start, #ARGS do + table.insert(cmd, ARGS[i]) + end + local pm = process.start(cmd) + if pm then + repeat + local out = pm:read_stdout() + local err = pm:read_stderr() + if out then io.stdout:write(out) end + if err then io.stderr:write(err) end + until not pm:running() + os.exit(pm:returncode() or 1) + end + end + end + end +} + return PluginManager diff --git a/plugins/welcome.lua b/plugins/welcome.lua index 5516568..acabc16 100644 --- a/plugins/welcome.lua +++ b/plugins/welcome.lua @@ -1,4 +1,4 @@ --- mod-version:3 --lite-xl 2.1 +-- mod-version:3 local core = require "core" local style = require "core.style" @@ -36,12 +36,12 @@ end local buttons = { { label = "Install Addons Package", command = "welcome:install-addons", tooltip = { - "Installs syntax highlightings, themes, and plugins that make Lite XL easier to use.", + "Installs syntax highlightings, themes, and plugins that make Pragtical easier to use.", "", - "Recommended for newcomers to Lite XL.", + "Recommended for newcomers to Pragtical.", "Requires a network connection." } }, - { label = "Open Plugin Manager", command = "welcome:open-plugin-manager", tooltip = { "Manually select plugins you'd like to install before beginning with Lite XL.", "", "Requires a network connection." } }, + { label = "Open Plugin Manager", command = "welcome:open-plugin-manager", tooltip = { "Manually select plugins you'd like to install before beginning with Pragtical.", "", "Requires a network connection." } }, { label = "Dismiss Welcome Options", command = "welcome:dismiss", tooltip = { "Dismisses this screen permanently." } } } @@ -60,7 +60,7 @@ function EmptyView:draw() end - local title = "Lite XL" + local title = "Pragtical" local version = "version " .. VERSION local title_width = style.big_font:get_width(title) local version_width = style.font:get_width(version) @@ -153,4 +153,3 @@ command.add(EmptyView, { terminate_welcome() end }) - diff --git a/lpm.json b/ppm.json similarity index 94% rename from lpm.json rename to ppm.json index de3e747..fdfd3a3 100644 --- a/lpm.json +++ b/ppm.json @@ -1,8 +1,8 @@ { "$schema": "https://json-schema.org/draft-07/schema", - "$id": "https://github.com/lite-xl/lite-xl-plugin-manager/raw/master/lpm.json", - "title": "Lite XL Plugin Manager Manifest", - "description": "Description of Lite XL addons", + "$id": "https://github.com/pragtical/plugin-manager/raw/master/ppm.json", + "title": "Pragtical Plugin Manager Manifest", + "description": "Description of Pragtical addons", "$comment": "TODO: Add our own uri format for :.", "definitions": { "addon-id": { @@ -11,7 +11,7 @@ }, "addon-version": { "type": "string", - "$comment": "TODO: should we avoid limiting this to only 3 components? See lite-xl-lsp-servers -> lsp_json.", + "$comment": "TODO: should we avoid limiting this to only 3 components? See pragtical-lsp-servers -> lsp_json.", "pattern": "^[0-9]+(\\.[0-9]+){0,2}$" }, "addon-version-specifier": { @@ -31,7 +31,7 @@ ] }, "arch": { - "description": "Lite XL/Clang architecture tuple that the file is relevant for", + "description": "Pragtical/Clang architecture tuple that the file is relevant for", "type": "string", "examples": [ "x86_64-linux", @@ -260,8 +260,8 @@ ] } }, - "lite-xls": { - "description": "Represents the different versions of Lite XL that are registered in this repository", + "pragticals": { + "description": "Represents the different versions of Pragtical that are registered in this repository", "type": "array", "items": { "type": "object", @@ -272,7 +272,7 @@ "$ref": "#/definitions/mod-version" }, "files": { - "description": "Files that are downloaded. If the file is an archive, it will be automatically extracted. Conventionally, there should be a single file per architecture that is a `.tar.gz` or `.zip` containing all necessary files for Lite XL to run.", + "description": "Files that are downloaded. If the file is an archive, it will be automatically extracted. Conventionally, there should be a single file per architecture that is a `.tar.gz` or `.zip` containing all necessary files for Pragtical to run.", "$ref": "#/definitions/files" } } diff --git a/pragtical-plugin-manager.json b/pragtical-plugin-manager.json new file mode 100644 index 0000000..b906148 --- /dev/null +++ b/pragtical-plugin-manager.json @@ -0,0 +1,30 @@ +{ + "version": "latest", + "description": "Plugin and package manager for Pragtical editor.", + "homepage": "https://github.com/pragtical/plugin-manager", + "license": "PPM", + "architecture": { + "64bit": { + "url": "https://github.com/pragtical/plugin-manager/releases/download/latest/ppm.x86_64-windows.exe#/ppm.exe", + "checksum": "SKIP" + } + }, + "bin": "ppm.exe", + "shortcuts": [ + [ + "ppm.exe", + "Pragtical Plugin Manager" + ] + ], + "checkver": { + "url": "https://github.com/pragtical/plugin-manager/tags", + "regex": "/releases/tag/(?:v|V)?([\\d.]+)" + }, + "autoupdate": { + "architecture": { + "64bit": { + "url": "https://github.com/pragtical/plugin-manager/releases/download/latest/ppm.x86_64-windows.exe" + } + } + } +} diff --git a/src/lpm.c b/src/ppm.c similarity index 89% rename from src/lpm.c rename to src/ppm.c index a3f984e..508f150 100644 --- a/src/lpm.c +++ b/src/ppm.c @@ -65,7 +65,7 @@ typedef struct { #else pthread_t thread; #endif -} lpm_thread_t; +} ppm_thread_t; typedef struct { #if _WIN32 @@ -73,10 +73,10 @@ typedef struct { #else pthread_mutex_t mutex; #endif -} lpm_mutex_t; +} ppm_mutex_t; -static lpm_mutex_t* new_mutex() { - lpm_mutex_t* mutex = malloc(sizeof(lpm_mutex_t)); +static ppm_mutex_t* new_mutex() { + ppm_mutex_t* mutex = malloc(sizeof(ppm_mutex_t)); #if _WIN32 mutex->mutex = CreateMutex(NULL, FALSE, NULL); #else @@ -85,7 +85,7 @@ static lpm_mutex_t* new_mutex() { return mutex; } -static void free_mutex(lpm_mutex_t* mutex) { +static void free_mutex(ppm_mutex_t* mutex) { #if _WIN32 CloseHandle(mutex->mutex); #else @@ -94,7 +94,7 @@ static void free_mutex(lpm_mutex_t* mutex) { free(mutex); } -static void lock_mutex(lpm_mutex_t* mutex) { +static void lock_mutex(ppm_mutex_t* mutex) { #if _WIN32 WaitForSingleObject(mutex->mutex, INFINITE); #else @@ -102,7 +102,7 @@ static void lock_mutex(lpm_mutex_t* mutex) { #endif } -static void unlock_mutex(lpm_mutex_t* mutex) { +static void unlock_mutex(ppm_mutex_t* mutex) { #if _WIN32 ReleaseMutex(mutex->mutex); #else @@ -113,14 +113,14 @@ static void unlock_mutex(lpm_mutex_t* mutex) { #if _WIN32 static DWORD windows_thread_callback(void* data) { - lpm_thread_t* thread = data; + ppm_thread_t* thread = data; thread->data = thread->func(thread->data); return 0; } #endif -static lpm_thread_t* create_thread(void* (*func)(void*), void* data) { - lpm_thread_t* thread = malloc(sizeof(lpm_thread_t)); +static ppm_thread_t* create_thread(void* (*func)(void*), void* data) { + ppm_thread_t* thread = malloc(sizeof(ppm_thread_t)); #if _WIN32 thread->func = func; thread->data = data; @@ -131,7 +131,7 @@ static lpm_thread_t* create_thread(void* (*func)(void*), void* data) { return thread; } -static void* join_thread(lpm_thread_t* thread) { +static void* join_thread(ppm_thread_t* thread) { if (!thread) return NULL; void* retval; @@ -219,7 +219,7 @@ static void lua_pushhexstring(lua_State* L, const unsigned char* buffer, size_t lua_pushlstring(L, hex_buffer, length * 2); } -static int lpm_hash(lua_State* L) { +static int ppm_hash(lua_State* L) { size_t len; const char* data = luaL_checklstring(L, 1, &len); const char* type = luaL_optstring(L, 2, "string"); @@ -251,7 +251,7 @@ static int lpm_hash(lua_State* L) { return 1; } -static int lpm_tcflush(lua_State* L) { +static int ppm_tcflush(lua_State* L) { int stream = luaL_checkinteger(L, 1); #ifndef _WIN32 if (isatty(stream)) @@ -260,7 +260,7 @@ static int lpm_tcflush(lua_State* L) { return 0; } -static int lpm_tcwidth(lua_State* L) { +static int ppm_tcwidth(lua_State* L) { int stream = luaL_checkinteger(L, 1); #ifndef _WIN32 if (isatty(stream)) { @@ -280,7 +280,7 @@ static int lpm_tcwidth(lua_State* L) { return 0; } -static int lpm_symlink(lua_State* L) { +static int ppm_symlink(lua_State* L) { #ifndef _WIN32 if (symlink(luaL_checkstring(L, 1), luaL_checkstring(L, 2))) return luaL_error(L, "can't create symlink %s: %s", luaL_checkstring(L, 2), strerror(errno)); @@ -290,7 +290,7 @@ static int lpm_symlink(lua_State* L) { #endif } -static int lpm_chmod(lua_State* L) { +static int ppm_chmod(lua_State* L) { #ifdef _WIN32 if (_wchmod(lua_toutf16(L, luaL_checkstring(L, 1)), luaL_checkinteger(L, 2))) #else @@ -300,7 +300,7 @@ static int lpm_chmod(lua_State* L) { return 0; } -static int lpm_ls(lua_State *L) { +static int ppm_ls(lua_State *L) { const char *path = luaL_checkstring(L, 1); int i = 1; #ifdef _WIN32 @@ -343,7 +343,7 @@ static int lpm_ls(lua_State *L) { return 1; } -static int lpm_rmdir(lua_State *L) { +static int ppm_rmdir(lua_State *L) { const char *path = luaL_checkstring(L, 1); #ifdef _WIN32 if (!RemoveDirectoryW(lua_toutf16(L, path))) @@ -355,7 +355,7 @@ static int lpm_rmdir(lua_State *L) { return 0; } -static int lpm_mkdir(lua_State *L) { +static int ppm_mkdir(lua_State *L) { const char *path = luaL_checkstring(L, 1); #ifdef _WIN32 int err = _wmkdir(lua_toutf16(L, path)); @@ -367,7 +367,7 @@ static int lpm_mkdir(lua_State *L) { return 0; } -static int lpm_stat(lua_State *L) { +static int ppm_stat(lua_State *L) { const char *path = luaL_checkstring(L, 1); #ifdef _WIN32 wchar_t full_path[MAX_PATH]; @@ -431,7 +431,7 @@ static int lpm_stat(lua_State *L) { lua_setfield(L, -2, "type"); return 1; } -/** END STOLEN LITE CODE **/ +/** END STOLEN PRAGTICAL CODE **/ static const char* git_error_last_string() { const git_error* last_error = git_error_last(); @@ -480,7 +480,7 @@ static git_commit* git_retrieve_commit(git_repository* repository, const char* c } // We move this out of main, because this is a significantly expensive function, -// and we don't need to call it every time we run lpm. +// and we don't need to call it every time we run ppm. static int git_initialized = 0; static int git_cert_type = 0; static char git_cert_path[MAX_PATH]; @@ -497,7 +497,7 @@ static void git_init() { } -static int lpm_reset(lua_State* L) { +static int ppm_reset(lua_State* L) { git_init(); git_repository* repository = luaL_checkgitrepo(L, 1); const char* commit_name = luaL_checkstring(L, 2); @@ -521,7 +521,7 @@ static int lpm_reset(lua_State* L) { } -static int lpm_init(lua_State* L) { +static int ppm_init(lua_State* L) { git_init(); const char* path = luaL_checkstring(L, 1); const char* url = luaL_checkstring(L, 2); @@ -545,7 +545,7 @@ static mbedtls_ctr_drbg_context drbg_context; static mbedtls_ssl_config ssl_config; static mbedtls_ssl_context ssl_context; -static int lpm_git_transport_certificate_check_cb(struct git_cert *cert, int valid, const char *host, void *payload) { +static int ppm_git_transport_certificate_check_cb(struct git_cert *cert, int valid, const char *host, void *payload) { return 0; // If no_verify_ssl is enabled, basically always return 0 when this is set as callback. } @@ -562,10 +562,10 @@ typedef struct { int complete; int error_code; char data[512]; - lpm_thread_t* thread; + ppm_thread_t* thread; } fetch_context_t; -static int lpm_fetch_callback(lua_State* L, const git_transfer_progress *stats) { +static int ppm_fetch_callback(lua_State* L, const git_transfer_progress *stats) { lua_pushinteger(L, stats->received_bytes); lua_pushinteger(L, stats->total_objects); lua_pushinteger(L, stats->indexed_objects); @@ -576,12 +576,12 @@ static int lpm_fetch_callback(lua_State* L, const git_transfer_progress *stats) return lua_pcall(L, 7, 0, 0); } -static int lpm_git_transfer_progress_cb(const git_transfer_progress *stats, void *payload) { +static int ppm_git_transfer_progress_cb(const git_transfer_progress *stats, void *payload) { fetch_context_t* context = (fetch_context_t*)payload; if (!context->threaded) { if (context->callback_function) { lua_rawgeti(context->L, LUA_REGISTRYINDEX, context->callback_function); - lpm_fetch_callback(context->L, stats); + ppm_fetch_callback(context->L, stats); } } else { context->progress = *stats; @@ -596,7 +596,7 @@ static int lua_is_main_thread(lua_State* L) { return is_main; } -static void* lpm_fetch_thread(void* ctx) { +static void* ppm_fetch_thread(void* ctx) { git_remote* remote; fetch_context_t* context = (fetch_context_t*)ctx; int error = git_remote_lookup(&remote, context->repository, "origin"); @@ -612,8 +612,8 @@ static void* lpm_fetch_thread(void* ctx) { fetch_opts.depth = context->depth; #endif if (no_verify_ssl) - fetch_opts.callbacks.certificate_check = lpm_git_transport_certificate_check_cb; - fetch_opts.callbacks.transfer_progress = lpm_git_transfer_progress_cb; + fetch_opts.callbacks.certificate_check = ppm_git_transport_certificate_check_cb; + fetch_opts.callbacks.transfer_progress = ppm_git_transfer_progress_cb; char* strings[] = { context->refspec }; git_strarray array = { strings, 1 }; @@ -638,13 +638,13 @@ static void* lpm_fetch_thread(void* ctx) { } -static int lpm_fetchk(lua_State* L, int status, lua_KContext ctx) { +static int ppm_fetchk(lua_State* L, int status, lua_KContext ctx) { lua_rawgeti(L, LUA_REGISTRYINDEX, (int)ctx); fetch_context_t* context = lua_touserdata(L, -1); lua_pop(L, 1); if (context->threaded && !context->error_code && context->callback_function && context->progress_update) { lua_rawgeti(L, LUA_REGISTRYINDEX, context->callback_function); - context->error_code = lpm_fetch_callback(L, &context->progress); + context->error_code = ppm_fetch_callback(L, &context->progress); if (context->error_code) strncpy(context->data, lua_tostring(L, -1), sizeof(context->data)); } @@ -661,11 +661,11 @@ static int lpm_fetchk(lua_State* L, int status, lua_KContext ctx) { return 1; } assert(context->threaded); - return lua_yieldk(L, 0, (lua_KContext)ctx, lpm_fetchk); + return lua_yieldk(L, 0, (lua_KContext)ctx, ppm_fetchk); } -static int lpm_fetch(lua_State* L) { +static int ppm_fetch(lua_State* L) { git_init(); int args = lua_gettop(L); fetch_context_t* context = lua_newuserdata(L, sizeof(fetch_context_t)); @@ -683,27 +683,27 @@ static int lpm_fetch(lua_State* L) { } int ctx = luaL_ref(L, LUA_REGISTRYINDEX); if (lua_is_main_thread(L)) { - lpm_fetch_thread(context); - lpm_fetchk(L, 0, ctx); + ppm_fetch_thread(context); + ppm_fetchk(L, 0, ctx); return 0; } else { - context->thread = create_thread(lpm_fetch_thread, context); - return lua_yieldk(L, 0, (lua_KContext)ctx, lpm_fetchk); + context->thread = create_thread(ppm_fetch_thread, context); + return lua_yieldk(L, 0, (lua_KContext)ctx, ppm_fetchk); } } -static void lpm_tls_debug(void *ctx, int level, const char *file, int line, const char *str) { +static void ppm_tls_debug(void *ctx, int level, const char *file, int line, const char *str) { fprintf(stderr, "%s:%04d: |%d| %s", file, line, level, str); fflush(stderr); } -static void lpm_libgit2_debug(git_trace_level_t level, const char *msg) { +static void ppm_libgit2_debug(git_trace_level_t level, const char *msg) { fprintf(stderr, "[libgit2]: %s\n", msg); fflush(stderr); } -static int lpm_trace(lua_State* L) { +static int ppm_trace(lua_State* L) { print_trace = lua_toboolean(L, 1) ? 1 : 0; return 0; } @@ -721,7 +721,7 @@ static int luaL_mbedtls_error(lua_State* L, int code, const char* str, ...) { } -static int lpm_certs(lua_State* L) { +static int ppm_certs(lua_State* L) { const char* type = luaL_checkstring(L, 1); int status; if (has_setup_ssl) { @@ -747,9 +747,9 @@ static int lpm_certs(lua_State* L) { #if defined(MBEDTLS_DEBUG_C) if (print_trace) { mbedtls_debug_set_threshold(5); - mbedtls_ssl_conf_dbg(&ssl_config, lpm_tls_debug, NULL); + mbedtls_ssl_conf_dbg(&ssl_config, ppm_tls_debug, NULL); git_init(); - git_trace_set(GIT_TRACE_TRACE, lpm_libgit2_debug); + git_trace_set(GIT_TRACE_TRACE, ppm_libgit2_debug); } #endif has_setup_ssl = 1; @@ -862,7 +862,7 @@ static int mkdirp(char* path, int len) { #define FA_RDONLY 0x01 // FILE_ATTRIBUTE_READONLY #define FA_DIREC 0x10 // FILE_ATTRIBUTE_DIRECTORY -static int lpm_extract(lua_State* L) { +static int ppm_extract(lua_State* L) { const char* src = luaL_checkstring(L, 1); const char* dst = luaL_checkstring(L, 2); @@ -1231,11 +1231,11 @@ typedef struct { } get_context_t; -static int lpm_socket_write(get_context_t* context, int len) { +static int ppm_socket_write(get_context_t* context, int len) { return context->is_ssl ? mbedtls_ssl_write(&context->ssl, context->buffer, len) : write(context->s, context->buffer, len); } -static int lpm_socket_read(get_context_t* context, int len) { +static int ppm_socket_read(get_context_t* context, int len) { if (len == -1) len = sizeof(context->buffer) - context->buffer_length; if (len == 0) @@ -1247,7 +1247,7 @@ static int lpm_socket_read(get_context_t* context, int len) { } -static int lpm_get_error(get_context_t* context, int error_code, const char* str, ...) { +static int ppm_get_error(get_context_t* context, int error_code, const char* str, ...) { if (error_code) { context->error_code = error_code; char mbed_buffer[256]; @@ -1267,7 +1267,7 @@ static int lpm_get_error(get_context_t* context, int error_code, const char* str return error_code; } -static int lpm_set_error(get_context_t* context, const char* str, ...) { +static int ppm_set_error(get_context_t* context, const char* str, ...) { va_list va; int offset = 0; va_start(va, str); @@ -1277,7 +1277,7 @@ static int lpm_set_error(get_context_t* context, const char* str, ...) { return offset; } -static int lpm_getk(lua_State* L, int status, lua_KContext ctx) { +static int ppm_getk(lua_State* L, int status, lua_KContext ctx) { lua_rawgeti(L, LUA_REGISTRYINDEX, ctx); get_context_t* context = (get_context_t*)lua_touserdata(L, -1); lua_pop(L,1); @@ -1285,18 +1285,18 @@ static int lpm_getk(lua_State* L, int status, lua_KContext ctx) { case STATE_HANDSHAKE: { int status = mbedtls_ssl_handshake(&context->ssl); if (status == MBEDTLS_ERR_SSL_WANT_READ || status == MBEDTLS_ERR_SSL_WANT_WRITE) - return lua_yieldk(L, 0, ctx, lpm_getk); + return lua_yieldk(L, 0, ctx, ppm_getk); if ( - lpm_get_error(context, status, "can't handshake") || - lpm_get_error(context, mbedtls_ssl_get_verify_result(&context->ssl), "can't verify result") + ppm_get_error(context, status, "can't handshake") || + ppm_get_error(context, mbedtls_ssl_get_verify_result(&context->ssl), "can't verify result") ) goto cleanup; context->state = STATE_SEND; } case STATE_SEND: { context->buffer_length = snprintf(context->buffer, sizeof(context->buffer), "GET %s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n", context->rest, context->hostname); - int length = lpm_socket_write(context, context->buffer_length); - if (length < context->buffer_length && lpm_get_error(context, length, "can't write to socket")) + int length = ppm_socket_write(context, context->buffer_length); + if (length < context->buffer_length && ppm_get_error(context, length, "can't write to socket")) goto cleanup; context->buffer_length = 0; context->buffer[0] = 0; @@ -1306,14 +1306,14 @@ static int lpm_getk(lua_State* L, int status, lua_KContext ctx) { const char* header_end; while (1) { header_end = strstr(context->buffer, "\r\n\r\n"); - if (!header_end && context->buffer_length >= sizeof(context->buffer) - 1 && lpm_set_error(context, "response header buffer length exceeded")) + if (!header_end && context->buffer_length >= sizeof(context->buffer) - 1 && ppm_set_error(context, "response header buffer length exceeded")) goto cleanup; if (!header_end) { - int length = lpm_socket_read(context, -1); - if (length < 0 && lpm_get_error(context, length, "can't read from socket")) + int length = ppm_socket_read(context, -1); + if (length < 0 && ppm_get_error(context, length, "can't read from socket")) goto cleanup; if (length == 0) - return lua_yieldk(L, 0, ctx, lpm_getk); + return lua_yieldk(L, 0, ctx, ppm_getk); } else { header_end += 4; const char* protocol_end = strnstr_local(context->buffer, " ", context->buffer_length); @@ -1327,9 +1327,9 @@ static int lpm_getk(lua_State* L, int status, lua_KContext ctx) { lua_pushlstring(L, location, context->buffer_length); lua_setfield(L, -2, "location"); } else - lpm_set_error(context, "received invalid %d-response", code); + ppm_set_error(context, "received invalid %d-response", code); } else - lpm_set_error(context, "received non 200-response of %d", code); + ppm_set_error(context, "received non 200-response of %d", code); goto report; } const char* transfer_encoding = get_header(context->buffer, "transfer-encoding", NULL); @@ -1352,21 +1352,21 @@ static int lpm_getk(lua_State* L, int status, lua_KContext ctx) { char* newline = (char*)strnstr_local(context->buffer, "\r\n", context->buffer_length); if (newline) { *newline = '\0'; - if ((sscanf(context->buffer, "%x", &context->chunk_length) != 1 && lpm_set_error(context, "error retrieving chunk length"))) + if ((sscanf(context->buffer, "%x", &context->chunk_length) != 1 && ppm_set_error(context, "error retrieving chunk length"))) goto cleanup; else if (context->chunk_length == 0) goto finish; context->buffer_length -= (newline + 2 - context->buffer); if (context->buffer_length > 0) memmove(context->buffer, newline + 2, context->buffer_length); - } else if (context->buffer_length >= sizeof(context->buffer) && lpm_set_error(context, "can't find chunk length")) { + } else if (context->buffer_length >= sizeof(context->buffer) && ppm_set_error(context, "can't find chunk length")) { goto cleanup; } else { - int length = lpm_socket_read(context, -1); - if ((length <= 0 || (context->is_ssl && length == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY)) && lpm_get_error(context, length, "error retrieving full repsonse")) + int length = ppm_socket_read(context, -1); + if ((length <= 0 || (context->is_ssl && length == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY)) && ppm_get_error(context, length, "error retrieving full repsonse")) goto cleanup; if (length == 0) - return lua_yieldk(L, 0, ctx, lpm_getk); + return lua_yieldk(L, 0, ctx, ppm_getk); } } if (context->buffer_length > 0) { @@ -1399,7 +1399,7 @@ static int lpm_getk(lua_State* L, int status, lua_KContext ctx) { if (!context->chunked) goto finish; if (context->buffer_length >= 2) { - if (!strnstr_local(context->buffer, "\r\n", 2) && lpm_set_error(context, "invalid end to chunk")) + if (!strnstr_local(context->buffer, "\r\n", 2) && ppm_set_error(context, "invalid end to chunk")) goto cleanup; memmove(context->buffer, &context->buffer[2], context->buffer_length - 2); context->buffer_length -= 2; @@ -1408,13 +1408,13 @@ static int lpm_getk(lua_State* L, int status, lua_KContext ctx) { } } if (context->chunk_length > 0) { - int length = lpm_socket_read(context, imin(sizeof(context->buffer) - context->buffer_length, context->chunk_length - context->chunk_written + (context->chunked ? 2 : 0))); + int length = ppm_socket_read(context, imin(sizeof(context->buffer) - context->buffer_length, context->chunk_length - context->chunk_written + (context->chunked ? 2 : 0))); if ((!context->is_ssl && length == 0) || (context->is_ssl && context->content_length == -1 && length == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY)) goto finish; - if (length < 0 && lpm_get_error(context, length, "error retrieving full chunk")) + if (length < 0 && ppm_get_error(context, length, "error retrieving full chunk")) goto cleanup; if (length == 0) - return lua_yieldk(L, 0, ctx, lpm_getk); + return lua_yieldk(L, 0, ctx, ppm_getk); } } } @@ -1440,7 +1440,7 @@ static int lpm_getk(lua_State* L, int status, lua_KContext ctx) { luaL_pushresult(&b); lua_newtable(L); } - if (context->content_length != -1 && context->total_downloaded != context->content_length && lpm_set_error(context, "error retrieving full response")) + if (context->content_length != -1 && context->total_downloaded != context->content_length && ppm_set_error(context, "error retrieving full response")) goto cleanup; report: if (context->callback_function && !context->error_code) { @@ -1466,7 +1466,7 @@ static int lpm_getk(lua_State* L, int status, lua_KContext ctx) { return 2; } -static int lpm_get(lua_State* L) { +static int ppm_get(lua_State* L) { get_context_t* context = lua_newuserdata(L, sizeof(get_context_t)); memset(context, 0, sizeof(get_context_t)); int threaded = !lua_is_main_thread(L); @@ -1499,9 +1499,9 @@ static int lpm_get(lua_State* L) { mbedtls_net_set_block(&context->net); mbedtls_ssl_set_bio(&context->ssl, &context->net, mbedtls_net_send, mbedtls_net_recv, NULL); if ( - lpm_get_error(context, mbedtls_ssl_setup(&context->ssl, &ssl_config), "can't set up ssl") || - lpm_get_error(context, mbedtls_net_connect(&context->net, context->hostname, port, MBEDTLS_NET_PROTO_TCP), "can't set hostname") || - lpm_get_error(context, mbedtls_ssl_set_hostname(&context->ssl, context->hostname), "can't set hostname") + ppm_get_error(context, mbedtls_ssl_setup(&context->ssl, &ssl_config), "can't set up ssl") || + ppm_get_error(context, mbedtls_net_connect(&context->net, context->hostname, port, MBEDTLS_NET_PROTO_TCP), "can't set hostname") || + ppm_get_error(context, mbedtls_ssl_set_hostname(&context->ssl, context->hostname), "can't set hostname") ) { mbedtls_ssl_free(&context->ssl); mbedtls_net_free(&context->net); @@ -1535,12 +1535,12 @@ static int lpm_get(lua_State* L) { context->state = STATE_SEND; } if (!threaded) - return lpm_getk(L, 0, luaL_ref(L, LUA_REGISTRYINDEX)); - return lua_yieldk(L, 0, luaL_ref(L, LUA_REGISTRYINDEX), lpm_getk); + return ppm_getk(L, 0, luaL_ref(L, LUA_REGISTRYINDEX)); + return lua_yieldk(L, 0, luaL_ref(L, LUA_REGISTRYINDEX), ppm_getk); } -static int lpm_chdir(lua_State* L) { +static int ppm_chdir(lua_State* L) { #ifdef _WIN32 if (_wchdir(lua_toutf16(L, luaL_checkstring(L, 1)))) #else @@ -1550,7 +1550,7 @@ static int lpm_chdir(lua_State* L) { return 0; } -static int lpm_pwd(lua_State* L) { +static int ppm_pwd(lua_State* L) { #ifdef _WIN32 wchar_t buffer[MAX_PATH]; if (!_wgetcwd(buffer, sizeof(buffer))) @@ -1565,7 +1565,7 @@ static int lpm_pwd(lua_State* L) { return 1; } -static int lpm_flock(lua_State* L) { +static int ppm_flock(lua_State* L) { const char* path = luaL_checkstring(L, 1); luaL_checktype(L, 2, LUA_TFUNCTION); int error_handler = lua_type(L, 3) == LUA_TFUNCTION ? 3 : 0; @@ -1630,32 +1630,32 @@ static double get_time() { #endif } -static int lpm_time(lua_State* L) { +static int ppm_time(lua_State* L) { lua_pushnumber(L, get_time()); return 1; } static const luaL_Reg system_lib[] = { - { "ls", lpm_ls }, // Returns an array of files. - { "stat", lpm_stat }, // Returns info about a single file. - { "mkdir", lpm_mkdir }, // Makes a directory. - { "rmdir", lpm_rmdir }, // Removes a directory. - { "hash", lpm_hash }, // Returns a hex sha256 hash. - { "tcflush", lpm_tcflush }, // Flushes an terminal stream. - { "tcwidth", lpm_tcwidth }, // Gets the terminal width in columns. - { "symlink", lpm_symlink }, // Creates a symlink. - { "chmod", lpm_chmod }, // Chmod's a file. - { "init", lpm_init }, // Initializes a git repository with the specified remote. - { "fetch", lpm_fetch }, // Updates a git repository with the specified remote. - { "reset", lpm_reset }, // Updates a git repository to the specified commit/hash/branch. - { "get", lpm_get }, // HTTP(s) GET request. - { "extract", lpm_extract }, // Extracts .tar.gz, and .zip files. - { "trace", lpm_trace }, // Sets trace bit. - { "certs", lpm_certs }, // Sets the SSL certificate chain folder/file. - { "chdir", lpm_chdir }, // Changes directory. Only use for --post actions. - { "pwd", lpm_pwd }, // Gets existing directory. Only use for --post actions. - { "flock", lpm_flock }, // Locks a file. - { "time", lpm_time }, // Get high-precision system time. + { "ls", ppm_ls }, // Returns an array of files. + { "stat", ppm_stat }, // Returns info about a single file. + { "mkdir", ppm_mkdir }, // Makes a directory. + { "rmdir", ppm_rmdir }, // Removes a directory. + { "hash", ppm_hash }, // Returns a hex sha256 hash. + { "tcflush", ppm_tcflush }, // Flushes an terminal stream. + { "tcwidth", ppm_tcwidth }, // Gets the terminal width in columns. + { "symlink", ppm_symlink }, // Creates a symlink. + { "chmod", ppm_chmod }, // Chmod's a file. + { "init", ppm_init }, // Initializes a git repository with the specified remote. + { "fetch", ppm_fetch }, // Updates a git repository with the specified remote. + { "reset", ppm_reset }, // Updates a git repository to the specified commit/hash/branch. + { "get", ppm_get }, // HTTP(s) GET request. + { "extract", ppm_extract }, // Extracts .tar.gz, and .zip files. + { "trace", ppm_trace }, // Sets trace bit. + { "certs", ppm_certs }, // Sets the SSL certificate chain folder/file. + { "chdir", ppm_chdir }, // Changes directory. Only use for --post actions. + { "pwd", ppm_pwd }, // Gets existing directory. Only use for --post actions. + { "flock", ppm_flock }, // Locks a file. + { "time", ppm_time }, // Get high-precision system time. { NULL, NULL } }; @@ -1689,29 +1689,29 @@ static const luaL_Reg system_lib[] = { #error "Please define -DARCH_PLATFORM." #endif #endif -#ifndef LITE_ARCH_TUPLE - #define LITE_ARCH_TUPLE ARCH_PROCESSOR "-" ARCH_PLATFORM +#ifndef PRAGTICAL_ARCH_TUPLE + #define PRAGTICAL_ARCH_TUPLE ARCH_PROCESSOR "-" ARCH_PLATFORM #endif -#ifndef LPM_VERSION - #define LPM_VERSION "unknown" +#ifndef PPM_VERSION + #define PPM_VERSION "unknown" #endif -#ifndef LPM_DEFAULT_REPOSITORY - #define LPM_DEFAULT_REPOSITORY "https://github.com/lite-xl/lite-xl-plugin-manager.git:latest" +#ifndef PPM_DEFAULT_REPOSITORY + #define PPM_DEFAULT_REPOSITORY "https://github.com/pragtical/plugin-manager.git:latest" #endif // If this is defined as empty string, we disable self-upgrading. -#ifndef LPM_DEFAULT_RELEASE +#ifndef PPM_DEFAULT_RELEASE #if _WIN32 - #define LPM_DEFAULT_RELEASE "https://github.com/lite-xl/lite-xl-plugin-manager/releases/download/%r/lpm." LITE_ARCH_TUPLE ".exe" + #define PPM_DEFAULT_RELEASE "https://github.com/pragtical/plugin-manager/releases/download/%r/ppm." PRAGTICAL_ARCH_TUPLE ".exe" #else - #define LPM_DEFAULT_RELEASE "https://github.com/lite-xl/lite-xl-plugin-manager/releases/download/%r/lpm." LITE_ARCH_TUPLE + #define PPM_DEFAULT_RELEASE "https://github.com/pragtical/plugin-manager/releases/download/%r/ppm." PRAGTICAL_ARCH_TUPLE #endif #endif -#ifdef LPM_STATIC - extern const char lpm_luac[]; - extern unsigned int lpm_luac_len; +#ifdef PPM_STATIC + extern const char ppm_luac[]; + extern unsigned int ppm_luac_len; #endif int main(int argc, char* argv[]) { @@ -1725,7 +1725,7 @@ int main(int argc, char* argv[]) { lua_rawseti(L, -2, i+1); } lua_setglobal(L, "ARGV"); - lua_pushliteral(L, LPM_VERSION); + lua_pushliteral(L, PPM_VERSION); lua_setglobal(L, "VERSION"); lua_pushliteral(L, ARCH_PLATFORM); lua_setglobal(L, "PLATFORM"); @@ -1777,16 +1777,16 @@ int main(int argc, char* argv[]) { #endif lua_setglobal(L, "EXEFILE"); - lua_pushliteral(L, LITE_ARCH_TUPLE); + lua_pushliteral(L, PRAGTICAL_ARCH_TUPLE); lua_setglobal(L, "DEFAULT_ARCH"); - lua_pushliteral(L, LPM_DEFAULT_REPOSITORY); + lua_pushliteral(L, PPM_DEFAULT_REPOSITORY); lua_setglobal(L, "DEFAULT_REPO_URL"); - lua_pushliteral(L, LPM_DEFAULT_RELEASE); + lua_pushliteral(L, PPM_DEFAULT_RELEASE); lua_setglobal(L, "DEFAULT_RELEASE_URL"); - #ifndef LPM_STATIC - if (luaL_loadfile(L, "src/lpm.lua") || lua_pcall(L, 0, 1, 0)) { + #ifndef PPM_STATIC + if (luaL_loadfile(L, "src/ppm.lua") || lua_pcall(L, 0, 1, 0)) { #else - if (luaL_loadbuffer(L, lpm_luac, lpm_luac_len, "lpm.lua") || lua_pcall(L, 0, 1, 0)) { + if (luaL_loadbuffer(L, ppm_luac, ppm_luac_len, "ppm.lua") || lua_pcall(L, 0, 1, 0)) { #endif fprintf(stderr, "internal error when starting the application: %s\n", lua_tostring(L, -1)); return -1; diff --git a/src/lpm.lua b/src/ppm.lua similarity index 83% rename from src/lpm.lua rename to src/ppm.lua index 51b09cc..8cc6a3b 100644 --- a/src/lpm.lua +++ b/src/ppm.lua @@ -532,12 +532,12 @@ function common.args(arguments, options) end global({ - LATEST_MOD_VERSION = "3.0.0", + LATEST_MOD_VERSION = "3.5.0", EXECUTABLE_EXTENSION = PLATFORM == "windows" and ".exe" or "", SHOULD_COLOR = ((PLATFORM == "windows" or (os.getenv("TERM") and os.getenv("TERM") ~= "dumb")) and not os.getenv("NO_COLOR")) or false }) -global({ "HOME", "USERDIR", "CACHEDIR", "JSON", "TABLE", "HEADER", "RAW", "VERBOSE", "FILTRATION", "MOD_VERSION", "QUIET", "FORCE", "REINSTALL", "CONFIG", "NO_COLOR", "AUTO_PULL_REMOTES", "ARCH", "ASSUME_YES", "NO_INSTALL_OPTIONAL", "TMPDIR", "DATADIR", "BINARY", "POST", "PROGRESS", "SYMLINK", "REPOSITORY", "EPHEMERAL", "MASK", "settings", "repositories", "lite_xls", "system_bottle", "progress_bar_label", "write_progress_bar" }) -global({ Addon = {}, Repository = {}, LiteXL = {}, Bottle = {}, lpm = {}, log = {} }) +global({ "HOME", "USERDIR", "CACHEDIR", "JSON", "TABLE", "HEADER", "RAW", "VERBOSE", "FILTRATION", "MOD_VERSION", "QUIET", "FORCE", "REINSTALL", "CONFIG", "NO_COLOR", "AUTO_PULL_REMOTES", "ARCH", "ASSUME_YES", "NO_INSTALL_OPTIONAL", "TMPDIR", "DATADIR", "BINARY", "POST", "PROGRESS", "SYMLINK", "REPOSITORY", "EPHEMERAL", "MASK", "settings", "repositories", "pragticals", "system_bottle", "progress_bar_label", "write_progress_bar" }) +global({ Addon = {}, Repository = {}, Pragtical = {}, Bottle = {}, ppm = {}, log = {} }) -- in the cases where we don't have a manifest, assume generalized structure, take addons folder, trawl through it, build manifest that way -- assuming each .lua file under the `addons` folder is a addon. also parse the README, if present, and see if any of the addons @@ -683,19 +683,19 @@ local function match_version(version, pattern) return version == pattern end -local function compatible_modversion(lite_xl_modversion, addon_modversion) - local result = compare_version(lite_xl_modversion, addon_modversion) +local function compatible_modversion(pragtical_modversion, addon_modversion) + local result = compare_version(pragtical_modversion, addon_modversion) return result >= 0 and result < 3 end --- There can exist many different versions of an addon. All statuses are relative to a particular lite bottle. +-- There can exist many different versions of an addon. All statuses are relative to a particular pragtical bottle. -- available: Addon is available in a repository, and can be installed. There is no comparable version on the system. -- upgradable: Addon is installed, but does not match the highest version in any repository. -- orphan: Addon is installed, but there is no corresponding addon in any repository. -- installed: Addon is installed, and matches the highest version in any repository, or highest version is incompatible. --- core: Addon is a part of the lite data directory, and doesn't have corresponding addons in any repository. --- bundled: Addon is part of the lite data directory, but has corresponding addons in any repository. +-- core: Addon is a part of the pragtical data directory, and doesn't have corresponding addons in any repository. +-- bundled: Addon is part of the pragtical data directory, but has corresponding addons in any repository. -- incompatible: Addon is not installed and conflicts with existing installed addons. function Addon.__index(self, idx) return rawget(self, idx) or Addon[idx] end function Addon.new(repository, metadata) @@ -770,7 +770,7 @@ end function Addon:get_install_path(bottle) local folder = self.type == "library" and "libraries" or (self.type .. "s") - local path = (((self:is_core(bottle) or self:is_bundled()) and bottle.lite_xl.datadir_path) or (bottle.local_path and (bottle.local_path .. PATHSEP .. "user") or USERDIR)) .. PATHSEP .. folder + local path = (((self:is_core(bottle) or self:is_bundled()) and bottle.pragtical.datadir_path) or (bottle.local_path and (bottle.local_path .. PATHSEP .. "user") or USERDIR)) .. PATHSEP .. folder if self:is_asset() and self.organization == "singleton" then if (self.path or self.url) and common.basename(self.path or self.url):gsub("%.%w+$", "") ~= self.id then log.warning(string.format("Mistmatch between asset url/path filename and id; (%s vs. %s)", self.path or self.url, self.id)) @@ -831,7 +831,7 @@ function Addon:get_compatibilities(bottle) local dependency_list = common.canonical_order(self.dependencies) for _, addon in ipairs(dependency_list) do local v = self.dependencies[addon] - local potential_addons = { bottle:get_addon(addon, v.version, { mod_version = bottle.lite_xl.mod_version }) } + local potential_addons = { bottle:get_addon(addon, v.version, { mod_version = bottle.pragtical.mod_version }) } for i, potential_addon in ipairs(potential_addons) do local incomaptibilities = common.grep(installed_addons, function(p) return p:is_incompatible(potential_addon) end) if #incomaptibilities == 0 then @@ -1016,7 +1016,7 @@ end function Addon:get_orphaned_dependencies(bottle, uninstalling) local t = {} - uninstalling = uninstalling or { [self.id] = true } + uninstalling = uninstalling or { [self.id] = true } local installed_addons = system_bottle:installed_addons() for i, id in ipairs(common.canonical_order(self.dependencies)) do local options = self.dependencies[id] @@ -1085,7 +1085,7 @@ function Repository.new(hash) live = nil, addons = nil, repo_path = hash.repo_path or (CACHEDIR .. PATHSEP .. "repos" .. PATHSEP .. system.hash(hash.remote)), - lite_xls = {}, + pragticals = {}, last_retrieval = nil }, Repository) if not self:is_local() then @@ -1151,8 +1151,8 @@ function Repository:parse_manifest(repo_id) for i, metadata in ipairs(self.manifest["addons"] or self.manifest["plugins"] or {}) do table.insert(self.addons, Addon.new(self, metadata)) end - for i, metadata in ipairs(self.manifest["lite-xls"] or {}) do - table.insert(self.lite_xls, LiteXL.new(self, metadata)) + for i, metadata in ipairs(self.manifest["pragticals"] or {}) do + table.insert(self.pragticals, Pragtical.new(self, metadata)) end self.remotes = common.map(self.manifest["remotes"] or {}, function(r) return Repository.url(r) end) end) @@ -1318,7 +1318,7 @@ function Repository:update(pull_remotes) if self.branch then log.progress_action("Updating " .. self:url() .. "...") local status, err = pcall(system.fetch, self.local_path, write_progress_bar, "+refs/heads/" .. self.branch .. ":refs/remotes/origin/" .. self.branch) - if not status then -- see https://github.com/lite-xl/lite-xl-plugin-manager/issues/85 + if not status then -- see https://github.com/pragtical/pragtical-plugin-manager/issues/85 if not err:find("object not found %- no match for id") then error(err, 0) end common.rmrf(self.local_path) return self:fetch() @@ -1346,46 +1346,46 @@ function Repository:remove() end -function LiteXL.__index(t, k) return LiteXL[k] end -function LiteXL.new(repository, metadata) - if not metadata.version then error("lite-xl entry requires a version") end +function Pragtical.__index(t, k) return Pragtical[k] end +function Pragtical.new(repository, metadata) + if not metadata.version then error("pragtical entry requires a version") end local self = setmetatable(common.merge({ repository = repository, tags = {}, files = {} - }, metadata), LiteXL) + }, metadata), Pragtical) self.hash = system.hash((repository and repository:url() or "") .. "-" .. metadata.version .. common.join("", common.map(self.files, function(f) return f.checksum end))) - self.local_path = self:is_local() and self.path or (CACHEDIR .. PATHSEP .. "lite_xls" .. PATHSEP .. self.version .. PATHSEP .. self.hash) + self.local_path = self:is_local() and self.path or (CACHEDIR .. PATHSEP .. "pragticals" .. PATHSEP .. self.version .. PATHSEP .. self.hash) self.binary_path = self.binary_path or { } self.datadir_path = self.datadir_path or (self.local_path .. PATHSEP .. "data") return self end -function LiteXL:get_binary_path(arch) +function Pragtical:get_binary_path(arch) if self.binary_path and self.binary_path[arch or DEFAULT_ARCH] then return self.binary_path[arch or DEFAULT_ARCH] end - return self.local_path .. PATHSEP .. "lite-xl" + return self.local_path .. PATHSEP .. "pragtical" end -function LiteXL:is_system() return system_bottle and system_bottle.lite_xl == self end -function LiteXL:is_local() return not self.repository and self.path end -function LiteXL:is_compatible(addon) return not addon.mod_version or compatible_modversion(self.mod_version, addon.mod_version) end -function LiteXL:is_installed() return system.stat(self.local_path) ~= nil end +function Pragtical:is_system() return system_bottle and system_bottle.pragtical == self end +function Pragtical:is_local() return not self.repository and self.path end +function Pragtical:is_compatible(addon) return not addon.mod_version or compatible_modversion(self.mod_version, addon.mod_version) end +function Pragtical:is_installed() return system.stat(self.local_path) ~= nil end -function LiteXL:install() - if self:is_installed() then log.warning("lite-xl " .. self.version .. " already installed") return end +function Pragtical:install() + if self:is_installed() then log.warning("pragtical " .. self.version .. " already installed") return end common.mkdirp(self.local_path) - if system_bottle.lite_xl == self then -- system lite-xl. We have to copy it because we can't really set the user directory. - local executable, datadir = common.path("lite-xl" .. EXECUTABLE_EXTENSION) - if not executable then error("can't find system lite-xl executable") end + if system_bottle.pragtical == self then -- system pragtical. We have to copy it because we can't really set the user directory. + local executable, datadir = common.path("pragtical" .. EXECUTABLE_EXTENSION) + if not executable then error("can't find system pragtical executable") end local stat = system.stat(executable) executable = stat.symlink and stat.symlink or executable datadir = common.dirname(executable) .. PATHSEP .. "data" - if not system.stat(datadir) then error("can't find system lite-xl data dir") end - common.copy(executable, self.local_path .. PATHSEP .. "lite-xl") - system.chmod(self.local_path .. PATHSEP .. "lite-xl", 448) -- chmod to rwx------- + if not system.stat(datadir) then error("can't find system pragtical data dir") end + common.copy(executable, self.local_path .. PATHSEP .. "pragtical") + system.chmod(self.local_path .. PATHSEP .. "pragtical", 448) -- chmod to rwx------- common.copy(datadir, self.local_path .. PATHSEP .. "data") elseif self.path and not self.repository then -- local repository - system.symlink(self:get_binary_path(), self.local_path .. PATHSEP .. "lite_xl") + system.symlink(self:get_binary_path(), self.local_path .. PATHSEP .. "pragtical") else if self.remote then system.init(self.local_path, self.remote) @@ -1395,45 +1395,45 @@ function LiteXL:install() if file.arch and common.grep(ARCH, function(e) return e == file.arch end)[1] then if not file.checksum then error("requires a checksum") end local basename = common.basename(file.url) - local archive = assert(basename:find("%.zip$") or basename:find("%.tar%.gz$"), "lite-xl files must be archives") - local path = self.local_path .. PATHSEP .. (archive and basename or "lite-xl") + local archive = assert(basename:find("%.zip$") or basename:find("%.tar%.gz$"), "pragtical files must be archives") + local path = self.local_path .. PATHSEP .. (archive and basename or "pragtical") log.action("Downloading file " .. file.url .. "...") common.get(file.url, { target = path, checksum = file.checksum, callback = write_progress_bar }) log.action("Downloaded file " .. file.url .. " to " .. path) if archive then log.action("Extracting file " .. basename .. " in " .. self.local_path) system.extract(path, self.local_path) - -- because this is a lite-xl archive binary, we should expect to find a `lite-xl` folder, containing the lite-xl binary, and a data directory + -- because this is a pragtical archive binary, we should expect to find a `pragtical` folder, containing the pragtical binary, and a data directory -- we want to move these into the primary directory, then delete the archive and the directory - common.rename(self.local_path .. PATHSEP .. "lite-xl", self.local_path .. PATHSEP .. "dir") + common.rename(self.local_path .. PATHSEP .. "pragtical", self.local_path .. PATHSEP .. "dir") common.rename(self.local_path .. PATHSEP .. "dir" .. PATHSEP .. "data", self.local_path .. PATHSEP .. "data") - common.rename(self.local_path .. PATHSEP .. "dir" .. PATHSEP .. "lite-xl", self.local_path .. PATHSEP .. "lite-xl") + common.rename(self.local_path .. PATHSEP .. "dir" .. PATHSEP .. "pragtical", self.local_path .. PATHSEP .. "pragtical") common.rmrf(self.local_path .. PATHSEP .. "dir") common.rmrf(path) end end end end - if not system.stat(self.local_path .. PATHSEP .. "lite-xl") then error("can't find executable for lite-xl " .. self.version) end + if not system.stat(self.local_path .. PATHSEP .. "pragtical") then error("can't find executable for pragtical " .. self.version) end end -function LiteXL:uninstall() - if not system.stat(self.local_path) then error("lite-xl " .. self.version .. " not installed") end +function Pragtical:uninstall() + if not system.stat(self.local_path) then error("pragtical " .. self.version .. " not installed") end common.rmrf(self.local_path) end function Bottle.__index(t, k) return Bottle[k] end -function Bottle.new(lite_xl, addons, config, is_system) +function Bottle.new(pragtical, addons, config, is_system) local self = setmetatable({ - lite_xl = lite_xl, + pragtical = pragtical, addons = addons, config = config, is_system = is_system }, Bottle) if not is_system then table.sort(self.addons, function(a, b) return (a.id .. ":" .. a.version) < (b.id .. ":" .. b.version) end) - self.hash = system.hash(lite_xl.version .. " " .. common.join(" ", common.map(self.addons, function(p) return (p.repository and p.repository:url() or "") .. ":" .. p.id .. ":" .. p.version end)) .. (config or "") .. (EPHEMERAL and "E" or "")) + self.hash = system.hash(pragtical.version .. " " .. common.join(" ", common.map(self.addons, function(p) return (p.repository and p.repository:url() or "") .. ":" .. p.id .. ":" .. p.version end)) .. (config or "") .. (EPHEMERAL and "E" or "")) if EPHEMERAL then for i = 1, 1000 do self.local_path = CACHEDIR .. PATHSEP .. "bottles" .. PATHSEP .. self.hash .. "-" .. i @@ -1464,19 +1464,19 @@ function Bottle:construct() self.local_path = TMPDIR .. PATHSEP .. "bottles" .. PATHSEP .. self.hash common.rmrf(self.local_path) - if not self.lite_xl:is_installed() then self.lite_xl:install() end + if not self.pragtical:is_installed() then self.pragtical:install() end common.mkdirp(self.local_path .. PATHSEP .. "user") if self.config then common.write(self.local_path .. PATHSEP .. "user" .. PATHSEP .. "init.lua", DEFAULT_CONFIG_HEADER .. self.config) end - -- Always copy the executbale, because of the way that lite determines the user folder (for now). - common.copy(self.lite_xl:get_binary_path(), self.local_path .. PATHSEP .. "lite-xl" .. EXECUTABLE_EXTENSION) - system.chmod(self.local_path .. PATHSEP .. "lite-xl" .. EXECUTABLE_EXTENSION, 448) -- chmod to rwx-------\ + -- Always copy the executbale, because of the way that pragtical determines the user folder (for now). + common.copy(self.pragtical:get_binary_path(), self.local_path .. PATHSEP .. "pragtical" .. EXECUTABLE_EXTENSION) + system.chmod(self.local_path .. PATHSEP .. "pragtical" .. EXECUTABLE_EXTENSION, 448) -- chmod to rwx-------\ if SYMLINK then - system.symlink(self.lite_xl.datadir_path, self.local_path .. PATHSEP .. "data") + system.symlink(self.pragtical.datadir_path, self.local_path .. PATHSEP .. "data") else - common.copy(self.lite_xl.datadir_path, self.local_path .. PATHSEP .. "data") + common.copy(self.pragtical.datadir_path, self.local_path .. PATHSEP .. "data") end local installing = {} for i,addon in ipairs(self.addons) do @@ -1526,13 +1526,13 @@ end function Bottle:destruct() if self.is_system then error("system bottle cannot be destructed") end - if not self:is_constructed() then error("lite-xl " .. self.version .. " not constructed") end + if not self:is_constructed() then error("pragtical " .. self.version .. " not constructed") end common.rmrf(self.local_path) end function Bottle:run(args) args = args or {} - local path = not self.is_system and (self.local_path .. PATHSEP .. "lite-xl" .. EXECUTABLE_EXTENSION) or self.lite_xl:get_binary_path() + local path = not self.is_system and (self.local_path .. PATHSEP .. "pragtical" .. EXECUTABLE_EXTENSION) or self.pragtical:get_binary_path() if not system.stat(path) then error("cannot find bottle executable " .. path) end local line = path .. (#args > 0 and " " or "") .. table.concat(common.map(args, function(arg) if PLATFORM == "windows" then @@ -1589,7 +1589,7 @@ function Bottle:all_addons() for _, addon_type in ipairs({ "plugins", "libraries", "fonts", "colors" }) do local addon_paths = { (self.local_path and (self.local_path .. PATHSEP .. "user") or USERDIR) .. PATHSEP .. addon_type, - self.lite_xl.datadir_path .. PATHSEP .. addon_type + self.pragtical.datadir_path .. PATHSEP .. addon_type } for i, addon_path in ipairs(addon_paths) do if system.stat(addon_path) then @@ -1615,11 +1615,13 @@ function Bottle:all_addons() location = (i == 2 and (hash[id] and "bundled" or "core")) or "user", organization = (v:find("%.lua$") and "singleton" or "complex"), local_path = path, - mod_version = self.lite_xl.mod_version, + mod_version = self.pragtical.mod_version, path = addon_type .. PATHSEP .. v, - description = (hash[id] and hash[id][1].description or nil), - repo_path = (hash[id] and hash[id][1].local_path or nil), - dependencies = (hash[id] and hash[id][1].dependencies or nil) + -- temporary fix upstream bug directly on our ppm fork + -- which consists on checking if hash[id][1] is set + description = ((hash[id] and hash[id][1]) and hash[id][1].description or nil), + repo_path = ((hash[id] and hash[id][1]) and hash[id][1].local_path or nil), + dependencies = ((hash[id] and hash[id][1]) and hash[id][1].dependencies or nil) })) if not hash[id] then hash[id] = t[#t] end end @@ -1636,7 +1638,7 @@ function Bottle:all_addons() location = "core", organization = "singleton", local_path = nil, - mod_version = self.lite_xl.mod_version, + mod_version = self.pragtical.mod_version, path = "plugins" .. PATHSEP .. id .. ".lua" })) end @@ -1720,33 +1722,33 @@ local function get_repository(url) return nil end -function lpm.settings_save() +function ppm.settings_save() common.write(CACHEDIR .. PATHSEP .. "settings.json", json.encode(settings)) end -function lpm.repo_save() +function ppm.repo_save() settings.repositories = common.map(repositories, function(r) return r:url() end) - lpm.settings_save() + ppm.settings_save() end local DEFAULT_REPOS -function lpm.repo_init(repos) +function ppm.repo_init(repos) DEFAULT_REPOS = { Repository.url(DEFAULT_REPO_URL) } common.mkdirp(CACHEDIR) if not system.stat(CACHEDIR .. PATHSEP .. "settings.json") then for i, repository in ipairs(repos or DEFAULT_REPOS) do table.insert(repositories, repository:add(true)) end - lpm.repo_save() + ppm.repo_save() end end -function lpm.repo_add(...) +function ppm.repo_add(...) for i, url in ipairs({ ... }) do local idx, repo = get_repository(url) if repo then -- if we're alreayd a repo, put this at the head of the resolution list @@ -1757,22 +1759,22 @@ function lpm.repo_add(...) table.insert(repositories, 1, repo) repo:update() end - lpm.repo_save() + ppm.repo_save() end -function lpm.repo_rm(...) +function ppm.repo_rm(...) for i, url in ipairs({ ... }) do local idx, repo = get_repository(url) if not repo then error("cannot find repository " .. url) end table.remove(repositories, idx) repo:remove() end - lpm.repo_save() + ppm.repo_save() end -function lpm.repo_update(...) +function ppm.repo_update(...) local t = { ... } if #t == 0 then table.insert(t, false) end for i, url in ipairs(t) do @@ -1785,114 +1787,114 @@ function lpm.repo_update(...) end end -function lpm.get_lite_xl(version) - return common.first(common.concat(lite_xls, common.flat_map(repositories, function(e) return e.lite_xls end)), function(lite_xl) return lite_xl.version == version end) +function ppm.get_pragtical(version) + return common.first(common.concat(pragticals, common.flat_map(repositories, function(e) return e.pragticals end)), function(pragtical) return pragtical.version == version end) end -function lpm.lite_xl_save() - settings.lite_xls = common.map(common.grep(lite_xls, function(l) return l:is_local() and not l:is_system() end), function(l) return { version = l.version, mod_version = l.mod_version, path = l.path, binary_path = l.binary_path, datadir_path = l.datadir_path } end) - lpm.settings_save() +function ppm.pragtical_save() + settings.pragticals = common.map(common.grep(pragticals, function(l) return l:is_local() and not l:is_system() end), function(l) return { version = l.version, mod_version = l.mod_version, path = l.path, binary_path = l.binary_path, datadir_path = l.datadir_path } end) + ppm.settings_save() end -function lpm.lite_xl_add(version, path) +function ppm.pragtical_add(version, path) if not version then error("requires a version") end if not version:find("^%d") then error("versions must begin numerically (i.e. 2.1.1-debug)") end - if common.first(lite_xls, function(lite_xl) return lite_xl.version == version end) then error(version .. " lite-xl already exists") end - local binary_path = BINARY or (path and(path .. PATHSEP .. "lite-xl" .. EXECUTABLE_EXTENSION)) + if common.first(pragticals, function(pragtical) return pragtical.version == version end) then error(version .. " pragtical already exists") end + local binary_path = BINARY or (path and(path .. PATHSEP .. "pragtical" .. EXECUTABLE_EXTENSION)) local data_path = DATADIR or (path and (path .. PATHSEP .. "data")) local binary_stat, data_stat = system.stat(binary_path), system.stat(data_path) if not binary_stat then error("can't find binary path " .. binary_path) end if not data_stat then error("can't find data path " .. data_path) end local path_stat = system.stat(path:gsub(PATHSEP .. "$", "")) - if not path_stat then error("can't find lite-xl path " .. path) end - table.insert(lite_xls, LiteXL.new(nil, { version = version, binary_path = { [ARCH[1]] = binary_stat.abs_path }, datadir_path = data_stat.abs_path, path = path_stat.abs_path, mod_version = MOD_VERSION or LATEST_MOD_VERSION })) - lpm.lite_xl_save() + if not path_stat then error("can't find pragtical path " .. path) end + table.insert(pragticals, Pragtical.new(nil, { version = version, binary_path = { [ARCH[1]] = binary_stat.abs_path }, datadir_path = data_stat.abs_path, path = path_stat.abs_path, mod_version = MOD_VERSION or LATEST_MOD_VERSION })) + ppm.pragtical_save() end -function lpm.lite_xl_rm(version) +function ppm.pragtical_rm(version) if not version then error("requires a version") end - local lite_xl = lpm.get_lite_xl(version) or error("can't find lite_xl version " .. version) - lite_xls = common.grep(lite_xls, function(l) return l ~= lite_xl end) - lpm.lite_xl_save() + local pragtical = ppm.get_pragtical(version) or error("can't find pragtical version " .. version) + pragticals = common.grep(pragticals, function(l) return l ~= pragtical end) + ppm.pragtical_save() end -function lpm.lite_xl_install(version) +function ppm.pragtical_install(version) if not version then error("requires a version") end - (lpm.get_lite_xl(version) or error("can't find lite-xl version " .. version)):install() + (ppm.get_pragtical(version) or error("can't find pragtical version " .. version)):install() end -function lpm.lite_xl_switch(version, target) +function ppm.pragtical_switch(version, target) if not version then error("requires a version") end - target = target or common.path("lite-xl" .. EXECUTABLE_EXTENSION) - if not target then error("can't find installed lite-xl. please provide a target to install the symlink explicitly as a second argument") end - local lite_xl = lpm.get_lite_xl(version) or error("can't find lite-xl version " .. version) - if not lite_xl:is_installed() then log.action("Installing lite-xl " .. lite_xl.version) lite_xl:install() end + target = target or common.path("pragtical" .. EXECUTABLE_EXTENSION) + if not target then error("can't find installed pragtical. please provide a target to install the symlink explicitly as a second argument") end + local pragtical = ppm.get_pragtical(version) or error("can't find pragtical version " .. version) + if not pragtical:is_installed() then log.action("Installing pragtical " .. pragtical.version) pragtical:install() end local stat = system.stat(target) if stat and stat.symlink then os.remove(target) end - system.symlink(lite_xl:get_binary_path(), target) - if not common.path('lite-xl' .. EXECUTABLE_EXTENSION) then + system.symlink(pragtical:get_binary_path(), target) + if not common.path('pragtical' .. EXECUTABLE_EXTENSION) then os.remove(target) - error(target .. " is not on your $PATH; please supply a target that can be found on your $PATH, called `lite-xl`.") + error(target .. " is not on your $PATH; please supply a target that can be found on your $PATH, called `pragtical`.") end end -function lpm.lite_xl_uninstall(version) - (lpm.get_lite_xl(version) or error("can't find lite-xl version " .. version)):uninstall() +function ppm.pragtical_uninstall(version) + (ppm.get_pragtical(version) or error("can't find pragtical version " .. version)):uninstall() end -function lpm.lite_xl_list() - local result = { ["lite-xls"] = { } } +function ppm.pragtical_list() + local result = { ["pragticals"] = { } } local max_version = 0 - for i,lite_xl in ipairs(lite_xls) do - table.insert(result["lite-xls"], { - version = lite_xl.version, - mod_version = lite_xl.mod_version, - tags = lite_xl.tags, - is_system = lite_xl:is_system(), - is_installed = lite_xl:is_installed(), - status = (lite_xl:is_installed() or lite_xl:is_system()) and (lite_xl:is_local() and "local" or "installed") or "available", - local_path = lite_xl:is_installed() and lite_xl.local_path or nil, - datadir_path = lite_xl:is_installed() and lite_xl.datadir_path or nil, - binary_path = lite_xl:is_installed() and lite_xl.binary_path or nil + for i,pragtical in ipairs(pragticals) do + table.insert(result["pragticals"], { + version = pragtical.version, + mod_version = pragtical.mod_version, + tags = pragtical.tags, + is_system = pragtical:is_system(), + is_installed = pragtical:is_installed(), + status = (pragtical:is_installed() or pragtical:is_system()) and (pragtical:is_local() and "local" or "installed") or "available", + local_path = pragtical:is_installed() and pragtical.local_path or nil, + datadir_path = pragtical:is_installed() and pragtical.datadir_path or nil, + binary_path = pragtical:is_installed() and pragtical.binary_path or nil }) - max_version = math.max(max_version, #lite_xl.version) + max_version = math.max(max_version, #pragtical.version) end for i,repo in ipairs(repositories) do - if not repo.lite_xls then error("can't find lite-xl for repo " .. repo:url()) end - for j, lite_xl in ipairs(repo.lite_xls) do - table.insert(result["lite-xls"], { - version = lite_xl.version, - mod_version = lite_xl.mod_version, + if not repo.pragticals then error("can't find pragtical for repo " .. repo:url()) end + for j, pragtical in ipairs(repo.pragticals) do + table.insert(result["pragticals"], { + version = pragtical.version, + mod_version = pragtical.mod_version, repository = repo:url(), - tags = lite_xl.tags, - is_system = lite_xl:is_system(), - is_installed = lite_xl:is_installed(), - status = (lite_xl:is_installed() or lite_xl:is_system()) and (lite_xl:is_local() and "local" or "installed") or "available", - local_path = lite_xl:is_installed() and lite_xl.local_path + tags = pragtical.tags, + is_system = pragtical:is_system(), + is_installed = pragtical:is_installed(), + status = (pragtical:is_installed() or pragtical:is_system()) and (pragtical:is_local() and "local" or "installed") or "available", + local_path = pragtical:is_installed() and pragtical.local_path }) - max_version = math.max(max_version, #lite_xl.version) + max_version = math.max(max_version, #pragtical.version) end end if JSON then io.stdout:write(json.encode(result) .. "\n") else if VERBOSE then - for i, lite_xl in ipairs(result["lite-xls"]) do + for i, pragtical in ipairs(result["pragticals"]) do if i ~= 0 then print("---------------------------") end - print("Version: " .. lite_xl.version) - print("Status: " .. lite_xl.status) - print("Mod-Version: " .. (lite_xl.mod_version or "unknown")) - print("Tags: " .. common.join(", ", lite_xl.tags)) + print("Version: " .. pragtical.version) + print("Status: " .. pragtical.status) + print("Mod-Version: " .. (pragtical.mod_version or "unknown")) + print("Tags: " .. common.join(", ", pragtical.tags)) end else max_version = max_version + 2 print(string.format("%" .. max_version .. "s | %10s | %s", "Version", "Status", "Location")) print(string.format("%" .. max_version .."s | %10s | %s", "-------", "---------", "---------------------------")) - for i, lite_xl in ipairs(result["lite-xls"]) do - print(string.format("%" .. max_version .. "s | %10s | %s", (lite_xl.is_system and "* " or "") .. lite_xl.version, lite_xl.status, (lite_xl.is_installed and lite_xl.local_path or lite_xl.repository))) + for i, pragtical in ipairs(result["pragticals"]) do + print(string.format("%" .. max_version .. "s | %10s | %s", (pragtical.is_system and "* " or "") .. pragtical.version, pragtical.status, (pragtical.is_installed and pragtical.local_path or pragtical.repository))) end end end @@ -1902,7 +1904,7 @@ local function is_argument_repo(arg) return arg:find("^http") or arg:find("[\\/]") or arg == "." end -function lpm.retrieve_addons(lite_xl, arguments, filters) +function ppm.retrieve_addons(pragtical, arguments, filters) local addons = {} local i = 1 while i <= #arguments do @@ -1917,7 +1919,7 @@ function lpm.retrieve_addons(lite_xl, arguments, filters) if not remainder then repo = nil end local id, version = common.split(":", remainder or str) - local potentials = { system_bottle:get_addon(id, version, common.merge({ mod_version = lite_xl.mod_version, repository = repo }, filters or {})) } + local potentials = { system_bottle:get_addon(id, version, common.merge({ mod_version = pragtical.mod_version, repository = repo }, filters or {})) } local uniq = {} local found_one = false for i, addon in ipairs(potentials) do @@ -1941,9 +1943,9 @@ function lpm.retrieve_addons(lite_xl, arguments, filters) return addons, i end -function lpm.apply(...) +function ppm.apply(...) local arguments = { ... } - local addons, i = lpm.retrieve_addons(system_bottle.lite_xl, arguments) + local addons, i = ppm.retrieve_addons(system_bottle.pragtical, arguments) if #arguments >= i then error("invalid use of --") end local changed = system_bottle:apply(addons, CONFIG) if JSON then @@ -1954,7 +1956,7 @@ function lpm.apply(...) end -function lpm.lite_xl_run(...) +function ppm.pragtical_run(...) local version, version_idx = "system", 1 local arguments = { } for i,v in ipairs({ ... }) do @@ -1969,14 +1971,14 @@ function lpm.lite_xl_run(...) table.insert(arguments, v) end end - local lite_xl = lpm.get_lite_xl(version) or error("can't find lite-xl version " .. version) - local potential_addons, i = lpm.retrieve_addons(lite_xl, arguments) + local pragtical = ppm.get_pragtical(version) or error("can't find pragtical version " .. version) + local potential_addons, i = ppm.retrieve_addons(pragtical, arguments) local addons = common.map(potential_addons, function(potentials) return common.grep(potentials, function(addon) return not addon:is_core(system_bottle) and not addon:is_orphan(system_bottle) end)[1] end) - local bottle = Bottle.new(lite_xl, addons, CONFIG) + local bottle = Bottle.new(pragtical, addons, CONFIG) if not bottle:is_constructed() or REINSTALL then bottle:construct() end return function() bottle:run(common.slice(arguments, i + 1)) @@ -1985,11 +1987,11 @@ function lpm.lite_xl_run(...) end -function lpm.install(type, ...) +function ppm.install(type, ...) local arguments = { ... } for i, identifier in ipairs(arguments) do local id, version = common.split(":", identifier) - if id == "lite-xl" then lpm.lite_xl_install(version) + if id == "pragtical" then ppm.pragtical_install(version) table.remove(arguments, i) break end @@ -1997,11 +1999,11 @@ function lpm.install(type, ...) local to_install = {} local to_explicitly_install = {} - local potential_addon_list = lpm.retrieve_addons(system_bottle.lite_xl, arguments, { type = type }) + local potential_addon_list = ppm.retrieve_addons(system_bottle.pragtical, arguments, { type = type }) for i, potential_addons in ipairs(potential_addon_list) do local id = potential_addons[1].id local addons = common.grep(potential_addons, function(e) return e:is_installable(system_bottle) and (not e:is_installed(system_bottle) or REINSTALL) end) - if #addons == 0 and #potential_addons == 0 then error("can't find " .. (type or "addon") .. " " .. id .. " mod-version: " .. (system_bottle.lite_xl.mod_version or 'any')) end + if #addons == 0 and #potential_addons == 0 then error("can't find " .. (type or "addon") .. " " .. id .. " mod-version: " .. (system_bottle.pragtical.mod_version or 'any')) end if #addons == 0 then log.warning((potential_addons[1].type or "addon") .. " " .. id .. " already installed") if not common.first(settings.installed, id) then table.insert(to_explicitly_install, id) end @@ -2020,7 +2022,7 @@ function lpm.install(type, ...) end end) settings.installed = common.concat(settings.installed, to_explicitly_install) - lpm.settings_save() + ppm.settings_save() end local function get_table(headers, rows) @@ -2054,14 +2056,14 @@ local function print_addon_info(type, addons, filters) elseif addon.path then url = addon.path end local hash = { id = addon.id, - status = addon.repository and (addon:is_installed(system_bottle) and "installed" or (system_bottle.lite_xl:is_compatible(addon) and "available" or "incompatible")) or (addon:is_bundled(system_bottle) and "bundled" or (addon:is_core(system_bottle) and "core" or (addon:is_upgradable(system_bottle) and "upgradable" or "orphan"))), + status = addon.repository and (addon:is_installed(system_bottle) and "installed" or (system_bottle.pragtical:is_compatible(addon) and "available" or "incompatible")) or (addon:is_bundled(system_bottle) and "bundled" or (addon:is_core(system_bottle) and "core" or (addon:is_upgradable(system_bottle) and "upgradable" or "orphan"))), stub = (addon:is_stub() and "git" or false), name = addon.name or addon.id, version = "" .. addon.version, dependencies = addon.dependencies, remote = addon.remote, description = addon.description, - author = addon.extra and addon.extra.author or (addon:is_core(system_bottle) and "lite-xl") or nil, + author = addon.extra and addon.extra.author or (addon:is_core(system_bottle) and "pragtical") or nil, extra = addon.extra, mod_version = addon.mod_version or LATEST_MOD_VERSION, tags = addon.tags, @@ -2129,7 +2131,7 @@ local function print_addon_info(type, addons, filters) end -function lpm.unstub(type, ...) +function ppm.unstub(type, ...) local addons = {} for i, identifier in ipairs({ ... }) do if not identifier then error('unrecognized identifier ' .. identifier) end @@ -2137,9 +2139,9 @@ function lpm.unstub(type, ...) table.insert(repositories, 1, Repository.url(identifier):add(AUTO_PULL_REMOTES)) system_bottle:invalidate_cache() else - local potential_addons = { system_bottle:get_addon(identifier, nil, { mod_version = system_bottle.lite_xl.mod_version }) } + local potential_addons = { system_bottle:get_addon(identifier, nil, { mod_version = system_bottle.pragtical.mod_version }) } addons = common.grep(potential_addons, function(e) return e:is_stub() end) - if #addons == 0 and #potential_addons == 0 then error("can't find " .. (type or "addon") .. " " .. identifier .. " mod-version: " .. (system_bottle.lite_xl.mod_version or 'any')) end + if #addons == 0 and #potential_addons == 0 then error("can't find " .. (type or "addon") .. " " .. identifier .. " mod-version: " .. (system_bottle.pragtical.mod_version or 'any')) end if #addons == 0 then log.warning((potential_addons[1].type or "addon") .. " " .. identifier .. " already unstubbed") end @@ -2150,7 +2152,7 @@ function lpm.unstub(type, ...) end -function lpm.addon_uninstall(type, ...) +function ppm.addon_uninstall(type, ...) for i, id in ipairs({ ... }) do local addons = { system_bottle:get_addon(id, nil, { type = type }) } if #addons == 0 then error("can't find addon " .. id) end @@ -2161,12 +2163,12 @@ function lpm.addon_uninstall(type, ...) settings.installed = common.grep(settings.installed, function(e) return e ~= addon.id end) end end - lpm.settings_save() + ppm.settings_save() end -function lpm.addon_reinstall(type, ...) for i, id in ipairs({ ... }) do pcall(lpm.addon_uninstall, type, id) end lpm.install(type, ...) end +function ppm.addon_reinstall(type, ...) for i, id in ipairs({ ... }) do pcall(ppm.addon_uninstall, type, id) end ppm.install(type, ...) end -function lpm.repo_list() +function ppm.repo_list() if JSON then io.stdout:write(json.encode({ repositories = common.map(repositories, function(repo) return { remote = repo.remote, commit = repo.commit, branch = repo.branch, path = repo.local_path, remotes = common.map(repo.remotes or {}, function(r) return r:url() end) } end) }) .. "\n") else @@ -2180,146 +2182,146 @@ function lpm.repo_list() end end -function lpm.addon_list(type, id, filters) +function ppm.addon_list(type, id, filters) print_addon_info(type, common.grep(system_bottle:all_addons(), function(p) return (not type or p.type == type) and (not id or p.id:find(id)) end), filters) end -function lpm.describe() +function ppm.describe() local repo_urls = common.grep(common.map(repositories, function(e) return e:url() end), function(url) return #common.grep(DEFAULT_REPOS, function(r) return r:url() == url end) == 0 end) - print("lpm run " .. common.join(" ", { system_bottle.lite_xl.version, table.unpack(repo_urls) }) .. " " .. common.join(" ", common.map(system_bottle:installed_addons(), function(p) return p.id .. ":" .. p.version end))) + print("ppm run " .. common.join(" ", { system_bottle.pragtical.version, table.unpack(repo_urls) }) .. " " .. common.join(" ", common.map(system_bottle:installed_addons(), function(p) return p.id .. ":" .. p.version end))) end -function lpm.addon_upgrade() +function ppm.addon_upgrade() for _,addon in ipairs(system_bottle:installed_addons()) do local upgrade = common.sort({ system_bottle:get_addon(addon.id, ">" .. addon.version) }, function(a, b) return compare_version(b.version, a.version) end)[1] if upgrade then upgrade:install(system_bottle) end end end -function lpm.self_upgrade(release) - if not DEFAULT_RELEASE_URL or #DEFAULT_RELEASE_URL == 0 then error("self-upgrade has been disabled on lpm version " .. VERSION .. "; please upgrade it however you installed it") end +function ppm.self_upgrade(release) + if not DEFAULT_RELEASE_URL or #DEFAULT_RELEASE_URL == 0 then error("self-upgrade has been disabled on ppm version " .. VERSION .. "; please upgrade it however you installed it") end release = release or "latest" local release_url = release and release:find("^https://") and release or (DEFAULT_RELEASE_URL:gsub("%%r", release)) local stat = EXEFILE and system.stat(EXEFILE) - if not stat then error("can't find lpm at " .. EXEFILE) end - local new_temporary_file = SYSTMPDIR .. PATHSEP .. "lpm.upgrade" - local old_temporary_file = SYSTMPDIR .. PATHSEP .. "lpm.backup" + if not stat then error("can't find ppm at " .. EXEFILE) end + local new_temporary_file = SYSTMPDIR .. PATHSEP .. "ppm.upgrade" + local old_temporary_file = SYSTMPDIR .. PATHSEP .. "ppm.backup" common.rmrf(new_temporary_file) common.rmrf(old_temporary_file) local status, err = pcall(common.get, release_url, { cache = SYSTMPDIR, target = new_temporary_file, callback = write_progress_bar }) - if not status then error("can't find release for lpm at " .. release_url .. (VERBOSE and (": " .. err) or "")) end + if not status then error("can't find release for ppm at " .. release_url .. (VERBOSE and (": " .. err) or "")) end if common.is_path_different(new_temporary_file, EXEFILE) then status, err = pcall(common.rename, EXEFILE, old_temporary_file) - if not status then error("can't move lpm executable; do you need to " .. (PLATFORM == "windows" and "run as administrator" or "be root") .. "?" .. (VERBOSE and ": " .. err or "")) end + if not status then error("can't move ppm executable; do you need to " .. (PLATFORM == "windows" and "run as administrator" or "be root") .. "?" .. (VERBOSE and ": " .. err or "")) end common.rename(new_temporary_file, EXEFILE) system.chmod(EXEFILE, stat.mode) if PLATFORM ~= "windows" then -- because we can't delete the running executbale on windows common.rmrf(old_temporary_file) end - log.action("Upgraded lpm to " .. release .. ".") + log.action("Upgraded ppm to " .. release .. ".") else log.warning("aborting upgrade; remote executable is identical to current") common.rmrf(new_temporary_file) end end -function lpm.bottle_purge() +function ppm.bottle_purge() common.rmrf(CACHEDIR .. PATHSEP .. "bottles") end -function lpm.purge() +function ppm.purge() log.action("Purged " .. CACHEDIR .. ".", "green") common.rmrf(CACHEDIR) end --- Base setup; initialize default repos if applicable, read them in. Determine Lite XL system binary if not specified, and pull in a list of all local lite-xl's. -function lpm.setup() - settings = { lite_xls = {}, repositories = {}, installed = {}, version = VERSION } - lpm.repo_init(ARGS[2] == "init" and #ARGS > 2 and (ARGS[3] ~= "none" and common.map(common.slice(ARGS, 3), function(url) return Repository.url(url) end) or {}) or nil) - repositories, lite_xls = {}, {} +-- Base setup; initialize default repos if applicable, read them in. Determine Pragtical system binary if not specified, and pull in a list of all local pragticals. +function ppm.setup() + settings = { pragticals = {}, repositories = {}, installed = {}, version = VERSION } + ppm.repo_init(ARGS[2] == "init" and #ARGS > 2 and (ARGS[3] ~= "none" and common.map(common.slice(ARGS, 3), function(url) return Repository.url(url) end) or {}) or nil) + repositories, pragticals = {}, {} if system.stat(CACHEDIR .. PATHSEP .. "settings.json") then settings = json.decode(common.read(CACHEDIR .. PATHSEP .. "settings.json")) end repositories = common.map(settings.repositories or {}, function(url) local repo = Repository.url(url) repo:parse_manifest() return repo end) - lite_xls = common.map(settings.lite_xls or {}, function(lite_xl) return LiteXL.new(nil, { version = lite_xl.version, mod_version = lite_xl.mod_version, binary_path = lite_xl.binary_path, datadir_path = lite_xl.datadir_path, path = lite_xl.path, tags = { "local" } }) end) + pragticals = common.map(settings.pragticals or {}, function(pragtical) return Pragtical.new(nil, { version = pragtical.version, mod_version = pragtical.mod_version, binary_path = pragtical.binary_path, datadir_path = pragtical.datadir_path, path = pragtical.path, tags = { "local" } }) end) if BINARY and not system.stat(BINARY) then error("can't find specified --binary") end if DATADIR and not system.stat(DATADIR) then error("can't find specified --datadir") end - local lite_xl_binary = BINARY or common.path("lite-xl" .. EXECUTABLE_EXTENSION) - if lite_xl_binary then - local stat = system.stat(lite_xl_binary) - if not stat then error("can't find lite-xl binary " .. lite_xl_binary) end - lite_xl_binary = stat.symlink or lite_xl_binary - local system_lite_xl = common.first(common.concat(common.flat_map(repositories, function(r) return r.lite_xls end), lite_xls), function(lite_xl) return lite_xl:get_binary_path() == lite_xl_binary end) - if not system_lite_xl then - system_lite_xl = common.first(lite_xls, function(e) return e.version == "system" end) - - local directory = common.dirname(lite_xl_binary) - local lite_xl_datadirs = { DATADIR or "", directory .. PATHSEP .. "data", directory:find(PATHSEP .. "bin$") and common.dirname(directory) .. PATHSEP .. "share" .. PATHSEP .. "lite-xl" or "", directory .. PATHSEP .. "data" } - local lite_xl_datadir = common.first(lite_xl_datadirs, function(p) return p and system.stat(p) end) - - if not BINARY and not DATADIR and system_lite_xl then error("can't find existing system lite (does " .. system_lite_xl:get_binary_path() .. " exist? was it moved?); run `lpm purge`, or specify --binary and --datadir.") end - local detected_lite_xl = LiteXL.new(nil, { path = directory, datadir_path = lite_xl_datadir, binary_path = { [DEFAULT_ARCH] = lite_xl_binary }, mod_version = MOD_VERSION or LATEST_MOD_VERSION, version = "system", tags = { "system", "local" } }) - if not system_lite_xl then - system_lite_xl = detected_lite_xl - table.insert(lite_xls, system_lite_xl) - lpm.lite_xl_save() + local pragtical_binary = BINARY or common.path("pragtical" .. EXECUTABLE_EXTENSION) + if pragtical_binary then + local stat = system.stat(pragtical_binary) + if not stat then error("can't find pragtical binary " .. pragtical_binary) end + pragtical_binary = stat.symlink or pragtical_binary + local system_pragtical = common.first(common.concat(common.flat_map(repositories, function(r) return r.pragticals end), pragticals), function(pragtical) return pragtical:get_binary_path() == pragtical_binary end) + if not system_pragtical then + system_pragtical = common.first(pragticals, function(e) return e.version == "system" end) + + local directory = common.dirname(pragtical_binary) + local pragtical_datadirs = { DATADIR or "", directory .. PATHSEP .. "data", directory:find(PATHSEP .. "bin$") and common.dirname(directory) .. PATHSEP .. "share" .. PATHSEP .. "pragtical" or "", directory .. PATHSEP .. "data" } + local pragtical_datadir = common.first(pragtical_datadirs, function(p) return p and system.stat(p) end) + + if not BINARY and not DATADIR and system_pragtical then error("can't find existing system pragtical (does " .. system_pragtical:get_binary_path() .. " exist? was it moved?); run `ppm purge`, or specify --binary and --datadir.") end + local detected_pragtical = Pragtical.new(nil, { path = directory, datadir_path = pragtical_datadir, binary_path = { [DEFAULT_ARCH] = pragtical_binary }, mod_version = MOD_VERSION or LATEST_MOD_VERSION, version = "system", tags = { "system", "local" } }) + if not system_pragtical then + system_pragtical = detected_pragtical + table.insert(pragticals, system_pragtical) + ppm.pragtical_save() else - lite_xls = common.grep(lite_xls, function(e) return e ~= system_lite_xl end) - system_lite_xl = detected_lite_xl - table.insert(lite_xls, system_lite_xl) + pragticals = common.grep(pragticals, function(e) return e ~= system_pragtical end) + system_pragtical = detected_pragtical + table.insert(pragticals, system_pragtical) end else - if DATADIR then system_lite_xl.datadir_path = DATADIR end - if MOD_VERSION then system_lite_xl.mod_version = MOD_VERSION end - table.insert(system_lite_xl.tags, "system") + if DATADIR then system_pragtical.datadir_path = DATADIR end + if MOD_VERSION then system_pragtical.mod_version = MOD_VERSION end + table.insert(system_pragtical.tags, "system") end - system_bottle = Bottle.new(system_lite_xl, nil, nil, true) + system_bottle = Bottle.new(system_pragtical, nil, nil, true) else - system_bottle = Bottle.new(LiteXL.new(nil, { mod_version = MOD_VERSION or LATEST_MOD_VERSION, datadir_path = DATADIR, version = "system", tags = { "system", "local" } }), nil, nil, true) + system_bottle = Bottle.new(Pragtical.new(nil, { mod_version = MOD_VERSION or LATEST_MOD_VERSION, datadir_path = DATADIR, version = "system", tags = { "system", "local" } }), nil, nil, true) end if not system_bottle then system_bottle = Bottle.new(nil, nil, nil, true) end if REPOSITORY then repositories = common.map(type(REPOSITORY) == "table" and REPOSITORY or { REPOSITORY }, function(url) local repo = Repository.url(url) repo:parse_manifest() return repo end) end end -function lpm.command(ARGS) +function ppm.command(ARGS) if not ARGS[2]:find("%S") then return elseif ARGS[2] == "init" then return - elseif ARGS[2] == "repo" and ARGS[3] == "add" then lpm.repo_add(table.unpack(common.slice(ARGS, 4))) - elseif ARGS[2] == "repo" and ARGS[3] == "rm" then lpm.repo_rm(table.unpack(common.slice(ARGS, 4))) - elseif ARGS[2] == "add" then lpm.repo_add(table.unpack(common.slice(ARGS, 3))) - elseif ARGS[2] == "rm" then lpm.repo_rm(table.unpack(common.slice(ARGS, 3))) - elseif ARGS[2] == "update" then lpm.repo_update(table.unpack(common.slice(ARGS, 3))) - elseif ARGS[2] == "repo" and ARGS[3] == "update" then lpm.repo_update(table.unpack(common.slice(ARGS, 4))) - elseif ARGS[2] == "repo" and (#ARGS == 2 or ARGS[3] == "list") then return lpm.repo_list() - elseif ARGS[2] == "apply" then return lpm.apply(table.unpack(common.slice(ARGS, 3))) - elseif (ARGS[2] == "plugin" or ARGS[2] == "color" or ARGS[2] == "library" or ARGS[2] == "font") and ARGS[3] == "install" then lpm.install(ARGS[2], table.unpack(common.slice(ARGS, 4))) - elseif (ARGS[2] == "plugin" or ARGS[2] == "color" or ARGS[2] == "library" or ARGS[2] == "font") and ARGS[3] == "uninstall" then lpm.addon_uninstall(ARGS[2], table.unpack(common.slice(ARGS, 4))) - elseif (ARGS[2] == "plugin" or ARGS[2] == "color" or ARGS[2] == "library" or ARGS[2] == "font") and ARGS[3] == "reinstall" then lpm.addon_reinstall(ARGS[2], table.unpack(common.slice(ARGS, 4))) - elseif (ARGS[2] == "plugin" or ARGS[2] == "color" or ARGS[2] == "library" or ARGS[2] == "font") and (#ARGS == 2 or ARGS[3] == "list") then return lpm.addon_list(ARGS[2], ARGS[4], ARGS) - elseif ARGS[2] == "upgrade" then return lpm.addon_upgrade(table.unpack(common.slice(ARGS, 3))) - elseif ARGS[2] == "install" then lpm.install(nil, table.unpack(common.slice(ARGS, 3))) - elseif ARGS[2] == "unstub" then return lpm.unstub(nil, table.unpack(common.slice(ARGS, 3))) - elseif ARGS[2] == "uninstall" then lpm.addon_uninstall(nil, table.unpack(common.slice(ARGS, 3))) - elseif ARGS[2] == "reinstall" then lpm.addon_reinstall(nil, table.unpack(common.slice(ARGS, 3))) - elseif ARGS[2] == "describe" then lpm.describe(nil, table.unpack(common.slice(ARGS, 3))) - elseif ARGS[2] == "list" then return lpm.addon_list(nil, ARGS[3], ARGS) - elseif ARGS[2] == "lite-xl" and (#ARGS == 2 or ARGS[3] == "list") then return lpm.lite_xl_list(table.unpack(common.slice(ARGS, 4))) - elseif ARGS[2] == "lite-xl" and ARGS[3] == "uninstall" then return lpm.lite_xl_uninstall(table.unpack(common.slice(ARGS, 4))) - elseif ARGS[2] == "lite-xl" and ARGS[3] == "install" then return lpm.lite_xl_install(table.unpack(common.slice(ARGS, 4))) - elseif ARGS[2] == "lite-xl" and ARGS[3] == "switch" then return lpm.lite_xl_switch(table.unpack(common.slice(ARGS, 4))) - elseif ARGS[2] == "lite-xl" and ARGS[3] == "run" then return lpm.lite_xl_run(table.unpack(common.slice(ARGS, 4))) - elseif ARGS[2] == "lite-xl" and ARGS[3] == "add" then return lpm.lite_xl_add(table.unpack(common.slice(ARGS, 4))) - elseif ARGS[2] == "lite-xl" and ARGS[3] == "rm" then return lpm.lite_xl_rm(table.unpack(common.slice(ARGS, 4))) - elseif ARGS[2] == "lite-xl" then error("unknown lite-xl command: " .. ARGS[3]) - elseif ARGS[2] == "bottle" and ARGS[3] == "purge" then return lpm.bottle_purge(common.slice(ARGS, 4)) - elseif ARGS[2] == "run" then return lpm.lite_xl_run(table.unpack(common.slice(ARGS, 3))) - elseif ARGS[2] == "switch" then return lpm.lite_xl_switch(table.unpack(common.slice(ARGS, 3))) - elseif ARGS[2] == "purge" then lpm.purge() + elseif ARGS[2] == "repo" and ARGS[3] == "add" then ppm.repo_add(table.unpack(common.slice(ARGS, 4))) + elseif ARGS[2] == "repo" and ARGS[3] == "rm" then ppm.repo_rm(table.unpack(common.slice(ARGS, 4))) + elseif ARGS[2] == "add" then ppm.repo_add(table.unpack(common.slice(ARGS, 3))) + elseif ARGS[2] == "rm" then ppm.repo_rm(table.unpack(common.slice(ARGS, 3))) + elseif ARGS[2] == "update" then ppm.repo_update(table.unpack(common.slice(ARGS, 3))) + elseif ARGS[2] == "repo" and ARGS[3] == "update" then ppm.repo_update(table.unpack(common.slice(ARGS, 4))) + elseif ARGS[2] == "repo" and (#ARGS == 2 or ARGS[3] == "list") then return ppm.repo_list() + elseif ARGS[2] == "apply" then return ppm.apply(table.unpack(common.slice(ARGS, 3))) + elseif (ARGS[2] == "plugin" or ARGS[2] == "color" or ARGS[2] == "library" or ARGS[2] == "font") and ARGS[3] == "install" then ppm.install(ARGS[2], table.unpack(common.slice(ARGS, 4))) + elseif (ARGS[2] == "plugin" or ARGS[2] == "color" or ARGS[2] == "library" or ARGS[2] == "font") and ARGS[3] == "uninstall" then ppm.addon_uninstall(ARGS[2], table.unpack(common.slice(ARGS, 4))) + elseif (ARGS[2] == "plugin" or ARGS[2] == "color" or ARGS[2] == "library" or ARGS[2] == "font") and ARGS[3] == "reinstall" then ppm.addon_reinstall(ARGS[2], table.unpack(common.slice(ARGS, 4))) + elseif (ARGS[2] == "plugin" or ARGS[2] == "color" or ARGS[2] == "library" or ARGS[2] == "font") and (#ARGS == 2 or ARGS[3] == "list") then return ppm.addon_list(ARGS[2], ARGS[4], ARGS) + elseif ARGS[2] == "upgrade" then return ppm.addon_upgrade(table.unpack(common.slice(ARGS, 3))) + elseif ARGS[2] == "install" then ppm.install(nil, table.unpack(common.slice(ARGS, 3))) + elseif ARGS[2] == "unstub" then return ppm.unstub(nil, table.unpack(common.slice(ARGS, 3))) + elseif ARGS[2] == "uninstall" then ppm.addon_uninstall(nil, table.unpack(common.slice(ARGS, 3))) + elseif ARGS[2] == "reinstall" then ppm.addon_reinstall(nil, table.unpack(common.slice(ARGS, 3))) + elseif ARGS[2] == "describe" then ppm.describe(nil, table.unpack(common.slice(ARGS, 3))) + elseif ARGS[2] == "list" then return ppm.addon_list(nil, ARGS[3], ARGS) + elseif ARGS[2] == "pragtical" and (#ARGS == 2 or ARGS[3] == "list") then return ppm.pragtical_list(table.unpack(common.slice(ARGS, 4))) + elseif ARGS[2] == "pragtical" and ARGS[3] == "uninstall" then return ppm.pragtical_uninstall(table.unpack(common.slice(ARGS, 4))) + elseif ARGS[2] == "pragtical" and ARGS[3] == "install" then return ppm.pragtical_install(table.unpack(common.slice(ARGS, 4))) + elseif ARGS[2] == "pragtical" and ARGS[3] == "switch" then return ppm.pragtical_switch(table.unpack(common.slice(ARGS, 4))) + elseif ARGS[2] == "pragtical" and ARGS[3] == "run" then return ppm.pragtical_run(table.unpack(common.slice(ARGS, 4))) + elseif ARGS[2] == "pragtical" and ARGS[3] == "add" then return ppm.pragtical_add(table.unpack(common.slice(ARGS, 4))) + elseif ARGS[2] == "pragtical" and ARGS[3] == "rm" then return ppm.pragtical_rm(table.unpack(common.slice(ARGS, 4))) + elseif ARGS[2] == "pragtical" then error("unknown pragtical command: " .. ARGS[3]) + elseif ARGS[2] == "bottle" and ARGS[3] == "purge" then return ppm.bottle_purge(common.slice(ARGS, 4)) + elseif ARGS[2] == "run" then return ppm.pragtical_run(table.unpack(common.slice(ARGS, 3))) + elseif ARGS[2] == "switch" then return ppm.pragtical_switch(table.unpack(common.slice(ARGS, 3))) + elseif ARGS[2] == "purge" then ppm.purge() else return false end return true end -function lpm.run(ARGS) - local result = lpm.command(ARGS) +function ppm.run(ARGS) + local result = ppm.command(ARGS) if result == false then error("unknown command: " .. ARGS[2]) elseif result == true and JSON then @@ -2349,7 +2351,7 @@ local function error_handler(err) status = -1 end local function lock_warning() - log.warning("waiting for lpm global lock to be released (only one instance of lpm can be run at once)") + log.warning("waiting for ppm global lock to be released (only one instance of ppm can be run at once)") end @@ -2372,20 +2374,20 @@ xpcall(function() end if ARGS["help"] or #ARGS == 1 or ARGS[2] == "help" then io.stdout:write([[ -Usage: lpm COMMAND [...ARGUMENTS] [--json] [--userdir=directory] +Usage: ppm COMMAND [...ARGUMENTS] [--json] [--userdir=directory] [--cachedir=directory] [--quiet] [--version] [--help] [--remotes] [--ssl-certs=directory/file] [--force] [--arch=]] .. DEFAULT_ARCH .. [[] [--assume-yes] [--no-install-optional] [--verbose] [--mod-version=3] [--datadir=directory] [--binary=path] [--symlink] [--post] [--reinstall] [--no-color] [--table=...] [--plugin=file/url] -LPM is a package manager for `lite-xl`, written in C (and packed-in lua). +PPM is a package manager for `pragtical`, written in C (and packed-in lua). It's designed to install packages from our central github repository (and -affiliated repositories), directly into your lite-xl user directory. It can -be called independently, or from the lite-xl `plugin_manager` addon. +affiliated repositories), directly into your pragtical user directory. It can +be called independently, or from the pragtical `plugin_manager` addon. -LPM will always use +PPM will always use ]] .. DEFAULT_REPO_URL .. [[ as its base repository, if none are present, and the cache directory @@ -2393,7 +2395,7 @@ doesn't exist, but others can be added, and this base one can be removed. It has the following commands: - lpm init [repo 1] [repo 2] [...] Implicitly called before all commands + ppm init [repo 1] [repo 2] [...] Implicitly called before all commands if necessary, but can be called independently to save time later, or to set things up differently. @@ -2407,73 +2409,73 @@ It has the following commands: If "none" is specified, initializes an empty repository list. - lpm repo list List all extant repos. - lpm [repo] add Add a source repository. + ppm repo list List all extant repos. + ppm [repo] add Add a source repository. [...] - lpm [repo] rm Remove a source repository. + ppm [repo] rm Remove a source repository. [...] - lpm [repo] update [] Update all/the specified repos. + ppm [repo] update [] Update all/the specified repos. [...] - lpm [plugin|library|color] install Install specific addons. + ppm [plugin|library|color] install Install specific addons. [:] If installed, upgrades. [...:] - lpm [plugin|library|color] uninstall Uninstall the specific addon. + ppm [plugin|library|color] uninstall Uninstall the specific addon. [...] - lpm [plugin|library|color] reinstall Uninstall and installs the specific addon. + ppm [plugin|library|color] reinstall Uninstall and installs the specific addon. [...] - lpm [plugin|library|color] list List all/associated addons. + ppm [plugin|library|color] list List all/associated addons. [...] - lpm upgrade Upgrades all installed addons + ppm upgrade Upgrades all installed addons to new version if applicable. - lpm self-upgrade [version] Upgrades lpm to a new version, + ppm self-upgrade [version] Upgrades ppm to a new version, if applicable. Defaults to latest. - lpm [lite-xl] install Installs lite-xl. Infers the + ppm [pragtical] install Installs pragtical. Infers the [binary] [datadir] paths on your system if not supplied. Automatically switches to be your system default if path auto inferred. - lpm lite-xl add Adds a local version of lite-xl to + ppm pragtical add Adds a local version of pragtical to the managed list, allowing it to be easily bottled. - lpm lite-xl rm Removes a local version of lite-xl + ppm pragtical rm Removes a local version of pragtical from the managed list. - lpm [lite-xl] switch [] Sets the active version of lite-xl + ppm [pragtical] switch [] Sets the active version of pragtical to be the specified version. Auto-detects - current install of lite-xl; if none found + current install of pragtical; if none found path can be specified. - lpm lite-xl list [name pattern] Lists all installed versions of - [...filters] lite-xl. Can specify the flags listed + ppm pragtical list [name pattern] Lists all installed versions of + [...filters] pragtical. Can specify the flags listed in the filtering section. - lpm run [...addons] Sets up a "bottle" to run the specified - lite version, with the specified addons + ppm run [...addons] Sets up a "bottle" to run the specified + pragtical version, with the specified addons and then opens it. - lpm describe [bottle] Describes the bottle specified in the form + ppm describe [bottle] Describes the bottle specified in the form of a list of commands, that allow someone else to run your configuration. - lpm purge Completely purge all state for LPM. - lpm - Read these commands from stdin in + ppm purge Completely purge all state for PPM. + ppm - Read these commands from stdin in an interactive print-eval loop. - lpm help Displays this help text. + ppm help Displays this help text. Flags have the following effects: --json Performs all communication in JSON. - --userdir=directory Sets the lite-xl userdir manually. - If omitted, uses the normal lite-xl logic. + --userdir=directory Sets the pragtical userdir manually. + If omitted, uses the normal pragtical logic. --cachedir=directory Sets the directory to store all repositories. --tmpdir=directory During install, sets the staging area. --datadir=directory Sets the data directory where core addons are located - for the system lite-xl. - --binary=path Sets the lite-xl binary path for the system lite-xl. + for the system pragtical. + --binary=path Sets the pragtical binary path for the system pragtical. --verbose Spits out more information, including intermediate steps to install and whatnot. --quiet Outputs nothing but explicit responses. - --mod-version=version Sets the mod version of lite-xl to install addons. + --mod-version=version Sets the mod version of pragtical to install addons. --version Returns version information. --help Displays this help text. --ssl-certs Sets the SSL certificate store. Can be a directory, @@ -2506,13 +2508,13 @@ Flags have the following effects: repositories, simply act as if the only repositories are those specified in this option. --ephemeral Designates a bottle as 'ephemeral', meaning that it - is fully cleaned up when lpm exits. Multiple ephemeral + is fully cleaned up when ppm exits. Multiple ephemeral bottles will also execute independently of one another even if they share plugins. - --plugin Loads the specified plugin as part of lpm. Used - for customizing lpm for various tasks. Can be + --plugin Loads the specified plugin as part of ppm. Used + for customizing ppm for various tasks. Can be specified as a remote URL. By default, will always - load all the plugins specified in $HOME/.config/lpm/plugins. + load all the plugins specified in $HOME/.config/ppm/plugins. The following flags are useful when listing addons, or generating the addon table. Putting a ! infront of the string will invert the filter. Multiple @@ -2548,15 +2550,15 @@ in any circumstance unless explicitly supplied. There exist also other debug commands that are potentially useful, but are not commonly used publically. - lpm test Runs the specified test suite. - lpm exec Runs the specified lua file/string with the internal + ppm test Runs the specified test suite. + ppm exec Runs the specified lua file/string with the internal interpreter. - lpm download [target] Downloads the specified URL to stdout, + ppm download [target] Downloads the specified URL to stdout, or to the specified target file. - lpm hash Returns the sha256sum of the file. - lpm update-checksums Pulls all remote files, computes their + ppm hash Returns the sha256sum of the file. + ppm update-checksums Pulls all remote files, computes their checksums, and updates them in the file. - lpm extract Extracts the specified archive at + ppm extract Extracts the specified archive at [target] target, or the current working directory. ]] ) @@ -2565,9 +2567,9 @@ not commonly used publically. VERBOSE = ARGS["verbose"] or false - JSON = ARGS["json"] or os.getenv("LPM_JSON") - QUIET = ARGS["quiet"] or os.getenv("LPM_QUIET") - EPHEMERAL = ARGS["ephemeral"] or os.getenv("LPM_EPHEMERAL") + JSON = ARGS["json"] or os.getenv("PPM_JSON") + QUIET = ARGS["quiet"] or os.getenv("PPM_QUIET") + EPHEMERAL = ARGS["ephemeral"] or os.getenv("PPM_EPHEMERAL") local arg = ARGS["table"] or ARGS["raw"] if arg then local offset,s,e,i = 1, 1, 0, 1 @@ -2612,13 +2614,13 @@ not commonly used publically. NO_INSTALL_OPTIONAL = ARGS["no-install-optional"] ARCH = ARGS["arch"] or { DEFAULT_ARCH } ASSUME_YES = ARGS["assume-yes"] or FORCE - MOD_VERSION = ARGS["mod-version"] or os.getenv("LPM_MODVERSION") + MOD_VERSION = ARGS["mod-version"] or os.getenv("PPM_MODVERSION") if MOD_VERSION == "any" then MOD_VERSION = nil end HOME = (os.getenv("USERPROFILE") or os.getenv("HOME")):gsub(PATHSEP .. "$", "") - USERDIR = common.normalize_path(ARGS["userdir"]) or os.getenv("LITE_USERDIR") or (os.getenv("XDG_CONFIG_HOME") and os.getenv("XDG_CONFIG_HOME") .. PATHSEP .. "lite-xl") - or (HOME and (HOME .. PATHSEP .. '.config' .. PATHSEP .. 'lite-xl')) + USERDIR = common.normalize_path(ARGS["userdir"]) or os.getenv("PRAGTICAL_USERDIR") or (os.getenv("XDG_CONFIG_HOME") and os.getenv("XDG_CONFIG_HOME") .. PATHSEP .. "pragtical") + or (HOME and (HOME .. PATHSEP .. '.config' .. PATHSEP .. 'pragtical')) AUTO_PULL_REMOTES = ARGS["remotes"] - CACHEDIR = common.normalize_path(ARGS["cachedir"]) or os.getenv("LPM_CACHE") or USERDIR .. PATHSEP .. "lpm" + CACHEDIR = common.normalize_path(ARGS["cachedir"]) or os.getenv("PPM_CACHE") or USERDIR .. PATHSEP .. "ppm" TMPDIR = common.normalize_path(ARGS["tmpdir"]) or CACHEDIR .. PATHSEP .. "tmp" if ARGS["trace"] then system.trace(true) end @@ -2681,7 +2683,7 @@ not commonly used publically. repositories = {} - if ARGS[2] == "purge" then return lpm.purge() end + if ARGS[2] == "purge" then return ppm.purge() end local ssl_certs = ARGS["ssl-certs"] or os.getenv("SSL_CERT_DIR") or os.getenv("SSL_CERT_FILE") if ssl_certs then if ssl_certs == "noverify" then @@ -2723,25 +2725,25 @@ not commonly used publically. end end - local lpm_plugins_path = HOME .. PATHSEP .. ".config" .. PATHSEP .. "lpm" .. PATHSEP .. "plugins" - local lpm_plugins = {} - if system.stat(lpm_plugins_path) then - local files = system.ls(lpm_plugins_path) - lpm_plugins = common.concat( - common.map(common.grep(files, function(path) return path:find("%.lua$") end), function(path) return lpm_plugins_path .. PATHSEP .. path end), - common.grep(common.map(common.grep(files, function(path) return not path:find("%.lua$") end), function(path) return lpm_plugins_path .. PATHSEP .. path .. PATHSEP .. "init.lua" end), function(path) return system.stat(path) end) + local ppm_plugins_path = HOME .. PATHSEP .. ".config" .. PATHSEP .. "ppm" .. PATHSEP .. "plugins" + local ppm_plugins = {} + if system.stat(ppm_plugins_path) then + local files = system.ls(ppm_plugins_path) + ppm_plugins = common.concat( + common.map(common.grep(files, function(path) return path:find("%.lua$") end), function(path) return ppm_plugins_path .. PATHSEP .. path end), + common.grep(common.map(common.grep(files, function(path) return not path:find("%.lua$") end), function(path) return ppm_plugins_path .. PATHSEP .. path .. PATHSEP .. "init.lua" end), function(path) return system.stat(path) end) ) end local env = setmetatable({}, { __index = _G, __newindex = function(t, k, v) _G[k] = v end }) - for i,v in ipairs(common.concat(ARGS["plugin"] or {}, { common.split(",", os.getenv("LPM_PLUGINS") or "") }, lpm_plugins)) do + for i,v in ipairs(common.concat(ARGS["plugin"] or {}, { common.split(",", os.getenv("PPM_PLUGINS") or "") }, ppm_plugins)) do if v ~= "" then local contents = v:find("^https?://") and common.get(v) or common.read(v) local func, err = load(contents, v, "bt", env) if func then func() else - log.warning("unable to load lpm plugin " .. v .. ": " .. err) + log.warning("unable to load ppm plugin " .. v .. ": " .. err) end if VERBOSE then log.action("Loaded plugin " .. v) end end @@ -2788,7 +2790,7 @@ not commonly used publically. os.exit(0) end if ARGS[2] == "update-checksums" then - if #ARGS == 2 then error("usage: lpm update-checksums manifest.json") end + if #ARGS == 2 then error("usage: ppm update-checksums manifest.json") end local contents = common.read(ARGS[3]) local m = json.decode(contents) local computed = {} @@ -2799,7 +2801,7 @@ not commonly used publically. if i > 3 then filter[arg] = true end end end - for _, section in ipairs(common.concat(m.addons or {}, m["lite-xls"] or {})) do + for _, section in ipairs(common.concat(m.addons or {}, m["pragticals"] or {})) do for _, file in ipairs(common.concat({ section }, section.files or {})) do if (not filter or (section.id and filter[section.id])) and file.url and file.checksum ~= "SKIP" and type(file.checksum) == "string" then log.action("Computing checksum for " .. (section.id or section.version) .. " (" .. file.url .. ")...") @@ -2822,19 +2824,19 @@ not commonly used publically. os.exit(0) end if ARGS[2] == "self-upgrade" then - lpm.self_upgrade(table.unpack(common.slice(ARGS, 3))) + ppm.self_upgrade(table.unpack(common.slice(ARGS, 3))) os.exit(0) end if not system.stat(USERDIR) then common.mkdirp(USERDIR) end if engage_locks(function() - lpm.setup() + ppm.setup() end, error_handler, lock_warning) then return end if ARGS[2] ~= '-' then local res engage_locks(function() - res = lpm.run(ARGS) + res = ppm.run(ARGS) end, error_handler, lock_warning) if res then res() @@ -2854,7 +2856,7 @@ not commonly used publically. xpcall(function() local res engage_locks(function() - res = lpm.run(args) + res = ppm.run(args) end, error_handler, lock_warning) if res then if type(res) == 'function' then diff --git a/t/run.lua b/t/run.lua index 4c9b699..a14e74e 100644 --- a/t/run.lua +++ b/t/run.lua @@ -1,89 +1,89 @@ -local lpm +local ppm local function assert_exists(path) if not io.open(path, "rb") then error("assertion failed: file " .. path .. " does not exist", 2) end end local function assert_not_exists(path) if io.open(path, "rb") then error("assertion failed: file " .. path .. " exists", 2) end end local tmpdir = os.getenv("TMPDIR") or "/tmp" local fast = os.getenv("FAST") -local userdir = tmpdir .. "/lpmtest" +local userdir = tmpdir .. "/ppmtest" setmetatable(_G, { __index = function(t, k) if not rawget(t, k) then error("cannot get undefined global variable: " .. k, 2) end end, __newindex = function(t, k) error("cannot set global variable: " .. k, 2) end }) local tests = { ["00_install_singleton"] = function() - local plugins = lpm("list bracketmatch")["addons"] + local plugins = ppm("list bracketmatch")["addons"] assert(#plugins == 1) assert(plugins[1].organization == "singleton") assert(plugins[1].status == "available") - local actions = lpm("install bracketmatch")["actions"] + local actions = ppm("install bracketmatch")["actions"] assert(actions[1]:find("Installing singleton")) assert_exists(userdir .. "/plugins/bracketmatch.lua") - actions = lpm("uninstall bracketmatch")["actions"] + actions = ppm("uninstall bracketmatch")["actions"] assert_not_exists(userdir .. "/plugins/bracketmatch.lua") end, ["01_upgrade_singleton"] = function() - lpm("install bracketmatch") - local plugins = lpm("list bracketmatch")["addons"] + ppm("install bracketmatch") + local plugins = ppm("list bracketmatch")["addons"] assert(#plugins == 1) assert(plugins[1].status == "installed") assert_exists(plugins[1].path) io.open(plugins[1].path, "ab"):write("-- this is a test comment to modify the checksum"):close() - plugins = lpm("list bracketmatch")["addons"] + plugins = ppm("list bracketmatch")["addons"] assert(#plugins == 2) - lpm("install bracketmatch") - plugins = lpm("list bracketmatch")["addons"] + ppm("install bracketmatch") + plugins = ppm("list bracketmatch")["addons"] assert(#plugins == 1) - lpm("install console") + ppm("install console") assert_exists(userdir .. "/plugins/console/init.lua") end, ["02_install_complex"] = function() - local plugins = lpm("list plugin_manager")["addons"] + local plugins = ppm("list plugin_manager")["addons"] assert(#plugins == 1) assert(plugins[1].organization == "complex") assert(plugins[1].status == "available") assert(plugins[1].dependencies.json) - local actions = lpm("install plugin_manager")["actions"] + local actions = ppm("install plugin_manager")["actions"] assert_exists(userdir .. "/libraries/json.lua") assert_exists(userdir .. "/plugins/plugin_manager") assert_exists(userdir .. "/plugins/plugin_manager/init.lua") - actions = lpm("uninstall plugin_manager")["actions"] + actions = ppm("uninstall plugin_manager")["actions"] assert_not_exists(userdir .. "/plugins/plugin_manager") - lpm("install editorconfig") + ppm("install editorconfig") assert_exists(userdir .. "/plugins/editorconfig") assert_exists(userdir .. "/plugins/editorconfig/init.lua") end, ["03_upgrade_complex"] = function() - local actions = lpm("install plugin_manager") - local plugins = lpm("list plugin_manager")["addons"] + local actions = ppm("install plugin_manager") + local plugins = ppm("list plugin_manager")["addons"] assert(#plugins == 1) assert(plugins[1].organization == "complex") assert(plugins[1].status == "installed") end, ["04_list_plugins"] = function() - local plugins = lpm("list")["addons"] + local plugins = ppm("list")["addons"] assert(#plugins > 20) - lpm("list --status core") + ppm("list --status core") end, ["05_install_url"] = function() - local plugins = lpm("list eofnewline")["addons"] + local plugins = ppm("list eofnewline")["addons"] assert(#plugins == 1) assert(plugins[1].organization == "singleton") assert(plugins[1].status == "available") - local actions = lpm("install eofnewline") + local actions = ppm("install eofnewline") assert_exists(userdir .. "/plugins/eofnewline.lua") end, ["06_install_stub"] = function() - local plugins = lpm("list lsp")["addons"] + local plugins = ppm("list lsp")["addons"] assert(#plugins > 1) for i, plugin in ipairs(plugins) do if plugin.id == "lsp" then assert(plugins[1].organization == "complex") assert(plugins[1].status == "available") - local actions = lpm("install lsp") + local actions = ppm("install lsp") assert_exists(userdir .. "/plugins/lsp/init.lua") assert_exists(userdir .. "/libraries/widget/init.lua") break end end - local actions = lpm("install encodings") + local actions = ppm("install encodings") assert_exists(userdir .. "/plugins/encodings.lua") local stat = system.stat(userdir .. "/plugins/encodings.lua") assert(stat) @@ -99,41 +99,41 @@ local tests = { assert(#results["addons"] == 3) end, ["08_install_many"] = function() - lpm("install encoding gitblame gitstatus language_ts lsp minimap") + ppm("install encoding gitblame gitstatus language_ts lsp minimap") end, ["09_misc_commands"] = function() - lpm("update") - lpm("upgrade") + ppm("update") + ppm("upgrade") end, ["10_install_multiarch"] = function() - lpm("install plugin_manager --arch x86_64-windows --arch x86_64-linux") - assert_exists(userdir .. "/plugins/plugin_manager/lpm.x86_64-linux") - assert_exists(userdir .. "/plugins/plugin_manager/lpm.x86_64-windows.exe") + ppm("install plugin_manager --arch x86_64-windows --arch x86_64-linux") + assert_exists(userdir .. "/plugins/plugin_manager/ppm.x86_64-linux") + assert_exists(userdir .. "/plugins/plugin_manager/ppm.x86_64-windows.exe") assert_exists(userdir .. "/plugins/plugin_manager/init.lua") end, ["11_dependency_check"] = function() - lpm("install lsp") + ppm("install lsp") assert_exists(userdir .. "/plugins/lsp") assert_exists(userdir .. "/plugins/lintplus") - lpm("uninstall lsp") + ppm("uninstall lsp") assert_not_exists(userdir .. "/plugins/lsp") assert_not_exists(userdir .. "/plugins/lintplus") end, ["12_masking"] = function() - lpm("install lsp --mask lintplus") + ppm("install lsp --mask lintplus") assert_exists(userdir .. "/plugins/lsp") assert_not_exists(userdir .. "/plugins/lintplus") end } local last_command_result, last_command -lpm = function(cmd) +ppm = function(cmd) last_command = arg[0] .. " --quiet --json --assume-yes --userdir=" .. userdir .. " " .. cmd local pipe = io.popen(last_command, "r") local result = pipe:read("*all") last_command_result = result ~= "" and json.decode(result) or nil local success = pipe:close() - if not success then error("error calling lpm", 2) end + if not success then error("error calling ppm", 2) end return last_command_result end @@ -147,14 +147,14 @@ local function run_tests(tests, arg) end table.sort(names) local max_name = 0 - os.execute("rm -rf " .. tmpdir .. "/lpmtest && mkdir -p " .. tmpdir .. "/lpmtest"); + os.execute("rm -rf " .. tmpdir .. "/ppmtest && mkdir -p " .. tmpdir .. "/ppmtest"); for i,k in ipairs(names) do max_name = math.max(max_name, #k) end for i,k in ipairs(names) do local v = tests[k] if fast then - os.execute("rm -rf " .. tmpdir .. "/lpmtest/plugins && mkdir -p " .. tmpdir .. "/lpmtest"); + os.execute("rm -rf " .. tmpdir .. "/ppmtest/plugins && mkdir -p " .. tmpdir .. "/ppmtest"); else - os.execute("rm -rf " .. tmpdir .. "/lpmtest && mkdir -p " .. tmpdir .. "/lpmtest"); + os.execute("rm -rf " .. tmpdir .. "/ppmtest && mkdir -p " .. tmpdir .. "/ppmtest"); end io.stdout:write(string.format("test %-" .. (max_name + 1) .. "s: ", k)) local failed = false