diff --git a/packages/create-next-app/helpers/install.ts b/packages/create-next-app/helpers/install.ts index f1c814f58d92a..f8855275a91d6 100644 --- a/packages/create-next-app/helpers/install.ts +++ b/packages/create-next-app/helpers/install.ts @@ -30,7 +30,7 @@ export function install( /** * NPM-specific command-line flags. */ - const npmFlags: string[] = ['--logLevel', 'error'] + const npmFlags: string[] = [] /** * Yarn-specific command-line flags. */ diff --git a/test/integration/create-next-app/index.test.js b/test/integration/create-next-app/index.test.js index 3e9c030f89cb9..1a7672570d3ca 100644 --- a/test/integration/create-next-app/index.test.js +++ b/test/integration/create-next-app/index.test.js @@ -17,7 +17,7 @@ async function usingTempDir(fn, options) { const folder = path.join(os.tmpdir(), Math.random().toString(36).substring(2)) await fs.mkdirp(folder, options) try { - return await fn(folder) + await fn(folder) } finally { await fs.remove(folder) } @@ -52,6 +52,9 @@ describe('create next app', () => { expect( fs.existsSync(path.join(cwd, projectName, 'pages/index.js')) ).toBeTruthy() + expect( + fs.existsSync(path.join(cwd, projectName, 'node_modules/next')) + ).toBe(true) }) }) } @@ -88,6 +91,9 @@ describe('create next app', () => { expect( fs.existsSync(path.join(cwd, projectName, '.gitignore')) ).toBeTruthy() + expect( + fs.existsSync(path.join(cwd, projectName, 'node_modules/next')) + ).toBe(true) }) }) @@ -115,6 +121,9 @@ describe('create next app', () => { expect( fs.existsSync(path.join(cwd, projectName, 'next-env.d.ts')) ).toBeTruthy() + expect( + fs.existsSync(path.join(cwd, projectName, 'node_modules/next')) + ).toBe(true) // check we copied default `.gitignore` expect( fs.existsSync(path.join(cwd, projectName, '.gitignore')) @@ -154,6 +163,9 @@ describe('create next app', () => { expect( fs.existsSync(path.join(cwd, projectName, '.gitignore')) ).toBeTruthy() + expect( + fs.existsSync(path.join(cwd, projectName, 'node_modules/next')) + ).toBe(true) }) }) @@ -177,6 +189,9 @@ describe('create next app', () => { expect( fs.existsSync(path.join(cwd, projectName, '.gitignore')) ).toBeTruthy() + expect( + fs.existsSync(path.join(cwd, projectName, 'node_modules/next')) + ).toBe(true) }) }) @@ -206,6 +221,9 @@ describe('create next app', () => { expect( fs.existsSync(path.join(cwd, projectName, '.gitignore')) ).toBeTruthy() + expect( + fs.existsSync(path.join(cwd, projectName, 'node_modules/next')) + ).toBe(true) }) }) @@ -248,6 +266,9 @@ describe('create next app', () => { expect( fs.existsSync(path.join(cwd, projectName, '.gitignore')) ).toBeTruthy() + expect( + fs.existsSync(path.join(cwd, projectName, 'node_modules/next')) + ).toBe(true) }) }) @@ -283,7 +304,12 @@ describe('create next app', () => { const res = await run(['.'], { cwd }) expect(res.exitCode).toBe(0) - const files = ['package.json', 'pages/index.js', '.gitignore'] + const files = [ + 'package.json', + 'pages/index.js', + '.gitignore', + 'node_modules/next', + ] files.forEach((file) => expect(fs.existsSync(path.join(cwd, file))).toBeTruthy() ) @@ -296,7 +322,12 @@ describe('create next app', () => { const res = await run([], { cwd, input: `${projectName}\n` }) expect(res.exitCode).toBe(0) - const files = ['package.json', 'pages/index.js', '.gitignore'] + const files = [ + 'package.json', + 'pages/index.js', + '.gitignore', + 'node_modules/next', + ] files.forEach((file) => expect(fs.existsSync(path.join(cwd, projectName, file))).toBeTruthy() ) @@ -314,6 +345,34 @@ describe('create next app', () => { 'pages/index.js', '.gitignore', 'package-lock.json', + 'node_modules/next', + ] + files.forEach((file) => + expect(fs.existsSync(path.join(cwd, projectName, file))).toBeTruthy() + ) + }) + }) + + it('should use npm as the package manager on supplying --use-npm with example', async () => { + await usingTempDir(async (cwd) => { + const projectName = 'use-npm' + const res = await run( + [ + projectName, + '--use-npm', + '--example', + 'https://github.com/vercel/next-learn-starter/tree/master/learn-starter', + ], + { cwd } + ) + expect(res.exitCode).toBe(0) + + const files = [ + 'package.json', + 'pages/index.js', + '.gitignore', + 'package-lock.json', + 'node_modules/next', ] files.forEach((file) => expect(fs.existsSync(path.join(cwd, projectName, file))).toBeTruthy()