-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a78a3e
commit 8db9359
Showing
26 changed files
with
19,097 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,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 | ||
``` |
This file contains 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,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 | ||
}, | ||
}; |
This file contains 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,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 |
This file contains 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 @@ | ||
save-exact=true |
This file contains 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,4 @@ | ||
# Add files here to ignore them from prettier formatting | ||
|
||
/dist | ||
|
This file contains 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,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 | ||
} |
This file contains 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,3 @@ | ||
module.exports = { | ||
presets: [['@babel/preset-env', { targets: { node: 'current' } }], '@babel/preset-typescript'], | ||
}; |
This file contains 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 @@ | ||
module.exports = { | ||
collectCoverage: true, | ||
coverageDirectory: 'coverage', | ||
coverageReporters: ['text'], | ||
coverageThreshold: { | ||
'**/*': { | ||
branches: 60, | ||
}, | ||
}, | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
}; |
This file contains 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,5 @@ | ||
{ | ||
"execMap": { | ||
"ts": "ts-node" | ||
} | ||
} |
Oops, something went wrong.