Skip to content

Commit

Permalink
Updated how the package.json is created, removed redunancy and added …
Browse files Browse the repository at this point in the history
…new thingssdk deps
  • Loading branch information
chalkers committed Jun 3, 2017
1 parent 1e0c703 commit ea303e9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 28 deletions.
29 changes: 7 additions & 22 deletions lib/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@ const {write, copy, isDirectoryEmpty} = require('./core/file');
const colors = require('./core/colors-theme');
const {shouldOverwrite} = require('./core/cli-helpers');


/**
* @const
* @type {object}
* @description
* A list of possible runtimes that can be listed in the package.json file for
* the IoT project. Currently not configurable, defaults to esprurino 1.89
*/
const RUNTIMES = {
espruino: "1.89"
};


/**
* @name checkForTilde
*
Expand Down Expand Up @@ -148,8 +135,7 @@ function makeDirectory(directory) {
* @description
* Selects the correct template files for the IoT project, creates the new project
* folder, and copies the template files into the new project folder. Configures
* and writes the package.json and devices.json files. Currently runtime for all
* projects created is fixed at esprurino 1.89.
* and writes the package.json and devices.json files.
*
* @param {Object} options The four configuration options passed to the yargs
* command line.
Expand Down Expand Up @@ -205,6 +191,10 @@ function createFiles(options) {
* @returns {Object} The package.json object for the new project
*/
function createPackageJSON(app_name, runtime) {
const strategy = `thingssdk-${runtime}-strategy`;
const strategyVersions = {
espruino: "~1.0.2"
};
const pkg = {
name: app_name,
version: '0.0.0',
Expand All @@ -216,16 +206,11 @@ function createPackageJSON(app_name, runtime) {
repl: "node ./scripts/repl"
},
devDependencies: {
"thingssdk-deployer": "~1.0.0",
"thingssdk-espruino-strategy": "~1.0.1"
},
engines: {

"thingssdk-deployer": "~1.0.1",
[strategy]: strategyVersions[runtime]
}
};

pkg.engines[runtime] = RUNTIMES[runtime];

return pkg;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "thingssdk-cli",
"version": "1.1.0",
"version": "1.2.0",
"description": "Generator for JavaScript microcontroller projects",
"main": "bin/thingssdk.js",
"bin": {
Expand Down
7 changes: 2 additions & 5 deletions test/commands/test-new.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,8 @@ describe("thingssdk new", () => {
repl: "node ./scripts/repl"
},
devDependencies: {
"thingssdk-deployer": "~1.0.0",
"thingssdk-espruino-strategy": "~1.0.1"
},
engines: {
espruino: "1.89"
"thingssdk-deployer": "~1.0.1",
"thingssdk-espruino-strategy": "~1.0.2"
}
};
assert.deepEqual(pkgJSON, expectedJson, "package.json didn't match expectedJson");
Expand Down

0 comments on commit ea303e9

Please sign in to comment.