// Copyright 2021, University of Colorado Boulder

/**
 * Command Line Interface (CLI) for TypeScript transpilation via babel.  Transpiles *.ts and copies all *.js files to
 * chipper/dist. Does not do type checking. Filters based on active-repos and subsets of directories within repos (such as js/, images/, and sounds/)
 *
 * Usage:
 * cd chipper
 * node js/scripts/transpile.js --watch
 *
 * OPTIONS:
 * --watch                continue watching all directories and transpile on detected changes
 * --clean                dispose of the cache that tracks file status on startup, can be combined with other commands
 *                        you would need to run --clean if the transpiled file status ever gets out of sync with the
 *                        cache file status, for example if you deleted/modified a transpiled file in chipper/dist
 * --skipInitial          skip the initial transpilation
 *
 * @author Sam Reid (PhET Interactive Simulations)
 */

// constants
const start = Date.now();
const args = process.argv.slice( 2 );

// imports
const Transpiler = require( '../common/Transpiler' );

const transpiler = new Transpiler( {
  clean: args.includes( '--clean' ),
  verbose: args.includes( '--verbose' )
} );

// Initial pass
if ( !args.includes( '--skipInitial' ) ) {
  transpiler.transpileAll();
  console.log( 'Finished initial transpilation in ' + ( Date.now() - start ) + 'ms' );
}

// Watch process
if ( args.includes( '--watch' ) ) {
  transpiler.watch();
  console.log( 'Watching...' );
}
@@ -181,16 +181,19 @@
 per/dist
+/js
 . Does n
@@ -282,16 +282,19 @@
 in repos
+%0A *
  (such a
@@ -430,17 +430,17 @@
         
-c
+C
 ontinue 
@@ -497,16 +497,17 @@
  changes
+.
 %0A * --cl
@@ -525,17 +525,17 @@
         
-d
+D
 ispose o
@@ -617,16 +617,17 @@
 commands
+.
 %0A *     
@@ -645,17 +645,17 @@
         
-y
+Y
 ou would
@@ -686,61 +686,69 @@
 the 
-transpiled file status ever gets out of sync with the
+files in chipper/dist/js or chipper/dist/js-cache-status.json
 %0A * 
@@ -774,25 +774,31 @@
     
-cache file status
+are modified externally
 , fo
@@ -864,16 +864,17 @@
 per/dist
+.
 %0A * --sk
@@ -892,17 +892,17 @@
         
-s
+S
 kip the 
@@ -922,16 +922,17 @@
 pilation
+.
 %0A *%0A * @

Improve documentation, see https://github.com/phetsims/chipper/issues/1156