Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add useful tips and automatic git repo initialization #55

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions bin/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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...');
Expand All @@ -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}`, {
Expand All @@ -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!`
);
});
};

Expand Down
Loading