marjory-cli
Marjory CLI
This package is a CLI tool to help you to manage your Marjory applications.
Create a new application - Instructions for end users
Here is the typical process an end user will follow to create a new application with the CLI :
- Install the CLI tool globally:
npm i -g marjory-cli - Create the app from marjory (https://app.marjory.io) in the section
Custom Extensions->+ Add Newbutton - Login to marjory through the CLI with
marjory login - Initialize a new Marjory application:
marjory init- Select the tenant you have used to create the appliacation
- From there you can select you application
- Edit the
deployment.ymlfile to configure this application - Configure the installation variables using the
marjory configure- Any variables configured is locally stored :
~/.marjory/<YOUR_APP_NAME>.json
- Any variables configured is locally stored :
- Run the application locally using the
marjory localcommand - Implement you application and test it locally
- Deploy the application using the
marjory deploycommand - Test the application inside the Marjory environment
- Promote the application to the
latestversion using themarjory promote
Update an existing application - Instructions for end users
Here is the typical process an end user will follow to update or deploy an existing application :
- Install the CLI tool globally:
npm i -g marjory-cli@beta - Retrieve the source code of your application (git clone from gitlab for example)
- Update the application as needed
- Make sure that the application slug in the package.json match with the application you want to update or deploy
- Deploy the application using the
marjory deploycommand - Test the application inside the Marjory environment
- Promote the application to the
latestversion using themarjory promote
List of commands
- marjory init: Initialize a new Marjory application
- marjory configure: Configure a Marjory application when runned locally
- marjory local: Run a Marjory application locally
- marjory login: Login to a Marjory application
- marjory deploy: Deploy a Marjory application
- marjory promote: Promote a Marjory application
- marjory logout: Logout from a Marjory application
- marjory oauth: Init a new OAuth process to retrieve an access token
marjory init
This command will initialize a new Marjory application based on the template stored in the src/new_app_template folder.
If we want to update the template, all changes must be done in this folder.
If we want to update the dependencies' versions, we must update the package.json file inside the src/new_app_template folder.
marjory configure
This command will configure the installation variables for a Marjory application. An interactive prompt will ask you to enter the values for each variable, based on the deployment.yml file.
If you have configured an OAuth 2 variable, this command will automatically open a browser window to start the OAuth process.
All settings will be saved locally in the $HOMEDIR/.marjory folder.
marjory local
This command will run a Marjory application locally. All functions and webhooks will be detected and displayed in the console. If you don't see a freshly created function or webhook, you can check your deployment.yml file to make sure it's correctly configured.
You can keep this command running while you're developing your application. If you make any change to your code, the application will be automatically reloaded.
marjory login
This command will login to a Marjory application. It'll ask you to enter your email and password. Then, it'll retrieve an access token and save it locally.
All credentials are saved locally in the $HOMEDIR/.marjory folder.
marjory logout
This command will logout from a Marjory application. It'll delete all credentials saved locally.
marjory deploy
This command will deploy a Marjory application. It'll check the current version of the app and the one from your local deployment.yml. If a current latest version exist it will offer you to upgrade your version following the semver standart. This version will be available for testing only and will need to be promoted to be accessible by your users.
marjory promote
This command will promote a Marjory application. It will make your current selected version as the latest. This version will be available for your users.
marjory oauth
It's better to use the marjory configure command to configure an OAuth 2 variable. This command is only useful if you want to test an OAuth configuration locally.
To test an OAuth configuration locally, configure the OAuth app inside your deployment.yml file and then run the following command:
marjory oauth --name [OAuth config name]
This command line will verify your OAuth configuration and init a new OAuth authorization process in order to retrieve the access_token.
All tokens will be saved locally and the command can be run again: it'll return you the access_token or will renew it for you. If the token has expired and can't be renewed, the old token will be deleted and the OAuth process will start again.
You can delete manually the cache by cleaning the $HOMEDIR/.marjory/oauth folder or using the following command:
marjory oauth --name [OAuth config name] --clean
Local development
install the CLI globally
type node index.js, the list of commands available
Ideally, put the project in a cli-workspace directory, open it from vscode and enter node factory-cli/index.js in the terminal
NPM Link
To use this package in dev, we must use npm link
Inside this application, run the following command:
npm link
Then, inside the app you want to use this package, make sure to change de devDependencies from marjory-cli to @marjory/factory-cli and then run the following command:
npm link @marjory/factory-cli