-
Notifications
You must be signed in to change notification settings - Fork 28
Support TypeScript plugins in find plugin manager via esbuild #187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
abdulahmad307
merged 22 commits into
main
from
copilot/implement-esbuild-plugin-support
Apr 20, 2026
Merged
Changes from 8 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
f25c32b
POC TypeScript plugin loading with esbuild fallback
Copilot 3646661
Improve esbuild no-output error messaging
Copilot 4d62c1a
refactor copilot code
abdulahmad307 588a2cc
formatting fixes
abdulahmad307 ef53f46
log custom plugins
abdulahmad307 3472732
testing
abdulahmad307 ec52e36
remove testing logs
abdulahmad307 aefd2f4
update tests
abdulahmad307 8d6f0ce
update pluginManager file paths
abdulahmad307 59e7848
update the types
abdulahmad307 05c103d
update package-lock from main
abdulahmad307 5ce6e16
merge main
abdulahmad307 11fe1fb
update docs
abdulahmad307 c658432
fix lint inssue
abdulahmad307 cb1baf6
update test plugin so its clear why it exists
abdulahmad307 778ade2
fix import
abdulahmad307 267ae02
fix linting
abdulahmad307 7d90426
update docs with suggested feedback
abdulahmad307 8cc49ca
Update .github/actions/find/src/pluginManager/index.ts
abdulahmad307 8d7526c
add new test plugin to list of plugins to skip
abdulahmad307 51ffc31
explicitly install find dependencies
abdulahmad307 3243dd5
go up 1 more level to get the right path
abdulahmad307 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
.github/actions/find/src/pluginManager/pluginFileLoaders.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import * as fs from 'fs' | ||
| import * as path from 'path' | ||
| import * as esbuild from 'esbuild' | ||
| import {dynamicImport} from '../dynamicImport.js' | ||
| import * as core from '@actions/core' | ||
| import { Plugin } from './types.js' | ||
|
abdulahmad307 marked this conversation as resolved.
Outdated
|
||
|
|
||
| // - these functions had to be moved into a separate file | ||
| // because vitest will not mock the implementation of functions | ||
| // that are in the same file as the function under test. | ||
| // - https://vitest.dev/guide/mocking/modules.html#mocking-modules-pitfalls | ||
| export async function loadPluginViaTsFile(pluginFolderPath: string): Promise<Plugin | undefined> { | ||
| const pluginEntryPath = path.join(pluginFolderPath, 'index.ts') | ||
| if (!fs.existsSync(pluginEntryPath)) { | ||
| core.info(`No index.ts found for plugin at path: ${pluginFolderPath}`) | ||
| return | ||
| } | ||
|
|
||
| core.info(`index.ts found for plugin at path: ${pluginFolderPath}`) | ||
| const esbuildResult = await esbuild.build({ | ||
| entryPoints: [pluginEntryPath], | ||
| write: false, | ||
| bundle: true, | ||
| format: 'esm', | ||
| platform: 'node', | ||
| target: 'node24', | ||
| sourcemap: 'inline', | ||
| }) | ||
|
|
||
| const outputFileContents = esbuildResult.outputFiles[0]?.text | ||
| if (!outputFileContents) { | ||
| core.info(`esbuild produced no output for plugin: ${pluginEntryPath}`) | ||
| return | ||
| } | ||
|
|
||
| const base64CompiledPlugin = Buffer.from(outputFileContents).toString('base64') | ||
| return dynamicImport(`data:text/javascript;base64,${base64CompiledPlugin}`) | ||
| } | ||
|
|
||
| export async function loadPluginViaJsFile(pluginFolderPath: string): Promise<Plugin | undefined> { | ||
| const pluginEntryPath = path.join(pluginFolderPath, 'index.js') | ||
| if (!fs.existsSync(pluginEntryPath)) { | ||
| core.info(`No index.js found for plugin at path: ${pluginFolderPath}`) | ||
| return | ||
| } | ||
|
|
||
| core.info(`index.js found for plugin at path: ${pluginFolderPath}`) | ||
| return dynamicImport(pluginEntryPath) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import type {Finding} from './types.d.js' | ||
| import playwright from 'playwright' | ||
|
|
||
| type PluginDefaultParams = { | ||
| page: playwright.Page | ||
| addFinding: (findingData: Finding) => Promise<void> | ||
| } | ||
|
|
||
| export type Plugin = { | ||
| name: string | ||
| default: (options: PluginDefaultParams) => Promise<void> | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.