• Stars
    star
    153
  • Rank 243,368 (Top 5 %)
  • Language
    F#
  • Created over 5 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Femto is a CLI tool that automatically resolves npm packages used by Fable bindings

Femto Nuget

Femto is CLI tool that manages the npm/python packages used by Fable bindings. It installs them using the package manager that you are using whether that is:

  • npm (default)
  • yarn when yarn.lock is found
  • pnpm when pnpm-lock.yaml is detected
  • poetry when pyproject.toml is detected

Read Introducing Femto for an in-depth understanding of why Femto is needed and what problem it solves.

Install

dotnet tool install femto --global

Project Dependency Analysis

Simply cd your way to the directory where you have your Fable application and run

femto

Alternatively, you can specify a project file by yourself:

femto ./Client.fsproj

Here is an example output (note package.json can be alongside the project or in a directory above):

c:\projects\elmish-getting-started\src> femto
[18:17:09 INF] Analyzing project c:/projects/elmish-getting-started/src/App.fsproj
[18:17:11 INF] Found package.json in c:\projects\elmish-getting-started
[18:17:11 INF] Using npm for package management
[18:17:14 INF] Elmish.AnimatedTree requires npm package react-spring
[18:17:14 INF]   | -- Required range >= 8.0.0 found in project file
[18:17:14 INF]   | -- Used range ^8.0.1 in package.json
[18:17:14 INF]   | -- Found installed version 8.0.1
[18:17:14 INF]   | -- react-spring was installed into "devDependencies" instead of "dependencies"
[18:17:14 INF]   | -- Re-install as a production dependency
[18:17:14 INF]   | -- Resolve manually using 'npm uninstall react-spring' then 'npm install [email protected] --save'
[18:17:14 INF] Fable.DateFunctions requires npm package date-fns
[18:17:14 INF]   | -- Required range >= 1.30 < 2.0 found in project file
[18:17:14 INF]   | -- Missing date-fns in package.json
[18:17:14 INF]   | -- Resolve manually using 'npm install [email protected] --save'
[18:17:14 INF] Elmish.SweetAlert requires npm package sweetalert2
[18:17:14 INF]   | -- Required range >= 8.5 found in project file
[18:17:14 INF]   | -- Missing sweetalert2 in package.json
[18:17:14 INF]   | -- Resolve manually using 'npm install [email protected] --save'

Automatic Package resolution with --resolve

Femto can automagically resolve required package issues using the command --resolve:

femto --resolve

femto --resolve ./src/Client.fsproj

This command checks for missing packages and packages of which the installed version does not satisfy the required version found in npm dependency metadata of the used Fable packages.

  • If a package is missing then it is installed.
  • If a package version doesn't satisfy requirements, then a proper version is resolved and the package is replaced with the new resolved version by uninstalling the current one and installing the correct package.
  • If a package version doesn't satisfy requirements and a version cannot be resolved that satisfies requirements, then a resolution error is logged.

Installing Packages with femto install <package>

Femto can install a package for a project whether it is using paket or not then automatically resolves the required npm packages afterwards. Simply navigate to a project where there is a fsharp/Fable project and call

femto install <package>

First, Femto detects whether it needs to use paket by checking the existence of a paket.references file, if that is the case then Femto also detects in which dependency group the package has to be installed and eventually calls the installed paket instance to install the package. Afterwards, Femto calls --resolve to install potentially required npm packages. When there is no paket.references file, then Femto simply calls dotnet add package <package> and then femto --resolve in the project directory.

When Femto cannot find paket installed as a global dotnet tool nor as a local installation from the paket bootstrapper under .paket/paket.exe, then Femto will install it locally following these Paket gettings started guidelines and restarts the installation process.

Uninstalling Packages with femto uninstall <package>

Same as when installing a package, Femto will instruct either nuget or paket to uninstall the package except this command does not remove unused packages from npm in package.json because Femto cannot know whether the package is being used multiple projects.

Library Authors with JavaScript

In order for Femto to pick up the npm packages that your library depends upon, you must add a section in the project file of your library:

<PropertyGroup>
  <NpmDependencies>
      <NpmPackage Name="date-fns" Version="gt 1.30.0 lt 2.0.0" ResolutionStrategy="Max" />
  </NpmDependencies>
</PropertyGroup>

Notice here in the example, we have one npm package we depend upon which has requires a version that satisfies the range gt 1.30.0 lt 2.0.0 and the resolution strategy is max. This means that Femto will find the version in this current major release with latest bug fixes but nothing in the next release because we cannot assume the binding will still work in the next major release which will most likely contain breaking changes. It is recommended to always follow the format above when specifying the version requirements.

Library Authors with Python

Defining Python dependencies in your project as follows:

<PropertyGroup>
  <PythonDependencies>
    <Package Name="requests" Version="&gt;= 2.28.1 &lt; 3.0.0" ResolutionStrategy="Max" />
  </PythonDependencies>
</PropertyGroup>

Resolution Strategy

You can customize the resolution strategy by adding ResolutionStrategy attribute to an NpmPackage node. Accepted values are min and max (case-insensitive). If ResolutionStrategy is not set, we default to min strategy.

Development Dependency

You can specify whether the npm package your library depends upon is actually a development dependency instead a production dependency using the DevDependency attribute. Package resolution take development dependencies into account and if the developer had installed the package by mistake in production dependencies then the automatic resolver will un-install it and re-install it a development dependency.

<PropertyGroup>
  <NpmDependencies>
      <NpmPackage Name="date-fns" Version="gt 1.30.0 lt 2.0.0" ResolutionStrategy="Max" DevDependency="true" />
  </NpmDependencies>
</PropertyGroup>

Unsupported Version Ranges

Sometimes you want to restrict the version using a specific range such as >= 1.0 < 2 This range cannot be set inside the attribute value of Version because the XML would be invalid and you would not be able to dotnet restore the project. In these cases you can replace the operator with it's abbreviated name:

  • >= becomes gte
  • > become gt
  • <= becomes lte
  • < becomes lt

This way you can specify your version range as gte 1.0 lt 2 or you can mix-and-match the notations >= 1.0 lt 2

Visual Studio Users

If you happen to use Visual Studio to build your library, it will escape symbols like >= or > from the project and turn them into &gt;= or &gt;. Don't worry about this because Femto can still understand the underlying symbols. To make sure everything still works, run femto --validate (see below) against your project and you should see the same results.

Validate your dependencies

If you are a library author and wondering whether Femto will pick up the dependencies you specified in your project file, then simply run:

femto --validate

femto --validate ./path/to/Library.fsproj

In the directory where you have the project file of your library. This command will check whether the library has valid metadata about the required npm packages and will try to resolve the versions based on the specified ResolutionStrategy.

More Repositories

1

Feliz

A fresh retake of the React API in Fable and a collection of high-quality components to build React applications in F#, optimized for happiness
F#
533
star
2

the-elmish-book

A practical guide to building modern and reliable web applications in F# from first principles
HTML
338
star
3

Npgsql.FSharp

Thin F# wrapper around Npgsql, the PostgreSQL database driver for .NET
F#
318
star
4

Fable.Remoting

Type-safe communication layer (RPC-style) for F# featuring Fable and .NET Apps
F#
273
star
5

tabula-rasa

Minimalistic real-worldish blogging platform, written entirely in F#, made as a learning reference for building large Elmish apps
F#
199
star
6

LiteDB.FSharp

Advanced F# Support for LiteDB, an embedded NoSql database for .NET with type-safe query expression through F# quotations
F#
179
star
7

Snowflaqe

A dotnet CLI to generate type-safe GraphQL clients for F# and Fable with automatic deserialization, static query verification and type checking
F#
150
star
8

ThrowawayDb

Dead simple integration tests with SQL Server or Postgres throwaway databases that are created on the fly, used briefly then disposed of automagically.
C#
140
star
9

Npgsql.FSharp.Analyzer

F# analyzer that provides embedded SQL syntax analysis, type-checking for parameters and result sets and nullable column detection when writing queries using Npgsql.FSharp.
C#
132
star
10

Hawaii

dotnet CLI tool to generate type-safe F# and Fable clients from OpenAPI/Swagger or OData services
F#
122
star
11

SAFE.Simplified

A lightweight alternative template of SAFE for happy cross-IDE full-stack F# development
F#
101
star
12

Fable.SimpleHttp

Http with Fable, made simple.
F#
82
star
13

ClosedXML.SimpleSheets

Easily generate Excel sheets from F#
F#
80
star
14

DustyTables

Thin F# API for SqlClient for easy data access to ms sql server with functional seasoning on top
F#
74
star
15

Giraffe.GoodRead

Practical dependency injection in Giraffe that gets out of your way
F#
73
star
16

Feliz.Router

A router component for React and Elmish that is focused, powerful and extremely easy to use.
F#
72
star
17

Fable.SimpleJson

A library for working with JSON in Fable projects
F#
56
star
18

SAFE.React

Full Stack F# powered by ASP.NET Core on the backend and modern React on the frontend.
F#
54
star
19

Fable.Mocha

Fable library for a proper testing story using different runners such as mocha, standalone browsers and dotnet
F#
51
star
20

fabulous-simple-elements

An alternative view rendering API for Fabulous (Elmish Xamarin.Forms) that is easy to use and simple to read, inspired by Elmish on the web.
F#
46
star
21

desktop-feliz-with-photino

F#
43
star
22

fsharp-weekly

F# Weekly mobile, available for Android (soon iOS and UWP too)
F#
42
star
23

SAFE-TodoList

The simplest Todo app showcasing a client-server application written entirely in F#
F#
41
star
24

Giraffe.SerilogExtensions

Dead simple library to integrate Serilog within Giraffe apps: implemented as a composable HttpHandler and has native destructuring of F# types.
F#
30
star
25

dotnetconf-react-with-fsharp

Demo application used in DotnetCONF to build React applications with F#
F#
30
star
26

Elmish.SweetAlert

SweetAlert integration for Fable, made with ❤️ to work in Elmish apps. https://zaid-ajaj.github.io/Elmish.SweetAlert/
F#
29
star
27

Fable.DateFunctions

Fable binding for date-fns javascript library, implemented as extension methods for DateTime. See https://zaid-ajaj.github.io/Fable.DateFunctions/
F#
27
star
28

Fable.CloudFlareWorkers

Write CloudFlare Workers in idiomatic, type-safe F# and compile them to JS using Fable
F#
24
star
29

Elmish.Toastr

Toastr integration with Fable, implemented as Elmish commands https://zaid-ajaj.github.io/Elmish.Toastr/
F#
24
star
30

elmish-getting-started

A simple and minimalistic template to easily get up and running with Elmish and Fable
F#
22
star
31

Giraffe.QueryReader

HttpHandler for easily working with query string parameters within Giraffe apps.
F#
21
star
32

navigation-bar-with-feliz

Modern navigation bar built with Feliz
JavaScript
20
star
33

fable-getting-started

Template for getting started with Fable
JavaScript
19
star
34

Giraffe.JsonTherapy

Simply extract JSON values from HTTP requests without defining intermediate types or using model binding
F#
19
star
35

Feliz.ViewEngine.Htmx

A library that allows using Htmx attributes with Feliz.ViewEngine
F#
18
star
36

Fable.SimpleXml

A library for easily parsing and working with XML in Fable projects
F#
17
star
37

AlgebraFs

A simple computer algebra system (CAS), written in F# for fun and learning.
F#
15
star
38

Fable.React.Flatpickr

Fable binding for react-flatpickr that is ready to use within Elmish applications
F#
14
star
39

elmish-login-flow-validation

Elmish sample that demonstrates a login flow with user input validation
F#
13
star
40

pulumi-schema-explorer

Web application and UI to explore Pulumi schemas
F#
13
star
41

Fable.SqlClient

Fable Node client for Microsoft SQL Server, built around a node-mssql binding
F#
12
star
42

pulumi-csharp-analyzer

Roslyn-based static code analysis for pulumi programs written in C#
C#
11
star
43

Elmish.AnimatedTree

An animated tree user interface made for Elmish applications
JavaScript
11
star
44

elmish-composition

A library to compare the different compositional techniques in Elmish applications
JavaScript
10
star
45

Cable

Type-safe client-server communication for C# featuring Bridge.NET and NancyFx
C#
10
star
46

Nancy.Serilog

Nancy plugin for application-wide logging using Serilog
C#
9
star
47

scaling-elmish-programs

FableConf 2018 slides and apps used in the presentation
F#
8
star
48

Suave.SerilogExtensions

Suave plugin to use the awesome Serilog library as the logger for your application
F#
8
star
49

ElmCounterWPF

Pure F#/Xaml counter using Elmish.WPF and XAML type provider
F#
7
star
50

ReactCSharpDemo

Using React in C# with Bridge
C#
7
star
51

Feliz.AntDesign

AntDesign bindings using Feliz syntax for a clean, discoverable and type-safe React components. (WIP)
F#
7
star
52

Fable.SimpleJson.Python

A library for working with JSON in F# Fable projects targeting Python
F#
7
star
53

hawaii-samples-feliz-petstore

This is a sample application that shows how to use Feliz with a client generated by Hawaii
F#
6
star
54

elmish-wpf-template

A template for easily getting started with building WPF apps using Elmish
F#
5
star
55

elmish-routing

F#
4
star
56

Bridge.Redux

Bindings of the Redux library for the Bridge transpiler
C#
4
star
57

Fable.Requests

Fable library for making HTTP requests targeting Python
F#
4
star
58

elmish-todo-exercises

F#
4
star
59

ExcelPluginTemplate

Template project to create Excel Add-ins with F# and ExcelDNA
F#
3
star
60

elmish-calc

Calculator application with Fable and Fable-Elmish
F#
3
star
61

interop-fableconf2019

JavaScript
3
star
62

FifteenPuzzleWithFeliz

The small fifteen puzzle game I am building live on Twitch
JavaScript
3
star
63

FSharp.SimpleJson

A library for easily parsing, transforming and converting JSON in F#, ported from Fable.SimpleJson
F#
3
star
64

docute-starter

a simple and easy to use project to start writing documentation with Docute
HTML
3
star
65

Bridge.ChartJS

Bindings for Chart.js library to be used in Bridge.NET projects
C#
3
star
66

Bridge.CanvasJS

CanvasJS C#-wrapper for Bridge.NET project.
C#
3
star
67

pulumi-workshop-automation-fsharp

This workshop will walk you through the basics of using the Automation API of Pulumi to create and deploy a Pulumi stack programmatically with F#
F#
3
star
68

MandelbrotHaskell

Mandelbrot fractal as text (ASCII), written in Haskell
Haskell
2
star
69

hawaii-samples-petstore

PetStore API sample with Hawaii
F#
2
star
70

fsharp-exchange-2021

Code repository for the F# eXchange 2021 conference
F#
2
star
71

terraform-basic-vpc-to-pulumi

HCL
2
star
72

Cable.ArticleSample

Type-safe web app sample used to demonstrate Cable
C#
2
star
73

SAFE-FileUploadDownload

F#
2
star
74

login-with-url-extended

F#
2
star
75

hawaii-samples-odata-trippin

F#
2
star
76

ReactReduxTodoApp

Todo app written in pure C# with React and Redux
C#
2
star
77

Simple-Feliz-i18n

Using Feliz template, this repository shows how to implement a simple internationalization mechanism that makes parts of the application be dependent on the current users' locale.
JavaScript
2
star
78

Fable.React.Responsive

Fable binding for react-responsive that is ready to use within Elmish applications
F#
1
star
79

remoting-pure-kestrel

The simplest AspNetCore sample with Fable.Remoting using the Kestrel server
F#
1
star
80

Bridge.SweetAlert

SweetAlert bindings for the Bridge.NET project.
CSS
1
star
81

Image-Processor

A program to process and filter images, written in C#.
C#
1
star
82

FableSuaveSample

Fable and Suave sample for integration-testing Fable.Remoting with Suave to the death
F#
1
star
83

ChristianHolidaysAssignment

C++
1
star
84

gitbook-enhanced-katex

Math typesetting using KaTex for gitBook
JavaScript
1
star
85

RemotingJsonBenchmarks

F#
1
star
86

pulumi-codegen-dotnet

Building Pulumi Codegen tooling in F#
F#
1
star
87

elmish-todo-part1

F#
1
star
88

WindowsExplorer

A WPF application that mimics Windows Explorer functionality
C#
1
star
89

elmish-hackernews-part1

F#
1
star
90

elmish-todo-part2

F#
1
star
91

fast-refresh-bug-reproduction

JavaScript
1
star
92

tagmeme-analyzer

Static code analyzer that checks for exhaustive pattern matching, union case typos and redundant arguments in tagmeme
JavaScript
1
star
93

xmlhttprequest-in-elmish

F#
1
star
94

Bridge.Ractive

Bindings of Ractive.js to be used in Bridge.NET projects.
JavaScript
1
star
95

elmish-hackernews-part3

F#
1
star
96

elmish-todo-part3

F#
1
star