From 10d524f3590dd695b94c3e1fb7834314ecbe1964 Mon Sep 17 00:00:00 2001 From: Exortions <75327059+Exortions@users.noreply.github.com> Date: Mon, 14 Mar 2022 10:13:13 -0700 Subject: [PATCH 1/3] Merge multiple log statements It is inefficient to use multiple console.log satements, and if something is logged to the console in the middle of execution, it will be in the center of the text, making it hard to read. This pull request merges multiple console.logs into one. In addition, it reduces the bundle size. --- packages/create-next-app/index.ts | 41 ++++++++++++++----------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/packages/create-next-app/index.ts b/packages/create-next-app/index.ts index 8d7f254276103..3b1e7cf683025 100644 --- a/packages/create-next-app/index.ts +++ b/packages/create-next-app/index.ts @@ -88,17 +88,17 @@ async function run(): Promise { } if (!projectPath) { - console.log() - console.log('Please specify the project directory:') - console.log( - ` ${chalk.cyan(program.name())} ${chalk.green('')}` - ) - console.log() - console.log('For example:') - console.log(` ${chalk.cyan(program.name())} ${chalk.green('my-next-app')}`) - console.log() console.log( - `Run ${chalk.cyan(`${program.name()} --help`)} to see all options.` + ` + + Please specify the project directory: + ${chalk.cyan(program.name())} ${chalk.green('')} + + For example: + ${chalk.cyan(program.name())} ${chalk.green('my-next-app')} + + Run ${chalk.cyan(`${program.name()} --help`)} to see all options. + ` ) process.exit(1) } @@ -173,19 +173,13 @@ async function notifyUpdate(): Promise { if (res?.latest) { const pkgManager = getPkgManager() - console.log() console.log( + ` chalk.yellow.bold('A new version of `create-next-app` is available!') + You can update by running: ${chalk.cyan(pkgManager === 'yarn' ? 'yarn global add create-next-app' : `${pkgManager} install --global create-next-app` )} + + ` ) - console.log( - 'You can update by running: ' + - chalk.cyan( - pkgManager === 'yarn' - ? 'yarn global add create-next-app' - : `${pkgManager} install --global create-next-app` - ) - ) - console.log() } process.exit() } catch { @@ -201,8 +195,11 @@ run() if (reason.command) { console.log(` ${chalk.cyan(reason.command)} has failed.`) } else { - console.log(chalk.red('Unexpected error. Please report it as a bug:')) - console.log(reason) + console.log( + ` + ${chalk.red('Unexpected error. Please report it as a bug:')} + ${reason} + ` } console.log() From 88ca100bc78889a03746784d7c846922835962fc Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Sun, 22 May 2022 12:54:35 -0500 Subject: [PATCH 2/3] ensure formatting matches --- packages/create-next-app/index.ts | 41 +++++++++++++++---------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/packages/create-next-app/index.ts b/packages/create-next-app/index.ts index 3b1e7cf683025..aa89b4fd25175 100644 --- a/packages/create-next-app/index.ts +++ b/packages/create-next-app/index.ts @@ -89,16 +89,13 @@ async function run(): Promise { if (!projectPath) { console.log( - ` - - Please specify the project directory: - ${chalk.cyan(program.name())} ${chalk.green('')} - - For example: - ${chalk.cyan(program.name())} ${chalk.green('my-next-app')} - - Run ${chalk.cyan(`${program.name()} --help`)} to see all options. - ` + '\nPlease specify the project directory:\n' + + ` ${chalk.cyan(program.name())} ${chalk.green( + '' + )}\n` + + 'For example:\n' + + ` ${chalk.cyan(program.name())} ${chalk.green('my-next-app')}\n\n` + + `Run ${chalk.cyan(`${program.name()} --help`)} to see all options.` ) process.exit(1) } @@ -129,7 +126,7 @@ async function run(): Promise { ? 'npm' : !!program.usePnpm ? 'pnpm' - : 'yarn' + : getPkgManager() const example = typeof program.example === 'string' && program.example.trim() try { @@ -172,13 +169,16 @@ async function notifyUpdate(): Promise { const res = await update if (res?.latest) { const pkgManager = getPkgManager() - console.log( - ` - chalk.yellow.bold('A new version of `create-next-app` is available!') - You can update by running: ${chalk.cyan(pkgManager === 'yarn' ? 'yarn global add create-next-app' : `${pkgManager} install --global create-next-app` )} - - ` + chalk.yellow.bold('A new version of `create-next-app` is available!') + + '\n' + + 'You can update by running: ' + + chalk.cyan( + pkgManager === 'yarn' + ? 'yarn global add create-next-app' + : `${pkgManager} install --global create-next-app` + ) + + '\n' ) } process.exit() @@ -196,10 +196,9 @@ run() console.log(` ${chalk.cyan(reason.command)} has failed.`) } else { console.log( - ` - ${chalk.red('Unexpected error. Please report it as a bug:')} - ${reason} - ` + chalk.red('Unexpected error. Please report it as a bug:') + '\n', + reason + ) } console.log() From c82bb11812ce4f04a1f6a7fa0f4f201f289cbd47 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Sun, 22 May 2022 13:42:53 -0500 Subject: [PATCH 3/3] update test --- test/integration/client-navigation/test/index.test.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/integration/client-navigation/test/index.test.js b/test/integration/client-navigation/test/index.test.js index 52bae94269011..3bf00daa88ac3 100644 --- a/test/integration/client-navigation/test/index.test.js +++ b/test/integration/client-navigation/test/index.test.js @@ -1716,22 +1716,21 @@ describe('Client Navigation', () => { it('should navigate to paths relative to the current page', async () => { const browser = await webdriver(context.appPort, '/nav/relative') - await browser.waitForElementByCss('body', 500) let page await browser.elementByCss('a').click() - browser.waitForElementByCss('#relative-1', 500) + browser.waitForElementByCss('#relative-1') page = await browser.elementByCss('body').text() expect(page).toMatch(/On relative 1/) await browser.elementByCss('a').click() - browser.waitForElementByCss('#relative-2', 500) + browser.waitForElementByCss('#relative-2') page = await browser.elementByCss('body').text() expect(page).toMatch(/On relative 2/) await browser.elementByCss('button').click() - browser.waitForElementByCss('#relative', 500) + browser.waitForElementByCss('#relative') page = await browser.elementByCss('body').text() expect(page).toMatch(/On relative index/)