Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sahinvardar committed May 15, 2024
0 parents commit 88cd93d
Show file tree
Hide file tree
Showing 52 changed files with 17,300 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
'plugin:typescript-sort-keys/recommended'
],
plugins: ['@typescript-eslint', 'unused-imports', 'typescript-sort-keys'],
ignorePatterns: [
'*.cjs',
'jest.*.ts',
'/dist',
'**/cdk.out/*',
'**/build/*',
'pnpm-*.yaml',
'*.sql',
'*.sh',
'*.png',
'*.svg',
'*.jpg',
'*.jpeg',
'*.csv',
'*.ttf',
'*.postcss',
'*.html',
'*.md',
'*.css',
'LICENSE'
],
overrides: [],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2021
},
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'turbo/no-undeclared-env-vars': 'off',
'unused-imports/no-unused-imports-ts': 'error',
'@typescript-eslint/no-unused-vars': [
'warn',
{ vars: 'all', varsIgnorePattern: '^_', args: 'after-used', argsIgnorePattern: '^_' }
]
},
env: {
browser: true,
es2022: true,
node: true
},
globals: {
$$Generic: 'readonly'
}
};
14 changes: 14 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: build-test
on: push
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- uses: pnpm/action-setup@v2
- run: pnpm install
- run: pnpm build
24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: release
on:
push:
branches: [release]
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
pull-requests: write
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
registry-url: https://registry.npmjs.org/
- uses: pnpm/action-setup@v2
- run: pnpm install
- run: pnpm build
- run: pnpm semantic-release
env:
GITHUB_TOKEN: ${{ github.TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
134 changes: 134 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

lib

.DS_Store
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm lint-staged
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"printWidth": 120,
"arrowParens": "avoid",
"trailingComma": "none"
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Sahin Vardar

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
11 changes: 11 additions & 0 deletions example/deploy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.js
!jest.config.js
*.d.ts
node_modules

# CDK asset staging directory
.cdk.staging
cdk.out

!lib
cdk.outputs.json
7 changes: 7 additions & 0 deletions example/deploy/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.ts
!*.d.ts

# CDK asset staging directory
.cdk.staging
cdk.out
cdk.context.json
34 changes: 34 additions & 0 deletions example/deploy/cdk.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"app": "tsx src/app.ts",
"context": {
"@aws-cdk/aws-lambda:recognizeLayerVersion": true,
"@aws-cdk/core:checkSecretUsage": true,
"@aws-cdk/core:target-partitions": ["aws", "aws-cn"],
"@aws-cdk-containers/ecs-service-extensions:enableDefaultLogDriver": true,
"@aws-cdk/aws-ec2:uniqueImdsv2TemplateName": true,
"@aws-cdk/aws-ecs:arnFormatIncludesClusterName": true,
"@aws-cdk/aws-iam:minimizePolicies": true,
"@aws-cdk/core:validateSnapshotRemovalPolicy": true,
"@aws-cdk/aws-codepipeline:crossAccountKeyAliasStackSafeResourceName": true,
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true,
"@aws-cdk/aws-sns-subscriptions:restrictSqsDescryption": true,
"@aws-cdk/aws-apigateway:disableCloudWatchRole": true,
"@aws-cdk/core:enablePartitionLiterals": true,
"@aws-cdk/aws-events:eventsTargetQueueSameAccount": true,
"@aws-cdk/aws-iam:standardizedServicePrincipals": true,
"@aws-cdk/aws-ecs:disableExplicitDeploymentControllerForCircuitBreaker": true,
"@aws-cdk/aws-iam:importedRoleStackSafeDefaultPolicyName": true,
"@aws-cdk/aws-s3:serverAccessLogsUseBucketPolicy": true,
"@aws-cdk/aws-route53-patters:useCertificate": true,
"@aws-cdk/customresources:installLatestAwsSdkDefault": false,
"@aws-cdk/aws-rds:databaseProxyUniqueResourceName": true,
"@aws-cdk/aws-codedeploy:removeAlarmsFromDeploymentGroup": true,
"@aws-cdk/aws-apigateway:authorizerChangeDeploymentLogicalId": true,
"@aws-cdk/aws-ec2:launchTemplateDefaultUserData": true,
"@aws-cdk/aws-secretsmanager:useAttachedSecretResourcePolicyForSecretTargetAttachments": true,
"@aws-cdk/aws-redshift:columnId": true,
"@aws-cdk/aws-stepfunctions-tasks:enableEmrServicePolicyV2": true,
"@aws-cdk/aws-ec2:restrictDefaultSecurityGroup": true,
"@aws-cdk/aws-apigateway:requestValidatorUniqueId": true
}
}
26 changes: 26 additions & 0 deletions example/deploy/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"private": true,
"name": "deploy",
"type": "module",
"bin": {
"deploy": "bin/deploy.js"
},
"scripts": {
"build": "tsc --noEmit",
"cdk-deploy": "cdk deploy --outputs-file ./cdk.outputs.json",
"cdk-destroy": "cdk destroy",
"cdk-synth": "cdk synth"
},
"devDependencies": {
"@types/node": "*",
"@vardario/cdk-spa-app": "workspace:*",
"aws-cdk": "*",
"aws-cdk-lib": "*",
"constructs": "*",
"esbuild": "^0.17.17",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.1",
"tsx": "^4.7.0",
"typescript": "^5.0.0"
}
}
7 changes: 7 additions & 0 deletions example/deploy/src/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env node
import 'source-map-support/register.js';
import * as cdk from 'aws-cdk-lib';
import { CdkSpaDeploymentExample } from './cdk-spa-deployment-example.js';

const app = new cdk.App();
new CdkSpaDeploymentExample(app, 'CdkSpaDeploymentExample', {});
41 changes: 41 additions & 0 deletions example/deploy/src/cdk-spa-deployment-example.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import path from 'node:path';
import { SpaApp } from '@vardario/cdk-spa-app/src/spa-app.js';
import { fileURLToPath } from 'node:url';

export class CdkSpaDeploymentExample extends cdk.Stack {
public reactApp: SpaApp;
public svelteApp: SpaApp;
public readonly reactAppUrl: cdk.CfnOutput;
public readonly svelteAppUrl: cdk.CfnOutput;

constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

this.reactApp = new SpaApp(this, 'FrontendReactApp', {
spaBuildPath: path.resolve(__dirname, '../../react-app/build'),
config: {
region: cdk.Stack.of(this).region
}
});

this.svelteApp = new SpaApp(this, 'FrontendSvelteApp', {
spaBuildPath: path.resolve(__dirname, '../../svelte-app/build'),
config: {
region: cdk.Stack.of(this).region
}
});

this.reactAppUrl = new cdk.CfnOutput(this, 'FrontendReactAppUrl', {
value: this.reactApp.appUrl
});

this.svelteAppUrl = new cdk.CfnOutput(this, 'FrontendSvelteAppUrl', {
value: this.svelteApp.appUrl
});
}
}
Loading

0 comments on commit 88cd93d

Please sign in to comment.