Skip to content

Commit

Permalink
Minor consistency nitpicks.
Browse files Browse the repository at this point in the history
Session command numbering and missing command.
Highlighting of file and package names.
Sync instructions with shown results.

Pull request: #489
Approved by: metadave
  • Loading branch information
mattray authored and jtimberman committed Jun 12, 2016
1 parent ec3c6e7 commit d7a5fe6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
28 changes: 14 additions & 14 deletions www/source/tutorials/getting-started-create-plan.html.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ To create a plan, do the following:

1. If you still have the terminal window open from the setup step, you should be in the studio and in `/src/plans`; otherwise, open the studio and change to that directory.

[2][default:/src/plans:0]$
[1][default:/src:0]$cd plans

2. Create a new folder and a plan called _mytutorialapp_ by calling the `new-plan` target.
2. Create a new directory and a plan called _mytutorialapp_ by calling the `new-plan` target.

[3][default:/src/plans:0]$make new-plan plan=mytutorialapp
[2][default:/src/plans:0]$make new-plan plan=mytutorialapp

3. Change the directory to the mytutorialapp folder and open plan.sh in your favorite text editor. The filesystem is shared between your host machine and the studio, so you can use any text editor installed on your host machine, or use vim, which is installed in the studio environment. Here's an example of what the plan template creates:
3. Open the `mytutorialapp/plan.sh` file in your favorite text editor. The filesystem is shared between your host machine and the studio, so you can use any text editor installed on your host machine, or use vim, which is installed in the studio environment. Here's an example of what the plan template creates:


pkg_origin=core
Expand Down Expand Up @@ -55,11 +55,11 @@ We now have a skeleton plan, but we need to modify some of its settings before w

> Note: If you modified the source files from the previous step and created your own archive, you will have to compute the sha256 value yourself. If your computed value does not match the value calculated by the hab-plan-build script, an error with the expected value will be returned when you execute your plan.

5. Our Node.js app depends on the node and npm binaries at runtime, so we need to include one of the core Habitat artifacts, `core/node`, as another one of our dependencies. Core Habitat artifacts are maintained by the Habitat team for general artifact building. The default plan also includes a reference to `core/glibc`, but because it is a transitive dependency used by `core/node`, we don't explicitly need to list it.
5. Our Node.js app depends on the `node` and `npm` binaries at runtime, so we need to include one of the core Habitat artifacts, `core/node`, as another one of our dependencies. Core Habitat artifacts are maintained by the Habitat team for general artifact building. The default plan also includes a reference to `core/glibc`, but because it is a transitive dependency used by `core/node`, we don't explicitly need to list it.

pkg_deps=(core/node)

6. Also, because we will be installing the nconf module as part of our package, we need to include the `core/node` as a build dependency. Our source files and other elements of our artifact do not depend on `core/coreutils` to build, so you can simply replace it with a reference to the `core/node` artifact.
6. Also, because we will be installing the `nconf` module as part of our package, we need to include the `core/node` as a build dependency. Our source files and other elements of our artifact do not depend on `core/coreutils` to build, so you can simply replace it with a reference to the `core/node` artifact.

pkg_build_deps=(core/node)

Expand All @@ -77,9 +77,9 @@ You've finished with the basic setup of your plan. It is time to move into defin

## Add in callbacks

Callbacks in a plan are simply overrides to existing functions that are called by the hab-plan-build.sh script at build time. Because our source code in this tutorial relies on the nconf module, we need to make sure it's packaged up in our artifact. Also, our package.json and server.js source files need to move from the the tarball that we referenced in `pkg_source` into our artifact.
Callbacks in a plan are simply overrides to existing functions that are called by the `hab-plan-build.sh` script at build time. Because our source code in this tutorial relies on the `nconf` module, we need to make sure it's packaged up in our artifact. Also, our `package.json` and `server.js` source files need to move from the the tarball that we referenced in `pkg_source` into our artifact.

To do both of those actions, we will implement our own **do_build()** and **do_install()** callbacks. By default, these functions perform simple tasks like calling `make` and `make install`. Add the following function definitions to your plan.sh file below the plan settings.
To do both of those actions, we will implement our own **do_build()** and **do_install()** callbacks. By default, these functions perform simple tasks like calling `make` and `make install`. Add the following function definitions to your `plan.sh` file below the plan settings.

~~~ bash
do_build() {
Expand Down Expand Up @@ -109,15 +109,15 @@ do_install() {
}
~~~

> Note: The first line of the do_build() function is only required because our package name and version do not match the source file name and pkg_prefix refers to the fully-qualified package path directory.
> Note: The first line of the **do_build()** function is only required because our package name and version do not match the source file name and `pkg_prefix` refers to the fully-qualified package path directory.

Here's what your plan.sh should look like in the end:
Here's what your `plan.sh` should look like in the end:

~~~ bash
pkg_origin=myorigin
pkg_name=mytutorialapp
pkg_version=0.0.1
pkg_maintainer="The Habitat Maintainers <humans@habitat.sh>"
pkg_maintainer="Your Name <your email address>"
pkg_license=()
pkg_source=https://s3-us-west-2.amazonaws.com/nodejs-tutorial-app/nodejs-tutorial-app-0.1.0.tar.gz
pkg_shasum=2ad73b78ef5e88e9e916873c0f762bbdf286e4de93e67cf211f9761a2876c7ef
Expand Down Expand Up @@ -161,16 +161,16 @@ As part of building an artifact, you need to have an origin key installed in you

hab origin key generate myorigin

This subcommand will place myorigin-_timestamp.sig.key and myorigin-_timestamp_.pub files in the `/hab/cache/keys` directory. As we said earlier, you use the signature key as part of the artifact signing process and should not be shared freely with anyone; however, if anyone wants to download and use your artifact, then they must have your .pub key installed in their local `/hab/cache/keys` directory.
This subcommand will place myorigin-_timestamp_.sig.key and myorigin-_timestamp_.pub files in the `/hab/cache/keys` directory. As we said earlier, you use the signature key as part of the artifact signing process and should not be shared freely with anyone; however, if anyone wants to download and use your artifact, then they must have your .pub key installed in their local `/hab/cache/keys` directory.

## Do an initial build (optional)
If you want to see your package build in the studio, go back to your terminal window where your studio environment is open, switch to the `/src/plans` directory, and run the following command:

~~~ bash
[155][default:/src/plans:0]$build mytutorialapp
[4][default:/src/plans:0]$build mytutorialapp
~~~

The hab-plan-build.sh script checks dependencies, sets variables, creates a tarball (.hart file) of your package and installs your source files in `/hab/pkgs/origin/packagename/version/release` and your artifact file in `/hab/cache/artifacts`. The artifact is signed using the origin signature key and must match the pkg_origin value in your plan. If you navigate to that folder you will see the source files copied over in the **do_install()** callback as well as the nconf module files.
The `hab-plan-build.sh` script checks dependencies, sets variables, creates a tarball (`.hart` file) of your package and installs your source files in `/hab/pkgs/origin/packagename/version/release` and your artifact file in `/hab/cache/artifacts`. The artifact is signed using the origin signature key and must match the `pkg_origin` value in your plan. If you navigate to that directory you will see the source files copied over in the **do_install()** callback as well as the nconf module files.

Right now, your package builds, but will not do anything at runtime. The next step is to add hooks to your plan. These will copy over the correct files during initialization and start the npm binary.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ title: Review the client source files
---

# Review the source files
The Node.js application in this tutorial is a simple web app that displays a message to anyone who connects to the app's endpoint. You can configure both the listening port and the message that gets displayed. The application contains three files: server.js, package.json, and config.json. You are not expected to take any action in this step; however, it's helpful to understand the source files first before learning how to build, install, and configure them in your plan.
The Node.js application in this tutorial is a simple web app that displays a message to anyone who connects to the app's endpoint. You can configure both the listening port and the message that gets displayed. The application contains three files: `server.js`, `package.json`, and `config.json`. You are not expected to take any action in this step; however, it's helpful to understand the source files first before learning how to build, install, and configure them in your plan.

**server.js**

This is the main file in our web app. It uses the [nconf module](https://github.com/indexzero/nconf) to retrieve the `message` and `port` configuration values that are set in the config.json file.
This is the main file in our web app. It uses the [nconf module](https://github.com/indexzero/nconf) to retrieve the `message` and `port` configuration values that are set in the `config.json` file.

~~~ javascript
var http = require('http'),
Expand Down Expand Up @@ -41,7 +41,7 @@ You can think of this file as the default configuration file that you would use

**package.json**

Because we are using npm to start up our Node.js web app, the npm binary looks for a package.json file to describe the Node.js app project and its dependencies.
Because we are using npm to start up our Node.js web app, the npm binary looks for a `package.json` file to describe the Node.js app project and its dependencies.

~~~ javascript
{
Expand Down

0 comments on commit d7a5fe6

Please sign in to comment.