The MetaSSR CLI is a powerful tool designed to streamline the development, building, and deployment of web applications using the MetaSSR framework. This guide provides detailed information on how to use the CLI effectively.
These options can be used with any command to modify the behavior of the MetaSSR CLI:
-
--root
(default:.
)
The root directory of your project. Use this option to specify a different directory if your project files are not in the current working directory. -
--debug-mode
Enables debug mode, which provides additional logging details. This is useful for troubleshooting and understanding the internal workings of the framework.- Possible values:
All
- Enables all available debug logs.Metacall
- Logs related specifically to MetaCall operations.Http
- Logs HTTP request and response details.
- Possible values:
-
--log-file
Specifies the file path where logs will be saved. If not provided, logs will be output to the console.
The MetaSSR CLI supports several commands, each tailored to a specific stage of your project's lifecycle:
-
build
Compiles your web application into a deployable format. -
run
Launches the server to run your Server-Side Rendered (SSR) application. -
create
Generates a new MetaSSR project from a template, setting up your project structure and initial files.
Compiles your web application into the specified output directory, preparing it for deployment.
Options:
-
--out-dir
(default:dist
)
The directory where the build output will be saved. -
-t
,--type
(default:ssr
)
The type of build to perform:ssr
- Server-Side Rendering.ssg
- Static Site Generation.
Usage:
metassr build [OPTIONS]
Example:
metassr build --out-dir build-directory --type ssg
Starts the HTTP server to serve your SSR application. You can also use this command to serve static files generated by a previous build.
Options:
-
--port
(default:8080
)
The port number on which the HTTP server will run. -
--serve
Enables serving of the generated static site directly, it's used if you build your porject withssg
building type.
Usage:
metassr run [OPTIONS]
Example:
metassr run --port 3000 --serve
Creates a new MetaSSR project. This command scaffolds a project directory with the necessary files based on the selected template.
Options:
-
<project_name>
The name of your new project. This is a required positional argument. -
-v
,--version
(default:1.0.0
)
The initial version of your project. -
-d
,--description
(default:A web application built with MetaSSR framework.
)
A brief description of your project. -
-t
,--template
(default:javascript
)
The template to use for generating your project:javascript
typescript
Explore templates directory for more details
Usage:
metassr create <project_name> [OPTIONS]
Example:
metassr create my-app --version 1.0.1 --description "My first MetaSSR app" --template typescript
Here are some practical examples of how to use the MetaSSR CLI:
-
Build a project with the default settings:
metassr build
-
Run the SSR server on port 4000 with HTTP logging enabled:
metassr --debug-mode=http run --port 4000
-
Create a new TypeScript-based MetaSSR project named
my-new-app
:metassr create my-new-app --template=typescript
-
Build the project and output to a custom directory with debug mode enabled:
metassr --debug-mode=all build --out-dir custom-build
The MetaSSR CLI is designed to be a versatile and user-friendly tool for developing and managing web applications built with the MetaSSR framework. By understanding the available commands and options, you can effectively control every aspect of your project's lifecycle from creation to deployment.
For more detailed information on each command and its options, refer to the sections above. Happy coding!