Skip to content

Commit f5f6152

Browse files
committed
getting started, cont.
1 parent 2a4d204 commit f5f6152

File tree

3 files changed

+75
-36
lines changed

3 files changed

+75
-36
lines changed

docs/getting-started.md

Lines changed: 72 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@
1313

1414
# Getting started
1515

16-
Welcome! This tutorial will guide your first steps with Observable Framework. (We’ll refer to it as “Framework” for short.) If you follow this tutorial to the end, you’ll have a live dashboard ready to share. 🚀
16+
Welcome! This tutorial will guide your first steps with Observable Framework. (We call it “Framework” for short.) Framework is a new way of building data apps that combines the power of JavaScript for interactive graphics on the front-end with any language you want on the back-end for data preparation and analysis.
1717

18-
Before we begin, let’s review the development workflow, end-to-end. Framework is a **local development server**, a **static site generator**, and a **command-line interface** to Observable, all rolled into one!
18+
In this tutorial, you’ll create a live dashboard of your local weather. 🌦️ But before we begin, let’s first review the end-to-end development workflow. Framework is three things in one:
19+
20+
- a **local development server** that you use to preview your project locally during development, with instant updates as you save changes,
21+
- a **static site generator** that compiles your Markdown, JavaScript, and other sources and static assets — alongside data snapshots generated dynamically by loaders — into a static site that you can host anywhere, and
22+
- a **command-line interface** to Observable so that you can quickly and securely share your site with your team (or the world, or whoever).
23+
24+
We’ll touch on each of these parts in this tutorial.
1925

2026
```js
2127
const digraph = dot`digraph {
@@ -45,56 +51,81 @@ const digraph = dot`digraph {
4551
<figcaption>An overview of the development workflow.</figcaption>
4652
</figure>
4753

48-
You’ll first [**create**](#2.-create) a new project, setting up your local development environment.
54+
You’ll first setup your local development environment by [**creating**](#2.-create) a new project.
4955

50-
Next you’ll [**develop**](#3.-develop). This is an iterative process where you save changes to Markdown and other source files in your preferred editor, and then preview the result running locally in your browser.
56+
Next you’ll [**develop**](#3.-develop). This is an iterative process where you save changes to source files in your editor, and then preview the result running locally in your browser.
5157

52-
When you’re ready to share with your team (or the world), it’s time to [**publish**](#4.-publish). You can either build a static site for self-hosting or hosting on a third-party such as GitHub or Netlify, or you can deploy directly to Observable.
58+
When you’re ready to share your work, it’s time to [**publish**](#4.-publish). You can either build a static site for self-hosting or you can deploy directly to Observable.
5359

5460
Lastly, you can invite people to [**view**](#5.-view) your project!
5561

62+
Of course, you can continue to develop your project after you publish, and then republish to make these changes live. And you can setup continuous deployment so that your site re-builds whenever you push a commit or on a fixed schedule. We’ll cover these [next steps](#next-steps) briefly below.
63+
64+
Here we go… 🚀
65+
5666
## 1. Create
5767

58-
<div class="tip">Observable Framework is a <a href="https://nodejs.org/">Node.js</a> application. You must have <a href="https://nodejs.org/en/download">Node.js 20.6 or later</a> installed before you can install Framework.</div>
68+
Observable Framework includes a helper script, `observable create`, for creating new projects. After a few quick prompts — where to create the project, your preferred package manager, *etc.* — it will create a fresh project from a template.
5969

60-
To create a new project, you can use `npm`:
70+
<div class="tip">Observable Framework is a <a href="https://nodejs.org/">Node.js</a> application. You must have <a href="https://nodejs.org/en/download">Node.js 20.6 or later</a> installed before you can install Framework. Observable Framework is a command-line interface (CLI) and runs in the terminal.</div>
71+
72+
To create a new project with `npm`, run:
6173

6274
```sh
6375
npm init @observablehq
6476
```
6577

66-
Or if you prefer `yarn`:
78+
Or to create a new project with `yarn`, run:
6779

6880
```sh
6981
yarn create @observablehq
7082
```
7183

72-
This runs `observable create`, our helper script for creating new projects. You will be asked several questions, starting with where to create the new project.
84+
You can run the above command anywhere, but maybe `cd` to your `~/Development` directory first (or wherever you do local development).
85+
86+
First you’ll need to specify where to create the new project. For this tutorial, we want to create a folder called `local-weather` within the current directory, so enter `./local-weather` at the prompt. (This path is equivalent to `local-weather`; we’re just showing that you can use `../` or `/` or `~/` to create a project anywhere.)
7387

7488
<pre><span class="muted">┌</span> <span class="invert"> observable create </span>
7589
<span class="muted">│</span>
7690
<span class="focus">◆</span> Where to create your project?
77-
<span class="focus">│</span> <span class="muted"><span class="invert">.</span>/demo-project</span>
91+
<span class="focus">│</span> ./local-weather<span class="invert">&nbsp;</span>
92+
<span class="focus">└</span></pre>
93+
94+
Next you’ll need to enter a project title. The title appears in the sidebar as well as on pages. (A memorable name will make your project easier to find in your browser history, for one.) You can just hit Enter here to accept the default title derived from the directory you entered in the previous step.
95+
96+
<pre><span class="muted">┌</span> <span class="invert"> observable create </span>
97+
<span class="muted">│</span>
98+
<span class="green">◇</span> Where to create your project?
99+
<span class="muted">│</span> <span class="muted">./local-weather</span>
100+
<span class="muted">│</span>
101+
<span class="focus">◆</span> What to title your project?
102+
<span class="focus">│</span> <span class="muted"><span class="invert">L</span>ocal Weather</span>
78103
<span class="focus">└</span></pre>
79104

80-
We’ll use the name `./hello-framework` for our project folder.
105+
Next, you can decide whether to include sample files in your new project. These sample files will demonstrate a few tricks, and are handy for learning by tinkering, since you can just edit the code and see what happens. But if you’d prefer a more minimal starter project, you can chose to omit them. We recommend you include them (again, learning), but they’re not needed for this tutorial.
81106

82107
<pre><span class="muted">┌</span> <span class="invert"> observable create </span>
83108
<span class="muted">│</span>
84109
<span class="green">◇</span> Where to create your project?
85-
<span class="muted">│</span> <span class="muted">./hello-framework</span>
110+
<span class="muted">│</span> <span class="muted">./local-weather</span>
111+
<span class="muted">│</span>
112+
<span class="green">◇</span> What to title your project?
113+
<span class="muted">│</span> <span class="muted">Local Weather</span>
86114
<span class="muted">│</span>
87115
<span class="focus">◆</span> Include sample files to help you get started?
88116
<span class="focus">│</span> <span class="green">●</span> Yes, include sample files <span class="muted">(recommended)</span>
89117
<span class="focus">│</span> <span class="muted">○ No, create an empty project</span>
90118
<span class="focus">└</span></pre>
91119

92-
120+
If you use `npm` or `yarn` as your preferred package manager, you should now declare your allegiance. If you’re not sure, chose `npm`. If you prefer a different package manager (say `pnpm`), choose `No`, and then you can install dependencies yourself after the project is created.
93121

94122
<pre><span class="muted">┌</span> <span class="invert"> observable create </span>
95123
<span class="muted">│</span>
96124
<span class="green">◇</span> Where to create your project?
97-
<span class="muted">│</span> <span class="muted">./hello-framework</span>
125+
<span class="muted">│</span> <span class="muted">./local-weather</span>
126+
<span class="muted">│</span>
127+
<span class="green">◇</span> What to title your project?
128+
<span class="muted">│</span> <span class="muted">Local Weather</span>
98129
<span class="muted">│</span>
99130
<span class="green">◇</span> Include sample files to help you get started?
100131
<span class="muted">│</span> <span class="muted">Yes, include sample files</span>
@@ -105,14 +136,15 @@ We’ll use the name `./hello-framework` for our project folder.
105136
<span class="focus">│</span> <span class="muted">○ No</span>
106137
<span class="focus">└</span></pre>
107138

108-
If you choose a package manager here, we’ll automatically install dependencies when the project is created. If you want to use something besides `npm` or `yarn`, we’ll leave it to you.
109-
110-
139+
If you’re going to develop this dashboard further, you’ll likely want source control to track changes and collaborate. Answer `Yes` to initialize a git repository for your no project. This is optional, and you can always do it later by running `git init`.
111140

112141
<pre><span class="muted">┌</span> <span class="invert"> observable create </span>
113142
<span class="muted">│</span>
114143
<span class="green">◇</span> Where to create your project?
115-
<span class="muted">│</span> <span class="muted">./hello-framework</span>
144+
<span class="muted">│</span> <span class="muted">./local-weather</span>
145+
<span class="muted">│</span>
146+
<span class="green">◇</span> What to title your project?
147+
<span class="muted">│</span> <span class="muted">Local Weather</span>
116148
<span class="muted">│</span>
117149
<span class="green">◇</span> Include sample files to help you get started?
118150
<span class="muted">│</span> <span class="muted">Yes, include sample files</span>
@@ -124,12 +156,15 @@ If you choose a package manager here, we’ll automatically install dependencies
124156
<span class="focus">│</span> <span class="green">●</span> Yes <span class="muted">/ ○ No</span>
125157
<span class="focus">└</span></pre>
126158

127-
159+
And that’s it! After copying some files and installing some dependencies, your new project will be ready to go! 🎉
128160

129161
<pre><span class="muted">┌</span> <span class="invert"> observable create </span>
130162
<span class="muted">│</span>
131163
<span class="green">◇</span> Where to create your project?
132-
<span class="muted">│</span> <span class="muted">./hello-framework</span>
164+
<span class="muted">│</span> <span class="muted">./local-weather</span>
165+
<span class="muted">│</span>
166+
<span class="green">◇</span> What to title your project?
167+
<span class="muted">│</span> <span class="muted">Local Weather</span>
133168
<span class="muted">│</span>
134169
<span class="green">◇</span> Include sample files to help you get started?
135170
<span class="muted">│</span> <span class="muted">Yes, include sample files</span>
@@ -140,30 +175,34 @@ If you choose a package manager here, we’ll automatically install dependencies
140175
<span class="green">◇</span> Initialize a git repository?
141176
<span class="muted">│</span> <span class="muted">Yes</span>
142177
<span class="muted">│</span>
143-
<span class="green">◇</span> Installed!
178+
<span class="green">◇</span> Installed! 🎉
144179
<span class="muted">│</span>
145180
<span class="green">◇</span> Next steps…
146181
<span class="muted">│</span>
147-
<span class="muted">│</span> <span class="focus">cd ./hello-framework</span>
182+
<span class="muted">│</span> <span class="focus">cd ./local-weather</span>
148183
<span class="muted">│</span> <span class="focus">yarn dev</span>
149184
<span class="muted">│</span>
150-
<span class="muted">└</span> Problems? <u>https://framework.observablehq.com/getting-started</u></pre>
185+
<span class="muted">└</span> Problems? <u>https://cli.observablehq.com/getting-started</u></pre>
151186

152-
After answering a few questions, this command will create a new project folder in the current working directory.
187+
<div class="tip">If you have any issues creating a new project, please visit the <a href="https://talk.observablehq.com">Observable Forum</a> or our <a href="https://github.com/observablehq/cli/discussions">GitHub discussions</a> to ask for help.</div>
153188

154-
```sh
155-
cd hello-world
156-
```
189+
## 3. Develop
190+
191+
If you haven’t already, `cd` into your new project folder.
157192

158193
```sh
159-
yarn
194+
cd local-weather
160195
```
161196

162-
## 3. Develop
197+
In preview mode, Framework generates HTML pages on-demand as you view a local version of your site in the browser. As you edit files, changes will be instantly reflected in the browser.
163198

164-
After you’ve initialized your project, you can start developing locally. In preview mode, Framework generates HTML pages on-demand as you view a local version of your site in the browser. As you edit files, changes will be instantly reflected in the browser.
199+
To start the preview server using `npm`:
200+
201+
```sh
202+
npm run dev
203+
```
165204

166-
To start the preview server:
205+
Or to start the preview server using `yarn`:
167206

168207
```sh
169208
yarn dev
@@ -210,11 +249,11 @@ You can schedule builds and deploy your project automatically on commit, or on a
210249
You can install Framework as a dependency on an existing project if you don’t want to create a new project using our default template as described above.
211250

212251
```sh
213-
npm install @observablehq/framework
252+
npm install @observablehq/cli
214253
```
215254

216255
```sh
217-
yarn add @observablehq/framework
256+
yarn add @observablehq/cli
218257
```
219258

220259
You can also install Framework globally so that the `observable` command is available across projects, but we don’t recommend this approach. By installing Framework into each project, everyone you work with will use the same version.

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ toc: false
2626

2727
</style>
2828

29-
**Observable Framework** is an [open-source](https://github.com/observablehq/cli) static site generator for data apps, dashboards, reports, and more. Framework includes a preview server for local development, and a command-line interface for automating build & deploy.
29+
**Observable Framework** is an [open-source](https://github.com/observablehq/cli) static site generator for data apps, dashboards, reports, and more. Framework includes a preview server for local development, and a command-line interface for automating builds & deploys.
3030

31-
You write simple [Markdown](./markdown) pages — with interactive charts and inputs in [reactive JavaScript](./javascript), and data snapshots generated by [loaders](./loaders) in any programming language (SQL, Python, R, and more) — and Framework compiles it into a static site with instant page loads for a great user experience. Since everything is just files, you can use your preferred editor and source control, write unit tests, share code with other apps, integrate with CI/CD, and host projects anywhere.
31+
You write simple [Markdown](./markdown) pages — with interactive charts and inputs in [reactive JavaScript](./javascript), and with data snapshots generated by [loaders](./loaders) in _any_ programming language (SQL, Python, R, and more) — and Framework compiles it into a static site with instant page loads for a great user experience. Since everything is just files, you can use your preferred editor and source control, write unit tests, share code with other apps, integrate with CI/CD, and host projects anywhere.
3232

3333
Framework includes thoughtfully-designed [themes and components](./components) to help you build displays of data that look great on any device. And you can quickly craft custom components using open-source libraries such as [Observable Plot](./lib/plot), [D3.js](./lib/d3), [Vega-Lite](./lib/vega-lite), [Graphviz](./lib/graphviz), [Mermaid](./lib/mermaid), [Leaflet](./lib/leaflet), [KaTeX](./lib/tex), and myriad more. (And for working with data, don’t forget about [Arquero](./lib/arquero), [DuckDB](./lib/duckdb), and [SQLite](./lib/sqlite), too.)
3434

src/create.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export async function create(options = {}, effects: CreateEffects = defaultEffec
113113
await promisify(exec)("git init", {cwd: rootPath});
114114
await promisify(exec)("git add -A", {cwd: rootPath});
115115
}
116-
s.stop("Installed!");
116+
s.stop("Installed! 🎉");
117117
const instructions = [`cd ${rootPath}`, ...(packageManager ? [] : [installCommand]), `${runCommand} dev`];
118118
clack.note(instructions.map((line) => reset(cyan(line))).join("\n"), "Next steps…");
119119
clack.outro(`Problems? ${underline("https://cli.observablehq.com/getting-started")}`);

0 commit comments

Comments
 (0)