|
|
Environment
Now that we manually created a working and tested app,
we need a way of working to change, re-test and deploy it, on all configurations and on all platforms. In the spirit of Smalltalk, SmallJS takes a minimalist approach here. Its not tied to any specific tools, but just uses cross-platform bash scripts. Note: As stated in the Prerequisites, if you're on Windows, you need 'Git for Windows'. Not necessarily for the Git tools, but for the bash shell 'Git Bash'. Cleaning
Before our app can be added to source control, all generated files should be deleted.
This is done by the bash script: ./clean.sh .First replace its contents with this script: #!/bin/bash cd "$(dirname "$0")" echo "Cleaning: Frequencies" rm -fr ./web/Script This first line ensures its run with the bash shell. Then the current directory is set to the script directory (folder), ensuring all file operations are done from a known point. A message is displayed what the script is about to do. The actual cleaning is only removing the ./web/Script directory,that contains all compiled TypeScript and Smalltalk files. Now start the script ./clean.sh from a bash terminal or from your file manager.Version control
Now our project is cleaned, we should put in under version control.
For this you can use any system you like, as SmallJS does not have any built-in preferences or hooks. If you're new to this, then GitHub will probably be fine to start with. And then GitHub Desktop is a user friendly tool for making changes (committing). Now you can commit all files the project directory (optional). Browser configuration
To enable automated GUI testing, we need to tell the script
./build.shwhich browsers are available and which we want to use. This can differ per system, so it needs to be configured. First copy the file ./.env.example to file ./.env.(You can do this easily in the file view of VSCode) Then open the file .env in VSCode.You can see there are default browser locations for Windows, MacOS and Linux. Uncomment the browser you want to use by removing the leading hash characters # ,and adjust their paths to match installation on your computer. For example, if use are on Windows and only want to use Chrome to test, the resulting .env file would look something like this:browserChrome="/c/Program Files/Google/Chrome/Application/chrome.exe" # browserEdge="/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe" # browserFirefox="/c/Program Files/Mozilla Firefox/firefox.exe" Building & Testing
The script ./build.sh builds and tests our app this way:
./build.sh is already configured to run for every project.You should only replace all all text occurences of Counter with Frequencies,
to have build messages show the correct project name.If you moved the project folder relative to the SmallJS compiler and library, then the relative paths to them must be adjusted. Now start the script ./build.sh from a bash terminal.All steps should run automatically to completion, including starting configured browsers in test mode and closing them when done. If a tests in a browser fails, that browser will not close. To see what went wrong, you can open its developer tools with [F12], and then check out the error messages in the Console tab. Its probably more convenient to fix any errors in VSCode, using its debugger. Deploying
The SmallJS system actually does *not* have any specific tools for deploying,
as this is quite straightforward, and you will probably want to your own cloud tooling. To deploy this static web app, you can just:
|
|---|