10000 chore: use `compiled` hook from nitro to final build event by atinux · Pull Request #338 · nuxt-hub/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore: use compiled hook from nitro to final build event #338

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

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Changes from all commits
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
36 changes: 19 additions & 17 deletions src/utils/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,26 @@ export function addBuildHooks(nuxt: Nuxt, hub: HubConfig) {
})
})

nuxt.hook('build:done', async () => {
await $fetch(`/api/projects/${process.env.NUXT_HUB_PROJECT_KEY}/build/${process.env.NUXT_HUB_ENV}/done`, {
baseURL: hub.url,
method: 'POST',
headers: {
authorization: `Bearer ${process.env.NUXT_HUB_PROJECT_DEPLOY_TOKEN}`
},
body: {
pagesUrl: process.env.CF_PAGES_URL
}
}).catch((e) => {
if (e.response?._data?.message) {
log.error(e.response._data.message)
} else {
log.error('Failed run build:done hook on NuxtHub.', e)
}
nuxt.hook('nitro:init', async (nitro) => {
nitro.hooks.hook('compiled', async () => {
await $fetch(`/api/projects/${process.env.NUXT_HUB_PROJECT_KEY}/build/${process.env.NUXT_HUB_ENV}/done`, {
baseURL: hub.url,
method: 'POST',
headers: {
authorization: `Bearer ${process.env.NUXT_HUB_PROJECT_DEPLOY_TOKEN}`
},
body: {
pagesUrl: process.env.CF_PAGES_URL
}
}).catch((e) => {
if (e.response?._data?.message) {
log.error(e.response._data.message)
} else {
log.error('Failed run build:done hook on NuxtHub.', e)
}

process.exit(1)
process.exit(1)
})
})
})
} else {
Expand Down
0