2021-09-27 12:49:36 +00:00
|
|
|
import { resolve } from 'pathe'
|
2020-11-20 00:16:31 +00:00
|
|
|
import consola from 'consola'
|
|
|
|
import { extendPreset, writeFile, prettyPath } from '../utils'
|
2021-01-22 19:55:59 +00:00
|
|
|
import { NitroContext, NitroPreset } from '../context'
|
2020-11-20 00:16:31 +00:00
|
|
|
import { worker } from './worker'
|
|
|
|
|
2021-01-22 19:55:59 +00:00
|
|
|
export const cloudflare: NitroPreset = extendPreset(worker, {
|
2020-11-20 00:16:31 +00:00
|
|
|
entry: '{{ _internal.runtimeDir }}/entries/cloudflare',
|
|
|
|
ignore: [
|
|
|
|
'wrangler.toml'
|
|
|
|
],
|
|
|
|
hooks: {
|
2021-01-22 19:55:59 +00:00
|
|
|
async 'nitro:compiled' ({ output, _nuxt }: NitroContext) {
|
2021-07-15 09:38:06 +00:00
|
|
|
await writeFile(resolve(output.dir, 'package.json'), JSON.stringify({ private: true, main: './server/index.mjs' }, null, 2))
|
2020-11-20 00:16:31 +00:00
|
|
|
await writeFile(resolve(output.dir, 'package-lock.json'), JSON.stringify({ lockfileVersion: 1 }, null, 2))
|
2020-11-20 12:14:16 +00:00
|
|
|
let inDir = prettyPath(_nuxt.rootDir)
|
|
|
|
if (inDir) {
|
|
|
|
inDir = 'in ' + inDir
|
|
|
|
}
|
|
|
|
consola.success('Ready to run `wrangler publish`', inDir)
|
2020-11-20 00:16:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|