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

Refresh CLI pages #377

Merged
merged 14 commits into from
Jan 4, 2024
104 changes: 104 additions & 0 deletions docs/build-for-developers/cli-installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
title: Using the CLI
sidebar_label: Installation and Updating
slug: /cli-installation
---

## Installation

**To install**

```bash
npm install -g @openfn/cli
```

**Make sure everything works by running the built-in test job**

```bash
openfn test
```

The word `openfn` will invoke the CLI. The word `test` will invoke the test
command.

<details><summary>You should see some output like this:</summary>
mtuchi marked this conversation as resolved.
Show resolved Hide resolved

[CLI] ℹ Versions:
▸ node.js 18.12.1
▸ cli 0.4.11
▸ runtime 0.2.2
▸ compiler 0.0.38
[CLI] ℹ Running test job...
[CLI] ℹ Workflow object:
[CLI] ℹ {
"start": "start",
"jobs": [
{
"id": "start",
"data": {
"defaultAnswer": 42
},
"expression": "const fn = () => (state) => { console.log('Starting computer...'); return state; }; fn()",
"next": {
"calculate": "!state.error"
}
},
{
"id": "calculate",
"expression": "const fn = () => (state) => { console.log('Calculating to life, the universe, and everything..'); return state }; fn()",
"next": {
"result": true
}
},
{
"id": "result",
"expression": "const fn = () => (state) => ({ data: { answer: state.data.answer || state.data.defaultAnswer } }); fn()"
}
]
}

[CLI] ✔ Compilation complete
[R/T] ♦ Starting job start
[JOB] ℹ Starting computer...
[R/T] ℹ Operation 1 complete in 0ms
[R/T] ✔ Completed job start in 1ms
[R/T] ♦ Starting job calculate
[JOB] ℹ Calculating to life, the universe, and everything..
[R/T] ℹ Operation 1 complete in 0ms
[R/T] ✔ Completed job calculate in 1ms
[R/T] ♦ Starting job result
[R/T] ℹ Operation 1 complete in 0ms
[R/T] ✔ Completed job result in 0ms
[CLI] ✔ Result: 42

</details>
All other output is the CLI telling us what it is doing internally
mtuchi marked this conversation as resolved.
Show resolved Hide resolved

**Check the version**

```bash
openfn -v
```

**Get help**

```bash
openfn help
```

## Updating

**You should be able to install a new version straight on top of your current
mtuchi marked this conversation as resolved.
Show resolved Hide resolved
installation**

```bash
npm install -g @openfn/cli
```

**If this fails, try uninstalling the current version first, And then
re-installing.**

```bash
npm uninstall -g @openfn/cli
npm install -g @openfn/cli
```
65 changes: 28 additions & 37 deletions docs/build-for-developers/cli-intro.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,40 @@
---
title: Intro to the OpenFn CLI
title: OpenFn CLI Quick Start
sidebar_label: Intro to CLI
slug: /cli
---

:::info What is this tutorial?
### Introduction

- It's a _hands-on_ way to learn about the new OpenFn CLI. By following the
prompts and "challenges", a developer with a bit of Javascript experience
should be able to write, run, and debug complex, multi-step jobs with OpenFn,
using nothing but a text editor and their terminal.
- The estimated time to finish this developer challenge is 1 to 2 hours
(depending on your familiarity with the underlying concepts and tooling)
- If you are stuck and need help, please post in
[community.openfn.org](https://community.openfn.org/t/about-the-job-writing-category/11/1)
Welcome to the documentation for the @openfn/cli, an essential tool designed for
running workflows locally. It streamlines the execution, building, and testing
of OpenFn workflows for developers.

:::
### Overview

## Intro to the OpenFn CLI
This documentation serves as a comprehensive guide to the
[@openfn/cli](https://www.npmjs.com/package/@openfn/cli), replacing the
deprecated [@openfn/devtools](https://github.com/OpenFn/devtools). It introduces
new features, including:

The [@openfn/cli](https://github.com/OpenFn/kit/tree/main/packages/cli) is a
command line interface for running OpenFn workflows locally. It enables
developers to run, build, and test steps in an OpenFn workflow.
- A new runtime and compiler for executing and creating OpenFn jobs.
- Customizable logging output for enhanced visibility.
- Automatic installation of language adaptors.
- Support for the adaptors monorepo (@openfn/adaptors).

This CLI replaces [@openfn/devtools](https://github.com/OpenFn/devtools) and
provides a new suite of features and improvements, including:
### Before you start

- a new runtime and compiler for executing and creating runnable OpenFn jobs,
- customizable logging output,
- automatic installation of language adaptors,
- and support for the adaptors monorepo
([@openfn/adaptors](https://github.com/OpenFn/adaptors)) where all OpenFn
adaptor source code and documentation lives.
Before you begin with the @openfn/cli, make sure to follow these simple steps:

These features are designed to make it easier and more convenient for developers
to use and understand OpenFn.

:::caution Looking for a way to execute jobs from OpenFn v1 locally? Use Core!

If you're looking for a way to execute jobs running on the OpenFn v1 platform,
please see the documentation for **[@openfn/core](/documentation/core)** and
[Devtools](/documentation/devtools/home).

:::


Learn more about CLI
[github.com/OpenFn/kit/](https://github.com/OpenFn/kit/tree/main/packages/cli)
1. **Code Editor:** Ensure you have a code editor installed on your machine. You
can use popular editors like [VS Code](https://code.visualstudio.com/) or
[Sublime](https://www.sublimetext.com/).
2. **Node.js Installation:** Install Node.js (version 18 or later): - For Linux,
Windows, or macOS, use a version manager like
[nvm](https://github.com/nvm-sh/nvm) or
[asdf](https://asdf-vm.com/guide/getting-started.html). -
[Install Node.js](https://kinsta.com/blog/how-to-install-node-js/) by
following this guide.
3. **Understand OpenFn Basics:** Have a basic understanding of OpenFn,
particularly jobs and adaptors. Check out the
[Intro section](/documentation/next) on this site.
Loading