-
Notifications
You must be signed in to change notification settings - Fork 1
Tutorial: Creating New LitePolis Packages with litepolis‐cli
Ever wanted to add your own custom API magic to a LitePolis project? Maybe a new set of endpoints for that killer feature you've been dreaming up? Well, buckle up, because the litepolis-cli is here to make it super easy!
Forget creating folders, copying boilerplate, and setting up Git manually. We're going to use a simple command to bootstrap a whole new router package, ready for you to fill with your brilliant code.
Our Goal: By the end of this short guide, you'll have a fresh, ready-to-code LitePolis router package sitting in a directory on your computer, complete with its own Git repository! ✨
Ready? Let's dive in!
Before we start our coding adventure, let's do a quick check of our toolkit. Make sure you have these ready:
- ✅ Python & pip: The heart of our operation.
- ✅ Git: For version control magic.
- ✅
litepolis-cli: Our main tool! (If not installed, trypip install litepolis). - ✅
gitpython: The CLI uses this behind the scenes. (Maybe install withpip install gitpythonif you hit errors later).
Got 'em all? Awesome!
This is IMPORTANT! litepolis-cli needs your new package name to follow a specific pattern. It's like a secret handshake:
litepolis-router-<your-awesome-name-here>
- Start with
litepolis-router-. - Add your unique name using hyphens (
-). - Example:
litepolis-router-user-profilesorlitepolis-router-epic-feature.
Got a cool name in mind that fits the pattern? Perfect! For this tutorial, we'll use litepolis-router-awesome-sauce.
Alright, open your favorite terminal or command prompt. It's time for the magic!
Navigate to the directory where you want your new project folder to live. Then, type this command, replacing our example name if you chose your own:
litepolis-cli create router litepolis-router-awesome-sauceHit Enter!
You'll see the CLI spring into action. It's doing the boring stuff for you:
- Cloning the official LitePolis router template.
- Renaming everything inside to match
litepolis-router-awesome-sauce. - Setting up a clean, new Git repository just for your package.
Wait for it to finish...
The command finished? Sweet! You should see some "Next steps" printed out. Let's follow them to get your local project ready to connect to the world (or at least, to your Git hosting provider like GitHub or GitLab).
-
Enter your new project:
cd litepolis-router-awesome-sauce -
Create its online home: Go to GitHub, GitLab, or your preferred Git host and create a new, empty repository. Don't add a README or license file from their side. Just create it and copy its URL (usually ends in
.git). -
Link local to remote: Back in your terminal, run this command, pasting your repository URL:
git remote add origin <YOUR_REPOSITORY_URL_HERE>
-
First Push! Send your new package code to its online home:
git push -u origin main
(Note: Your default branch might be
masterinstead ofmainon older Git versions. Adjust if needed.)
Woohoo! Check that out! You now have a brand new directory (litepolis-router-awesome-sauce) containing a fully structured LitePolis router package. It's already a local Git repository and it's connected to your remote repository online.
You've successfully used litepolis-cli to bootstrap your project. Now the real fun begins – open up the code, explore the template structure, and start building your awesome API endpoints!
You've mastered creating routers, nice! But the litepolis-cli create command is your trusty sidekick for building other types of LitePolis components too, each using its own dedicated template:
-
Need to manage data or state? Create a
databasepackage:litepolis-cli create database litepolis-database-profiles
-
Want to add logic that runs on every request (like logging or auth checks)? Create
middleware:litepolis-cli create middleware litepolis-middleware-cors
-
Building a cool front-end part or serving static files? Create a
uipackage:litepolis-cli create ui litepolis-ui-admin-panel
Just remember the Secret Code! The naming pattern litepolis-<type>-<your-package-name> applies to all of them. The creation process (cloning the right template, renaming, initializing Git) works exactly the same way as it did for our router.
So go ahead, explore, and build out your LitePolis applications with all the custom components you need! Happy coding!
💡 Important Note: Making Your Package Discoverable with add-deps
So you've built an awesome new LitePolis package, maybe like litepolis-ui-admin-panel using the create command? Great!
Now, if you want to enable seamless discovery and installation of your custom LitePolis packages via litepolis-cli deploy add-deps, make sure you've successfully built and uploaded them to PyPI!
Now LitePolis users, system administrators all over the world will be able to easily add your package as a new feature through dependency of their LitePolis deployment using the command:
litepolis-cli deploy add-deps <your-package-name>
# Example: litepolis-cli deploy add-deps litepolis-ui-admin-panel