Skip to content

Commit af9f986

Browse files
committed
20230316A
1 parent 0ec833b commit af9f986

File tree

16 files changed

+65378
-64
lines changed

16 files changed

+65378
-64
lines changed

hugoalh.GitHubActionsToolkit/module/artifact.psm1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
#Requires -Version 7.2
33
Import-Module -Name (
44
@(
5-
'nodejs-wrapper',
6-
'utility'
5+
'nodejs-wrapper'
76
) |
87
ForEach-Object -Process { Join-Path -Path $PSScriptRoot -ChildPath "$_.psm1" }
98
) -Prefix 'GitHubActions' -Scope 'Local'

hugoalh.GitHubActionsToolkit/module/cache.psm1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
#Requires -Version 7.2
33
Import-Module -Name (
44
@(
5-
'nodejs-wrapper',
6-
'utility'
5+
'nodejs-wrapper'
76
) |
87
ForEach-Object -Process { Join-Path -Path $PSScriptRoot -ChildPath "$_.psm1" }
98
) -Prefix 'GitHubActions' -Scope 'Local'

hugoalh.GitHubActionsToolkit/module/command-control.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ Function New-CommandsEndToken {
163163
[OutputType([String])]
164164
Param ()
165165
Do {
166-
[String]$Result = New-GitHubActionsRandomToken -Length 32
166+
[String]$Result = New-GitHubActionsRandomToken
167167
}
168168
While ( $Result -iin $GitHubActionsCommandsEndTokensUsed )
169169
$Script:GitHubActionsCommandsEndTokensUsed += $Result

hugoalh.GitHubActionsToolkit/module/internal/new-random-token.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Function New-RandomToken {
1515
[CmdletBinding()]
1616
[OutputType([String])]
1717
Param (
18-
[Parameter(Position = 0)][ValidateRange(1, [UInt32]::MaxValue)][UInt32]$Length = 16
18+
[Parameter(Position = 0)][ValidateRange(1, [UInt32]::MaxValue)][UInt32]$Length = 32
1919
)
2020
[Char[]]$PoolCurrent = $PoolMain |
2121
Get-Random -Shuffle

hugoalh.GitHubActionsToolkit/module/nodejs-wrapper.psm1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Import-Module -Name (
1515
[RegEx]$SemVerRegEx = 'v?\d+\.\d+\.\d+'
1616
[String]$WrapperRoot = Join-Path -Path $PSScriptRoot -ChildPath 'nodejs-wrapper'
1717
[String]$WrapperMetaPath = Join-Path -Path $WrapperRoot -ChildPath 'package.json'
18-
[String]$WrapperScriptPath = Join-Path -Path $WrapperRoot -ChildPath 'lib' -AdditionalChildPath @('main.js')
18+
[String]$WrapperScriptPath = Join-Path -Path $WrapperRoot -ChildPath 'unbundled.js'
1919
<#
2020
.SYNOPSIS
2121
GitHub Actions - Internal - Convert From Base64 String To Utf8 String
@@ -89,7 +89,7 @@ Function Invoke-NodeJsWrapper {
8989
Return
9090
}
9191
}
92-
[String]$ResultSeparator = "=====$(New-GitHubActionsRandomToken -Length 32)====="
92+
[String]$ResultSeparator = "=====$(New-GitHubActionsRandomToken)====="
9393
Try {
9494
[String[]]$Result = Invoke-Expression -Command "node --no-deprecation --no-warnings `"$WrapperScriptPath`" $(Convert-FromUtf8StringToBase64String -InputObject $Name) $(
9595
$Argument |

hugoalh.GitHubActionsToolkit/module/nodejs-wrapper/bundled.js

Lines changed: 64598 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1 @@
1-
{
2-
"name": "@hugoalh/ghactions-toolkit-powershell-nodejs-wrapper",
3-
"version": "1.3.2",
4-
"description": "A PowerShell module to provide a better and easier way for GitHub Actions to communicate with the runner machine, and the toolkit for developing GitHub Actions in PowerShell.",
5-
"keywords": [
6-
"gh-actions",
7-
"ghactions",
8-
"github-actions",
9-
"PSEdition_Core",
10-
"toolkit"
11-
],
12-
"homepage": "https://github.com/hugoalh-studio/ghactions-toolkit-powershell#readme",
13-
"bugs": {
14-
"url": "https://github.com/hugoalh-studio/ghactions-toolkit-powershell/issues"
15-
},
16-
"license": "MIT",
17-
"author": "hugoalh",
18-
"type": "module",
19-
"main": "./lib/main.js",
20-
"exports": {
21-
"import": "./lib/main.js"
22-
},
23-
"repository": {
24-
"type": "git",
25-
"url": "git+https://github.com/hugoalh-studio/ghactions-toolkit-powershell.git"
26-
},
27-
"dependencies": {
28-
"@actions/artifact": "^1.1.1",
29-
"@actions/cache": "^3.2.1",
30-
"@actions/core": "^1.10.0",
31-
"@actions/tool-cache": "^2.0.1"
32-
},
33-
"engines": {
34-
"node": ">=14.15.0"
35-
},
36-
"private": true
37-
}
1+
{"name":"@hugoalh/ghactions-toolkit-powershell-nodejs-wrapper-distribution","version":"1.3.2","description":"A PowerShell module to provide a better and easier way for GitHub Actions to communicate with the runner machine, and the toolkit for developing GitHub Actions in PowerShell.","keywords":["gh-actions","ghactions","github-actions","PSEdition_Core","toolkit"],"homepage":"https://github.com/hugoalh-studio/ghactions-toolkit-powershell#readme","bugs":{"url":"https://github.com/hugoalh-studio/ghactions-toolkit-powershell/issues"},"license":"MIT","author":"hugoalh","type":"module","main":"./main.js","exports":{"import":"./main.js"},"repository":{"type":"git","url":"git+https://github.com/hugoalh-studio/ghactions-toolkit-powershell.git"},"dependencies":{"@actions/artifact":"^1.1.1","@actions/cache":"^3.2.1","@actions/core":"^1.10.0","@actions/tool-cache":"^2.0.1"},"engines":{"node":">=14.15.0"},"private":true}

hugoalh.GitHubActionsToolkit/module/nodejs-wrapper/pnpm-lock.yaml

Lines changed: 15 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
import { cacheDir as ghactionsToolCacheCacheDirectory, cacheFile as ghactionsToolCacheCacheFile, downloadTool as ghactionToolCacheDownloadTool, extract7z as ghactionToolCacheExtract7z, extractTar as ghactionToolCacheExtractTar, extractXar as ghactionToolCacheExtractXar, extractZip as ghactionToolCacheExtractZip, find as ghactionsToolCacheFind, findAllVersions as ghactionsToolCacheFindAllVersions } from "@actions/tool-cache";
2+
import { create as ghactionsArtifact } from "@actions/artifact";
3+
import { debug as ghactionsDebug, getIDToken as ghactionsGetOpenIDConnectToken } from "@actions/core";
4+
import { restoreCache as ghactionsCacheRestoreCache, saveCache as ghactionsCacheSaveCache } from "@actions/cache";
5+
function encodeConvert(item, from, to) {
6+
return Buffer.from(item, from).toString(to);
7+
}
8+
function errorHandle(reason) {
9+
let message;
10+
if (typeof reason.message === "undefined") {
11+
message = reason;
12+
} else {
13+
message = reason.message;
14+
if (typeof reason.stack === "undefined") {
15+
message = `\n${reason.stack}`
16+
}
17+
}
18+
console.error(message);
19+
return process.exit(1);
20+
}
21+
function resultHandle(result) {
22+
return encodeConvert(JSON.stringify(result), "utf8", "base64");
23+
}
24+
let [wrapperName, inputsRaw, delimiter] = process.argv.slice(2);
25+
[wrapperName, inputsRaw, delimiter] = [wrapperName, inputsRaw, delimiter].map((value) => {
26+
return encodeConvert(value, "base64", "utf8");
27+
});
28+
const inputs = JSON.parse(inputsRaw);
29+
switch (wrapperName) {
30+
case "__debug":
31+
{
32+
ghactionsDebug(inputs.Message);
33+
console.log(delimiter);
34+
console.log(resultHandle({
35+
Message: "Hello, world!",
36+
Message2: "Good day, world!"
37+
}));
38+
}
39+
break;
40+
case "artifact/download":
41+
{
42+
const result = await ghactionsArtifact().downloadArtifact(inputs.Name, inputs.Destination, { createArtifactFolder: inputs.CreateSubfolder }).catch(errorHandle);
43+
console.log(delimiter);
44+
console.log(resultHandle({
45+
Name: result.artifactName,
46+
Path: result.downloadPath
47+
}));
48+
}
49+
break;
50+
case "artifact/download-all":
51+
{
52+
const result = await ghactionsArtifact().downloadAllArtifacts(inputs.Destination).catch(errorHandle);
53+
console.log(delimiter);
54+
console.log(resultHandle(result.map((value) => {
55+
return {
56+
Name: value.artifactName,
57+
Path: value.downloadPath
58+
};
59+
})));
60+
}
61+
break;
62+
case "artifact/upload":
63+
{
64+
const result = await ghactionsArtifact().uploadArtifact(inputs.Name, inputs.Path, inputs.BaseRoot, {
65+
continueOnError: inputs.ContinueOnIssue,
66+
retentionDays: inputs.RetentionTime
67+
}).catch(errorHandle);
68+
console.log(delimiter);
69+
console.log(resultHandle({
70+
FailedItem: result.failedItems,
71+
FailedItems: result.failedItems,
72+
Item: result.artifactItems,
73+
Items: result.artifactItems,
74+
Name: result.artifactName,
75+
Size: result.size,
76+
Sizes: result.size
77+
}));
78+
}
79+
break;
80+
case "cache/restore":
81+
{
82+
const result = await ghactionsCacheRestoreCache(inputs.Path, inputs.PrimaryKey, inputs.RestoreKey, {
83+
downloadConcurrency: inputs.DownloadConcurrency,
84+
lookupOnly: inputs.LookUp,
85+
segmentTimeoutInMs: inputs.SegmentTimeout,
86+
timeoutInMs: inputs.Timeout,
87+
useAzureSdk: inputs.UseAzureSdk
88+
}).catch(errorHandle);
89+
console.log(delimiter);
90+
console.log(resultHandle({ CacheKey: result ?? null }));
91+
}
92+
break;
93+
case "cache/save":
94+
{
95+
const result = await ghactionsCacheSaveCache(inputs.Path, inputs.Key, {
96+
uploadChunkSize: inputs.UploadChunkSizes,
97+
uploadConcurrency: inputs.UploadConcurrency
98+
}).catch(errorHandle);
99+
console.log(delimiter);
100+
console.log(resultHandle({ CacheId: result }));
101+
}
102+
break;
103+
case "open-id-connect/get-token":
104+
{
105+
const result = await ghactionsGetOpenIDConnectToken(inputs.Audience).catch(errorHandle);
106+
console.log(delimiter);
107+
console.log(resultHandle({ Token: result }));
108+
}
109+
break;
110+
case "tool-cache/cache-directory":
111+
{
112+
const result = await ghactionsToolCacheCacheDirectory(inputs.Source, inputs.Name, inputs.Version, inputs.Architecture).catch(errorHandle);
113+
console.log(delimiter);
114+
console.log(resultHandle({ Path: result }));
115+
}
116+
break;
117+
case "tool-cache/cache-file":
118+
{
119+
const result = await ghactionsToolCacheCacheFile(inputs.Source, inputs.Target, inputs.Name, inputs.Version, inputs.Architecture).catch(errorHandle);
120+
console.log(delimiter);
121+
console.log(resultHandle({ Path: result }));
122+
}
123+
break;
124+
case "tool-cache/download-tool":
125+
{
126+
const result = await ghactionToolCacheDownloadTool(inputs.Uri, inputs.Destination, inputs.Authorization, inputs.Header).catch(errorHandle);
127+
console.log(delimiter);
128+
console.log(resultHandle({ Path: result }));
129+
}
130+
break;
131+
case "tool-cache/extract-7z":
132+
{
133+
const result = await ghactionToolCacheExtract7z(inputs.File, inputs.Destination, inputs["7zrPath"]).catch(errorHandle);
134+
console.log(delimiter);
135+
console.log(resultHandle({ Path: result }));
136+
}
137+
break;
138+
case "tool-cache/extract-tar":
139+
{
140+
const result = await ghactionToolCacheExtractTar(inputs.File, inputs.Destination, inputs.Flag).catch(errorHandle);
141+
console.log(delimiter);
142+
console.log(resultHandle({ Path: result }));
143+
}
144+
break;
145+
case "tool-cache/extract-xar":
146+
{
147+
const result = await ghactionToolCacheExtractXar(inputs.File, inputs.Destination, inputs.Flag).catch(errorHandle);
148+
console.log(delimiter);
149+
console.log(resultHandle({ Path: result }));
150+
}
151+
break;
152+
case "tool-cache/extract-zip":
153+
{
154+
const result = await ghactionToolCacheExtractZip(inputs.File, inputs.Destination).catch(errorHandle);
155+
console.log(delimiter);
156+
console.log(resultHandle({ Path: result }));
157+
}
158+
break;
159+
case "tool-cache/find":
160+
{
161+
const result = ghactionsToolCacheFind(inputs.Name, inputs.Version, inputs.Architecture);
162+
console.log(delimiter);
163+
console.log(resultHandle({ Path: result }));
164+
}
165+
break;
166+
case "tool-cache/find-all-versions":
167+
{
168+
const result = ghactionsToolCacheFindAllVersions(inputs.Name, inputs.Architecture);
169+
console.log(delimiter);
170+
console.log(resultHandle({ Paths: result }));
171+
}
172+
break;
173+
default:
174+
errorHandle(`\`${wrapperName}\` is not a valid NodeJS wrapper name! Most likely a mistake made by the contributors, please report this issue.`);
175+
break;
176+
}

hugoalh.GitHubActionsToolkit/module/open-id-connect.psm1

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
#Requires -Version 7.2
33
Import-Module -Name (
44
@(
5-
'log',
6-
'nodejs-wrapper',
7-
'utility'
5+
'nodejs-wrapper'
86
) |
97
ForEach-Object -Process { Join-Path -Path $PSScriptRoot -ChildPath "$_.psm1" }
108
) -Prefix 'GitHubActions' -Scope 'Local'

0 commit comments

Comments
 (0)