Skip to content

Commit

Permalink
refactor: ✨ move netlify functions folder
Browse files Browse the repository at this point in the history
  • Loading branch information
kien-ht committed May 27, 2024
1 parent e2cc059 commit 95285e0
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 23 deletions.
8 changes: 8 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@
from = "/*"
to = "/index.html"
status = 200

[functions]
directory = "/src/github-app-server/functions"

[build]
ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF src/github-app-server src/common src/ui package.json netlify.toml"
publish = "dist/ui"
command = "npm run build:ci"
12 changes: 1 addition & 11 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import {
GenerateInlineConfig,
StartInlineConfig,
RunMode,
InjectedData,
ProbotLogLevel
InjectedData
} from './types.js'
import { DEFAULT_CONFIG, DEFAULT_CONFIG_PATH } from './constants.js'
import { __dirname, dynamicImport } from './utils-cjs.js'
Expand Down Expand Up @@ -234,12 +233,3 @@ async function getLatestJsonFromDir(dir: string): Promise<string | undefined> {
throw Error((err as Error).message)
}
}

export function getProbotConfig() {
return {
appId: process.env.APP_ID!,
privateKey: process.env.PRIVATE_KEY!,
secret: process.env.WEBHOOK_SECRET!,
logLevel: process.env.LOG_LEVEL! as ProbotLogLevel
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ import {
Report,
DownloadArtifactsOptions,
GetSnapshotsHashed,
HashedSnapshotToUpdate
HashedSnapshotToUpdate,
ProbotLogLevel
} from '../common/types.js'
import { App as OctokitApp, Octokit } from 'octokit'
import {
getProbotConfig,
getReportJsonWithTotalStats
} from '../common/utils.js'
import { getReportJsonWithTotalStats } from '../common/utils.js'

export class CiController {
private app: OctokitApp
Expand Down Expand Up @@ -106,7 +104,16 @@ export async function downloadArtifacts(
return JSON.parse(report.getData().toString())
}

export async function getSnapshotsHashes(
function getProbotConfig() {
return {
appId: process.env.APP_ID!,
privateKey: process.env.PRIVATE_KEY!,
secret: process.env.WEBHOOK_SECRET!,
logLevel: process.env.LOG_LEVEL! as ProbotLogLevel
}
}

async function getSnapshotsHashes(
{ owner, repo, snapshots }: GetSnapshotsHashed,
octokit: Octokit | ProbotOctokit
): Promise<HashedSnapshotToUpdate[]> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Handler } from '@netlify/functions'
import { UpdateBaselines, WorkflowInstance } from '../../src/common/types'
import { CiController } from '../../src/github-ci-server/controller'
import { PATH_TO_SERVERLESS_FUNCTIONS } from '../../src/common/constants'
import { UpdateBaselines, WorkflowInstance } from '../../common/types'
import { CiController } from '../controller'
import { PATH_TO_SERVERLESS_FUNCTIONS } from '../../common/constants'

// Replace escaped newlines to fix this octokit bug
// Error: secretOrPrivateKey must be an asymmetric key when using RS256
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
createProbot,
ApplicationFunction
} from '@probot/adapter-aws-lambda-serverless'
import { appFn } from '../../src/github-ci-server/webhook'
import { appFn } from '../probot-app'

// Replace escaped newlines to fix this octokit bug
// Error: secretOrPrivateKey must be an asymmetric key when using RS256
Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions src/ui/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ export default defineConfig(async ({ mode }): Promise<UserConfig> => {
publicDir: mode === 'development' ? '../../playground' : false,

build: {
outDir:
process.env.RUN_MODE === 'ci' ? '../../dist-ci/ui' : '../../dist/ui',
outDir: '../../dist/ui',
emptyOutDir: true
},

Expand Down

0 comments on commit 95285e0

Please sign in to comment.