Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddunkin committed Feb 4, 2018
0 parents commit d1740a7
Show file tree
Hide file tree
Showing 14 changed files with 594 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
charset = utf-8
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true

[*.{cake,cs,fsd,ts}]
indent_size = 4
indent_style = tab

[*.ps1]
indent_size = 4
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.vs/
.vscode/
bin/
cake/
node_modules/
obj/
packages/
release/

*.cache
*.log
*.ncrunchproject
*.ncrunchsolution
*.user
*.userprefs
34 changes: 34 additions & 0 deletions FacilityLanguageServer.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facility.LanguageServer", "src\Facility.LanguageServer\Facility.LanguageServer.csproj", "{F4447045-21D6-4D1A-A7DE-6DC7DE5372FF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F4447045-21D6-4D1A-A7DE-6DC7DE5372FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F4447045-21D6-4D1A-A7DE-6DC7DE5372FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F4447045-21D6-4D1A-A7DE-6DC7DE5372FF}.Debug|x64.ActiveCfg = Debug|Any CPU
{F4447045-21D6-4D1A-A7DE-6DC7DE5372FF}.Debug|x64.Build.0 = Debug|Any CPU
{F4447045-21D6-4D1A-A7DE-6DC7DE5372FF}.Debug|x86.ActiveCfg = Debug|Any CPU
{F4447045-21D6-4D1A-A7DE-6DC7DE5372FF}.Debug|x86.Build.0 = Debug|Any CPU
{F4447045-21D6-4D1A-A7DE-6DC7DE5372FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F4447045-21D6-4D1A-A7DE-6DC7DE5372FF}.Release|Any CPU.Build.0 = Release|Any CPU
{F4447045-21D6-4D1A-A7DE-6DC7DE5372FF}.Release|x64.ActiveCfg = Release|Any CPU
{F4447045-21D6-4D1A-A7DE-6DC7DE5372FF}.Release|x64.Build.0 = Release|Any CPU
{F4447045-21D6-4D1A-A7DE-6DC7DE5372FF}.Release|x86.ActiveCfg = Release|Any CPU
{F4447045-21D6-4D1A-A7DE-6DC7DE5372FF}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Dave Dunkin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Facility Language Server

Language Server Protocol server for the [Facility API Framework](https://facilityapi.github.io/).

[![Build Status](https://travis-ci.org/FacilityApi/FacilityLanguageServer.svg?branch=master)](https://travis-ci.org/FacilityApi/FacilityLanguageServer)
[![Build Status](https://ci.appveyor.com/api/projects/status/hpyavxt83gfqd491?svg=true)](https://ci.appveyor.com/project/ejball/FacilityLanguageServer)
[![Coverage Status](https://coveralls.io/repos/github/FacilityApi/FacilityLanguageServer/badge.svg?branch=master)](https://coveralls.io/github/FacilityApi/FacilityLanguageServer?branch=master)

## Facility.LanguageServer

Language server for Facility Service Definition documents.
7 changes: 7 additions & 0 deletions SolutionInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
using System.Reflection;

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCopyright("Copyright 2018 Dave Dunkin")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
7 changes: 7 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: '{build}'
environment:
COVERALLSAPIKEY:
secure: +3piz+KU6kTBtLXxADrKxJmnKQcJTHwpBICVolk5bH/8GbNgW5ZrGr6WYEp9KWSm
build_script:
- ps: .\build.ps1 -target=CoveragePublish -configuration=Debug "-coverallsApiKey=$env:COVERALLSAPIKEY"
test: off
197 changes: 197 additions & 0 deletions build.cake
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
#addin "nuget:?package=Cake.Git&version=0.16.1"
#addin "nuget:?package=Octokit&version=0.23.0"
#tool "nuget:?package=coveralls.io&version=1.3.4"
#tool "nuget:?package=gitlink&version=2.3.0"
#tool "nuget:?package=NUnit.ConsoleRunner&version=3.5.0"
#tool "nuget:?package=OpenCover&version=4.6.519"
#tool "nuget:?package=ReportGenerator&version=2.5.0"

using LibGit2Sharp;

var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var nugetApiKey = Argument("nugetApiKey", "");
var githubApiKey = Argument("githubApiKey", "");
var coverallsApiKey = Argument("coverallsApiKey", "");
var prerelease = Argument("prerelease", "");
var sourceIndex = Argument("sourceIndex", true);

var solutionFileName = "FacilityLanguageServer.sln";
var githubOwner = "FacilityApi";
var githubRepo = "FacilityLanguageServer";
var githubRawUri = "http://raw.githubusercontent.com";
var nugetSource = "https://www.nuget.org/api/v2/package";
var coverageAssemblies = new[] { "Facility.LanguageServer" };

var rootPath = MakeAbsolute(Directory(".")).FullPath;
var gitRepository = LibGit2Sharp.Repository.IsValid(rootPath) ? new LibGit2Sharp.Repository(rootPath) : null;

var githubClient = new Octokit.GitHubClient(new Octokit.ProductHeaderValue("build.cake"));
if (!string.IsNullOrEmpty(githubApiKey))
githubClient.Credentials = new Octokit.Credentials(githubApiKey);

string version = null;
string headSha = null;

Task("Clean")
.Does(() =>
{
CleanDirectories($"src/**/bin");
CleanDirectories($"src/**/obj");
CleanDirectories($"tests/**/bin");
CleanDirectories($"tests/**/obj");
CleanDirectories("release");
});

Task("Build")
.IsDependentOn("Clean")
.Does(() =>
{
NuGetRestore(solutionFileName);
MSBuild(solutionFileName, settings => settings.SetConfiguration(configuration));
});

Task("Test")
.IsDependentOn("Build")
.Does(() => NUnit3($"tests/**/bin/**/*.UnitTests.dll", new NUnit3Settings { NoResults = true }));

Task("SourceIndex")
.IsDependentOn("Test")
.WithCriteria(() => configuration == "Release" && gitRepository != null)
.Does(() =>
{
if (sourceIndex)
{
var dirtyEntry = gitRepository.RetrieveStatus().FirstOrDefault(x => x.State != FileStatus.Unaltered && x.State != FileStatus.Ignored);
if (dirtyEntry != null)
throw new InvalidOperationException($"The git working directory must be clean, but '{dirtyEntry.FilePath}' is dirty.");
headSha = gitRepository.Head.Tip.Sha;
try
{
githubClient.Repository.Commit.GetSha1(githubOwner, githubRepo, headSha).GetAwaiter().GetResult();
}
catch (Octokit.NotFoundException exception)
{
throw new InvalidOperationException($"The current commit '{headSha}' must be pushed to GitHub.", exception);
}
GitLink(MakeAbsolute(Directory(".")).FullPath, new GitLinkSettings
{
RepositoryUrl = $"{githubRawUri}/{githubOwner}/{githubRepo}",
ArgumentCustomization = args => args.Append($"-ignore Bom,BomTest"),
});
}
else
{
Warning("Skipping source index.");
}
version = GetSemVerFromFile(GetFiles($"src/**/bin/**/{coverageAssemblies[0]}.dll").First().ToString());
});

Task("NuGetPackage")
.IsDependentOn("SourceIndex")
.Does(() =>
{
CreateDirectory("release");
foreach (var nuspecPath in GetFiles($"src/**/*.nuspec"))
{
NuGetPack(nuspecPath, new NuGetPackSettings
{
Version = version,
OutputDirectory = "release",
});
}
});

Task("NuGetPublish")
.IsDependentOn("NuGetPackage")
.WithCriteria(() => !string.IsNullOrEmpty(nugetApiKey) && !string.IsNullOrEmpty(githubApiKey))
.Does(() =>
{
foreach (var nupkgPath in GetFiles($"release/*.nupkg"))
{
NuGetPush(nupkgPath, new NuGetPushSettings
{
ApiKey = nugetApiKey,
Source = nugetSource,
});
}
if (headSha != null)
{
var tagName = $"nuget-{version}";
Information($"Creating git tag '{tagName}'...");
githubClient.Git.Reference.Create(githubOwner, githubRepo,
new Octokit.NewReference($"refs/tags/{tagName}", headSha)).GetAwaiter().GetResult();
}
else
{
Warning("Skipping git tag for prerelease.");
}
});

Task("Coverage")
.IsDependentOn("Build")
.Does(() =>
{
CreateDirectory("release");
if (FileExists("release/coverage.xml"))
DeleteFile("release/coverage.xml");
string filter = string.Concat(coverageAssemblies.Select(x => $@" ""-filter:+[{x}]*"""));
var nunitPath = Context.Tools.Resolve("nunit3-console.exe").ToString();
foreach (var testDllPath in GetFiles($"tests/**/bin/**/*.UnitTests.dll"))
{
ExecuteTool("OpenCover.Console.exe",
$@"-register:user -mergeoutput ""-target:{nunitPath}"" ""-targetargs:{testDllPath} --noresult"" ""-output:{File("release/coverage.xml")}"" -skipautoprops -returntargetcode" + filter);
}
});

Task("CoverageReport")
.IsDependentOn("Coverage")
.Does(() =>
{
ExecuteTool("ReportGenerator.exe", $@"""-reports:{File("release/coverage.xml")}"" ""-targetdir:{File("release/coverage")}""");
});

Task("CoveragePublish")
.IsDependentOn("Coverage")
.Does(() =>
{
ExecuteTool("coveralls.net.exe", $@"--opencover ""{File("release/coverage.xml")}"" --full-sources --repo-token {coverallsApiKey}");
});

Task("Default")
.IsDependentOn("Test");

string GetSemVerFromFile(string path)
{
var versionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(path);
var semver = $"{versionInfo.FileMajorPart}.{versionInfo.FileMinorPart}.{versionInfo.FileBuildPart}";
if (prerelease.Length != 0)
semver += $"-{prerelease}";
return semver;
}

void ExecuteTool(string tool, string arguments)
{
ExecuteProcess(Context.Tools.Resolve(tool).ToString(), arguments);
}

void ExecuteProcess(string exePath, string arguments)
{
if (IsRunningOnUnix())
{
arguments = exePath + " " + arguments;
exePath = "mono";
}
int exitCode = StartProcess(exePath, arguments);
if (exitCode != 0)
throw new InvalidOperationException($"{exePath} failed with exit code {exitCode}.");
}

RunTarget(target);
55 changes: 55 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<#
.SYNOPSIS
This is a Powershell script to bootstrap a Cake build.
#>

[CmdletBinding()]
Param(
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$ScriptArgs
)

# delete cake directory if script changed
$CakeDirPath = Join-Path $PSScriptRoot "cake"
$PackagesConfigPath = Join-Path $CakeDirPath "packages.config"
If ((Test-Path $PackagesConfigPath) -and ((Get-Item(Join-Path $PSScriptRoot "build.cake")).LastWriteTime -gt (Get-Item($PackagesConfigPath)).LastWriteTime)) {
Write-Host "Cake script changed; rebuilding cake directory."
Remove-Item $CakeDirPath -Force -Recurse
}

# create cake directory
New-Item -Path $CakeDirPath -Type Directory -ErrorAction SilentlyContinue | Out-Null

# create packages.config
If (!(Test-Path $PackagesConfigPath)) {
[System.IO.File]::WriteAllLines($PackagesConfigPath, @(
"<?xml version=`"1.0`" encoding=`"utf-8`"?>",
"<packages>",
"`t<package id=`"Cake`" version=`"0.25.0`" />",
"</packages>"))
}

# download nuget.exe if not in path and not already downloaded
$NuGetExe = Get-Command "nuget.exe" -ErrorAction SilentlyContinue
If ($NuGetExe -ne $null) {
$NuGetExePath = $NuGetExe.Path
}
Else {
$NuGetExePath = Join-Path $CakeDirPath "nuget.exe"
If (!(Test-Path $NuGetExePath)) {
Invoke-WebRequest -Uri http://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile $NuGetExePath
}
}

# use NuGet to download Cake
Push-Location $CakeDirPath
Invoke-Expression "&`"$NuGetExePath`" install -ExcludeVersion -OutputDirectory ."
If ($LASTEXITCODE -ne 0) {
Throw "An error occured while restoring NuGet tools."
}
Pop-Location

# run Cake with specified arguments
$CakeExePath = Join-Path $CakeDirPath "Cake/Cake.exe"
Invoke-Expression "& `"$CakeExePath`" --paths_tools=cake -experimental $ScriptArgs"
Exit $LASTEXITCODE
Loading

0 comments on commit d1740a7

Please sign in to comment.