Added project pages and cards, most of the screens in chris samuels figma design document. Still need to implement project initialization modal and walkthrough, connect to backend and connect to wallet (maybe be beyond scope of this project)
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import * as fs from 'node:fs/promises'
|
||||
import debug from 'debug'
|
||||
|
||||
import { getConfig } from '../src/utils'
|
||||
|
||||
const log = debug('snowball:delete-database')
|
||||
|
||||
const deleteFile = async (filePath: string) => {
|
||||
await fs.unlink(filePath)
|
||||
log(`File ${filePath} has been deleted.`)
|
||||
}
|
||||
|
||||
const main = async () => {
|
||||
const config = await getConfig()
|
||||
|
||||
deleteFile(config.database.dbPath)
|
||||
}
|
||||
|
||||
main().catch((err) => log(err))
|
||||
+189
@@ -0,0 +1,189 @@
|
||||
[
|
||||
{
|
||||
"projectIndex": 0,
|
||||
"domainIndex": 0,
|
||||
"createdByIndex": 0,
|
||||
"id": "ffhae3zq",
|
||||
"status": "Ready",
|
||||
"environment": "Production",
|
||||
"isCurrent": true,
|
||||
"applicationRecordId": "qbafyrehvzya6ovp4yfpkqnddkui2iw7t6hbhwq74lbqs7bhobvmfhrowoi",
|
||||
"applicationRecordData": {},
|
||||
"applicationDeploymentRequestId": "xqbafyrehvzya6ovp4yfpkqnddkui2iw7t6hbhwq74lbqs7bhobvmfhrowoi",
|
||||
"applicationDeploymentRequestData": {},
|
||||
"branch": "main",
|
||||
"commitHash": "d5dfd7b827226b0d09d897346d291c256e113e00",
|
||||
"commitMessage": "subscription added",
|
||||
"url": "testProject-ffhae3zq.snowball.xyz"
|
||||
},
|
||||
{
|
||||
"projectIndex": 0,
|
||||
"domainIndex": 1,
|
||||
"createdByIndex": 0,
|
||||
"id": "vehagei8",
|
||||
"status": "Ready",
|
||||
"environment": "Preview",
|
||||
"isCurrent": false,
|
||||
"applicationRecordId": "wbafyreihvzya6ovp4yfpkqnddkui2iw7thbhwq74lbqs7bhobvmfhrowoi",
|
||||
"applicationRecordData": {},
|
||||
"applicationDeploymentRequestId": "wqbafyrehvzya6ovp4yfpkqnddkui2iw7t6hbhwq74lbqs7bhobvmfhrowoi",
|
||||
"applicationDeploymentRequestData": {},
|
||||
"branch": "test",
|
||||
"commitHash": "d5dfd7b827226b0d09d897346d291c256e113e00",
|
||||
"commitMessage": "subscription added",
|
||||
"url": "testProject-vehagei8.snowball.xyz"
|
||||
},
|
||||
{
|
||||
"projectIndex": 0,
|
||||
"domainIndex": 2,
|
||||
"createdByIndex": 0,
|
||||
"id": "qmgekyte",
|
||||
"status": "Ready",
|
||||
"environment": "Development",
|
||||
"isCurrent": false,
|
||||
"applicationRecordId": "ebafyreihvzya6ovp4yfpkqnddkui2iw7t6bhwq74lbqs7bhobvmfhrowoi",
|
||||
"applicationRecordData": {},
|
||||
"applicationDeploymentRequestId": "kqbafyrehvzya6ovp4yfpkqnddkui2iw7t6hbhwq74lbqs7bhobvmfhrowoi",
|
||||
"applicationDeploymentRequestData": {},
|
||||
"branch": "test",
|
||||
"commitHash": "d5dfd7b827226b0d09d897346d291c256e113e00",
|
||||
"commitMessage": "subscription added",
|
||||
"url": "testProject-qmgekyte.snowball.xyz"
|
||||
},
|
||||
{
|
||||
"projectIndex": 0,
|
||||
"domainIndex": null,
|
||||
"createdByIndex": 0,
|
||||
"id": "f8wsyim6",
|
||||
"status": "Ready",
|
||||
"environment": "Production",
|
||||
"isCurrent": false,
|
||||
"applicationRecordId": "rbafyreihvzya6ovp4yfpkqnddkui2iw7t6hbhw74lbqs7bhobvmfhrowoi",
|
||||
"applicationRecordData": {},
|
||||
"applicationDeploymentRequestId": "yqbafyrehvzya6ovp4yfpkqnddkui2iw7t6hbhwq74lbqs7bhobvmfhrowoi",
|
||||
"applicationDeploymentRequestData": {},
|
||||
"branch": "prod",
|
||||
"commitHash": "d5dfd7b827226b0d09d897346d291c256e113e00",
|
||||
"commitMessage": "subscription added",
|
||||
"url": "testProject-f8wsyim6.snowball.xyz"
|
||||
},
|
||||
{
|
||||
"projectIndex": 1,
|
||||
"domainIndex": 3,
|
||||
"createdByIndex": 1,
|
||||
"id": "eO8cckxk",
|
||||
"status": "Ready",
|
||||
"environment": "Production",
|
||||
"isCurrent": true,
|
||||
"applicationRecordId": "tbafyreihvzya6ovp4yfpqnddkui2iw7t6hbhwq74lbqs7bhobvmfhrowoi",
|
||||
"applicationRecordData": {},
|
||||
"applicationDeploymentRequestId": "pqbafyrehvzya6ovp4yfpkqnddkui2iw7t6hbhwq74lbqs7bhobvmfhrowoi",
|
||||
"applicationDeploymentRequestData": {},
|
||||
"branch": "main",
|
||||
"commitHash": "d5dfd7b827226b0d09d897346d291c256e113e00",
|
||||
"commitMessage": "subscription added",
|
||||
"url": "testProject-2-eO8cckxk.snowball.xyz"
|
||||
},
|
||||
{
|
||||
"projectIndex": 1,
|
||||
"domainIndex": 4,
|
||||
"createdByIndex": 1,
|
||||
"id": "yaq0t5yw",
|
||||
"status": "Ready",
|
||||
"environment": "Preview",
|
||||
"isCurrent": false,
|
||||
"applicationRecordId": "ybafyreihvzya6ovp4yfpkqnddkui2iw7t6bhwq74lbqs7bhobvmfhrowoi",
|
||||
"applicationRecordData": {},
|
||||
"applicationDeploymentRequestId": "tqbafyrehvzya6ovp4yfpkqnddkui2iw7t6hbhwq74lbqs7bhobvmfhrowoi",
|
||||
"applicationDeploymentRequestData": {},
|
||||
"branch": "test",
|
||||
"commitHash": "d5dfd7b827226b0d09d897346d291c256e113e00",
|
||||
"commitMessage": "subscription added",
|
||||
"url": "testProject-2-yaq0t5yw.snowball.xyz"
|
||||
},
|
||||
{
|
||||
"projectIndex": 1,
|
||||
"domainIndex": 5,
|
||||
"createdByIndex": 1,
|
||||
"id": "hwwr6sbx",
|
||||
"status": "Ready",
|
||||
"environment": "Development",
|
||||
"isCurrent": false,
|
||||
"applicationRecordId": "ubafyreihvzya6ovp4yfpkqnddkui2iw7t6hbhwq74lbqs7bhobvfhrowoi",
|
||||
"applicationRecordData": {},
|
||||
"applicationDeploymentRequestId": "eqbafyrehvzya6ovp4yfpkqnddkui2iw7t6hbhwq74lbqs7bhobvmfhrowoi",
|
||||
"applicationDeploymentRequestData": {},
|
||||
"branch": "test",
|
||||
"commitHash": "d5dfd7b827226b0d09d897346d291c256e113e00",
|
||||
"commitMessage": "subscription added",
|
||||
"url": "testProject-2-hwwr6sbx.snowball.xyz"
|
||||
},
|
||||
{
|
||||
"projectIndex": 2,
|
||||
"domainIndex": 9,
|
||||
"createdByIndex": 2,
|
||||
"id": "ndxje48a",
|
||||
"status": "Ready",
|
||||
"environment": "Production",
|
||||
"isCurrent": true,
|
||||
"applicationRecordId": "ibayreihvzya6ovp4yfpkqnddkui2iw7t6hbhwq74lbqs7bhobvmfhrowoi",
|
||||
"applicationRecordData": {},
|
||||
"applicationDeploymentRequestId": "dqbafyrehvzya6ovp4yfpkqnddkui2iw7t6hbhwq74lbqs7bhobvmfhrowoi",
|
||||
"applicationDeploymentRequestData": {},
|
||||
"branch": "main",
|
||||
"commitHash": "d5dfd7b827226b0d09d897346d291c256e113e00",
|
||||
"commitMessage": "subscription added",
|
||||
"url": "iglootools-ndxje48a.snowball.xyz"
|
||||
},
|
||||
{
|
||||
"projectIndex": 2,
|
||||
"domainIndex": 7,
|
||||
"createdByIndex": 2,
|
||||
"id": "gtgpgvei",
|
||||
"status": "Ready",
|
||||
"environment": "Preview",
|
||||
"isCurrent": false,
|
||||
"applicationRecordId": "obafyreihvzya6ovp4yfpkqnddkui2iw7t6hbhwq74lbqs7bhobvmfhrowoi",
|
||||
"applicationRecordData": {},
|
||||
"applicationDeploymentRequestId": "aqbafyrehvzya6ovp4yfpkqnddkui2iw7t6hbhwq74lbqs7bhobvmfhrowoi",
|
||||
"applicationDeploymentRequestData": {},
|
||||
"branch": "test",
|
||||
"commitHash": "d5dfd7b827226b0d09d897346d291c256e113e00",
|
||||
"commitMessage": "subscription added",
|
||||
"url": "iglootools-gtgpgvei.snowball.xyz"
|
||||
},
|
||||
{
|
||||
"projectIndex": 2,
|
||||
"domainIndex": 8,
|
||||
"createdByIndex": 2,
|
||||
"id": "b4bpthjr",
|
||||
"status": "Ready",
|
||||
"environment": "Development",
|
||||
"isCurrent": false,
|
||||
"applicationRecordId": "pbafyreihvzya6ovp4yfpkqnddkui2iw7t6hbhwq74lbqs7bhobvmfhrowo",
|
||||
"applicationRecordData": {},
|
||||
"applicationDeploymentRequestId": "uqbafyrehvzya6ovp4yfpkqnddkui2iw7t6hbhwq74lbqs7bhobvmfhrowoi",
|
||||
"applicationDeploymentRequestData": {},
|
||||
"branch": "test",
|
||||
"commitHash": "d5dfd7b827226b0d09d897346d291c256e113e00",
|
||||
"commitMessage": "subscription added",
|
||||
"url": "iglootools-b4bpthjr.snowball.xyz"
|
||||
},
|
||||
{
|
||||
"projectIndex": 3,
|
||||
"domainIndex": 6,
|
||||
"createdByIndex": 2,
|
||||
"id": "b4bpthjr",
|
||||
"status": "Ready",
|
||||
"environment": "Production",
|
||||
"isCurrent": true,
|
||||
"applicationRecordId": "pbafyreihvzya6ovp4yfpkqnddkui2iw7t6hbhwq74lbqs7bhobvmfhrowo",
|
||||
"applicationRecordData": {},
|
||||
"applicationDeploymentRequestId": "pqbafyrehvzya6ovp4yfpkqnddkui2iw7t6hbhwq74lbqs7bhobvmfhrowoi",
|
||||
"applicationDeploymentRequestData": {},
|
||||
"branch": "test",
|
||||
"commitHash": "d5dfd7b827226b0d09d897346d291c256e113e00",
|
||||
"commitMessage": "subscription added",
|
||||
"url": "iglootools-b4bpthjr.snowball.xyz"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,92 @@
|
||||
[
|
||||
{
|
||||
"projectIndex": 0,
|
||||
"key": "ABC",
|
||||
"value": "ABC",
|
||||
"environment": "Production"
|
||||
},
|
||||
{
|
||||
"projectIndex": 0,
|
||||
"key": "ABC",
|
||||
"value": "ABC",
|
||||
"environment": "Preview"
|
||||
},
|
||||
{
|
||||
"projectIndex": 0,
|
||||
"key": "XYZ",
|
||||
"value": "abc3",
|
||||
"environment": "Preview"
|
||||
},
|
||||
{
|
||||
"projectIndex": 1,
|
||||
"key": "ABC",
|
||||
"value": "ABC",
|
||||
"environment": "Production"
|
||||
},
|
||||
{
|
||||
"projectIndex": 1,
|
||||
"key": "ABC",
|
||||
"value": "ABC",
|
||||
"environment": "Preview"
|
||||
},
|
||||
{
|
||||
"projectIndex": 1,
|
||||
"key": "XYZ",
|
||||
"value": "abc3",
|
||||
"environment": "Preview"
|
||||
},
|
||||
{
|
||||
"projectIndex": 2,
|
||||
"key": "ABC",
|
||||
"value": "ABC",
|
||||
"environment": "Production"
|
||||
},
|
||||
{
|
||||
"projectIndex": 2,
|
||||
"key": "ABC",
|
||||
"value": "ABC",
|
||||
"environment": "Preview"
|
||||
},
|
||||
{
|
||||
"projectIndex": 2,
|
||||
"key": "XYZ",
|
||||
"value": "abc3",
|
||||
"environment": "Preview"
|
||||
},
|
||||
{
|
||||
"projectIndex": 3,
|
||||
"key": "ABC",
|
||||
"value": "ABC",
|
||||
"environment": "Production"
|
||||
},
|
||||
{
|
||||
"projectIndex": 3,
|
||||
"key": "ABC",
|
||||
"value": "ABC",
|
||||
"environment": "Preview"
|
||||
},
|
||||
{
|
||||
"projectIndex": 3,
|
||||
"key": "XYZ",
|
||||
"value": "abc3",
|
||||
"environment": "Preview"
|
||||
},
|
||||
{
|
||||
"projectIndex": 4,
|
||||
"key": "ABC",
|
||||
"value": "ABC",
|
||||
"environment": "Production"
|
||||
},
|
||||
{
|
||||
"projectIndex": 4,
|
||||
"key": "ABC",
|
||||
"value": "ABC",
|
||||
"environment": "Preview"
|
||||
},
|
||||
{
|
||||
"projectIndex": 4,
|
||||
"key": "XYZ",
|
||||
"value": "abc3",
|
||||
"environment": "Preview"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,7 @@
|
||||
[
|
||||
{
|
||||
"id": "2379cf1f-a232-4ad2-ae14-4d881131cc26",
|
||||
"name": "Deploy Tools",
|
||||
"slug": "deploy-tools"
|
||||
}
|
||||
]
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
[
|
||||
{
|
||||
"projectIndex": 0,
|
||||
"name": "example.snowballtools.xyz",
|
||||
"status": "Live",
|
||||
"branch": "main"
|
||||
},
|
||||
{
|
||||
"projectIndex": 0,
|
||||
"name": "example.org",
|
||||
"status": "Pending",
|
||||
"branch": "test"
|
||||
},
|
||||
{
|
||||
"projectIndex": 1,
|
||||
"name": "example.snowballtools.xyz",
|
||||
"status": "Live",
|
||||
"branch": "main"
|
||||
},
|
||||
{
|
||||
"projectIndex": 1,
|
||||
"name": "example.org",
|
||||
"status": "Pending",
|
||||
"branch": "test"
|
||||
},
|
||||
{
|
||||
"projectIndex": 2,
|
||||
"name": "example.snowballtools.xyz",
|
||||
"status": "Live",
|
||||
"branch": "main"
|
||||
},
|
||||
{
|
||||
"projectIndex": 2,
|
||||
"name": "example.org",
|
||||
"status": "Pending",
|
||||
"branch": "test"
|
||||
},
|
||||
{
|
||||
"projectIndex": 3,
|
||||
"name": "iglootools-2.com",
|
||||
"status": "Pending",
|
||||
"branch": "test"
|
||||
}
|
||||
]
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
[
|
||||
{
|
||||
"memberIndex": 1,
|
||||
"projectIndex": 0,
|
||||
"permissions": ["View"],
|
||||
"isPending": false
|
||||
},
|
||||
{
|
||||
"memberIndex": 2,
|
||||
"projectIndex": 0,
|
||||
"permissions": ["View", "Edit"],
|
||||
"isPending": false
|
||||
},
|
||||
{
|
||||
"memberIndex": 2,
|
||||
"projectIndex": 1,
|
||||
"permissions": ["View"],
|
||||
"isPending": false
|
||||
},
|
||||
{
|
||||
"memberIndex": 0,
|
||||
"projectIndex": 2,
|
||||
"permissions": ["View"],
|
||||
"isPending": false
|
||||
},
|
||||
{
|
||||
"memberIndex": 1,
|
||||
"projectIndex": 2,
|
||||
"permissions": ["View", "Edit"],
|
||||
"isPending": false
|
||||
},
|
||||
{
|
||||
"memberIndex": 0,
|
||||
"projectIndex": 3,
|
||||
"permissions": ["View"],
|
||||
"isPending": false
|
||||
},
|
||||
{
|
||||
"memberIndex": 2,
|
||||
"projectIndex": 3,
|
||||
"permissions": ["View", "Edit"],
|
||||
"isPending": false
|
||||
},
|
||||
{
|
||||
"memberIndex": 1,
|
||||
"projectIndex": 4,
|
||||
"permissions": ["View"],
|
||||
"isPending": false
|
||||
},
|
||||
{
|
||||
"memberIndex": 2,
|
||||
"projectIndex": 4,
|
||||
"permissions": ["View", "Edit"],
|
||||
"isPending": false
|
||||
}
|
||||
]
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
[
|
||||
{
|
||||
"ownerIndex": 0,
|
||||
"organizationIndex": 0,
|
||||
"name": "testProject",
|
||||
"repository": "snowball-tools/snowball-ts-framework-template",
|
||||
"prodBranch": "main",
|
||||
"description": "test",
|
||||
"template": "webapp",
|
||||
"framework": "test",
|
||||
"webhooks": [],
|
||||
"icon": "",
|
||||
"subDomain": "testProject.snowball.xyz"
|
||||
},
|
||||
{
|
||||
"ownerIndex": 1,
|
||||
"organizationIndex": 0,
|
||||
"name": "testProject-2",
|
||||
"repository": "snowball-tools/snowball-ts-framework-template",
|
||||
"prodBranch": "main",
|
||||
"description": "test-2",
|
||||
"template": "webapp",
|
||||
"framework": "test-2",
|
||||
"webhooks": [],
|
||||
"icon": "",
|
||||
"subDomain": "testProject-2.snowball.xyz"
|
||||
},
|
||||
{
|
||||
"ownerIndex": 2,
|
||||
"organizationIndex": 0,
|
||||
"name": "iglootools",
|
||||
"repository": "snowball-tools/snowball-ts-framework-template",
|
||||
"prodBranch": "main",
|
||||
"description": "test-3",
|
||||
"template": "webapp",
|
||||
"framework": "test-3",
|
||||
"webhooks": [],
|
||||
"icon": "",
|
||||
"subDomain": "iglootools.snowball.xyz"
|
||||
},
|
||||
{
|
||||
"ownerIndex": 1,
|
||||
"organizationIndex": 0,
|
||||
"name": "iglootools-2",
|
||||
"repository": "snowball-tools/snowball-ts-framework-template",
|
||||
"prodBranch": "main",
|
||||
"description": "test-4",
|
||||
"template": "webapp",
|
||||
"framework": "test-4",
|
||||
"webhooks": [],
|
||||
"icon": "",
|
||||
"subDomain": "iglootools-2.snowball.xyz"
|
||||
},
|
||||
{
|
||||
"ownerIndex": 0,
|
||||
"organizationIndex": 1,
|
||||
"name": "snowball-2",
|
||||
"repository": "snowball-tools/snowball-ts-framework-template",
|
||||
"prodBranch": "main",
|
||||
"description": "test-5",
|
||||
"template": "webapp",
|
||||
"framework": "test-5",
|
||||
"webhooks": [],
|
||||
"icon": "",
|
||||
"subDomain": "snowball-2.snowball.xyz"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,23 @@
|
||||
[
|
||||
{
|
||||
"projectIndex": 0,
|
||||
"name": "www.example.org",
|
||||
"status": "Pending",
|
||||
"redirectToIndex": 1,
|
||||
"branch": "test"
|
||||
},
|
||||
{
|
||||
"projectIndex": 1,
|
||||
"name": "www.example.org",
|
||||
"status": "Pending",
|
||||
"redirectToIndex": 3,
|
||||
"branch": "test"
|
||||
},
|
||||
{
|
||||
"projectIndex": 2,
|
||||
"name": "www.example.org",
|
||||
"status": "Pending",
|
||||
"redirectToIndex": 5,
|
||||
"branch": "test"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,22 @@
|
||||
[
|
||||
{
|
||||
"role": "Owner",
|
||||
"memberIndex": 0,
|
||||
"organizationIndex": 0
|
||||
},
|
||||
{
|
||||
"role": "Maintainer",
|
||||
"memberIndex": 1,
|
||||
"organizationIndex": 0
|
||||
},
|
||||
{
|
||||
"role": "Owner",
|
||||
"memberIndex": 2,
|
||||
"organizationIndex": 0
|
||||
},
|
||||
{
|
||||
"role": "Owner",
|
||||
"memberIndex": 0,
|
||||
"organizationIndex": 1
|
||||
}
|
||||
]
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
[
|
||||
{
|
||||
"id": "59f4355d-9549-4aac-9b54-eeefceeabef0",
|
||||
"name": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
|
||||
"email": "snowball@snowballtools.xyz",
|
||||
"isVerified": true,
|
||||
"ethAddress": "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
|
||||
},
|
||||
{
|
||||
"id": "e505b212-8da6-48b2-9614-098225dab34b",
|
||||
"name": "0xbe0eb53f46cd790cd13851d5eff43d12404d33e8",
|
||||
"email": "alice@snowballtools.xyz",
|
||||
"isVerified": true,
|
||||
"ethAddress": "0xbe0eb53f46cd790cd13851d5eff43d12404d33e8"
|
||||
},
|
||||
{
|
||||
"id": "cd892fad-9138-4aa2-a62c-414a32776ea7",
|
||||
"name": "0x8315177ab297ba92a06054ce80a67ed4dbd7ed3a",
|
||||
"email": "bob@snowballtools.xyz",
|
||||
"isVerified": true,
|
||||
"ethAddress": "0x8315177ab297ba92a06054ce80a67ed4dbd7ed3a"
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,176 @@
|
||||
import path from 'node:path'
|
||||
import debug from 'debug'
|
||||
import { DataSource } from 'typeorm'
|
||||
|
||||
import { Deployment } from '../src/entity/Deployment'
|
||||
import { Domain } from '../src/entity/Domain'
|
||||
import { EnvironmentVariable } from '../src/entity/EnvironmentVariable'
|
||||
import { Organization } from '../src/entity/Organization'
|
||||
import { Project } from '../src/entity/Project'
|
||||
import { ProjectMember } from '../src/entity/ProjectMember'
|
||||
import { User } from '../src/entity/User'
|
||||
import { UserOrganization } from '../src/entity/UserOrganization'
|
||||
import {
|
||||
checkFileExists,
|
||||
getConfig,
|
||||
getEntities,
|
||||
loadAndSaveData
|
||||
} from '../src/utils'
|
||||
|
||||
const log = debug('snowball:initialize-database')
|
||||
|
||||
const USER_DATA_PATH = './fixtures/users.json'
|
||||
const PROJECT_DATA_PATH = './fixtures/projects.json'
|
||||
const ORGANIZATION_DATA_PATH = './fixtures/organizations.json'
|
||||
const USER_ORGANIZATION_DATA_PATH = './fixtures/user-organizations.json'
|
||||
const PROJECT_MEMBER_DATA_PATH = './fixtures/project-members.json'
|
||||
const PRIMARY_DOMAIN_DATA_PATH = './fixtures/primary-domains.json'
|
||||
const DEPLOYMENT_DATA_PATH = './fixtures/deployments.json'
|
||||
const ENVIRONMENT_VARIABLE_DATA_PATH = './fixtures/environment-variables.json'
|
||||
const REDIRECTED_DOMAIN_DATA_PATH = './fixtures/redirected-domains.json'
|
||||
|
||||
const generateTestData = async (dataSource: DataSource) => {
|
||||
const userEntities = await getEntities(
|
||||
path.resolve(__dirname, USER_DATA_PATH)
|
||||
)
|
||||
const savedUsers = await loadAndSaveData(User, dataSource, userEntities)
|
||||
|
||||
const orgEntities = await getEntities(
|
||||
path.resolve(__dirname, ORGANIZATION_DATA_PATH)
|
||||
)
|
||||
const savedOrgs = await loadAndSaveData(Organization, dataSource, orgEntities)
|
||||
|
||||
const projectRelations = {
|
||||
owner: savedUsers,
|
||||
organization: savedOrgs
|
||||
}
|
||||
|
||||
const projectEntities = await getEntities(
|
||||
path.resolve(__dirname, PROJECT_DATA_PATH)
|
||||
)
|
||||
const savedProjects = await loadAndSaveData(
|
||||
Project,
|
||||
dataSource,
|
||||
projectEntities,
|
||||
projectRelations
|
||||
)
|
||||
|
||||
const domainRepository = dataSource.getRepository(Domain)
|
||||
|
||||
const domainPrimaryRelations = {
|
||||
project: savedProjects
|
||||
}
|
||||
|
||||
const primaryDomainsEntities = await getEntities(
|
||||
path.resolve(__dirname, PRIMARY_DOMAIN_DATA_PATH)
|
||||
)
|
||||
const savedPrimaryDomains = await loadAndSaveData(
|
||||
Domain,
|
||||
dataSource,
|
||||
primaryDomainsEntities,
|
||||
domainPrimaryRelations
|
||||
)
|
||||
|
||||
const domainRedirectedRelations = {
|
||||
project: savedProjects,
|
||||
redirectTo: savedPrimaryDomains
|
||||
}
|
||||
|
||||
const redirectDomainsEntities = await getEntities(
|
||||
path.resolve(__dirname, REDIRECTED_DOMAIN_DATA_PATH)
|
||||
)
|
||||
await loadAndSaveData(
|
||||
Domain,
|
||||
dataSource,
|
||||
redirectDomainsEntities,
|
||||
domainRedirectedRelations
|
||||
)
|
||||
|
||||
const savedDomains = await domainRepository.find()
|
||||
|
||||
const userOrganizationRelations = {
|
||||
member: savedUsers,
|
||||
organization: savedOrgs
|
||||
}
|
||||
|
||||
const userOrganizationsEntities = await getEntities(
|
||||
path.resolve(__dirname, USER_ORGANIZATION_DATA_PATH)
|
||||
)
|
||||
await loadAndSaveData(
|
||||
UserOrganization,
|
||||
dataSource,
|
||||
userOrganizationsEntities,
|
||||
userOrganizationRelations
|
||||
)
|
||||
|
||||
const projectMemberRelations = {
|
||||
member: savedUsers,
|
||||
project: savedProjects
|
||||
}
|
||||
|
||||
const projectMembersEntities = await getEntities(
|
||||
path.resolve(__dirname, PROJECT_MEMBER_DATA_PATH)
|
||||
)
|
||||
await loadAndSaveData(
|
||||
ProjectMember,
|
||||
dataSource,
|
||||
projectMembersEntities,
|
||||
projectMemberRelations
|
||||
)
|
||||
|
||||
const deploymentRelations = {
|
||||
project: savedProjects,
|
||||
domain: savedDomains,
|
||||
createdBy: savedUsers
|
||||
}
|
||||
|
||||
const deploymentsEntities = await getEntities(
|
||||
path.resolve(__dirname, DEPLOYMENT_DATA_PATH)
|
||||
)
|
||||
await loadAndSaveData(
|
||||
Deployment,
|
||||
dataSource,
|
||||
deploymentsEntities,
|
||||
deploymentRelations
|
||||
)
|
||||
|
||||
const environmentVariableRelations = {
|
||||
project: savedProjects
|
||||
}
|
||||
|
||||
const environmentVariablesEntities = await getEntities(
|
||||
path.resolve(__dirname, ENVIRONMENT_VARIABLE_DATA_PATH)
|
||||
)
|
||||
await loadAndSaveData(
|
||||
EnvironmentVariable,
|
||||
dataSource,
|
||||
environmentVariablesEntities,
|
||||
environmentVariableRelations
|
||||
)
|
||||
}
|
||||
|
||||
const main = async () => {
|
||||
const config = await getConfig()
|
||||
const isDbPresent = await checkFileExists(config.database.dbPath)
|
||||
|
||||
if (!isDbPresent) {
|
||||
const dataSource = new DataSource({
|
||||
type: 'better-sqlite3',
|
||||
database: config.database.dbPath,
|
||||
synchronize: true,
|
||||
logging: true,
|
||||
entities: [path.join(__dirname, '../src/entity/*')]
|
||||
})
|
||||
|
||||
await dataSource.initialize()
|
||||
|
||||
await generateTestData(dataSource)
|
||||
log('Data loaded successfully')
|
||||
} else {
|
||||
log('WARNING: Database already exists')
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
log(err)
|
||||
})
|
||||
@@ -0,0 +1,49 @@
|
||||
import debug from 'debug'
|
||||
|
||||
import { Registry, parseGasAndFees } from '@cerc-io/registry-sdk'
|
||||
|
||||
import { getConfig } from '../src/utils'
|
||||
|
||||
const log = debug('snowball:initialize-registry')
|
||||
|
||||
const DENOM = 'alnt'
|
||||
const BOND_AMOUNT = '1000000000'
|
||||
|
||||
async function main() {
|
||||
const { registryConfig } = await getConfig()
|
||||
|
||||
// TODO: Get authority names from args
|
||||
const authorityNames = ['snowballtools', registryConfig.authority]
|
||||
|
||||
const registry = new Registry(
|
||||
registryConfig.gqlEndpoint,
|
||||
registryConfig.restEndpoint,
|
||||
{ chainId: registryConfig.chainId }
|
||||
)
|
||||
|
||||
const bondId = await registry.getNextBondId(registryConfig.privateKey)
|
||||
log('bondId:', bondId)
|
||||
|
||||
const fee = parseGasAndFees(registryConfig.fee.gas, registryConfig.fee.fees)
|
||||
|
||||
await registry.createBond(
|
||||
{ denom: DENOM, amount: BOND_AMOUNT },
|
||||
registryConfig.privateKey,
|
||||
fee
|
||||
)
|
||||
|
||||
for await (const name of authorityNames) {
|
||||
await registry.reserveAuthority({ name }, registryConfig.privateKey, fee)
|
||||
log('Reserved authority name:', name)
|
||||
await registry.setAuthorityBond(
|
||||
{ name, bondId },
|
||||
registryConfig.privateKey,
|
||||
fee
|
||||
)
|
||||
log(`Bond ${bondId} set for authority ${name}`)
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
log(err)
|
||||
})
|
||||
@@ -0,0 +1,100 @@
|
||||
import path from 'node:path'
|
||||
import debug from 'debug'
|
||||
import { DataSource } from 'typeorm'
|
||||
|
||||
import { Registry, parseGasAndFees } from '@cerc-io/registry-sdk'
|
||||
|
||||
import {
|
||||
Deployment,
|
||||
DeploymentStatus,
|
||||
Environment
|
||||
} from '../src/entity/Deployment'
|
||||
import { getConfig } from '../src/utils'
|
||||
|
||||
const log = debug('snowball:publish-deploy-records')
|
||||
|
||||
async function main() {
|
||||
const { registryConfig, database } = await getConfig()
|
||||
|
||||
const registry = new Registry(
|
||||
registryConfig.gqlEndpoint,
|
||||
registryConfig.restEndpoint,
|
||||
{ chainId: registryConfig.chainId }
|
||||
)
|
||||
|
||||
const dataSource = new DataSource({
|
||||
type: 'better-sqlite3',
|
||||
database: database.dbPath,
|
||||
synchronize: true,
|
||||
entities: [path.join(__dirname, '../src/entity/*')]
|
||||
})
|
||||
|
||||
await dataSource.initialize()
|
||||
|
||||
const deploymentRepository = dataSource.getRepository(Deployment)
|
||||
const deployments = await deploymentRepository.find({
|
||||
relations: {
|
||||
project: true
|
||||
},
|
||||
where: {
|
||||
status: DeploymentStatus.Building
|
||||
}
|
||||
})
|
||||
|
||||
for await (const deployment of deployments) {
|
||||
const url = `https://${(deployment.project.name).toLowerCase()}-${deployment.id}.${deployment.deployer.baseDomain}`
|
||||
|
||||
const applicationDeploymentRecord = {
|
||||
type: 'ApplicationDeploymentRecord',
|
||||
version: '0.0.1',
|
||||
name: deployment.applicationRecordData.name,
|
||||
application: deployment.applicationRecordId,
|
||||
|
||||
// TODO: Create DNS record
|
||||
dns: 'bafyreihlymqggsgqiqawvehkpr2imt4l3u6q7um7xzjrux5rhsvwnuyewm',
|
||||
|
||||
// Using dummy values
|
||||
meta: JSON.stringify({
|
||||
config: 'da39a3ee5e6b4b0d3255bfef95601890afd80709',
|
||||
so: '66fcfa49a1664d4cb4ce4f72c1c0e151'
|
||||
}),
|
||||
|
||||
request: deployment.applicationDeploymentRequestId,
|
||||
url
|
||||
}
|
||||
|
||||
const fee = parseGasAndFees(registryConfig.fee.gas, registryConfig.fee.fees)
|
||||
|
||||
const result = await registry.setRecord(
|
||||
{
|
||||
privateKey: registryConfig.privateKey,
|
||||
record: applicationDeploymentRecord,
|
||||
bondId: registryConfig.bondId
|
||||
},
|
||||
'',
|
||||
fee
|
||||
)
|
||||
|
||||
// Remove deployment for project subdomain if deployment is for production environment
|
||||
if (deployment.environment === Environment.Production) {
|
||||
applicationDeploymentRecord.url = `https://${deployment.project.name}.${deployment.deployer.baseDomain}`
|
||||
|
||||
await registry.setRecord(
|
||||
{
|
||||
privateKey: registryConfig.privateKey,
|
||||
record: applicationDeploymentRecord,
|
||||
bondId: registryConfig.bondId
|
||||
},
|
||||
'',
|
||||
fee
|
||||
)
|
||||
}
|
||||
|
||||
log('Application deployment record data:', applicationDeploymentRecord)
|
||||
log(`Application deployment record published: ${result.id}`)
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
log(err)
|
||||
})
|
||||
@@ -0,0 +1,70 @@
|
||||
import path from 'node:path'
|
||||
import debug from 'debug'
|
||||
import { DataSource } from 'typeorm'
|
||||
|
||||
import { Registry, parseGasAndFees } from '@cerc-io/registry-sdk'
|
||||
|
||||
import { Deployment, DeploymentStatus } from '../src/entity/Deployment'
|
||||
import { getConfig } from '../src/utils'
|
||||
|
||||
const log = debug('snowball:publish-deployment-removal-records')
|
||||
|
||||
async function main() {
|
||||
const { registryConfig, database } = await getConfig()
|
||||
|
||||
const registry = new Registry(
|
||||
registryConfig.gqlEndpoint,
|
||||
registryConfig.restEndpoint,
|
||||
{ chainId: registryConfig.chainId }
|
||||
)
|
||||
|
||||
const dataSource = new DataSource({
|
||||
type: 'better-sqlite3',
|
||||
database: database.dbPath,
|
||||
synchronize: true,
|
||||
entities: [path.join(__dirname, '../src/entity/*')]
|
||||
})
|
||||
|
||||
await dataSource.initialize()
|
||||
|
||||
const deploymentRepository = dataSource.getRepository(Deployment)
|
||||
const deployments = await deploymentRepository.find({
|
||||
relations: {
|
||||
project: true
|
||||
},
|
||||
where: {
|
||||
status: DeploymentStatus.Deleting
|
||||
}
|
||||
})
|
||||
|
||||
for await (const deployment of deployments) {
|
||||
const applicationDeploymentRemovalRecord = {
|
||||
type: 'ApplicationDeploymentRemovalRecord',
|
||||
version: '1.0.0',
|
||||
deployment: deployment.applicationDeploymentRecordId,
|
||||
request: deployment.applicationDeploymentRemovalRequestId
|
||||
}
|
||||
|
||||
const fee = parseGasAndFees(registryConfig.fee.gas, registryConfig.fee.fees)
|
||||
|
||||
const result = await registry.setRecord(
|
||||
{
|
||||
privateKey: registryConfig.privateKey,
|
||||
record: applicationDeploymentRemovalRecord,
|
||||
bondId: registryConfig.bondId
|
||||
},
|
||||
'',
|
||||
fee
|
||||
)
|
||||
|
||||
log(
|
||||
'Application deployment removal record data:',
|
||||
applicationDeploymentRemovalRecord
|
||||
)
|
||||
log(`Application deployment removal record published: ${result.id}`)
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
log(err)
|
||||
})
|
||||
Reference in New Issue
Block a user