File tree Expand file tree Collapse file tree 13 files changed +88
-22
lines changed Expand file tree Collapse file tree 13 files changed +88
-22
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,17 @@ else if (program.search) {
40
40
search_1 . default ( query ) ;
41
41
}
42
42
else if ( program . tutorials ) {
43
- tutorials_1 . default ( ) ;
43
+ process . stdout . write ( "List of tutorial packages in this directory..." ) ;
44
+ var tuts = tutorials_1 . default ( ) ;
45
+ if ( ! tuts ) {
46
+ result_1 . fail ( ) ;
47
+ }
48
+ else {
49
+ process . stdout . write ( '\n\n' ) ;
50
+ tuts . forEach ( function ( tut ) {
51
+ process . stdout . write ( " " + tut . name + " : " + tut . version + "\n" ) ;
52
+ } ) ;
53
+ }
44
54
}
45
55
else if ( program . publish ) {
46
56
var version = program . args [ 0 ] ;
Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+ var node_file_exists_1 = require ( 'node-file-exists' ) ;
3
+ var fs_1 = require ( 'fs' ) ;
4
+ function getPackageJson ( ) {
5
+ var pathToPJ = './package.json' ;
6
+ if ( ! node_file_exists_1 . default ( pathToPJ ) ) {
7
+ return null ;
8
+ }
9
+ var pj = fs_1 . readFileSync ( pathToPJ , 'utf8' ) ;
10
+ return JSON . parse ( pj ) ;
11
+ }
12
+ Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
13
+ exports . default = getPackageJson ;
Original file line number Diff line number Diff line change 1
1
"use strict" ;
2
2
var fs = require ( 'fs' ) ;
3
3
var chalk_1 = require ( 'chalk' ) ;
4
- var file_1 = require ( '../tools/ file' ) ;
4
+ var node_file_exists_1 = require ( 'node- file-exists ' ) ;
5
5
function incrementVersion ( version ) {
6
6
var finalDot = version . lastIndexOf ( '.' ) ;
7
7
var start = version . substring ( 0 , finalDot + 1 ) ;
8
8
var patch = parseInt ( version . substring ( finalDot + 1 , version . length ) , 10 ) + 1 ;
9
9
return start + patch ;
10
10
}
11
11
function versionIsGreaterThanCurrent ( version ) {
12
- if ( ! file_1 . fileExists ( 'package.json' ) ) {
12
+ if ( ! node_file_exists_1 . default ( 'package.json' ) ) {
13
13
console . log ( chalk_1 . yellow ( "\n No available package.json file.Create one.\n > npm init\n " ) ) ;
14
14
process . exit ( 1 ) ;
15
15
}
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ var fs_1 = require('fs');
4
4
var node_file_exists_1 = require ( 'node-file-exists' ) ;
5
5
var is_tutorial_1 = require ( './is-tutorial' ) ;
6
6
var update_1 = require ( './update' ) ;
7
- function searchForTutorials ( dir , deps ) {
7
+ function findTutorials ( dir , deps ) {
8
8
if ( ! ! deps && Object . keys ( deps ) . length > 0 ) {
9
9
return ( Object . keys ( deps )
10
10
. filter ( function ( name ) { return is_tutorial_1 . isTutorial ( dir , name ) ; } )
@@ -30,4 +30,5 @@ function searchForTutorials(dir, deps) {
30
30
return [ ] ;
31
31
}
32
32
}
33
- exports . searchForTutorials = searchForTutorials ;
33
+ Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
34
+ exports . default = findTutorials ;
Original file line number Diff line number Diff line change 1
1
"use strict" ;
2
2
var chalk_1 = require ( 'chalk' ) ;
3
+ var find_tutorials_1 = require ( './find-tutorials' ) ;
4
+ var get_1 = require ( '../packageJson/get' ) ;
3
5
function tutorials ( ) {
4
- console . log ( "List of tutorial packages in this directory...\n" ) ;
5
- console . log ( chalk_1 . yellow ( 'This feature is not yet implemented' ) ) ;
6
+ var pj = get_1 . default ( ) ;
7
+ if ( ! pj ) {
8
+ console . log ( chalk_1 . red ( "No package.json available" ) ) ;
9
+ return false ;
10
+ }
11
+ return ( [ ]
12
+ . concat ( find_tutorials_1 . default ( process . cwd ( ) , pj . dependencies ) )
13
+ . concat ( find_tutorials_1 . default ( process . cwd ( ) , pj . devDependencies ) ) ) ;
6
14
}
7
15
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
8
16
exports . default = tutorials ;
Original file line number Diff line number Diff line change @@ -5,9 +5,7 @@ function tutorialUpdate(name) {
5
5
}
6
6
exports . tutorialUpdate = tutorialUpdate ;
7
7
function canUpdateTutorial ( name , currentVersion ) {
8
- if ( ! navigator . onLine ) {
9
- return null ;
10
- }
8
+ return null ;
11
9
return ( atom_plugin_command_line_1 . default ( 'npm' , "outdated " + name ) . then ( function ( res ) {
12
10
console . log ( res ) ;
13
11
if ( res . length > 0 ) {
Original file line number Diff line number Diff line change @@ -30,13 +30,15 @@ if (program.build) {
30
30
const tutorial = program . args [ 0 ] || 'tutorial/tutorial.md' ;
31
31
const output = 'coderoad.json' ;
32
32
process . stdout . write ( grey ( `building coderoad.json for ${ tutorial } ...` ) ) ;
33
+ // run build
33
34
if ( ! build ( tutorial , output ) ) {
34
35
fail ( ) ;
35
36
}
36
37
37
38
} else if ( program . create ) {
38
39
const packageName = program . args [ 0 ] ;
39
40
process . stdout . write ( `Creating demo tutorial "coderoad-${ packageName } "...` ) ;
41
+ // run create
40
42
if ( ! create ( packageName ) ) {
41
43
fail ( ) ;
42
44
}
@@ -46,7 +48,17 @@ if (program.build) {
46
48
search ( query ) ;
47
49
48
50
} else if ( program . tutorials ) {
49
- tutorials ( ) ;
51
+ // run find tutorials
52
+ process . stdout . write ( `List of tutorial packages in this directory...` ) ;
53
+ const tuts = tutorials ( ) ;
54
+ if ( ! tuts ) {
55
+ fail ( ) ;
56
+ } else {
57
+ process . stdout . write ( '\n\n' )
58
+ tuts . forEach ( ( tut ) => {
59
+ process . stdout . write ( ` ${ tut . name } : ${ tut . version } \n` ) ;
60
+ } ) ;
61
+ }
50
62
51
63
} else if ( program . publish ) {
52
64
const version = program . args [ 0 ] ;
Original file line number Diff line number Diff line change
1
+ import fileExists from 'node-file-exists' ;
2
+ import { readFileSync } from 'fs' ;
3
+
4
+ export default function getPackageJson ( ) : PackageJson {
5
+ const pathToPJ = './package.json' ;
6
+ if ( ! fileExists ( pathToPJ ) ) { return null ; }
7
+ const pj = readFileSync ( pathToPJ , 'utf8' ) ;
8
+ return JSON . parse ( pj ) ;
9
+ }
Original file line number Diff line number Diff line change 1
1
import * as fs from 'fs' ;
2
2
import { yellow } from 'chalk' ;
3
- import { fileExists } from '../tools/file' ;
4
-
3
+ import fileExists from 'node-file-exists' ;
5
4
6
5
function incrementVersion ( version : string ) : string {
7
6
let finalDot = version . lastIndexOf ( '.' ) ;
Original file line number Diff line number Diff line change @@ -4,7 +4,9 @@ import fileExists from 'node-file-exists';
4
4
import { isTutorial , tutorialError } from './is-tutorial' ;
5
5
import { canUpdateTutorial } from './update' ;
6
6
7
- export function searchForTutorials ( dir : string , deps : Object ) : Tutorial . Info [ ] {
7
+ export default function findTutorials (
8
+ dir : string , deps : Object
9
+ ) : Tutorial . Info [ ] {
8
10
if ( ! ! deps && Object . keys ( deps ) . length > 0 ) {
9
11
return ( Object . keys ( deps )
10
12
. filter ( ( name : string ) => isTutorial ( dir , name ) )
Original file line number Diff line number Diff line change 1
- import { yellow } from 'chalk' ;
1
+ import { yellow , red } from 'chalk' ;
2
+ import findTutorials from './find-tutorials' ;
3
+ import getPackageJson from '../packageJson/get' ;
2
4
3
- export default function tutorials ( ) : void {
4
- console . log ( `List of tutorial packages in this directory...\n` ) ;
5
- console . log ( yellow ( 'This feature is not yet implemented' ) ) ;
6
- // getTutorials();
5
+ export default function tutorials ( ) : string [ ] | boolean {
6
+ // console.log(yellow('This feature is not yet implemented'));
7
+
8
+ const pj : PackageJson = getPackageJson ( ) ;
9
+
10
+ if ( ! pj ) {
11
+ console . log ( red ( `No package.json available` ) )
12
+ return false ;
13
+ }
14
+
15
+ return ( [ ]
16
+ . concat ( findTutorials ( process . cwd ( ) , pj . dependencies ) )
17
+ . concat ( findTutorials ( process . cwd ( ) , pj . devDependencies ) )
18
+ ) ;
7
19
}
Original file line number Diff line number Diff line change @@ -13,9 +13,10 @@ export function tutorialUpdate(name: string): void {
13
13
export function canUpdateTutorial (
14
14
name : string , currentVersion : string
15
15
) : Promise < boolean > {
16
- if ( ! navigator . onLine ) {
17
- return null ;
18
- }
16
+ return null ;
17
+ // if (global.hasOwnProperty('navigator') || !global.navigator.onLine) {
18
+ // return null;
19
+ // }
19
20
return ( commandLine (
20
21
'npm' , `outdated ${ name } `
21
22
) . then (
Original file line number Diff line number Diff line change 32
32
" src/create/validate.ts" ,
33
33
" src/create/write-demo.ts" ,
34
34
" src/list/list.ts" ,
35
+ " src/packageJson/get.ts" ,
35
36
" src/publish/index.ts" ,
36
37
" src/publish/validate.ts" ,
37
38
" src/search/index.ts" ,
You can’t perform that action at this time.
0 commit comments