Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ea1d95b70 | |||
| 6d0c21f0f5 | |||
| c31824144b |
@@ -4,7 +4,10 @@
|
||||
* Entry point for GitHub Action
|
||||
*/
|
||||
|
||||
import { readdir } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import * as core from "@actions/core";
|
||||
import { dirName } from "@ark/fs";
|
||||
import { type Inputs, main } from "./main.ts";
|
||||
import { createMcpServer } from "./mcp/server.ts";
|
||||
import { log } from "./utils/cli.ts";
|
||||
@@ -12,7 +15,41 @@ import { log } from "./utils/cli.ts";
|
||||
// Export createMcpServer so it can be called from the spawned MCP process
|
||||
export { createMcpServer };
|
||||
|
||||
async function printDirectoryTree(dir: string, prefix = "", rootDir = dir): Promise<string> {
|
||||
const entries = await readdir(dir, { withFileTypes: true });
|
||||
const lines: string[] = [];
|
||||
|
||||
for (let i = 0; i < entries.length; i++) {
|
||||
const entry = entries[i];
|
||||
const isLast = i === entries.length - 1;
|
||||
const currentPrefix = isLast ? "└── " : "├── ";
|
||||
const nextPrefix = isLast ? " " : "│ ";
|
||||
|
||||
const fullPath = join(dir, entry.name);
|
||||
lines.push(`${prefix}${currentPrefix}${entry.name}`);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
const subTree = await printDirectoryTree(fullPath, `${prefix}${nextPrefix}`, rootDir);
|
||||
lines.push(subTree);
|
||||
}
|
||||
}
|
||||
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
async function run(): Promise<void> {
|
||||
// Debug: Print current directory tree before changing directories
|
||||
const actionDir = dirName();
|
||||
log.info(`action dir: ${actionDir}`);
|
||||
try {
|
||||
const tree = await printDirectoryTree(actionDir);
|
||||
log.info(`Directory tree:\n${tree}`);
|
||||
} catch (error) {
|
||||
log.warning(
|
||||
`Failed to print directory tree: ${error instanceof Error ? error.message : String(error)}`
|
||||
);
|
||||
}
|
||||
|
||||
// Change to GITHUB_WORKSPACE if set (this is where actions/checkout puts the repo)
|
||||
// JavaScript actions run from the action's directory, not the checked-out repo
|
||||
if (process.env.GITHUB_WORKSPACE && process.cwd() !== process.env.GITHUB_WORKSPACE) {
|
||||
|
||||
+2
-1
@@ -19,8 +19,9 @@ await build({
|
||||
"sury",
|
||||
],
|
||||
// Provide a proper require shim for CommonJS modules bundled into ESM
|
||||
// We use a unique variable name to avoid conflicts with bundled imports
|
||||
banner: {
|
||||
js: `import { createRequire } from 'module'; import { fileURLToPath } from 'url'; import { dirname } from 'path'; const require = createRequire(import.meta.url); const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename);`,
|
||||
js: `import { createRequire as __createRequire } from 'module'; import { fileURLToPath as __fileURLToPath } from 'url'; import { dirname as __dirnameFn } from 'path'; const require = __createRequire(import.meta.url); const __filename = __fileURLToPath(import.meta.url); const __dirname = __dirnameFn(__filename);`,
|
||||
},
|
||||
// Enable tree-shaking to remove unused code
|
||||
treeShaking: true,
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { readdir } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { type } from "arktype";
|
||||
import { claude } from "./agents/claude.ts";
|
||||
import { createMcpConfigs } from "./mcp/config.ts";
|
||||
@@ -23,42 +21,8 @@ export interface MainResult {
|
||||
|
||||
export type PromptJSON = {};
|
||||
|
||||
async function printDirectoryTree(dir: string, prefix = "", rootDir = dir): Promise<string> {
|
||||
const entries = await readdir(dir, { withFileTypes: true });
|
||||
const lines: string[] = [];
|
||||
|
||||
for (let i = 0; i < entries.length; i++) {
|
||||
const entry = entries[i];
|
||||
const isLast = i === entries.length - 1;
|
||||
const currentPrefix = isLast ? "└── " : "├── ";
|
||||
const nextPrefix = isLast ? " " : "│ ";
|
||||
|
||||
const fullPath = join(dir, entry.name);
|
||||
lines.push(`${prefix}${currentPrefix}${entry.name}`);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
const subTree = await printDirectoryTree(fullPath, `${prefix}${nextPrefix}`, rootDir);
|
||||
lines.push(subTree);
|
||||
}
|
||||
}
|
||||
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
export async function main(inputs: Inputs): Promise<MainResult> {
|
||||
try {
|
||||
// Debug: Print current directory tree before anything runs
|
||||
const cwd = process.cwd();
|
||||
log.info(`Current working directory: ${cwd}`);
|
||||
try {
|
||||
const tree = await printDirectoryTree(cwd);
|
||||
log.info(`Directory tree:\n${tree}`);
|
||||
} catch (error) {
|
||||
log.warning(
|
||||
`Failed to print directory tree: ${error instanceof Error ? error.message : String(error)}`
|
||||
);
|
||||
}
|
||||
|
||||
log.info(`🐸 Running pullfrog/action@${packageJson.version}...`);
|
||||
|
||||
setupGitConfig();
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pullfrog/action",
|
||||
"version": "0.0.81",
|
||||
"version": "0.0.84",
|
||||
"type": "module",
|
||||
"files": [
|
||||
"index.js",
|
||||
|
||||
Reference in New Issue
Block a user