chore: add logging templates script and fix engines for pnpm v10 (#12021)

- Fixes issues with using pnpm v10 in some templates by allowing `^10`
in engines as well
- Added logging to the template generation script so we can debug the
latest version being pulled by CI
This commit is contained in:
Paul
2025-04-07 20:13:54 +01:00
committed by GitHub
parent c7b14bd44d
commit b270901fa6
7 changed files with 15 additions and 7 deletions

View File

@@ -39,7 +39,7 @@
}, },
"engines": { "engines": {
"node": "^18.20.2 || >=20.9.0", "node": "^18.20.2 || >=20.9.0",
"pnpm": "^9" "pnpm": "^9 || ^10"
}, },
"pnpm": { "pnpm": {
"onlyBuiltDependencies": [ "onlyBuiltDependencies": [

View File

@@ -39,7 +39,7 @@
}, },
"engines": { "engines": {
"node": "^18.20.2 || >=20.9.0", "node": "^18.20.2 || >=20.9.0",
"pnpm": "^9" "pnpm": "^9 || ^10"
}, },
"pnpm": { "pnpm": {
"onlyBuiltDependencies": [ "onlyBuiltDependencies": [

View File

@@ -81,7 +81,7 @@
}, },
"engines": { "engines": {
"node": "^18.20.2 || >=20.9.0", "node": "^18.20.2 || >=20.9.0",
"pnpm": "^9" "pnpm": "^9 || ^10"
}, },
"publishConfig": { "publishConfig": {
"exports": { "exports": {

View File

@@ -70,7 +70,7 @@
}, },
"engines": { "engines": {
"node": "^18.20.2 || >=20.9.0", "node": "^18.20.2 || >=20.9.0",
"pnpm": "^9" "pnpm": "^9 || ^10"
}, },
"pnpm": { "pnpm": {
"onlyBuiltDependencies": [ "onlyBuiltDependencies": [

View File

@@ -39,7 +39,7 @@
}, },
"engines": { "engines": {
"node": "^18.20.2 || >=20.9.0", "node": "^18.20.2 || >=20.9.0",
"pnpm": "^9" "pnpm": "^9 || ^10"
}, },
"pnpm": { "pnpm": {
"onlyBuiltDependencies": [ "onlyBuiltDependencies": [

View File

@@ -40,7 +40,7 @@
}, },
"engines": { "engines": {
"node": "^18.20.2 || >=20.9.0", "node": "^18.20.2 || >=20.9.0",
"pnpm": "^9" "pnpm": "^9 || ^10"
}, },
"pnpm": { "pnpm": {
"onlyBuiltDependencies": [ "onlyBuiltDependencies": [

View File

@@ -435,9 +435,10 @@ function header(message: string) {
function log(message: string) { function log(message: string) {
console.log(chalk.dim(message)) console.log(chalk.dim(message))
} }
function execSyncSafe(command: string, options?: Parameters<typeof execSync>[1]) { function execSyncSafe(command: string, options?: Parameters<typeof execSync>[1]) {
try { try {
console.log(`Executing: ${command}`) log(`Executing: ${command}`)
execSync(command, { stdio: 'inherit', ...options }) execSync(command, { stdio: 'inherit', ...options })
} catch (error) { } catch (error) {
if (error instanceof Error) { if (error instanceof Error) {
@@ -492,6 +493,11 @@ async function bumpPackageJson({
) )
} }
/**
* Fetches the latest version of a package from the NPM registry.
*
* Used in determining the latest version of Payload to use in the generated templates.
*/
async function getLatestPackageVersion({ async function getLatestPackageVersion({
packageName = 'payload', packageName = 'payload',
}: { }: {
@@ -509,6 +515,8 @@ async function getLatestPackageVersion({
const data = await response.json() const data = await response.json()
const latestVersion = data['dist-tags'].latest const latestVersion = data['dist-tags'].latest
log(`Found latest version of ${packageName}: ${latestVersion}`)
return latestVersion return latestVersion
} catch (error) { } catch (error) {
console.error('Error fetching Payload version:', error) console.error('Error fetching Payload version:', error)