Skip to content

Commit 0b61d03

Browse files
authored
chore: Reduce npm vulnerability and attack surface across workspace (#57)
* chore: reduce npm vulnerability and attack surface across workspace * fix: align sdk TypeScript resolution * fix: wire turbo task dependencies correctly * docs: add repository agent guide * fix: preserve survey script base path * fix: address CodeRabbit review findings * refactor: remove redundant segment filters cast
1 parent 2e3fee9 commit 0b61d03

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1986
-5079
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ jobs:
2323
- name: Checkout code
2424
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2525

26-
- name: Setup Node.js 22.x
26+
- name: Setup Node.js 24.x
2727
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
2828
with:
29-
node-version: 22.x
29+
node-version: 24.x
3030

3131
- name: Install pnpm
3232
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0

.github/workflows/lint.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Lint and Type Check
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened]
9+
merge_group:
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Harden the runner
19+
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
20+
with:
21+
egress-policy: audit
22+
23+
- name: Checkout code
24+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
25+
26+
- name: Setup Node.js 24.x
27+
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
28+
with:
29+
node-version: 24.x
30+
31+
- name: Install pnpm
32+
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
33+
34+
- name: Install dependencies
35+
run: pnpm install --frozen-lockfile
36+
37+
- name: Lint
38+
run: pnpm lint
39+
40+
- name: Check types
41+
run: pnpm check-types

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ jobs:
3535
- name: Install dependencies
3636
run: pnpm install --frozen-lockfile
3737

38+
- name: Lint
39+
run: pnpm lint
40+
41+
- name: Check types
42+
run: pnpm check-types
43+
3844
- name: Build package
3945
run: |
4046
cd packages/react-native

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ jobs:
2424
- name: Checkout code
2525
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2626

27-
- name: Setup Node.js 22.x
27+
- name: Setup Node.js 24.x
2828
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
2929
with:
30-
node-version: 22.x
30+
node-version: 24.x
3131

3232
- name: Install pnpm
3333
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0

AGENTS.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Module Organization
4+
This repository is a `pnpm` workspace with two main packages:
5+
6+
- `packages/react-native`: the published SDK (`@formbricks/react-native`). Source lives in `src/`, grouped by domain under `src/lib/`, with React components in `src/components/` and shared types in `src/types/`.
7+
- `apps/playground`: an Expo app for manual testing and integration checks. App code is in `src/`, with static assets in `assets/`.
8+
9+
GitHub Actions under `.github/workflows/` enforce build, lint, type-check, test, and release steps.
10+
11+
## Build, Test, and Development Commands
12+
Run commands from the repository root unless package-scoped work is needed.
13+
14+
- `pnpm install --frozen-lockfile`: install workspace dependencies.
15+
- `pnpm dev`: run Turbo watchers across packages.
16+
- `pnpm build`: build the SDK and playground.
17+
- `pnpm lint`: enforce exact dependency versions, then run Biome checks.
18+
- `pnpm check-types`: run TypeScript checks across the workspace.
19+
- `pnpm test`: run unit tests with Vitest.
20+
- `pnpm test:coverage`: generate coverage reports used in release validation.
21+
- `pnpm --filter playground ios` / `pnpm --filter playground android`: launch the Expo playground on a device target.
22+
23+
## Coding Style & Naming Conventions
24+
Use TypeScript with strict compiler settings. Biome is the formatter and linter; run `pnpm format` before large refactors. The repo uses spaces for indentation, double quotes, and semicolons.
25+
26+
Follow existing naming patterns: React components in lowercase kebab-style filenames such as `survey-web-view.tsx`, domain modules in concise lowercase names such as `state.ts`, and tests as `*.test.ts`. Keep imports using the `@/` alias inside `packages/react-native` when referencing `src/`.
27+
28+
## Testing Guidelines
29+
Unit tests live beside each domain under `src/lib/**/tests/`. Prefer small, focused Vitest suites and place reusable doubles in local `__mocks__/` folders. Add or update tests with every behavior change; there is no published coverage threshold, but `test:coverage` is part of the release workflow, so changed code should stay covered.
30+
31+
## Commit & Pull Request Guidelines
32+
Recent history mostly follows Conventional Commit-style subjects such as `feat:`, `fix:`, and `chore:` with short imperative summaries. Keep commits narrowly scoped and descriptive.
33+
34+
PRs should include a clear summary, linked issue if applicable, and the commands you ran locally (`pnpm lint`, `pnpm check-types`, relevant tests). Include screenshots or screen recordings when a playground or UI behavior changes. Avoid loose dependency ranges: this repo enforces exact versions in every `package.json`.

apps/playground/.eslintrc.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

apps/playground/app.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
"assetBundlePatterns": ["**/*"],
1010
"icon": "./assets/icon.png",
1111
"ios": {
12-
"infoPlist": {
13-
"NSCameraUsageDescription": "Take pictures for certain activities.",
14-
"NSMicrophoneUsageDescription": "Need microphone access for recording videos.",
15-
"NSPhotoLibraryUsageDescription": "Select pictures for certain activities."
16-
},
1712
"supportsTablet": true
1813
},
1914
"jsEngine": "hermes",

apps/playground/package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,22 @@
77
"android": "expo start --android",
88
"ios": "expo start --ios",
99
"clean": "rimraf .turbo node_modules .expo",
10-
"build": "expo export --no-bytecode"
10+
"build": "expo export --no-bytecode",
11+
"check-types": "tsc --noEmit"
1112
},
1213
"dependencies": {
1314
"@formbricks/react-native": "workspace:*",
14-
"@react-native-async-storage/async-storage": "2.2.0",
15-
"expo": "54.0.33",
16-
"expo-status-bar": "3.0.9",
15+
"@react-native-async-storage/async-storage": "3.0.2",
16+
"expo": "55.0.9",
17+
"expo-status-bar": "55.0.4",
1718
"react": "19.2.4",
18-
"react-native": "0.84.0",
19-
"react-native-webview": "13.16.0"
19+
"react-native": "0.84.1",
20+
"react-native-webview": "13.16.1"
2021
},
2122
"devDependencies": {
2223
"@babel/core": "7.29.0",
2324
"@types/react": "19.2.14",
24-
"typescript": "5.9.3"
25+
"typescript": "6.0.2"
2526
},
2627
"private": true
2728
}

apps/playground/src/app.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import { StatusBar } from "expo-status-bar";
2-
import React, { type JSX } from "react";
3-
import { Button, LogBox, StyleSheet, Text, View } from "react-native";
41
import Formbricks, {
52
logout,
63
setAttribute,
@@ -9,6 +6,9 @@ import Formbricks, {
96
setUserId,
107
track,
118
} from "@formbricks/react-native";
9+
import { StatusBar } from "expo-status-bar";
10+
import type { JSX } from "react";
11+
import { Button, LogBox, StyleSheet, Text, View } from "react-native";
1212

1313
LogBox.ignoreAllLogs();
1414

@@ -74,7 +74,7 @@ export default function App(): JSX.Element {
7474
(error: unknown) => {
7575
// eslint-disable-next-line no-console -- logging is allowed in demo apps
7676
console.error("Error setting user attributes:", error);
77-
}
77+
},
7878
);
7979
}}
8080
/>

biome.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.4.9/schema.json",
3+
"vcs": {
4+
"enabled": true,
5+
"clientKind": "git",
6+
"useIgnoreFile": true
7+
},
8+
"files": {
9+
"ignoreUnknown": true,
10+
"includes": [
11+
"**",
12+
"!**/coverage",
13+
"!**/dist",
14+
"!**/.expo",
15+
"!**/node_modules"
16+
]
17+
},
18+
"formatter": {
19+
"enabled": true,
20+
"indentStyle": "space"
21+
},
22+
"linter": {
23+
"enabled": true,
24+
"rules": {
25+
"recommended": true
26+
}
27+
},
28+
"javascript": {
29+
"formatter": {
30+
"quoteStyle": "double",
31+
"semicolons": "always"
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)