@@ -9,13 +9,17 @@ import {
99 multiselect ,
1010 outro ,
1111 select ,
12- spinner ,
1312 text ,
1413} 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' ;
1620
1721import { execSync } from 'child_process' ;
18- import { existsSync } from 'fs' ;
22+ import { existsSync , readFileSync , writeFileSync } from 'fs' ;
1923import { bold , cyan , green , red } from 'kleur/colors' ;
2024import yargs , { type CommandModule } from 'yargs' ;
2125import {
@@ -188,6 +192,7 @@ async function handleInit() {
188192 }
189193
190194 // ADD QWIK UI CLI TO DEPENDENCIES
195+ log . info ( 'Adding qwik-ui cli to package.json...' ) ;
191196 execSync ( `${ getPackageManagerCommand ( ) . addDev } qwik-ui@latest` , {
192197 stdio : 'inherit' ,
193198 } ) ;
@@ -209,6 +214,7 @@ async function handleInit() {
209214
210215 const packageTag = args [ 'e2e' ] ? 'e2e' : 'latest' ;
211216
217+ log . info ( `Installing ${ styledPackage } ...` ) ;
212218 execSync ( `${ getPackageManagerCommand ( ) . addDev } ${ styledPackage } @${ packageTag } ` , {
213219 stdio : 'inherit' ,
214220 } ) ;
@@ -225,38 +231,35 @@ async function handleInit() {
225231 } ,
226232 ) ;
227233
228- await handleAdd ( config . projectRoot , args [ 'components' ] as string ) ;
234+ log . info ( 'Tailwind configured.' ) ;
229235}
230236
231237async function installNxIfNeeded ( ) {
232- // eslint-disable-next-line @typescript-eslint/no-var-requires
233- // const nxVersion = require('../package.json').dependencies['@nx/devkit'];
234-
235238 if ( existsSync ( 'nx.json' ) ) {
236239 log . info ( 'seems like nx.json already exists. cool!' ) ;
237240 } 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 ( ) ;
247241 log . info ( 'Installing Nx...' ) ;
248- initSpinner . start ( 'Installing Nx...' ) ;
242+
249243 execSync ( `${ getPackageManagerCommand ( ) . addDev } nx@latest` , {
250244 stdio : 'inherit' ,
251245 } ) ;
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+ }
257261 }
258262 log . success ( 'nx init done' ) ;
259- // }
260263}
261264
262265async function handleAdd ( projectRoot ?: string , componentsFromInit ?: string ) {
0 commit comments