Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: preparing next build with correct dirs #3380

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions toolchains/simple-pnpm/build_node_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
parser.add_argument(
"--root-dir",
help="Path to the root",
)
Expand All @@ -22,19 +21,12 @@

args = parser.parse_args()

if args.root_dir:
cwd = args.root_dir
else:
cwd = None

cmd = ["pnpm", "install", "--frozen-lockfile"]

exit_code = subprocess.call(cmd, cwd=cwd)
exit_code = subprocess.call(cmd, cwd=args.root_dir)

if exit_code == 0:
src = "node_modules"
if cwd:
src = os.path.join(cwd, src)
src = os.path.join(args.root_dir, "node_modules")

shutil.copytree(
src,
Expand Down
25 changes: 17 additions & 8 deletions toolchains/workspace-pnpm/build_next_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
"--root-dir",
help="Path to the root",
)
parser.add_argument(
"--package-dir",
help="Directory of the package",
Expand All @@ -25,27 +29,32 @@
os.path.relpath("node_modules/.bin/next"),
"build"
]
exit_code = subprocess.call(next_cmd, cwd=args.package_dir)

app_dir = os.path.join(args.root_dir, args.package_dir)
build_out_dir = os.path.join(app_dir, ".next")

exit_code = subprocess.call(next_cmd, cwd=app_dir)

shutil.copytree(
os.path.join(args.package_dir,".next"),
build_out_dir,
os.path.join(args.out_path, ".next"),
symlinks=True,
dirs_exist_ok=True,
)

if os.path.exists(os.path.join(args.package_dir, "public")):
if os.path.exists(os.path.join(app_dir, "public")):
shutil.copytree(
os.path.join(args.package_dir,"public"),
os.path.join(args.out_path, ".next", "standalone", "public"),
os.path.join(app_dir, "public"),
os.path.join(args.out_path, ".next", "standalone", args.package_dir, "public"),
symlinks=True,
dirs_exist_ok=True,
)

if os.path.exists(os.path.join(args.package_dir, ".next", "static")):
if os.path.exists(os.path.join(build_out_dir, "static")):
shutil.copytree(
os.path.join(args.package_dir,".next", "static"),
os.path.join(args.out_path, ".next", "standalone", "static"),
os.path.join(build_out_dir, "static"),
os.path.join(args.out_path, ".next", "standalone",
args.package_dir,".next", "static"),
symlinks=True,
dirs_exist_ok=True,
)
Expand Down
4 changes: 3 additions & 1 deletion toolchains/workspace-pnpm/macros.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,10 @@ def next_build_impl(ctx: AnalysisContext) -> list[[DefaultInfo, RunInfo]]:
cmd = cmd_args(
ctx.attrs._python_toolchain[PythonToolchainInfo].interpreter,
pnpm_toolchain.build_next_build[DefaultInfo].default_outputs,
"--root-dir",
build_context.workspace_root,
"--package-dir",
cmd_args([build_context.workspace_root, ctx.label.package], delimiter = "/"),
ctx.label.package,
out.as_output()
)

Expand Down
Loading