Skip to content

Commit

Permalink
chore(astro): Add @sentry/astro package (#9187)
Browse files Browse the repository at this point in the history
Add the boilerplate files for the new `@sentry/astro` package. Amongst the usual files, some noteworthy things include:
* Bumped the Volta Node version from 16 to 18 for the entire monorepo.
* Using Vitest instead of Jest, like we do in SvelteKit. 

ref #9182
  • Loading branch information
Lms24 authored Oct 6, 2023
1 parent 945d873 commit 4236181
Show file tree
Hide file tree
Showing 18 changed files with 2,510 additions and 23 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@
"yalc:publish": "lerna run yalc:publish"
},
"volta": {
"node": "16.19.0",
"node": "18.17.0",
"yarn": "1.22.19"
},
"workspaces": [
"packages/angular",
"packages/angular-ivy",
"packages/astro",
"packages/browser",
"packages/browser-integration-tests",
"packages/bun",
Expand Down Expand Up @@ -126,7 +127,8 @@
"yalc": "^1.0.0-pre.53"
},
"resolutions": {
"**/agent-base": "5"
"**/agent-base": "5",
"**/terser/source-map": "0.7.4"
},
"version": "0.0.0",
"name": "sentry-javascript"
Expand Down
15 changes: 15 additions & 0 deletions packages/astro/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
env: {
browser: true,
node: true,
},
extends: ['../../.eslintrc.js'],
overrides: [
{
files: ['vite.config.ts'],
parserOptions: {
project: ['tsconfig.test.json'],
},
},
],
};
14 changes: 14 additions & 0 deletions packages/astro/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Copyright (c) 2023 Sentry (https://sentry.io) and individual contributors. All rights reserved.

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.
31 changes: 31 additions & 0 deletions packages/astro/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<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>

# Official Sentry SDK for Astro

[![npm version](https://img.shields.io/npm/v/@sentry/astro.svg)](https://www.npmjs.com/package/@sentry/astro)
[![npm dm](https://img.shields.io/npm/dm/@sentry/astro.svg)](https://www.npmjs.com/package/@sentry/astro)
[![npm dt](https://img.shields.io/npm/dt/@sentry/astro.svg)](https://www.npmjs.com/package/@sentry/astro)

<!--
TODO: Add links once we have official docs
## Links
- [Official SDK Docs](https://docs.sentry.io/platforms/javascript/guides/astro/)
-->

## Experimental Note

This SDK is experimental and in Alpha state. Breaking changes can occurr at any time.
If you have feedback or encounter any bugs, feel free to [open an issue](https://github.com/getsentry/sentry-javascript/issues/new/choose).

## General

This package is a wrapper around `@sentry/node` for the server and `@sentry/browser` for the client side.

## Installation and Setup

TODO
53 changes: 53 additions & 0 deletions packages/astro/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "@sentry/astro",
"version": "7.73.0",
"description": "Official Sentry SDK for Astro",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/astro",
"author": "Sentry",
"license": "MIT",
"engines": {
"node": ">=18.14.1"
},
"main": "build/cjs/index.server.js",
"module": "build/esm/index.server.js",
"browser": "build/esm/index.client.js",
"types": "build/types/index.types.d.ts",
"publishConfig": {
"access": "public"
},
"peerDependencies": {
"astro": "1.x"
},
"devDependencies": {
"astro": "^3.2.3",
"rollup": "^3.20.2",
"vite": "4.0.5"
},
"scripts": {
"build": "run-p build:transpile build:types",
"build:dev": "yarn build",
"build:transpile": "rollup -c rollup.npm.config.js --bundleConfigAsCjs",
"build:types": "tsc -p tsconfig.types.json",
"build:watch": "run-p build:transpile:watch build:types:watch",
"build:dev:watch": "yarn build:watch",
"build:transpile:watch": "rollup -c rollup.npm.config.js --bundleConfigAsCjs --watch",
"build:types:watch": "tsc -p tsconfig.types.json --watch",
"build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build",
"circularDepCheck": "madge --circular src/index.client.ts && madge --circular src/index.server.ts && madge --circular src/index.types.ts",
"clean": "rimraf build coverage sentry-astro-*.tgz",
"fix": "run-s fix:eslint fix:prettier",
"fix:eslint": "eslint . --format stylish --fix",
"fix:prettier": "prettier --write \"{src,test,scripts}/**/**.ts\"",
"lint": "run-s lint:prettier lint:eslint",
"lint:eslint": "eslint . --format stylish",
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
"test": "yarn test:unit",
"test:unit": "vitest run",
"test:watch": "vitest --watch",
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
},
"volta": {
"extends": "../../package.json"
}
}
12 changes: 12 additions & 0 deletions packages/astro/rollup.npm.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { makeBaseNPMConfig, makeNPMConfigVariants } from '../../rollup/index.js';

export default makeNPMConfigVariants(
makeBaseNPMConfig({
entrypoints: ['src/index.server.ts', 'src/index.client.ts'],
packageSpecificConfig: {
output: {
dynamicImportInCjs: true,
},
},
}),
);
1 change: 1 addition & 0 deletions packages/astro/src/index.client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const client = true;
1 change: 1 addition & 0 deletions packages/astro/src/index.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const server = true;
1 change: 1 addition & 0 deletions packages/astro/src/index.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type Placeholder = true;
5 changes: 5 additions & 0 deletions packages/astro/test/index.client.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('placeholder', () => {
it('holds a place', () => {
expect(true).toBe(true);
});
});
9 changes: 9 additions & 0 deletions packages/astro/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",

"include": ["src/**/*"],

"compilerOptions": {
// package-specific options
}
}
10 changes: 10 additions & 0 deletions packages/astro/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",

"include": ["test/**/*", "vite.config.ts"],

"compilerOptions": {
// should include all types from `./tsconfig.json` plus types for all test frameworks used
"types": ["node", "vitest/globals"]
}
}
10 changes: 10 additions & 0 deletions packages/astro/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",

"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"outDir": "build/types"
}
}
13 changes: 13 additions & 0 deletions packages/astro/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { UserConfig } from 'vitest';

import baseConfig from '../../vite/vite.config';

export default {
...baseConfig,
test: {
// test exists, no idea why TS doesn't recognize it
// eslint-disable-next-line @typescript-eslint/no-explicit-any
...(baseConfig as UserConfig & { test: any }).test,
environment: 'jsdom',
},
};
2 changes: 1 addition & 1 deletion packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"node-fetch": "^2.6.0",
"playwright": "^1.31.1",
"sinon": "^7.3.2",
"webpack": "^4.30.0"
"webpack": "^4.47.0"
},
"scripts": {
"build": "run-p build:transpile build:bundle build:types",
Expand Down
6 changes: 6 additions & 0 deletions packages/e2e-tests/verdaccio-config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ packages:
unpublish: $all
# proxy: npmjs # Don't proxy for E2E tests!

'@sentry/astro':
access: $all
publish: $all
unpublish: $all
# proxy: npmjs # Don't proxy for E2E tests!

'@sentry/browser':
access: $all
publish: $all
Expand Down
14 changes: 11 additions & 3 deletions scripts/node-unit-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const SKIP_TEST_PACKAGES: Record<NodeVersion, VersionConfig> = {
'@sentry-internal/replay-worker',
'@sentry/node-experimental',
'@sentry/vercel-edge',
'@sentry/astro',
],
legacyDeps: [
'jsdom@15.x',
Expand All @@ -53,22 +54,29 @@ const SKIP_TEST_PACKAGES: Record<NodeVersion, VersionConfig> = {
'@sentry-internal/replay-worker',
'@sentry/node-experimental',
'@sentry/vercel-edge',
'@sentry/astro',
],
legacyDeps: ['jsdom@16.x', 'lerna@3.13.4'],
shouldES6Utils: true,
},
'12': {
ignoredPackages: ['@sentry/remix', '@sentry/sveltekit', '@sentry/node-experimental', '@sentry/vercel-edge'],
ignoredPackages: [
'@sentry/remix',
'@sentry/sveltekit',
'@sentry/node-experimental',
'@sentry/vercel-edge',
'@sentry/astro',
],
legacyDeps: ['lerna@3.13.4'],
shouldES6Utils: true,
},
'14': {
ignoredPackages: ['@sentry/sveltekit', '@sentry/vercel-edge'],
ignoredPackages: ['@sentry/sveltekit', '@sentry/vercel-edge', '@sentry/astro'],
legacyDeps: [],
shouldES6Utils: false,
},
'16': {
ignoredPackages: ['@sentry/vercel-edge'],
ignoredPackages: ['@sentry/vercel-edge', '@sentry/astro'],
legacyDeps: [],
shouldES6Utils: false,
},
Expand Down
Loading

0 comments on commit 4236181

Please sign in to comment.