-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #193 from napse-invest/dev
Dev
- Loading branch information
Showing
91 changed files
with
12,961 additions
and
853 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ node_modules | |
/app | ||
dist | ||
next-env.d.ts | ||
out/ | ||
out/ | ||
secrets.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { | ||
CreateApplicationCommand, | ||
ElasticBeanstalkClient | ||
} from '@aws-sdk/client-elastic-beanstalk' | ||
import { BrowserWindow } from 'electron' | ||
|
||
export default async function Main( | ||
secrets: { | ||
AWS__API_TOKEN: string | ||
AWS__API_SECRET: string | ||
AWS__REGION: string | ||
}, | ||
mainWindow: BrowserWindow, | ||
ApplicationName: string, | ||
ApplicationDescription: string | ||
) { | ||
const client = new ElasticBeanstalkClient({ | ||
region: secrets.AWS__REGION, | ||
credentials: { | ||
accessKeyId: secrets.AWS__API_TOKEN, | ||
secretAccessKey: secrets.AWS__API_SECRET | ||
} | ||
}) | ||
|
||
const params = { | ||
ApplicationName: ApplicationName, | ||
Description: ApplicationDescription | ||
} | ||
|
||
try { | ||
const data = await client.send(new CreateApplicationCommand(params)) | ||
} catch (err) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { | ||
CreateApplicationVersionCommand, | ||
ElasticBeanstalkClient | ||
} from '@aws-sdk/client-elastic-beanstalk' | ||
|
||
export default async function Main( | ||
secrets: { | ||
AWS__API_TOKEN: string | ||
AWS__API_SECRET: string | ||
AWS__REGION: string | ||
}, | ||
mainWindow: Electron.BrowserWindow, | ||
applicationName: string, | ||
s3BucketName: string, | ||
newVersionLabel: string | ||
) { | ||
const ebClient = new ElasticBeanstalkClient({ | ||
region: secrets.AWS__REGION, | ||
credentials: { | ||
accessKeyId: secrets.AWS__API_TOKEN, | ||
secretAccessKey: secrets.AWS__API_SECRET | ||
} | ||
}) | ||
try { | ||
const data = await ebClient.send( | ||
new CreateApplicationVersionCommand({ | ||
ApplicationName: applicationName, | ||
VersionLabel: newVersionLabel, | ||
SourceBundle: { | ||
S3Bucket: s3BucketName, | ||
S3Key: `deploy-${newVersionLabel}.zip` | ||
} | ||
}) | ||
) | ||
} catch (err) {} | ||
} |
109 changes: 109 additions & 0 deletions
109
desktop-app/main/helpers/aws/EB/createEBEnvironement.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import { | ||
CreateEnvironmentCommand, | ||
ElasticBeanstalkClient | ||
} from '@aws-sdk/client-elastic-beanstalk' | ||
import { | ||
EB_BUCKET_NAME, | ||
getBucketURL, | ||
getIAMRoleArn, | ||
getInstanceProfileArn | ||
} from 'main/helpers' | ||
|
||
export default async function Main( | ||
secrets: { | ||
AWS__API_TOKEN: string | ||
AWS__API_SECRET: string | ||
AWS__REGION: string | ||
}, | ||
mainWindow: Electron.BrowserWindow, | ||
applicationName: string, | ||
environmentName: string, | ||
instanceProfileName: string, | ||
serviceRoleName: string, | ||
versionLabel: string | ||
) { | ||
const client = new ElasticBeanstalkClient({ | ||
region: secrets.AWS__REGION, | ||
credentials: { | ||
accessKeyId: secrets.AWS__API_TOKEN, | ||
secretAccessKey: secrets.AWS__API_SECRET | ||
} | ||
}) | ||
|
||
const params = { | ||
ApplicationName: applicationName, | ||
EnvironmentName: environmentName, | ||
SolutionStackName: '64bit Amazon Linux 2023 v4.1.2 running Docker', | ||
OptionSettings: [ | ||
{ | ||
Namespace: 'aws:autoscaling:launchconfiguration', | ||
OptionName: 'IamInstanceProfile', | ||
Value: await getInstanceProfileArn( | ||
secrets, | ||
mainWindow, | ||
instanceProfileName | ||
) | ||
}, | ||
{ | ||
Namespace: 'aws:autoscaling:launchconfiguration', | ||
OptionName: 'InstanceType', | ||
Value: 't2.small' | ||
}, | ||
{ | ||
Namespace: 'aws:elasticbeanstalk:environment', | ||
OptionName: 'EnvironmentType', | ||
Value: 'SingleInstance' | ||
}, | ||
{ | ||
Namespace: 'aws:ec2:instances', | ||
OptionName: 'EnableSpot', | ||
Value: 'true' | ||
}, | ||
{ | ||
Namespace: 'aws:elasticbeanstalk:environment', | ||
OptionName: 'ServiceRole', | ||
Value: await getIAMRoleArn(secrets, mainWindow, serviceRoleName) | ||
}, | ||
{ | ||
Namespace: 'aws:elasticbeanstalk:cloudwatch:logs', | ||
OptionName: 'StreamLogs', | ||
Value: 'true' | ||
}, | ||
{ | ||
Namespace: 'aws:elasticbeanstalk:cloudwatch:logs', | ||
OptionName: 'DeleteOnTerminate', | ||
Value: 'true' | ||
}, | ||
{ | ||
Namespace: 'aws:elasticbeanstalk:cloudwatch:logs', | ||
OptionName: 'RetentionInDays', | ||
Value: '7' | ||
}, | ||
{ | ||
Namespace: 'aws:elasticbeanstalk:application:environment', | ||
OptionName: 'DJANGO_SECRET_KEY', | ||
Value: 'django-secret-key' | ||
}, | ||
{ | ||
Namespace: 'aws:elasticbeanstalk:application:environment', | ||
OptionName: 'AWS_ACCESS_KEY_ID', | ||
Value: secrets.AWS__API_TOKEN | ||
}, | ||
{ | ||
Namespace: 'aws:elasticbeanstalk:application:environment', | ||
OptionName: 'AWS_SECRET_ACCESS_KEY', | ||
Value: secrets.AWS__API_SECRET | ||
}, | ||
{ | ||
Namespace: 'aws:elasticbeanstalk:application:environment', | ||
OptionName: 'AWS_S3_BUCKET_URI', | ||
Value: getBucketURL(EB_BUCKET_NAME, 'litestream') | ||
} | ||
], | ||
VersionLabel: versionLabel | ||
} | ||
|
||
try { | ||
const data = await client.send(new CreateEnvironmentCommand(params)) | ||
} catch (err) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { | ||
DeleteApplicationCommand, | ||
ElasticBeanstalkClient | ||
} from '@aws-sdk/client-elastic-beanstalk' | ||
import { BrowserWindow } from 'electron' | ||
|
||
export default async function Main( | ||
secrets: { | ||
AWS__API_TOKEN: string | ||
AWS__API_SECRET: string | ||
AWS__REGION: string | ||
}, | ||
mainWindow: BrowserWindow, | ||
ApplicationName: string | ||
) { | ||
const client = new ElasticBeanstalkClient({ | ||
region: secrets.AWS__REGION, | ||
credentials: { | ||
accessKeyId: secrets.AWS__API_TOKEN, | ||
secretAccessKey: secrets.AWS__API_SECRET | ||
} | ||
}) | ||
|
||
const params = { | ||
ApplicationName: ApplicationName | ||
} | ||
|
||
try { | ||
const data = await client.send(new DeleteApplicationCommand(params)) | ||
} catch (err) {} | ||
} |
Oops, something went wrong.