Skip to content

Commit

Permalink
publish(repo): Publish forked rrweb packages to NPM (#20)
Browse files Browse the repository at this point in the history
This patch adds the necessary configuration around our rrweb fork to publish our own `@sentry-internal/rr*` packages. This includes:

- prefixing packages with `@sentry-internal`
- adjusting licences and the readme
- adding a craft config and a version bump script
- adding artifact upload to our build&test GHA
- adding the Sentry create release GHA
  • Loading branch information
Lms24 authored and billyvg committed Jul 29, 2023
1 parent 9d17a71 commit a3f6ed8
Show file tree
Hide file tree
Showing 111 changed files with 699 additions and 238 deletions.
15 changes: 15 additions & 0 deletions .craft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
github:
owner: getsentry
repo: rrweb
changelogPolicy: simple
preReleaseCommand: bash scripts/craft-pre-release.sh
requireNames:
- /^sentry-internal-rrweb-snapshot-.*\.tgz$/
- /^sentry-internal-rrweb-player-.*\.tgz$/
- /^sentry-internal-rrweb-.*\.tgz$/
- /^sentry-internal-rrdom-.*\.tgz$/
targets:
- name: github
includeNames: /^sentry-.*.tgz$/
- name: npm
includeNames: /^sentry-.*.tgz$/
37 changes: 34 additions & 3 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
name: Tests
name: Build & Tests

on: [push, pull_request]
on:
push:
branches:
- master
- release/**
pull_request:

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
job_test:
name: Tests
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -39,3 +44,29 @@ jobs:
name: image-diff
path: packages/rrweb/test/e2e/__image_snapshots__/__diff_output__/*.png
if-no-files-found: ignore

job_artifacts:
needs: job_test
name: Upload Artifacts
runs-on: ubuntu-latest
# Build artifacts are only needed for releasing workflow.
if: startsWith(github.ref, 'refs/heads/release/')
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Set up Node
uses: volta-cli/action@v3

- name: Install Dependencies
run: yarn --frozen-lockfile

- name: Build Tarballs
run: yarn build:tarball

- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}
path: |
${{ github.workspace }}/packages/**/*.tgz
55 changes: 23 additions & 32 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,30 @@
name: Release

name: Prepare Release
on:
push:
branches:
- master

concurrency: ${{ github.workflow }}-${{ github.ref }}

workflow_dispatch:
inputs:
version:
description: Version to release
required: true
force:
description: Force a release even when there are release-blockers (optional)
required: false
merge_target:
description: Target branch to merge into. Uses the default branch, sentry-v1, as a fallback (optional)
required: false
jobs:
release:
name: Release
runs-on: ubuntu-latest
name: 'Release a new version'
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Setup Node.js lts/*
uses: actions/setup-node@v3
- uses: actions/checkout@v3
with:
node-version: lts/*

- name: Install Dependencies
run: yarn

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: yarn run release
token: ${{ secrets.GH_RELEASE_PAT }}
fetch-depth: 0
- name: Prepare release
uses: getsentry/action-prepare-release@v1
env:
NODE_OPTIONS: "--max-old-space-size=4096"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

# - name: Send a Slack notification if a publish happens
# if: steps.changesets.outputs.published == 'true'
# # You can do something when a publish happens.
# run: my-slack-bot send-notification --message "A new version of ${GITHUB_REPOSITORY} was published!"
GITHUB_TOKEN: ${{ secrets.GH_RELEASE_PAT }}
with:
version: ${{ github.event.inputs.version }}
force: ${{ github.event.inputs.force }}
merge_target: ${{ github.event.inputs.merge_target }}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
This project is forked from rrweb-io/rrweb (https://github.com/rrweb-io/rrweb) under the MIT license:

MIT License

Copyright (c) 2018 Contributors (https://github.com/rrweb-io/rrweb/graphs/contributors) and SmartX Inc.
Expand All @@ -19,3 +21,22 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Our modifications to this project are also released under the MIT license:

Copyright (c) 2023 Functional Software, Inc. dba Sentry

Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
<p align="center">
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
<img src="https://sentry-brand.storage.googleapis.com/sentry-wordmark-dark-280x84.png" alt="Sentry" width="280" height="84">
</a>
</p>

# Sentry rrweb Fork

This repo is a fork of [rrweb](https://github.com/rrweb-io/rrweb). The purpose is to apply patches and bugfixes to rrweb and release Sentry-internal packages with our patches included. All credits and attribution for rrweb go to the original creators of the library and all its contributors.

From this monorepo, Sentry maintains and publishes the following NPM packages:

- `@sentry-internal/rrweb` (corresponds to the [original `rrweb` package](https://www.npmjs.com/package/rrweb))
- `@sentry-internal/rrdom` (corresponds to the [original `rrdom` package](https://www.npmjs.com/package/rrdom))
- `@sentry-internal/rrweb-player` (corresponds to the [original `rrweb-player` package](https://www.npmjs.com/package/rrweb-player))
- `@sentry-internal/rrweb-snapshot` (corresponds to the [original `rrweb-snapshot` package](https://www.npmjs.com/package/rrweb-snapshot))

# rrweb

<p align="center">
<img width="100px" height="100px" src="https://www.rrweb.io/favicon.png">
</p>
<p align="center">
<a href="https://www.rrweb.io/" style="font-weight: bold">Try rrweb</a>
<a href="https://github.com/rrweb-io/rrweb" style="font-weight: bold">Check out the original rrweb Repo</a>
</p>
<p align="center">
<a href="https://rrweb.io" style="font-weight: bold">rrweb.io</a>
</p>

# rrweb
Expand Down
4 changes: 2 additions & 2 deletions packages/rrdom-nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"cssom": "^0.5.0",
"cssstyle": "^2.3.0",
"nwsapi": "^2.2.0",
"rrdom": "^2.0.0-alpha.9",
"rrweb-snapshot": "^2.0.0-alpha.9"
"@sentry-internal/rrdom": "^2.0.0-alpha.9",
"@sentry-internal/rrweb-snapshot": "^2.0.0-alpha.9"
},
"browserslist": [
"supports es6-class"
Expand Down
4 changes: 2 additions & 2 deletions packages/rrdom-nodejs/src/document-nodejs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { NodeType as RRNodeType } from 'rrweb-snapshot';
import { NodeType as RRNodeType } from '@sentry-internal/rrweb-snapshot';
import type { NWSAPI } from 'nwsapi';
import type { CSSStyleDeclaration as CSSStyleDeclarationType } from 'cssstyle';
import {
Expand All @@ -14,7 +14,7 @@ import {
ClassList,
IRRDocument,
CSSStyleDeclaration,
} from 'rrdom';
} from '@sentry-internal/rrdom';
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
const nwsapi = require('nwsapi');
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
Expand Down
4 changes: 2 additions & 2 deletions packages/rrdom-nodejs/test/document-nodejs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import * as fs from 'fs';
import * as path from 'path';
import { NodeType as RRNodeType } from 'rrweb-snapshot';
import { NodeType as RRNodeType } from '@sentry-internal/rrweb-snapshot';
import {
RRCanvasElement,
RRCDATASection,
Expand All @@ -16,7 +16,7 @@ import {
RRStyleElement,
RRText,
} from '../src/document-nodejs';
import { buildFromDom } from 'rrdom';
import { buildFromDom } from '@sentry-internal/rrdom';

describe('RRDocument for nodejs environment', () => {
describe('RRDocument API', () => {
Expand Down
9 changes: 7 additions & 2 deletions packages/rrdom-nodejs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@
"sourceMap": true,
"rootDir": "src",
"outDir": "build",
"lib": ["es6", "dom"],
"lib": [
"es6",
"dom"
],
"skipLibCheck": true,
"declaration": true,
"importsNotUsedAsValues": "error"
},
"compileOnSave": true,
"exclude": ["test"],
"exclude": [
"test"
],
"include": [
"src",
"test.d.ts",
Expand Down
42 changes: 42 additions & 0 deletions packages/rrdom/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
This project is forked from rrweb-io/rrweb (https://github.com/rrweb-io/rrweb) under the MIT license:

MIT License

Copyright (c) 2018 Contributors (https://github.com/rrweb-io/rrweb/graphs/contributors) and SmartX Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Our modifications to this project are also released under the MIT license:

Copyright (c) 2023 Functional Software, Inc. dba Sentry

Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7 changes: 4 additions & 3 deletions packages/rrdom/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "rrdom",
"name": "@sentry-internal/rrdom",
"version": "2.0.0-alpha.9",
"homepage": "https://github.com/rrweb-io/rrweb/tree/main/packages/rrdom#readme",
"license": "MIT",
Expand All @@ -20,6 +20,7 @@
},
"scripts": {
"dev": "rollup -c -w",
"build:tarball": "npm pack",
"bundle": "rollup --config",
"bundle:es-only": "cross-env ES_ONLY=true rollup --config",
"check-types": "tsc -noEmit",
Expand All @@ -32,7 +33,7 @@
},
"devDependencies": {
"@rollup/plugin-commonjs": "^20.0.0",
"@rrweb/types": "^2.0.0-alpha.9",
"@sentry-internal/rrweb-types": "^2.0.0-alpha.9",
"@types/jest": "^27.4.1",
"@types/puppeteer": "^5.4.4",
"@typescript-eslint/eslint-plugin": "^5.23.0",
Expand All @@ -47,6 +48,6 @@
"ts-jest": "^27.1.3"
},
"dependencies": {
"rrweb-snapshot": "^2.0.0-alpha.9"
"@sentry-internal/rrweb-snapshot": "^2.0.0-alpha.9"
}
}
2 changes: 2 additions & 0 deletions packages/rrdom/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ for (let config of baseConfigs) {
name: config.name,
format: 'iife',
file: pkg.unpkg.replace(pkg.name, config.path),
extend: true,
},
],
},
Expand All @@ -67,6 +68,7 @@ for (let config of baseConfigs) {
format: 'iife',
file: toMinPath(pkg.unpkg).replace(pkg.name, config.path),
sourcemap: true,
extend: true,
},
],
},
Expand Down
4 changes: 2 additions & 2 deletions packages/rrdom/src/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import {
NodeType as RRNodeType,
Mirror as NodeMirror,
elementNode,
} from 'rrweb-snapshot';
} from '@sentry-internal/rrweb-snapshot';
import type {
canvasMutationData,
canvasEventWithTime,
inputData,
scrollData,
styleDeclarationData,
styleSheetRuleData,
} from '@rrweb/types';
} from '@sentry-internal/rrweb-types';
import type {
IRRCDATASection,
IRRComment,
Expand Down
2 changes: 1 addition & 1 deletion packages/rrdom/src/document.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NodeType as RRNodeType } from 'rrweb-snapshot';
import { NodeType as RRNodeType } from '@sentry-internal/rrweb-snapshot';
import { parseCSSText, camelize, toCSSText } from './style';
export interface IRRNode {
parentElement: IRRNode | null;
Expand Down
6 changes: 3 additions & 3 deletions packages/rrdom/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import {
NodeType as RRNodeType,
createMirror as createNodeMirror,
} from 'rrweb-snapshot';
} from '@sentry-internal/rrweb-snapshot';
import type {
Mirror as NodeMirror,
IMirror,
serializedNodeWithId,
} from 'rrweb-snapshot';
} from '@sentry-internal/rrweb-snapshot';
import type {
canvasMutationData,
canvasEventWithTime,
inputData,
scrollData,
styleSheetRuleData,
styleDeclarationData,
} from '@rrweb/types';
} from '@sentry-internal/rrweb-types';
import {
BaseRRNode as RRNode,
BaseRRCDATASectionImpl,
Expand Down
Loading

0 comments on commit a3f6ed8

Please sign in to comment.