@@ -37,6 +37,7 @@ import {
37
37
QWIK_UI_CONFIG_FILENAME ,
38
38
} from '../src/_shared/config-filenames' ;
39
39
40
+ import path from 'path' ;
40
41
import externalDeps from '../src/_shared/external-deps.json' ;
41
42
42
43
const COMMANDS = [ 'init' , 'add' ] ;
@@ -144,8 +145,8 @@ async function handleInit() {
144
145
if ( ! config . projectRoot ) {
145
146
config . projectRoot = cancelable (
146
147
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 : '. /' ,
149
150
} ) ,
150
151
) ;
151
152
}
@@ -162,9 +163,10 @@ async function handleInit() {
162
163
if ( ! config . rootCssPath ) {
163
164
config . rootCssPath = await collectFileLocationFromUser ( {
164
165
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 )' ,
166
167
) ,
167
168
errorMessageName : 'Global css file' ,
169
+ rootDir : config . projectRoot ,
168
170
initialValue : 'src/global.css' ,
169
171
} ) ;
170
172
}
@@ -181,12 +183,12 @@ async function handleInit() {
181
183
) ;
182
184
}
183
185
184
- // TODO: Add "cwd" with the project root, and see if we can skip the interactive question from qwik cli
185
186
if ( installTailwind ) {
186
187
execSync (
187
- `${ getPackageManagerCommand ( ) . exec } qwik add tailwind --skipConfirmation=true` ,
188
+ `${ getPackageManagerCommand ( ) . exec } qwik add tailwind --skipConfirmation=true --projectDir= ${ config . projectRoot } ` ,
188
189
{
189
190
stdio : 'inherit' ,
191
+ cwd : config . projectRoot ,
190
192
} ,
191
193
) ;
192
194
}
@@ -430,9 +432,9 @@ Options: [${possibleComponentNames.join(', ')}]`,
430
432
coerce : ( components ) => componentTypesFromString ( components ) ,
431
433
} )
432
434
. option ( 'projectRoot' , {
433
- description : 'The root of the project (default: "/")' ,
435
+ description : 'The root of the project (default: ". /")' ,
434
436
type : 'string' ,
435
- default : '/' ,
437
+ default : '. /' ,
436
438
} ) ,
437
439
handler : ( ) = > { } ,
438
440
} ;
@@ -448,8 +450,8 @@ Options: [${possibleComponentNames.join(', ')}]`,
448
450
if ( ! projectRoot && ! args [ 'projectRoot' ] ) {
449
451
projectRoot = cancelable (
450
452
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 : '. /' ,
453
455
} ) ,
454
456
) ;
455
457
}
@@ -507,6 +509,7 @@ function parseCommands(command: CommandModule) {
507
509
interface FilePromptInfo {
508
510
message : string ;
509
511
errorMessageName : string ;
512
+ rootDir : string ;
510
513
initialValue ?: string ;
511
514
}
512
515
@@ -517,9 +520,9 @@ async function collectFileLocationFromUser(config: FilePromptInfo) {
517
520
initialValue : config . initialValue ,
518
521
} ) ,
519
522
) ;
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?` ) ;
523
526
return collectFileLocationFromUser ( { ...config , initialValue : filePath } ) ;
524
527
}
525
528
return filePath ;
0 commit comments