Comments (3)
@Zaid-Ajaj you're absolutely right about kvp.Value|Key
(I refactored it just before posting). Also, thanks for the proposed refactoring!
from femto.
Hey @Zaid-Ajaj!
I was interested in the current issue, but I'm not sure if my style or approach would be valid for your project.
I just created a sample code for one part where Newtonsoft.Json
is used and I would like you to have a look at it. I just want to make sure that my code is something that you could merge :)
In order to not clutter this post I'll include number lines where I thought I would replace your part with mine.
Your: https://github.com/Zaid-Ajaj/Femto/blob/master/Program.fs#L83-L113
Mine:
type RawPackage =
{
Dependencies : Map<string, string> option
DevDependencies : Map<string, string> option }
let topLevelPackages =
match Decode.Auto.fromString<RawPackage>(file, isCamelCase = true) with
| Ok rawPackage ->
let inline createInstalledPackage name version isDevDependency = {
Name = name;
Range = Some (SemVer.Range(version));
Installed = None;
DevDependency = isDevDependency
}
let inline createInstalledPackages isDevDependency (dependencies: Map<string, string> option) =
dependencies
|> Option.map (fun deps -> deps |> Seq.map (fun kvp -> createInstalledPackage kvp.Value kvp.Key isDevDependency))
|> Option.defaultValue Seq.empty
ResizeArray [
yield! (false, rawPackage.Dependencies) ||> createInstalledPackages;
yield! (true, rawPackage.DevDependencies) ||> createInstalledPackages
]
| Error _ -> ResizeArray []
In advance, thanks for the feedback)
from femto.
Hello @semuserable, I am really glad to hear that you want to pick this up!
The code above looks good, though I am not a big fan of the ||>
operator since its use here is unnecessary. I would simplify createInstalledPackage
and createInstalledPackages
into a single function:
let createInstalledPackages isDevDependency (dependencies: Map<string, string> option) =
dependencies
|> Option.defaultValue Map.empty
|> Seq.map (fun pair -> {
Name = pair.Key
Range = Some (SemVer.Range(pair.Value))
Installed = None
DevDependency = isDevDependency
})
In your code you have the parameter
name
is bound fromkvp.Value
andversion
fromkvp.Key
. I think it should be the other way around if I remember correctly
from femto.
Related Issues (20)
- Support source path with whitespace HOT 3
- Femto cannot use local paket HOT 9
- femto upgrade HOT 11
- Failed to retrieve information ... | Add verbose mode? HOT 4
- Femto force user to explictly install a dependencies and not have it as transitive (from npm POV) HOT 5
- Use pnpm instead of npm HOT 6
- Cannot specify Nuget package version or --prelease mode HOT 5
- Femto reports an error about parsing an unrelated package.json
- Exit code HOT 2
- Support pip for Fable-to-Python HOT 2
- dotnet tool restore femto results in a nuget error: The repository primary signature validity period has expired. HOT 4
- Where to find `package.json`? HOT 1
- Yarn / NPM detection is not aware of workspaces HOT 1
- femto resolve not working HOT 2
- is there equivalent to femto --update HOT 2
- Can't retrieve information HOT 8
- Little bug in help display HOT 1
- Femto fails to retreive scoped package information with pnpm HOT 6
- Conflicting dependencies across nuget packages causes infinite re-installation of packages HOT 7
- Femto doesn't work with dotnet SDK v7.x HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from femto.