From ffc60e45f822229526f900de6bf2af9ba1cafbc7 Mon Sep 17 00:00:00 2001 From: Isha Date: Wed, 6 Nov 2024 10:19:37 +0530 Subject: [PATCH 1/3] Add next app template --- build-webapp.sh | 1 + packages/deployer/deploy-frontend.sh | 1 + packages/deployer/deploy-frontend.staging.sh | 1 + .../application-deployment-request.yml | 1 + .../application-deployment-request.yml | 2 ++ packages/frontend/.env.example | 1 + packages/frontend/src/assets/templates.ts | 25 +++++-------------- .../projects/create/MockConnectGitCard.tsx | 12 ++------- .../CustomIcon/templates/TemplateIcon.tsx | 14 +---------- .../frontend/src/context/Web3Provider.tsx | 2 +- packages/frontend/src/utils/constants.ts | 7 +++--- 11 files changed, 20 insertions(+), 47 deletions(-) diff --git a/build-webapp.sh b/build-webapp.sh index c763a706..e6476e6f 100755 --- a/build-webapp.sh +++ b/build-webapp.sh @@ -14,6 +14,7 @@ VITE_SERVER_URL = 'LACONIC_HOSTED_CONFIG_server_url' VITE_GITHUB_CLIENT_ID = 'LACONIC_HOSTED_CONFIG_github_clientid' VITE_GITHUB_PWA_TEMPLATE_REPO = 'LACONIC_HOSTED_CONFIG_github_pwa_templaterepo' VITE_GITHUB_IMAGE_UPLOAD_PWA_TEMPLATE_REPO = 'LACONIC_HOSTED_CONFIG_github_image_upload_templaterepo' +VITE_GITHUB_NEXT_APP_TEMPLATE_REPO = 'LACONIC_HOSTED_CONFIG_github_next_app_templaterepo' VITE_WALLET_CONNECT_ID = 'LACONIC_HOSTED_CONFIG_wallet_connect_id' VITE_LACONICD_CHAIN_ID = 'LACONIC_HOSTED_CONFIG_laconicd_chain_id' VITE_LIT_RELAY_API_KEY = 'LACONIC_HOSTED_CONFIG_lit_relay_api_key' diff --git a/packages/deployer/deploy-frontend.sh b/packages/deployer/deploy-frontend.sh index b210d8bd..5f843981 100755 --- a/packages/deployer/deploy-frontend.sh +++ b/packages/deployer/deploy-frontend.sh @@ -126,6 +126,7 @@ record: LACONIC_HOSTED_CONFIG_github_clientid: Ov23liaet4yc0KX0iM1c LACONIC_HOSTED_CONFIG_github_pwa_templaterepo: laconic-templates/test-progressive-web-app LACONIC_HOSTED_CONFIG_github_image_upload_templaterepo: laconic-templates/image-upload-pwa-example + LACONIC_HOSTED_CONFIG_github_next_app_templaterepo: laconic-templates/starter.nextjs-react-tailwind LACONIC_HOSTED_CONFIG_wallet_connect_id: 63cad7ba97391f63652161f484670e15 LACONIC_HOSTED_CONFIG_laconicd_chain_id: laconic-testnet-2 meta: diff --git a/packages/deployer/deploy-frontend.staging.sh b/packages/deployer/deploy-frontend.staging.sh index 09ebb820..338b884f 100755 --- a/packages/deployer/deploy-frontend.staging.sh +++ b/packages/deployer/deploy-frontend.staging.sh @@ -40,6 +40,7 @@ record: LACONIC_HOSTED_CONFIG_github_templaterepo: snowball-tools/test-progressive-web-app LACONIC_HOSTED_CONFIG_github_pwa_templaterepo: snowball-tools/test-progressive-web-app LACONIC_HOSTED_CONFIG_github_image_upload_templaterepo: snowball-tools/image-upload-pwa-example + LACONIC_HOSTED_CONFIG_github_next_app_templaterepo: snowball-tools/starter.nextjs-react-tailwind LACONIC_HOSTED_CONFIG_wallet_connect_id: eda9ba18042a5ea500f358194611ece2 LACONIC_HOSTED_CONFIG_laconicd_chain_id: laconic-testnet-2 LACONIC_HOSTED_CONFIG_lit_relay_api_key: 15DDD969-E75F-404D-AAD9-58A37C4FD354_snowball diff --git a/packages/deployer/records/application-deployment-request.yml b/packages/deployer/records/application-deployment-request.yml index 88b6319b..2b53d579 100644 --- a/packages/deployer/records/application-deployment-request.yml +++ b/packages/deployer/records/application-deployment-request.yml @@ -10,6 +10,7 @@ record: LACONIC_HOSTED_CONFIG_github_clientid: Ov23liaet4yc0KX0iM1c LACONIC_HOSTED_CONFIG_github_pwa_templaterepo: laconic-templates/test-progressive-web-app LACONIC_HOSTED_CONFIG_github_image_upload_templaterepo: laconic-templates/image-upload-pwa-example + LACONIC_HOSTED_CONFIG_github_next_app_templaterepo: laconic-templates/starter.nextjs-react-tailwind LACONIC_HOSTED_CONFIG_wallet_connect_id: 63cad7ba97391f63652161f484670e15 meta: note: Added by Snowball @ Thu Apr 4 14:49:41 UTC 2024 diff --git a/packages/deployer/staging-records/application-deployment-request.yml b/packages/deployer/staging-records/application-deployment-request.yml index e3a022a7..a3767504 100644 --- a/packages/deployer/staging-records/application-deployment-request.yml +++ b/packages/deployer/staging-records/application-deployment-request.yml @@ -11,6 +11,8 @@ record: LACONIC_HOSTED_CONFIG_github_templaterepo: snowball-tools/test-progressive-web-app LACONIC_HOSTED_CONFIG_github_pwa_templaterepo: snowball-tools/test-progressive-web-app LACONIC_HOSTED_CONFIG_github_image_upload_templaterepo: snowball-tools/image-upload-pwa-example + LACONIC_HOSTED_CONFIG_github_next_app_templaterepo: snowball-tools/starter.nextjs-react-tailwind + LACONIC_HOSTED_CONFIG_wallet_connect_id: eda9ba18042a5ea500f358194611ece2 LACONIC_HOSTED_CONFIG_lit_relay_api_key: 15DDD969-E75F-404D-AAD9-58A37C4FD354_snowball LACONIC_HOSTED_CONFIG_aplchemy_api_key: THvPart_gqI5x02RNYSBntlmwA66I_qc diff --git a/packages/frontend/.env.example b/packages/frontend/.env.example index 74968931..88f6bc1f 100644 --- a/packages/frontend/.env.example +++ b/packages/frontend/.env.example @@ -3,6 +3,7 @@ VITE_SERVER_URL='http://localhost:8000' VITE_GITHUB_CLIENT_ID= VITE_GITHUB_PWA_TEMPLATE_REPO="snowball-tools/test-progressive-web-app" VITE_GITHUB_IMAGE_UPLOAD_PWA_TEMPLATE_REPO="snowball-tools/image-upload-pwa-example" +VITE_GITHUB_NEXT_APP_TEMPLATE_REPO="snowball-tools/starter.nextjs-react-tailwind" VITE_WALLET_CONNECT_ID= diff --git a/packages/frontend/src/assets/templates.ts b/packages/frontend/src/assets/templates.ts index 98bb3fe3..d263b313 100644 --- a/packages/frontend/src/assets/templates.ts +++ b/packages/frontend/src/assets/templates.ts @@ -1,13 +1,14 @@ import { VITE_GITHUB_IMAGE_UPLOAD_PWA_TEMPLATE_REPO, VITE_GITHUB_PWA_TEMPLATE_REPO, + VITE_GITHUB_NEXT_APP_TEMPLATE_REPO, } from 'utils/constants'; export default [ { id: '1', name: 'Progressive Web App (PWA)', - icon: 'pwa', + icon: 'web', repoFullName: `${VITE_GITHUB_PWA_TEMPLATE_REPO}`, isComingSoon: false, }, @@ -20,23 +21,9 @@ export default [ }, { id: '3', - name: 'Kotlin', - icon: 'kotlin', - repoFullName: '', - isComingSoon: true, - }, - { - id: '4', - name: 'React Native', - icon: 'react-native', - repoFullName: '', - isComingSoon: true, - }, - { - id: '5', - name: 'Swift', - icon: 'swift', - repoFullName: '', - isComingSoon: true, + name: 'Next App', + icon: 'web', + repoFullName: `${VITE_GITHUB_NEXT_APP_TEMPLATE_REPO}`, + isComingSoon: false, }, ]; diff --git a/packages/frontend/src/components/projects/create/MockConnectGitCard.tsx b/packages/frontend/src/components/projects/create/MockConnectGitCard.tsx index 02478060..bcd786bd 100644 --- a/packages/frontend/src/components/projects/create/MockConnectGitCard.tsx +++ b/packages/frontend/src/components/projects/create/MockConnectGitCard.tsx @@ -56,16 +56,8 @@ export const MockConnectGitCard = () => { icon: 'pwa', }, { - name: 'React Native', - icon: 'react-native', - }, - { - name: 'Kotlin', - icon: 'kotlin', - }, - { - name: 'Swift', - icon: 'swift', + name: 'Next app', + icon: 'next-app', }, ]; diff --git a/packages/frontend/src/components/shared/CustomIcon/templates/TemplateIcon.tsx b/packages/frontend/src/components/shared/CustomIcon/templates/TemplateIcon.tsx index fcc74154..43879fcf 100644 --- a/packages/frontend/src/components/shared/CustomIcon/templates/TemplateIcon.tsx +++ b/packages/frontend/src/components/shared/CustomIcon/templates/TemplateIcon.tsx @@ -1,18 +1,12 @@ import { useMemo } from 'react'; import { CustomIconProps } from '../CustomIcon'; -import { ReactNativeIcon } from './ReactNativeIcon'; import { cloneIcon } from 'utils/cloneIcon'; import { PWAIcon } from './PWAIcon'; import { WebAppIcon } from './WebAppIcon'; -import { KotlinIcon } from './KotlinIcon'; -import { SwitfIcon } from './SwiftIcon'; const TEMPLATE_ICONS = [ - 'react-native', 'pwa', - 'web', - 'kotlin', - 'swift', + 'web' ] as const; export type TemplateIconType = (typeof TEMPLATE_ICONS)[number]; @@ -23,16 +17,10 @@ export interface TemplateIconProps extends CustomIconProps { export const TemplateIcon = ({ type, ...props }: TemplateIconProps) => { const renderIcon = useMemo(() => { switch (type) { - case 'react-native': - return ; case 'pwa': return ; case 'web': return ; - case 'kotlin': - return ; - case 'swift': - return ; default: throw new Error(`Invalid template icon type: ${type}`); } diff --git a/packages/frontend/src/context/Web3Provider.tsx b/packages/frontend/src/context/Web3Provider.tsx index 7ab1229f..a7a90651 100644 --- a/packages/frontend/src/context/Web3Provider.tsx +++ b/packages/frontend/src/context/Web3Provider.tsx @@ -17,7 +17,7 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { VITE_WALLET_CONNECT_ID, BASE_URL } from 'utils/constants'; if (!VITE_WALLET_CONNECT_ID) { - throw new Error('Error: REACT_APP_WALLET_CONNECT_ID env config is not set'); + throw new Error('Error: VITE_WALLET_CONNECT_ID env config is not set'); } assert(BASE_URL, 'VITE_SERVER_URL is not set in env'); diff --git a/packages/frontend/src/utils/constants.ts b/packages/frontend/src/utils/constants.ts index 8e2d77b0..037e23aa 100644 --- a/packages/frontend/src/utils/constants.ts +++ b/packages/frontend/src/utils/constants.ts @@ -1,10 +1,9 @@ export const BASE_URL = import.meta.env.VITE_SERVER_URL; export const PASSKEY_WALLET_RPID = import.meta.env.VITE_PASSKEY_WALLET_RPID!; export const TURNKEY_BASE_URL = import.meta.env.VITE_TURNKEY_API_BASE_URL!; -export const VITE_GITHUB_PWA_TEMPLATE_REPO = import.meta.env - .VITE_GITHUB_PWA_TEMPLATE_REPO; -export const VITE_GITHUB_IMAGE_UPLOAD_PWA_TEMPLATE_REPO = import.meta.env - .VITE_GITHUB_IMAGE_UPLOAD_PWA_TEMPLATE_REPO; +export const VITE_GITHUB_PWA_TEMPLATE_REPO = import.meta.env.VITE_GITHUB_PWA_TEMPLATE_REPO; +export const VITE_GITHUB_IMAGE_UPLOAD_PWA_TEMPLATE_REPO = import.meta.env.VITE_GITHUB_IMAGE_UPLOAD_PWA_TEMPLATE_REPO; +export const VITE_GITHUB_NEXT_APP_TEMPLATE_REPO = import.meta.env.VITE_GITHUB_NEXT_APP_TEMPLATE_REPO; export const VITE_GITHUB_CLIENT_ID = import.meta.env.VITE_GITHUB_CLIENT_ID; export const VITE_WALLET_CONNECT_ID = import.meta.env.VITE_WALLET_CONNECT_ID; export const VITE_BUGSNAG_API_KEY = import.meta.env.VITE_BUGSNAG_API_KEY; -- 2.45.2 From 62006a09ed3d431ad19c41f9e9cdce0dd849af2a Mon Sep 17 00:00:00 2001 From: Nabarun Date: Wed, 6 Nov 2024 10:42:17 +0530 Subject: [PATCH 2/3] Add hotfix for updating org slug --- packages/backend/src/database.ts | 25 ++++++++++- packages/deployer/deploy-frontend.sh | 7 +++- packages/deployer/remove-deployment.sh | 57 ++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 4 deletions(-) create mode 100755 packages/deployer/remove-deployment.sh diff --git a/packages/backend/src/database.ts b/packages/backend/src/database.ts index 71b2323b..f20eb455 100644 --- a/packages/backend/src/database.ts +++ b/packages/backend/src/database.ts @@ -49,12 +49,25 @@ export class Database { await this.dataSource.initialize(); log('database initialized'); - const organizations = await this.getOrganizations({}); + let organizations = await this.getOrganizations({}); // Load an organization if none exist if (!organizations.length) { const orgEntities = await getEntities(path.resolve(__dirname, ORGANIZATION_DATA_PATH)); - await loadAndSaveData(Organization, this.dataSource, [orgEntities[0]]); + organizations = await loadAndSaveData(Organization, this.dataSource, [orgEntities[0]]); + } + + // Hotfix for updating old DB data + if (organizations[0].slug === 'snowball-tools-1') { + const [orgEntity] = await getEntities(path.resolve(__dirname, ORGANIZATION_DATA_PATH)); + + await this.updateOrganization( + organizations[0].id, + { + slug: orgEntity.slug as string, + name: orgEntity.name as string + } + ) } } @@ -121,6 +134,14 @@ export class Database { return newUserOrganization; } + async updateOrganization(organizationId: string, data: DeepPartial): Promise { + const organizationRepository = this.dataSource.getRepository(Organization); + const updateResult = await organizationRepository.update({ id: organizationId }, data); + assert(updateResult.affected); + + return updateResult.affected > 0; + } + async getProjects(options: FindManyOptions): Promise { const projectRepository = this.dataSource.getRepository(Project); const projects = await projectRepository.find(options); diff --git a/packages/deployer/deploy-frontend.sh b/packages/deployer/deploy-frontend.sh index 5f843981..83c42887 100755 --- a/packages/deployer/deploy-frontend.sh +++ b/packages/deployer/deploy-frontend.sh @@ -8,8 +8,11 @@ echo "Using AUTHORITY: $AUTHORITY" # Repository URL REPO_URL="https://git.vdb.to/cerc-io/snowballtools-base" -# Get the latest commit hash from the repository -LATEST_HASH=$(git ls-remote $REPO_URL HEAD | awk '{print $1}') +# Get the latest commit hash for a branch +BRANCH_NAME="main" +LATEST_HASH=$(git ls-remote $REPO_URL refs/heads/$BRANCH_NAME | awk '{print $1}') + +echo "Latest commit hash for branch $BRANCH_NAME: $LATEST_HASH" # Extract version from ../frontend/package.json PACKAGE_VERSION=$(jq -r '.version' ../frontend/package.json) diff --git a/packages/deployer/remove-deployment.sh b/packages/deployer/remove-deployment.sh new file mode 100755 index 00000000..f767bb61 --- /dev/null +++ b/packages/deployer/remove-deployment.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +source .env +echo "Using REGISTRY_BOND_ID: $REGISTRY_BOND_ID" +echo "Using DEPLOYER_LRN: $DEPLOYER_LRN" + +# Generate application-deployment-removal-request.yml +REMOVAL_REQUEST_RECORD_FILE=records/application-deployment-removal-request.yml +# TODO: Pass deployment record ID as arg +DEPLOYMENT_RECORD_ID=bafyreidjho77xeczaqpyawhc4wbpm5it5atibtuxk6ost6vnpu2svlp3ka + +cat > $REMOVAL_REQUEST_RECORD_FILE < Date: Wed, 6 Nov 2024 11:14:28 +0530 Subject: [PATCH 3/3] Update nextjs template card name --- .../staging-records/application-deployment-request.yml | 1 - packages/frontend/src/assets/templates.ts | 2 +- .../components/projects/create/MockConnectGitCard.tsx | 2 +- packages/frontend/src/utils/constants.ts | 9 ++++++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/deployer/staging-records/application-deployment-request.yml b/packages/deployer/staging-records/application-deployment-request.yml index a3767504..fd7ee288 100644 --- a/packages/deployer/staging-records/application-deployment-request.yml +++ b/packages/deployer/staging-records/application-deployment-request.yml @@ -12,7 +12,6 @@ record: LACONIC_HOSTED_CONFIG_github_pwa_templaterepo: snowball-tools/test-progressive-web-app LACONIC_HOSTED_CONFIG_github_image_upload_templaterepo: snowball-tools/image-upload-pwa-example LACONIC_HOSTED_CONFIG_github_next_app_templaterepo: snowball-tools/starter.nextjs-react-tailwind - LACONIC_HOSTED_CONFIG_wallet_connect_id: eda9ba18042a5ea500f358194611ece2 LACONIC_HOSTED_CONFIG_lit_relay_api_key: 15DDD969-E75F-404D-AAD9-58A37C4FD354_snowball LACONIC_HOSTED_CONFIG_aplchemy_api_key: THvPart_gqI5x02RNYSBntlmwA66I_qc diff --git a/packages/frontend/src/assets/templates.ts b/packages/frontend/src/assets/templates.ts index d263b313..3dc7c4c8 100644 --- a/packages/frontend/src/assets/templates.ts +++ b/packages/frontend/src/assets/templates.ts @@ -21,7 +21,7 @@ export default [ }, { id: '3', - name: 'Next App', + name: 'Next.js + React + TailwindCSS', icon: 'web', repoFullName: `${VITE_GITHUB_NEXT_APP_TEMPLATE_REPO}`, isComingSoon: false, diff --git a/packages/frontend/src/components/projects/create/MockConnectGitCard.tsx b/packages/frontend/src/components/projects/create/MockConnectGitCard.tsx index bcd786bd..362a52eb 100644 --- a/packages/frontend/src/components/projects/create/MockConnectGitCard.tsx +++ b/packages/frontend/src/components/projects/create/MockConnectGitCard.tsx @@ -56,7 +56,7 @@ export const MockConnectGitCard = () => { icon: 'pwa', }, { - name: 'Next app', + name: 'Next.js + React + TailwindCSS', icon: 'next-app', }, ]; diff --git a/packages/frontend/src/utils/constants.ts b/packages/frontend/src/utils/constants.ts index 037e23aa..446d9d58 100644 --- a/packages/frontend/src/utils/constants.ts +++ b/packages/frontend/src/utils/constants.ts @@ -1,9 +1,12 @@ export const BASE_URL = import.meta.env.VITE_SERVER_URL; export const PASSKEY_WALLET_RPID = import.meta.env.VITE_PASSKEY_WALLET_RPID!; export const TURNKEY_BASE_URL = import.meta.env.VITE_TURNKEY_API_BASE_URL!; -export const VITE_GITHUB_PWA_TEMPLATE_REPO = import.meta.env.VITE_GITHUB_PWA_TEMPLATE_REPO; -export const VITE_GITHUB_IMAGE_UPLOAD_PWA_TEMPLATE_REPO = import.meta.env.VITE_GITHUB_IMAGE_UPLOAD_PWA_TEMPLATE_REPO; -export const VITE_GITHUB_NEXT_APP_TEMPLATE_REPO = import.meta.env.VITE_GITHUB_NEXT_APP_TEMPLATE_REPO; +export const VITE_GITHUB_PWA_TEMPLATE_REPO = import.meta.env + .VITE_GITHUB_PWA_TEMPLATE_REPO; +export const VITE_GITHUB_IMAGE_UPLOAD_PWA_TEMPLATE_REPO = import.meta.env + .VITE_GITHUB_IMAGE_UPLOAD_PWA_TEMPLATE_REPO; +export const VITE_GITHUB_NEXT_APP_TEMPLATE_REPO = import.meta.env + .VITE_GITHUB_NEXT_APP_TEMPLATE_REPO; export const VITE_GITHUB_CLIENT_ID = import.meta.env.VITE_GITHUB_CLIENT_ID; export const VITE_WALLET_CONNECT_ID = import.meta.env.VITE_WALLET_CONNECT_ID; export const VITE_BUGSNAG_API_KEY = import.meta.env.VITE_BUGSNAG_API_KEY; -- 2.45.2