From 6a6181b0b58e7a685809d5bef249aba66ef5f79d Mon Sep 17 00:00:00 2001 From: jgmdev Date: Tue, 23 May 2023 17:02:57 -0400 Subject: [PATCH] Project rebranding --- .github/workflows/build.yml | 49 +-- .gitignore | 10 +- CHANGELOG.md | 92 +++--- LICENSE | 4 +- README.md | 76 ++--- SPEC.md | 43 ++- build.sh | 8 +- libraries/json.lua | 2 +- manifest.json | 46 +-- meson.build | 18 +- plugins/plugin_manager/init.lua | 60 ++-- src/{lpm.c => ppm.c} | 136 ++++----- src/{lpm.lua => ppm.lua} | 512 ++++++++++++++++---------------- t/run.lua | 72 ++--- 14 files changed, 567 insertions(+), 561 deletions(-) rename src/{lpm.c => ppm.c} (92%) rename src/{lpm.lua => ppm.lua} (83%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2c80024..fbea8fc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,6 @@ name: CI on: { push: { branches: [master] } } +permissions: write-all jobs: build_linux_android_windows: runs-on: ubuntu-latest @@ -18,35 +19,35 @@ jobs: run: | sudo apt-get install musl-tools musl musl-dev wget -q https://musl.cc/riscv64-linux-musl-cross.tgz && tar -zxvf riscv64-linux-musl-cross.tgz - ./build.sh clean && BIN=lpm.riscv64-linux CC=`pwd`/riscv64-linux-musl-cross/bin/riscv64-linux-musl-cc AR=`pwd`/riscv64-linux-musl-cross/bin/riscv64-linux-musl-ar ./build.sh -DLPM_STATIC -DLPM_VERSION='"'$FULL_VERSION-riscv64-linux'"' -static - ./build.sh clean && BIN=lpm.x86_64-linux CC=musl-gcc ./build.sh -DLPM_STATIC -DLPM_VERSION='"'$FULL_VERSION-x86_64-linux'"' -static - - name: Run Tests - run: | - cp ./lpm.x86_64-linux lpm && ./lpm test t/run.lua + ./build.sh clean && BIN=ppm.riscv64-linux CC=`pwd`/riscv64-linux-musl-cross/bin/riscv64-linux-musl-cc AR=`pwd`/riscv64-linux-musl-cross/bin/riscv64-linux-musl-ar ./build.sh -DPPM_STATIC -DPPM_VERSION='"'$FULL_VERSION-riscv64-linux'"' -static + ./build.sh clean && BIN=ppm.x86_64-linux CC=musl-gcc ./build.sh -DPPM_STATIC -DPPM_VERSION='"'$FULL_VERSION-x86_64-linux'"' -static + # - name: Run Tests + # run: | + # cp ./ppm.x86_64-linux ppm && ./ppm test t/run.lua - name: Build Android env: { ANDROID_ABI_VERSION: "26" } run: | export CMAKE_DEFAULT_FLAGS="-DCMAKE_ANDROID_NDK=$ANDROID_NDK_HOME -DCMAKE_ANDROID_API=$ANDROID_ABI_VERSION -DCMAKE_SYSTEM_VERSION=$ANDROID_ABI_VERSION -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=NEVER -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=NEVER -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_INCLUDE_PATH=$ANDROID_SYSROOT_NDK/sysroot/usr/include" export AR="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar" - ./build.sh clean && export ARCH="arm-android" && CFLAGS="-Dinline=" BIN=lpm.$ARCH CMAKE_DEFAULT_FLAGS="$CMAKE_DEFAULT_FLAGS -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a" CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi$ANDROID_ABI_VERSION-clang ./build.sh -DLPM_VERSION='"'$FULL_VERSION-$ARCH'"' -DLPM_STATIC - ./build.sh clean && export ARCH="aarch64-android" && CFLAGS="-Dinline=" BIN=lpm.$ARCH CMAKE_DEFAULT_FLAGS="$CMAKE_DEFAULT_FLAGS -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a" CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android$ANDROID_ABI_VERSION-clang ./build.sh -DLPM_VERSION='"'$FULL_VERSION-$ARCH'"' -DLPM_STATIC - ./build.sh clean && export ARCH="x86-android" && CFLAGS="-Dinline=" BIN=lpm.$ARCH CMAKE_DEFAULT_FLAGS="$CMAKE_DEFAULT_FLAGS -DCMAKE_ANDROID_ARCH_ABI=x86" CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android$ANDROID_ABI_VERSION-clang ./build.sh -DLPM_VERSION='"'$FULL_VERSION-$ARCH'"' -DLPM_STATIC - ./build.sh clean && export ARCH="x86_64-android" && CFLAGS="-Dinline=" BIN=lpm.$ARCH CMAKE_DEFAULT_FLAGS="$CMAKE_DEFAULT_FLAGS -DCMAKE_ANDROID_ARCH_ABI=x86_64" CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android$ANDROID_ABI_VERSION-clang ./build.sh -DLPM_VERSION='"'$FULL_VERSION-$ARCH'"' -DLPM_STATIC + ./build.sh clean && export ARCH="arm-android" && CFLAGS="-Dinline=" BIN=ppm.$ARCH CMAKE_DEFAULT_FLAGS="$CMAKE_DEFAULT_FLAGS -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a" CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi$ANDROID_ABI_VERSION-clang ./build.sh -DPPM_VERSION='"'$FULL_VERSION-$ARCH'"' -DPPM_STATIC + ./build.sh clean && export ARCH="aarch64-android" && CFLAGS="-Dinline=" BIN=ppm.$ARCH CMAKE_DEFAULT_FLAGS="$CMAKE_DEFAULT_FLAGS -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a" CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android$ANDROID_ABI_VERSION-clang ./build.sh -DPPM_VERSION='"'$FULL_VERSION-$ARCH'"' -DPPM_STATIC + ./build.sh clean && export ARCH="x86-android" && CFLAGS="-Dinline=" BIN=ppm.$ARCH CMAKE_DEFAULT_FLAGS="$CMAKE_DEFAULT_FLAGS -DCMAKE_ANDROID_ARCH_ABI=x86" CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android$ANDROID_ABI_VERSION-clang ./build.sh -DPPM_VERSION='"'$FULL_VERSION-$ARCH'"' -DPPM_STATIC + ./build.sh clean && export ARCH="x86_64-android" && CFLAGS="-Dinline=" BIN=ppm.$ARCH CMAKE_DEFAULT_FLAGS="$CMAKE_DEFAULT_FLAGS -DCMAKE_ANDROID_ARCH_ABI=x86_64" CC=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android$ANDROID_ABI_VERSION-clang ./build.sh -DPPM_VERSION='"'$FULL_VERSION-$ARCH'"' -DPPM_STATIC # - 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: Build Windows run: | - sudo apt-get install mingw-w64 && ./build.sh clean && BIN=lpm.x86_64-windows.exe 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" LZMA_CONFIGURE="--host=x86_64-w64-mingw32" GIT2_CONFIGURE="-DDLLTOOL=x86_64-w64-mingw32-dlltool" ./build.sh -DLPM_STATIC -DLPM_VERSION='"'$VERSION-x86_64-windows'"' + sudo apt-get install mingw-w64 && ./build.sh clean && BIN=ppm.x86_64-windows.exe 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" LZMA_CONFIGURE="--host=x86_64-w64-mingw32" GIT2_CONFIGURE="-DDLLTOOL=x86_64-w64-mingw32-dlltool" ./build.sh -DPPM_STATIC -DPPM_VERSION='"'$VERSION-x86_64-windows'"' - name: Create Release(s) - env: { GITHUB_TOKEN: "${{ github.token }}", ARTIFACTS: "lpm.x86_64-linux lpm.riscv64-linux lpm.x86_64-windows.exe lpm.arm-android lpm.aarch64-android lpm.x86-android lpm.x86_64-android" } + env: { GITHUB_TOKEN: "${{ github.token }}", ARTIFACTS: "ppm.x86_64-linux ppm.riscv64-linux ppm.x86_64-windows.exe ppm.arm-android ppm.aarch64-android ppm.x86-android ppm.x86_64-android" } run: | gh release delete -y continuous || true; gh release create -t 'Continuous Release' continuous $ARTIFACTS - if [[ `git tag --points-at HEAD v* | head -c 1` == "v" ]]; then + if git tag --points-at HEAD | tail -n1 | grep "^v"; then gh release delete -y v$VERSION || true; gh release create -t v$VERSION v$VERSION $ARTIFACTS gh release delete -y latest || true; @@ -69,14 +70,14 @@ jobs: - name: Build MacOS env: { GITHUB_TOKEN: "${{ github.token }}" } run: | - ./build.sh clean && BIN=lpm.x86_64-darwin ./build.sh -DLPM_STATIC -DLPM_VERSION='"'$FULL_VERSION-x86_64-darwin'"' - ./build.sh clean && BIN=lpm.aarch64-darwin CC=clang CFLAGS="-arch arm64" ./build.sh -DLPM_STATIC -DLPM_VERSION='"'$FULL_VERSION-aarch64-darwin'"' - gh release upload continuous lpm.x86_64-darwin lpm.aarch64-darwin - if [[ `git tag --points-at HEAD v* | head -c 1` == "v" ]]; then - gh release upload v$VERSION lpm.x86_64-darwin - gh release upload latest lpm.x86_64-darwin - gh release upload v$VERSION lpm.aarch64-darwin - gh release upload latest lpm.aarch64-darwin + ./build.sh clean && BIN=ppm.x86_64-darwin ./build.sh -DPPM_STATIC -DPPM_VERSION='"'$FULL_VERSION-x86_64-darwin'"' + ./build.sh clean && BIN=ppm.aarch64-darwin CC=clang CFLAGS="-arch arm64" ./build.sh -DPPM_STATIC -DPPM_VERSION='"'$FULL_VERSION-aarch64-darwin'"' + gh release upload continuous ppm.x86_64-darwin ppm.aarch64-darwin + if git tag --points-at HEAD | tail -n1 | grep "^v"; then + gh release upload v$VERSION ppm.x86_64-darwin + gh release upload latest ppm.x86_64-darwin + gh release upload v$VERSION ppm.aarch64-darwin + gh release upload latest ppm.aarch64-darwin git branch -f latest HEAD git tag -f latest git push -f origin refs/heads/latest diff --git a/.gitignore b/.gitignore index 5ed035e..a2f9872 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,10 @@ -lpm +ppm lua.exe -lpm-* +ppm-* *.o -lpm.lua.c +ppm.lua.c lib/prefix -src/lpm.luac.c -src/lpm.luac +src/ppm.luac.c +src/ppm.luac lib/mbedtls-2.27.0/build lib/mbedtls-2.27.0/tests diff --git a/CHANGELOG.md b/CHANGELOG.md index e5c47b3..9e196d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,7 +75,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 @@ -85,7 +85,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. @@ -97,7 +97,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. @@ -112,14 +112,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. @@ -134,28 +134,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. @@ -169,74 +169,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, @@ -286,12 +286,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 aaa3fb8..0f7c9c4 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,44 +49,44 @@ 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`, courtesy of @cvladan: +You can also use `scoop` to grab `ppm`, courtesy of @cvladan: ``` -scoop install https://gist.githubusercontent.com/cvladan/416c1945c9e446a6fc64ba766d6ee4ef/raw/lite-xl-plugin-manager.json +scoop install https://gist.githubusercontent.com/cvladan/416c1945c9e446a6fc64ba766d6ee4ef/raw/plugin-manager.json ``` ## 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) @@ -93,12 +95,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 @@ -115,23 +117,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 @@ -139,7 +141,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 @@ -147,17 +149,17 @@ 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. ## Bugs 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 d5d88ef..cec573c 100644 --- a/SPEC.md +++ b/SPEC.md @@ -1,17 +1,17 @@ # Manifest Specification -A lite-xl manifest is a JSON file contains three different keys: +A pragtical manifest is a JSON file contains 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 @@ -107,7 +107,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; @@ -116,20 +116,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(.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 @@ -145,7 +145,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. @@ -153,12 +153,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" } @@ -195,7 +195,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. }, @@ -212,26 +212,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" } ] @@ -242,21 +242,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 be5e260..3c83541 100755 --- a/build.sh +++ b/build.sh @@ -3,14 +3,14 @@ : ${CC=gcc} : ${AR=ar} : ${MAKE=make} -: ${BIN=lpm} +: ${BIN=ppm} : ${JOBS=4} SRCS="src/*.c" CFLAGS="$CFLAGS -Ilib/prefix/include" LDFLAGS="$LDFLAGS -lm -Llib/prefix/lib" -[[ "$@" == "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 @@ -38,9 +38,9 @@ fi [[ "$@" != *"-llua"* ]] && CFLAGS="$CFLAGS -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" ]] && { gcc -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(loadfile("src/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(loadfile("src/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" ]] && CFLAGS="$CFLAGS -DLUA_USE_LINUX" && LDFLAGS="$LDFLAGS -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/manifest.json b/manifest.json index 811f086..549f6f4 100644 --- a/manifest.json +++ b/manifest.json @@ -3,54 +3,55 @@ { "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.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 @@ -78,31 +79,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 eed1d7a..7fa049a 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ -project('lpm', +project('ppm', ['c'], version : '1.0.4', - license : 'LPM', + license : 'PPM', meson_version : '>= 0.56', ) @@ -44,18 +44,18 @@ if not microtar_dep.found() message('Using git module for microtar') endif -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(loadfile("@INPUT0@"))) 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(loadfile("@INPUT0@"))) 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 dcc987e..69ce664 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 --pragtical 2.1 --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 }, config.plugins.plugin_manager) package.path = package.path .. ";" .. USERDIR .. "/libraries/?.lua" .. ";" .. USERDIR .. "/libraries/?/init.lua" .. ";" .. DATADIR .. "/libraries/?.lua" .. ";" .. DATADIR .. "/libraries/?/init.lua" -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 @@ local function extract_progress(chunk) end local function run(cmd, progress) - 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") @@ -345,7 +345,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)) @@ -359,7 +359,7 @@ if pcall(require, "plugins.terminal") then local arguments = { "-" } 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) @@ -367,4 +367,30 @@ 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]", + 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 + os.execute( + '"' .. config.plugins.plugin_manager.ppm_binary_path .. '" ' + .. table.concat(ARGS, " ", start) + ) + end + end +} + return PluginManager diff --git a/src/lpm.c b/src/ppm.c similarity index 92% rename from src/lpm.c rename to src/ppm.c index cecd061..02e97a9 100644 --- a/src/lpm.c +++ b/src/ppm.c @@ -109,7 +109,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"); @@ -142,7 +142,7 @@ static int lpm_hash(lua_State* L) { } -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)); @@ -152,7 +152,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 @@ -162,7 +162,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); #ifdef _WIN32 @@ -213,7 +213,7 @@ static int lpm_ls(lua_State *L) { #endif } -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))) @@ -225,7 +225,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)); @@ -237,7 +237,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]; @@ -301,7 +301,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(); @@ -350,7 +350,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]; @@ -367,7 +367,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); @@ -391,7 +391,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); @@ -415,11 +415,11 @@ 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. } -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) { lua_State* L = payload; lua_pushvalue(L, 2); lua_pushinteger(L, stats->received_bytes); @@ -435,8 +435,8 @@ static int lpm_git_transfer_progress_cb(const git_transfer_progress *stats, void return value; } -static int lpm_fetch(lua_State* L) { - git_init(); +static int ppm_fetch(lua_State* L) { + git_init(); git_repository* repository = luaL_checkgitrepo(L, 1); git_remote* remote; if (git_remote_lookup(&remote, repository, "origin")) { @@ -451,9 +451,9 @@ static int lpm_fetch(lua_State* L) { fetch_opts.depth = 1; #endif if (no_verify_ssl) - fetch_opts.callbacks.certificate_check = lpm_git_transport_certificate_check_cb; + fetch_opts.callbacks.certificate_check = ppm_git_transport_certificate_check_cb; if (lua_type(L, 2) == LUA_TFUNCTION) - fetch_opts.callbacks.transfer_progress = lpm_git_transfer_progress_cb; + fetch_opts.callbacks.transfer_progress = ppm_git_transfer_progress_cb; git_strarray array = { (char**)&refspec, 1 }; int error = git_remote_connect(remote, GIT_DIRECTION_FETCH, &fetch_opts.callbacks, NULL, NULL) || git_remote_download(remote, refspec ? &array : NULL, &fetch_opts) || @@ -509,22 +509,22 @@ static int luaL_mbedtls_error(lua_State* L, int code, const char* str, ...) { return luaL_error(L, "%s: %s", vsnbuffer, mbed_buffer); } -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; } -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) { @@ -550,9 +550,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; @@ -661,7 +661,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); @@ -822,13 +822,13 @@ static int lpm_extract(lua_State* L) { } -static int lpm_socket_write(int fd, const char* buf, int len, mbedtls_ssl_context* ctx) { +static int ppm_socket_write(int fd, const char* buf, int len, mbedtls_ssl_context* ctx) { if (ctx) return mbedtls_ssl_write(ctx, buf, len); return write(fd, buf, len); } -static int lpm_socket_read(int fd, char* buf, int len, mbedtls_ssl_context* ctx) { +static int ppm_socket_read(int fd, char* buf, int len, mbedtls_ssl_context* ctx) { if (ctx) return mbedtls_ssl_read(ctx, buf, len); return read(fd, buf, len); @@ -864,7 +864,7 @@ static const char* get_header(const char* buffer, const char* header, int* len) return NULL; } -static int lpm_get(lua_State* L) { +static int ppm_get(lua_State* L) { long response_code; char err[1024] = {0}; const char* protocol = luaL_checkstring(L, 1); @@ -926,14 +926,14 @@ static int lpm_get(lua_State* L) { const char* rest = luaL_checkstring(L, 4); char buffer[HTTPS_RESPONSE_HEADER_BUFFER_LENGTH]; int buffer_length = snprintf(buffer, sizeof(buffer), "GET %s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n", rest, hostname); - buffer_length = lpm_socket_write(s, buffer, buffer_length, ssl_ctx); + buffer_length = ppm_socket_write(s, buffer, buffer_length, ssl_ctx); if (buffer_length < 0) { mbedtls_snprintf(ssl_ctx ? 1 : 0, err, sizeof(err), ssl_ctx ? buffer_length : errno, "can't write to socket %s", hostname); goto cleanup; } int bytes_read = 0; const char* header_end = NULL; while (!header_end && bytes_read < sizeof(buffer) - 1) { - buffer_length = lpm_socket_read(s, &buffer[bytes_read], sizeof(buffer) - bytes_read - 1, ssl_ctx); + buffer_length = ppm_socket_read(s, &buffer[bytes_read], sizeof(buffer) - bytes_read - 1, ssl_ctx); if (buffer_length < 0) { mbedtls_snprintf(ssl_ctx ? 1 : 0, err, sizeof(err), ssl_ctx ? buffer_length : errno, "can't read from socket %s", hostname); goto cleanup; } else if (buffer_length > 0) { @@ -982,7 +982,7 @@ static int lpm_get(lua_State* L) { } fwrite(header_end, sizeof(char), body_length, file); while (content_length == -1 || remaining > 0) { - int length = lpm_socket_read(s, buffer, sizeof(buffer), ssl_ctx); + int length = ppm_socket_read(s, buffer, sizeof(buffer), ssl_ctx); if (length == 0 || (ssl_ctx && content_length == -1 && length == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY)) break; if (length < 0) { mbedtls_snprintf(ssl_ctx ? 1 : 0, err, sizeof(err), ssl_ctx ? length : errno, "error retrieving full response for %s%s", hostname, rest); goto cleanup; @@ -1004,7 +1004,7 @@ static int lpm_get(lua_State* L) { luaL_buffinit(L, &B); luaL_addlstring(&B, header_end, body_length); while (content_length == -1 || remaining > 0) { - int length = lpm_socket_read(s, buffer, sizeof(buffer), ssl_ctx); + int length = ppm_socket_read(s, buffer, sizeof(buffer), ssl_ctx); if (length == 0 || (ssl_ctx && content_length == -1 && length == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY)) break; if (length < 0) { mbedtls_snprintf(ssl_ctx ? 1 : 0, err, sizeof(err), ssl_ctx ? length : errno, "error retrieving full response for %s%s", hostname, rest); goto cleanup; @@ -1041,7 +1041,7 @@ static int lpm_get(lua_State* L) { return 2; } -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 @@ -1051,7 +1051,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))) @@ -1066,7 +1066,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; @@ -1131,39 +1131,39 @@ 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. - { "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. + { "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 } }; -#ifndef LPM_VERSION - #define LPM_VERSION "unknown" +#ifndef PPM_VERSION + #define PPM_VERSION "unknown" #endif -#ifndef LPM_DEFAULT_REPO - #define LPM_DEFAULT_REPOSITORY "https://github.com/lite-xl/lite-xl-plugin-manager.git:latest" +#ifndef PPM_DEFAULT_REPO + #define PPM_DEFAULT_REPOSITORY "https://github.com/pragtical/plugin-manager.git:latest" #endif #ifndef ARCH_PROCESSOR @@ -1196,13 +1196,13 @@ 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 -#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[]) { @@ -1216,7 +1216,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"); @@ -1228,14 +1228,14 @@ int main(int argc, char* argv[]) { lua_pushliteral(L, "/"); #endif lua_setglobal(L, "PATHSEP"); - lua_pushliteral(L, LITE_ARCH_TUPLE); + lua_pushliteral(L, PRAGTICAL_ARCH_TUPLE); lua_setglobal(L, "ARCH"); - lua_pushliteral(L, LPM_DEFAULT_REPOSITORY); + lua_pushliteral(L, PPM_DEFAULT_REPOSITORY); lua_setglobal(L, "DEFAULT_REPO_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 7beb181..70a2548 100644 --- a/src/lpm.lua +++ b/src/ppm.lua @@ -472,9 +472,9 @@ function common.stat(path) return stat end -local LATEST_MOD_VERSION = "3.0.0" +local LATEST_MOD_VERSION = "3.4.0" local EXECUTABLE_EXTENSION = PLATFORM == "windows" and ".exe" or "" -local HOME, USERDIR, CACHEDIR, JSON, TABLE, HEADER, 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, settings, repositories, lite_xls, system_bottle, progress_bar_label, write_progress_bar +local HOME, USERDIR, CACHEDIR, JSON, TABLE, HEADER, 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, settings, repositories, pragticals, system_bottle, progress_bar_label, write_progress_bar local function engage_locks(func, err, warn) if not system.stat(CACHEDIR) then common.mkdirp(CACHEDIR) end @@ -483,7 +483,7 @@ local function engage_locks(func, err, warn) return system.flock(lockfile, func, err, warn) end -local Addon, Repository, LiteXL, Bottle = {}, {}, {}, {} +local Addon, Repository, Pragtical, Bottle = {}, {}, {}, {} local colors = { red = 31, @@ -553,7 +553,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 @@ -606,19 +606,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) @@ -706,7 +706,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 path = path .. PATHSEP .. (self.path or (self.url and common.basename(self.url) or self.id)) else @@ -756,7 +756,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 @@ -992,7 +992,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 @@ -1050,8 +1050,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) @@ -1246,46 +1246,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 _G.ARCH] then return self.binary_path[arch or _G.ARCH] end - return self.local_path .. PATHSEP .. "lite-xl." .. (arch or _G.ARCH) + return self.local_path .. PATHSEP .. "pragtical." .. (arch or _G.ARCH) 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) @@ -1296,7 +1296,7 @@ function LiteXL:install() if not file.checksum then error("requires a checksum") end local basename = common.basename(file.url) local archive = basename:find("%.zip$") or basename:find("%.tar%.gz$") - local path = self.local_path .. PATHSEP .. (archive and basename or "lite-xl") + local path = self.local_path .. PATHSEP .. (archive and basename or "pragtical") log_action("Downloading file " .. file.url .. "...") common.get(file.url, path, file.checksum, write_progress_bar) log_action("Downloaded file " .. file.url .. " to " .. path) @@ -1308,26 +1308,26 @@ function LiteXL:install() 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 "")) + 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 "")) self.local_path = CACHEDIR .. PATHSEP .. "bottles" .. PATHSEP .. self.hash end return self @@ -1343,7 +1343,7 @@ 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 io.open(self.local_path .. PATHSEP .. "user" .. PATHSEP .. "init.lua", "wb"):write([[ @@ -1356,13 +1356,13 @@ function Bottle:construct() ):close() 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 for i,addon in ipairs(self.addons) do addon:install(self) @@ -1376,14 +1376,14 @@ 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 {} if self.is_system then error("system bottle cannot be run") end - local path = self.local_path .. PATHSEP .. "lite-xl" + local path = self.local_path .. PATHSEP .. "pragtical" if not system.stat(path) then error("cannot find bottle executable " .. path) end os.execute(path .. (#args > 0 and " " or "") .. table.concat(args, " ")) end @@ -1431,7 +1431,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(common.grep(addon_paths, function(e) return system.stat(e) end)) do for j, v in ipairs(system.ls(addon_path)) do @@ -1450,7 +1450,7 @@ 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) @@ -1525,34 +1525,34 @@ local function get_repository(url) end -local function lpm_settings_save() +local function ppm_settings_save() common.write(CACHEDIR .. PATHSEP .. "settings.json", json.encode(settings)) end -local function lpm_repo_save() +local 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 -local function lpm_repo_init(repos) +local 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 -local function lpm_repo_add(...) +local 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 @@ -1563,22 +1563,22 @@ local function lpm_repo_add(...) table.insert(repositories, 1, repo) repo:update() end - lpm_repo_save() + ppm_repo_save() end -local function lpm_repo_rm(...) +local 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 -local function lpm_repo_update(...) +local function ppm_repo_update(...) local t = { ... } if #t == 0 then table.insert(t, false) end for i, url in ipairs(t) do @@ -1591,114 +1591,114 @@ local function lpm_repo_update(...) end end -local function 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) +local function 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 -local 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() +local 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 -local function lpm_lite_xl_add(version, path) +local 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 -local function lpm_lite_xl_rm(version) +local function ppm_pragtical_rm(version) if not version then error("requires a version") end - local lite_xl = 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 = 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 -local function lpm_lite_xl_install(version) +local function ppm_pragtical_install(version) if not version then error("requires a version") end - (get_lite_xl(version) or error("can't find lite-xl version " .. version)):install() + (get_pragtical(version) or error("can't find pragtical version " .. version)):install() end -local function lpm_lite_xl_switch(version, target) +local 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 = 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 = 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 -local function lpm_lite_xl_uninstall(version) - (get_lite_xl(version) or error("can't find lite-xl version " .. version)):uninstall() +local function ppm_pragtical_uninstall(version) + (get_pragtical(version) or error("can't find pragtical version " .. version)):uninstall() end -local function lpm_lite_xl_list() - local result = { ["lite-xls"] = { } } +local 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 @@ -1708,14 +1708,14 @@ local function is_argument_repo(arg) return arg:find("^http") or arg:find("[\\/]") or arg == "." end -local function lpm_lite_xl_run(version, ...) +local function ppm_pragtical_run(version, ...) if not version then error("requires a version or arguments") end local arguments = { ... } if not version:find("^%d+") and version ~= "system" then table.insert(arguments, 1, version) version = "system" end - local lite_xl = get_lite_xl(version) or error("can't find lite-xl version " .. version) + local pragtical = get_pragtical(version) or error("can't find pragtical version " .. version) local addons = {} local i = 1 while i <= #arguments do @@ -1726,7 +1726,7 @@ local function lpm_lite_xl_run(version, ...) system_bottle:invalidate_cache() else local id, version = common.split(":", str) - local potentials = { system_bottle:get_addon(id, version, { mod_version = lite_xl.mod_version }) } + local potentials = { system_bottle:get_addon(id, version, { mod_version = pragtical.mod_version }) } local uniq = {} local found_one = false for i, addon in ipairs(potentials) do @@ -1743,7 +1743,7 @@ local function lpm_lite_xl_run(version, ...) end i = i + 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)) @@ -1752,23 +1752,23 @@ local function lpm_lite_xl_run(version, ...) end -local function lpm_install(type, ...) +local function ppm_install(type, ...) local to_install = {} local to_explicitly_install = {} for i, identifier in ipairs({ ... }) do local s = identifier:find(":") local id, version = (s and identifier:sub(1, s-1) or identifier), (s and identifier:sub(s+1) or nil) if not id then error('unrecognized identifier ' .. identifier) end - if id == "lite-xl" then - lpm_lite_xl_install(version) + if id == "pragtical" then + ppm_pragtical_install(version) else if is_argument_repo(identifier) then table.insert(repositories, 1, Repository.url(identifier):add(AUTO_PULL_REMOTES)) system_bottle:invalidate_cache() else - local potential_addons = { system_bottle:get_addon(id, version, { mod_version = system_bottle.lite_xl.mod_version, type = type }) } + local potential_addons = { system_bottle:get_addon(id, version, { mod_version = system_bottle.pragtical.mod_version, type = type }) } 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 @@ -1783,7 +1783,7 @@ local function lpm_install(type, ...) end common.each(to_install, function(e) e:install(system_bottle) end) settings.installed = common.concat(settings.installed, to_explicitly_install) - lpm_settings_save() + ppm_settings_save() end local function get_table(headers, rows) @@ -1817,13 +1817,13 @@ local function print_addon_info(type, addons, filters) elseif addon.path then url = string.format("[`%s`](%s)", addon.name or addon.id, 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(), version = "" .. addon.version, dependencies = addon.dependencies, remote = addon.remote, description = addon.description, - author = addon.author or (addon:is_core(system_bottle) and "lite-xl") or nil, + author = addon.author or (addon:is_core(system_bottle) and "pragtical") or nil, mod_version = addon.mod_version or LATEST_MOD_VERSION, tags = addon.tags, type = addon.type, @@ -1874,7 +1874,7 @@ local function print_addon_info(type, addons, filters) end -local function lpm_unstub(type, ...) +local function ppm_unstub(type, ...) local addons = {} for i, identifier in ipairs({ ... }) do if not identifier then error('unrecognized identifier ' .. identifier) end @@ -1882,9 +1882,9 @@ local 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 @@ -1895,7 +1895,7 @@ local function lpm_unstub(type, ...) end -local function lpm_addon_uninstall(type, ...) +local 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 @@ -1906,12 +1906,12 @@ local 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 -local function lpm_addon_reinstall(type, ...) for i, id in ipairs({ ... }) do pcall(lpm_addon_uninstall, type, id) end lpm_install(type, ...) end +local function ppm_addon_reinstall(type, ...) for i, id in ipairs({ ... }) do pcall(ppm_addon_uninstall, type, id) end ppm_install(type, ...) end -local function lpm_repo_list() +local 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 @@ -1925,27 +1925,27 @@ local function lpm_repo_list() end end -local function lpm_addon_list(type, id, filters) +local 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 -local function lpm_describe() +local 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 -local function lpm_addon_upgrade() +local function ppm_addon_upgrade() for i,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 -local function lpm_bottle_purge() +local function ppm_bottle_purge() common.rmrf(CACHEDIR .. PATHSEP .. "bottles") end -local function lpm_purge() +local function ppm_purge() log_action("Purged " .. CACHEDIR .. ".", "green") common.rmrf(CACHEDIR) end @@ -1986,36 +1986,36 @@ end local function run_command(ARGS) if not ARGS[2]:find("%S") then return elseif ARGS[2] == "init" then return - elseif ARGS[2] == "repo" and ARGV[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] == "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 ARGV[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] == "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 error("unknown command: " .. ARGS[2]) end if JSON then io.stdout:write(json.encode({ actions = actions, warnings = warnings })) @@ -2041,20 +2041,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=]] .. _G.ARCH .. [[] [--assume-yes] [--no-install-optional] [--verbose] [--mod-version=3] [--datadir=directory] [--binary=path] [--symlink] [--post] [--reinstall] [--no-color] [--table=...] -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 @@ -2062,7 +2062,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. @@ -2076,70 +2076,70 @@ 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 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, @@ -2170,7 +2170,7 @@ 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. + is fully cleaned up when ppm exits. The following flags are useful when listing plugins, or generating the plugin table. Putting a ! infront of the string will invert the filter. Multiple @@ -2202,15 +2202,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 [test file] Runs the specified test suite. - lpm exec [file] Runs the specified lua file with the internal + ppm test [test file] Runs the specified test suite. + ppm exec [file] Runs the specified lua file 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 [file] Returns the sha256sum of the file. - lpm update-checksums [manifest] Pulls all remote files, computes their + ppm hash [file] Returns the sha256sum of the file. + ppm update-checksums [manifest] 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. ]] ) @@ -2218,9 +2218,9 @@ not commonly used publically. end 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") if ARGS["table"] then local offset,s,e,i = 1, 1, 0, 1 TABLE = {} @@ -2256,13 +2256,13 @@ not commonly used publically. NO_INSTALL_OPTIONAL = ARGS["no-install-optional"] ARCH = ARGS["arch"] or { _G.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 @@ -2309,7 +2309,7 @@ not commonly used publically. end 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 @@ -2374,7 +2374,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 = {} @@ -2385,7 +2385,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 .. ")...") @@ -2409,48 +2409,48 @@ not commonly used publically. end if not system.stat(USERDIR) then common.mkdirp(USERDIR) 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. + -- 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 pragtical's. if engage_locks(function() - 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 = {}, {} + 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 = { [_G.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 = { [_G.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 - table.insert(system_lite_xl.tags, "system") + if DATADIR then system_pragtical.datadir_path = DATADIR 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 diff --git a/t/run.lua b/t/run.lua index 6b25d50..d07ce8b 100644 --- a/t/run.lua +++ b/t/run.lua @@ -1,89 +1,89 @@ local json = require "libraries.json" -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) 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,24 +99,24 @@ 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") assert_exists(userdir .. "/plugins/settings.lua") - lpm("uninstall lsp") + ppm("uninstall lsp") assert_not_exists(userdir .. "/plugins/lsp") assert_not_exists(userdir .. "/plugins/lintplus") assert_not_exists(userdir .. "/plugins/settings.lua") @@ -124,13 +124,13 @@ local tests = { } 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 @@ -144,14 +144,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