thingssdk-cli
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -10,31 +10,46 @@ 'use strict'; | ||
const devices = {}; | ||
devices[port] = {baud_rate, runtime}; | ||
return { devices }; | ||
devices[port] = { baud_rate, runtime }; | ||
return { devices }; | ||
} | ||
function askUserForPortAndBaudRate(runtime) { | ||
function askForPort(answers) { | ||
return getPorts().then((ports) => { | ||
let questions = [ | ||
{ | ||
type: 'list', | ||
name: 'port', | ||
message: 'Select a port:', | ||
choices: ports, | ||
default: ports[0] | ||
}, | ||
{ | ||
type: 'list', | ||
name: 'baud_rate', | ||
message: 'Select the baud rate:', | ||
choices: ['9600', '115200'], | ||
default: '115200' | ||
} | ||
]; | ||
const portQuestion = [ | ||
{ | ||
type: 'list', | ||
name: 'port', | ||
message: 'Select a port:', | ||
choices: ports, | ||
default: ports[0] | ||
} | ||
]; | ||
return inquirer | ||
.prompt(portQuestion) | ||
.then(promptAnswers => Object.assign({},answers,promptAnswers)) | ||
}); | ||
} | ||
let deviceJSON = inquirer.prompt(questions).then(answers => { | ||
const port = answers.port; | ||
return devicesObject(port, answers.baud_rate, runtime); | ||
}); | ||
function askForBaudRate(answers) { | ||
const baudRateQuestion = [ | ||
{ | ||
type: 'list', | ||
name: 'baud_rate', | ||
message: 'Select the baud rate:', | ||
choices: ['9600', '115200'], | ||
default: '115200' | ||
} | ||
]; | ||
return inquirer | ||
.prompt(baudRateQuestion) | ||
.then(promptAnswers => Object.assign({},answers,promptAnswers)) | ||
} | ||
return deviceJSON; | ||
function askUserForPortAndBaudRate(runtime) { | ||
const answers = {}; | ||
return askForPort() | ||
.then(answers => { | ||
return askForBaudRate(answers); | ||
}) | ||
.then(answers => { | ||
return devicesObject(answers.port, answers.baud_rate, runtime); | ||
}); | ||
@@ -46,5 +61,11 @@ } | ||
let devicePromise; | ||
if (typeof port === 'undefined' && typeof baud_rate === 'undefined') { | ||
devicePromise = askUserForPortAndBaudRate(runtime); | ||
} | ||
else if(typeof port === 'undefined') { | ||
devicePromise = askForPort({}).then(answers => devicesObject(answers.port, baud_rate, runtime)); | ||
} | ||
else if(typeof baud_rate === 'undefined') { | ||
devicePromise = askForBaudRate({}).then(answers => devicesObject(port, answers.baud_rate, runtime)); | ||
} else { | ||
@@ -55,3 +76,3 @@ devicePromise = new Promise((resolve) => { | ||
} | ||
return devicePromise.then(devices => { | ||
@@ -58,0 +79,0 @@ write(path.join(destinationPath, "devices.json"), JSON.stringify(devices, null, 2)); |
@@ -12,6 +12,6 @@ 'use strict'; | ||
const RUNTIMES = { | ||
espruino: "1.88" | ||
espruino: "1.89" | ||
}; | ||
function checkForTilda(destinationPath) { | ||
function checkForTilde(destinationPath) { | ||
/** | ||
@@ -91,3 +91,3 @@ If the first part of the path contains a ~, | ||
checkForTilda(destinationPath); | ||
checkForTilde(destinationPath); | ||
@@ -128,4 +128,4 @@ return makeDirectory(path.join(destinationPath, 'scripts')) | ||
devDependencies: { | ||
"thingssdk-deployer": "1.0.0", | ||
"thingssdk-espruino-strategy": "1.0.0" | ||
"thingssdk-deployer": "~1.0.0", | ||
"thingssdk-espruino-strategy": "~1.0.1" | ||
}, | ||
@@ -144,2 +144,2 @@ engines: { | ||
createApplication | ||
}; | ||
}; |
{ | ||
"name": "thingssdk-cli", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Generator for JavaScript microcontroller projects", | ||
@@ -5,0 +5,0 @@ "main": "bin/thingssdk.js", |
@@ -53,8 +53,7 @@ 'use strict'; | ||
devDependencies: { | ||
//TODO: REPLACE WITH LIVE VERSIONS WHEN RELEASED @chalkers | ||
"thingssdk-deployer": "1.0.0", | ||
"thingssdk-espruino-strategy": "1.0.0" | ||
"thingssdk-deployer": "~1.0.0", | ||
"thingssdk-espruino-strategy": "~1.0.1" | ||
}, | ||
engines: { | ||
espruino: "1.88" | ||
espruino: "1.89" | ||
} | ||
@@ -162,4 +161,4 @@ }; | ||
describe("if arguments with tildas in the path are passed", () => { | ||
it("should error if tilda is used at the start of path and no project created", done => { | ||
describe("if arguments with tildes in the path are passed", () => { | ||
it("should error if tilde is used at the start of path and no project created", done => { | ||
const examplePath = "~/example"; | ||
@@ -166,0 +165,0 @@ newCommand({ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39309
889