Skip to content

Commit 0d3b69d

Browse files
committed
review comments
1 parent cc44647 commit 0d3b69d

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

packages/cloudflare/src/cli/build/index.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,25 @@ import { rm } from "node:fs/promises";
1111
*
1212
* It saves the output in a `.worker-next` directory
1313
*
14-
* @param opts The options for the project
14+
* @param projectOpts The options for the project
1515
*/
16-
export async function build(opts: ProjectOptions): Promise<void> {
17-
if (!opts.skipBuild) {
16+
export async function build(projectOpts: ProjectOptions): Promise<void> {
17+
if (!projectOpts.skipBuild) {
1818
// Build the next app
19-
await buildNextjsApp(opts.sourceDir);
19+
await buildNextjsApp(projectOpts.sourceDir);
2020
}
2121

22-
if (!containsDotNextDir(opts.sourceDir)) {
23-
throw new Error(`.next folder not found in ${opts.sourceDir}`);
22+
if (!containsDotNextDir(projectOpts.sourceDir)) {
23+
throw new Error(`.next folder not found in ${projectOpts.sourceDir}`);
2424
}
2525

2626
// Clean the output directory
27-
await cleanDirectory(opts.outputDir);
27+
await cleanDirectory(projectOpts.outputDir);
2828

2929
// Copy the .next directory to the output directory so it can be mutated.
30-
cpSync(join(opts.sourceDir, ".next"), join(opts.outputDir, ".next"), { recursive: true });
30+
cpSync(join(projectOpts.sourceDir, ".next"), join(projectOpts.outputDir, ".next"), { recursive: true });
3131

32-
const config = getConfig(opts);
32+
const config = getConfig(projectOpts);
3333

3434
await buildWorker(config);
3535
}

packages/cloudflare/src/cli/config.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export type Config = {
1515
// Timestamp for when the build was started
1616
timestamp: number;
1717
// Whether to skip building the Next.js app or not
18-
shouldSkip: boolean;
18+
skipNextBuild: boolean;
1919
};
2020

2121
paths: {
@@ -50,14 +50,11 @@ export type Config = {
5050
/**
5151
* Computes the configuration.
5252
*
53-
* @param opts.sourceDir Next app root folder
54-
* @param opts.outputDir The directory where to save the output (defaults to the app's directory)
55-
* @param opts.skipBuild Whether the Next.js build should be skipped (i.e. if the `.next` dir is already built)
56-
*
53+
* @param projectOpts The options for the project
5754
* @returns The configuration, see `Config`
5855
*/
59-
export function getConfig(opts: ProjectOptions): Config {
60-
const dotNext = path.join(opts.outputDir, ".next");
56+
export function getConfig(projectOpts: ProjectOptions): Config {
57+
const dotNext = path.join(projectOpts.outputDir, ".next");
6158
const appPath = getNextjsApplicationPath(dotNext).replace(/\/$/, "");
6259
const standaloneRoot = path.join(dotNext, "standalone");
6360
const standaloneApp = path.join(standaloneRoot, appPath);
@@ -71,12 +68,12 @@ export function getConfig(opts: ProjectOptions): Config {
7168
return {
7269
build: {
7370
timestamp: Date.now(),
74-
shouldSkip: !!opts.skipBuild,
71+
skipNextBuild: !!projectOpts.skipBuild,
7572
},
7673

7774
paths: {
78-
sourceDir: opts.sourceDir,
79-
outputDir: opts.outputDir,
75+
sourceDir: projectOpts.sourceDir,
76+
outputDir: projectOpts.outputDir,
8077
dotNext,
8178
standaloneRoot,
8279
standaloneApp,
@@ -103,8 +100,11 @@ export function containsDotNextDir(folder: string): boolean {
103100
}
104101

105102
export type ProjectOptions = {
103+
// Next app root folder
106104
sourceDir: string;
105+
// The directory to save the output to (defaults to the app's directory)
107106
outputDir: string;
107+
// Whether the Next.js build should be skipped (i.e. if the `.next` dir is already built)
108108
skipBuild?: boolean;
109109
};
110110

0 commit comments

Comments
 (0)