Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,37 @@ Ready to start hacking? Once you've forked this extension, you can incorporate f

### How to Use This Template

> This guide assumes you're using this extension as a base for a new one, and have installed LNbits using https://github.com/lnbits/lnbits/blob/main/docs/guide/installation.md#option-1-recommended-poetry.
> [!IMPORTANT] the sequence of steps is very important so as not to run into issues!

* Stop LNbits
* Clone this extension into the extension folder
* Make your changes to models.py/migration.py (if you run without making your changes it will build the db and you will likely have to delete later - no biggie, but making the chnages first helps)
* Hack about building your awesome new extension. Start/stop LNbits as you are hacking.
* Share. Profit. Innovate. Win!
> [!NOTE] You may want to modify your models.py/migration.py before installing the extension on your lnbits server (between steps

IMPORTANT: If you want your extension to be added to the official LNbits manifest, please follow the guidelines here: https://github.com/lnbits/lnbits-extensions#important
> This guide assumes you're using this extension as a base for a new one, and have installed LNbits using <https://github.com/lnbits/lnbits/blob/main/docs/guide/installation.md#option-1-recommended-poetry>.

1. Fork this extension to your Github repo with the name you want, e.g., `yourextensionname` -> <https://github.com/yourgithubusername/yourextensionname> (do not include hyphens as they can cause issues!)

1. Clone the Repository to your local computer. `git clone git@github.com/yourgithubuersname/yourextensionname`

1. `cd` into the folder `yourextensionname` and delete the `.git` folder with `rm -rf .git`

1. run `./updateExtensionName.sh myextension:<yourextensionname> myExtension:<yourExtensionName> MyExtension:<YourExtensionName>` (to replace all variations)

1. edit `./manifest.json` and replace the organization `lnbits` with `<yourgithubusernaame>`

1. (Optional) Modify your models.py/migration.py file to create your own database tables, or just play with the already existing ones

1. Re-initialize a git repo with `git init && git add . && git commit -m "initial commit"`

1. Push to your github repo

1. [!IMPORTANT] **you must create a release** _in your github repo_ in order for it to show up in your lnbits extensions!

1. Start up your lnbits server and go to the Settings -> EXTENSIONS and add your manifest to the extension sources. It should be `https://raw.githubusercontent.com/<yourgithubusernaame>/<yourextensionname>/main/manifest.json` (going to this link should show your updated manifest) and **save**. ![Extension Sources](https://i.imgur.com/MUGwAU3.png)
1. Great! Now if you go to the **Extensions** and go to the **ALL** tab, you should see your extension available for installing! (note that Github has an API rate limit, and you may want to include an API key generated from your github account in the `.env` file)

1. Remove the installed extension from `lnbits/lnbits/extensions`.

1. Create a symbolic link using `ln -s /home/ben/Projects/<name of your extension> /home/ben/Projects/lnbits/lnbits/extensions`.

1. Restart your LNbits installation. You can now modify your extension and the changes will appear on your LNbits instance (stop & restart your lnbits for full initialization of all files if needed, e.g., for migration to take effect). You can also `git push` changes to your new repo and create a release _in your github repo_ if you want to install it from a fresh lnbits!

1. IMPORTANT: If you want your extension to be added to the official LNbits manifest, please follow the guidelines here: <https://github.com/lnbits/lnbits-extensions#important>
45 changes: 45 additions & 0 deletions updateExtensionName.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env bash

# Usage: ./rename-plugin.sh oldname:newname [old2:new2 ...]

set -euo pipefail

# Function to rename files, contents, and directories
rename_pair() {
local OLD="$1"
local NEW="$2"

echo "🔁 Replacing '$OLD' with '$NEW'..."

# 1. Rename files with OLD in the name
find . -type f -not -path "*/.git/*" -name "*${OLD}*" | while read -r file; do
dir=$(dirname "$file")
base=$(basename "$file")
new_base="${base//$OLD/$NEW}"
new_path="$dir/$new_base"
mv "$file" "$new_path"
echo "Renamed file: $file -> $new_path"
done

# 2. Replace inside file content
find . -type f -not -path "*/.git/*" -print0 | xargs -0 sed -i "s/${OLD}/${NEW}/g"

# 3. Rename directories (bottom-up)
find . -depth -type d -not -path "*/.git/*" -name "*${OLD}*" | while read -r dir; do
parent=$(dirname "$dir")
base=$(basename "$dir")
new_base="${base//$OLD/$NEW}"
new_path="$parent/$new_base"
mv "$dir" "$new_path"
echo "Renamed directory: $dir -> $new_path"
done
}

# Main loop over all name pairs
for pair in "$@"; do
OLD="${pair%%:*}"
NEW="${pair##*:}"
rename_pair "$OLD" "$NEW"
done

echo "✅ All done, with .git folder safely ignored."