@@ -2,7 +2,6 @@ import { execSync } from 'child_process';
22import * as fs from 'fs' ;
33import * as path from 'path' ;
44
5- const PLUGIN_DIR_NAME = 'nx-infra-plugin' ;
65const DIST_DIR_NAME = 'dist' ;
76const SRC_DIR_NAME = 'src' ;
87const TEMP_TSCONFIG_NAME = 'tsconfig.bootstrap.json' ;
@@ -35,12 +34,12 @@ interface AssetCopyResult {
3534}
3635
3736const buildPathConfig = ( rootDir : string ) : PathConfig => {
38- const pluginDir = path . join ( rootDir , '../../packages' , PLUGIN_DIR_NAME ) ;
37+ const pluginDir = path . join ( rootDir , '..' ) ;
3938 return {
4039 pluginDir,
4140 distDir : path . join ( pluginDir , DIST_DIR_NAME ) ,
4241 srcDir : path . join ( pluginDir , SRC_DIR_NAME ) ,
43- tsconfig : path . join ( pluginDir , TSCONFIG_LIB_NAME )
42+ tsconfig : path . join ( pluginDir , TSCONFIG_LIB_NAME ) ,
4443 } ;
4544} ;
4645
@@ -60,8 +59,8 @@ const createBootstrapConfig = (original: TsConfig): TsConfig => ({
6059 compilerOptions : {
6160 ...original . compilerOptions ,
6261 rootDir : undefined ,
63- outDir : `./${ DIST_DIR_NAME } `
64- }
62+ outDir : `./${ DIST_DIR_NAME } ` ,
63+ } ,
6564} ) ;
6665
6766const writeTsConfig = ( configPath : string , config : TsConfig ) : void => {
@@ -70,19 +69,16 @@ const writeTsConfig = (configPath: string, config: TsConfig): void => {
7069
7170const compileTypeScript = ( pluginDir : string , configPath : string ) : CompilationResult => {
7271 try {
73- execSync (
74- `npx tsc -p ${ configPath } ` ,
75- {
76- cwd : pluginDir ,
77- stdio : 'inherit' ,
78- env : { ...process . env , NODE_ENV : 'production' }
79- }
80- ) ;
72+ execSync ( `npx tsc -p ${ configPath } ` , {
73+ cwd : pluginDir ,
74+ stdio : 'inherit' ,
75+ env : { ...process . env , NODE_ENV : 'production' } ,
76+ } ) ;
8177 return { success : true } ;
8278 } catch ( error ) {
8379 return {
8480 success : false ,
85- error : ( error as Error ) . message
81+ error : ( error as Error ) . message ,
8682 } ;
8783 }
8884} ;
@@ -120,14 +116,17 @@ const copyJsonAssets = (srcDir: string, destDir: string): AssetCopyResult => {
120116const updateExecutorPaths = ( config : Record < string , unknown > ) : Record < string , unknown > => {
121117 const executors = config . executors as Record < string , { implementation : string ; schema : string } > ;
122118
123- const updated = Object . entries ( executors ) . reduce ( ( acc , [ key , value ] ) => {
124- acc [ key ] = {
125- ...value ,
126- implementation : value . implementation . replace ( './src/' , './' ) ,
127- schema : value . schema . replace ( './src/' , './' )
128- } ;
129- return acc ;
130- } , { } as Record < string , { implementation : string ; schema : string } > ) ;
119+ const updated = Object . entries ( executors ) . reduce (
120+ ( acc , [ key , value ] ) => {
121+ acc [ key ] = {
122+ ...value ,
123+ implementation : value . implementation . replace ( './src/' , './' ) ,
124+ schema : value . schema . replace ( './src/' , './' ) ,
125+ } ;
126+ return acc ;
127+ } ,
128+ { } as Record < string , { implementation : string ; schema : string } > ,
129+ ) ;
131130
132131 return { ...config , executors : updated } ;
133132} ;
@@ -190,7 +189,7 @@ const buildPlugin = (paths: PathConfig, forceRebuild = false): void => {
190189const parseArgs = ( ) : { forceRebuild : boolean } => {
191190 const args = process . argv . slice ( 2 ) ;
192191 return {
193- forceRebuild : args . includes ( '--force' ) || args . includes ( '-f' )
192+ forceRebuild : args . includes ( '--force' ) || args . includes ( '-f' ) ,
194193 } ;
195194} ;
196195
0 commit comments