fix(nextjs): hide lockfile generation behind a flag so it can be toggled on and off (#14204)

This commit is contained in:
Jack Hsu 2023-01-06 15:26:10 -05:00 committed by GitHub
parent e8b2731a47
commit d3ba6447d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 14 deletions

View File

@ -53,6 +53,11 @@
"type": "boolean",
"description": "Include `devDependencies` in the generated package.json file. By default only production `dependencies` are included.",
"default": false
},
"generateLockfile": {
"type": "boolean",
"description": "Generate a lockfile (e.g. yarn.lock) that matches the workspace lockfile to ensure package versions match.",
"default": false
}
},
"required": ["root", "outputPath"],

View File

@ -12,9 +12,9 @@ import {
updateFile,
updateProjectConfig,
} from '@nrwl/e2e/utils';
import { checkApp } from './utils';
import { stringUtils } from '@nrwl/workspace';
import * as http from 'http';
import { checkApp } from './utils';
describe('Next.js Applications', () => {
let proj: string;

View File

@ -1,14 +1,11 @@
import {
checkFilesExist,
detectPackageManager,
killPorts,
readJson,
runCLI,
runCLIAsync,
runCypressTests,
tmpProjPath,
} from '../../utils';
import { getLockFileName } from '../../../packages/nx/src/lock-file/lock-file';
export async function checkApp(
appName: string,
@ -28,12 +25,6 @@ export async function checkApp(
expect(packageJson.dependencies['react-dom']).toBeDefined();
expect(packageJson.dependencies.next).toBeDefined();
checkFilesExist(
`dist/apps/${appName}/${getLockFileName(
detectPackageManager(tmpProjPath())
)}`
);
if (opts.checkLint) {
const lintResults = runCLI(`lint ${appName}`);
expect(lintResults).toContain('All files pass linting.');

View File

@ -90,11 +90,14 @@ export default async function buildExecutor(
}
);
updatePackageJson(builtPackageJson, context);
const lockFile = createLockFile(builtPackageJson);
writeJsonFile(`${options.outputPath}/package.json`, builtPackageJson);
if (options.generateLockfile) {
const lockFile = createLockFile(builtPackageJson);
writeFileSync(`${options.outputPath}/${getLockFileName()}`, lockFile, {
encoding: 'utf-8',
});
}
createNextConfigFile(options, context);

View File

@ -53,6 +53,11 @@
"type": "boolean",
"description": "Include `devDependencies` in the generated package.json file. By default only production `dependencies` are included.",
"default": false
},
"generateLockfile": {
"type": "boolean",
"description": "Generate a lockfile (e.g. yarn.lock) that matches the workspace lockfile to ensure package versions match.",
"default": false
}
},
"required": ["root", "outputPath"]

View File

@ -37,6 +37,7 @@ export interface NextBuildBuilderOptions {
nextConfig?: string;
buildLibsFromSource?: boolean;
includeDevDependenciesInPackageJson?: boolean;
generateLockfile?: boolean;
watch?: boolean;
}