Compare commits

...
Sign in to create a new pull request.

7 commits
main ... pnpm

Author SHA1 Message Date
nick-delirium
9799280399
workflows 2024-10-11 16:41:50 +02:00
nick-delirium
fc28e2efd9
workflows 2024-10-11 16:35:14 +02:00
nick-delirium
c8ebfb14f1
workflows 2024-10-11 16:31:34 +02:00
nick-delirium
c09c608bbb
workflows 2024-10-11 16:27:25 +02:00
nick-delirium
520e75ba53
fix error with tests 2024-10-11 16:22:05 +02:00
nick-delirium
de3d7784c0
fix error with tests 2024-10-11 16:20:53 +02:00
nick-delirium
db7f5f1166
move ui to pnpm stuff 2024-10-11 16:17:09 +02:00
25 changed files with 23310 additions and 28617 deletions

View file

@ -9,14 +9,23 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - uses: oven-sh/setup-bun@v2
uses: actions/checkout@v2
- name: Cache node modules
uses: actions/cache@v1
with: with:
path: node_modules bun-version: latest
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }} - name: Checkout
uses: actions/checkout@v3
- uses: pnpm/action-setup@v4
with:
version: 9
- name: Cache node_modules
uses: actions/cache@v3
with:
path: |
node_modules
~/.pnpm-store
key: ${{ runner.OS }}-build-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: | restore-keys: |
${{ runner.OS }}-build- ${{ runner.OS }}-build-
${{ runner.OS }}- ${{ runner.OS }}-
@ -52,7 +61,7 @@ jobs:
set -x set -x
cd frontend cd frontend
mv .env.sample .env mv .env.sample .env
docker run --rm -v /etc/passwd:/etc/passwd -u `id -u`:`id -g` -v $(pwd):/home/${USER} -w /home/${USER} --name node_build node:14-stretch-slim /bin/bash -c "yarn && yarn build" docker run --rm -v /etc/passwd:/etc/passwd -u `id -u`:`id -g` -v $(pwd):/home/${USER} -w /home/${USER} --name node_build node:20-slim /bin/bash -c "npm i -g pnpm && pnpm i && pnpm build"
# https://github.com/docker/cli/issues/1134#issuecomment-613516912 # https://github.com/docker/cli/issues/1134#issuecomment-613516912
DOCKER_BUILDKIT=1 docker build --target=cicd -t $DOCKER_REPO/frontend:${IMAGE_TAG} . DOCKER_BUILDKIT=1 docker build --target=cicd -t $DOCKER_REPO/frontend:${IMAGE_TAG} .
docker tag $DOCKER_REPO/frontend:${IMAGE_TAG} $DOCKER_REPO/frontend:${IMAGE_TAG}-ee docker tag $DOCKER_REPO/frontend:${IMAGE_TAG} $DOCKER_REPO/frontend:${IMAGE_TAG}-ee

View file

@ -1,4 +1,5 @@
name: Frontend Foss Deployment name: Frontend Foss Deployment
on: on:
workflow_dispatch: workflow_dispatch:
push: push:
@ -6,7 +7,7 @@ on:
- dev - dev
paths: paths:
- frontend/** - frontend/**
# Disable previous workflows for this action.
concurrency: concurrency:
group: ${{ github.workflow }} #-${{ github.ref }} group: ${{ github.workflow }} #-${{ github.ref }}
cancel-in-progress: true cancel-in-progress: true
@ -18,13 +19,17 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- uses: pnpm/action-setup@v4
with:
version: 9
- name: Cache node modules - name: Cache node modules
uses: actions/cache@v4 uses: actions/cache@v4
with: with:
path: | path: |
/home/runner/work/openreplay/openreplay/frontend/node_modules /home/runner/work/openreplay/openreplay/frontend/node_modules
/home/runner/work/openreplay/openreplay/frontend/.yarn /home/runner/.pnpm-store
key: ${{ runner.OS }}-build-${{ hashFiles('frontend/yarn.lock') }} key: ${{ runner.OS }}-build-${{ hashFiles('frontend/pnpm-lock.yaml') }}
restore-keys: | restore-keys: |
${{ runner.OS }}-build- ${{ runner.OS }}-build-
${{ runner.OS }}- ${{ runner.OS }}-
@ -47,7 +52,7 @@ jobs:
- uses: azure/k8s-set-context@v1 - uses: azure/k8s-set-context@v1
with: with:
method: kubeconfig method: kubeconfig
kubeconfig: ${{ secrets.OSS_KUBECONFIG }} # Use content of kubeconfig in secret. kubeconfig: ${{ secrets.OSS_KUBECONFIG }}
id: setcontext id: setcontext
- name: Building and Pushing frontend image - name: Building and Pushing frontend image
@ -60,7 +65,7 @@ jobs:
set -x set -x
cd frontend cd frontend
mv .env.sample .env mv .env.sample .env
docker run --rm -v /etc/passwd:/etc/passwd -u `id -u`:`id -g` -v $(pwd):/home/${USER} -w /home/${USER} --name node_build node:18-slim /bin/bash -c "yarn && yarn build" docker run --rm -v /etc/passwd:/etc/passwd -u `id -u`:`id -g` -v $(pwd):/home/${USER} -w /home/${USER} --name node_build node:20-slim /bin/bash -c "npm i -g pnpm && pnpm i && bun run build"
# https://github.com/docker/cli/issues/1134#issuecomment-613516912 # https://github.com/docker/cli/issues/1134#issuecomment-613516912
DOCKER_BUILDKIT=1 docker build --target=cicd -t $DOCKER_REPO/frontend:${IMAGE_TAG} . DOCKER_BUILDKIT=1 docker build --target=cicd -t $DOCKER_REPO/frontend:${IMAGE_TAG} .
docker tag $DOCKER_REPO/frontend:${IMAGE_TAG} $DOCKER_REPO/frontend:${IMAGE_TAG}-ee docker tag $DOCKER_REPO/frontend:${IMAGE_TAG} $DOCKER_REPO/frontend:${IMAGE_TAG}-ee
@ -85,7 +90,7 @@ jobs:
# Deploy command # Deploy command
mkdir -p /tmp/charts mkdir -p /tmp/charts
mv openreplay/charts/{ingress-nginx,frontend,quickwit,connector} /tmp/charts/ mv openreplay/charts/{ingress-nginx,frontend,quickwit,connector} /tmp/charts/
rm -rf openreplay/charts/* rm -rf openreplay/charts/*
mv /tmp/charts/* openreplay/charts/ mv /tmp/charts/* openreplay/charts/
helm template openreplay -n app openreplay -f vars.yaml -f /tmp/image_override.yaml --set ingress-nginx.enabled=false --set skipMigration=true --no-hooks | kubectl apply -n app -f - helm template openreplay -n app openreplay -f vars.yaml -f /tmp/image_override.yaml --set ingress-nginx.enabled=false --set skipMigration=true --no-hooks | kubectl apply -n app -f -
env: env:
@ -93,12 +98,10 @@ jobs:
IMAGE_TAG: ${{ github.ref_name }}_${{ github.sha }} IMAGE_TAG: ${{ github.ref_name }}_${{ github.sha }}
ENVIRONMENT: staging ENVIRONMENT: staging
### Enterprise code deployment
- uses: azure/k8s-set-context@v1 - uses: azure/k8s-set-context@v1
with: with:
method: kubeconfig method: kubeconfig
kubeconfig: ${{ secrets.EE_KUBECONFIG }} # Use content of kubeconfig in secret. kubeconfig: ${{ secrets.EE_KUBECONFIG }}
id: setcontextee id: setcontextee
- uses: ./.github/composite-actions/update-keys - uses: ./.github/composite-actions/update-keys
@ -129,7 +132,7 @@ jobs:
# Deploy command # Deploy command
mkdir -p /tmp/charts mkdir -p /tmp/charts
mv openreplay/charts/{ingress-nginx,frontend,quickwit,connector} /tmp/charts/ mv openreplay/charts/{ingress-nginx,frontend,quickwit,connector} /tmp/charts/
rm -rf openreplay/charts/* rm -rf openreplay/charts/*
mv /tmp/charts/* openreplay/charts/ mv /tmp/charts/* openreplay/charts/
helm template openreplay -n app openreplay -f vars.yaml -f /tmp/image_override.yaml --set ingress-nginx.enabled=false --set skipMigration=true --no-hooks | kubectl apply -n app -f - helm template openreplay -n app openreplay -f vars.yaml -f /tmp/image_override.yaml --set ingress-nginx.enabled=false --set skipMigration=true --no-hooks | kubectl apply -n app -f -
env: env:
@ -137,13 +140,3 @@ jobs:
# We're not passing -ee flag, because helm will add that. # We're not passing -ee flag, because helm will add that.
IMAGE_TAG: ${{ github.ref_name }}_${{ github.sha }} IMAGE_TAG: ${{ github.ref_name }}_${{ github.sha }}
ENVIRONMENT: staging ENVIRONMENT: staging
# - name: Debug Job
# # if: ${{ failure() }}
# uses: mxschmitt/action-tmate@v3
# env:
# DOCKER_REPO: ${{ secrets.EE_REGISTRY_URL }}
# IMAGE_TAG: ${{ github.sha }}-ee
# ENVIRONMENT: staging
# with:
# iimit-access-to-actor: true

View file

@ -1,5 +1,5 @@
# Checking unit tests for tracker and assist
name: Tracker tests name: Tracker tests
on: on:
workflow_dispatch: workflow_dispatch:
push: push:
@ -10,58 +10,81 @@ on:
branches: [ "dev", "main" ] branches: [ "dev", "main" ]
paths: paths:
- tracker/** - tracker/**
jobs: jobs:
build-and-test: build-and-test:
runs-on: macos-latest runs-on: macos-latest
name: Build and test Tracker name: Build and test Tracker
steps: steps:
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: oven-sh/setup-bun@v2 - uses: oven-sh/setup-bun@v2
with: with:
bun-version: latest bun-version: latest
- uses: actions/checkout@v3 - uses: actions/checkout@v3
# Cache tracker node_modules
- name: Cache tracker modules - name: Cache tracker modules
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: tracker/tracker/node_modules path: tracker/tracker/node_modules
key: ${{ runner.OS }}-test_tracker_build-${{ hashFiles('**/bun.lockb') }} key: ${{ runner.OS }}-test_tracker_build-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: | restore-keys: |
test_tracker_build{{ runner.OS }}-build- test_tracker_build{{ runner.OS }}-build-
test_tracker_build{{ runner.OS }}- test_tracker_build{{ runner.OS }}-
# Cache tracker-assist node_modules
- name: Cache tracker-assist modules - name: Cache tracker-assist modules
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: tracker/tracker-assist/node_modules path: tracker/tracker-assist/node_modules
key: ${{ runner.OS }}-test_tracker_build-${{ hashFiles('**/bun.lockb') }} key: ${{ runner.OS }}-test_tracker_build-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: | restore-keys: |
test_tracker_build{{ runner.OS }}-build- test_tracker_build{{ runner.OS }}-build-
test_tracker_build{{ runner.OS }}- test_tracker_build{{ runner.OS }}-
- name: Setup Testing packages
# Setup testing packages for Tracker
- name: Setup Testing packages for Tracker
run: | run: |
cd tracker/tracker cd tracker/tracker
bun install pnpm install
- name: Jest tests
# Run Jest tests for Tracker
- name: Jest tests for Tracker
run: | run: |
cd tracker/tracker cd tracker/tracker
bun run test:ci bun run test:ci
- name: Building test
# Build Tracker project
- name: Build Tracker
run: | run: |
cd tracker/tracker cd tracker/tracker
bun run build bun run build
- name: (TA) Setup Testing packages
# Setup testing packages for Tracker Assist
- name: (TA) Setup Testing packages for Tracker Assist
run: | run: |
cd tracker/tracker-assist cd tracker/tracker-assist
bun install pnpm install
- name: (TA) Jest tests
# Run Jest tests for Tracker Assist
- name: (TA) Jest tests for Tracker Assist
run: | run: |
cd tracker/tracker-assist cd tracker/tracker-assist
bun run test:ci bun run test:ci
- name: (TA) Building test
# Build Tracker Assist project
- name: (TA) Build Tracker Assist
run: | run: |
cd tracker/tracker-assist cd tracker/tracker-assist
bun run build bun run build
# Upload coverage reports to Codecov
- name: Upload coverage reports to Codecov - name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v3
with: with:
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}
flags: tracker flags: tracker
iame: tracker name: tracker

View file

@ -1,18 +1,18 @@
# Checking unit and visual tests locally on every merge rq to dev and main
name: Frontend tests name: Frontend tests
on: on:
workflow_dispatch: workflow_dispatch:
push: push:
branches: [ "main" ] branches: ["main"]
paths: paths:
- frontend/** - frontend/**
- tracker/** - tracker/**
pull_request: pull_request:
branches: [ "dev", "main" ] branches: ["dev", "main"]
paths: paths:
- frontend/** - frontend/**
- tracker/** - tracker/**
env: env:
API: ${{ secrets.E2E_API_ORIGIN }} API: ${{ secrets.E2E_API_ORIGIN }}
ASSETS: ${{ secrets.E2E_ASSETS_ORIGIN }} ASSETS: ${{ secrets.E2E_ASSETS_ORIGIN }}
@ -21,63 +21,78 @@ env:
CY_PASS: ${{ secrets.CYPRESS_PASSWORD }} CY_PASS: ${{ secrets.CYPRESS_PASSWORD }}
FOSS_PROJECT_KEY: ${{ secrets.FOSS_PROJECT_KEY }} FOSS_PROJECT_KEY: ${{ secrets.FOSS_PROJECT_KEY }}
FOSS_INGEST: ${{ secrets.FOSS_INGEST }} FOSS_INGEST: ${{ secrets.FOSS_INGEST }}
jobs: jobs:
build-and-test: build-and-test:
runs-on: macos-latest runs-on: macos-latest
name: Build and test Tracker plus Replayer name: Build and test Tracker plus Replayer
strategy: strategy:
matrix: matrix:
node-version: [ 18.x ] node-version: [18.x]
steps: steps:
- uses: oven-sh/setup-bun@v2 - uses: oven-sh/setup-bun@v2
with: with:
bun-version: latest bun-version: latest
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }} - name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
- name: Cache tracker modules
# Cache pnpm node modules for Tracker
- name: Cache tracker node_modules
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: tracker/tracker/node_modules path: tracker/tracker/node_modules
key: ${{ runner.OS }}-test_tracker_build-${{ hashFiles('tracker/tracker/bun.lockb') }} key: ${{ runner.OS }}-test_tracker_build-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: | restore-keys: |
test_tracker_build-{{ runner.OS }}-build- test_tracker_build-{{ runner.OS }}-build-
test_tracker_build-{{ runner.OS }}- test_tracker_build-{{ runner.OS }}-
- name: Setup Testing packages
# Install dependencies for Tracker
- name: Setup Testing packages for Tracker
run: | run: |
cd tracker/tracker cd tracker/tracker
bun install pnpm install
- name: Build tracker inst - name: Build tracker inst
run: | run: |
cd tracker/tracker cd tracker/tracker
bun run build bun run build
- name: Setup Testing UI Env
run: | # Cache pnpm node_modules for Testing UI
cd tracker/tracker-testing-playground
echo "REACT_APP_KEY=$FOSS_PROJECT_KEY" >> .env
echo "REACT_APP_INGEST=$FOSS_INGEST" >> .env
- name: Cache testing UI node modules - name: Cache testing UI node modules
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: tracker/tracker-testing-playground/node_modules path: tracker/tracker-testing-playground/node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('**/yarn.lock') }} key: ${{ runner.OS }}-build-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: | restore-keys: |
${{ runner.OS }}-build- ${{ runner.OS }}-build-
${{ runner.OS }}- ${{ runner.OS }}-
- name: Setup Testing packages
# Install dependencies for Testing UI
- name: Setup Testing packages for Testing UI
run: | run: |
cd tracker/tracker-testing-playground cd tracker/tracker-testing-playground
yarn pnpm install
- name: Cache node modules
# Cache pnpm node_modules for Frontend
- name: Cache frontend node_modules
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
path: frontend/node_modules path: frontend/node_modules
key: ${{ runner.OS }}-build-${{ hashFiles('frontend/yarn.lock') }} key: ${{ runner.OS }}-build-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: | restore-keys: |
${{ runner.OS }}-build- ${{ runner.OS }}-build-
${{ runner.OS }}- ${{ runner.OS }}-
# Set up environment for Frontend
- name: Setup env - name: Setup env
run: | run: |
cd frontend cd frontend
@ -86,37 +101,45 @@ jobs:
echo "ORIGIN=$API" >> .env echo "ORIGIN=$API" >> .env
echo "ASSETS_HOST=$ASSETS" >> .env echo "ASSETS_HOST=$ASSETS" >> .env
echo "API_EDP=$APIEDP" >> .env echo "API_EDP=$APIEDP" >> .env
echo "SENTRY_ENABLED = false" >> .env echo "SENTRY_ENABLED=false" >> .env
echo "SENTRY_URL = ''" >> .env echo "SENTRY_URL=''" >> .env
echo "CAPTCHA_ENABLED = false" >> .env echo "CAPTCHA_ENABLED=false" >> .env
echo "CAPTCHA_SITE_KEY = 'asdad'" >> .env echo "CAPTCHA_SITE_KEY='asdad'" >> .env
echo "MINIO_ENDPOINT = ''" >> .env echo "MINIO_ENDPOINT=''" >> .env
echo "MINIO_PORT = ''" >> .env echo "MINIO_PORT=''" >> .env
echo "MINIO_USE_SSL = ''" >> .env echo "MINIO_USE_SSL=''" >> .env
echo "MINIO_ACCESS_KEY = ''" >> .env echo "MINIO_ACCESS_KEY=''" >> .env
echo "MINIO_SECRET_KEY = ''" >> .env echo "MINIO_SECRET_KEY=''" >> .env
echo "VERSION = '1.15.0'" >> .env echo "VERSION='1.15.0'" >> .env
echo "TRACKER_VERSION = '10.0.0'" >> .env echo "TRACKER_VERSION='10.0.0'" >> .env
echo "COMMIT_HASH = 'dev'" >> .env echo "COMMIT_HASH='dev'" >> .env
echo "{ \"account\": \"$CY_ACC\", \"password\": \"$CY_PASS\" }" >> cypress.env.json echo "{ \"account\": \"$CY_ACC\", \"password\": \"$CY_PASS\" }" >> cypress.env.json
# Install dependencies for Frontend
- name: Setup packages - name: Setup packages
run: | run: |
cd frontend cd frontend
yarn pnpm install
# Run unit tests for Frontend
- name: Run unit tests - name: Run unit tests
run: | run: |
cd frontend cd frontend
yarn test:ci pnpm test:ci
# Upload coverage reports to Codecov
- name: Upload coverage reports to Codecov - name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3 uses: codecov/codecov-action@v3
with: with:
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}
flags: ui flags: ui
name: ui name: ui
# Run Testing frontend with pnpm
- name: Run testing frontend - name: Run testing frontend
run: | run: |
cd tracker/tracker-testing-playground cd tracker/tracker-testing-playground
yarn start &> testing.log & pnpm start &> testing.log &
echo "Started" echo "Started"
npm i -g wait-on npm i -g wait-on
echo "Got wait on" echo "Got wait on"
@ -125,6 +148,8 @@ jobs:
npx wait-on http://localhost:3000 npx wait-on http://localhost:3000
echo "Done" echo "Done"
timeout-minutes: 4 timeout-minutes: 4
# Run frontend with pnpm
- name: Run Frontend - name: Run Frontend
run: | run: |
cd frontend cd frontend
@ -135,21 +160,20 @@ jobs:
npx wait-on http://0.0.0.0:3333 npx wait-on http://0.0.0.0:3333
echo "Done" echo "Done"
timeout-minutes: 4 timeout-minutes: 4
# Run visual tests with pnpm
- name: (Chrome) Run visual tests - name: (Chrome) Run visual tests
run: | run: |
cd frontend cd frontend
yarn cy:test pnpm cy:test
# firefox have different viewport somehow
# - name: (Firefox) Run visual tests
# run: yarn cy:test-firefox
# - name: (Edge) Run visual tests
# run: yarn cy:test-edge
timeout-minutes: 5 timeout-minutes: 5
# Upload Debug Info if tests fail
- name: Upload Debug - name: Upload Debug
if: ${{ failure() }} if: ${{ failure() }}
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: 'Snapshots' name: "Snapshots"
path: | path: |
frontend/cypress/videos frontend/cypress/videos
frontend/cypress/snapshots/replayer.cy.ts frontend/cypress/snapshots/replayer.cy.ts

3
.npmrc Normal file
View file

@ -0,0 +1,3 @@
use-node-version=18.16.0
link-workspace-packages=false
save-workspace-protocol=rolling

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,9 +0,0 @@
nodeLinker: node-modules
compressionLevel: 0
enableGlobalCache: true
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"
yarnPath: .yarn/releases/yarn-3.2.1.cjs

View file

@ -1,31 +1,42 @@
from node:18-slim AS builder FROM oven/bun:1.1.30-slim
workdir /work
WORKDIR /work/frontend
COPY ../pnpm-lock.yaml /work/
COPY . . COPY . .
RUN cp .env.sample .env RUN cp .env.sample .env
RUN yarn
RUN yarn build
FROM nginx:alpine as cicd RUN npm install -g pnpm
LABEL maintainer=Rajesh<rajesh@openreplay.com>
COPY public /var/www/openreplay
COPY nginx.conf /etc/nginx/conf.d/default.conf
RUN pnpm install --filter . --frozen-lockfile --dir /work/frontend
RUN bun run build
FROM nginx:alpine AS cicd
LABEL maintainer="Rajesh<rajesh@openreplay.com>"
COPY --from=builder /work/frontend/public /var/www/openreplay
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
# Default step in docker build
FROM nginx:alpine FROM nginx:alpine
LABEL maintainer=Rajesh<rajesh@openreplay.com> LABEL maintainer="Rajesh<rajesh@openreplay.com>"
ARG GIT_SHA ARG GIT_SHA
LABEL GIT_SHA=$GIT_SHA LABEL GIT_SHA=$GIT_SHA
COPY --from=builder /work/public /var/www/openreplay
COPY nginx.conf /etc/nginx/conf.d/default.conf COPY --from=builder /var/www/openreplay /var/www/openreplay
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
ENV GIT_SHA=$GIT_SHA ENV GIT_SHA=$GIT_SHA
EXPOSE 8080
RUN chown -R nginx:nginx /var/cache/nginx && \ RUN chown -R nginx:nginx /var/cache/nginx && \
chown -R nginx:nginx /var/log/nginx && \ chown -R nginx:nginx /var/log/nginx && \
chown -R nginx:nginx /etc/nginx/conf.d && \ chown -R nginx:nginx /etc/nginx/conf.d && \
touch /var/run/nginx.pid && \ touch /var/run/nginx.pid && \
chown -R nginx:nginx /var/run/nginx.pid chown -R nginx:nginx /var/run/nginx.pid
EXPOSE 8080
USER nginx USER nginx

View file

@ -0,0 +1,177 @@
import { DateTime, Info } from 'luxon';
const weekDayFormatMap = {
zh_CN: 'narrow',
zh_TW: 'narrow',
};
const weekDayLengthMap = {
en_US: 2,
en_GB: 2,
};
/**
* Normalizes part of a moment format string that should
* not be escaped to a luxon compatible format string.
*
* @param part string
* @returns string
*/
const normalizeFormatPart = (part: string): string =>
part
.replace(/Y/g, 'y')
.replace(/D/g, 'd')
.replace(/gg/g, 'kk')
.replace(/Q/g, 'q')
.replace(/([Ww])o/g, 'WW')
.replace(/A/g, 'a');
/**
* Normalizes a moment compatible format string to a luxon compatible format string
*
* @param format string
* @returns string
*/
const normalizeFormat = (format: string): string =>
format
// moment escapes strings contained in brackets
.split(/[[\]]/)
.map((part, index) => {
const shouldEscape = index % 2 > 0;
return shouldEscape ? part : normalizeFormatPart(part);
})
// luxon escapes strings contained in single quotes
.join("'");
/**
* Normalizes language tags used to luxon compatible
* language tags by replacing underscores with hyphen-minus.
*
* @param locale string
* @returns string
*/
const normalizeLocale = (locale: string): string => locale.replace(/_/g, '-');
const generateConfig: GenerateConfig<DateTime> = {
// get
getNow: () => DateTime.local(),
getFixedDate: (string) => DateTime.fromFormat(string, 'yyyy-MM-dd'),
getEndDate: (date) => date.endOf('month'),
getWeekDay: (date) => date.weekday,
getYear: (date) => date.year,
getMonth: (date) => date.month - 1, // getMonth should return 0-11, luxon month returns 1-12
getDate: (date) => date.day,
getHour: (date) => date.hour,
getMinute: (date) => date.minute,
getSecond: (date) => date.second,
getMillisecond: (date) => date.millisecond,
// set
addYear: (date, diff) => date.plus({ year: diff }),
addMonth: (date, diff) => date.plus({ month: diff }),
addDate: (date, diff) => date.plus({ day: diff }),
setYear: (date, year) => date.set({ year }),
setMonth: (date, month) => date.set({ month: month + 1 }), // setMonth month argument is 0-11, luxon months are 1-12
setDate: (date, day) => date.set({ day }),
setHour: (date, hour) => date.set({ hour }),
setMinute: (date, minute) => date.set({ minute }),
setSecond: (date, second) => date.set({ second }),
setMillisecond: (date, milliseconds) => date.set({ millisecond: milliseconds }),
// Compare
isAfter: (date1, date2) => date1 > date2,
isValidate: (date) => date.isValid,
locale: {
getWeekFirstDate: (locale, date) => date.setLocale(normalizeLocale(locale)).startOf('week'),
getWeekFirstDay: (locale) =>
DateTime.local().setLocale(normalizeLocale(locale)).startOf('week').weekday,
getWeek: (locale, date) => date.setLocale(normalizeLocale(locale)).weekNumber,
getShortWeekDays: (locale) => {
const weekdays = Info.weekdays(weekDayFormatMap[locale] || 'short', {
locale: normalizeLocale(locale),
});
const shifted = weekdays.map((weekday) => weekday.slice(0, weekDayLengthMap[locale]));
// getShortWeekDays should return weekday labels starting from Sunday.
// luxon returns them starting from Monday, so we have to shift the results.
shifted.unshift(shifted.pop() as string);
return shifted;
},
getShortMonths: (locale) => Info.months('short', { locale: normalizeLocale(locale) }),
format: (locale, date, format) => {
if (!date || !date.isValid) {
return null;
}
return date.setLocale(normalizeLocale(locale)).toFormat(normalizeFormat(format));
},
parse: (locale, text, formats) => {
for (let i = 0; i < formats.length; i += 1) {
const normalizedFormat = normalizeFormat(formats[i]);
const date = DateTime.fromFormat(text, normalizedFormat, {
locale: normalizeLocale(locale),
});
if (date.isValid) {
return date;
}
}
return null;
},
},
};
export type GenerateConfig<DateType> = {
// Get
getWeekDay: (value: DateType) => number;
getMillisecond: (value: DateType) => number;
getSecond: (value: DateType) => number;
getMinute: (value: DateType) => number;
getHour: (value: DateType) => number;
getDate: (value: DateType) => number;
getMonth: (value: DateType) => number;
getYear: (value: DateType) => number;
getNow: () => DateType;
getFixedDate: (fixed: string) => DateType;
getEndDate: (value: DateType) => DateType;
// Set
addYear: (value: DateType, diff: number) => DateType;
addMonth: (value: DateType, diff: number) => DateType;
addDate: (value: DateType, diff: number) => DateType;
setYear: (value: DateType, year: number) => DateType;
setMonth: (value: DateType, month: number) => DateType;
setDate: (value: DateType, date: number) => DateType;
setHour: (value: DateType, hour: number) => DateType;
setMinute: (value: DateType, minute: number) => DateType;
setSecond: (value: DateType, second: number) => DateType;
setMillisecond: (value: DateType, millisecond: number) => DateType;
// Compare
isAfter: (date1: DateType, date2: DateType) => boolean;
isValidate: (date: DateType) => boolean;
locale: {
getWeekFirstDay: (locale: string) => number;
getWeekFirstDate: (locale: string, value: DateType) => DateType;
getWeek: (locale: string, value: DateType) => number;
format: (locale: string, date: DateType, format: string) => string;
/** Should only return validate date instance */
parse: (locale: string, text: string, formats: string[]) => DateType | null;
/** A proxy for getting locale with moment or other locale library */
getShortWeekDays?: (locale: string) => string[];
/** A proxy for getting locale with moment or other locale library */
getShortMonths?: (locale: string) => string[];
};
};
export default generateConfig;

View file

@ -2,7 +2,7 @@
import { DatePicker } from 'antd'; import { DatePicker } from 'antd';
import { PickerTimeProps } from 'antd/es/time-picker'; import { PickerTimeProps } from 'antd/es/time-picker';
import React from 'react'; import React from 'react';
import luxonGenerateConfig from 'rc-picker/lib/generate/luxon'; import luxonGenerateConfig from './config';
const CustomPicker = DatePicker.generatePicker<DateTime>(luxonGenerateConfig); const CustomPicker = DatePicker.generatePicker<DateTime>(luxonGenerateConfig);

View file

@ -4,9 +4,9 @@
"license": "Apache-2.0", "license": "Apache-2.0",
"scripts": { "scripts": {
"start": "webpack serve", "start": "webpack serve",
"build": "yarn gen:icons && yarn gen:colors && rm -rf public && webpack", "build": "pnpm gen:icons && pnpm gen:colors && rm -rf public && webpack",
"upload:minio": "node ./scripts/upload-minio.js", "upload:minio": "node ./scripts/upload-minio.js",
"deploy:minio": "yarn build:minio && yarn upload:minio", "deploy:minio": "pnpm build:minio && pnpm upload:minio",
"lint": "eslint --fix app; exit 0", "lint": "eslint --fix app; exit 0",
"tsc": "tsc --noEmit --w --incremental false", "tsc": "tsc --noEmit --w --incremental false",
"gen:constants": "node ./scripts/constants.js", "gen:constants": "node ./scripts/constants.js",
@ -14,7 +14,7 @@
"gen:colors": "node ./scripts/colors.js", "gen:colors": "node ./scripts/colors.js",
"storybook": "start-storybook -p 6006", "storybook": "start-storybook -p 6006",
"flow": "flow", "flow": "flow",
"gen:static": "yarn gen:icons && yarn gen:colors", "gen:static": "pnpm gen:icons && pnpm gen:colors",
"build-storybook": "build-storybook", "build-storybook": "build-storybook",
"test:ci": "jest --maxWorkers=1 --no-cache --coverage", "test:ci": "jest --maxWorkers=1 --no-cache --coverage",
"test": "jest --watch", "test": "jest --watch",
@ -59,6 +59,7 @@
"prismjs": "^1.29.0", "prismjs": "^1.29.0",
"rc-time-picker": "^3.7.3", "rc-time-picker": "^3.7.3",
"react": "^18.2.0", "react": "^18.2.0",
"react-calendar": "^5.0.0",
"react-confirm": "^0.3.0-7", "react-confirm": "^0.3.0-7",
"react-daterange-picker": "^2.0.1", "react-daterange-picker": "^2.0.1",
"react-dnd": "^16.0.1", "react-dnd": "^16.0.1",
@ -160,6 +161,5 @@
}, },
"engines": { "engines": {
"node": ">=10.14.1" "node": ">=10.14.1"
}, }
"packageManager": "yarn@3.2.1"
} }

File diff suppressed because it is too large Load diff

View file

@ -1,29 +0,0 @@
{
"name": "network-proxy",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "network-proxy",
"version": "1.0.0",
"license": "ISC",
"devDependencies": {
"typescript": "^5.6.2"
}
},
"node_modules/typescript": {
"version": "5.6.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz",
"integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
}
}
}

File diff suppressed because it is too large Load diff

10
package.json Normal file
View file

@ -0,0 +1,10 @@
{
"name": "or-js-monorepo",
"version": "1.0.0",
"description": "entry file for all things javascript related in openreplay",
"scripts": {
"start-ui": "pnpm --filter openreplay start"
},
"keywords": [],
"author": "Nick <nick.delirium@pm.me>"
}

22952
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load diff

5
pnpm-workspace.yaml Normal file
View file

@ -0,0 +1,5 @@
packages:
- frontend
- 'tracker/tracker/*'
- 'tracker/tracker-assist/*'
- networkProxy

View file

@ -22,7 +22,6 @@
"replace-pkg-version": "sh pkgver.sh", "replace-pkg-version": "sh pkgver.sh",
"replace-req-version": "replace-in-files lib/* cjs/* --string='REQUIRED_TRACKER_VERSION' --replacement='13.0.0'", "replace-req-version": "replace-in-files lib/* cjs/* --string='REQUIRED_TRACKER_VERSION' --replacement='13.0.0'",
"prepublishOnly": "bun run test && bun run build", "prepublishOnly": "bun run test && bun run build",
"lint-front": "lint-staged",
"test": "jest --coverage=false", "test": "jest --coverage=false",
"test:ci": "jest --coverage=true", "test:ci": "jest --coverage=true",
"postversion": "bun run build" "postversion": "bun run build"
@ -45,15 +44,9 @@
"eslint-plugin-prettier": "^4.2.1", "eslint-plugin-prettier": "^4.2.1",
"jest": "^29.3.1", "jest": "^29.3.1",
"jest-environment-jsdom": "^29.3.1", "jest-environment-jsdom": "^29.3.1",
"lint-staged": "^13.0.3",
"prettier": "^2.7.1", "prettier": "^2.7.1",
"replace-in-files-cli": "^1.0.0", "replace-in-files-cli": "^1.0.0",
"ts-jest": "^29.0.3", "ts-jest": "^29.0.3",
"typescript": "^4.6.0-dev.20211126" "typescript": "^4.6.0-dev.20211126"
},
"lint-staged": {
"*.{js,mjs,cjs,jsx,ts,tsx}": [
"eslint --fix --quiet"
]
} }
} }

Binary file not shown.

View file

@ -21,7 +21,6 @@
"rollup": "rollup --config rollup.config.js", "rollup": "rollup --config rollup.config.js",
"compile": "node --experimental-modules --experimental-json-modules scripts/compile.cjs", "compile": "node --experimental-modules --experimental-json-modules scripts/compile.cjs",
"build": "bun run clean && bun run tscRun && bun run rollup && bun run compile", "build": "bun run clean && bun run tscRun && bun run rollup && bun run compile",
"lint-front": "lint-staged",
"test": "jest --coverage=false", "test": "jest --coverage=false",
"test:ci": "jest --coverage=true", "test:ci": "jest --coverage=true",
"postversion": "bun run build", "postversion": "bun run build",
@ -39,7 +38,6 @@
"eslint-plugin-prettier": "^5.0.1", "eslint-plugin-prettier": "^5.0.1",
"jest": "^29.3.1", "jest": "^29.3.1",
"jest-environment-jsdom": "^29.3.1", "jest-environment-jsdom": "^29.3.1",
"lint-staged": "^13.0.3",
"prettier": "^3.0.3", "prettier": "^3.0.3",
"replace-in-files": "^2.0.3", "replace-in-files": "^2.0.3",
"rollup": "^4.1.4", "rollup": "^4.1.4",
@ -57,13 +55,5 @@
}, },
"engines": { "engines": {
"node": ">=14.0" "node": ">=14.0"
},
"lint-staged": {
"*.{js,mjs,jsx,ts,tsx}": [
"eslint --fix --quiet"
],
"*.{json,md,html,js,jsx,ts,tsx}": [
"prettier --write"
]
} }
} }

View file

@ -20,7 +20,7 @@ interface Options {
class CanvasRecorder { class CanvasRecorder {
private snapshots: Record<number, CanvasSnapshot> = {} private snapshots: Record<number, CanvasSnapshot> = {}
private readonly intervals: NodeJS.Timeout[] = [] private readonly intervals: ReturnType<typeof setInterval>[] = []
private readonly interval: number private readonly interval: number
private readonly fileExt: 'webp' | 'png' | 'jpeg' | 'avif' private readonly fileExt: 'webp' | 'png' | 'jpeg' | 'avif'

View file

@ -136,7 +136,7 @@ export default function (app: App, options?: MouseHandlerOptions): void {
let direction = 0 let direction = 0
let directionChangeCount = 0 let directionChangeCount = 0
let distance = 0 let distance = 0
let checkIntervalId: NodeJS.Timer let checkIntervalId: ReturnType<typeof setInterval> | null = null
const shakeThreshold = 0.008 const shakeThreshold = 0.008
const shakeCheckInterval = 225 const shakeCheckInterval = 225

View file

@ -1,7 +1,7 @@
{ {
"extends": "../../tsconfig-base.json", "extends": "../../tsconfig-base.json",
"compilerOptions": { "compilerOptions": {
"lib": ["es6"] "lib": ["es2016", "webworker"]
}, },
"references": [{ "path": "../common" }] "references": [{ "path": "../common" }]
} }

View file

@ -1,4 +0,0 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1