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;

// 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:
esbuild: true
sharp: false
workerd: true