Package: zf-pd
pd (Product Development and Deployment)FeaturesProject initialization (FastAPI, NextJS, React, Electron).Content downloading (YouTube)File conversion (Image, Audio, Video).EC2 instance management (launch, terminate).Environment setup and configuration (zsh, vim, git, etc.)Nginx configuration management (proxy, static resources).Installationpipinstallzf-pdThis will install apdbinary in your system (even though the package name iszf-pd).Like other shell tools, pd stores its config in~/.pdconfig.json.See theConfigsection for more information.Usage### 1. Init`pdinit`isgreattoolforquicklyinitializingnewdevelopmentprojects.ItsupportsFastAPI,ReactandElectron
projects.

**Example**

YoucanquicklycreateanewFastAPIprojectbyrunning:```bash
$pdinitfastapi
Name:fastapi-testThis will create a new FastAPI project and print the following:Createdprojectfastapi-testat./fastapi-test.Pleaserunthefollowingcommands:cd./fastapi-test
pipinstall-rrequirements.txt
npmruninstall
python3-muvicornapp.main:app--reload
Openhttp://localhost:8000By default,pd initwill create a new project at./<project-name>path. You can specify a custom path by running$pdinitfastapi--name/path/to/fastapi-testThis will initialize a new FastAPI project at/path/to/fastapi-test.For React or NextJS, you can basically do the same:$pdinitreact
Name:react-test$pdinitnextjs
Name:nextjs-testThis will create a new React project calledreact-testat./react-testpath.You can also generate an Electron project:$pdinitelectron
Name:electron-testThe Electron project will come preconfigured with TypeScript, React, Chakra UI, and Apple DMG.2. Downloadpd downis tool for downloading content form the internet. Often times, when you are working on project, you need to
download resources from the internet in video, audio or text format.pd downmakes this process easy.pd downsupport the following commands:$pddown--help

Usage:pddown[OPTIONS]COMMAND[ARGS]...Downloadfromtheinternet

Options:--helpShowthismessageandexit.

Commands:youtubeDownloadaYouTubevideo2.1 YouTubepd down youtubeis a tool for downloading YouTube videos.$pddownyoutube--helpUsage:pddownyoutube[OPTIONS]DownloadaYouTubevideo

Options:-l,--linkTEXTLinktotheYouTubevideo(e.g.https://www.youtube.com/watch?v=...)[required]-f,--formatTEXTFormattodownloadas(e.g.mp4,mp3,txt)[required]--helpShowthismessageandexit.$pddownyoutube-lhttps://www.youtube.com/watch?v=...-fmp4or$pddownyoutube--linkhttps://www.youtube.com/watch?v=...--formatmp4Not only you can download YouTube videos, you can also download YouTube videos as audio (mp3) or text (txt) files.$pddownyoutube-lhttps://www.youtube.com/watch?v=...-fmp3or$pddownyoutube--linkhttps://www.youtube.com/watch?v=...--formattxtThis will output a file called<YOUTUBE_TITLE>.txtat the current directory.4. Convertpd convis a tool for converting your files into other formats. It support image, video, and audio conversion.You can list all available conversions by running:$pdconvlist
Availableconversions:texttxt->mp3imagejpg,jpeg,webp->pngjpg,jpeg,webp,png->mp4audiom4a->wav,mp3mp3->wav,m4avideomp4,webm,mov->mp3ExampleYou can convert a mp4 video file into an audio file by running:$pdconvvideo-ptests/video.mp4-fmp3The converted audio file will be saved attests/video.mp3.Similarly, you can convert a m4a audio file into a mp3 audio file by running:$pdconvaudio-ptests/audio.m4a-fmp3The converted audio file will be saved attests/audio.mp3.You can also convert a text file into an audio file by running:$pdconvtext-v"Convert this text to audio"-fmp3This uses the OpenAI API so you will need to set your Open AI API key.You can also pass options such as the voice:$pdconvtext--value"Convert this text to audio"--formatmp3--optionsvoice=Nova### 4. EC2`pdec2`isatoolformanagingEC2instances.Ituses`boto3`tomanageEC2instances.

Youmustconfigurethefollowingwhenusing`pdec2`forthefirsttime:

**Environment**:```bashexportAWS_ACCESS_KEY_ID=<your-access-key-id>exportAWS_SECRET_ACCESS_KEY=<your-secret-access-key>exportAWS_DEFAULT_REGION=<your-region>~/.pdconfig:You must update~/.pdconfig.jsonwith your EC2 launch template id and key pair path:{"ec2":{"launch-template-id":<your-launch-template-ide.g.lt-1234567890>,"key-pair-path":<your-key-pair-pathe.g./home/ubuntu/key.pem>,}}The key pair path must be an absolute path on the disk.SeeAWS EC2 Launch Templatesfor more
information.pd ec2support the following commands:4.1 Launchpd ec2 launchlaunches a new EC2 instance.$pdec2launch--help
Usage:pdec2launch[OPTIONS]LaunchanEC2instance

Options:-n,--nameTEXTNameoftheEC2instancee.g.ec2-test[required]-c,--countINTEGERNumberofinstancestolaunch[default:1]-p,--projectTEXTProjectnamee.g/path/to/project--helpShowthismessageandexit.Example$pdec2launch-nec2-test-c1If this EC2 instance is part of a project, you can specify the project path:$pdec2launch-nec2-test-p/path/to/project4.2 Terminatepd ec2 terminateterminates an EC2 instance.$pdec2terminate--help
Usage:pdec2terminate[OPTIONS]TerminateanEC2instance

Options:-i,--instance-idTEXTIDoftheEC2instancetoterminatee.g.i-1234567890abcdef[required]-p,--projectTEXTProjectnamee.g/path/to/project--helpShowthismessageandexit.Example$pdec2terminate-nec2-testYou can additionally pass the project path:$pdec2terminate-nec2-test-p/path/to/project5. Nginxpd nginxis a tool for managing Nginx configuration files.pd nginxsupport the following commands:5.1 Generatepd nginx generategenerates Nginx configuration files.pdnginxgenerate--help
Usage:pdnginxgenerate[OPTIONS]Generatenginxconfig

Options:-h,--hostTEXTHosttoproxytoe.g.localhost[required]-p,--portINTEGERPorttoproxytoe.g.80[required]-d,--domainTEXTDomaintousefornginxconfige.g.example.com[required]-s,--staticTEXTStaticresourcespathe.g./path/to/static--helpShowthismessageandexit.Example$pdnginxgenerate--host127.0.0.1--port8000--domainexample.com
server{server_nameexamaple.com;location/{proxy_passhttp://127.0.0.1:8000;proxy_set_headerHost$host;proxy_set_headerX-Real-IP$remote_addr;proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;proxy_set_headerX-Forwarded-Proto$scheme;}}You can additionally specify the static resources path:$pdnginxgenerate-hlocalhost-p80-dexample.com-s/path/to/static
server{server_nameexample.com;root/path/to/static;client_max_body_size50M;location/{proxy_passhttp://localhost:80;proxy_set_headerHost$host;proxy_set_headerX-Real-IP$remote_addr;proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;proxy_set_headerX-Forwarded-Proto$scheme;}location/static/{alias/path/to/static;# Add CORS 'Access-Control-Allow-Origin' header for fontslocation~*\.(ico|png|css|ttf)${add_headerAccess-Control-Allow-Origin*;}}}Configpdwill store the following information in~/.pdconfig.json:{"projects":[{"type":"fastapi","name":"project1","path":"/path/to/project1","instances":["instance-1"]},{"type":"fastapi","name":"project2","path":"/path/to/project2","instances":["instance-2"]},{"type":"fastapi","name":"project3","path":"/path/to/project3","instances":["instance-3","instance-4"]}],"ec2":{"launch-template-id":"lt-template-id","key-pair-path":"/path/to/keypair.pem","instances":["instance-1","instance-2","instance-3","instance-4"]}}You can manually edit this file to add new projects or EC2 instances. However, it is recommended to usepdcommands.
When you init a new project,pdwill automatically add the project to~/.pdconfig.json. Similarly, when you launch
a new EC2 instance,pdwill automatically add the instance to~/.pdconfig.jsonand associate it with the project
if you specify the project path.LICENSEMIT License