Skip to content

Commit 18e63cb

Browse files
committed
feat: initial OpenSocket implementation
- Set up monorepo with pnpm workspaces and Turborepo - Implement core abstractions (IProvider, IChannel, etc.) - Create testing utilities with mock provider - Configure CI/CD with GitHub Actions - Add Release Please for automated releases - Configure NPM publishing workflow - TypeScript strict mode enabled - Bundle size optimized (<11KB)
0 parents  commit 18e63cb

Some content is hidden

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

43 files changed

+8452
-0
lines changed

.eslintrc.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module.exports = {
2+
root: true,
3+
parser: '@typescript-eslint/parser',
4+
parserOptions: {
5+
ecmaVersion: 2020,
6+
sourceType: 'module',
7+
project: './tsconfig.json',
8+
},
9+
env: {
10+
browser: true,
11+
es2020: true,
12+
node: true,
13+
jest: true,
14+
},
15+
extends: [
16+
'eslint:recommended',
17+
'plugin:@typescript-eslint/recommended',
18+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
19+
'plugin:prettier/recommended',
20+
],
21+
plugins: ['@typescript-eslint', 'prettier'],
22+
rules: {
23+
'@typescript-eslint/explicit-function-return-type': 'off',
24+
'@typescript-eslint/explicit-module-boundary-types': 'off',
25+
'@typescript-eslint/no-explicit-any': 'warn',
26+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
27+
'@typescript-eslint/no-non-null-assertion': 'warn',
28+
'@typescript-eslint/consistent-type-imports': [
29+
'error',
30+
{ prefer: 'type-imports' },
31+
],
32+
'prettier/prettier': 'error',
33+
'no-console': ['warn', { allow: ['warn', 'error'] }],
34+
},
35+
ignorePatterns: ['dist', 'node_modules', 'coverage', '*.js', '*.mjs'],
36+
};

.github/workflows/ci.yml

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- 'release/**'
8+
pull_request:
9+
types: [opened, synchronize, reopened]
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
lint:
17+
name: Lint
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- uses: pnpm/action-setup@v2
25+
with:
26+
version: 8
27+
28+
- uses: actions/setup-node@v4
29+
with:
30+
node-version: 20
31+
cache: 'pnpm'
32+
33+
- name: Install dependencies
34+
run: pnpm install --frozen-lockfile
35+
36+
- name: Lint code
37+
run: pnpm lint
38+
39+
- name: Check formatting
40+
run: pnpm format:check
41+
42+
typecheck:
43+
name: Type Check
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v4
47+
with:
48+
fetch-depth: 0
49+
50+
- uses: pnpm/action-setup@v2
51+
with:
52+
version: 8
53+
54+
- uses: actions/setup-node@v4
55+
with:
56+
node-version: 20
57+
cache: 'pnpm'
58+
59+
- name: Install dependencies
60+
run: pnpm install --frozen-lockfile
61+
62+
- name: Build packages
63+
run: pnpm build
64+
65+
- name: Type check
66+
run: pnpm typecheck
67+
68+
test:
69+
name: Test (Node ${{ matrix.node-version }})
70+
runs-on: ubuntu-latest
71+
strategy:
72+
matrix:
73+
node-version: [18, 20, 21]
74+
steps:
75+
- uses: actions/checkout@v4
76+
with:
77+
fetch-depth: 0
78+
79+
- uses: pnpm/action-setup@v2
80+
with:
81+
version: 8
82+
83+
- uses: actions/setup-node@v4
84+
with:
85+
node-version: ${{ matrix.node-version }}
86+
cache: 'pnpm'
87+
88+
- name: Install dependencies
89+
run: pnpm install --frozen-lockfile
90+
91+
- name: Run tests
92+
run: pnpm test:coverage
93+
94+
- name: Upload coverage to Codecov
95+
if: matrix.node-version == 20
96+
uses: codecov/codecov-action@v3
97+
with:
98+
directory: ./coverage
99+
flags: unittests
100+
name: codecov-umbrella
101+
fail_ci_if_error: false
102+
103+
build:
104+
name: Build
105+
runs-on: ubuntu-latest
106+
steps:
107+
- uses: actions/checkout@v4
108+
with:
109+
fetch-depth: 0
110+
111+
- uses: pnpm/action-setup@v2
112+
with:
113+
version: 8
114+
115+
- uses: actions/setup-node@v4
116+
with:
117+
node-version: 20
118+
cache: 'pnpm'
119+
120+
- name: Install dependencies
121+
run: pnpm install --frozen-lockfile
122+
123+
- name: Build packages
124+
run: pnpm build
125+
126+
- name: Check bundle size
127+
run: |
128+
echo "Checking bundle sizes..."
129+
for package in packages/*/dist; do
130+
if [ -d "$package" ]; then
131+
size=$(du -sb "$package" | cut -f1)
132+
gzipped=$(tar -czf - "$package" | wc -c)
133+
echo "$(basename $(dirname $package)): $size bytes ($gzipped bytes gzipped)"
134+
if [ $gzipped -gt 10240 ]; then
135+
echo "Warning: $(basename $(dirname $package)) bundle size exceeds 10KB gzipped!"
136+
fi
137+
fi
138+
done
139+
140+
provider-tests:
141+
name: Provider Compatibility Tests
142+
runs-on: ubuntu-latest
143+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
144+
needs: [build, test]
145+
steps:
146+
- uses: actions/checkout@v4
147+
with:
148+
fetch-depth: 0
149+
150+
- uses: pnpm/action-setup@v2
151+
with:
152+
version: 8
153+
154+
- uses: actions/setup-node@v4
155+
with:
156+
node-version: 20
157+
cache: 'pnpm'
158+
159+
- name: Install dependencies
160+
run: pnpm install --frozen-lockfile
161+
162+
- name: Build packages
163+
run: pnpm build
164+
165+
- name: Run provider tests
166+
run: pnpm test:providers
167+
env:
168+
NODE_ENV: test
169+
continue-on-error: true # Allow provider tests to fail initially
170+
171+
all-checks:
172+
name: All CI Checks
173+
runs-on: ubuntu-latest
174+
needs: [lint, typecheck, test, build]
175+
if: always()
176+
steps:
177+
- name: Check CI Status
178+
run: |
179+
if [[ "${{ needs.lint.result }}" != "success" || \
180+
"${{ needs.typecheck.result }}" != "success" || \
181+
"${{ needs.test.result }}" != "success" || \
182+
"${{ needs.build.result }}" != "success" ]]; then
183+
echo "One or more CI checks failed"
184+
exit 1
185+
fi
186+
echo "All CI checks passed successfully!"

.github/workflows/publish.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Publish
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to publish (leave empty for current version)'
8+
required: false
9+
type: string
10+
tag:
11+
description: 'NPM tag (latest, next, beta, etc.)'
12+
required: false
13+
default: 'latest'
14+
type: string
15+
dry-run:
16+
description: 'Dry run (do not actually publish)'
17+
required: false
18+
default: false
19+
type: boolean
20+
21+
jobs:
22+
publish:
23+
name: Publish to NPM
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- uses: pnpm/action-setup@v2
31+
with:
32+
version: 8
33+
34+
- uses: actions/setup-node@v4
35+
with:
36+
node-version: 20
37+
cache: 'pnpm'
38+
registry-url: 'https://registry.npmjs.org'
39+
40+
- name: Install dependencies
41+
run: pnpm install --frozen-lockfile
42+
43+
- name: Build packages
44+
run: pnpm build
45+
46+
- name: Run tests
47+
run: pnpm test
48+
49+
- name: Set version (if provided)
50+
if: inputs.version != ''
51+
run: |
52+
echo "Setting version to ${{ inputs.version }}"
53+
pnpm changeset version --snapshot ${{ inputs.version }}
54+
55+
- name: Publish packages (Dry Run)
56+
if: inputs.dry-run == true
57+
run: |
58+
echo "=== DRY RUN MODE ==="
59+
pnpm changeset publish --dry-run --tag ${{ inputs.tag }}
60+
env:
61+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
62+
63+
- name: Publish packages
64+
if: inputs.dry-run == false
65+
run: |
66+
echo "Publishing packages with tag: ${{ inputs.tag }}"
67+
pnpm changeset publish --tag ${{ inputs.tag }}
68+
env:
69+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
70+
71+
- name: Create summary
72+
run: |
73+
echo "## 📦 NPM Publish Summary" >> $GITHUB_STEP_SUMMARY
74+
echo "" >> $GITHUB_STEP_SUMMARY
75+
if [[ "${{ inputs.dry-run }}" == "true" ]]; then
76+
echo "🔍 **Mode**: Dry Run" >> $GITHUB_STEP_SUMMARY
77+
else
78+
echo "🚀 **Mode**: Published" >> $GITHUB_STEP_SUMMARY
79+
fi
80+
echo "🏷️ **Tag**: ${{ inputs.tag }}" >> $GITHUB_STEP_SUMMARY
81+
if [[ "${{ inputs.version }}" != "" ]]; then
82+
echo "📌 **Version**: ${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
83+
fi
84+
echo "" >> $GITHUB_STEP_SUMMARY
85+
echo "### Packages" >> $GITHUB_STEP_SUMMARY
86+
echo "" >> $GITHUB_STEP_SUMMARY
87+
for package in packages/*/package.json; do
88+
if [ -f "$package" ]; then
89+
name=$(jq -r .name "$package")
90+
version=$(jq -r .version "$package")
91+
echo "- **$name**: v$version" >> $GITHUB_STEP_SUMMARY
92+
fi
93+
done

0 commit comments

Comments
 (0)