Unverified Commit 36589b5d authored by Sebastian "Sebbie" Silbermann's avatar Sebastian "Sebbie" Silbermann Committed by GitHub

[backport][test] Pin package manager to patch versions (#93596)

parent ad6fd4e5
...@@ -11,6 +11,7 @@ describe('nx-handling', () => { ...@@ -11,6 +11,7 @@ describe('nx-handling', () => {
name: '@nx-next/source', name: '@nx-next/source',
version: '0.0.0', version: '0.0.0',
private: true, private: true,
packageManager: 'npm@10.9.2',
scripts: { scripts: {
build: 'rm -rf dist; nx run next-nx-test:build', build: 'rm -rf dist; nx run next-nx-test:build',
dev: 'nx run next-nx-test:dev', dev: 'nx run next-nx-test:dev',
......
import { createNext } from 'e2e-utils' import { createNext, isNextDev } from 'e2e-utils'
import { NextInstance } from 'e2e-utils' import { NextInstance } from 'e2e-utils'
import { renderViaHTTP } from 'next-test-utils' import { renderViaHTTP } from 'next-test-utils'
...@@ -24,8 +24,18 @@ describe('handle-non-hoisted-swc-helpers', () => { ...@@ -24,8 +24,18 @@ describe('handle-non-hoisted-swc-helpers', () => {
} }
`, `,
}, },
packageJson: {
packageManager: 'npm@10.9.2',
scripts: {
build: 'next build',
dev: 'next dev',
start: 'next start',
},
},
installCommand: installCommand:
'npm install; mkdir -p node_modules/next/node_modules/@swc; mv node_modules/@swc/helpers node_modules/next/node_modules/@swc/', 'npm install; mkdir -p node_modules/next/node_modules/@swc; mv node_modules/@swc/helpers node_modules/next/node_modules/@swc/',
buildCommand: 'npm run build',
startCommand: isNextDev ? 'npm run dev' : 'npm run start',
dependencies: {}, dependencies: {},
}) })
}) })
......
...@@ -49,6 +49,11 @@ export function runTests( ...@@ -49,6 +49,11 @@ export function runTests(
}, },
{} as { [key: string]: FileRef } {} as { [key: string]: FileRef }
), ),
packageJson: {
// Bootstrap with classic yarn; the install command below runs
// `yarn set version berry` which rewrites this to the berry version.
packageManager: 'yarn@1.22.22',
},
dependencies: { dependencies: {
...packageJson.dependencies, ...packageJson.dependencies,
...packageJson.devDependencies, ...packageJson.devDependencies,
......
import { import {
command,
DEFAULT_FILES, DEFAULT_FILES,
FULL_EXAMPLE_PATH, FULL_EXAMPLE_PATH,
projectFilesShouldExist, projectFilesShouldExist,
...@@ -9,6 +10,11 @@ import { ...@@ -9,6 +10,11 @@ import {
const lockFile = 'pnpm-lock.yaml' const lockFile = 'pnpm-lock.yaml'
const files = [...DEFAULT_FILES, lockFile] const files = [...DEFAULT_FILES, lockFile]
// Match the monorepo's pinned pnpm so CNA's `pnpm install` doesn't drift to
// whichever version corepack happens to fetch as "latest" at test time.
const rootPackageManager: string =
require('../../../../package.json').packageManager
describe('create-next-app with package manager pnpm', () => { describe('create-next-app with package manager pnpm', () => {
let nextTgzFilename: string let nextTgzFilename: string
...@@ -17,6 +23,8 @@ describe('create-next-app with package manager pnpm', () => { ...@@ -17,6 +23,8 @@ describe('create-next-app with package manager pnpm', () => {
throw new Error('This test needs to be run with `node run-tests.js`.') throw new Error('This test needs to be run with `node run-tests.js`.')
} }
await command('corepack', ['prepare', '--activate', rootPackageManager])
const pkgPaths = new Map<string, string>( const pkgPaths = new Map<string, string>(
JSON.parse(process.env.NEXT_TEST_PKG_PATHS) JSON.parse(process.env.NEXT_TEST_PKG_PATHS)
) )
......
...@@ -9,6 +9,7 @@ const { linkPackages } = ...@@ -9,6 +9,7 @@ const { linkPackages } =
const PREFER_OFFLINE = process.env.NEXT_TEST_PREFER_OFFLINE === '1' const PREFER_OFFLINE = process.env.NEXT_TEST_PREFER_OFFLINE === '1'
const useRspack = process.env.NEXT_TEST_USE_RSPACK === '1' const useRspack = process.env.NEXT_TEST_USE_RSPACK === '1'
const ROOT_PACKAGE_MANAGER = require('../../package.json').packageManager
async function installDependencies(cwd, tmpDir) { async function installDependencies(cwd, tmpDir) {
const args = [ const args = [
...@@ -176,6 +177,10 @@ async function createNextInstall({ ...@@ -176,6 +177,10 @@ async function createNextInstall({
path.join(installDir, 'package.json'), path.join(installDir, 'package.json'),
JSON.stringify( JSON.stringify(
{ {
// Pin packageManager so corepack doesn't auto-inject a reference
// to the latest version (and rewrite this file mid-test).
// Callers can override via packageJson.packageManager.
packageManager: ROOT_PACKAGE_MANAGER,
...packageJson, ...packageJson,
scripts, scripts,
dependencies: combinedDependencies, dependencies: combinedDependencies,
......
...@@ -64,6 +64,9 @@ const nextjsReactPeerVersion = "19.1.0"; ...@@ -64,6 +64,9 @@ const nextjsReactPeerVersion = "19.1.0";
const latestSupportedTypeScriptVersion = '5.8.2' const latestSupportedTypeScriptVersion = '5.8.2'
const latestSupportedNodeTypesVersion = '20.17.6' const latestSupportedNodeTypesVersion = '20.17.6'
const ROOT_PACKAGE_MANAGER: string =
require('../../../package.json').packageManager
export class NextInstance { export class NextInstance {
protected files: ResolvedFileConfig protected files: ResolvedFileConfig
protected overrideFiles: ResolvedFileConfig protected overrideFiles: ResolvedFileConfig
...@@ -228,6 +231,10 @@ export class NextInstance { ...@@ -228,6 +231,10 @@ export class NextInstance {
path.join(this.testDir, 'package.json'), path.join(this.testDir, 'package.json'),
JSON.stringify( JSON.stringify(
{ {
// Pin packageManager so corepack doesn't auto-inject a reference
// to the latest version (and rewrite this file mid-test).
// Callers can override via packageJson.packageManager.
packageManager: ROOT_PACKAGE_MANAGER,
...this.packageJson, ...this.packageJson,
dependencies: { dependencies: {
...finalDependencies, ...finalDependencies,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment