From 4a78a3e2d5c1c76b6dd967bcd2136f8e14b22aa3 Mon Sep 17 00:00:00 2001 From: altafDevRev Date: Thu, 14 Nov 2024 15:04:17 +0530 Subject: [PATCH 1/9] chore: add repo details command --- .gitignore | 6 +- 002-pr-details/README.md | 72 + 002-pr-details/code/.eslintrc.js | 48 + 002-pr-details/code/.gitignore | 27 + 002-pr-details/code/.npmrc | 1 + 002-pr-details/code/.prettierignore | 4 + 002-pr-details/code/.prettierrc | 15 + 002-pr-details/code/babel.config.js | 3 + 002-pr-details/code/jest.config.js | 12 + 002-pr-details/code/nodemon.json | 5 + 002-pr-details/code/package-lock.json | 18087 ++++++++++++++++ 002-pr-details/code/package.json | 62 + .../code/src/fixtures/on_command.json | 46 + 002-pr-details/code/src/function-factory.ts | 8 + .../functions/command_handler/index.test.ts | 10 + .../src/functions/command_handler/index.ts | 146 + 002-pr-details/code/src/index.ts | 1 + 002-pr-details/code/src/main.ts | 27 + .../code/src/test-runner/example.test.ts | 7 + .../code/src/test-runner/test-runner.ts | 27 + 002-pr-details/code/test/http_client.ts | 52 + 002-pr-details/code/test/main.ts | 29 + 002-pr-details/code/test/runner.ts | 264 + 002-pr-details/code/test/types.ts | 87 + 002-pr-details/code/tsconfig.eslint.json | 4 + 002-pr-details/code/tsconfig.json | 26 + 002-pr-details/manifest.yaml | 30 + 27 files changed, 19105 insertions(+), 1 deletion(-) create mode 100644 002-pr-details/README.md create mode 100644 002-pr-details/code/.eslintrc.js create mode 100644 002-pr-details/code/.gitignore create mode 100644 002-pr-details/code/.npmrc create mode 100644 002-pr-details/code/.prettierignore create mode 100644 002-pr-details/code/.prettierrc create mode 100644 002-pr-details/code/babel.config.js create mode 100644 002-pr-details/code/jest.config.js create mode 100644 002-pr-details/code/nodemon.json create mode 100644 002-pr-details/code/package-lock.json create mode 100644 002-pr-details/code/package.json create mode 100644 002-pr-details/code/src/fixtures/on_command.json create mode 100644 002-pr-details/code/src/function-factory.ts create mode 100644 002-pr-details/code/src/functions/command_handler/index.test.ts create mode 100644 002-pr-details/code/src/functions/command_handler/index.ts create mode 100644 002-pr-details/code/src/index.ts create mode 100644 002-pr-details/code/src/main.ts create mode 100644 002-pr-details/code/src/test-runner/example.test.ts create mode 100644 002-pr-details/code/src/test-runner/test-runner.ts create mode 100644 002-pr-details/code/test/http_client.ts create mode 100644 002-pr-details/code/test/main.ts create mode 100644 002-pr-details/code/test/runner.ts create mode 100644 002-pr-details/code/test/types.ts create mode 100644 002-pr-details/code/tsconfig.eslint.json create mode 100644 002-pr-details/code/tsconfig.json create mode 100644 002-pr-details/manifest.yaml diff --git a/.gitignore b/.gitignore index 723ef36..ac4a1f7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ -.idea \ No newline at end of file +.idea + +**/node_modules +**/build.tar.gz +**/dist diff --git a/002-pr-details/README.md b/002-pr-details/README.md new file mode 100644 index 0000000..0c9435b --- /dev/null +++ b/002-pr-details/README.md @@ -0,0 +1,72 @@ +## Snap-in to perform an external action + +Snap-in that mirrors an issue from +DevRev to GitHub. This introduces a command which can be used to replicate the issue in the specific repository. + +To run the command : +``` +/gh_issue OrgName RepoName +``` + +### Testing locally + +You can test your code by adding test events under `src/fixtures` similar to the example event provided. You can add [keyring](https://docs.devrev.ai/snap-ins/references/keyrings) values to the event payload to test API calls as well. + +Once you have added the event, you can test your code by running: + +``` +npm install +npm run start -- --functionName=command_handler --fixturePath=on_command.json +``` + +### Adding external dependencies + +You can also add dependencies on external packages in `package.json` under the “dependencies” key. These dependencies will be made available to your function at runtime and testing. + +### Linting + +To check for lint errors, run the following command: + +```bash +npm run lint +``` + +To automatically fix lint errors, run: + +```bash +npm run lint:fix +``` + +### Activating Snap-Ins + +Once you are done with the testing, run the following commands to activate your snap_in: + +1. Authenticate to devrev CLI + +``` +devrev profiles authenticate --org --usr +``` + +2. Create a snap_in_version + +``` +devrev snap_in_version create-one --path