Skip to content
Open
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
13 changes: 10 additions & 3 deletions packages/create-pds/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,21 @@ function runCommand(
});
}

async function copyTemplateDir(src: string, dest: string): Promise<void> {
async function copyTemplateDir(
src: string,
dest: string,
pm: PackageManager,
): Promise<void> {
await mkdir(dest, { recursive: true });
const entries = await readdir(src, { withFileTypes: true });

for (const entry of entries) {
const srcPath = join(src, entry.name);
let destName = entry.name;

// Skip pnpm-specific files if not using pnpm
if (destName === "pnpm-workspace.yaml" && pm !== "pnpm") continue;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This branch isn't covered — test/e2e.test.ts asserts a fixed file list. Would be good to run both (--package-manager pnpm gets the file, npm doesn't) since the CLI already supports the flag.


// Rename dotfiles (npm strips them from packages)
if (destName === "gitignore") destName = ".gitignore";
else if (destName === "env.example") destName = ".env.example";
Expand All @@ -95,7 +102,7 @@ async function copyTemplateDir(src: string, dest: string): Promise<void> {
const destPath = join(dest, destName);

if (entry.isDirectory()) {
await copyTemplateDir(srcPath, destPath);
await copyTemplateDir(srcPath, destPath, pm);
} else {
await cp(srcPath, destPath);
}
Expand Down Expand Up @@ -266,7 +273,7 @@ const main = defineCommand({
spinner.start("Copying template...");

const templateDir = join(__dirname, "..", "templates", "pds-worker");
await copyTemplateDir(templateDir, targetDir);
await copyTemplateDir(templateDir, targetDir, pm);

// Replace placeholders in package.json
await replaceInFile(join(targetDir, "package.json"), {
Expand Down
4 changes: 4 additions & 0 deletions packages/create-pds/templates/pds-worker/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
allowBuilds:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

pnpm 9 treats any pnpm-workspace.yaml as a workspace manifest and, with no packages: key, aborts with ERROR packages field missing or empty — reproduced on 9.15.9. The template has no packageManager field so that's what corepack resolves to. pnpm 9 doesn't block build scripts at all, so for those users this file is pure downside: install fails and create-pds reports "Failed to install dependencies".

Two ways out: gate the copy on the pnpm major (it's in npm_config_user_agent), or spell it as onlyBuiltDependencies: [esbuild, workerd], which every pnpm 10 understands — allowBuilds only arrived partway through 10.x so early 10 users silently get nothing from this either way. I'd avoid adding packageManager to the template since that breaks npm/yarn/bun under corepack.

esbuild: true
sharp: false

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

sharp isn't in a scaffolded project's tree (it comes from docs/ in this monorepo), so this entry is noise.

workerd: true