-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update turbo and package for migrations to apply on vercel
- Loading branch information
Showing
4 changed files
with
52 additions
and
37 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
packages/core/installMachine/installSteps/payload/createMigration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { execAsync } from '../../../utils/execAsync'; | ||
import { logger } from '../../../utils/logger'; | ||
|
||
export const createMigration = async () => { | ||
logger.withSpinner('payload', 'Creating migration...', async (spinner) => { | ||
try { | ||
execAsync('mkdir migrations'); | ||
execAsync('npx payload migrate:create'); | ||
spinner.succeed('Migration created.'); | ||
} catch (error) { | ||
spinner.fail('Failed to create migration.'); | ||
console.error(error); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
packages/core/installMachine/installSteps/payload/removeTurboFlag.ts
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
packages/core/installMachine/installSteps/payload/updatePackageJson.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { promises as fs } from 'fs'; | ||
import path from 'path'; | ||
import { logger } from '../../../utils/logger'; | ||
|
||
export const updatePackageJson = async () => { | ||
const packageJsonPath = path.resolve('package.json'); | ||
logger.withSpinner('payload', 'Updating package.json...', async (spinner) => { | ||
try { | ||
// Read and parse package.json | ||
const packageData = JSON.parse(await fs.readFile(packageJsonPath, 'utf8')); | ||
|
||
// Add db script to package.json | ||
packageData.scripts = { | ||
...packageData.scripts, | ||
'db:migrate': 'npx payload migrate', | ||
}; | ||
|
||
// Payload doesn't work with Turbopack yet | ||
// Remove '--turbo' flag from the "dev" script | ||
if (packageData.scripts && packageData.scripts.dev) { | ||
packageData.scripts.dev = packageData.scripts.dev.replace('--turbo', '').trim(); | ||
} | ||
|
||
// Write the modified package.json | ||
await fs.writeFile(packageJsonPath, JSON.stringify(packageData, null, 2)); | ||
spinner.succeed('Updated package.json'); | ||
} catch (error) { | ||
spinner.fail('Failed to update package.json'); | ||
console.error('Error updating files:', error); | ||
} | ||
}); | ||
}; |