ci: template errors not being caught due. fix: error due to updated generated-types User type (#12973)

This PR consists of two separate changes. One change cannot pass CI
without the other, so both are included in this single PR.


## CI - ensure types are generated

Our website template is currently failing to build due to a type error.
This error was introduced by a change in our generated types.

Our CI did not catch this issue because it wasn't generating types /
import map before attempting to build the templates. This PR updates the
CI to generate types first.

It also updates some CI step names for improved clarity.

## Fix: type error

![Screenshot 2025-06-29 at 12 53
49@2x](https://github.com/user-attachments/assets/962f1513-bc6c-4e12-9b74-9b891c49900b)


This fixes the type error by ensuring we consistently use the _same_
generated `TypedUser` object within payload, instead of `BaseUser`.
Previously, we sometimes used the generated-types user and sometimes the
base user, which was causing type conflicts depending on what the
generated user type was.

It also deprecates the `User` type (which was essentially just
`BaseUser`), as consumers should use `TypedUser` instead. `TypedUser`
will automatically fall back to `BaseUser` if no generated types exists,
but will accept passing it a generated-types User.

Without this change, additional properties added to the user via
generated-types may cause the user object to not be accepted by
functions that only accept a `User` instead of a `TypedUser`, which is
what failed here.

## Templates: re-generate templates to update generated types

---
- To see the specific tasks where the Asana app for GitHub is being
used, see below:
  - https://app.asana.com/0/0/1210668927737258
This commit is contained in:
Alessio Gravili
2025-06-29 14:27:50 -07:00
committed by GitHub
parent cfc7adcbc5
commit 4458f74cef
53 changed files with 710 additions and 146 deletions

View File

@@ -1,6 +1,6 @@
import { TEMPLATES_DIR } from '@tools/constants'
import chalk from 'chalk'
import { exec as execOrig, execSync } from 'child_process'
import { execSync } from 'child_process'
import fs from 'fs/promises'
import path from 'path'
@@ -46,6 +46,8 @@ async function main() {
const initialPackageJson = await fs.readFile(packageJsonPath, 'utf-8')
const initialPackageJsonObj = JSON.parse(initialPackageJson)
// Update the package.json dependencies to use any specific version instead of `workspace:*`, so that
// the next pnpm add command can install the local packages correctly.
updatePackageJSONDependencies({ latestVersion: '3.42.0', packageJson: initialPackageJsonObj })
await fs.writeFile(packageJsonPath, JSON.stringify(initialPackageJsonObj, null, 2))
@@ -85,7 +87,14 @@ DATABASE_URI=${databaseConnection}
POSTGRES_URL=${databaseConnection}
BLOB_READ_WRITE_TOKEN=vercel_blob_rw_TEST_asdf`,
)
execSync('pnpm run build', execOpts)
// Important: run generate:types and generate:importmap first
if (templateName !== 'plugin') {
// TODO: fix in a separate PR - these commands currently fail in the plugin template
execSync('pnpm --ignore-workspace run generate:types', execOpts)
execSync('pnpm --ignore-workspace run generate:importmap', execOpts)
}
execSync('pnpm --ignore-workspace run build', execOpts)
header(`\n🎉 Done!`)
}

View File

@@ -323,13 +323,19 @@ async function main() {
// Generate importmap
log('Generating import map')
execSyncSafe(`pnpm ${workspace ? '' : '--ignore-workspace'} generate:importmap`, {
execSyncSafe(`pnpm ${workspace ? '' : '--ignore-workspace '}generate:importmap`, {
cwd: destDir,
})
// Generate types
log('Generating types')
execSyncSafe(`pnpm ${workspace ? '' : '--ignore-workspace '}generate:types`, {
cwd: destDir,
})
if (shouldBuild) {
log('Building...')
execSyncSafe(`pnpm ${workspace ? '' : '--ignore-workspace'} build`, { cwd: destDir })
execSyncSafe(`pnpm ${workspace ? '' : '--ignore-workspace '}build`, { cwd: destDir })
}
// TODO: Email?