diff --git a/bin/init.js b/bin/init.js index 32fb391..142a1e6 100644 --- a/bin/init.js +++ b/bin/init.js @@ -21,6 +21,15 @@ const renamePackage = (projectPath, projectName, verbose) => { } }; +const initGitRepository = (projectPath, verbose) => { + if (verbose) { + logger.info('Initializing git repository...'); + } + process.chdir(projectPath); + execSync('git init'); + logger.info('Git repository was initialized'); +}; + const installPackages = (projectPath, verbose) => { if (verbose) { logger.info('Installing packages...'); @@ -31,6 +40,7 @@ const installPackages = (projectPath, verbose) => { }; const init = (projectName, verbose = false, directory = '.') => { + const currentPath = process.cwd(); logger.info(`Initializing a new project: ${projectName}`); const emitter = degit(`${AUTHOR}/${REPOSITORY}/${TEMPLATE_DIR}`, { @@ -54,8 +64,52 @@ const init = (projectName, verbose = false, directory = '.') => { } renamePackage(projectPath, projectName, verbose); logger.success('Temaplate was successfully cloned!'); + initGitRepository(projectPath, verbose); installPackages(projectPath, verbose); logger.success('šŸŽ‰ Project was successfully initialized!'); + logger.info('āŒ› Wait until process finishes...'); + + logger.info('\n\nšŸ’” A few tips:'); + logger.info( + '1. Put your library code in src/ directory. It contains example code that can be removed.' + ); + logger.info( + '2. Add usage examples to the example/app/src/ directory. You can also use this example app while developing your library.' + ); + logger.info( + '3. Develop your library with react-native CLI (bare example app) or Expo Go (expo example app).' + ); + logger.info( + "4. Don't modify example/bare/ and example/expo/ directories if you don't have to. These apps use shared configuration from the top-level babel config and shared code from the example/app/ directory." + ); + + logger.info('\n\nšŸ’» Useful commands:'); + logger.info('1. Bare example app:'); + logger.info(' - yarn example:bare:pod - install pods for iOS'); + logger.info(' - yarn example:bare:start - start the Metro bundler'); + logger.info(' - yarn example:bare:android - run the Android app'); + logger.info(' - yarn example:bare:ios - run the iOS app'); + + logger.info('\n2. Expo example app:'); + logger.info(' - yarn example:expo:start - start the Expo Go app'); + logger.info(' - yarn example:expo:android - run the Android app'); + logger.info(' - yarn example:expo:ios - run the iOS app'); + + logger.info('\n3. Code quality:'); + logger.info(' - yarn lint - check code quality'); + logger.info(' - yarn lint:fix - fix code quality issues'); + logger.info(' - yarn test - run tests'); + logger.info(' - yarn typecheck - check types'); + + logger.info('\n4. Publish:'); + logger.info( + 'To publish your library, use the Release Github Action. It will publish your library, automatically detect the version, and create a release on Github.' + ); + + const relativePath = path.relative(currentPath, projectPath); + logger.success( + `\nšŸš€ cd to the '${relativePath}' directory and start coding!` + ); }); };