Skip to content

Commit 8a3ccdb

Browse files
authored
allow using shirt-shop as a template (#80)
* allow using shirt-shop as a template * js » mjs
1 parent 6467786 commit 8a3ccdb

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import fs from 'fs/promises';
2+
3+
async function prepareTemplate() {
4+
// Skip when not used as a template
5+
if (process.env.VERCEL_PROJECT_ID === 'prj_6Km3AvCCo0QgJSoEb3cFQwwB9x0Y') {
6+
return;
7+
}
8+
9+
// Read the package.json
10+
const packageJson = JSON.parse(await fs.readFile('./package.json', 'utf8'));
11+
12+
// Create a copy for the template
13+
const templatePackageJson = { ...packageJson };
14+
15+
// Replace workspace dependencies with real versions
16+
for (const [dep, version] of Object.entries(
17+
templatePackageJson.dependencies || {},
18+
)) {
19+
if (version.startsWith('workspace:')) {
20+
// Replace with the actual version you want
21+
templatePackageJson.dependencies[dep] = 'latest';
22+
}
23+
}
24+
25+
// Write the template package.json
26+
await fs.writeFile('./package.json', JSON.stringify(templatePackageJson));
27+
}
28+
29+
prepareTemplate();

examples/shirt-shop/vercel.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"installCommand": "node scripts/replace-workspace-version.mjs && pnpm install"
3+
}

0 commit comments

Comments
 (0)