@@ -37,6 +37,7 @@ import {
3737 QWIK_UI_CONFIG_FILENAME ,
3838} from '../src/_shared/config-filenames' ;
3939
40+ import path from 'path' ;
4041import externalDeps from '../src/_shared/external-deps.json' ;
4142
4243const COMMANDS = [ 'init' , 'add' ] ;
@@ -144,8 +145,8 @@ async function handleInit() {
144145 if ( ! config . projectRoot ) {
145146 config . projectRoot = cancelable (
146147 await text ( {
147- message : cyan ( 'Specify the root of the project (leave empty for "/")' ) ,
148- initialValue : '/' ,
148+ message : cyan ( 'Specify the root of the project (leave empty for ". /")' ) ,
149+ initialValue : '. /' ,
149150 } ) ,
150151 ) ;
151152 }
@@ -162,9 +163,10 @@ async function handleInit() {
162163 if ( ! config . rootCssPath ) {
163164 config . rootCssPath = await collectFileLocationFromUser ( {
164165 message : cyan (
165- 'Your global css file location (where you defined your tailwind directives )' ,
166+ 'The path to the global css file the tailwind directives are defined (relative to the root you specified above )' ,
166167 ) ,
167168 errorMessageName : 'Global css file' ,
169+ rootDir : config . projectRoot ,
168170 initialValue : 'src/global.css' ,
169171 } ) ;
170172 }
@@ -181,12 +183,12 @@ async function handleInit() {
181183 ) ;
182184 }
183185
184- // TODO: Add "cwd" with the project root, and see if we can skip the interactive question from qwik cli
185186 if ( installTailwind ) {
186187 execSync (
187- `${ getPackageManagerCommand ( ) . exec } qwik add tailwind --skipConfirmation=true` ,
188+ `${ getPackageManagerCommand ( ) . exec } qwik add tailwind --skipConfirmation=true --projectDir= ${ config . projectRoot } ` ,
188189 {
189190 stdio : 'inherit' ,
191+ cwd : config . projectRoot ,
190192 } ,
191193 ) ;
192194 }
@@ -430,9 +432,9 @@ Options: [${possibleComponentNames.join(', ')}]`,
430432 coerce : ( components ) => componentTypesFromString ( components ) ,
431433 } )
432434 . option ( 'projectRoot' , {
433- description : 'The root of the project (default: "/")' ,
435+ description : 'The root of the project (default: ". /")' ,
434436 type : 'string' ,
435- default : '/' ,
437+ default : '. /' ,
436438 } ) ,
437439 handler : ( ) = > { } ,
438440 } ;
@@ -448,8 +450,8 @@ Options: [${possibleComponentNames.join(', ')}]`,
448450 if ( ! projectRoot && ! args [ 'projectRoot' ] ) {
449451 projectRoot = cancelable (
450452 await text ( {
451- message : cyan ( 'Specify the root of the project (leave empty for "/")' ) ,
452- initialValue : '/' ,
453+ message : cyan ( 'Specify the root of the project (leave empty for ". /")' ) ,
454+ initialValue : '. /' ,
453455 } ) ,
454456 ) ;
455457 }
@@ -507,6 +509,7 @@ function parseCommands(command: CommandModule) {
507509interface FilePromptInfo {
508510 message : string ;
509511 errorMessageName : string ;
512+ rootDir : string ;
510513 initialValue ?: string ;
511514}
512515
@@ -517,9 +520,9 @@ async function collectFileLocationFromUser(config: FilePromptInfo) {
517520 initialValue : config . initialValue ,
518521 } ) ,
519522 ) ;
520-
521- if ( ! existsSync ( filePath ) ) {
522- log . error ( `${ config . errorMessageName } not found at ${ filePath } , want to try again?` ) ;
523+ const fullPath = path . join ( config . rootDir , filePath ) ;
524+ if ( ! existsSync ( fullPath ) ) {
525+ log . error ( `${ config . errorMessageName } not found at ${ fullPath } , want to try again?` ) ;
523526 return collectFileLocationFromUser ( { ...config , initialValue : filePath } ) ;
524527 }
525528 return filePath ;
0 commit comments