Skip to content
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

test: testando action #1

Merged
merged 5 commits into from
Nov 14, 2024
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
10 changes: 8 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29923,10 +29923,14 @@ function wrappy (fn, cb) {

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.wait = void 0;
exports.stringify = stringify;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A função 'stringify' está sendo exportada duas vezes.
A linha 29926 exporta 'stringify' duas vezes, o que é redundante. A exportação deve ser feita apenas uma vez.

const wait = (timeout) => {
return new Promise(resolve => setTimeout(resolve, timeout));
};
exports.wait = wait;
function stringify(obj) {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Função 'stringify' adicionada sem verificação de tipo
Para garantir a segurança e evitar erros de execução, é importante definir tipos para os parâmetros de funções, especialmente em TypeScript.

return JSON.stringify(obj, undefined, 2);
}


/***/ }),
Expand Down Expand Up @@ -29999,6 +30003,7 @@ exports.compareCommits = compareCommits;
const fs_1 = __nccwpck_require__(9896);
const github = __importStar(__nccwpck_require__(3228));
const core = __importStar(__nccwpck_require__(7484));
const helpers_1 = __nccwpck_require__(253);
function getGithubToken() {
return core.getInput('GITHUB_TOKEN') || process.env.GITHUB_TOKEN || '';
}
Expand All @@ -30012,13 +30017,14 @@ async function getPRDetails() {
if (!token)
throw new Error('GITHUB_TOKEN is not set');
const event = getEventData();
console.log('EVENT:', event);
console.log('EVENT: \n', (0, helpers_1.stringify)(event));
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uso de console.log para debug
O uso de 'console.log' para depuração pode não ser ideal em um ambiente de produção. Considere usar um mecanismo de logging mais robusto que permita diferentes níveis de log e melhor gerenciamento de saída.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uso de 'console.log' para depuração
O uso de 'console.log' para depuração em código de produção não é recomendado. Considere usar uma biblioteca de logging apropriada que permita diferentes níveis de log e melhor controle sobre a saída.

const params = {
owner: event.repository.owner.login,
repo: event.repository.name,
pull_number: 10
pull_number: event.number
};
const octokit = github.getOctokit(token);
console.log('PARAMS: \n', (0, helpers_1.stringify)(params));
const response = await octokit.rest.pulls.get(params);
const result = {
action: event.action,
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export const wait = (timeout: number): Promise<any> => {
return new Promise(resolve => setTimeout(resolve, timeout));
};

export function stringify(obj: any): string {
return JSON.stringify(obj, undefined, 2);
}
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
* The entrypoint for the action.
*/
import { run } from './main';

// eslint-disable-next-line @typescript-eslint/no-floating-promises
run();
6 changes: 4 additions & 2 deletions src/lib/github.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { readFileSync } from 'fs';
import * as github from '@actions/github';
import * as core from '@actions/core';
import { stringify } from 'src/helpers';

export function getGithubToken(): string {
return core.getInput('GITHUB_TOKEN') || process.env.GITHUB_TOKEN || '';
Expand Down Expand Up @@ -49,16 +50,17 @@ export async function getPRDetails(): Promise<PRDetails | null> {

const event = getEventData();

console.log('EVENT:', event);
console.log('EVENT: \n', stringify(event));

const params = {
owner: event.repository.owner.login,
repo: event.repository.name,
pull_number: 10
pull_number: event.number
};

const octokit = github.getOctokit(token);

console.log('PARAMS: \n', stringify(params));
const response = await octokit.rest.pulls.get(params);

const result: PRDetails = {
Expand Down