Skip to content

Commit

Permalink
♻️ back to non-image support for nuxt2
Browse files Browse the repository at this point in the history
  • Loading branch information
acidjazz committed Sep 2, 2023
1 parent b273e57 commit 08b742d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 5 deletions.
1 change: 1 addition & 0 deletions link-cli-pnpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rm ~/Library/pnpm//fume; ln -s ~/fumeapp/fume-cli/bin/run ~/Library/pnpm/fume
37 changes: 37 additions & 0 deletions src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,42 @@ export default class Deploy extends Command {
},
])


const nuxt2 = new Listr([
{
title: 'Copy fume assets',
task: () => dp.assets(),
enabled: () => !dp.nitro,
},
/*
{
title: 'Send dependencies',
task: () => dp.package(PackageType.layer),
enabled: () => dp.refresh_deps && !dp.nitro,
},
*/
{
title: 'Send source code',
task: () => dp.package(PackageType.code),
enabled: () => !dp.nitro,
},
{
title: 'Restore environment variables',
task: () => dp.envRestore(),
enabled: () => dp.variables.length > 0,
},
{
title: 'Deploy to function',
task: (ctx, task) => dp.deploy('DEPLOY_FUNCTION', task),
},
{
title: 'Cleanup deployment',
task: () => dp.cleanup(),
},
])



const headless = new Listr([
{
title: 'Install modules',
Expand Down Expand Up @@ -267,6 +303,7 @@ export default class Deploy extends Command {
else await ssr.run().catch(error => this.error(error))
}
if (dp.mode === Mode.image) image.run().catch(() => false)
if (dp.mode === Mode.native) await nuxt2.run().catch(error => this.error(error))
if (dp.structure === 'headless') await headless.run().catch(error => this.error(error))
}
if (dp.firstDeploy) this.warn('First deployments take time to propagate - the URL will work in several minutes')
Expand Down
20 changes: 15 additions & 5 deletions src/lib/deploytasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,24 @@ export default class DeployTasks {
}
}

/*
* copy fume assets into project
*/
async assets() {
if (fs.existsSync('./.fume')) fs.rmdirSync('./.fume', {recursive: true})
fs.mkdirSync('./.fume')
fse.copySync(`${__dirname}/../../src/assets/nuxt`, './.fume')
}



async modeSelect(task: any) {
const util = require('util')
const format = '0.0b'
if (this.nitro) {
this.mode = Mode.native

fs.writeFileSync('.output/server/fume.js', `
fs.writeFileSync('.output/server/fume.cjs', `
exports.handler = async (event, context) => {
const { handler } = await import('/var/task/.output/server/index.mjs');
return handler(event, context);
Expand Down Expand Up @@ -110,10 +121,7 @@ exports.handler = async (event, context) => {
pub: 0,
server: 0,
} as Size
this.mode = Mode.image
const allowed = 262_144_000
if (this.refresh_deps && this.size.deps > allowed)
this.mode = Mode.image
this.mode = Mode.native
/*
const error = `Dependencies greater than an allowed size of ${allowed} bytes (${numeral(allowed).format(format)}) - ${this.size.deps} (${numeral(this.size.deps).format(format)})`
this.deployment.fail({
Expand Down Expand Up @@ -485,8 +493,10 @@ exports.handler = async (event, context) => {
'-r',
this.staticDir,
'nuxt.config.js',
'node_modules/',
'fume.yml',
'.nuxt/',
'.fume/',
]))
}
}
Expand Down

0 comments on commit 08b742d

Please sign in to comment.