2020-11-20 00:16:31 +00:00
|
|
|
import { resolve } from 'upath'
|
|
|
|
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) {
|
2020-11-20 00:16:31 +00:00
|
|
|
await writeFile(resolve(output.dir, 'package.json'), JSON.stringify({ private: true, main: './server/index.js' }, null, 2))
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|