Skip to content

Commit ce0eeee

Browse files
committed
build: update action.yml to use node runner
1 parent 53c3bf1 commit ce0eeee

File tree

4 files changed

+85
-37
lines changed

4 files changed

+85
-37
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,6 @@ out
133133
# Vite logs files
134134
vite.config.js.timestamp-*
135135
vite.config.ts.timestamp-*
136+
137+
# SVG output directory
138+
output

action.yml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,5 @@ inputs:
1616
default: ${{ github.token }}
1717

1818
runs:
19-
using: "composite"
20-
steps:
21-
- uses: actions/setup-node@v4
22-
with:
23-
node-version: 23
24-
- run: npm install
25-
shell: bash
26-
- run: mkdir -p output
27-
shell: bash
28-
- run: npx ts-node src/cli.ts "${{ inputs.github_username }}" "${{ inputs.github_token }}" light > output/light.svg
29-
shell: bash
30-
- run: npx ts-node src/cli.ts "${{ inputs.github_username }}" "${{ inputs.github_token }}" dark > output/dark.svg
31-
shell: bash
19+
using: node20
20+
main: dist/cli.js

dist/cli.js

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,64 @@
11
"use strict";
2+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3+
if (k2 === undefined) k2 = k;
4+
var desc = Object.getOwnPropertyDescriptor(m, k);
5+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6+
desc = { enumerable: true, get: function() { return m[k]; } };
7+
}
8+
Object.defineProperty(o, k2, desc);
9+
}) : (function(o, m, k, k2) {
10+
if (k2 === undefined) k2 = k;
11+
o[k2] = m[k];
12+
}));
13+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14+
Object.defineProperty(o, "default", { enumerable: true, value: v });
15+
}) : function(o, v) {
16+
o["default"] = v;
17+
});
18+
var __importStar = (this && this.__importStar) || (function () {
19+
var ownKeys = function(o) {
20+
ownKeys = Object.getOwnPropertyNames || function (o) {
21+
var ar = [];
22+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23+
return ar;
24+
};
25+
return ownKeys(o);
26+
};
27+
return function (mod) {
28+
if (mod && mod.__esModule) return mod;
29+
var result = {};
30+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31+
__setModuleDefault(result, mod);
32+
return result;
33+
};
34+
})();
235
Object.defineProperty(exports, "__esModule", { value: true });
336
const svg_1 = require("./svg");
4-
// Get the GitHub username from command line arguments
5-
const username = process.argv[2];
6-
// Get the GitHub token from command line arguments or environment variable
37+
const fs = __importStar(require("fs"));
38+
const path = __importStar(require("path"));
39+
// Get the GitHub username and token from command line arguments or environment variables
40+
const username = process.argv[2] || process.env.GITHUB_USERNAME;
741
const token = process.argv[3] || process.env.GITHUB_TOKEN;
8-
// Get the mode (dark or light) from command line arguments or use 'light' as default
9-
const mode = process.argv[4] || "light";
1042
// If no token or username is provided, print usage and exit
11-
if (!token || !username) {
12-
console.error("Usage: node test-svg.js <github-username> <github-token> [dark|light]");
43+
if (!username || !token) {
44+
console.error("Usage: node cli.js <github-username> <github-token>\n" +
45+
"Or set GITHUB_USERNAME and GITHUB_TOKEN as environment variables.");
1346
process.exit(1);
1447
}
15-
// Call generateSVG and handle the result or any errors
16-
(0, svg_1.generateSVG)(username, token, mode === "dark")
17-
.then((svg) => console.log(svg))
48+
// Ensure output directory exists
49+
const outDir = path.join(process.cwd(), "output");
50+
if (!fs.existsSync(outDir)) {
51+
fs.mkdirSync(outDir, { recursive: true });
52+
}
53+
// Generate both light and dark SVGs
54+
Promise.all([
55+
(0, svg_1.generateSVG)(username, token, false).then((svg) => fs.writeFileSync(path.join(outDir, "light.svg"), svg)),
56+
(0, svg_1.generateSVG)(username, token, true).then((svg) => fs.writeFileSync(path.join(outDir, "dark.svg"), svg)),
57+
])
58+
.then(() => {
59+
console.log("SVGs generated: output/light.svg, output/dark.svg");
60+
})
1861
.catch((err) => {
19-
console.error("Failed to generate SVG:", err);
62+
console.error("Failed to generate SVGs:", err);
2063
process.exit(1);
2164
});

src/cli.ts

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,39 @@
11
import { generateSVG } from "./svg";
2+
import * as fs from "fs";
3+
import * as path from "path";
24

3-
// Get the GitHub username from command line arguments
4-
const username = process.argv[2];
5-
6-
// Get the GitHub token from command line arguments or environment variable
5+
// Get the GitHub username and token from command line arguments or environment variables
6+
const username = process.argv[2] || process.env.GITHUB_USERNAME;
77
const token = process.argv[3] || process.env.GITHUB_TOKEN;
88

9-
// Get the mode (dark or light) from command line arguments or use 'light' as default
10-
const mode = process.argv[4] || "light";
11-
129
// If no token or username is provided, print usage and exit
13-
if (!token || !username) {
10+
if (!username || !token) {
1411
console.error(
15-
"Usage: node test-svg.js <github-username> <github-token> [dark|light]",
12+
"Usage: node cli.js <github-username> <github-token>\n" +
13+
"Or set GITHUB_USERNAME and GITHUB_TOKEN as environment variables.",
1614
);
1715
process.exit(1);
1816
}
1917

20-
// Call generateSVG and handle the result or any errors
21-
generateSVG(username, token, mode === "dark")
22-
.then((svg) => console.log(svg))
18+
// Ensure output directory exists
19+
const outDir = path.join(process.cwd(), "output");
20+
if (!fs.existsSync(outDir)) {
21+
fs.mkdirSync(outDir, { recursive: true });
22+
}
23+
24+
// Generate both light and dark SVGs
25+
Promise.all([
26+
generateSVG(username, token, false).then((svg) =>
27+
fs.writeFileSync(path.join(outDir, "light.svg"), svg),
28+
),
29+
generateSVG(username, token, true).then((svg) =>
30+
fs.writeFileSync(path.join(outDir, "dark.svg"), svg),
31+
),
32+
])
33+
.then(() => {
34+
console.log("SVGs generated: output/light.svg, output/dark.svg");
35+
})
2336
.catch((err) => {
24-
console.error("Failed to generate SVG:", err);
37+
console.error("Failed to generate SVGs:", err);
2538
process.exit(1);
2639
});

0 commit comments

Comments
 (0)