try esm action
This commit is contained in:
+1
-4
@@ -1,6 +1,3 @@
|
||||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
# Ensure lockfile is up to date
|
||||
echo "🔒 Updating lockfile..."
|
||||
pnpm install --lockfile-only
|
||||
@@ -10,4 +7,4 @@ echo "🔨 Building action..."
|
||||
pnpm build
|
||||
|
||||
# Add the built files and lockfile to the commit
|
||||
git add entry.cjs pnpm-lock.yaml
|
||||
git add entry.js pnpm-lock.yaml
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ inputs:
|
||||
|
||||
runs:
|
||||
using: "node20"
|
||||
main: "entry.cjs"
|
||||
main: "entry.js"
|
||||
|
||||
branding:
|
||||
icon: "code"
|
||||
|
||||
@@ -37,11 +37,4 @@ async function run(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
// Only run main action if INPUTS_JSON is set (running as GitHub Action)
|
||||
// When SDK spawns MCP server, it calls createMcpServer() directly
|
||||
if (process.env.INPUTS_JSON) {
|
||||
// Wrap in IIFE to avoid top-level await in CJS
|
||||
(async () => {
|
||||
await run();
|
||||
})();
|
||||
}
|
||||
await run();
|
||||
|
||||
+6
-3
@@ -5,13 +5,16 @@ import { build } from "esbuild";
|
||||
await build({
|
||||
entryPoints: ["./entry.ts"],
|
||||
bundle: true,
|
||||
outfile: "./entry.cjs",
|
||||
format: "cjs",
|
||||
outfile: "./entry.js",
|
||||
format: "esm",
|
||||
platform: "node",
|
||||
target: "node20",
|
||||
minify: true,
|
||||
sourcemap: false,
|
||||
// Mark optional peer dependencies as external to avoid bundling errors
|
||||
// Mark all node_modules as external - Node.js will handle ESM/CJS interop natively
|
||||
// This avoids esbuild's require() polyfill which doesn't work in ESM
|
||||
packages: "external",
|
||||
// Mark optional peer dependencies as external
|
||||
external: [
|
||||
"@valibot/to-json-schema",
|
||||
"effect",
|
||||
|
||||
+8
-4
@@ -15,15 +15,19 @@ export function createMcpConfigs(githubInstallationToken: string): McpConfigs {
|
||||
const repoContext = parseRepoContext();
|
||||
const githubRepository = `${repoContext.owner}/${repoContext.name}`;
|
||||
|
||||
// Get absolute path to entry.cjs - use GITHUB_ACTION_PATH if available, otherwise current directory
|
||||
// Get absolute path to entry.js - use GITHUB_ACTION_PATH if available, otherwise current directory
|
||||
const entryPath = process.env.GITHUB_ACTION_PATH
|
||||
? `${process.env.GITHUB_ACTION_PATH}/entry.cjs`
|
||||
: `${process.cwd()}/entry.cjs`;
|
||||
? `${process.env.GITHUB_ACTION_PATH}/entry.js`
|
||||
: `${process.cwd()}/entry.js`;
|
||||
|
||||
return {
|
||||
[ghPullfrogMcpName]: {
|
||||
command: "node",
|
||||
args: ["-e", `require('${entryPath.replace(/'/g, "\\'")}').createMcpServer()`],
|
||||
args: [
|
||||
"--input-type=module",
|
||||
"-e",
|
||||
`import('${entryPath.replace(/'/g, "\\'")}').then(m => m.createMcpServer())`,
|
||||
],
|
||||
env: {
|
||||
GITHUB_INSTALLATION_TOKEN: githubInstallationToken,
|
||||
GITHUB_REPOSITORY: githubRepository,
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pullfrog/action",
|
||||
"version": "0.0.75",
|
||||
"version": "0.0.76",
|
||||
"type": "module",
|
||||
"files": [
|
||||
"index.js",
|
||||
|
||||
@@ -50,8 +50,16 @@ export function setupGitConfig(): void {
|
||||
|
||||
/**
|
||||
* Setup git authentication using GitHub token
|
||||
* Only runs in GitHub Actions environment to avoid breaking local git remotes
|
||||
*/
|
||||
export function setupGitAuth(githubToken: string, repoContext: RepoContext): void {
|
||||
// Only set up git auth in GitHub Actions environment
|
||||
// In local testing, this would overwrite the real git remote with fake credentials
|
||||
if (!process.env.GITHUB_ACTIONS) {
|
||||
log.info("⚠️ Skipping git authentication setup (not in GitHub Actions)");
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("🔐 Setting up git authentication...");
|
||||
|
||||
// Remove existing git auth headers that actions/checkout might have set
|
||||
|
||||
Reference in New Issue
Block a user