Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: version 3 #6

Merged
merged 2 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ on:
jobs:
release:
name: Release (${{ github.event.workflow_run.head_commit.id }})
if: ${{ github.event.workflow_run.head_branch == 'main' && github.event.workflow_run.conclusion == 'success' }}
if: ${{ github.event.workflow_run.head_branch == 'main' && github.event.workflow_run.conclusion == 'success' && github.repository_owner == 'Data-Only-Greater'}}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
registry-url: 'https://registry.npmjs.org'
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,30 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
node-version: [16, 18]
node-version: [18, 20]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: yarn install
run: npm install
- name: Test
run: yarn run test run --reporter verbose
run: npm run test -- run --reporter verbose
coverage:
needs: 'test'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
- name: Install dependencies
run: yarn install
run: npm install
- name: Generate coverage report
run: yarn run coverage
run: npm run coverage
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
node_modules
dist
coverage
yarn.lock
package-lock.json
!release.config.js
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"editor.formatOnSave": true
}
6 changes: 3 additions & 3 deletions bin/destroy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { createRequire } from 'module'

import yargs from 'yargs/yargs'

import { AWSAdapterProps } from '../adapter'
import { AWSAdapterProps } from '../adapter.js'

const __dirname = fileURLToPath(new URL('.', import.meta.url))

Expand Down Expand Up @@ -52,7 +52,7 @@ export async function main(args: string[]): Promise<void> {
describe: 'cancel ongoing stack updates',
type: 'boolean',
})
}
},
)
.alias('h', 'help')
.help()
Expand Down Expand Up @@ -136,7 +136,7 @@ export async function main(args: string[]): Promise<void> {
cwd: pulumiPath,
stdio: [process.stdin, process.stdout, process.stderr],
env: process.env,
}
},
)

if (comRes.status === null) {
Expand Down
50 changes: 23 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"adapter-stack-destroy": "./bin/destroy.js"
},
"scripts": {
"build": "yarn clean && tsc --project tsconfig.build.json && yarn copy-files",
"build": "npm run clean && tsc --project tsconfig.build.json && npm run copy-files",
"watch": "tsc -w --excludeFiles test",
"format": "prettier --write .",
"test": "vitest",
Expand All @@ -40,46 +40,41 @@
"coverage": "vitest run --coverage"
},
"devDependencies": {
"@types/folder-hash": "^4.0.2",
"@types/lodash": "^4.14.191",
"@types/mime": "^3.0.1",
"@types/minimist": "^1.2.2",
"@types/node": "18.16.3",
"@types/yargs": "^17.0.24",
"@vitest/coverage-c8": "^0.31.0",
"@types/folder-hash": "^4.0.4",
"@types/lodash": "^4.17.1",
"@types/minimist": "^1.2.5",
"@types/node": "20.12.12",
"@types/yargs": "^17.0.32",
"copyfiles": "^2.4.1",
"prettier": "^2.8.8",
"rimraf": "^5.0.0",
"typescript": "^5.0.4",
"vitest": "^0.31.0"
"prettier": "^3.2.5",
"rimraf": "^5.0.7",
"typescript": "^5.4.5",
"vitest": "^1.6.0"
},
"dependencies": {
"@pulumi/aws": "^5.39.0",
"@pulumi/command": "^0.7.1",
"@pulumi/pulumi": "^3.66.0",
"dotenv": "^16.0.3",
"@pulumi/aws": "^6.36.0",
"@pulumi/command": "^0.10.0",
"@pulumi/pulumi": "^3.116.1",
"@vitest/coverage-v8": "^1.6.0",
"dotenv": "^16.4.5",
"folder-hash": "^4.0.4",
"lodash": "^4.17.21",
"sveltekit-adapter-aws-base": "^2.2.2",
"mime": "^4.0.3",
"sveltekit-adapter-aws-base": "^3.0.1",
"yargs": "^17.7.2"
},
"peerDependencies": {
"@sveltejs/kit": "^1.15.2"
"@sveltejs/kit": "^2.5.8"
},
"resolutions": {
"vitest/**/vite": "~4.2.0"
"engines": {
"node": ">=18.13"
},
"release": {
"branches": [
"main"
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits"
}
],
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog",
Expand All @@ -103,6 +98,7 @@
"message": "chore(release): set `package.json` to ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
]
],
"preset": "conventionalcommits"
}
}
46 changes: 23 additions & 23 deletions stacks/main/resources.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as fs from 'fs'
import * as mime from 'mime'
import * as path from 'path'
import mime from 'mime'

import * as aws from '@pulumi/aws'
import * as pulumi from '@pulumi/pulumi'
import { local } from '@pulumi/command'

import { NameRegister } from '../utils'
import { NameRegister } from '../utils.js'

const nameRegister = NameRegister.getInstance()
let registerName = (name: string): string => {
Expand All @@ -25,12 +25,12 @@ export function getLambdaRole(functionArns?: string[]): aws.iam.Role {
{
type: string
identifiers: string[]
}
},
]
actions: string[]
effect: string
resources?: string[]
}
},
]
}

Expand Down Expand Up @@ -59,7 +59,7 @@ export function getLambdaRole(functionArns?: string[]): aws.iam.Role {
{
role: iamForLambda.name,
policyArn: aws.iam.ManagedPolicy.AWSLambdaBasicExecutionRole,
}
},
)

if (functionArns) {
Expand Down Expand Up @@ -90,7 +90,7 @@ export function getLambdaRole(functionArns?: string[]): aws.iam.Role {

export function buildRouter(
iamForLambda: aws.iam.Role,
routerPath: string
routerPath: string,
): aws.lambda.Function {
const routerHandler = new aws.lambda.Function(
registerName('LambdaRouterFunctionHandler'),
Expand All @@ -102,15 +102,15 @@ export function buildRouter(
memorySize: 128,
publish: true,
},
{ provider: eastRegion }
{ provider: eastRegion },
)

return routerHandler
}

export function validateCertificate(
FQDN: string,
domainName: string
domainName: string,
): pulumi.Output<string> {
if (!FQDN.includes(domainName)) {
throw new Error('FQDN must contain domainName')
Expand All @@ -122,7 +122,7 @@ export function validateCertificate(
domainName: FQDN,
validationMethod: 'DNS',
},
{ provider: eastRegion }
{ provider: eastRegion },
)

const hostedZone = aws.route53.getZone({
Expand All @@ -138,7 +138,7 @@ export function validateCertificate(
ttl: 60,
type: certificate.domainValidationOptions[0].resourceRecordType,
zoneId: hostedZone.then((x) => x.zoneId),
}
},
)

const certificateValidation = new aws.acm.CertificateValidation(
Expand All @@ -147,15 +147,15 @@ export function validateCertificate(
certificateArn: certificate.arn,
validationRecordFqdns: [validationRecord.fqdn],
},
{ provider: eastRegion }
{ provider: eastRegion },
)

return certificateValidation.certificateArn
}

export function buildStatic(
staticPath: string,
prerenderedPath: string
prerenderedPath: string,
): aws.s3.Bucket {
const bucket = new aws.s3.Bucket(registerName('StaticContentBucket'), {
acl: 'private',
Expand Down Expand Up @@ -200,7 +200,7 @@ export function uploadStatic(dirPath: string, bucket: aws.s3.Bucket) {
},
{
parent: bucket,
}
},
)
})
}
Expand All @@ -210,7 +210,7 @@ export function buildCDN(
bucket: aws.s3.Bucket,
serverHeaders: string[],
FQDN?: string,
certificateArn?: pulumi.Input<string>
certificateArn?: pulumi.Input<string>,
): aws.cloudfront.Distribution {
const defaultRequestPolicy = new aws.cloudfront.OriginRequestPolicy(
registerName('DefaultRequestPolicy'),
Expand All @@ -227,7 +227,7 @@ export function buildCDN(
queryStringsConfig: {
queryStringBehavior: 'all',
},
}
},
)

const oac = new aws.cloudfront.OriginAccessControl(
Expand All @@ -238,7 +238,7 @@ export function buildCDN(
originAccessControlOriginType: 's3',
signingBehavior: 'no-override',
signingProtocol: 'sigv4',
}
},
)

const optimizedCachePolicy = aws.cloudfront.getCachePolicyOutput({
Expand Down Expand Up @@ -300,7 +300,7 @@ export function buildCDN(
restrictionType: 'none',
},
},
}
},
)

const cloudFrontPolicyDocument = aws.iam.getPolicyDocumentOutput({
Expand Down Expand Up @@ -348,7 +348,7 @@ export function buildCDN(
{
bucket: bucket.id,
policy: cloudFrontPolicyDocument.apply((policy) => policy.json),
}
},
)

return distribution
Expand All @@ -358,7 +358,7 @@ export function buildCDN(
// distribution.
export function createAliasRecord(
targetDomain: string,
distribution: aws.cloudfront.Distribution
distribution: aws.cloudfront.Distribution,
): aws.route53.Record {
const domainParts = exports.getDomainAndSubdomain(targetDomain)
const hostedZoneId = aws.route53
Expand Down Expand Up @@ -404,7 +404,7 @@ export function getDomainAndSubdomain(domain: string): {
export function buildInvalidator(
distribution: aws.cloudfront.Distribution,
staticPath: string,
prerenderedPath: string
prerenderedPath: string,
) {
interface PathHashResourceInputs {
path: pulumi.Input<string>
Expand All @@ -427,7 +427,7 @@ export function buildInvalidator(
async diff(
id: string,
previousOutput: PathHashOutputs,
news: PathHashInputs
news: PathHashInputs,
): Promise<pulumi.dynamic.DiffResult> {
const replaces: string[] = []
let changes = true
Expand Down Expand Up @@ -458,7 +458,7 @@ export function buildInvalidator(
constructor(
name: string,
args: PathHashResourceInputs,
opts?: pulumi.CustomResourceOptions
opts?: pulumi.CustomResourceOptions,
) {
super(pathHashProvider, name, { hash: undefined, ...args }, opts)
}
Expand All @@ -480,6 +480,6 @@ export function buildInvalidator(
},
{
dependsOn: [distribution],
}
},
)
}
Loading