@@ -9,13 +9,17 @@ import {
9
9
multiselect ,
10
10
outro ,
11
11
select ,
12
- spinner ,
13
12
text ,
14
13
} from '@clack/prompts' ;
15
- import { getPackageManagerCommand , readJsonFile , workspaceRoot } from '@nx/devkit' ;
14
+ import {
15
+ getPackageManagerCommand ,
16
+ readJsonFile ,
17
+ workspaceRoot ,
18
+ writeJsonFile ,
19
+ } from '@nx/devkit' ;
16
20
17
21
import { execSync } from 'child_process' ;
18
- import { existsSync } from 'fs' ;
22
+ import { existsSync , readFileSync , writeFileSync } from 'fs' ;
19
23
import { bold , cyan , green , red } from 'kleur/colors' ;
20
24
import yargs , { type CommandModule } from 'yargs' ;
21
25
import {
@@ -188,6 +192,7 @@ async function handleInit() {
188
192
}
189
193
190
194
// ADD QWIK UI CLI TO DEPENDENCIES
195
+ log . info ( 'Adding qwik-ui cli to package.json...' ) ;
191
196
execSync ( `${ getPackageManagerCommand ( ) . addDev } qwik-ui@latest` , {
192
197
stdio : 'inherit' ,
193
198
} ) ;
@@ -209,6 +214,7 @@ async function handleInit() {
209
214
210
215
const packageTag = args [ 'e2e' ] ? 'e2e' : 'latest' ;
211
216
217
+ log . info ( `Installing ${ styledPackage } ...` ) ;
212
218
execSync ( `${ getPackageManagerCommand ( ) . addDev } ${ styledPackage } @${ packageTag } ` , {
213
219
stdio : 'inherit' ,
214
220
} ) ;
@@ -225,38 +231,35 @@ async function handleInit() {
225
231
} ,
226
232
) ;
227
233
228
- await handleAdd ( config . projectRoot , args [ 'components' ] as string ) ;
234
+ log . info ( 'Tailwind configured.' ) ;
229
235
}
230
236
231
237
async function installNxIfNeeded ( ) {
232
- // eslint-disable-next-line @typescript-eslint/no-var-requires
233
- // const nxVersion = require('../package.json').dependencies['@nx/devkit'];
234
-
235
238
if ( existsSync ( 'nx.json' ) ) {
236
239
log . info ( 'seems like nx.json already exists. cool!' ) ;
237
240
} else {
238
- // const haveNxInstalled = cancelable(
239
- // await confirm({
240
- // message: 'Do you already have Nx installed? (required)',
241
- // initialValue: false,
242
- // }),
243
- // );
244
-
245
- // if (!haveNxInstalled) {
246
- const initSpinner = spinner ( ) ;
247
241
log . info ( 'Installing Nx...' ) ;
248
- initSpinner . start ( 'Installing Nx...' ) ;
242
+
249
243
execSync ( `${ getPackageManagerCommand ( ) . addDev } nx@latest` , {
250
244
stdio : 'inherit' ,
251
245
} ) ;
252
- // TODO: Just add "nx: {} " to package.json and see if it still works
253
- execSync ( `${ getPackageManagerCommand ( ) . exec } nx init --interactive false` , {
254
- stdio : 'inherit' ,
255
- } ) ;
256
- initSpinner . stop ( 'Installed Nx!' ) ;
246
+
247
+ const packageJson = await readJsonFile ( 'package.json' ) ;
248
+ packageJson [ 'nx' ] = { } ;
249
+ await writeJsonFile ( 'package.json' , packageJson ) ;
250
+
251
+ const ignorePath = '.gitignore' ;
252
+ try {
253
+ let contents = readFileSync ( ignorePath , 'utf-8' ) ;
254
+ if ( ! contents . includes ( '.nx/cache' ) ) {
255
+ contents = [ contents , '' , '.nx/cache' ] . join ( '\n' ) ;
256
+ writeFileSync ( ignorePath , contents , 'utf-8' ) ;
257
+ }
258
+ } catch {
259
+ /* empty */
260
+ }
257
261
}
258
262
log . success ( 'nx init done' ) ;
259
- // }
260
263
}
261
264
262
265
async function handleAdd ( projectRoot ?: string , componentsFromInit ?: string ) {
0 commit comments