From f93f9e463a042ecfca6bf5282eaad814be07edcf Mon Sep 17 00:00:00 2001 From: Owen Buckley Date: Mon, 21 Oct 2024 13:05:24 -0400 Subject: [PATCH 1/2] clearer post init user next steps instructions --- packages/init/src/index.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/init/src/index.js b/packages/init/src/index.js index 691c6db2f..4dac1702a 100755 --- a/packages/init/src/index.js +++ b/packages/init/src/index.js @@ -256,6 +256,8 @@ const run = async () => { const firstArg = process.argv[process.argv.length - 1].split(' ')[0]; const taskRunner = program.yarn ? 'yarn' : 'npm run'; const shouldChangeDirectory = !firstArg.startsWith('--') && firstArg !== ''; + const shouldInstallDeps = program.install || program.yarn; + const instructions = []; if (!firstArg.startsWith('--') && firstArg !== '') { TARGET_DIR = path.join(TARGET_DIR, `./${firstArg}`); @@ -283,7 +285,7 @@ const run = async () => { console.log('Creating package.json...'); await npmInit(); - if (program.install || program.yarn) { + if (shouldInstallDeps) { console.log('Installing project dependencies...'); await install(); } @@ -291,12 +293,24 @@ const run = async () => { await cleanUp(); console.log(`${chalk.rgb(175, 207, 71)('Initializing new project complete!')}`); + console.log(`${chalk.rgb(175, 207, 71)('Complete the follow steps to get started:')}`); if (shouldChangeDirectory) { - console.log(`Change directories by running => cd ${firstArg}`); + instructions.push(`Change directories by running => cd ${firstArg}`); } - console.log(`To start developing run => ${taskRunner} dev`); + if (!shouldInstallDeps) { + instructions.push('Install dependencies with your package manager, e.g. => npm i'); + } + + instructions.push(`To start developing run => ${taskRunner} dev`); + + // output all instructions in step-based order + instructions.forEach((instruction, idx) => { + const step = idx += 1; + + console.log(`${step}) ${instruction}`); + }); } catch (err) { console.error(err); } From d53353af85c338d3e63a6e06c94c757a98d71ac6 Mon Sep 17 00:00:00 2001 From: Owen Buckley Date: Mon, 21 Oct 2024 13:29:46 -0400 Subject: [PATCH 2/2] commenting and clean up --- packages/init/src/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/init/src/index.js b/packages/init/src/index.js index 4dac1702a..cab84bc9b 100755 --- a/packages/init/src/index.js +++ b/packages/init/src/index.js @@ -255,11 +255,13 @@ const run = async () => { try { const firstArg = process.argv[process.argv.length - 1].split(' ')[0]; const taskRunner = program.yarn ? 'yarn' : 'npm run'; + // bypassing commander here for my-app directory option, since I couldn't get it to work as an argument :/ + // https://github.com/tj/commander.js?tab=readme-ov-file#command-arguments const shouldChangeDirectory = !firstArg.startsWith('--') && firstArg !== ''; const shouldInstallDeps = program.install || program.yarn; const instructions = []; - if (!firstArg.startsWith('--') && firstArg !== '') { + if (shouldChangeDirectory) { TARGET_DIR = path.join(TARGET_DIR, `./${firstArg}`); if (!fs.existsSync(TARGET_DIR)) {