-
Notifications
You must be signed in to change notification settings - Fork 588
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
Convert YarnHelper to module #1868
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Auto-Generated by FAKE; do not edit | ||
namespace System | ||
open System.Reflection | ||
|
||
[<assembly: AssemblyTitleAttribute("FAKE - F# Make Running Yarn commands")>] | ||
[<assembly: AssemblyProductAttribute("FAKE - F# Make")>] | ||
[<assembly: AssemblyVersionAttribute("5.0.0")>] | ||
[<assembly: AssemblyInformationalVersionAttribute("5.0.0-rc004")>] | ||
[<assembly: AssemblyFileVersionAttribute("5.0.0")>] | ||
do () | ||
|
||
module internal AssemblyVersionInformation = | ||
let [<Literal>] AssemblyTitle = "FAKE - F# Make Running Yarn commands" | ||
let [<Literal>] AssemblyProduct = "FAKE - F# Make" | ||
let [<Literal>] AssemblyVersion = "5.0.0" | ||
let [<Literal>] AssemblyInformationalVersion = "5.0.0-rc004" | ||
let [<Literal>] AssemblyFileVersion = "5.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<TargetFrameworks>netstandard1.6;netstandard2.0</TargetFrameworks> | ||
<AssemblyName>Fake.JavaScript.Yarn</AssemblyName> | ||
<OutputType>Library</OutputType> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="AssemblyInfo.fs" /> | ||
<Compile Include="Yarn.fs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Fake.Core.Environment\Fake.Core.Environment.fsproj" /> | ||
<ProjectReference Include="..\Fake.Core.Process\Fake.Core.Process.fsproj" /> | ||
<ProjectReference Include="..\Fake.IO.FileSystem\Fake.IO.FileSystem.fsproj" /> | ||
</ItemGroup> | ||
<Import Project="..\..\..\.paket\Paket.Restore.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
namespace Fake.JavaScript | ||
|
||
open Fake.Core | ||
open Fake.IO | ||
open System | ||
open System.IO | ||
|
||
[<RequireQualifiedAccess>] | ||
module Yarn = | ||
|
||
/// Default paths to Yarn | ||
let private yarnFileName = | ||
Process.tryFindFileOnPath "yarn" | ||
|> function | ||
| Some yarn when File.Exists yarn -> yarn | ||
| _ -> | ||
match Environment.isWindows with | ||
| true -> "./packages/Yarnpkg.js/tools/yarn.cmd" | ||
| _ -> "/usr/bin/yarn" | ||
|
||
/// Arguments for the Yarn install command | ||
type InstallArgs = | ||
| Standard | ||
| Flat | ||
| Force | ||
| Har | ||
| NoLockFile | ||
| Production | ||
| PureLockFile | ||
|
||
/// The list of supported Yarn commands. The `Custom` alternative | ||
/// can be used for other commands not in the list until they are | ||
/// implemented | ||
type YarnCommand = | ||
| Install of InstallArgs | ||
| Custom of string | ||
|
||
/// The Yarn parameter type | ||
type YarnParams = | ||
{ Src: string | ||
YarnFilePath: string | ||
WorkingDirectory: string | ||
Timeout: TimeSpan } | ||
|
||
/// Yarn default parameters | ||
let defaultYarnParams = | ||
{ Src = "" | ||
YarnFilePath = yarnFileName | ||
WorkingDirectory = "." | ||
Timeout = TimeSpan.MaxValue } | ||
|
||
let private parseInstallArgs = function | ||
| Standard -> "" | ||
| Flat -> " --flat" | ||
| Force -> " --force" | ||
| Har -> " --har" | ||
| NoLockFile -> " --no-lockfile" | ||
| Production -> " --production" | ||
| PureLockFile -> " --pure-lockfile" | ||
|
||
let private parse = function | ||
| Install installArgs -> sprintf "install%s" (installArgs |> parseInstallArgs) | ||
| Custom str -> str | ||
|
||
let private run yarnParams command = | ||
let yarnPath = Path.GetFullPath(yarnParams.YarnFilePath) | ||
let arguments = command |> parse | ||
let exitCode = | ||
Process.execSimple (fun info -> | ||
{ info with | ||
FileName = yarnPath | ||
WorkingDirectory = yarnParams.WorkingDirectory | ||
Arguments = arguments | ||
} | ||
) yarnParams.Timeout | ||
|
||
if exitCode <> 0 then failwith (sprintf "'yarn %s' task failed" arguments) | ||
|
||
let private yarn setParams = defaultYarnParams |> setParams |> run | ||
|
||
|
||
/// Run `yarn install` | ||
/// ## Parameters | ||
/// - 'setParams' - set command parameters | ||
/// ## Sample | ||
/// | ||
/// Yarn.install (fun o -> | ||
/// { o with | ||
/// WorkingDirectory = "./src/FAKESimple.Web/" | ||
/// }) | ||
let install setParams = yarn setParams <| Install Standard | ||
|
||
/// Run `yarn install --production` | ||
/// ## Parameters | ||
/// - 'setParams' - set command parameters | ||
/// ## Sample | ||
/// | ||
/// Yarn.installProduction (fun o -> | ||
/// { o with | ||
/// WorkingDirectory = "./src/FAKESimple.Web/" | ||
/// }) | ||
|
||
let installProduction setParams = yarn setParams <| Install Production | ||
|
||
/// Run `yarn install --force` | ||
/// ## Parameters | ||
/// - 'setParams' - set command parameters | ||
/// ## Sample | ||
/// | ||
/// Yarn.installForced (fun o -> | ||
/// { o with | ||
/// WorkingDirectory = "./src/FAKESimple.Web/" | ||
/// }) | ||
let installForced setParams = yarn setParams <| Install Force | ||
|
||
/// Run `yarn install --flat` | ||
/// ## Parameters | ||
/// - 'setParams' - set command parameters | ||
/// ## Sample | ||
/// | ||
/// Yarn.installFlat (fun o -> | ||
/// { o with | ||
/// WorkingDirectory = "./src/FAKESimple.Web/" | ||
/// }) | ||
let installFlat setParams = yarn setParams <| Install Flat | ||
|
||
|
||
/// Run `yarn install --har` | ||
/// ## Parameters | ||
/// - 'setParams' - set command parameters | ||
/// ## Sample | ||
/// | ||
/// Yarn.installHar (fun o -> | ||
/// { o with | ||
/// WorkingDirectory = "./src/FAKESimple.Web/" | ||
/// }) | ||
let installHar setParams = yarn setParams <| Install Har | ||
|
||
/// Run `yarn install --no-lockfile` | ||
/// ## Parameters | ||
/// - 'setParams' - set command parameters | ||
/// ## Sample | ||
/// | ||
/// Yarn.installNoLock (fun o -> | ||
/// { o with | ||
/// WorkingDirectory = "./src/FAKESimple.Web/" | ||
/// }) | ||
let installNoLock setParams = yarn setParams <| Install NoLockFile | ||
|
||
/// Run `yarn install --pure-lockfile` | ||
/// ## Parameters | ||
/// - 'setParams' - set command parameters | ||
/// ## Sample | ||
/// | ||
/// Yarn.installPureLock (fun o -> | ||
/// { o with | ||
/// WorkingDirectory = "./src/FAKESimple.Web/" | ||
/// }) | ||
let installPureLock setParams = yarn setParams <| Install PureLockFile | ||
|
||
/// Run `yarn <command>` | ||
/// ## Parameters | ||
/// - 'setParams' - set command parameters | ||
/// ## Sample | ||
/// | ||
/// Yarn.exec "someCommand" (fun o -> | ||
/// { o with | ||
/// WorkingDirectory = "./src/FAKESimple.Web/" | ||
/// }) | ||
let exec command setParams = yarn setParams <| Custom command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
group netcore | ||
|
||
FSharp.Core | ||
NETStandard.Library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add the attribute to the module as well.