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) {
4040 search_1 . default ( query ) ;
4141}
4242else 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+ }
4454}
4555else if ( program . publish ) {
4656 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 11"use strict" ;
22var fs = require ( 'fs' ) ;
33var chalk_1 = require ( 'chalk' ) ;
4- var file_1 = require ( '../tools/ file' ) ;
4+ var node_file_exists_1 = require ( 'node- file-exists ' ) ;
55function incrementVersion ( version ) {
66 var finalDot = version . lastIndexOf ( '.' ) ;
77 var start = version . substring ( 0 , finalDot + 1 ) ;
88 var patch = parseInt ( version . substring ( finalDot + 1 , version . length ) , 10 ) + 1 ;
99 return start + patch ;
1010}
1111function versionIsGreaterThanCurrent ( version ) {
12- if ( ! file_1 . fileExists ( 'package.json' ) ) {
12+ if ( ! node_file_exists_1 . default ( 'package.json' ) ) {
1313 console . log ( chalk_1 . yellow ( "\n No available package.json file.Create one.\n > npm init\n " ) ) ;
1414 process . exit ( 1 ) ;
1515 }
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ var fs_1 = require('fs');
44var node_file_exists_1 = require ( 'node-file-exists' ) ;
55var is_tutorial_1 = require ( './is-tutorial' ) ;
66var update_1 = require ( './update' ) ;
7- function searchForTutorials ( dir , deps ) {
7+ function findTutorials ( dir , deps ) {
88 if ( ! ! deps && Object . keys ( deps ) . length > 0 ) {
99 return ( Object . keys ( deps )
1010 . filter ( function ( name ) { return is_tutorial_1 . isTutorial ( dir , name ) ; } )
@@ -30,4 +30,5 @@ function searchForTutorials(dir, deps) {
3030 return [ ] ;
3131 }
3232}
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 11"use strict" ;
22var chalk_1 = require ( 'chalk' ) ;
3+ var find_tutorials_1 = require ( './find-tutorials' ) ;
4+ var get_1 = require ( '../packageJson/get' ) ;
35function 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 ) ) ) ;
614}
715Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
816exports . default = tutorials ;
Original file line number Diff line number Diff line change @@ -5,9 +5,7 @@ function tutorialUpdate(name) {
55}
66exports . tutorialUpdate = tutorialUpdate ;
77function canUpdateTutorial ( name , currentVersion ) {
8- if ( ! navigator . onLine ) {
9- return null ;
10- }
8+ return null ;
119 return ( atom_plugin_command_line_1 . default ( 'npm' , "outdated " + name ) . then ( function ( res ) {
1210 console . log ( res ) ;
1311 if ( res . length > 0 ) {
Original file line number Diff line number Diff line change @@ -30,13 +30,15 @@ if (program.build) {
3030 const tutorial = program . args [ 0 ] || 'tutorial/tutorial.md' ;
3131 const output = 'coderoad.json' ;
3232 process . stdout . write ( grey ( `building coderoad.json for ${ tutorial } ...` ) ) ;
33+ // run build
3334 if ( ! build ( tutorial , output ) ) {
3435 fail ( ) ;
3536 }
3637
3738} else if ( program . create ) {
3839 const packageName = program . args [ 0 ] ;
3940 process . stdout . write ( `Creating demo tutorial "coderoad-${ packageName } "...` ) ;
41+ // run create
4042 if ( ! create ( packageName ) ) {
4143 fail ( ) ;
4244 }
@@ -46,7 +48,17 @@ if (program.build) {
4648 search ( query ) ;
4749
4850} 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+ }
5062
5163} else if ( program . publish ) {
5264 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 11import * as fs from 'fs' ;
22import { yellow } from 'chalk' ;
3- import { fileExists } from '../tools/file' ;
4-
3+ import fileExists from 'node-file-exists' ;
54
65function incrementVersion ( version : string ) : string {
76 let finalDot = version . lastIndexOf ( '.' ) ;
Original file line number Diff line number Diff line change @@ -4,7 +4,9 @@ import fileExists from 'node-file-exists';
44import { isTutorial , tutorialError } from './is-tutorial' ;
55import { canUpdateTutorial } from './update' ;
66
7- export function searchForTutorials ( dir : string , deps : Object ) : Tutorial . Info [ ] {
7+ export default function findTutorials (
8+ dir : string , deps : Object
9+ ) : Tutorial . Info [ ] {
810 if ( ! ! deps && Object . keys ( deps ) . length > 0 ) {
911 return ( Object . keys ( deps )
1012 . filter ( ( name : string ) => isTutorial ( dir , name ) )
You can’t perform that action at this time.
0 commit comments