1.1.1 • Published 1 year ago

openai-electron-cli v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

OpenAI Electron

npm version node version size license

Command line tool to generate Electron application with OpenAI API

Demo

Installation

You can install this project by using NPM

npm install --global openai-electron-cli

You can check if the project installed properly and the version of the project

openai-electron --version

You can see all the avaiable commands

openai-electron -H

Windows User Issue

If you are Windows user and get error like this:

openai-electron : File C:\Users\xxxx\AppData\Roaming\npm\openai-electron.ps1 cannot be loaded because running scripts
is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ openai-electron
+ ~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

You can fix it by running this command (it may cause a security issue)

Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted

Command Usage

install

Installing all electron depencies that needed to run an Electron application

set-prompt

Set the prompt that will send to OpenAI to generate the source code. Example:

openai-electron set-prompt "write a simple blog in HTML with CSS"

get-prompt

Get the prompt that given by user. Example:

openai-electron get-prompt
# output:
# write a simple blog in HTML with CSS

generate-code

Generate the source code by sending the prompt to OpenAI API. You need to have OpenAI API Key. Recommend to read How to create OpenAI API keys. Example:

openai-electron generate-code --openai-key "sk-4EdVbFhGP..."
# output:
# ✅ Source code generated successfully
# ✅ Source code saved and application is ready to run

edit-code

View and edit the generated source code from OpenAI with text editor (default: vim). Example:

openai-electron edit-code --text-editor vim

Edit code

run

Run the generated source code as desktop application via electron

Electron App

run-webserver

Run the generated source code as Web application via HTTP server. Example:

openai-electron run-webserver
# output:
# ╭────────────────────────────────────────────────╮
# │                                                │
# │    Application run on http://localhost:5000    │
# │                                                │
# ╰────────────────────────────────────────────────╯

export

Export the generated source code as executable program via electron-forge. Example:

openai-electron export -o .
# output:
# ? What is your platform? Linux
# ✅ Application packaged successfully
tree -L 3 .
# output:
# .
# └── out
#     ├── electron_app-linux-x64
#     │   ├── LICENSE
#     │   ├── LICENSES.chromium.html
#     │   ├── chrome-sandbox
#     │   ├── chrome_100_percent.pak
#     │   ├── chrome_200_percent.pak
#     │   ├── crashpad_handler
#     │   ├── electron_app
#     │   ├── icudtl.dat
#     │   ├── libEGL.so
#     │   ├── libGLESv2.so
#     │   ├── libffmpeg.so
#     │   ├── libvk_swiftshader.so
#     │   ├── locales
#     │   ├── resources
#     │   ├── resources.pak
#     │   ├── snapshot_blob.bin
#     │   ├── swiftshader
#     │   ├── v8_context_snapshot.bin
#     │   ├── version
#     │   └── vk_swiftshader_icd.json
#     └── make
#         ├── electron-app_1.0.0_amd64.deb
#         └── electron_app-1.0.0.x86_64.rpm

# 6 directories, 19 files