Local developpement and deployment of the environement was a can of worm in the club.
Installation process was done using bash scripts both for the local developement environment and those script were hard to maintain and update. Updating them required a complete reinstall of the environment which was very time consumming.
Developement environment were installed localy on developement computer and on the AUV 7 computer. Custom commands were also an issue since everyone were using custom function and aliases defind in their own environment.
Using our new CLI we aim at having the following:
Here is an overview of the architecture of the CLI, ideas and reasoning behind it will be disclosed here. Documentation on each command will be available in their own page view SONIA-CLI
To ease up the developement effort, we selected oclif CLI framework.
Pushing code into master branch will automatically trigger package deployment on
npm. Package status can be seen on his npm page. Upon pushing inmasterbranch anpmandgithubrelease will be created. User having CLI installed on their environment should be notified that an update is available in their terminal and they shoud be able to update their client using thesonia updatecommand.
Update notification and update command where possible since we have added the following plugins to our CLI :
Additional oclif pluginsare available and could be usefull in the future
Before installing
sonia-auv-cliplease make sure to have an active ssh key added to you developement environement and into github. An github personal access token is also required more information on this will follow
First of all you will need to create an ssh key on your environment (local or subs). Here is a quick guide on how to create a key an where to add it into github:
In you terminal run the following commands to generate your ssh-key :
ssh-keygen -t rsa -b 4096
To display you ssh-key run the following command :
cat ~/.ssh/id_rsa.pub
After executing this command you can copy it's output and then add it to you github profile.
Here is a link of how to add and ssh-key to github adding-a-new-ssh-key-to-your-github-account
After adding your ssh-key to github you will need to generate an personal access token on github:
Here is a link on how to get you personal access token from github creating-a-personal-access-token
Once you have created your token, you will need to save it into your home directory into a file called TOKEN.txt
To implement new commands:
1. Install NodeJs on your system
2. Clone Sonia CLI Git repository
3. Code and read oclif framework documentation
4. To run and test a new command, run the following command at the root of the project:
node bin/run name-of-your-command
The following code was used to create a command that just print "Hello World!" in a terminal. It is avalaible in the hello-world.ts file.
The name of the command is the name of the ts file. You should use Kebab case.
export class HelloWorld extends Command {
static description = 'Just hello world'
async run(): Promise<void> {
console.log('Running command hello-world...')
const cmd = 'echo Hello World!'
try {
execSync(cmd, { stdio: 'inherit' })
} catch (error) {
// No need to print error message
}
}
}
To test this command, just type
node bin/run hello-world