Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: JavaScript CodeQL Configuration

paths-ignore:
- coverage
- megalinter-reports
- node_modules
- reports
79 changes: 79 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Copilot Instructions

## Environment Setup

Install dependencies by running:

```bash
npm install
```

## Testing

Ensure all unit tests pass by running:

```bash
npm run test
```

Unit tests should exist in the `__tests__` directory. They are powered by
`jest`. Fixtures should be placed in the `__fixtures__` directory.

## General Coding Guidelines

- Follow standard TypeScript and JavaScript coding conventions and best
practices
- Changes should maintain consistency with existing patterns and style
- Document changes clearly and thoroughly, including updates to existing
comments when appropriate
- Do not include basic, unnecessary comments that simply restate what the code
is doing (focus on explaining _why_, not _what_)
- Use consistent error handling patterns throughout the codebase
- Use TypeScript's type system to ensure type safety and clarity
- Keep functions focused and manageable
- Use descriptive variable and function names that clearly convey their purpose
- Use JSDoc comments to document functions, classes, and complex logic
- After doing any refactoring, ensure to run `npm run test` to ensure that all
tests still pass and coverage requirements are met
- When suggesting code changes, always opt for the most maintainable approach.
Try your best to keep the code clean and follow "Don't Repeat Yourself" (DRY)
principles
- Avoid unnecessary complexity and always consider the long-term maintainability
of the code
- When writing unit tests, try to consider edge cases as well as the main path
of success. This will help ensure that the code is robust and can handle
unexpected inputs or situations

### Versioning

GitHub Actions are versioned using branch and tag names. Please ensure the
version in the project's `package.json` is updated to reflect the changes made
in the codebase. The version should follow
[Semantic Versioning](https://semver.org/) principles.

## Pull Request Guidelines

When creating a pull request (PR), please ensure that:

- Keep changes focused and minimal (avoid large changes, or consider breaking
them into separate, smaller PRs)
- Formatting checks pass
- Linting checks pass
- Unit tests pass and coverage requirements are met
- If necessary, the `README.md` file is updated to reflect any changes in
functionality or usage

The body of the PR should include:

- A summary of the changes
- A special note of any changes to dependencies
- A link to any relevant issues or discussions
- Any additional context that may be helpful for reviewers

## Code Review Guidelines

When performing a code review, please follow these guidelines:

- If there are changes that modify the functionality/usage of the action,
validate that there are changes in the `README.md` file that document the new
or modified functionality
1 change: 1 addition & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
with:
languages: ${{ matrix.language }}
source-root: src
config-file: .github/codeql/codeql-config.yml

- name: Autobuild
id: autobuild
Expand Down
9 changes: 9 additions & 0 deletions .vscode/mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"servers": {
"github": {
"url": "https://api.githubcopilot.com/mcp/",
"type": "http"
}
},
"inputs": []
}
15 changes: 15 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"github.copilot.chat.reviewSelection.instructions": [
{
"text": "Review the code changes carefully before accepting them."
}
],
"github.copilot.chat.commitMessageGeneration.instructions": [
{
"text": "Use conventional commit message format."
}
],
"github.copilot.chat.pullRequestDescriptionGeneration.instructions": [
{ "text": "Always include a list of key changes." }
]
}
5 changes: 5 additions & 0 deletions bin/local-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ function entrypoint() {
? path.join(packagePath, 'src', 'bootstrap.ts').replaceAll('\\', '\\\\')
: path.join(packagePath, 'src', 'bootstrap.ts')

// Require the bootstrap script in NODE_OPTIONS.
process.env.NODE_OPTIONS = process.env.NODE_OPTIONS
? `${process.env.NODE_OPTIONS} --require "${bootstrapPath}"`
: `--require "${bootstrapPath}"`

// Disable experimental warnings.
process.env.NODE_NO_WARNINGS = 1

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@github/local-action",
"description": "Local Debugging for GitHub Actions",
"version": "5.0.1",
"version": "5.1.0",
"type": "module",
"author": "Nick Alteen <[email protected]>",
"private": false,
Expand Down
61 changes: 38 additions & 23 deletions src/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,46 @@
* will parse them and register them so that modules can be resolved correctly.
*/

const { existsSync, readFileSync } = require('fs')
const { loadConfig, register } = require('tsconfig-paths')
const { parse } = require('comment-json')
import('fs').then(({ existsSync, readFileSync }) => {
import('tsconfig-paths').then(({ loadConfig, register }) => {
import('comment-json').then(({ parse }) => {
import('path').then(({ dirname }) => {
import('url').then(({ fileURLToPath }) => {
if (
process.env.TARGET_ACTION_PATH &&
process.env.TARGET_ACTION_PATH !== ''
) {
// Check if the action has a `tsconfig.json` file.
if (existsSync(`${process.env.TARGET_ACTION_PATH}/tsconfig.json`)) {
const __dirname = dirname(fileURLToPath(import.meta.url))

if (process.env.TARGET_ACTION_PATH && process.env.TARGET_ACTION_PATH !== '') {
// Check if the action has a `tsconfig.json` file.
if (existsSync(`${process.env.TARGET_ACTION_PATH}/tsconfig.json`)) {
// Load the `tsconfig.json` from the action directory.
const actionTsConfig = parse(
readFileSync(`${process.env.TARGET_ACTION_PATH}/tsconfig.json`, 'utf-8')
)
// Load the `tsconfig.json` from the action directory.
const actionTsConfig = parse(
readFileSync(
`${process.env.TARGET_ACTION_PATH}/tsconfig.json`,
'utf-8'
)
)

// Load the current `tsconfig.json` from the root of this directory.
loadConfig(__dirname)
// Load the current `tsconfig.json` from the root of this directory.
loadConfig(__dirname)

// Get the paths from the action's `tsconfig.json`, if any.
const paths = actionTsConfig.compilerOptions?.paths ?? {}
// Get the paths from the action's `tsconfig.json`, if any.
// @ts-expect-error comment-json type mismatch
const paths = actionTsConfig?.compilerOptions?.paths ?? {}

// Add any path mappings from the imported action. Replace the base URL with
// the target action path.
// @todo Should this take into account the previous `baseUrl` value?
register({
baseUrl: process.env.TARGET_ACTION_PATH,
paths,
addMatchAll: true
// Add any path mappings from the imported action. Replace the base URL with
// the target action path.
// @todo Should this take into account the previous `baseUrl` value?
register({
baseUrl: process.env.TARGET_ACTION_PATH,
paths,
addMatchAll: true
})
}
}
})
})
})
}
}
})
})
3 changes: 2 additions & 1 deletion src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ export async function action(
// @todo Load this into EnvMeta directly? What about secrets...
config({
path: path.resolve(process.cwd(), dotenvFile),
override: true
override: true,
quiet: true
})

// Load action settings
Expand Down
Loading