11/**
22 * configures a package created from the template.
33 */
4- const cp = require ( ' child_process') ;
5- const fs = require ( ' fs') ;
6- const https = require ( ' https') ;
7- const path = require ( ' path') ;
8- const readline = require ( ' readline') ;
9- const util = require ( ' util') ;
4+ import cp from 'node: child_process';
5+ import fs from 'node: fs';
6+ import https from 'node: https';
7+ import path from 'node: path';
8+ import readline from 'node: readline';
9+ import util from 'node: util';
1010
1111const rl = readline . createInterface ( {
1212 input : process . stdin ,
@@ -55,12 +55,15 @@ class Stdout {
5555const stdout = new Stdout ( ) ;
5656
5757const runCommand = str => cp . execSync ( str , { cwd : __dirname , encoding : 'utf-8' , stdio : 'inherit' } ) ;
58- const gitCommand = command => cp . execSync ( `git ${ command } ` , { env : process . env , cwd : __dirname , encoding : 'utf-8' , stdio : 'pipe' } ) || '' ;
58+ const gitCommand = command => cp . execSync ( `git ${ command } ` , {
59+ env : process . env , cwd : __dirname , encoding : 'utf-8' , stdio : 'pipe'
60+ } ) || '' ;
5961const safeUnlink = path => fs . existsSync ( path ) && fs . unlinkSync ( path ) ;
6062const getWorkflowFilename = name => `${ __dirname } /.github/workflows/${ name } .yml` ;
6163const getGithubConfigFilename = name => `${ __dirname } /.github/${ name } .yml` ;
6264const writeFormattedJson = ( filename , data ) => fs . writeFileSync ( filename , JSON . stringify ( data , null , 4 ) , { encoding : 'utf-8' } ) ;
63- const isAnswerYes = answer => answer . toLowerCase ( ) . trim ( ) . startsWith ( 'y' ) ;
65+ const isAnswerYes = answer => answer . toLowerCase ( ) . trim ( )
66+ . startsWith ( 'y' ) ;
6467
6568/**
6669 * determine if a path is a directory.
@@ -217,12 +220,15 @@ async function getGithubApiEndpoint(endpoint) {
217220}
218221
219222function getGithubUsernameFromGitRemote ( ) {
220- const remoteUrlParts = gitCommand ( 'config remote.origin.url' ) . trim ( ) . replace ( ':' , '/' ) . split ( '/' ) ;
223+ const remoteUrlParts = gitCommand ( 'config remote.origin.url' ) . trim ( )
224+ . replace ( ':' , '/' )
225+ . split ( '/' ) ;
221226 return remoteUrlParts [ 1 ] ;
222227}
223228
224229function searchCommitsForGithubUsername ( ) {
225- const authorName = gitCommand ( `config user.name` ) . trim ( ) . toLowerCase ( ) ;
230+ const authorName = gitCommand ( `config user.name` ) . trim ( )
231+ . toLowerCase ( ) ;
226232
227233 const committers = gitCommand ( `log --author='@users.noreply.github.com' --pretty='%an:%ae' --reverse` )
228234 . split ( '\n' )
@@ -427,7 +433,9 @@ const processFiles = directory => {
427433} ;
428434
429435const populatePackageInfo = async ( onlyEmpty = false ) => {
430- const remoteUrlParts = gitCommand ( 'config remote.origin.url' ) . trim ( ) . replace ( ':' , '/' ) . split ( '/' ) ;
436+ const remoteUrlParts = gitCommand ( 'config remote.origin.url' ) . trim ( )
437+ . replace ( ':' , '/' )
438+ . split ( '/' ) ;
431439
432440 console . log ( ) ;
433441
@@ -512,9 +520,7 @@ class Features {
512520 const testsWorkflowFn = getWorkflowFilename ( 'run-tests' ) ;
513521 const contents = fs . readFileSync ( testsWorkflowFn , { encoding : 'utf-8' } ) ;
514522
515- fs . writeFileSync ( testsWorkflowFn , contents . replace ( 'USE_CODECOV_SERVICE: yes' , 'USE_CODECOV_SERVICE: no' ) , {
516- encoding : 'utf-8' ,
517- } ) ;
523+ fs . writeFileSync ( testsWorkflowFn , contents . replace ( 'USE_CODECOV_SERVICE: yes' , 'USE_CODECOV_SERVICE: no' ) , { encoding : 'utf-8' , } ) ;
518524 safeUnlink ( getGithubConfigFilename ( 'codecov' ) ) ;
519525 } ,
520526 } ;
@@ -548,7 +554,7 @@ class Features {
548554 prompt : 'Automerge Dependabot PRs?' ,
549555 enabled : true ,
550556 default : true ,
551- dependsOn : [ 'dependabot' ] ,
557+ dependsOn : [ 'dependabot' ] ,
552558 disable : ( ) => {
553559 safeUnlink ( getWorkflowFilename ( 'dependabot-auto-merge' ) ) ;
554560 } ,
@@ -600,7 +606,8 @@ class Features {
600606 safeUnlink ( `${ __dirname } /jest.config.js` ) ;
601607
602608 const pkg = new PackageFile ( ) ;
603- pkg . deleteScripts ( 'test:coverage' ) . replaceScript ( 'test' , 'echo "no tests defined" && exit 0' ) . save ( ) ;
609+ pkg . deleteScripts ( 'test:coverage' ) . replaceScript ( 'test' , 'echo "no tests defined" && exit 0' )
610+ . save ( ) ;
604611
605612 // remove tsconfig jest types reference
606613 let tsConfigContent = fs . readFileSync ( `${ __dirname } /tsconfig.json` ) . toString ( ) ;
@@ -780,7 +787,7 @@ class OptionalPackages {
780787 dependsOn : [ ] ,
781788 name : 'dotenv' ,
782789 add : ( ) => {
783- runCommand ( 'npm' , [ 'install' , 'dotenv' ] , { cwd : __dirname , stdio : 'inherit' } ) ;
790+ runCommand ( 'npm' , [ 'install' , 'dotenv' ] , { cwd : __dirname , stdio : 'inherit' } ) ;
784791
785792 fs . mkdirSync ( `${ __dirname } /dist` , { recursive : true } ) ;
786793 fs . writeFileSync ( `${ __dirname } /dist/.env` , 'TEST_VALUE=1\n' , { encoding : 'utf-8' } ) ;
@@ -805,7 +812,7 @@ class OptionalPackages {
805812 } ,
806813 } ;
807814
808- optionalPackages = [ this . config , this . dotenv ] ;
815+ optionalPackages = [ this . config , this . dotenv ] ;
809816
810817 async run ( ) {
811818 for ( let pkg of this . optionalPackages ) {
@@ -849,7 +856,7 @@ class FeaturePacks {
849856 runCommand ( `npm install ${ feature . packages . devDependencies . join ( ' ' ) } -D` , { cwd : __dirname , stdio : 'inherit' } ) ;
850857 }
851858
852- copyDirectory ( feature . path , __dirname , [ feature . featureScript ] ) ;
859+ copyDirectory ( feature . path , __dirname , [ feature . featureScript ] ) ;
853860
854861 stdout . writeln ( green ( '✓' ) + ` Added feature: ${ feature . info . name } ` ) ;
855862 }
0 commit comments