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

Use build:pack for dbauth when rebuilding the test project #9781

Merged
merged 2 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion __fixtures__/test-project/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"dependencies": {
"@redwoodjs/api": "6.0.7",
"@redwoodjs/auth-dbauth-api": "7.0.0-canary.789",
"@redwoodjs/auth-dbauth-api": "6.0.7",
"@redwoodjs/graphql-server": "6.0.7"
}
}
2 changes: 1 addition & 1 deletion __fixtures__/test-project/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
]
},
"dependencies": {
"@redwoodjs/auth-dbauth-web": "7.0.0-canary.789",
"@redwoodjs/auth-dbauth-web": "6.0.7",
"@redwoodjs/forms": "6.0.7",
"@redwoodjs/router": "6.0.7",
"@redwoodjs/web": "6.0.7",
Expand Down
80 changes: 60 additions & 20 deletions tasks/test-project/tui-tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ function getExecaOptions(cwd) {
// and is set when webTasks or apiTasks are called
let OUTPUT_PATH

const RW_FRAMEWORK_PATH = path.join(__dirname, '../../')

function fullPath(name, { addExtension } = { addExtension: true }) {
if (addExtension) {
if (name.startsWith('api')) {
Expand Down Expand Up @@ -406,38 +408,76 @@ async function apiTasks(outputPath, { linkWithLatestFwBuild }) {
},
})

// At an earlier step we run `yarn rwfw project:copy` which gives us
// [email protected] currently. We need that version to be a canary
// version for auth-dbauth-api and auth-dbauth-web package installations
// to work. So we update the package.json to make the setup use the latest
// canary version for the api and web sides
// We want to use the latest version of the auth-dbauth-{setup,api,web}
// packages. But they're not published yet. So let's package them up as
// tarballs and install them using that by setting yarn resolutions

const { stdout } = await exec(
`yarn npm info @redwoodjs/auth-dbauth-setup --fields versions --json`,
[],
execaOptions
const setupPkg = path.join(
RW_FRAMEWORK_PATH,
'packages',
'auth-providers',
'dbAuth',
'setup'
)
const apiPkg = path.join(
RW_FRAMEWORK_PATH,
'packages',
'auth-providers',
'dbAuth',
'api'
)
const webPkg = path.join(
RW_FRAMEWORK_PATH,
'packages',
'auth-providers',
'dbAuth',
'web'
)

await exec('yarn build:pack', [], getExecaOptions(setupPkg))
await exec('yarn build:pack', [], getExecaOptions(apiPkg))
await exec('yarn build:pack', [], getExecaOptions(webPkg))

const latestCanaryVersion = JSON.parse(stdout)
.versions.filter((version) => version.includes('canary'))
.at(-1)
const setupTgz = path.join(setupPkg, 'redwoodjs-auth-dbauth-setup.tgz')
const apiTgz = path.join(apiPkg, 'redwoodjs-auth-dbauth-api.tgz')
const webTgz = path.join(webPkg, 'redwoodjs-auth-dbauth-web.tgz')

const dbAuthSetupPath = path.join(
const setupTgzDest = path.join(
outputPath,
'node_modules',
Tobbe marked this conversation as resolved.
Show resolved Hide resolved
'auth-dbauth-setup.tgz'
)
const apiTgzDest = path.join(
outputPath,
'node_modules',
'@redwoodjs',
'auth-dbauth-setup'
'auth-dbauth-api.tgz'
)
const webTgzDest = path.join(
outputPath,
'node_modules',
'auth-dbauth-web.tgz'
)

fs.copyFileSync(setupTgz, setupTgzDest)
fs.copyFileSync(apiTgz, apiTgzDest)
fs.copyFileSync(webTgz, webTgzDest)

const dbAuthSetupPackageJson = JSON.parse(
fs.readFileSync(path.join(dbAuthSetupPath, 'package.json'), 'utf-8')
const projectPackageJsonPath = path.join(outputPath, 'package.json')
const projectPackageJson = JSON.parse(
fs.readFileSync(projectPackageJsonPath, 'utf-8')
)

dbAuthSetupPackageJson.version = latestCanaryVersion
projectPackageJson.resolutions ??= {}
projectPackageJson.resolutions = {
...projectPackageJson.resolutions,
'auth-dbauth-setup': './node_modules/auth-dbauth-setup.tgz',
'auth-dbauth-api': './node_modules/auth-dbauth-api.tgz',
'auth-dbauth-web': './node_modules/auth-dbauth-web.tgz',
}

fs.writeFileSync(
path.join(dbAuthSetupPath, 'package.json'),
JSON.stringify(dbAuthSetupPackageJson, null, 2)
projectPackageJsonPath,
JSON.stringify(projectPackageJson, null, 2)
Tobbe marked this conversation as resolved.
Show resolved Hide resolved
)

await exec(
Expand Down
Loading