CLI Guide
The ConnectDev CLI is a tool for you to deploy your projects and manage your applications.
Usage
After installing the CLI, you can run connectdev help
on the terminal to view the help information:
% connectdev --help
Usage: connectdev [OPTIONS] COMMAND [ARGS]...
ConnectDev is the fastest way to run code in the cloud.
See the website at https://connectdev.io for documentation and more information about running code on ConnectDev.
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --help Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ deploy Deploy the project. │
│ info Show the current app info. │
│ link Link the project to an app. │
│ login Login to ConnectDev. │
│ logs Print logs. │
│ new Create a new project from a template. │
│ secret Set or unset environment │
│ start local start the project. │
╰────────────────────────────────────────────────────────────────────────────────
You can learn more about each subcommand by running connectdev <command> --help
. For example:
% connectdev new --help
Usage: connectdev new [OPTIONS] [DEST]
Create a new project from a template.
╭─ Arguments ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ dest [DEST] [default: None] │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --help Show this message and exit. │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Log In
The first thing you may want to do after installing the CLI is to log in to your account.
You can generate new personal token by going to Console > Account > Personal Token > Generate Token.
Then you can login by follow command:
connectdev login --token your_personal_token
Initialize a Project
After logging in, you can initialize a project with connectdev new
. This will also link the project to an existing application.
If you haven’t created an app on the dashboard, please do it first. Once you have your app created, create a new project by running connectdev new
:
% connectdev new my-app
Please select an app template:
1. Python - Flask
2. Go - Echo
Enter the number of your choice (q to quit):: 1
You selected: Python - Flask
Please select an app:
1. SubDomain
2. domain
3. button
4. Chaser
5. Engineering
6. connectdev
Enter the number of your choice (q to quit):: 1
You selected: SubDomain
Creating project...
Created Python - Flask project in `my-app`
Flask's documentation at https://flask.palletsprojects.com
It will create a directory with the name you provided. We can now run cd my-app
and install the dependencies:
- Python
- Golang
- Node.js
pip install -Ur requirements.txt
go mod tidy
npm install
Link to an Application
Most of the functions provided by the CLI require the project to be linked to an application. You can use connectdev link
to link a project to an application.
To link the project to a different application, run connectdev link
again.
Run and Debug Locally
Run the following command under the root directory of your project to run and debug the project locally:
connectdev start
Besides starting your project, the CLI will also start a Debug Console.
Visit http://localhost:3000 for the homepage of a web application.
The CLI won’t take care of auto-restart or hot-reload for your project, though some of our demo projects (like the Node.js demo project) come with the auto-restart feature.
Deploy
Once you’ve finished developing and testing your project, you can deploy it to ConnectDev:
connectdev deploy
This command will deploy the project to the production environment and override the previous version deployed from a local project.
You can customize the message with --m
% connectdev deploy --m "test cli"
Deploying the project ...
Deploy message: test cli
Python runtime detected
Project packaged at /var/folders/2f/y6cfh42j16bclmgybwljk8hw0000gn/T/chaser1xrhlnh3/chaser.zip
Current app id: 8VEVf1QRZGH3AbR1DbGBN4NZ
Deploying to remote server ...
App id: 8VEVf1QRZGH3AbR1DbGBN4NZ env: 1 archive_file_path: /var/folders/2f/y6cfh42j16bclmgybwljk8hw0000gn/T/chaser1xrhlnh3/chaser.zip message: test cli
[REMOTE] Building start 20240216-214120
[REMOTE] Unpacking source code ...
[REMOTE] Runtime:python
[REMOTE] Downloading and install dependence ...
[REMOTE] Push image to repository
[REMOTE] [Python] Using Python 3.10.13
[REMOTE] Build version 20240216-214120 finished
[REMOTE] Deploying 20240216-214120
[REMOTE] Creating new instance ...
[REMOTE] Starting new instance ...
[REMOTE] Instance started: Hello, World
[REMOTE] Deploy finished
After projects deployed can only be accessed with domains configured. You can get common domain by going to Console > Apps > Application Detail > Domain.
For example, you can access demo app on https://8vevf1qr.connectdev.io.
View Logs
You can view the latest logs of your application with logs
:
% connectdev logs
Current app id: 8VEVf1QRZGH3AbR1DbGBN4NZ
Downloading and install dependence ...
Push image to repository ...
[Python] Using Python 3.10.13
Build version 20240216-214120 finished
Deploying 20240216-214120
Creating new instance ...
Starting new instance ...
Instance started: Hello, World
Deploy finished
The command will return 10 entries by default, with the latest ones on the bottom.
You can use the -f option to have logs fetched continuously (similar to using tail -f):
connectdev logs -f
Newer logs will be automatically printed to the bottom of the screen.
Set Environments
You can use secret
subcommand to list, set and unset environment variables for current link application.
connectdev secret list
% connectdev secret list
Current app id: 8VEVf1QRZGH3AbR1DbGBN4NZ
No secrets found.
connectdev secret set ENV_KEY ENV_VALUE
% connectdev secret set ENV_KEY ENV_VALUE
Setting secret 'ENV_KEY' with key value 'ENV_VALUE'
Current app id: 8VEVf1QRZGH3AbR1DbGBN4NZ
Secret 'ENV_KEY' set successfully
connectdev secret list
% connectdev secret list
Current app id: 8VEVf1QRZGH3AbR1DbGBN4NZ
ENV_KEY=ENV_VALUE
connectdev secret unset ENV_KEY
% connectdev secret unset ENV_KEY
unsetting secret 'ENV_KEY'
Current app id: 8VEVf1QRZGH3AbR1DbGBN4NZ
Secret 'ENV_KEY' unset successfully
set and unset environment will trigger instance redeploy.
Show Application Info
connectdev info
You will see the output:
% connectdev info
App name: SubDomain
App id: 8VEVf1QRZGH3AbR1DbGBN4NZ