CLI - globules-io/OGX.JS GitHub Wiki

OGX.CLI is a command line interpreter for OGX.JS. The CLI is the all around toolbox to work with files in OGX.JS without having to create/delete/link anything by hand, for both dev and prod builds.

Since version 1.7.2, upon installation, [email protected] is also installed globally. The compress command relies on this package.

Install

The CLI requires NPM/Node.JS

  //init npm package
  npm init 

  //install CLI globally 
  npm install @globules-io/ogx.cli -g

  //install or update OGX.JS for current project/folder
  ogx update --force

  //OR you can alternatively use the master dev version
  ogx update --dev

  //init default structure
  ogx init

Commands

Help

To display help and specific command help

  ogx help
  ogx help create

Init

To create the default folder structure

 ogx init

Version

To check the installed vs latest version of OGX.JS and OGX.CLI

 ogx version

Install/Update

To install or update to the latest version of OGX.JS (--force is optional)

 ogx update --force

Create

To create files and set them up in your OGX.JS project

  ogx create view MyView
  ogx create template MyTemplate
  ogx create stage MyStage
  ogx create controller MyController

Rename

To rename files and update them up in your OGX.JS project (OML files, JSON files, Views, Stages, Controllers and app.json)

  ogx rename view MyView MyNewName
  ogx rename template MyTemplate MyNewName
  ogx rename stage MyStage MyNewName
  ogx rename controller MyController MyNewName

Delete

To delete files and unset from in your OGX.JS project

  ogx delete view MyView
  ogx delete template MyTemplate
  ogx delete stage MyStage
  ogx delete controller MyController

Open 1.13.3+

The open command will lookup a View (js and css) and a Template, given a name, and will attempt to open the files in the current instance of VSCODE.

  ogx open invoices

The targeted files are www/js/views/view.Invoices.js, www/css/views/view.Invoices.css, www/js/html/template.Invoices.html and www/oml/invoices.html

You can also specify the type of file and lookup and open that specific file, considering the name of View

  ogx open js invoices 

In this case, the file www/js/views/view.Invoices.js will open

Images

To list all image files present in your www/img folder and all the images in each theme, and link them in the preload tag of app.json

  ogx images

Sounds

To list all sound files present in your www/snd folder, and link them in the preload tag of app.json

  ogx sounds

Jsons

To list all json files present in your www/json folder, and link them in the preload tag of app.json

  ogx jsons

Fonts

To list all folders and all fonts in each folder of the www/fonts folder, and all the fonts in each theme, then create www/css/bin/fonts.css with the font declarations in it then link it to the index.html

  ogx fonts

Then when OGX.JS is going to preload, it will create an invisible element with some text with a css set to a font variation, then later deleted to ensure all fonts are ready. Note that the expected font format is

  fontname-variation.ext

such as

  roboto-regular.ttf      

Note that this command must be run again if the link or unlink commands are used.

Link

To list all files of a type, and link them in to the head tag of index.html. Note that this is done automatically when using the create command.

 ogx link views
 ogx link templates
 ogx link stages
 ogx link css
 ogx link js
 ogx link all

Note that ogx link css only links the extra css files located in www/css/bin and that ogx link js only links the extra js files located in www/js/bin. The js and css files created with the CLI (controllers, views and stages) are linked with ogx link controllers, ogx link views and ogx link stages.

Unlink

To list all files of a type, and unlink them in to the head tag of index.html. Note that this is done automatically when using the delete command.

 ogx unlink views
 ogx unlink templates
 ogx unlink stages
 ogx unlink css
 ogx unlink js
 ogx unlink all

Note that ogx unlink css only unlinks the extra css files located in www/css/bin and that ogx unlink js only unlinks the extra js files located in www/js/bin. The js and css files created with the CLI (controllers, views and stages) are unlinked with ogx unlink controllers, ogx unlink views and ogx unlink stages.

Prepare

Prepare is the all in one command to unlink then list and link all files.

 ogx prepare

You can skip some elements

 ogx prepare skip images fonts

You can save this preference, so every time you use ogx prepare, the same elements are skipped

 ogx prepare skip images fonts --save

To remove the elements to skip

 ogx prepare skip --reset

You can also clear your preload node from app.json by doing

 ogx prepare clear

Note that clear does not reset any skip preference

Compress

Back up and compress files contained in the following folders, then links the compressed files in index.html

 www/css/bin
 www/css/views
 www/css/stages
 www/js/bin
 www/js/views
 www/js/controllers
 www/js/stages

Restore

Restore files contained in the following folders, then links the uncompressed files in index.html

 www/css/bin
 www/css/views
 www/css/stages
 www/js/bin
 www/js/views
 www/js/controllers
 www/js/stages

Purge

Looks up for unused files and prompts to remove them.

 ogx purge [stages|views|controllers|templates|images|all]

Set

To change an option of the CLI, such as the default index page from index.html to index.php, do

 ogx set index index.php

Dev

To link in index file and use OGX.JS dev/debug version

 ogx dev

Prod

To link in index file and use OGX.JS production version. Note that production builds stops working if inspected in the console. They are not meant to be used in a development environment.

 ogx prod

Encrypt

To encrypt app.json

 ogx encrypt my_secret_key

Decrypt

To decrypt app.json

 ogx decrypt my_secret_key

Build

To build via external tool

 ogx build android debug

Pack

Packs multiple files into one. Once packed, all files are still available within the framework as if they were unpacked.

 ogx pack templates
 ogx pack jsons
 ogx pack omls

To pack all supported file types

 ogx pack all

Note that if you are hosting on IIS, you should add .pak to MIME types as text/plain. You should also add .oml as application/json

Unpack

Unpacks a pak file into multiple files.

 ogx unpack templates
 ogx unpack jsons
 ogx unpack omls

To unpack all supported file types

 ogx unpack all

Deploy

To deploy a build to a device

 ogx deploy android debug

Workflow

The proper simplified workflow to release a production build

 ogx prod  /* tell the CLI to use production build of OGX */
 ogx pack all /* pack all supported files into a single file */
 ogx prepare /* prepare index */
 ogx compress /* compress files and update index */
 ogx encrypt [key] /* encrypts app.json */

To switch back to dev/debug

 ogx decrypt [key] /* decrypt app.json */
 ogx restore  /* restore uncompressed files */
 ogx unpack all /* unpack all supported files into multiple files */
 ogx dev  /* tell the CLI to use dev build of OGX */    
 ogx prepare /* rebuild index file */  

Note that if you pack and encrypt, pak files will be encrypted too, starting at version 1.14.0