Skip to content
Permalink
Browse files

Initial checkin

  • Loading branch information...
Praburaj committed Mar 24, 2015
0 parents commit 440f65f294c27d0f7f55e0975de0136c99711f20
Showing with 1,618 additions and 0 deletions.
  1. +50 −0 .gitattributes
  2. +27 −0 .gitignore
  3. +4 −0 CONTRIBUTING.md
  4. +12 −0 LICENSE.txt
  5. +7 −0 NuGet.Config
  6. +3 −0 README.md
  7. +28 −0 build.cmd
  8. +39 −0 build.sh
  9. +3 −0 global.json
  10. +7 −0 makefile.shade
  11. +51 −0 src/Microsoft.Framework.ConfigurationModel.UserSecrets/ConfigurationExtensions.cs
  12. +20 −0 ...Framework.ConfigurationModel.UserSecrets/Microsoft.Framework.ConfigurationModel.UserSecrets.xproj
  13. +62 −0 src/Microsoft.Framework.ConfigurationModel.UserSecrets/PathHelper.cs
  14. +78 −0 src/Microsoft.Framework.ConfigurationModel.UserSecrets/Properties/Resources.Designer.cs
  15. +129 −0 src/Microsoft.Framework.ConfigurationModel.UserSecrets/Resources.resx
  16. +16 −0 src/Microsoft.Framework.ConfigurationModel.UserSecrets/project.json
  17. +60 −0 src/SecretManager/CommandOutputLogger.cs
  18. +17 −0 src/SecretManager/CommandOutputProvider.cs
  19. +225 −0 src/SecretManager/Program.cs
  20. +6 −0 src/SecretManager/Properties/AssemblyInfo.cs
  21. +142 −0 src/SecretManager/Properties/Resources.Designer.cs
  22. +141 −0 src/SecretManager/Resources.resx
  23. +20 −0 src/SecretManager/SecretManager.xproj
  24. +22 −0 src/SecretManager/project.json
  25. +77 −0 test/SecretManager.Tests/PathHelperTests.cs
  26. +20 −0 test/SecretManager.Tests/SecretManager.Tests.xproj
  27. +247 −0 test/SecretManager.Tests/SecretManagerTests.cs
  28. +45 −0 test/SecretManager.Tests/TestLogger.cs
  29. +47 −0 test/SecretManager.Tests/UserSecretHelper.cs
  30. +13 −0 test/SecretManager.Tests/project.json
@@ -0,0 +1,50 @@
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

*.jpg binary
*.png binary
*.gif binary

*.cs text=auto diff=csharp
*.vb text=auto
*.resx text=auto
*.c text=auto
*.cpp text=auto
*.cxx text=auto
*.h text=auto
*.hxx text=auto
*.py text=auto
*.rb text=auto
*.java text=auto
*.html text=auto
*.htm text=auto
*.css text=auto
*.scss text=auto
*.sass text=auto
*.less text=auto
*.js text=auto
*.lisp text=auto
*.clj text=auto
*.sql text=auto
*.php text=auto
*.lua text=auto
*.m text=auto
*.asm text=auto
*.erl text=auto
*.fs text=auto
*.fsx text=auto
*.hs text=auto

*.csproj text=auto
*.vbproj text=auto
*.fsproj text=auto
*.dbproj text=auto
*.sln text=auto eol=crlf
@@ -0,0 +1,27 @@
[Oo]bj/
[Bb]in/
TestResults/
.nuget/
_ReSharper.*/
packages/
artifacts/
PublishProfiles/
*.user
*.suo
*.cache
*.docstates
_ReSharper.*
nuget.exe
*net45.csproj
*net451.csproj
*k10.csproj
*.psess
*.vsp
*.pidb
*.userprefs
*DS_Store
*.ncrunchsolution
*.*sdf
*.ipch
*.sln.ide
project.lock.json
@@ -0,0 +1,4 @@
Contributing
======

Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/master/CONTRIBUTING.md) in the Home repo.
@@ -0,0 +1,12 @@
Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use
these files except in compliance with the License. You may obtain a copy of the
License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetvnext/api/v2" />
<add key="NuGet" value="https://nuget.org/api/v2/" />
</packageSources>
</configuration>
@@ -0,0 +1,3 @@
User Secrets
=============

@@ -0,0 +1,28 @@
@echo off
cd %~dp0

SETLOCAL
SET CACHED_NUGET=%LocalAppData%\NuGet\NuGet.exe

IF EXIST %CACHED_NUGET% goto copynuget
echo Downloading latest version of NuGet.exe...
IF NOT EXIST %LocalAppData%\NuGet md %LocalAppData%\NuGet
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://www.nuget.org/nuget.exe' -OutFile '%CACHED_NUGET%'"

:copynuget
IF EXIST .nuget\nuget.exe goto restore
md .nuget
copy %CACHED_NUGET% .nuget\nuget.exe > nul

:restore
IF EXIST packages\KoreBuild goto run
.nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre
.nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion

IF "%SKIP_DNX_INSTALL%"=="1" goto run
CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -arch x86
CALL packages\KoreBuild\build\dnvm install default -runtime CoreCLR -arch x86

:run
CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86
packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %*
@@ -0,0 +1,39 @@
#!/bin/bash

if test `uname` = Darwin; then
cachedir=~/Library/Caches/KBuild
else
if [ -z $XDG_DATA_HOME ]; then
cachedir=$HOME/.local/share
else
cachedir=$XDG_DATA_HOME;
fi
fi
mkdir -p $cachedir

url=https://www.nuget.org/nuget.exe

if test ! -f $cachedir/nuget.exe; then
wget -O $cachedir/nuget.exe $url 2>/dev/null || curl -o $cachedir/nuget.exe --location $url /dev/null
fi

if test ! -e .nuget; then
mkdir .nuget
cp $cachedir/nuget.exe .nuget/nuget.exe
fi

if test ! -d packages/KoreBuild; then
mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre
mono .nuget/nuget.exe install Sake -version 0.2 -o packages -ExcludeVersion
fi

if ! type dnvm > /dev/null 2>&1; then
source packages/KoreBuild/build/dnvm.sh
fi

if ! type k > /dev/null 2>&1; then
dnvm upgrade
fi

mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@"

@@ -0,0 +1,3 @@
{
"sources": ["src"]
}
@@ -0,0 +1,7 @@

var VERSION='0.1'
var FULL_VERSION='0.1'
var AUTHORS='Microsoft Open Technologies, Inc.'

use-standard-lifecycle
k-standard-goals
@@ -0,0 +1,51 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System.IO;
using Microsoft.Framework.ConfigurationModel.UserSecrets;
using Microsoft.Framework.Internal;
using Microsoft.Framework.Runtime;
using Microsoft.Framework.Runtime.Infrastructure;

namespace Microsoft.Framework.ConfigurationModel
{
public static class ConfigurationExtensions
{
/// <summary>
/// Adds the user secrets configuration source.
/// </summary>
/// <param name="configuration"></param>
/// <returns></returns>
public static IConfigurationSourceRoot AddUserSecrets([NotNull]this IConfigurationSourceRoot configuration)
{
var appEnv = (IApplicationEnvironment)CallContextServiceLocator.Locator.ServiceProvider.GetService(typeof(IApplicationEnvironment));
var secretPath = PathHelper.GetSecretsPath(appEnv.ApplicationBasePath);

if (!File.Exists(secretPath))
{
// TODO: Use the optional config add after that's available?.
return configuration;
}

return configuration.AddJsonFile(secretPath);
}

/// <summary>
/// Adds the user secrets configuration source with specified secrets id.
/// </summary>
/// <param name="configuration"></param>
/// <returns></returns>
public static IConfigurationSourceRoot AddUserSecrets([NotNull]this IConfigurationSourceRoot configuration, [NotNull]string userSecretsId)
{
var secretPath = PathHelper.GetSecretsPathFromSecretsId(userSecretsId);

if (!File.Exists(secretPath))
{
// TODO: Use the optional config add after that's available?.
return configuration;
}

return configuration.AddJsonFile(secretPath);
}
}
}
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="__ToolsVersion__" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>58b6443b-1278-4df9-b7bb-ddf3bffcf868</ProjectGuid>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'" Label="Configuration">
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'" Label="Configuration">
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
@@ -0,0 +1,62 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.IO;
using Microsoft.Framework.Internal;
using Newtonsoft.Json.Linq;

namespace Microsoft.Framework.ConfigurationModel.UserSecrets
{
public class PathHelper
{
private const string Secrets_File_Name = "secrets.json";

public static string GetSecretsPath([NotNull]string projectPath)
{
var projectFilePath = Path.Combine(projectPath, "project.json");

if (!File.Exists(projectFilePath))
{
throw new InvalidOperationException(
string.Format(Resources.Error_Missing_Project_Json, projectFilePath));
}

var obj = JObject.Parse(File.ReadAllText(projectFilePath));
var userSecretsId = obj.Value<string>("userSecretsId");

if (string.IsNullOrEmpty(userSecretsId))
{
throw new InvalidOperationException(
string.Format(Resources.Error_Missing_UserSecretId_In_Project_Json, projectFilePath));
}

return GetSecretsPathFromSecretsId(userSecretsId);
}

public static string GetSecretsPathFromSecretsId([NotNull]string userSecretsId)
{
var badCharIndex = userSecretsId.IndexOfAny(Path.GetInvalidPathChars());
if (badCharIndex != -1)
{
throw new InvalidOperationException(
string.Format(
Resources.Error_Invalid_Character_In_UserSecrets_Id,
userSecretsId[badCharIndex],
badCharIndex));
}

var root = Environment.GetEnvironmentVariable("APPDATA") ?? // On Windows it goes to %APPDATA%\Microsoft\UserSecrets\
Environment.GetEnvironmentVariable("HOME"); // On Mac/Linux it goes to ~/.microsoft/usersecrets/

if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("APPDATA")))
{
return Path.Combine(root, "Microsoft", "UserSecrets", userSecretsId, Secrets_File_Name);
}
else
{
return Path.Combine(root, ".microsoft", "usersecrets", userSecretsId, Secrets_File_Name);
}
}
}
}
Oops, something went wrong.

0 comments on commit 440f65f

Please sign in to comment.
You can’t perform that action at this time.