README.md
Homepage Repository npm JavaScript Download
npm install ivx-cli@1.0.0
The iVX CLI uses Node 8+ and is installed using NPM. It works best when installed globally.
$ npm i -g ivx-deploy
$ ivx help
Options:
-V, --version Output the version number
-h, --help Output usage information
Commands:
init|i [options] Set up the environment variables for a working directory
login|l [options] Authenticates to the directory using email verification code
pull|p [options] Pulls down all the associated assets for a given story
scaffold|s [options] Scaffolds out the root directory for story assets
check|c [options] Checks the status by comparing assets for a given story
validate|v [options] Validate local files against the configured story
push|u [options] Pushes all the associated assets to a given story
The first thing the tool needs to do is initialize a workspace on the filesystem. Like NPM, the init function will prompt the developer about basic settings and hold them in two small files at the root of the workspace.
$ ivx init|i [options]
Set up the environment variables for a working directory
Options:
-D, --debug Debug output.
-e, --environment [env] Environment to use against [local|dev|stage] (default: dev)
-p, --path <path> Directory for this project (if not the root where the command is execute from)
-E, --email <email> Email address of the current user
-d, --directory <dir> Which directory holds stories (default: null)
-h, --help output usage information
The environment determines which iVX environment endpoints will be used to upload the asset.
* Production (prod) is only available in the non-interactive authentication mode. The tool will allow you to push straight from the workstation to the platform in local, dev and stage, but production MUST go through a build-deployment from TeamCity. This way, we can be nimble in staging environments and once the story looks good, a check in (after pull-request) is needed to get the assets up to the platform.
Currently, the assets can still be built and uploaded through the UI, but we need to update permissions so that we can lock assets down to deployment-mode only.
We need to make sure this tool can only be used by authorized StoryAdmins (w/AssetManagement grant in production). This means we need to authenticate the user or server for a token with permission to update the assets. We should use our Auth0 to authenticate this tool in one of two modes, interactive or application.
By default, this tool requires user credentials with permission to update the story assets. credentials and will prompt the user into the login-flow below, using the passwordless-email option in Auth0. No passwords will ever be transmitted or collected. However, the tokens should be saved in a location that allows the token to be reused if the command is run again.
$ ivx login|l [options] [email]
Authenticates to the directory using email verification code
Options:
-D, --debug Debug output.
-e, --environment [env] Environment to use against [local|dev|stage] (default: dev)
-p, --path <path> Directory for this project (if not the root where the command is execute from)
-E, --email <email> Your email address (for authentication)
-c, --code <code> Email verification code (default: null)
-t, --token <token> An existing token to write to the directory
-f, --force Force new authentication
-h, --help Output usage information
If we initialize Auth0 as Machine-to-Machine application and provide environment variables for the ClientID and ClientSecret for the client, this tool can authenticate as itself from the build-server with the special permissions needed to push assets to production.
Environment Variables:
The quickest way to get set up on an existing story is to pull all assets for a story using this command. It assumes the convention configuration mode and downloads the assets according to the file structure above.
$ ivx pull|p [options] [keys...]
Pull down all the associated assets for a given story
Options:
-D, --debug Debug output.
-e, --environment [env] Environment to use against [local|dev|stage] (default: dev)
-p, --path <path> Directory for this project (if not the root where the command is execute from)
-k, --key <key> Story key to pull assets from
-x, --explicit Write all file locations in the ivx-config.json file.
-a, --all Pull all stories without prompting
-h, --help output usage information
-i, --client_id <id> Auth0 Client ID
-s, --client_secret <id> Auth0 Client Secret
If this is a brand new repository for a new story. You can scaffold the folder structure along with empty files to get you started.
$ ivx scaffold|s [options] [keys...]
Scaffolds out the root directory for story assets
Options:
-D, --debug Debug output.
-e, --environment [env] Environment to use against [local|dev|stage] (default: dev)
-p, --path <path> Directory for this project (if not the root where the command is execute from)
-k, --key <key> Scaffold using this story key
-x, --explicit Write all file locations in the ivx-config.json file.
-h, --help Output usage information
The check command will compare the contents of the assets on the platform with the contents of the files on disc. This gives the user a quick way of seeing the impact a push might have.
$ ivx check|c [options] [keys...]
Checks to see what files are different on disc from the platform
Options:
-D, --debug Debug output.
-e, --environment [env] Environment to use against [local|dev|stage] (default: dev)
-p, --path <path> Directory for this project (if not the root where the command is execute from)
-k, --key <key> Story key to push (default: null)
-a, --all Push all stories without prompting
-i, --client_id <id> Auth0 Client ID
-s, --client_secret <id> Auth0 Client Secret
The validate command will validate the contents of the assets on the platform to ensure all tokens are valid.
$ ivx validate|v [options] [keys...]
Checks to see what files are different on disc from the platform
Options:
-D, --debug Debug output.
-e, --environment [env] Environment to use against [local|dev|stage] (default: dev)
-p, --path <path> Directory for this project (if not the root where the command is execute from)
-k, --key <key> Story key to push (default: null)
-a, --all Push all stories without prompting
-i, --client_id <id> Auth0 Client ID
-s, --client_secret <id> Auth0 Client Secret
The deployment command executes differently depending on the authenticating mode. For interactive clients, if not yet logged in, you are prompted first. Then the plan command is executed first with a prompt to continue. Then the validate command is executed. If no errors exist, the user is prompted to push.
$ ivx push|u [options] [keys...]
Pushes all the associated assets to a given story
Options:
-D, --debug Debug output.
-e, --environment [env] Environment to use against [local|dev|stage] (default: dev)
-p, --path <path> Directory for this project (if not the root where the command is execute from)
-k, --key <key> Story key to push (default: null)
-a, --all Push all stories without prompting
-i, --client_id <id> Auth0 Client ID
-s, --client_secret <id> Auth0 Client Secret
This application works best when the folder and file conventions are used. This method reduces the amount of configuration necessary for deployments. The following illustrates the convention for a given story.
[root]
ivx-config.json
📁<story-key>
/story.json
/story.js
/story.css
/story-intro.html
📁html-templates
/<file-key>.html
📁text-templates
/<file-key>.txt|json|js|css|less|csv|xml
📁email-templates
/<email-key>.cshtml
📁episodes
📁<episode-key>
/story.json
/story.css
/story.js
{
"directory": "./", // optional
"stories": { // not optional
"testing": {
"name": "Sample Story"
}
}
}
{
"directory": "/src/stories",
"stories": {
"testing": {
"name": "Sample Story",
"intro_html_file": "/testing/story-intro.html",
"js_file": "/testing/story.json",
"json_file": "/testing/story.js",
"css_file": "/testing/story.css",
"episodes": {
"test-episode": {
"json_file": "/testing/episodes/test-episode/story.json",
"css_file": "/testing/episodes/test-episode/story.css",
"js_file": "/testing/episodes/test-episode/story.js",
}
},
"email_templates": {
"example": "/testing/email-templates/example.cshtml"
},
"html_templates": {
"example": "/testing/html-templates/example.html"
},
"text_templates": {
"example": "/testing/text-templates/example.js"
}
}
}
}
This is another important part of all interactive deployments. It gives the user a chance to validate all file contents within the configuration, whether it was by convention or declaration. This command shows server validation for each file, including token errors.
$ ivx validate|v [options] [keys...]
This command will use the local-configuration as the source of truth, creating any assets missing on the platform as well as removing any not found locally on disc.
$ ivx sync|s [options] [keys...]