Skip to content

Commit 1e76b21

Browse files
committed
require Atom 1.8+ & Node 4+
1 parent 98f084d commit 1e76b21

File tree

7 files changed

+117
-58
lines changed

7 files changed

+117
-58
lines changed

lib/components/Start/Checks/SystemChecks.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ var DynamicStepper_1 = require('./DynamicStepper');
44
var StepCheck_1 = require('./StepCheck');
55
var VerifyButton_1 = require('./VerifyButton');
66
var Card_1 = require('material-ui/Card');
7-
var FlatButton_1 = require('material-ui/FlatButton');
87
var colors_1 = require('material-ui/styles/colors');
98
var SystemChecks = function (_a) {
109
var checks = _a.checks;
@@ -20,14 +19,19 @@ var SystemChecks = function (_a) {
2019
React.createElement(StepCheck_1.default, {label: 'Node >= 0.10', completed: system.node},
2120
React.createElement("p", null,
2221
"Install a newer version of ",
23-
React.createElement("a", {style: { color: colors_1.pink500 }, href: 'https://nodejs.org'}, "NodeJS"))
24-
),
22+
React.createElement("a", {style: { color: colors_1.pink500 }, href: 'https://nodejs.org'}, "NodeJS")),
23+
React.createElement("p", null, "Either version 4 (stable) or above.")),
2524
React.createElement(StepCheck_1.default, {label: 'NPM >= 3', completed: system.npm},
2625
"Update your version of NPM.",
2726
React.createElement("br", null),
2827
React.createElement("code", null, "> npm update -g npm"),
29-
React.createElement("br", null),
30-
React.createElement(FlatButton_1.default, {label: 'Update NPM', secondary: true})),
28+
React.createElement("br", null)),
29+
React.createElement(StepCheck_1.default, {label: 'Atom >= 1.8', completed: system.atom},
30+
React.createElement("p", null, "First make sure you have atom shell commands installed." + ' ' + "Click the atom menu and select \"Istall Shell Commands\"."),
31+
React.createElement("p", null,
32+
"Otherwise, update your version of Atom.",
33+
React.createElement("br", null),
34+
"Click on the blue \"update\" squirrel in the bottom right corner of your editor.")),
3135
React.createElement(StepCheck_1.default, {label: 'Xcode', completed: system.xcode},
3236
React.createElement("p", null,
3337
"Install ",

lib/modules/setup/utils/check-system.js

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,42 @@
11
"use strict";
22
var atom_plugin_command_line_1 = require('atom-plugin-command-line');
3+
var versions = {
4+
node: '4.0.0',
5+
atom: '1.8.0',
6+
npm: '3.0.0'
7+
};
38
function matchVersions(v) {
49
return v.match(/([0-9]+)\.([0-9]+)/);
510
}
11+
function isAboveVersion(a, b) {
12+
if (a === b) {
13+
return true;
14+
}
15+
var a_components = a.split('.');
16+
var b_components = b.split('.');
17+
var len = Math.min(a_components.length, b_components.length);
18+
for (var i = 0; i < len; i++) {
19+
var first = parseInt(a_components[i], 10);
20+
var second = parseInt(b_components[i], 10);
21+
if (first > second) {
22+
return true;
23+
}
24+
if (first < second) {
25+
return false;
26+
}
27+
}
28+
if (a_components.length > b_components.length) {
29+
return true;
30+
}
31+
if (a_components.length < b_components.length) {
32+
return false;
33+
}
34+
return true;
35+
}
636
function minVersion(command, minVersion) {
737
return new Promise(function (resolve, reject) {
838
var minOrLater = atom_plugin_command_line_1.default(command, '-v')
9-
.then(function (res) {
10-
if (parseInt(res, 10).toString() === 'NaN') {
11-
return false;
12-
}
13-
var mins = matchVersions(minVersion);
14-
if (!!mins) {
15-
var resMins = matchVersions(res);
16-
var firstDigit = parseInt(resMins[1], 10);
17-
var firstVersion = parseInt(mins[1], 10);
18-
return firstDigit > firstVersion ||
19-
firstDigit === firstVersion && parseInt(resMins[2], 10) >= parseInt(firstVersion[2], 10);
20-
}
21-
else {
22-
return parseInt(res, 10) >= parseInt(minVersion, 10);
23-
}
24-
});
39+
.then(function (res) { return isAboveVersion(res, minVersion); });
2540
if (!minOrLater) {
2641
resolve(false);
2742
}
@@ -30,12 +45,26 @@ function minVersion(command, minVersion) {
3045
}
3146
});
3247
}
48+
function atomMinVersion() {
49+
return new Promise(function (resolve, reject) {
50+
var minOrLater = atom_plugin_command_line_1.default('atom', '-v').then(function (res) {
51+
var match = res.match(/Atom\s+:\s+([0-9]\.[0-9]\.[0-9])/);
52+
if (match && match[1] && isAboveVersion(match[1], versions.atom)) {
53+
resolve(true);
54+
}
55+
else {
56+
resolve(false);
57+
}
58+
});
59+
});
60+
}
61+
exports.atomMinVersion = atomMinVersion;
3362
function npmMinVersion() {
34-
return minVersion('npm', '3');
63+
return minVersion('npm', versions.npm);
3564
}
3665
exports.npmMinVersion = npmMinVersion;
3766
function nodeMinVersion() {
38-
return minVersion('node', '0.10');
67+
return minVersion('node', versions.node);
3968
}
4069
exports.nodeMinVersion = nodeMinVersion;
4170
function requiresXCode() {

lib/modules/setup/utils/verify.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function setupVerify(dir, packageJson) {
1919
node: !!check_system_1.nodeMinVersion(),
2020
npm: !!check_system_1.npmMinVersion(),
2121
xcode: !!check_system_1.requiresXCode(),
22+
atom: !!check_system_1.atomMinVersion(),
2223
},
2324
setup: {
2425
hasDir: hasDir,

src/components/Start/Checks/SystemChecks.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const SystemChecks: React.StatelessComponent<{
3030
completed={system.node}
3131
>
3232
<p>Install a newer version of <a style={{color: pink500}} href='https://nodejs.org'>NodeJS</a></p>
33+
<p>Either version 4 (stable) or above.</p>
3334
</StepCheck>
3435

3536
<StepCheck
@@ -38,11 +39,16 @@ const SystemChecks: React.StatelessComponent<{
3839
>
3940
Update your version of NPM.<br />
4041
<code>> npm update -g npm</code><br />
41-
<FlatButton
42-
label='Update NPM'
43-
secondary={true}
44-
/* onTouchTap={updateNpm} */
45-
/>
42+
</StepCheck>
43+
44+
<StepCheck
45+
label='Atom >= 1.8'
46+
completed={system.atom}
47+
>
48+
<p>First make sure you have atom shell commands installed.
49+
Click the atom menu and select "Istall Shell Commands".</p>
50+
<p>Otherwise, update your version of Atom.<br />
51+
Click on the blue "update" squirrel in the bottom right corner of your editor.</p>
4652
</StepCheck>
4753

4854
<StepCheck

src/components/Start/Welcome/index.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ const Welcome: React.StatelessComponent<{
4141
title: string, tagline: string, firstRoute: string
4242
}> = ({title, tagline, firstRoute}) => (
4343
<div style={styles.header} className='cr-bg'>
44-
<div style={styles.title}>{title}</div>
45-
<div style={styles.tagline}>{tagline}</div>
46-
<br /><br />
47-
<RouteButton
48-
label='Start'
49-
route={firstRoute}
50-
style={styles.button}
51-
/>
44+
<div style={styles.title}>{title}</div>
45+
<div style={styles.tagline}>{tagline}</div>
46+
<br /><br />
47+
<RouteButton
48+
label='Start'
49+
route={firstRoute}
50+
style={styles.button}
51+
/>
5252
</div>
5353
);
5454
export default Welcome;

src/modules/setup/utils/check-system.ts

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,62 @@
11
import commandLine from 'atom-plugin-command-line';
22

3+
const versions = {
4+
node: '4.0.0',
5+
atom: '1.8.0',
6+
npm: '3.0.0'
7+
};
8+
39
function matchVersions(v: string): string[] {
410
return v.match(/([0-9]+)\.([0-9]+)/);
511
}
612

13+
function isAboveVersion(a: string, b: string): boolean {
14+
if (a === b) { return true; }
15+
const a_components = a.split('.');
16+
const b_components = b.split('.');
17+
const len = Math.min(a_components.length, b_components.length);
18+
for (let i = 0; i < len; i++) {
19+
const first = parseInt(a_components[i], 10);
20+
const second = parseInt(b_components[i], 10);
21+
if (first > second) { return true; }
22+
if (first < second) { return false; }
23+
}
24+
if (a_components.length > b_components.length) { return true; }
25+
if (a_components.length < b_components.length) { return false; }
26+
return true;
27+
}
28+
729
function minVersion(command: string, minVersion: string): Promise<boolean> {
830
return new Promise((resolve, reject) => {
931
let minOrLater: Promise<boolean> = commandLine(command, '-v')
10-
.then((res: string) => {
11-
// not installed
12-
if (parseInt(res, 10).toString() === 'NaN') {
13-
return false;
14-
}
15-
// two digits, ex: 0.10
16-
const mins = matchVersions(minVersion);
17-
if (!!mins) {
18-
const resMins = matchVersions(res);
19-
const firstDigit = parseInt(resMins[1], 10);
20-
const firstVersion = parseInt(mins[1], 10);
21-
return firstDigit > firstVersion ||
22-
firstDigit === firstVersion && parseInt(resMins[2], 10) >= parseInt(firstVersion[2], 10);
23-
} else {
24-
// single digit, ex: 3.0
25-
return parseInt(res, 10) >= parseInt(minVersion, 10);
26-
}
27-
});
32+
.then((res: string) => isAboveVersion(res, minVersion));
2833
if (!minOrLater) {
29-
resolve(false);
34+
resolve (false);
3035
} else {
3136
resolve(true);
3237
}
3338
});
3439
}
3540

41+
export function atomMinVersion(): Promise<boolean> {
42+
return new Promise((resolve, reject) => {
43+
let minOrLater = commandLine('atom', '-v').then((res: string) => {
44+
let match = res.match(/Atom\s+:\s+([0-9]\.[0-9]\.[0-9])/);
45+
if (match && match[1] && isAboveVersion(match[1], versions.atom)) {
46+
resolve(true);
47+
} else {
48+
resolve(false);
49+
}
50+
});
51+
});
52+
}
53+
3654
export function npmMinVersion(): Promise<boolean> {
37-
return minVersion('npm', '3');
55+
return minVersion('npm', versions.npm);
3856
}
3957

4058
export function nodeMinVersion(): Promise<boolean> {
41-
return minVersion('node', '0.10');
59+
return minVersion('node', versions.node);
4260
}
4361

4462
export function requiresXCode(): Promise<boolean> | boolean {

src/modules/setup/utils/verify.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {nodeMinVersion, npmMinVersion, requiresXCode} from './check-system';
1+
import {atomMinVersion, nodeMinVersion, npmMinVersion, requiresXCode} from './check-system';
22
import {tutorials} from 'coderoad-cli';
33

44
function allTrue(obj: Object): boolean {
@@ -24,6 +24,7 @@ export default function setupVerify(
2424
node: !!nodeMinVersion(),
2525
npm: !!npmMinVersion(),
2626
xcode: !!requiresXCode(),
27+
atom: !!atomMinVersion(),
2728
},
2829
setup: {
2930
hasDir,

0 commit comments

Comments
 (0)