Skip to content

Commit fe39c4f

Browse files
committed
3rd fix of NodeJS wrapper
1 parent 63477af commit fe39c4f

File tree

5 files changed

+43
-38
lines changed

5 files changed

+43
-38
lines changed

.github/ISSUE_TEMPLATE/bug-report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ body:
1818
description: "What versions are affected? Versions must be listed as supported in the Security Policy (file: `SECURITY.md`)."
1919
multiple: true
2020
options:
21-
- "v1.3.2-beta.1"
21+
- "v1.3.2-beta.2"
2222
- "v1.3.1"
2323
- "v1.3.0"
2424
- "v1.2.3"

hugoalh.GitHubActionsToolkit/hugoalh.GitHubActionsToolkit.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@
250250
ReleaseNotes = '(Please visit https://github.com/hugoalh-studio/ghactions-toolkit-powershell/releases.)'
251251

252252
# Prerelease string of this module
253-
Prerelease = 'beta1'
253+
Prerelease = 'beta2'
254254

255255
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
256256
RequireLicenseAcceptance = $False

hugoalh.GitHubActionsToolkit/module/nodejs-invoke.psm1

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ Function Invoke-NodeJsWrapper {
3838
}
3939
[String]$ResultSeparator = "=====$(New-GitHubActionsRandomToken -Length 32)====="
4040
Try {
41-
[String[]]$Result = Invoke-Expression -Command "node --no-deprecation --no-warnings `"$WrapperPath`" `"$Name`" `"$(
41+
[String[]]$Result = Invoke-Expression -Command "node --no-deprecation --no-warnings `"$WrapperPath`" `"$Name`" `"$([System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes((
4242
$InputObject |
4343
ConvertTo-Json -Depth 100 -Compress
44-
)`" `"$ResultSeparator`""
44+
))))`" `"$ResultSeparator`""
4545
[UInt32]$ResultSkipIndex = @()
4646
For ([UInt32]$ResultIndex = 0; $ResultIndex -ilt $Result.Count; $ResultIndex++) {
4747
[String]$Item = $Result[$ResultIndex]
@@ -57,8 +57,7 @@ Function Invoke-NodeJsWrapper {
5757
Join-String -Separator "`n"
5858
)"
5959
}
60-
$Result[($Result.IndexOf($ResultSeparator) + 1)..($Result.Count - 1)] |
61-
Join-String -Separator "`n" |
60+
[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($Result[$Result.IndexOf($ResultSeparator) + 1])) |
6261
ConvertFrom-Json -Depth 100 |
6362
Write-Output
6463
}

hugoalh.GitHubActionsToolkit/module/nodejs-wrapper/dist/main.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -64294,14 +64294,17 @@ function errorHandle(reason) {
6429464294
console.error(reason?.message ?? reason);
6429564295
return process.exit(1);
6429664296
}
64297+
function resultHandle(result) {
64298+
return Buffer.from(JSON.stringify(result), "utf8").toString("base64");
64299+
}
6429764300
const [wrapperName, inputsRaw, delimiter] = process.argv.slice(2);
64298-
const inputs = JSON.parse(inputsRaw);
64301+
const inputs = JSON.parse(Buffer.from(inputsRaw, "base64").toString("utf8"));
6429964302
switch (wrapperName) {
6430064303
case "artifact/download":
6430164304
{
6430264305
const result = await (0,_actions_artifact__WEBPACK_IMPORTED_MODULE_1__/* .create */ .U)().downloadArtifact(inputs.Name, inputs.Destination, { createArtifactFolder: inputs.CreateSubfolder }).catch(errorHandle);
6430364306
console.log(delimiter);
64304-
console.log(JSON.stringify({
64307+
console.log(resultHandle({
6430564308
Name: result.artifactName,
6430664309
Path: result.downloadPath
6430764310
}));
@@ -64311,7 +64314,7 @@ switch (wrapperName) {
6431164314
{
6431264315
const result = await (0,_actions_artifact__WEBPACK_IMPORTED_MODULE_1__/* .create */ .U)().downloadAllArtifacts(inputs.Destination).catch(errorHandle);
6431364316
console.log(delimiter);
64314-
console.log(JSON.stringify(result.map((value) => {
64317+
console.log(resultHandle(result.map((value) => {
6431564318
return {
6431664319
Name: value.artifactName,
6431764320
Path: value.downloadPath
@@ -64326,7 +64329,7 @@ switch (wrapperName) {
6432664329
retentionDays: inputs.RetentionTime
6432764330
}).catch(errorHandle);
6432864331
console.log(delimiter);
64329-
console.log(JSON.stringify({
64332+
console.log(resultHandle({
6433064333
FailedItem: result.failedItems,
6433164334
FailedItems: result.failedItems,
6433264335
Item: result.artifactItems,
@@ -64347,7 +64350,7 @@ switch (wrapperName) {
6434764350
useAzureSdk: inputs.UseAzureSdk
6434864351
}).catch(errorHandle);
6434964352
console.log(delimiter);
64350-
console.log(JSON.stringify({ CacheKey: result ?? null }));
64353+
console.log(resultHandle({ CacheKey: result ?? null }));
6435164354
}
6435264355
break;
6435364356
case "cache/save":
@@ -64357,77 +64360,77 @@ switch (wrapperName) {
6435764360
uploadConcurrency: inputs.UploadConcurrency
6435864361
}).catch(errorHandle);
6435964362
console.log(delimiter);
64360-
console.log(JSON.stringify({ CacheId: result }));
64363+
console.log(resultHandle({ CacheId: result }));
6436164364
}
6436264365
break;
6436364366
case "open-id-connect/get-token":
6436464367
{
6436564368
const result = await (0,_actions_core__WEBPACK_IMPORTED_MODULE_2__.getIDToken)(inputs.Audience).catch(errorHandle);
6436664369
console.log(delimiter);
64367-
console.log(JSON.stringify({ Token: result }));
64370+
console.log(resultHandle({ Token: result }));
6436864371
}
6436964372
break;
6437064373
case "tool-cache/cache-directory":
6437164374
{
6437264375
const result = await (0,_actions_tool_cache__WEBPACK_IMPORTED_MODULE_0__.cacheDir)(inputs.Source, inputs.Name, inputs.Version, inputs.Architecture).catch(errorHandle);
6437364376
console.log(delimiter);
64374-
console.log(JSON.stringify({ Path: result }));
64377+
console.log(resultHandle({ Path: result }));
6437564378
}
6437664379
break;
6437764380
case "tool-cache/cache-file":
6437864381
{
6437964382
const result = await (0,_actions_tool_cache__WEBPACK_IMPORTED_MODULE_0__.cacheFile)(inputs.Source, inputs.Target, inputs.Name, inputs.Version, inputs.Architecture).catch(errorHandle);
6438064383
console.log(delimiter);
64381-
console.log(JSON.stringify({ Path: result }));
64384+
console.log(resultHandle({ Path: result }));
6438264385
}
6438364386
break;
6438464387
case "tool-cache/download-tool":
6438564388
{
6438664389
const result = await (0,_actions_tool_cache__WEBPACK_IMPORTED_MODULE_0__.downloadTool)(inputs.Uri, inputs.Destination, inputs.Authorization, inputs.Header).catch(errorHandle);
6438764390
console.log(delimiter);
64388-
console.log(JSON.stringify({ Path: result }));
64391+
console.log(resultHandle({ Path: result }));
6438964392
}
6439064393
break;
6439164394
case "tool-cache/extract-7z":
6439264395
{
6439364396
const result = await (0,_actions_tool_cache__WEBPACK_IMPORTED_MODULE_0__.extract7z)(inputs.File, inputs.Destination, inputs["7zrPath"]).catch(errorHandle);
6439464397
console.log(delimiter);
64395-
console.log(JSON.stringify({ Path: result }));
64398+
console.log(resultHandle({ Path: result }));
6439664399
}
6439764400
break;
6439864401
case "tool-cache/extract-tar":
6439964402
{
6440064403
const result = await (0,_actions_tool_cache__WEBPACK_IMPORTED_MODULE_0__.extractTar)(inputs.File, inputs.Destination, inputs.Flag).catch(errorHandle);
6440164404
console.log(delimiter);
64402-
console.log(JSON.stringify({ Path: result }));
64405+
console.log(resultHandle({ Path: result }));
6440364406
}
6440464407
break;
6440564408
case "tool-cache/extract-xar":
6440664409
{
6440764410
const result = await (0,_actions_tool_cache__WEBPACK_IMPORTED_MODULE_0__.extractXar)(inputs.File, inputs.Destination, inputs.Flag).catch(errorHandle);
6440864411
console.log(delimiter);
64409-
console.log(JSON.stringify({ Path: result }));
64412+
console.log(resultHandle({ Path: result }));
6441064413
}
6441164414
break;
6441264415
case "tool-cache/extract-zip":
6441364416
{
6441464417
const result = await (0,_actions_tool_cache__WEBPACK_IMPORTED_MODULE_0__.extractZip)(inputs.File, inputs.Destination).catch(errorHandle);
6441564418
console.log(delimiter);
64416-
console.log(JSON.stringify({ Path: result }));
64419+
console.log(resultHandle({ Path: result }));
6441764420
}
6441864421
break;
6441964422
case "tool-cache/find":
6442064423
{
6442164424
const result = (0,_actions_tool_cache__WEBPACK_IMPORTED_MODULE_0__.find)(inputs.Name, inputs.Version, inputs.Architecture);
6442264425
console.log(delimiter);
64423-
console.log(JSON.stringify({ Path: result }));
64426+
console.log(resultHandle({ Path: result }));
6442464427
}
6442564428
break;
6442664429
case "tool-cache/find-all-versions":
6442764430
{
6442864431
const result = (0,_actions_tool_cache__WEBPACK_IMPORTED_MODULE_0__.findAllVersions)(inputs.Name, inputs.Architecture);
6442964432
console.log(delimiter);
64430-
console.log(JSON.stringify({ Paths: result }));
64433+
console.log(resultHandle({ Paths: result }));
6443164434
}
6443264435
break;
6443364436
default:

nodejs-wrapper-source/src/main.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ function errorHandle(reason) {
66
console.error(reason?.message ?? reason);
77
return process.exit(1);
88
}
9+
function resultHandle(result) {
10+
return Buffer.from(JSON.stringify(result), "utf8").toString("base64");
11+
}
912
const [wrapperName, inputsRaw, delimiter] = process.argv.slice(2);
10-
const inputs = JSON.parse(inputsRaw);
13+
const inputs = JSON.parse(Buffer.from(inputsRaw, "base64").toString("utf8"));
1114
switch (wrapperName) {
1215
case "artifact/download":
1316
{
1417
const result = await ghactionsArtifact().downloadArtifact(inputs.Name, inputs.Destination, { createArtifactFolder: inputs.CreateSubfolder }).catch(errorHandle);
1518
console.log(delimiter);
16-
console.log(JSON.stringify({
19+
console.log(resultHandle({
1720
Name: result.artifactName,
1821
Path: result.downloadPath
1922
}));
@@ -23,7 +26,7 @@ switch (wrapperName) {
2326
{
2427
const result = await ghactionsArtifact().downloadAllArtifacts(inputs.Destination).catch(errorHandle);
2528
console.log(delimiter);
26-
console.log(JSON.stringify(result.map((value) => {
29+
console.log(resultHandle(result.map((value) => {
2730
return {
2831
Name: value.artifactName,
2932
Path: value.downloadPath
@@ -38,7 +41,7 @@ switch (wrapperName) {
3841
retentionDays: inputs.RetentionTime
3942
}).catch(errorHandle);
4043
console.log(delimiter);
41-
console.log(JSON.stringify({
44+
console.log(resultHandle({
4245
FailedItem: result.failedItems,
4346
FailedItems: result.failedItems,
4447
Item: result.artifactItems,
@@ -59,7 +62,7 @@ switch (wrapperName) {
5962
useAzureSdk: inputs.UseAzureSdk
6063
}).catch(errorHandle);
6164
console.log(delimiter);
62-
console.log(JSON.stringify({ CacheKey: result ?? null }));
65+
console.log(resultHandle({ CacheKey: result ?? null }));
6366
}
6467
break;
6568
case "cache/save":
@@ -69,77 +72,77 @@ switch (wrapperName) {
6972
uploadConcurrency: inputs.UploadConcurrency
7073
}).catch(errorHandle);
7174
console.log(delimiter);
72-
console.log(JSON.stringify({ CacheId: result }));
75+
console.log(resultHandle({ CacheId: result }));
7376
}
7477
break;
7578
case "open-id-connect/get-token":
7679
{
7780
const result = await ghactionsGetOpenIDConnectToken(inputs.Audience).catch(errorHandle);
7881
console.log(delimiter);
79-
console.log(JSON.stringify({ Token: result }));
82+
console.log(resultHandle({ Token: result }));
8083
}
8184
break;
8285
case "tool-cache/cache-directory":
8386
{
8487
const result = await ghactionsToolCacheCacheDirectory(inputs.Source, inputs.Name, inputs.Version, inputs.Architecture).catch(errorHandle);
8588
console.log(delimiter);
86-
console.log(JSON.stringify({ Path: result }));
89+
console.log(resultHandle({ Path: result }));
8790
}
8891
break;
8992
case "tool-cache/cache-file":
9093
{
9194
const result = await ghactionsToolCacheCacheFile(inputs.Source, inputs.Target, inputs.Name, inputs.Version, inputs.Architecture).catch(errorHandle);
9295
console.log(delimiter);
93-
console.log(JSON.stringify({ Path: result }));
96+
console.log(resultHandle({ Path: result }));
9497
}
9598
break;
9699
case "tool-cache/download-tool":
97100
{
98101
const result = await ghactionToolCacheDownloadTool(inputs.Uri, inputs.Destination, inputs.Authorization, inputs.Header).catch(errorHandle);
99102
console.log(delimiter);
100-
console.log(JSON.stringify({ Path: result }));
103+
console.log(resultHandle({ Path: result }));
101104
}
102105
break;
103106
case "tool-cache/extract-7z":
104107
{
105108
const result = await ghactionToolCacheExtract7z(inputs.File, inputs.Destination, inputs["7zrPath"]).catch(errorHandle);
106109
console.log(delimiter);
107-
console.log(JSON.stringify({ Path: result }));
110+
console.log(resultHandle({ Path: result }));
108111
}
109112
break;
110113
case "tool-cache/extract-tar":
111114
{
112115
const result = await ghactionToolCacheExtractTar(inputs.File, inputs.Destination, inputs.Flag).catch(errorHandle);
113116
console.log(delimiter);
114-
console.log(JSON.stringify({ Path: result }));
117+
console.log(resultHandle({ Path: result }));
115118
}
116119
break;
117120
case "tool-cache/extract-xar":
118121
{
119122
const result = await ghactionToolCacheExtractXar(inputs.File, inputs.Destination, inputs.Flag).catch(errorHandle);
120123
console.log(delimiter);
121-
console.log(JSON.stringify({ Path: result }));
124+
console.log(resultHandle({ Path: result }));
122125
}
123126
break;
124127
case "tool-cache/extract-zip":
125128
{
126129
const result = await ghactionToolCacheExtractZip(inputs.File, inputs.Destination).catch(errorHandle);
127130
console.log(delimiter);
128-
console.log(JSON.stringify({ Path: result }));
131+
console.log(resultHandle({ Path: result }));
129132
}
130133
break;
131134
case "tool-cache/find":
132135
{
133136
const result = ghactionsToolCacheFind(inputs.Name, inputs.Version, inputs.Architecture);
134137
console.log(delimiter);
135-
console.log(JSON.stringify({ Path: result }));
138+
console.log(resultHandle({ Path: result }));
136139
}
137140
break;
138141
case "tool-cache/find-all-versions":
139142
{
140143
const result = ghactionsToolCacheFindAllVersions(inputs.Name, inputs.Architecture);
141144
console.log(delimiter);
142-
console.log(JSON.stringify({ Paths: result }));
145+
console.log(resultHandle({ Paths: result }));
143146
}
144147
break;
145148
default:

0 commit comments

Comments
 (0)