Skip to content

Commit

Permalink
feat: accept url and token as arguments on stencil init
Browse files Browse the repository at this point in the history
  • Loading branch information
bookernath committed Aug 13, 2019
1 parent d098af8 commit b69a9fe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
5 changes: 4 additions & 1 deletion bin/stencil-init
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ var versionCheck = require('../lib/version-check');

Program
.version(pkg.version)
.option('-u, --url [url]', 'Store URL')
.option('-t, --token [token]', 'Access Token')
.option('-p, --port [port]', 'Port')
.parse(process.argv);

if (!versionCheck()) {
return;
}

stencilInit(JspmAssembler, ThemeConfig, dotStencilFilePath);
stencilInit(JspmAssembler, ThemeConfig, dotStencilFilePath, Program.url, Program.token, Program.port);
24 changes: 12 additions & 12 deletions lib/stencil-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ internals.parseAnswers = function(JspmAssembler, ThemeConfig, dotStencilFile, do
});
};

internals.implementation = function(JspmAssembler, ThemeConfig, dotStencilFilePath) {
internals.implementation = function(JspmAssembler, ThemeConfig, dotStencilFilePath, url, token, port) {
var dotStencilFile;
var questions;

Expand All @@ -82,13 +82,22 @@ internals.implementation = function(JspmAssembler, ThemeConfig, dotStencilFilePa
return 'You must enter a URL';
}
},
default: dotStencilFile && dotStencilFile.normalStoreUrl || undefined,
default: url || dotStencilFile && dotStencilFile.normalStoreUrl || undefined,
},
{
type: 'input',
name: 'accessToken',
message: 'What is your Stencil OAuth Access Token?',
default: token || dotStencilFile && dotStencilFile.accessToken,
filter: function(val) {
return val.trim();
},
},
{
type: 'input',
name: 'port',
message: 'What port would you like to run the server on?',
default: dotStencilFile && dotStencilFile.port || 3000,
default: port || dotStencilFile && dotStencilFile.port || 3000,
validate: function (val) {
if (isNaN(val)) {
return 'You must enter an integer';
Expand All @@ -99,15 +108,6 @@ internals.implementation = function(JspmAssembler, ThemeConfig, dotStencilFilePa
}
},
},
{
type: 'input',
name: 'accessToken',
message: 'What is your Stencil OAuth Access Token?',
default: dotStencilFile && dotStencilFile.accessToken,
filter: function(val) {
return val.trim();
},
},
];

Inquirer.prompt(questions, function(answers) {
Expand Down

0 comments on commit b69a9fe

Please sign in to comment.