Skip to content

Commit

Permalink
Updated the demo to use cake 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nils-a committed Jul 16, 2024
1 parent e0141a0 commit 2a6c18b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 6 deletions.
13 changes: 13 additions & 0 deletions demo/dsl/.config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"cake.tool": {
"version": "2.0.0",
"commands": [
"dotnet-cake"
],
"rollForward": false
}
}
}
16 changes: 10 additions & 6 deletions demo/dsl/discord.cake
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#r "../../Source/Cake.Discord/bin/Debug/netstandard2.0/Cake.Discord.dll"
#r "../../Source/Cake.Discord/bin/Debug/net6.0/Cake.Discord.dll"
//#addin "nuget:https://www.nuget.org/api/v2?package=Cake.Discord"

var url = Argument<string>("url", null);

var cakeAssembly = typeof(ICakeContext).Assembly.GetName();
var cakeName = $"{cakeAssembly.Name ?? "UNKNOWN"} v{cakeAssembly.Version?.ToString() ?? "??.??.??"}";

if (string.IsNullOrEmpty(url))
{
Error("you need to pass a webhook url via `--url=...`");
Expand All @@ -15,7 +18,7 @@ try

var postMessageResult = Discord.Chat.PostMessage(
webHookUrl:url,
content:"This is a normal message."
content:$"This is a normal message from {cakeName}."
);

if (postMessageResult.Ok)
Expand All @@ -38,7 +41,7 @@ try

var postMessageResult = Discord.Chat.PostMessage(
webHookUrl:url,
content:"This is a TTS message.",
content:$"This is a TTS message from {cakeName}.",
messageSettings:new DiscordChatMessageSettings { Tts = true }
);

Expand All @@ -62,9 +65,9 @@ try

var postMessageResult = Discord.Chat.PostMessage(
webHookUrl:url,
content:"This is a custom avatar and name message.",
content:$"This is a custom avatar and name message from {cakeName}.",
messageSettings:new DiscordChatMessageSettings {
UserName = "gep13",
UserName = cakeName,
AvatarUrl = new Uri("https://avatars0.githubusercontent.com/u/1271146?s=400&v=4")
}
);
Expand All @@ -89,7 +92,7 @@ try

var postMessageResult = Discord.Chat.PostMessage(
webHookUrl:url,
content:"This _is_ a `message` with custom formatting from *CakeBuild* using incoming web hook:thumbsup:\r\n```Here is some code```"
content:$"This _is_ a `message` with custom formatting from *CakeBuild* using incoming web hook:thumbsup:\r\n```Here is some code``` from {cakeName}"
);

if (postMessageResult.Ok)
Expand All @@ -106,4 +109,5 @@ catch(Exception ex)
Error("{0}", ex);
}

Information("Any key to continue.");
Console.ReadLine();
11 changes: 11 additions & 0 deletions demo/dsl/test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Set-Location -LiteralPath $PSScriptRoot

$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = '1'
$env:DOTNET_CLI_TELEMETRY_OPTOUT = '1'
$env:DOTNET_NOLOGO = '1'

dotnet tool restore
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

dotnet cake discord.cake @args
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
12 changes: 12 additions & 0 deletions demo/dsl/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -euox pipefail

cd "$(dirname "${BASH_SOURCE[0]}")"

export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_NOLOGO=1

dotnet tool restore

dotnet cake discord.cake "$@"

0 comments on commit 2a6c18b

Please sign in to comment.