Skip to content

Latest commit

 

History

History
100 lines (74 loc) · 1.91 KB

00-install-dartfn.md

File metadata and controls

100 lines (74 loc) · 1.91 KB

Installing and using dartfn

dartfn is a command-line (CLI) tool for working with Dart Functions Framework projects. In this early version of the tool, you can use it to generate sample projects from templates. Currently there are three templates:

  • helloworld - a basic HTTP handler function
  • json - a simple function handler that accepts and sends JSON
  • cloudevent - a simple cloudevent function handler

Prerequisites

Install dartfn

To install dartfn on your machine, run the following command:

dart pub global activate dartfn

Output

dart pub global activate functions_framework_tool
Resolving dependencies... (1.2s)
...
Precompiling executables... (1.1s)
Precompiled functions_framework_tool:dartfn.
Installed executable dartfn.
Activated functions_framework_tool 0.3.0.

Using dartfn

List available generators

dartfn generate --list

Output

Available generators:
cloudevent - A sample Functions Framework project for handling a cloudevent.
helloworld - A sample "Hello, World!" Functions Framework project.
json       - A sample Functions Framework project for handling JSON.

Generate a project

Generate a helloworld project, for example:

mkdir helloworld
cd helloworld
dartfn generate helloworld

Output

project: demo
Creating helloworld application `ex`:
  demo/.gitignore
  demo/Dockerfile
  demo/README.md
  demo/analysis_options.yaml
  demo/bin/server.dart
  demo/lib/functions.dart
  demo/pubspec.yaml
  demo/test/function_test.dart
8 files written.

--> to provision required packages, run 'pub get'

Get the new project package dependencies

dart pub get

Output

Resolving dependencies... (2.1s)
...
Changed 74 dependencies!

[toc] [back] [next]