Skip to content

Commit

Permalink
Merge pull request #153 from Giveth/staging
Browse files Browse the repository at this point in the history
v1.0.0 First release of October - Getting ready for GIV launch
  • Loading branch information
mohammadranjbarz authored Oct 6, 2021
2 parents 8d8838c + c48e29a commit 0cef9f7
Show file tree
Hide file tree
Showing 45 changed files with 18,625 additions and 6,611 deletions.
1 change: 1 addition & 0 deletions .adminbro/.entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
AdminBro.UserComponents = {}
38 changes: 0 additions & 38 deletions .circleci/config.yml

This file was deleted.

67 changes: 67 additions & 0 deletions .github/workflows/CI-CD.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: CI/CD

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest

# I commented the postgres container to reduce time of CI/CD but we can undo that after adding integration tests
# services:
# postgres:
# image: postgres:12
# env:
# POSTGRES_USER: giveth_user
# POSTGRES_PASSWORD: mypass
# POSTGRES_DB: giveth
# options: >-
# --health-cmd pg_isready
# --health-interval 10s
# --health-timeout 5s
# --health-retries 5
# ports:
# - 5432:5432
steps:
- uses: actions/checkout@v1
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: install dependencies
run: npm ci
- name: run tests
run: npm run test


deploy:
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master'|| github.ref == 'refs/heads/staging'
needs: test
runs-on: ubuntu-latest
steps:
- name: develop deploy
if: github.ref == 'refs/heads/develop'
uses: garygrossgarten/[email protected]
with:
command: cd impact-graph && git checkout develop && git pull && npm ci && npm run typeorm:cli:live -- migration:run && npm run serve;
host: ${{ secrets.DEVELOP_HOST }}
username: ${{ secrets.DEVELOP_USERNAME }}
privateKey: ${{ secrets.DEVELOP_PRIVATE_KEY}}

- name: staging deploy
if: github.ref == 'refs/heads/staging'
uses: garygrossgarten/[email protected]
with:
command: cd impact-graph && git checkout staging && git pull && npm ci && npm run typeorm:cli:live -- migration:run && npm run serve;
host: ${{ secrets.STAGING_HOST }}
username: ${{ secrets.STAGING_USERNAME }}
privateKey: ${{ secrets.STAGING_PRIVATE_KEY}}

- name: production deploy
if: github.ref == 'refs/heads/master'
uses: garygrossgarten/[email protected]
with:
command: cd impact-graph && git checkout master && git pull && npm ci && npm run typeorm:cli:live -- migration:run && npm run serve;
host: ${{ secrets.PRODUCTION_HOST }}
username: ${{ secrets.PRODUCTION_USERNAME }}
privateKey: ${{ secrets.PRODUCTION_PRIVATE_KEY}}

15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,12 @@ mutation LoginWallet {
}

```
### Admin panel
We use [Admin Bro](https://github.com/SoftwareBrothers/adminjs) for Admin dashboard
You should navigate to `/admin` for browsing admin panel.
in your local database you can hash a desired password with `BCRYPT_SALT` that is in your `config/development.env` with
[bcrypt](https://github.com/kelektiv/node.bcrypt.js) then you set that value in `encryptedPassword` of your user in DB,
Now you can login in admin dashboard with your user's `email` and the `password` you already set

### Logging:

Expand All @@ -201,11 +207,20 @@ npm run typeorm:cli migration:create -- -n UpdateUserEmailUnique -d migration
Or by changing the entities and generating the migrations with:
```
npm run typeorm:cli migration:generate -- -n UpdateUserEmailUnique
```

Then you need to run the migrations like so:

```
npm run typeorm:cli -- migration:run
```

If you want to revert last migration :

```
npm run typeorm:cli -- migration:revert
```



You will need to add the above command to your build process so that all database migrations are run upon deployments.
2 changes: 1 addition & 1 deletion config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Config {
this.validateEnv(envFile)
}

//Have this - replace it!
// Have this - replace it!
validateEnv (envFile) {
envVars.forEach(envVar => {
if (envFile[envVar]) {
Expand Down
2 changes: 2 additions & 0 deletions config/example.env
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@ DEFAULT_ORGANISATION=giveth
SEED_PASSWORD=qweqweqwe
SERVER_ADMIN=[email protected]
UPLOAD_FILE_MAX_SIZE=1600000
ADMIN_BRO_COOKIE_SECRET=test_secret
BCRYPT_SALT=$2b$10$44gNUOnBXavOBMPOqzd48e
6 changes: 3 additions & 3 deletions delete-uniswap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const INFURA_ID = config.get('ETHEREUM_NODE_ID')
const ethers = require('ethers')
const network = 'mainnet'

//const provider = new ethers.providers.InfuraProvider(network, INFURA_ID)
// const provider = new ethers.providers.InfuraProvider(network, INFURA_ID)
function getProvider (network) {
if (network === 'xdaiChain') {
return new ethers.providers.JsonRpcProvider(
Expand Down Expand Up @@ -103,7 +103,7 @@ export async function getTokenPrice (
const sdk = new Sdk(chainId)

if (isETHisETH(symbol, baseSymbol)) return getETHisETHPrice()
//Should use main net now
// Should use main net now
// if (isTestPrice(symbol, baseSymbol))
// return getTestPrice(symbol, baseSymbol, chainId)

Expand Down Expand Up @@ -141,7 +141,7 @@ export async function getTokenPrice (
getProvider(getNetworkFromChainId(chainId)),
chainId
)
//console.log(`Found pair : ${JSON.stringify(pair, null, 2)}`)
// console.log(`Found pair : ${JSON.stringify(pair, null, 2)}`)

const price = sdk.getPrice(pair, token, chainId)
// console.log(`price : ${JSON.stringify(price, null, 2)}`)
Expand Down
4 changes: 2 additions & 2 deletions entities/bankAccount.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Field, Float, ID, ObjectType } from "type-graphql";
import { Field, Float, ID, ObjectType } from 'type-graphql';
import { BaseEntity, Column, Entity, OneToOne, PrimaryGeneratedColumn } from 'typeorm';

@ObjectType()
Expand Down Expand Up @@ -81,7 +81,7 @@ export class StripeTransaction extends BaseEntity {
@Field()
createdAt: Date

@Column({ type: "float", nullable: true })
@Column({ type: 'float', nullable: true })
@Field(type => Float, { nullable: true })
amount: number

Expand Down
39 changes: 22 additions & 17 deletions entities/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class Project extends BaseEntity {
@Column({ nullable: true })
slug?: string

@Index()
@Field(type => [String] ,{ nullable: true })
@Column( 'text',{ array:true, nullable: true })
slugHistory?: string[]

@Field({ nullable: true })
@Column({ nullable: true })
admin?: string
Expand Down Expand Up @@ -124,11 +129,6 @@ class Project extends BaseEntity {
)
reactions?: Reaction[]

@Field(type => Float, { nullable: true })
reactionsCount () {
return this.reactions ? this.reactions.length : 0
}

@Index()
@Field(type => ProjectStatus)
@ManyToOne(type => ProjectStatus, { eager: true })
Expand All @@ -137,6 +137,23 @@ class Project extends BaseEntity {
@RelationId((project: Project) => project.status)
statusId: number

@Field(type => Float, { nullable: true })
@Column({ type: 'real', nullable: true })
totalDonations: number = 0

@Field(type => Float, { nullable: true })
@Column({ type: 'real', nullable: true })
totalHearts: number = 0

@Field(type => Boolean)
@Column({ default: true, nullable: false })
listed: boolean = true

@Field(type => Float, { nullable: true })
reactionsCount () {
return this.reactions ? this.reactions.length : 0
}

mayUpdateStatus (user: User) {
if (this.users.filter(o => o.id === user.id).length > 0) {
return true
Expand All @@ -157,21 +174,9 @@ class Project extends BaseEntity {
}
}

@Field(type => Float, { nullable: true })
@Column({ type: 'real', nullable: true })
totalDonations: number = 0

@Field(type => Float, { nullable: true })
@Column({ type: 'real', nullable: true })
totalHearts: number = 0

owner () {
return this.users[0]
}

@Field(type => Boolean)
@Column({ default: true, nullable: false })
listed: boolean = true
}

@Entity()
Expand Down
27 changes: 22 additions & 5 deletions entities/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,26 @@ import { Organisation } from './organisation'
import { Project } from './project'
import { AccountVerification } from './accountVerification'

export enum UserRole {
ADMIN = "admin",
RESTRICTED = "restricted"
}

@ObjectType()
@Entity()
export class User extends BaseEntity {
@Field(type => ID)
@PrimaryGeneratedColumn()
readonly id: number

@Field({ nullable: true })
@Column({
type: "enum",
enum: UserRole,
default: UserRole.RESTRICTED
})
role: UserRole;

@Field({ nullable: true })
@Column({ nullable: true })
email?: string
Expand All @@ -41,9 +54,13 @@ export class User extends BaseEntity {
walletAddress?: string

@Field({ nullable: true })
@Column({ nullable: true, select: false })
@Column({ nullable: true })
password?: string

@Field({ nullable: true })
@Column({ nullable: true })
encryptedPassword?: string

@Field({ nullable: true })
@Column({ nullable: true })
avatar?: string
Expand Down Expand Up @@ -90,14 +107,14 @@ export class User extends BaseEntity {
@Column('bool', { default: false })
segmentIdentified: boolean

segmentUserId () {
return `givethId-${this.id}`
}

@Field(type => [AccountVerification], { nullable: true })
@OneToMany(
type => AccountVerification,
accountVerification => accountVerification.user
)
accountVerifications?: AccountVerification[]

segmentUserId () {
return `givethId-${this.id}`
}
}
Loading

0 comments on commit 0cef9f7

Please sign in to comment.