Skip to content

Commit

Permalink
chore: add repo details command
Browse files Browse the repository at this point in the history
  • Loading branch information
altafDevRev committed Nov 14, 2024
1 parent 3cc46de commit 4a78a3e
Show file tree
Hide file tree
Showing 27 changed files with 19,105 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
.idea
.idea

**/node_modules
**/build.tar.gz
**/dist
72 changes: 72 additions & 0 deletions 002-pr-details/README.md
Original file line number Diff line number Diff line change
@@ -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 <devorg name> --usr <user email>
```

2. Create a snap_in_version

```
devrev snap_in_version create-one --path <template path> --create-package
```

3. Draft the snap_in

```
devrev snap_in draft
```

4. Update the snap_in

```
devrev snap_in update
```

5. Activate the snap_in

```
devrev snap_in activate
```
48 changes: 48 additions & 0 deletions 002-pr-details/code/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module.exports = {
extends: [
'airbnb-typescript/base',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended', // Makes ESLint and Prettier play nicely together
'plugin:import/recommended',
'plugin:import/typescript',
],
ignorePatterns: ['**/dist/*'],
overrides: [
{
files: ['**/*.test.ts'],
rules: {
'simple-import-sort/imports': 'off', // for test files we would want to load the mocked up modules later so on sorting the mocking mechanism will not work
},
},
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.eslint.json',
},
plugins: ['prettier', 'unused-imports', 'import', 'simple-import-sort', 'sort-keys-fix'],
root: true,
rules: {
'import/first': 'error',
// Removes unused imports automatically,
'@typescript-eslint/no-explicit-any': 'warn',

// Ensures all imports are at the top of the file
'import/newline-after-import': 'error',
// Ensures there’s a newline after the imports
'import/no-duplicates': 'error',
// Merges import statements from the same file
'import/order': 'off',
// Not compatible with simple-import-sort
'no-unused-vars': 'off',
// Handled by @typescript-eslint/no-unused-vars
'simple-import-sort/exports': 'error',
// Auto-formats exports
'simple-import-sort/imports': 'error',
// Auto-formats imports
'sort-imports': 'off',
// Not compatible with simple-import-sort
'sort-keys-fix/sort-keys-fix': ['error', 'asc', { natural: true }],
// Sorts long object key lists alphabetically
'unused-imports/no-unused-imports': 'error', // Allows any type with a warning
},
};
27 changes: 27 additions & 0 deletions 002-pr-details/code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Ignore node_modules directory
node_modules/

# Ignore logs and temporary files
*.log
*.tmp

# Ignore compiled output
dist/
build/

# Ignore environment-specific files
.env
.env.local
.env.*.local

# Ignore IDE and editor files
.vscode/
.idea/
*.sublime-project
*.sublime-workspace

# Ignore OS generated files
.DS_Store
Thumbs.db

build.tar.gz
1 change: 1 addition & 0 deletions 002-pr-details/code/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
4 changes: 4 additions & 0 deletions 002-pr-details/code/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Add files here to ignore them from prettier formatting

/dist

15 changes: 15 additions & 0 deletions 002-pr-details/code/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxSingleQuote": false,
"arrowParens": "always",
"proseWrap": "never",
"htmlWhitespaceSensitivity": "strict",
"endOfLine": "lf",
"organizeImportsSkipDestructiveCodeActions": true
}
3 changes: 3 additions & 0 deletions 002-pr-details/code/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'],
};
12 changes: 12 additions & 0 deletions 002-pr-details/code/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
collectCoverage: true,
coverageDirectory: 'coverage',
coverageReporters: ['text'],
coverageThreshold: {
'**/*': {
branches: 60,
},
},
preset: 'ts-jest',
testEnvironment: 'node',
};
5 changes: 5 additions & 0 deletions 002-pr-details/code/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"execMap": {
"ts": "ts-node"
}
}
Loading

0 comments on commit 4a78a3e

Please sign in to comment.