Package: pcra
pcra - Python Create React AppCLI for template-based project scaffolding based on theReact to PythonbookThis highly opinionated but configurable script will create the initial structure for a React/Material-UI application that isprogrammed in Python(not JavaScript!) and usesTranscryptto transpile the code into JavaScript.The script performs the following actions:Creates a source code folder structure in the specified project folderAdds a set of core Python source code modules for creating the React applicationOptionally stubs out a Flask back-end application with basic user session managementCreates virtual environments for front-end and back-end applicationsPIP installs Transcrypt and Flask into the virtual environmentsNPM installs Parcel and the Transcrypt plug-in for ParcelAdds a middleware script for serving the Flask application in developmentNPM installs react, material-ui, and other supporting JavaScript librariesCreates a local git repository and does an initial commitInitializes npm semver versioning for the front-end applicationBy default, the sample React application that is installed withpy-create-react-appis just a placeholder for you to start building your application from.  It is similar to the one you get when using the JavaScriptcreate-react-appcommand.
If you would like to use the framework outlined in theReact to Pythonbook, you can use the--full-stackcommand-line option, which will create the scaffolding for a full-stack application with a Flask back-end.
If you only need the client side of that framework, you can use the--client-onlyoption.There are also options to bypass the setup for the virtual environment, installing JavaScript dependencies, and creating a Git repository, if you prefer to set any of those up manually.If you have your own framework template that follows the same folder structure as PCRA, you can specify that on the command line as well and take advantage of the automated setup features.After installing thepcrapackage with pip, you can verify that it works by running it with:py-create-react-app my_projectThis will set up the structure of a project in a newmy_projectfolder in the current directory.
After it finishes the setup process, you can build and run the application using the following commands:cd my_projectsource ./venv/bin/activateorvenv\Scripts\activatefor Windowsnpm start -- --openDefault React ProjectReact to Python ProjectInstallationInstall using Python 3.7 with:python3.7-mpipinstallpcraor to get the latest version from GitHub:python3.7-mpipinstallgit+https://github.com/JennaSys/pcraOn Windows you can also use:py-3.7-mpipinstallpcraUsage:py-create-react-app [-h] [-co | -fs] [-nv] [-njs] [-ng] [-t TEMPLATE] FOLDER_NAMEPython Create React App: Template-based Python React project scaffolding creatorpositional arguments:FOLDER_NAMEnameoftheprojectfolder(mustnotalreadyexist)optional arguments:-h,--helpshowthishelpmessageandexit-co,--client-onlyonlycreateclientproject(notfullstack)-fs,--full-stackcreatefull-stackproject(withFlaskback-end)-nv,--no-virtualenvDONOTcreatevirtualenvironments-njs,--no-javascriptDONOTinstallJavaScriptlibraries-ng,--no-gitDONOTcreateGitrepository-tTEMPLATE,--templateTEMPLATEalternatetemplatefoldertouseNOTE: Transcrypt requires that this must be run with Python version 3.7