Skip to content

Commit e3d0a4c

Browse files
committed
init check for outdated tutorials
1 parent 2eb838d commit e3d0a4c

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

src/services/setup/system-checks.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ export function npmVersionThreeOrLater(): Promise<CR.SetupWarning> {
88
reject({
99
key: 'updateNpm',
1010
title: 'Please update to NPM version 3+',
11-
click: null,
1211
text: 'Open a terminal and run:\n `npm install npm -g`',
13-
button: 'Update NPM',
1412
verify: 'NPM updated to version 3 or later'
1513
});
1614
} else {

src/services/setup/tutorials.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {store} from '../../_base';
22
import * as path from 'path';
33
import * as fs from 'fs';
44
import {fileExists} from '../exists';
5+
import {canUpdateTutorial} from './update-tutorial';
56

67
let tutorialError = 'This is an error with the tutorial itself';
78

@@ -41,11 +42,15 @@ function _isTutorial(name: string): boolean {
4142
console.log(`Error with ${name}: no test runner specified. ${tutorialError}`);
4243
return false;
4344
}
44-
let pathToTestRunner = path.join(window.coderoad.dir, 'node_modules', packageJson.config.testRunner);
45-
// if (!fileExists(pathToTestRunner)) {
46-
// console.log(`Error with ${name}: ${packageJson.config.testRunner} test runner not installed`);
47-
// return false;
48-
// }
45+
46+
let currentTutorialVersion: string = packageJson.dependencies[name] || packageJson.devDependencies[name];
47+
canUpdateTutorial(name, currentTutorialVersion);
48+
49+
// let pathToTestRunner = path.join(window.coderoad.dir, 'node_modules', packageJson.config.testRunner);
50+
// // if (!fileExists(pathToTestRunner)) {
51+
// // console.log(`Error with ${name}: ${packageJson.config.testRunner} test runner not installed`);
52+
// // return false;
53+
// // }
4954
return true;
5055
}
5156

src/services/setup/update-tutorial.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import commandLine from '../command-line';
2+
3+
export function canUpdateTutorial(name: string, currentVersion: string) {
4+
let latestVersion = commandLine('npm', `outdated ${name}`);
5+
console.log(latestVersion, currentVersion);
6+
}

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
"src/services/setup/setup.ts",
9595
"src/services/setup/system-checks.ts",
9696
"src/services/setup/tutorials.ts",
97+
"src/services/setup/update-tutorial.ts",
9798
"src/services/write.ts",
9899
"src/store/initialState.ts",
99100
"src/store/store.ts",

0 commit comments

Comments
 (0)