Skip to content

Commit 022dd05

Browse files
Initial commit
0 parents  commit 022dd05

38 files changed

+17511
-0
lines changed

.env.example

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
DEV_ORG=
2+
USER_EMAIL=

.github/templates/manifest.yaml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
version: "2"
2+
3+
name: %PRETTY_NAME%
4+
description: %PRETTY_NAME%
5+
6+
service_account:
7+
display_name: %PRETTY_NAME% Bot
8+
9+
functions:
10+
- name: extraction
11+
description: Extraction function for %PRETTY_NAME%
12+
- name: install_initial_domain_mapping
13+
description: Create blueprint and install initial domain mapping
14+
15+
keyring_types:
16+
- id: example-connection
17+
name: Example Connection
18+
description: Example Connection
19+
kind: "Secret"
20+
is_subdomain: true
21+
secret_config:
22+
secret_transform: ".token" # a JQ query
23+
fields:
24+
- id: token
25+
name: Token
26+
description: Example API token
27+
token_verification:
28+
urL: https://app.devrev.ai/favicon.ico
29+
method: GET
30+
31+
imports:
32+
- slug: %PROJECT_NAME%-extractor
33+
display_name: %PRETTY_NAME%
34+
description: %PRETTY_NAME%
35+
extractor_function: extraction
36+
allowed_connection_types:
37+
- example-connection
38+
39+
hooks:
40+
- type: activate
41+
function: install_initial_domain_mapping

.github/workflows/setup.yaml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Set up the repository
2+
on:
3+
push:
4+
branches: [main]
5+
jobs:
6+
cleanup:
7+
name: Set up the repository
8+
runs-on: ubuntu-latest
9+
if: github.event.repository.name != 'adaas-template'
10+
permissions:
11+
contents: write
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v3
15+
16+
- name: Replace templates
17+
run: |
18+
shopt -s dotglob
19+
20+
export LC_CTYPE=C
21+
export LANG=C
22+
23+
# Project name is lowercase repository name (used in configs)
24+
PROJECT_NAME="${GITHUB_REPOSITORY,,}" # Of form owner/repo
25+
PROJECT_NAME="${PROJECT_NAME##*/}" # Just the repo name
26+
27+
# Pretty name is how it's displayed in the README (spaces and starting case)
28+
# Since it can contain spaces, it has to be escaped in the sed command
29+
PRETTY_NAME="$(echo "$PROJECT_NAME" | sed 's/-/ /g; s/\b\(.\)/\u\1/g')"
30+
ESCAPED_PRETTY_NAME="$(echo "$PRETTY_NAME" | sed 's/ /\\ /g')"
31+
32+
echo "Project name: '$PROJECT_NAME'"
33+
echo "Pretty name: '$PRETTY_NAME'"
34+
35+
echo "Replacing pretty name: %PRETTY_NAME% -> '$PRETTY_NAME'"
36+
find .github/templates -type f -exec sed -i "s/%PRETTY_NAME%/$ESCAPED_PRETTY_NAME/g" {} \;
37+
38+
echo "Replacing project name: %PROJECT_NAME% -> '$PROJECT_NAME'"
39+
find .github/templates -type f -exec sed -i "s/%PROJECT_NAME%/$PROJECT_NAME/g" {} \;
40+
41+
42+
echo "Moving template files to the root of the repository"
43+
rm -rf manifest.yaml
44+
mv -f .github/templates/* .
45+
rm -rf .github
46+
47+
- name: Commit
48+
run: |
49+
git config --local user.email "[email protected]"
50+
git config --local user.name "GitHub Action"
51+
git add .
52+
git commit --amend --no-edit
53+
54+
- name: Push
55+
uses: ad-m/[email protected]
56+
with:
57+
github_token: ${{ secrets.GITHUB_TOKEN }}
58+
branch: main
59+
force: true

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# IDE-specific configs
2+
/.vscode/*
3+
.code-workspace
4+
/.idea/*
5+
6+
# Allow run configurations / launch files
7+
!/.idea/runConfigurations
8+
!/.vscode/launch.json
9+
10+
build.tar.gz
11+
nohup.out
12+
.env

Makefile

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
include .env
2+
3+
# export values in .env to be used in the shell scripts
4+
export $(shell sed 's/=.*//' .env)
5+
6+
default:
7+
$(MAKE) build
8+
9+
deps:
10+
cd code && npm ci
11+
.PHONY: deps
12+
13+
build: deps
14+
cd code && npm run build
15+
.PHONY: build
16+
17+
auth:
18+
devrev profiles authenticate --org $(DEV_ORG) --usr $(USER_EMAIL) --expiry 7 # days
19+
20+
.PHONY: auth
21+
22+
deploy: auth
23+
./code/scripts/deploy.sh
24+
.PHONY: deploy
25+
26+
# Removes the latest snap-in from the org. This is useful when you want to
27+
# re-deploy the same snap-in to the same org.
28+
uninstall:
29+
./code/scripts/cleanup.sh
30+
.PHONY: uninstall

README.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# ADaaS Template
2+
3+
This GitHub repository provides a template with example code to implement an Airdrop as a Service (ADaaS) Snap-in .
4+
5+
## Prerequisites
6+
7+
1\. Install [DevRev CLI](https://developer.devrev.ai/snapin-development/references/cli-install) by following the instructions as per the Operating System.
8+
9+
2\. Install [jq](https://jqlang.github.io/jq/download/).
10+
11+
## Build, Deploy and Run
12+
13+
1\. Clone Repository:
14+
15+
- Either clone this repository or create a new repository from it by clicking the "Use this template" button above.
16+
- Set the desired repository name for your own copy (e.g., `<organization>-<external system>-adaas`).
17+
18+
2\. Open the project in your IDE and set up project environment variables, by following these steps:
19+
20+
- Rename `.env.example` to `.env`.
21+
- In `.env` set the slug of your organization, and your email.
22+
23+
4\. Build the Snap-in using the following command:
24+
25+
```bash
26+
make build
27+
```
28+
29+
5\. Deploy the Snap-in to the organization:
30+
31+
```bash
32+
make deploy
33+
```
34+
35+
NOTE: This process may take some time. Command authenticates you to the org using the DevRev CLI, creates a Snap-in package, its Snap-in version, and finally the Snap-in draft.
36+
37+
6\. After the Snap-in draft is created, install the Snap-in in the DevRev UI (`Settings` -> `Snap-ins` -> `Install snap-in`).
38+
39+
7\. Start the import (`Imports` -> `Start import` -> `<your Snap-in>`).
40+
41+
## Common Pitfalls
42+
43+
#### Q: `Conflict` error after the `Creating snap-in package...` output during `make deploy`.
44+
45+
A: Snap-in package with the same slug already exists. Override the `SNAP_IN_SLUG` variable by explicitly updating the variable in `scripts/vars.sh`.
46+
47+
#### Q: Snap-in version `build/deployment failed` after the `Waiting for snap-in version to be ready...` message
48+
49+
A: The snap-in version could not be built. Check the logs by running the DevRev CLI command `devrev snap_in_package logs`. For prettier UI, pipe the output to `jq`
50+
51+
### Q: `Token is expired` when deploying or cleaning up.
52+
53+
A: Authentication token to the `DEV_ORG` has expired. Run `make auth` to reconnect to the organization.

code/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
.env

code/.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
save-exact=true

code/.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/**/*

code/.prettierrc

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"printWidth": 120,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": true,
7+
"trailingComma": "es5",
8+
"bracketSpacing": true,
9+
"jsxSingleQuote": false,
10+
"arrowParens": "always",
11+
"proseWrap": "never",
12+
"htmlWhitespaceSensitivity": "strict",
13+
"endOfLine": "lf",
14+
"organizeImportsSkipDestructiveCodeActions": true
15+
}

code/babel.config.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
presets: [
3+
['@babel/preset-env', { targets: { node: 'current' } }],
4+
'@babel/preset-typescript',
5+
],
6+
};

code/jest.config.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
};

code/nodemon.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"execMap": {
3+
"ts": "ts-node",
4+
"watch": ["src"]
5+
}
6+
}

0 commit comments

Comments
 (0)