This is the early access documentation preview for Custom Views. This documentation might not be in sync with our official documentation.
CLI
Use the CLI to set up, develop, and manage your website.
The CLI is the central entry point for frontend development. Its primary function is to transpile and bundle your code for development.
Install the CLI
To install the latest version of the CLI, open a command-line tool and run one of the following commands based on your operating system.
For macOS and Linux, run the following command:
Install frontastic-cli on macOS and LinuxTerminalbrew tap frontasticgmbh/tap && brew install frontastic-cliFor Windows, run the following commands:
Add scoop bucket on WindowsTerminalscoop bucket add FrontasticGmbH_scoop-bucket https://github.com/FrontasticGmbH/scoop-bucketInstall frontastic-cli on WindowsTerminalscoop install frontastic-cli
CLI dashboard
The CLI dashboard consists of the following panes:
Status displays the status of the running processes. For example, you can see if a process stops or a connection is lost.
Errors displays the number of unread errors for Next.js and backend extensions build. To read error logs, use the related hotkeys to open the window where the error occurred. When you return to the dashboard, the unread errors will be reset.
Startup checks displays the status of the CLI startup checks.
Test URL displays the URL for the test environment.
Studio URL displays the URL for the Studio.
The last pane displays the available hotkeys.
Commands, flags, and hotkeys
You interact with the CLI using commands and hotkeys. The flags let you provide additional options to the commands.
Commands
frontastic init
configures the project and prompts you to enter the Studio user API token.To copy your API token, follow these steps:
- From the Studio home page, click the Account icon and select Profile: the User settings dialog opens.
- Copy the value in the API token field.
You might need to provide your
sudo
password as the CLI updates your/etc/hosts
file, which needs superuser rights.frontastic install
runs the installation for all dependencies for your project.frontastic run
executes the following actions:- Starts the Next.js frontend process by running
yarn dev
. - Starts the build process of the extensions.
- Starts the Next.js frontend process by running
frontastic scaffold
creates a commercetools Frontend project when setting up a Git repository.frontastic upload
uploads the specified backend build to the Studio.frontastic help
runs thehelp
command to open up the help menu.
Flags
frontastic --version
displays the version of your CLI.frontastic [command] --verbose
displays logs and error messages from the specified command.frontastic [command] --help
displays information about the specified command.
Hotkeys
Dashboard
b
displays the webpack build log for extensions.d
opens the CLI dashboard.i
displays internal logs.n
displays the logs and error messages from the Next.js process.S
(eitherShift+s
orCaps Lock+s
) opens the URL to the Studio in a browser.t
opens your test URL in a browser.Control+c
exits the CLI. On Windows, you might need to typeexit
instead.
Logs
In the log windows, you can use the following hotkeys.
The hotkeys for extension logs differ from the hotkeys for other log windows. For further information, see Extension logs.
g
orhome
move to the top of the page.G
(eitherShift+g
orCaps Lock+g
) orend
move to the bottom of the page.h
orleft arrow
move left.j
ordown arrow
move down.k
orup arrow
move up.l
orright arrow
move right.Control+f
orpage down
move down one page.Control+b
orpage up
move up one page.Control+l
saves the current log window as a.txt
file.Control+m
adds a marker to the end of the log to help identify new log messages.
Extension logs
In the extension logs window, you can use the following hotkeys:
c
copies the selected log message to the clipboard.F
(eitherShift+f
orCaps Lock+f
) opens a filter dialog where you can filter messages by log level and other criteria.j
ordown arrow
move down.k
orup arrow
move up.r
initiates a search with regular expressions. Enter the expression to filter log messages./
initiates a search. Enter the search term to filter log messages.Enter
displays the detailed view of the selected log message.Control+h
adds a marker at the end of the log to help identify new log messages.
You can open a help window listing the hotkeys by pressing h
.
Update the CLI
We recommend keeping the CLI up-to-date to get the latest features and bug fixes. To update the CLI, run one of the following commands.
On macOS or Linux:
Update frontastic-cli on macOS/Linuxshellbrew upgrade frontastic-cliOn Windows:
Update frontastic-cli on Windowsshellscoop update frontastic-cli
Troubleshoot
Following are the most common issues with the CLI and their resolution.
CLI not starting on macOS
If you get a message saying the application cannot be started because the developer cannot be identified, you must allow the application from System Settings on your computer.
ENOENT or Yarn install errors
If you experience a problem with node_modules
or an error in the CLI containing ENOENT
, you must reset your local setup. To do so, follow these steps:
Run the following command to print the files that will be removed.
Test run the clean up commandshellgit clean -fdxn -e .ideaMake sure that the files can be removed. Then, run the following command to remove the files. This will delete the files that aren't tracked by Git and reset your local setup.
Print the files that will be removedshellgit clean -fdx -e .ideaRun the following command to re-initialize your project.
Remove untracked filesshellfrontastic init
Chromium not working on M1 Mac
You could get the following error when running frontastic install
on an M1 Mac.
The chromium binary is not available for arm64:If you are on Ubuntu, you can install with:apt-get install chromium-browserpath-to-project/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js:112throw new Error();
To fix the error, follow these steps:
Install Chromium on your local machine by running the following command:
Install Chromiumshellbrew install chromium- If Chromium runs correctly, go to step 5.
- If you get a message saying the application cannot be started because the developer cannot be identified, go to step 2.
Allow Chromium from System Settings on your computer. When doing so, you must select Anywhere.
If Anywhere is available, select it. Then, launch Chromium.
- If Chromium runs correctly, go to step 5.
- If you get the
Chromium is damaged and can't be opened
message, go to step 4.
If Anywhere is not available, go to step 3.
Run the following command to activate the Anywhere option. Then, repeat step 2.
Activate Anywhere option in security settingsshellsudo spctl --master-disableRun the following command, Chromium should now run correctly. Then, go to step 5.
Run Chromium with xattr -cr commandshellxattr -cr /Applications/Chromium.appEdit the
.zshrc
file on your computer by adding the following code. It allows skipping future installations of Chromium.Update Chromium configuration in .zshrcshellexport PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=trueexport PUPPETEER_EXECUTABLE_PATH=`which chromium`Run the following commands to remove the existing
node modules
,package-lock.json
, andcache
from the project.Remove node_modulesshellrm -rf node_modules/Remove package-lock.jsonshellrm -rf package-lock.jsonRemove cacheshellrm -rf .cacheClose your command-line tool and reopen it. Then, run
frontastic install
to install all dependencies.
Node-darwin-arm64 error on M1 Mac
You could get the following error when running frontastic install
on an M1 Mac.
Error: Cannot find module 'node-darwin-arm64/package.json
To fix the error, follow these steps:
Run the following command to check if the Apple Silicon M1 chip is causing the error.
Check the processor architectureshellnode -p process.arch- If this command outputs
arm64
, go to step 2. - If not, contact Support.
- If this command outputs
Run the following command to install Rosetta.
Install Rosettashellsoftwareupdate --install-rosettaRun the following command to use the
x86 64-bit
binary of zsh.Change zsh binary typeshellarch -x86_64 zshRun the following command to install the Node.js 16 long-term support version (LTS).
Install Node.js 16 LTSshellnvm install lts/galliumRun
frontastic install
.
CLI marked as virus on Windows
Windows could mark the CLI as a virus and you might get a threat quarantined message. On close, Windows might delete the .exe
file, and you will get a message like the following.
Error:Couldn't update hosts: fork/exec C:\Users\track\Desktop\frontastic-cli\frontastic.exe: Operation did not complete successfully because the file contains a virus or potentially unwanted software
To fix the error, you must edit Windows settings as follows:
On your computer, go to Windows Security > Virus & Threat Protection > Protection History.
Search for the quarantined CLI
.exe
file and select it.Ensure it's the CLI
.exe
file and not a real threat with a similar filename.Click Actions and select Restore.
Cannot install the CLI when using Docker
When creating a Docker image for your custom CI, you might face issues installing the CLI. In such case, you can use the CLI without installation by following these steps:
- From the release page of the CLI repository, download the archive for your operating system and architecture.
- Extract the archive and bundle the
frontastic
binary file into the Docker image.
When using the CLI without installation, you can only run the upload
command.