Skip to content

Commit 95285e0

Browse files
committed
refactor: ✨ move netlify functions folder
1 parent e2cc059 commit 95285e0

File tree

8 files changed

+27
-23
lines changed

8 files changed

+27
-23
lines changed

netlify.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,11 @@
22
from = "/*"
33
to = "/index.html"
44
status = 200
5+
6+
[functions]
7+
directory = "/src/github-app-server/functions"
8+
9+
[build]
10+
ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF src/github-app-server src/common src/ui package.json netlify.toml"
11+
publish = "dist/ui"
12+
command = "npm run build:ci"

src/common/utils.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import {
1111
GenerateInlineConfig,
1212
StartInlineConfig,
1313
RunMode,
14-
InjectedData,
15-
ProbotLogLevel
14+
InjectedData
1615
} from './types.js'
1716
import { DEFAULT_CONFIG, DEFAULT_CONFIG_PATH } from './constants.js'
1817
import { __dirname, dynamicImport } from './utils-cjs.js'
@@ -234,12 +233,3 @@ async function getLatestJsonFromDir(dir: string): Promise<string | undefined> {
234233
throw Error((err as Error).message)
235234
}
236235
}
237-
238-
export function getProbotConfig() {
239-
return {
240-
appId: process.env.APP_ID!,
241-
privateKey: process.env.PRIVATE_KEY!,
242-
secret: process.env.WEBHOOK_SECRET!,
243-
logLevel: process.env.LOG_LEVEL! as ProbotLogLevel
244-
}
245-
}

src/github-ci-server/controller.ts renamed to src/github-app-server/controller.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ import {
77
Report,
88
DownloadArtifactsOptions,
99
GetSnapshotsHashed,
10-
HashedSnapshotToUpdate
10+
HashedSnapshotToUpdate,
11+
ProbotLogLevel
1112
} from '../common/types.js'
1213
import { App as OctokitApp, Octokit } from 'octokit'
13-
import {
14-
getProbotConfig,
15-
getReportJsonWithTotalStats
16-
} from '../common/utils.js'
14+
import { getReportJsonWithTotalStats } from '../common/utils.js'
1715

1816
export class CiController {
1917
private app: OctokitApp
@@ -106,7 +104,16 @@ export async function downloadArtifacts(
106104
return JSON.parse(report.getData().toString())
107105
}
108106

109-
export async function getSnapshotsHashes(
107+
function getProbotConfig() {
108+
return {
109+
appId: process.env.APP_ID!,
110+
privateKey: process.env.PRIVATE_KEY!,
111+
secret: process.env.WEBHOOK_SECRET!,
112+
logLevel: process.env.LOG_LEVEL! as ProbotLogLevel
113+
}
114+
}
115+
116+
async function getSnapshotsHashes(
110117
{ owner, repo, snapshots }: GetSnapshotsHashed,
111118
octokit: Octokit | ProbotOctokit
112119
): Promise<HashedSnapshotToUpdate[]> {

netlify/functions/api.ts renamed to src/github-app-server/functions/api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Handler } from '@netlify/functions'
2-
import { UpdateBaselines, WorkflowInstance } from '../../src/common/types'
3-
import { CiController } from '../../src/github-ci-server/controller'
4-
import { PATH_TO_SERVERLESS_FUNCTIONS } from '../../src/common/constants'
2+
import { UpdateBaselines, WorkflowInstance } from '../../common/types'
3+
import { CiController } from '../controller'
4+
import { PATH_TO_SERVERLESS_FUNCTIONS } from '../../common/constants'
55

66
// Replace escaped newlines to fix this octokit bug
77
// Error: secretOrPrivateKey must be an asymmetric key when using RS256

netlify/functions/webhooks.ts renamed to src/github-app-server/functions/webhooks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
createProbot,
44
ApplicationFunction
55
} from '@probot/adapter-aws-lambda-serverless'
6-
import { appFn } from '../../src/github-ci-server/webhook'
6+
import { appFn } from '../probot-app'
77

88
// Replace escaped newlines to fix this octokit bug
99
// Error: secretOrPrivateKey must be an asymmetric key when using RS256
File renamed without changes.

src/ui/vite.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ export default defineConfig(async ({ mode }): Promise<UserConfig> => {
5252
publicDir: mode === 'development' ? '../../playground' : false,
5353

5454
build: {
55-
outDir:
56-
process.env.RUN_MODE === 'ci' ? '../../dist-ci/ui' : '../../dist/ui',
55+
outDir: '../../dist/ui',
5756
emptyOutDir: true
5857
},
5958

0 commit comments

Comments
 (0)