From 96537659c583d20aae44128af3e9388f1c392022 Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Wed, 19 Jun 2024 22:06:10 +0200 Subject: [PATCH] fix(init): print quick start instructions after init (#2095) --- scripts/init.mjs | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/scripts/init.mjs b/scripts/init.mjs index 352c70f5a..681e630e7 100755 --- a/scripts/init.mjs +++ b/scripts/init.mjs @@ -216,6 +216,47 @@ async function fetchTemplate(platforms) { return [version, path.join(output, "template")]; } +/** + * @param {import("./types.js").Platform} platform + * @returns {string} + */ +function instructionsFor(platform) { + switch (platform) { + case "android": + return [ + ` • Build and run the ${colors.bold("Android")} app`, + "", + "\tnpm run android", + "", + "", + ].join("\n"); + + case "ios": + case "macos": + case "visionos": + return [ + ` • Build and run the ${colors.bold(platform.slice(0, -2) + "OS")} app`, + "", + `\tpod install --project-directory=${platform}`, + `\tnpm run ${platform}`, + "", + "", + ].join("\n"); + + case "windows": + return [ + ` • Build and run the ${colors.bold("Windows")} app`, + "", + "\tnpx install-windows-test-app", + "\tnpm run windows", + "", + "", + ].join("\n"); + } + + throw new Error(`Unknown platform: ${platform}`); +} + function main() { return new Promise((resolve) => { parseArgs( @@ -309,6 +350,31 @@ function main() { init: true, }); + console.log( + [ + "", + "Your React Native project is now ready.", + "", + "Quick start instructions:", + "", + " • Install npm dependencies using your preferred package manager (the following instructions are for npm):", + "", + `\tcd ${packagePath}`, + "\tnpm install", + "", + "", + ...platforms.sort().map((platform) => instructionsFor(platform)), + " • Start the dev server", + "", + "\tnpm run start", + "", + "", + "Check out the wiki for more information:", + "\thttps://github.com/microsoft/react-native-test-app/wiki/Quick-Start", + "", + ].join("\n") + ); + resolve(result); } );