Skip to content

Commit c58a3f8

Browse files
committed
20230721D
1 parent ba173ca commit c58a3f8

File tree

9 files changed

+107
-284
lines changed

9 files changed

+107
-284
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.7.0-beta.5"
21+
- "v1.7.0-beta.6"
2222
- "v1.6.0"
2323
- "v1.5.0"
2424
- "v1.4.1"

.github/workflows/publish-powershell-module-psg.yml

Lines changed: 5 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -10,68 +10,8 @@ defaults:
1010
jobs:
1111
main:
1212
name: "Main"
13-
runs-on: "ubuntu-latest"
14-
steps:
15-
- name: "Checkout Repository"
16-
uses: "actions/[email protected]"
17-
- name: "Setup NodeJS"
18-
uses: "actions/[email protected]"
19-
with:
20-
node-version: "14"
21-
check-latest: true
22-
registry-url: "https://registry.npmjs.org/"
23-
- name: "Setup PowerShell Toolkit"
24-
uses: "hugoalh-studio/[email protected]"
25-
with:
26-
version: "^1.6.0"
27-
- name: "Get NodeJS Wrapper Directory"
28-
id: "nodejs-wrapper-directory"
29-
run: |
30-
Import-Module -Name 'hugoalh.GitHubActionsToolkit' -Scope 'Local'
31-
[String]$NodeJSWrapperRoot = Join-Path -Path $Env:GITHUB_WORKSPACE -ChildPath 'hugoalh.GitHubActionsToolkit\nodejs-wrapper'
32-
Set-GitHubActionsOutput -Name 'path' -Value $NodeJSWrapperRoot
33-
- name: "Bundle NodeJS Wrapper Dependencies"
34-
run: |
35-
npm install --package-lock=false
36-
working-directory: "${{steps.nodejs-wrapper-directory.outputs.path}}"
37-
- name: "Test Publish"
38-
run: |
39-
Publish-Module -Path '.\hugoalh.GitHubActionsToolkit\' -NugetAPIKey 'GUID' -WhatIf -Verbose
40-
- name: "Publish"
41-
run: |
42-
Publish-Module -Path '.\hugoalh.GitHubActionsToolkit\' -NugetAPIKey '${{secrets.POWERSHELLGALLERY_TOKEN}}' -Verbose
43-
main-fallback:
44-
name: "Main (Fallback)"
45-
needs:
46-
- "main"
47-
if: "${{needs.main.result == 'failure'}}"
48-
runs-on: "windows-latest"
49-
steps:
50-
- name: "Checkout Repository"
51-
uses: "actions/[email protected]"
52-
- name: "Setup NodeJS"
53-
uses: "actions/[email protected]"
54-
with:
55-
node-version: "14"
56-
check-latest: true
57-
registry-url: "https://registry.npmjs.org/"
58-
- name: "Setup PowerShell Toolkit"
59-
uses: "hugoalh-studio/[email protected]"
60-
with:
61-
version: "^1.6.0"
62-
- name: "Get NodeJS Wrapper Directory"
63-
id: "nodejs-wrapper-directory"
64-
run: |
65-
Import-Module -Name 'hugoalh.GitHubActionsToolkit' -Scope 'Local'
66-
[String]$NodeJSWrapperRoot = Join-Path -Path $Env:GITHUB_WORKSPACE -ChildPath 'hugoalh.GitHubActionsToolkit\nodejs-wrapper'
67-
Set-GitHubActionsOutput -Name 'path' -Value $NodeJSWrapperRoot
68-
- name: "Bundle NodeJS Wrapper Dependencies"
69-
run: |
70-
npm install --package-lock=false
71-
working-directory: "${{steps.nodejs-wrapper-directory.outputs.path}}"
72-
- name: "Test Publish"
73-
run: |
74-
Publish-Module -Path '.\hugoalh.GitHubActionsToolkit\' -NugetAPIKey 'GUID' -WhatIf -Verbose
75-
- name: "Publish"
76-
run: |
77-
Publish-Module -Path '.\hugoalh.GitHubActionsToolkit\' -NugetAPIKey '${{secrets.POWERSHELLGALLERY_TOKEN}}' -Verbose
13+
uses: "hugoalh/hugoalh/.github/workflows/publish-powershell-module-psg.yml@main"
14+
with:
15+
path: ".\\hugoalh.GitHubActionsToolkit\\"
16+
secrets:
17+
POWERSHELLGALLERY_TOKEN: "${{secrets.POWERSHELLGALLERY_TOKEN}}"

bundler.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { execSync } from "node:child_process";
2+
import { existsSync as fsExistsSync } from "node:fs";
3+
import { mkdir as fsMkdir, readdir as fsReaddir, readFile as fsReadFile, rm as fsRm, writeFile as fsWriteFile } from "node:fs/promises";
4+
import { dirname as pathDirname, join as pathJoin } from "node:path";
5+
import { fileURLToPath } from "node:url";
6+
import ncc from "@vercel/ncc";
7+
const root = pathDirname(fileURLToPath(import.meta.url));
8+
const packageFileName = "package.json"
9+
const scriptEntryPointFileName = "main.js";
10+
const inputDirectoryPath = pathJoin(root, "temp");
11+
const inputFilePath = pathJoin(inputDirectoryPath, scriptEntryPointFileName);
12+
const outputDirectoryPath = pathJoin(root, "hugoalh.GitHubActionsToolkit", "nodejs-wrapper");
13+
const outputFilePath = pathJoin(outputDirectoryPath, scriptEntryPointFileName);
14+
async function getDirectoryItem(directoryPath, relativeBasePath) {
15+
if (typeof relativeBasePath === "undefined") {
16+
relativeBasePath = directoryPath;
17+
}
18+
try {
19+
let result = [];
20+
for (let item of await fsReaddir(directoryPath, { withFileTypes: true })) {
21+
if (item.isDirectory()) {
22+
result.push(...await getDirectoryItem(pathJoin(directoryPath, item.name), relativeBasePath));
23+
} else {
24+
result.push(pathJoin(directoryPath, item.name).slice(relativeBasePath.length + 1).replace(/\\/gu, "/"));
25+
}
26+
}
27+
return result;
28+
} catch (error) {
29+
return [];
30+
}
31+
}
32+
33+
/* Clean up or initialize output directory (need to await in order to prevent race conditions). */
34+
if (fsExistsSync(outputDirectoryPath)) {
35+
for (let fileName of await getDirectoryItem(outputDirectoryPath)) {
36+
await fsRm(pathJoin(outputDirectoryPath, fileName), { recursive: true });
37+
}
38+
} else {
39+
await fsMkdir(outputDirectoryPath, { recursive: true });
40+
}
41+
42+
/* Create bundle. */
43+
console.log(execSync(`"${pathJoin(root, "node_modules", ".bin", process.platform === "win32" ? "tsc.cmd" : "tsc")}" -p "${pathJoin(root, "tsconfig.json")}"`).toString("utf8"));
44+
let { code } = await ncc(inputFilePath, {
45+
assetBuilds: false,
46+
cache: false,
47+
debugLog: false,
48+
license: "",
49+
minify: true,
50+
quiet: false,
51+
sourceMap: false,
52+
sourceMapRegister: false,
53+
target: "es2020",
54+
v8cache: false,
55+
watch: false
56+
});
57+
await fsWriteFile(outputFilePath, code, { encoding: "utf8" });
58+
let packageMeta = JSON.parse(await fsReadFile(pathJoin(root, packageFileName), { encoding: "utf8" }));
59+
delete packageMeta.scripts;
60+
delete packageMeta.dependencies;
61+
delete packageMeta.devDependencies;
62+
await fsWriteFile(pathJoin(outputDirectoryPath, packageFileName), `${JSON.stringify(packageMeta, undefined, "\t")}\n`, { encoding: "utf8" });

hugoalh.GitHubActionsToolkit/hugoalh.GitHubActionsToolkit.psd1

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

276276
# Prerelease string of this module
277-
Prerelease = 'beta5'
277+
Prerelease = 'beta6'
278278

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

hugoalh.GitHubActionsToolkit/nodejs-wrapper/main.js

Lines changed: 24 additions & 208 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hugoalh.GitHubActionsToolkit/nodejs-wrapper/package.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hugoalh/ghactions-toolkit-powershell-nodejs-wrapper",
3-
"version": "1.7.0-beta.5",
3+
"version": "1.7.0-beta.6",
44
"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.",
55
"keywords": [
66
"gh-actions",
@@ -24,12 +24,6 @@
2424
"type": "git",
2525
"url": "git+https://github.com/hugoalh-studio/ghactions-toolkit-powershell.git"
2626
},
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-
},
3327
"engines": {
3428
"node": ">=14.15.0"
3529
},

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hugoalh/ghactions-toolkit-powershell-nodejs-wrapper",
3-
"version": "1.7.0-beta.5",
3+
"version": "1.7.0-beta.6",
44
"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.",
55
"keywords": [
66
"gh-actions",
@@ -24,6 +24,9 @@
2424
"type": "git",
2525
"url": "git+https://github.com/hugoalh-studio/ghactions-toolkit-powershell.git"
2626
},
27+
"scripts": {
28+
"build": "node bundler.js"
29+
},
2730
"dependencies": {
2831
"@actions/artifact": "^1.1.1",
2932
"@actions/cache": "^3.2.1",
@@ -34,6 +37,7 @@
3437
"@types/node": "^20.4.2",
3538
"@typescript-eslint/eslint-plugin": "^6.1.0",
3639
"@typescript-eslint/parser": "^6.1.0",
40+
"@vercel/ncc": "^0.36.1",
3741
"eslint": "^8.45.0",
3842
"eslint-plugin-only-warn": "^1.1.0",
3943
"typescript": "^5.1.6"

pnpm-lock.yaml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"forceConsistentCasingInFileNames": true,
1111
"module": "NodeNext",
1212
"moduleResolution": "NodeNext",
13-
"outDir": "./hugoalh.GitHubActionsToolkit/nodejs-wrapper",
13+
"outDir": "./temp",
1414
"target": "ES2020"
1515
},
1616
"include": [

0 commit comments

Comments
 (0)