From 89e3eb615638ffb3fc3c48ab135cccdf34f1fbc5 Mon Sep 17 00:00:00 2001 From: Santiago Gonzalez Toral Date: Mon, 12 Nov 2018 22:39:20 -0500 Subject: [PATCH] feat(@embark/cli): add --template option to embark demo cli command Adds a --template option to the embark demo cli command so it is now possible to generate a demo project using an existing embark's template repository on Github with an existing demo branch (e.g. embark demo --template vue will use embark-framework/embark-vue-template#demo), or any other git URL repository. If no --template option is specified, the command will generate a demo from default template in templates/demo --- src/cmd/cmd.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/cmd/cmd.js b/src/cmd/cmd.js index eb6520c30..25793f97a 100644 --- a/src/cmd/cmd.js +++ b/src/cmd/cmd.js @@ -92,10 +92,19 @@ class Cmd { program .command('demo') .option('--locale [locale]', __('language to use (default: en)')) + .option('--template ', __('download a demo template using a known name or a git host URL')) .description(__('create a working dapp with a SimpleStorage contract')) .action(function(options) { i18n.setOrDetectLocale(options.locale); - embark.generateTemplate('demo', './', 'embark_demo'); + if(options.template) { + const hostedGitInfo = require('hosted-git-info'); + const hgi = hostedGitInfo.fromUrl(options.template); + const url = !hgi ? `embark-framework/embark-${options.template}-template#demo`:options.template; + const folderName = !hgi ? `embark_${options.template}_demo`:'template_demo'; + embark.generateTemplate('demo', './', folderName, url); + } else { + embark.generateTemplate('demo', './', 'embark_demo'); + } }); }