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

allow using shirt-shop as a template #80

Merged
merged 2 commits into from
Feb 28, 2025
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
29 changes: 29 additions & 0 deletions examples/shirt-shop/scripts/replace-workspace-version.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import fs from 'fs/promises';

async function prepareTemplate() {
// Skip when not used as a template
if (process.env.VERCEL_PROJECT_ID === 'prj_6Km3AvCCo0QgJSoEb3cFQwwB9x0Y') {
return;
}

// Read the package.json
const packageJson = JSON.parse(await fs.readFile('./package.json', 'utf8'));

// Create a copy for the template
const templatePackageJson = { ...packageJson };

// Replace workspace dependencies with real versions
for (const [dep, version] of Object.entries(
templatePackageJson.dependencies || {},
)) {
if (version.startsWith('workspace:')) {
// Replace with the actual version you want
templatePackageJson.dependencies[dep] = 'latest';
}
}

// Write the template package.json
await fs.writeFile('./package.json', JSON.stringify(templatePackageJson));
}

prepareTemplate();
3 changes: 3 additions & 0 deletions examples/shirt-shop/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"installCommand": "node scripts/replace-workspace-version.mjs && pnpm install"
}
Loading