How to use the command 'now' (with examples)
The ’now’ command is a cloud platform for serverless deployment. However, it is important to note that this command is deprecated and users are encouraged to use the updated version ‘vercel’ instead. The ’now’ command is used for various purposes such as deploying directories, managing deployments, inspecting deployment information, removing deployments, logging in or creating a new account, and initializing example projects.
Use case 1: Deploy the current directory
Code:
now
Motivation: The ’now’ command allows you to deploy the current directory. This can be helpful when you want to quickly deploy your project and make it accessible online.
Explanation: The ’now’ command without any arguments deploys the current directory. It takes no additional arguments.
Example output:
Deploying /path/to/current_directory under <deployment_url> ...
Use case 2: Display a list of deployments
Code:
now list
Motivation: Sometimes we need to check the list of deployments that have been made. This can be beneficial when you want to keep track of all your deployments and their statuses.
Explanation: The ’now list’ command displays a list of all the deployments made. It takes no additional arguments.
Example output:
Deployments:
- <deployment_1_url>
- <deployment_2_url>
- <deployment_3_url>
...
Use case 3: Display information related to a deployment
Code:
now inspect <deployment_url>
Motivation: When you want to get detailed information about a specific deployment, you can use the ’now inspect’ command. This can be useful if you want to verify the deployment status, review environment variables, or check the logs.
Explanation:
The ’now inspect’ command is used to display information related to a specific deployment. Replace <deployment_url>
with the URL of the deployment you want to inspect.
Example output:
Deployment information for <deployment_url>:
- URL: <deployment_url>
- State: READY
- Created: <timestamp>
- Aliases: none
- ...
Environment Variables:
- VARIABLE_1: value_1
- VARIABLE_2: value_2
- ...
Logs:
[timestamp] INFO: ...
[timestamp] ERROR: ...
...
Use case 4: Remove a deployment
Code:
now remove <deployment_id>
Motivation: If you need to remove a deployment that is no longer needed, you can use the ’now remove’ command. Removing unnecessary deployments can help manage your serverless resources more efficiently.
Explanation:
The ’now remove’ command is used to remove a specific deployment. Replace <deployment_id>
with the ID of the deployment you want to remove.
Example output:
Removing deployment <deployment_id> ...
Deployment removed successfully!
Use case 5: Log in into an account or create a new one
Code:
now login
Motivation: To access certain functionalities and manage your deployments, you need to log in to your account. The ’now login’ command allows you to log in or create a new account if you don’t have one.
Explanation: The ’now login’ command is used to log in to an existing account or create a new one. It takes no additional arguments.
Example output:
> Please run `now vercel` to install the latest version of the Now CLI.
Use case 6: Initialize an example project
Code:
now init
Motivation: If you want to start a new project, the ’now init’ command can help you get started by initializing an example project. This can serve as a starting point or a reference for your own project.
Explanation: The ’now init’ command initializes an example project and creates a new directory. It takes no additional arguments.
Example output:
Initializing example project in /path/to/new_directory ...
Example project initialized successfully!
Conclusion:
The ’now’ command offers various functionalities for serverless deployment. From deploying directories to managing deployments, inspecting deployment information, removing deployments, logging in, and initializing example projects, the ’now’ command provides a powerful toolset for cloud-based serverless development. However, users are encouraged to migrate to the updated version ‘vercel’ as the ’now’ command is deprecated.