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

Feature Request: CLI build static site #9

Open
stursby opened this Issue Sep 20, 2018 · 9 comments

Comments

Projects
None yet
7 participants
@stursby

stursby commented Sep 20, 2018

Would it be possible to add something like vapid build . to generate the static site? Currently, it looks like you can only deploy via the Vapid hosting.

I see there's a Builder Class but not sure how to implement it. Any ideas/thoughts would be much appreciated.

Thanks for the cool project!

@stursby

This comment has been minimized.

Show comment
Hide comment
@stursby

stursby Sep 20, 2018

Is something like this going in the right direction? Or should I be looking at Generate instead of Build?? 🤔

const Builder = require('./node_modules/vapid-cli/lib/builder.js')
const { resolve } = require('path')

const templatesDir = resolve(__dirname, 'www')

async function build() {
  const builder = new Builder({ templatesDir })
  console.log(builder.tree) // this works! (can see the tree)
  try {
    // await builder.init() do I need this?
    const files = await builder.build()
  } catch (err) {
    console.log(err)
  } 
}

build()

Getting the following Error

TypeError: Cannot read property 'rebuild' of undefined
    at Builder.build (/Users/hield/Desktop/__SCRAP__/vapid-demo/node_modules/vapid-cli/lib/builder.js:43:37)
    at build (/Users/hield/Desktop/__SCRAP__/vapid-demo/build.js:11:33)
    at Object.<anonymous> (/Users/hield/Desktop/__SCRAP__/vapid-demo/build.js:17:1)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)

stursby commented Sep 20, 2018

Is something like this going in the right direction? Or should I be looking at Generate instead of Build?? 🤔

const Builder = require('./node_modules/vapid-cli/lib/builder.js')
const { resolve } = require('path')

const templatesDir = resolve(__dirname, 'www')

async function build() {
  const builder = new Builder({ templatesDir })
  console.log(builder.tree) // this works! (can see the tree)
  try {
    // await builder.init() do I need this?
    const files = await builder.build()
  } catch (err) {
    console.log(err)
  } 
}

build()

Getting the following Error

TypeError: Cannot read property 'rebuild' of undefined
    at Builder.build (/Users/hield/Desktop/__SCRAP__/vapid-demo/node_modules/vapid-cli/lib/builder.js:43:37)
    at build (/Users/hield/Desktop/__SCRAP__/vapid-demo/build.js:11:33)
    at Object.<anonymous> (/Users/hield/Desktop/__SCRAP__/vapid-demo/build.js:17:1)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
@trst

This comment has been minimized.

Show comment
Hide comment
@trst

trst Sep 21, 2018

It would be doubly awesome to have a way to generate a static site from the dashboard interface as well.

trst commented Sep 21, 2018

It would be doubly awesome to have a way to generate a static site from the dashboard interface as well.

@KeizerDev

This comment has been minimized.

Show comment
Hide comment
@KeizerDev

KeizerDev Sep 21, 2018

This is for me a MUST to use it in production. I want to deploy it to my vps.

KeizerDev commented Sep 21, 2018

This is for me a MUST to use it in production. I want to deploy it to my vps.

@srobbin srobbin added the feature label Sep 22, 2018

@srobbin

This comment has been minimized.

Show comment
Hide comment
@srobbin

srobbin Sep 23, 2018

Contributor

@stursby: Thanks for bringing this up. Answers inline (slightly reordered):

Currently, it looks like you can only deploy via the Vapid hosting.

True, vapid deploy posts to the Vapid hosting service, but you can definitely host Vapid elsewhere, like Heroku or any service that supports Node.js. So in that sense, you can deploy anywhere.

Would it be helpful if Vapid let you override vapid deploy so that it acted as some sort of alias to an NPM script? e.g. If vapid deploy kicked off git push heroku master?

Would it be possible to add something like vapid build . to generate the static site?

I'm curious to hear more about your use case (and from @trst and @KeizerDev too). Are you planning to use Vapid's dashboard to edit content on your production server? What is appealing about using Vapid over one of the existing static site generators, like Jekyll or Middleman?

I see there's a Builder Class but not sure how to implement it. Any ideas/thoughts would be much appreciated. Getting the following Error: TypeError: Cannot read property 'rebuild' of undefined

The error is happening because Builder is looking for the Section model, which gets passed into the constructor. In any case, I'm not sure that Builder is isolated enough to be used as a standalone class, like your example.

Let's chat about the first two points, and then hopefully I can shed some more light on the third.

Contributor

srobbin commented Sep 23, 2018

@stursby: Thanks for bringing this up. Answers inline (slightly reordered):

Currently, it looks like you can only deploy via the Vapid hosting.

True, vapid deploy posts to the Vapid hosting service, but you can definitely host Vapid elsewhere, like Heroku or any service that supports Node.js. So in that sense, you can deploy anywhere.

Would it be helpful if Vapid let you override vapid deploy so that it acted as some sort of alias to an NPM script? e.g. If vapid deploy kicked off git push heroku master?

Would it be possible to add something like vapid build . to generate the static site?

I'm curious to hear more about your use case (and from @trst and @KeizerDev too). Are you planning to use Vapid's dashboard to edit content on your production server? What is appealing about using Vapid over one of the existing static site generators, like Jekyll or Middleman?

I see there's a Builder Class but not sure how to implement it. Any ideas/thoughts would be much appreciated. Getting the following Error: TypeError: Cannot read property 'rebuild' of undefined

The error is happening because Builder is looking for the Section model, which gets passed into the constructor. In any case, I'm not sure that Builder is isolated enough to be used as a standalone class, like your example.

Let's chat about the first two points, and then hopefully I can shed some more light on the third.

@KeizerDev

This comment has been minimized.

Show comment
Hide comment
@KeizerDev

KeizerDev Sep 24, 2018

I'm curious to hear more about your use case (and from @trst and @KeizerDev too). Are you planning to use Vapid's dashboard to edit content on your production server? What is appealing about using Vapid over one of the existing static site generators, like Jekyll or Middleman?

I would like to use the Vapid dashboard locally to maintain multiple sites and when I'm done I would deploy them on my vps like you would do with Jekyll. What I like about Vapid instead of Jekyll (I have no experience with middleman so can't say anything about that) is the way of just declaring a variable and then fill them with your data instead of the otherway around like you do in Jekyll. Same for articles (repeating content), it's a cleaner and more flexible way of working imho. Also one extra thing I really like and was looking for for a long time is just one dashboard to manage multiple sites.

I would like to have some command like vapid build to just generate static html/css so I can serve it with apache/nginx and not have to worry about anything else like hosting an admin panel or again another service to hosts my sites on (i'd like to keep my own control over what I host).

Maybe this is not the way you designed it or not the way you liked it to be, this is just how it would suit for me and how I would liked it to be.

Let me know what you think @srobbin

KeizerDev commented Sep 24, 2018

I'm curious to hear more about your use case (and from @trst and @KeizerDev too). Are you planning to use Vapid's dashboard to edit content on your production server? What is appealing about using Vapid over one of the existing static site generators, like Jekyll or Middleman?

I would like to use the Vapid dashboard locally to maintain multiple sites and when I'm done I would deploy them on my vps like you would do with Jekyll. What I like about Vapid instead of Jekyll (I have no experience with middleman so can't say anything about that) is the way of just declaring a variable and then fill them with your data instead of the otherway around like you do in Jekyll. Same for articles (repeating content), it's a cleaner and more flexible way of working imho. Also one extra thing I really like and was looking for for a long time is just one dashboard to manage multiple sites.

I would like to have some command like vapid build to just generate static html/css so I can serve it with apache/nginx and not have to worry about anything else like hosting an admin panel or again another service to hosts my sites on (i'd like to keep my own control over what I host).

Maybe this is not the way you designed it or not the way you liked it to be, this is just how it would suit for me and how I would liked it to be.

Let me know what you think @srobbin

@abcroes

This comment has been minimized.

Show comment
Hide comment
@abcroes

abcroes Sep 25, 2018

i need this!

abcroes commented Sep 25, 2018

i need this!

@trst

This comment has been minimized.

Show comment
Hide comment
@trst

trst Sep 25, 2018

If it were just for me, I might stick to a static generator, like Jekyll, however, I think Vapid really does benefit a client with less technical savvy than a developer. I would like to give clients an easy to update solution with the option to build statically for security purposes. These static files could be stored in a git repository through a cron job (or whatever), in case I have to roll back later on.

In a more technical team, it would be nice to just store the whole thing in git, clone the repository, fire it up locally to create content changes (or add a blog post, etc.), build it locally before committing or triggering a build via something like Netlify, and pulling in and serving the static files on a server via a webhook. That way the team can always keep the source material up to date without requiring too much heavy lifting from a server or exposing the possibility of a security breach of a dynamic interface.

Not to say that your security is poor, rather that I would just like to limit the attack surface as much as possible. Having flashbacks atm 😅

trst commented Sep 25, 2018

If it were just for me, I might stick to a static generator, like Jekyll, however, I think Vapid really does benefit a client with less technical savvy than a developer. I would like to give clients an easy to update solution with the option to build statically for security purposes. These static files could be stored in a git repository through a cron job (or whatever), in case I have to roll back later on.

In a more technical team, it would be nice to just store the whole thing in git, clone the repository, fire it up locally to create content changes (or add a blog post, etc.), build it locally before committing or triggering a build via something like Netlify, and pulling in and serving the static files on a server via a webhook. That way the team can always keep the source material up to date without requiring too much heavy lifting from a server or exposing the possibility of a security breach of a dynamic interface.

Not to say that your security is poor, rather that I would just like to limit the attack surface as much as possible. Having flashbacks atm 😅

@pbuzdin

This comment has been minimized.

Show comment
Hide comment
@pbuzdin

pbuzdin Sep 25, 2018

Static builds would be awesome

pbuzdin commented Sep 25, 2018

Static builds would be awesome

@Jack89ita

This comment has been minimized.

Show comment
Hide comment
@Jack89ita

Jack89ita Sep 28, 2018

Absolutely a must have feature in my opinion.

Jack89ita commented Sep 28, 2018

Absolutely a must have feature in my opinion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment