Skip to content
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

adds in blog post walkthrough for using the node scaffolding with an … #4074

Closed
wants to merge 2 commits into from

Conversation

nellshamrell
Copy link
Contributor

…angular-seed application

I know that seed frameworks like Angular Seed are falling out of favor and using angular-cli is now preferred, but Habitat is intended both for new and legacy applications. There are a LOT of legacy applications that use Angular Seed, I'm adding this functionality for them,
Signed-off-by: Nell Shamrell [email protected]

…angular-seed application

Signed-off-by: Nell Shamrell <[email protected]>
@thesentinels
Copy link
Contributor

Thanks for the pull request! Here is what will happen next:

  1. Your PR will be reviewed by the maintainers
  2. If everything looks good, one of them will approve it, and your PR will be merged.

Thank you for contributing!

@nellshamrell
Copy link
Contributor Author

@thesentinels acceptance

@thesentinels
Copy link
Contributor

🤘 I am sending your branch against master to our acceptance environment.

@thesentinels
Copy link
Contributor

:neckbeard: Travis CI has started the deployment of acceptance.

@thesentinels
Copy link
Contributor

💖 Travis CI reports acceptance has been deployed.

I love new and shiny websites!

I just want you and the contributor to answer me one question:

gif-keyboard-3280869874741411265

Signed-off-by: Nell Shamrell <[email protected]>
@nellshamrell
Copy link
Contributor Author

@thesentinels acceptance

@thesentinels
Copy link
Contributor

🤘 I am sending your branch against master to our acceptance environment.

@thesentinels
Copy link
Contributor

:neckbeard: Travis CI has started the deployment of acceptance.

@thesentinels
Copy link
Contributor

💖 Travis CI reports acceptance has been deployed.

I love new and shiny websites!

I just want you and the contributor to answer me one question:

gif-keyboard-3280869874741411265

@nellshamrell
Copy link
Contributor Author


Hello my fellow Habicats!

Do you have legacy Angular projects that use [angular-seed](https://github.com/mgechev/angular-seed)? Now you can package them with Habitat using the Node Scaffolding! Let's give it a go!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure "legacy projects that use Angular Seed" makes sense, since Angular Seed is a starter kit. It might be better to consider aiming this at developers of Angular apps rather than strictly those using Angular Seed specifically (many may not -- I actually never have, though I know it's widely referenced), and just use Angular seed as the reference example?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was something I added later on in the process - I've noticed that the moment I mention Angular Seed, someone tends to bring up that Angular does not recommend its use anymore in favor of angular cli. That said, Habitat is intended to be used with legacy applications, and we need a way to support them.

In short, I was trying to preempt the "Well, actually, you shouldn't be using Angular Seed anyway..." comments. I'll consider a better way to word this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's all true, which is why it might be good to tailor this more to a general Angular audience than specifically to Angular Seed or angular-cli, since scaffolding should be able to support either one.

I'm starting to wonder whether we can get away without having some sort of additional configuration setting in which the scaffolding user specifies which npm command should be run for build and start steps. I don't know there's going to be a reliable way to detect whether, for example, build should be run in all cases (because here, it's build.prod) or whether it makes sense to use start as a trigger to create a Habitat service (as here, it isn't, but for a Node app running Express or Koa, it would be). Hrm.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm planning on doing a follow up that highlights angular-cli - I'll mention that at the bottom of this blog post. Do you mind posting your thoughts on additional configuration setup as an issue in core-plans? That way we can track it and continue the conversation :)

While I would LOVE to do a general blog post that covers all things Angular, I think there is too much divergence in how it is used (starter kits vs. yeoman vs. angular-cli) to do a one size fits most (definitely not all!) post at this time. I'd like to have this be the start of a series on packaging Angular apps using the node scaffolding and cover each common way individually (especially since I will likely need to make changes to the scaffolding to accommodate each of them, I haven't tested that yet).

## Pre-requisites
* A Github Account
* NodeJS installed on your workstation
* Angular installed on your workstation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't install Angular on your workstation; it's just bundled up in package.json. You can probably remove this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point!

Do you have legacy Angular projects that use [angular-seed](https://github.com/mgechev/angular-seed)? Now you can package them with Habitat using the Node Scaffolding! Let's give it a go!

## Pre-requisites
* A Github Account
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Darn camel case strikes again...


## Pre-requisites
* A Github Account
* NodeJS installed on your workstation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any minimum version requirement (or maybe a note to refer to the README or package.json)? The angular-seed readme seems to strongly recommend node >=v6.5.0 and npm >=3.10.3 .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add that in!


```console
"typescript": "2.4.2",
"@compodoc/compodoc": "1.0.3",
Copy link
Contributor

@cnunciato cnunciato Nov 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it necessary to downgrade these? I'm sure there's a good reason, so some explanation would be nice and could serve as an opportunity to educate those new to Habitat as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dependency hell is the short version - several of the dependencies in the Angular Seed framework use typescript 2.4.2, but one requires typescript 2.6.0 (@compodoc/compodoc) - I have not been able to get the node scaffolding to accept two different versions of that dependency (and discovered that there are very strong opinions in the Node community around allowing a package.json to require multiple versions of a dependency). I've gone pretty deep into peer dependency land trying to solve this (and barely found my way out). Until all dependencies in Angular Seed require the same version of typescript, this seemed like the most straightforward solution.

I'll have to think on a good way to explain this...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until all dependencies in Angular Seed require the same version of typescript, this seemed like the most straightforward solution.

Ah, this is definitely going to be common, then. But I guess still don't understand why, if you can run npm run build.prod for example (which will ultimately resolve all dependencies, including whatever versions of typescript might be conflicting), we can't do the same with scaffolding.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add that as an issue to core-plans and mention it in the post.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ hab plan init -s node
```

Now let's open up the plan file that was created when we ran "hab init", it should look like this:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hab plan init.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

pkg_scaffolding="core/scaffolding-node"
```

And there is one line we need to add - currently, we need to manually say that we will run Habitat as the root user. Add this line to the plan.sh:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some explanation/elaboration here would be nice as well. (Personally I'd expect that since we'll just be building some JavaScript, we should be able to run this as the default user. Why can't we?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is due to an existing issue with the Supervisor, where it unintentionally resets directory ownership to root #1547. I'll include an explanation and link.

* A Github Account
* NodeJS installed on your workstation
* Angular installed on your workstation
* Habitat installed on your workstation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I happen to be on a new laptop, so I immediately hit the missing sig-key error when I try to enter the studio. We should link off to the appropriate places in the docs so those who haven't installed Habitat already can do that without having to hunt around.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do

@cnunciato
Copy link
Contributor

Nice!

This is a little strange, though, in that while it works, one never actually serves Angular apps in this way in real life (e.g., with a development server); they're compiled into HTML and JavaScript files and served up statically with something like Nginx. I'd sort of strongly suggest we provide a more real-world example for this if we can, since I don't believe we want to advocate this workflow for single-page apps or static web sites in general.


## Starting your application

Start up a docker container running your application with this command:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docker.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will correct!

Start up a docker container running your application with this command:

```console
$ docker run -it -p 5555:5555 core/angular-seed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copy-pasted this without first noticing the core/ in there. Might be good to use your-origin again as you do above and/or make mention of the need to specify your own when you run this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, ty!

Copy link
Contributor

@cnunciato cnunciato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should modify this to explain how to use Habitat to build production-ready assets and serving them statically with a real web server (since this is how it's done for real).

@nellshamrell
Copy link
Contributor Author

Just had a great conversation with @cnunciato about this - who provided some fantastic insight into the way many Angular devs work.

While this workflow is cool for demo purposes, it would be alienating to those who are used to compiling their Angular apps as static assets and then running them through a web server like nginx.

This will likely involve some fundamental rethinking of how the node scaffolding works - but I believe will make it much more powerful. Closing this for now while we rethink that :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants