-
Notifications
You must be signed in to change notification settings - Fork 6
User gets upgrade prompt #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
4b73e2a
379963e
355a6dc
f9e434d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| 'use strict'; | ||
|
|
||
| module.exports = function () { | ||
| var currentVersion = require('../package.json').version; | ||
| return new Promise(function (resolve, reject) { | ||
| var spawn = require('child_process').spawn; | ||
| var semver = require('semver'); | ||
| var versionProc = spawn('npm', ['view', 'perk-cli', 'version']); | ||
| return versionProc.stdout.on('data', function (data) { | ||
| var versionString = String(data); | ||
| if (semver.gt(versionString, currentVersion)) { | ||
| // version is outdated | ||
| console.log('There is a newer version of perk-cli available please upgrade'); | ||
| return resolve(false); | ||
| } | ||
| return resolve(true); | ||
| }); | ||
| version.stderr.on('data', function (data) { | ||
| // console.log(`stderr: ${data}`); | ||
| }); | ||
| }); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| module.exports = function() { | ||
| var currentVersion = require('../package.json').version; | ||
| return new Promise((resolve, reject) => { | ||
| const spawn = require('child_process').spawn; | ||
| const semver = require('semver'); | ||
| const versionProc = spawn('npm', ['view', 'perk-cli', 'version']); | ||
| return versionProc.stdout.on('data', (data) => { | ||
| const versionString = String(data); | ||
| if (semver.gt(versionString, currentVersion)) { | ||
| // version is outdated | ||
| console.log('There is a newer version of perk-cli available please upgrade'); | ||
| return resolve(false); | ||
| } | ||
| return resolve(true); | ||
| }); | ||
| version.stderr.on('data', (data) => { | ||
| // console.log(`stderr: ${data}`); | ||
| }); | ||
| }); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ You can read more about perk at http://perkframework.com | |
| `; | ||
|
|
||
| module.exports = { | ||
| all: function(locations) { | ||
| all: function(locations, current) { | ||
| return this.ensureDir(locations.tmpPath) | ||
| .then(p => this.clearPath(locations.extractPath)) | ||
| .then(p => this.ensureDir(locations.downloadPath)) | ||
|
|
@@ -32,7 +32,7 @@ module.exports = { | |
| .then(location => this.download(location, locations.zipPath)) | ||
| .then(downloadDir => this.unzip(downloadDir, locations.extractPath)) | ||
| .then(unzipDir => mergedirs(unzipDir, locations.targetPath, 'skip')) | ||
| .then(() => this.finish(locations.targetPath)); | ||
| .then(() => this.finish(locations.targetPath, current)); | ||
| }, | ||
| help: function() { | ||
| return help; | ||
|
|
@@ -150,7 +150,7 @@ module.exports = { | |
| }); | ||
| }); | ||
| }, | ||
| finish: function(dirPath) { | ||
| finish: function(dirPath, current) { | ||
| return ` | ||
|
|
||
|
|
||
|
|
@@ -167,6 +167,6 @@ http://perkframework.com/v1/guides/getting-started-os-x.html | |
|
|
||
|
|
||
|
|
||
| `; | ||
| ` + (current ? '' : 'Be Aware your perky-cli version is outdated, there may be differences with the docs'); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With ES6 string interpolation you could stick this right inside of the previous message instead of concatenating. Also there's a small typo (perky-cli) and we should notify them how to upgrade their perk-cli if they want to: eg. return `
Your new project has successfully been created in ${dirPath}
You should run:
cd ${dirPath} && npm install
While dependencies for your new perk app are installing you can check
out more info on how to use all the great features of perk at:
http://perkframework.com/v1/guides/getting-started-os-x.html
${current ? '' : 'Be Aware your perk-cli version is outdated, there may be differences with the docs. To upgrade run `npm install-g perk-cli`'}
`;
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking forward to getting this deployed. Great work! |
||
| } | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we name this something different than check for clarity. Maybe checkVersion?