Skip to content
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

Add CLI commons package #1180

Merged
merged 6 commits into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,10 @@ updates:
open-pull-requests-limit: 10
labels:
- TypeScript
- package-ecosystem: nuget
directory: "/cli/commons"
schedule:
interval: daily
open-pull-requests-limit: 10
labels:
- CLI
64 changes: 64 additions & 0 deletions .github/workflows/cli-commons.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: CLI commons

on:
workflow_dispatch:
push:
branches: [ main ]
paths: ['cli/commons/**', '.github/workflows/**']
pull_request:
paths: ['cli/commons/**', '.github/workflows/**']

jobs:
build:
runs-on: ubuntu-latest
env:
relativePath: ./cli/commons
solutionName: Microsoft.Kiota.Cli.Commons.sln
steps:
- uses: actions/checkout@v2.4.0
- name: Setup .NET
uses: actions/setup-dotnet@v1.9.0
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore ${{ env.solutionName }}
working-directory: ${{ env.relativePath }}
- name: Build
run: dotnet build ${{ env.solutionName }} --no-restore -c Release
working-directory: ${{ env.relativePath }}
- name: Test
run: dotnet test ${{ env.solutionName }} --no-build --verbosity normal -c Release /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOutputFormat=opencover
working-directory: ${{ env.relativePath }}
- name: Publish
run: dotnet publish ${{ env.solutionName }} --no-restore --no-build --verbosity normal -c Release
working-directory: ${{ env.relativePath }}
- name: Pack
run: dotnet pack ${{ env.solutionName }} --no-restore --no-build --verbosity normal -c Release
working-directory: ${{ env.relativePath }}
- name: Upload Coverage Results
uses: actions/upload-artifact@v2
with:
name: codeCoverage
path: |
${{ env.relativePath }}src/Microsoft.Kiota.Cli.Commons.Tests/TestResults
- name: Upload Nuget Package
uses: actions/upload-artifact@v2
with:
name: drop
path: |
${{ env.relativePath }}/src/bin/Release/*.nupkg
deploy:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
environment:
name: staging_feeds
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v1.9.0
with:
dotnet-version: 6.0.x
- uses: actions/download-artifact@v2
with:
name: drop
- run: dotnet nuget push "*.nupkg" --skip-duplicate -s https://nuget.pkg.github.com/microsoft/index.json -k ${{ secrets.PUBLISH_GH_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ on:
workflow_dispatch:
push:
branches: [ main ]
path-ignore: ['abstractions/**', 'authentication/**', 'serialization/**', 'http/**', '**.md', '.vscode/**', '**.svg']
path-ignore: ['abstractions/**', 'authentication/**', 'serialization/**', 'http/**', 'cli/**', '**.md', '.vscode/**', '**.svg']
pull_request:
# The branches below must be a subset of the branches above
path-ignore: ['abstractions/**', 'authentication/**', 'serialization/**', 'http/**', '**.md', '.vscode/**', '**.svg']
path-ignore: ['abstractions/**', 'authentication/**', 'serialization/**', 'http/**', 'cli/**', '**.md', '.vscode/**', '**.svg']
schedule:
- cron: '20 9 * * 5'

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ on:
push:
branches:
- main
path-ignore: ['abstractions/**', 'authentication/**', 'serialization/**', 'http/**', '**.md', '.vscode/**', '**.svg']
path-ignore: ['abstractions/**', 'authentication/**', 'serialization/**', 'http/**', 'cli/**', '**.md', '.vscode/**', '**.svg']
pull_request:
types: [opened, synchronize, reopened]
path-ignore: ['abstractions/**', 'authentication/**', 'serialization/**', 'http/**', '**.md', '.vscode/**', '**.svg']
path-ignore: ['abstractions/**', 'authentication/**', 'serialization/**', 'http/**', 'cli/**', '**.md', '.vscode/**', '**.svg']

env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The following table provides an overview of the languages supported by Kiota and
| Python | [▶](https://github.com/microsoft/kiota/projects/3) | [✔](./abstractions/python) | ❌ | [Anonymous](./abstractions/python/kiota/abstractions/authentication/anonymous_authentication_provider.py), [Azure](./authentication/python/azure) | ❌ | |
| Ruby | [✔](https://github.com/microsoft/kiota/projects/6) | [✔](./abstractions/ruby) | [JSON](./serialization/ruby/json/microsoft_kiota_serialization) | [Anonymous](./abstractions/ruby/microsoft_kiota_abstractions/lib/microsoft_kiota_abstractions/authentication/anonymous_authentication_provider.rb), [❌ Azure](https://github.com/microsoft/kiota/issues/421) | [✔](./http/ruby/nethttp/microsoft_kiota_nethttplibrary)| [link](https://microsoft.github.io/kiota/get-started/ruby) |
| TypeScript/JavaScript | [✔](https://github.com/microsoft/kiota/projects/2) | [✔](./abstractions/typescript) | [JSON](./serialization/typescript/json) | [Anonymous](./abstractions/typescript/src/authentication/anonymousAuthenticationProvider.ts), [Azure](./authentication/typescript/azure) | [✔](./http/typescript/fetch) | [link](https://microsoft.github.io/kiota/get-started/typescript) |
| Shell | [✔](https://github.com/microsoft/kiota/projects/10) | [✔](./abstractions/dotnet), [✔](./cli/commonc) | [JSON](./serialization/dotnet/json) | [Anonymous](./abstractions/dotnet/src/authentication/AnonymousAuthenticationProvider.cs), [Azure](./authentication/dotnet/azure) | [✔](./http/dotnet/httpclient) | [link](https://microsoft.github.io/kiota/get-started/dotnet) |

> Legend: ✔ -> in preview, ❌ -> not started, ▶ -> in progress.

Expand Down
34 changes: 34 additions & 0 deletions cli/commons/Microsoft.Kiota.Cli.Commons.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 Version 16
VisualStudioVersion = 16.0.30114.105
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{8DEB9AF3-BEA6-4E73-BB5E-EBC1DFE6AF22}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Kiota.Cli.Commons", "src\Microsoft.Kiota.Cli.Commons\Microsoft.Kiota.Cli.Commons.csproj", "{23DD14C5-3060-4498-B2F9-85B68770AE0B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Kiota.Cli.Commons.Tests", "src\Microsoft.Kiota.Cli.Commons.Tests\Microsoft.Kiota.Cli.Commons.Tests.csproj", "{D1228DD9-C98F-46C1-911A-65AE2D34DBE5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{23DD14C5-3060-4498-B2F9-85B68770AE0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{23DD14C5-3060-4498-B2F9-85B68770AE0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{23DD14C5-3060-4498-B2F9-85B68770AE0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23DD14C5-3060-4498-B2F9-85B68770AE0B}.Release|Any CPU.Build.0 = Release|Any CPU
{D1228DD9-C98F-46C1-911A-65AE2D34DBE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D1228DD9-C98F-46C1-911A-65AE2D34DBE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D1228DD9-C98F-46C1-911A-65AE2D34DBE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D1228DD9-C98F-46C1-911A-65AE2D34DBE5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{23DD14C5-3060-4498-B2F9-85B68770AE0B} = {8DEB9AF3-BEA6-4E73-BB5E-EBC1DFE6AF22}
{D1228DD9-C98F-46C1-911A-65AE2D34DBE5} = {8DEB9AF3-BEA6-4E73-BB5E-EBC1DFE6AF22}
EndGlobalSection
EndGlobal
3 changes: 3 additions & 0 deletions cli/commons/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Kiota CLI Commons Package

Contains CLI specific types that are referenced in code generated by the shell language.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Microsoft.Kiota.Cli.Commons.IO;

public enum FormatterType
{
JSON,
TABLE,
NONE
}
10 changes: 10 additions & 0 deletions cli/commons/src/Microsoft.Kiota.Cli.Commons/IO/IOutputFormatter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.CommandLine;

namespace Microsoft.Kiota.Cli.Commons.IO;

public interface IOutputFormatter
{
void WriteOutput(string content, IConsole console);

void WriteOutput(Stream content, IConsole console);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Microsoft.Kiota.Cli.Commons.IO;

public interface IOutputFormatterFactory
{
IOutputFormatter GetFormatter(FormatterType formatterType);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>0.1.0</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.CommandLine" Version="2.0.0-beta2.21617.1" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Kiota.Builder/Refiners/ShellRefiner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private static CodeMethod CreateBuildCommandMethod(CodeProperty navProperty, Cod
new (x => x is CodeClass @class && @class.IsOfKind(CodeClassKind.RequestBuilder),
"System.CommandLine", "Command", "RootCommand"),
new (x => x is CodeClass @class && @class.IsOfKind(CodeClassKind.RequestBuilder),
"Microsoft.Graph.Cli.Core.IO", "IOutputFormatterFactory"),
"Microsoft.Kiota.Cli.Commons.IO", "IOutputFormatterFactory"),
new (x => x is CodeClass @class && @class.IsOfKind(CodeClassKind.RequestBuilder),
"System.Text", "Encoding"),
};
Expand Down