Skip to content

Commit

Permalink
fix(nextjs): hide lockfile generation behind a flag so it can be togg…
Browse files Browse the repository at this point in the history
…led on and off (#14204)
  • Loading branch information
jaysoo committed Jan 6, 2023
1 parent e8b2731 commit d3ba644
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
5 changes: 5 additions & 0 deletions docs/generated/packages/next/executors/build.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
2 changes: 1 addition & 1 deletion e2e/next/src/next.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 0 additions & 9 deletions e2e/next/src/utils.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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.');
Expand Down
11 changes: 7 additions & 4 deletions packages/next/src/executors/build/build.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,14 @@ export default async function buildExecutor(
}
);
updatePackageJson(builtPackageJson, context);
const lockFile = createLockFile(builtPackageJson);
writeJsonFile(`${options.outputPath}/package.json`, builtPackageJson);
writeFileSync(`${options.outputPath}/${getLockFileName()}`, lockFile, {
encoding: 'utf-8',
});

if (options.generateLockfile) {
const lockFile = createLockFile(builtPackageJson);
writeFileSync(`${options.outputPath}/${getLockFileName()}`, lockFile, {
encoding: 'utf-8',
});
}

createNextConfigFile(options, context);

Expand Down
5 changes: 5 additions & 0 deletions packages/next/src/executors/build/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
1 change: 1 addition & 0 deletions packages/next/src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export interface NextBuildBuilderOptions {
nextConfig?: string;
buildLibsFromSource?: boolean;
includeDevDependenciesInPackageJson?: boolean;
generateLockfile?: boolean;
watch?: boolean;
}

Expand Down

1 comment on commit d3ba644

@vercel
Copy link

@vercel vercel bot commented on d3ba644 Jan 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-git-master-nrwl.vercel.app
nx-dev-nrwl.vercel.app
nx-five.vercel.app
nx.dev

Please sign in to comment.