Skip to content
Open
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
8 changes: 8 additions & 0 deletions Github Actions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Dependencies
/node_modules
package-lock.json

# Environment files
.env
.env.*
!.env.example
143 changes: 143 additions & 0 deletions Github Actions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# DevRev Snap-in Tutorial

This tutorial guides you through installing the DevRev CLI and creating/deploying a snap-in.

## Installing DevRev CLI

### Debian/Linux
```bash
# For amd64
sudo dpkg -i devrev_0.4.0-linux_amd64.deb

# For arm64
sudo dpkg -i devrev_0.4.0-linux_arm64.deb

# Install completions
wget https://raw.githubusercontent.com/devrev/cli/main/install_completions.sh && sh install_completions.sh /usr/local/bin/devrev
```

## Prerequisites

Before starting:
- Install DevRev CLI (steps above)
- Install `jq` for JSON processing
- Create a dev organization in DevRev

## Step-by-Step Guide

### 1. Authentication
```bash
devrev profiles authenticate -o <dev-org-slug> -u <[email protected]>
```

### 2. Initialize Snap-in Template
```bash
devrev snap_in_version init
```

This creates a new directory structure:
```
devrev-snaps-typescript-template/
├── code
│ ├── babel.config.js
│ ├── jest.config.js
│ ├── nodemon.json
│ ├── package.json
│ ├── src
│ │ ├── fixtures
│ │ ├── function-factory.ts
│ │ ├── functions
│ │ ├── index.ts
│ │ ├── main.ts
│ │ └── test-runner
│ ├── tsconfig.eslint.json
│ └── tsconfig.json
├── manifest.yaml
└── README.md
```

### 3. Create Snap-in Package
```bash
# Create package with unique slug
devrev snap_in_package create-one --slug my-first-snap-in | jq .
```

Note: If the slug is already taken, you'll need to choose a different one.

### 4. Create Snap-in Version
```bash
devrev snap_in_version create-one --path ./devrev-snaps-typescript-template
```

Expected output:
```json
{
"id": "don:integration:dvrv-us-1:devo/fOFb0IdZ:snap_in_package/...",
"state": "draft"
}
```

Important: A non-published package can only have one snap-in version.

### 5. Manage Snap-in Versions

List versions:
```bash
devrev snap_in_version list
```

Delete version:
```bash
devrev snap_in_version delete-one
```

### 6. Install Snap-in
```bash
devrev snap_in draft
```

### 7. Deploy Snap-in
```bash
# Update snap-in configuration (if needed)
devrev snap_in update

# Activate the snap-in
devrev snap_in activate
```

## Common Operations

### View Snap-in Versions
```bash
devrev snap_in_version list
```

### Upgrade Snap-in Version
```bash
devrev snap_in_version upgrade --manifest <path-to-manifest> --testing-url <updated-url>
```

For non-patch compatible updates:
```bash
devrev snap_in_version upgrade --force --manifest <path-to-manifest> --testing-url <updated-url>
```

### Uninstall DevRev CLI

Debian/Linux:
```bash
sudo dpkg -r devrev
```

MacOS:
```bash
brew uninstall devrev/tools/devrev
```



## Additional Resources

- [Snap-in Manifest Documentation](https://docs.devrev.ai/snap-ins/references/manifest)
- [DevRev CLI Reference](https://docs.devrev.ai/cli)
- [Snap-in Development Guide](https://docs.devrev.ai/snap-ins)
35 changes: 35 additions & 0 deletions Github Actions/code/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module.exports = {
extends: 'airbnb-typescript/base',
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended', // Makes ESLint and Prettier play nicely together
'plugin:import/recommended',
'plugin:import/typescript',
],
ignorePatterns: ['**/dist/*'],
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', // 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', // Removes unused imports automatically,
'@typescript-eslint/no-explicit-any': 'warn', // Allows any type with a warning
},
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
}
}]
};
39 changes: 39 additions & 0 deletions Github Actions/code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp
/out-tsc

# Testing
coverage/

# dependencies
/node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# System Files
.DS_Store
Thumbs.db

deps.json
results.json
before-run-data.json

# packaged app
*.tar.gz
1 change: 1 addition & 0 deletions Github Actions/code/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
4 changes: 4 additions & 0 deletions Github Actions/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 Github Actions/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 Github Actions/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 Github Actions/code/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
collectCoverage: true,
coverageDirectory: 'coverage',
coverageThreshold: {
"**/*": {
branches: 60
}
},
coverageReporters: ['text'],
preset: 'ts-jest',
testEnvironment: 'node'
};
5 changes: 5 additions & 0 deletions Github Actions/code/nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"execMap": {
"ts": "ts-node"
}
}
61 changes: 61 additions & 0 deletions Github Actions/code/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"name": "devrev-snaps-typescript-template",
"version": "1.0.0",
"description": "",
"main": "./dist/index.js",
"scripts": {
"lint": "eslint --ignore-path .gitignore .",
"lint:fix": "eslint --fix --ignore-path .gitignore .",
"build": "rimraf ./dist && tsc",
"build:watch": "tsc --watch",
"prepackage": "npm run build",
"package": "tar -cvzf build.tar.gz dist package.json package-lock.json .npmrc",
"start": "ts-node src/main.ts",
"start:watch": "nodemon src/main.ts",
"start:production": "node dist/main.js",
"test:server": "nodemon --watch src --watch test test/main.ts",
"test": "jest",
"test:watch": "jest --watch"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.20.12",
"@babel/preset-env": "^7.20.2",
"@babel/preset-typescript": "^7.18.6",
"@types/body-parser": "1.19.5",
"@types/express": "4.17.21",
"@types/jest": "^29.4.0",
"@types/node": "^18.13.0",
"@types/yargs": "^17.0.24",
"@typescript-eslint/eslint-plugin": "^5.51.0",
"babel-jest": "^29.4.2",
"body-parser": "1.20.3",
"dotenv": "^16.0.3",
"eslint": "^8.33.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-import": "2.25.4",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-simple-import-sort": "7.0.0",
"eslint-plugin-sort-keys-fix": "1.1.2",
"eslint-plugin-unused-imports": "2.0.0",
"express": "4.21.2",
"jest": "^29.4.2",
"nodemon": "3.1.9",
"prettier": "^2.8.3",
"prettier-plugin-organize-imports": "^3.2.2",
"rimraf": "^4.1.2",
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"typescript": "^4.9.5",
"yargs": "^17.6.2"
},
"dependencies": {
"@devrev/typescript-sdk": "1.1.27",
"axios": "1.7.8",
"protobufjs": "7.3.0"
}
}
Loading