Skip to content

Commit 4236181

Browse files
authored
chore(astro): Add @sentry/astro package (#9187)
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
1 parent 945d873 commit 4236181

18 files changed

+2510
-23
lines changed

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@
3434
"yalc:publish": "lerna run yalc:publish"
3535
},
3636
"volta": {
37-
"node": "16.19.0",
37+
"node": "18.17.0",
3838
"yarn": "1.22.19"
3939
},
4040
"workspaces": [
4141
"packages/angular",
4242
"packages/angular-ivy",
43+
"packages/astro",
4344
"packages/browser",
4445
"packages/browser-integration-tests",
4546
"packages/bun",
@@ -126,7 +127,8 @@
126127
"yalc": "^1.0.0-pre.53"
127128
},
128129
"resolutions": {
129-
"**/agent-base": "5"
130+
"**/agent-base": "5",
131+
"**/terser/source-map": "0.7.4"
130132
},
131133
"version": "0.0.0",
132134
"name": "sentry-javascript"

packages/astro/.eslintrc.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
node: true,
5+
},
6+
extends: ['../../.eslintrc.js'],
7+
overrides: [
8+
{
9+
files: ['vite.config.ts'],
10+
parserOptions: {
11+
project: ['tsconfig.test.json'],
12+
},
13+
},
14+
],
15+
};

packages/astro/LICENSE

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Copyright (c) 2023 Sentry (https://sentry.io) and individual contributors. All rights reserved.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
4+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
5+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
6+
persons to whom the Software is furnished to do so, subject to the following conditions:
7+
8+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
9+
Software.
10+
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
12+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
13+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
14+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

packages/astro/README.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<p align="center">
2+
<a href="https://sentry.io/?utm_source=github&utm_medium=logo" target="_blank">
3+
<img src="https://sentry-brand.storage.googleapis.com/sentry-wordmark-dark-280x84.png" alt="Sentry" width="280" height="84">
4+
</a>
5+
</p>
6+
7+
# Official Sentry SDK for Astro
8+
9+
[![npm version](https://img.shields.io/npm/v/@sentry/astro.svg)](https://www.npmjs.com/package/@sentry/astro)
10+
[![npm dm](https://img.shields.io/npm/dm/@sentry/astro.svg)](https://www.npmjs.com/package/@sentry/astro)
11+
[![npm dt](https://img.shields.io/npm/dt/@sentry/astro.svg)](https://www.npmjs.com/package/@sentry/astro)
12+
13+
<!--
14+
TODO: Add links once we have official docs
15+
## Links
16+
17+
- [Official SDK Docs](https://docs.sentry.io/platforms/javascript/guides/astro/)
18+
-->
19+
20+
## Experimental Note
21+
22+
This SDK is experimental and in Alpha state. Breaking changes can occurr at any time.
23+
If you have feedback or encounter any bugs, feel free to [open an issue](https://github.com/getsentry/sentry-javascript/issues/new/choose).
24+
25+
## General
26+
27+
This package is a wrapper around `@sentry/node` for the server and `@sentry/browser` for the client side.
28+
29+
## Installation and Setup
30+
31+
TODO

packages/astro/package.json

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"name": "@sentry/astro",
3+
"version": "7.73.0",
4+
"description": "Official Sentry SDK for Astro",
5+
"repository": "git://github.com/getsentry/sentry-javascript.git",
6+
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/astro",
7+
"author": "Sentry",
8+
"license": "MIT",
9+
"engines": {
10+
"node": ">=18.14.1"
11+
},
12+
"main": "build/cjs/index.server.js",
13+
"module": "build/esm/index.server.js",
14+
"browser": "build/esm/index.client.js",
15+
"types": "build/types/index.types.d.ts",
16+
"publishConfig": {
17+
"access": "public"
18+
},
19+
"peerDependencies": {
20+
"astro": "1.x"
21+
},
22+
"devDependencies": {
23+
"astro": "^3.2.3",
24+
"rollup": "^3.20.2",
25+
"vite": "4.0.5"
26+
},
27+
"scripts": {
28+
"build": "run-p build:transpile build:types",
29+
"build:dev": "yarn build",
30+
"build:transpile": "rollup -c rollup.npm.config.js --bundleConfigAsCjs",
31+
"build:types": "tsc -p tsconfig.types.json",
32+
"build:watch": "run-p build:transpile:watch build:types:watch",
33+
"build:dev:watch": "yarn build:watch",
34+
"build:transpile:watch": "rollup -c rollup.npm.config.js --bundleConfigAsCjs --watch",
35+
"build:types:watch": "tsc -p tsconfig.types.json --watch",
36+
"build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build",
37+
"circularDepCheck": "madge --circular src/index.client.ts && madge --circular src/index.server.ts && madge --circular src/index.types.ts",
38+
"clean": "rimraf build coverage sentry-astro-*.tgz",
39+
"fix": "run-s fix:eslint fix:prettier",
40+
"fix:eslint": "eslint . --format stylish --fix",
41+
"fix:prettier": "prettier --write \"{src,test,scripts}/**/**.ts\"",
42+
"lint": "run-s lint:prettier lint:eslint",
43+
"lint:eslint": "eslint . --format stylish",
44+
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
45+
"test": "yarn test:unit",
46+
"test:unit": "vitest run",
47+
"test:watch": "vitest --watch",
48+
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
49+
},
50+
"volta": {
51+
"extends": "../../package.json"
52+
}
53+
}

packages/astro/rollup.npm.config.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { makeBaseNPMConfig, makeNPMConfigVariants } from '../../rollup/index.js';
2+
3+
export default makeNPMConfigVariants(
4+
makeBaseNPMConfig({
5+
entrypoints: ['src/index.server.ts', 'src/index.client.ts'],
6+
packageSpecificConfig: {
7+
output: {
8+
dynamicImportInCjs: true,
9+
},
10+
},
11+
}),
12+
);

packages/astro/src/index.client.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const client = true;

packages/astro/src/index.server.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const server = true;

packages/astro/src/index.types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type Placeholder = true;
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
describe('placeholder', () => {
2+
it('holds a place', () => {
3+
expect(true).toBe(true);
4+
});
5+
});

packages/astro/tsconfig.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
4+
"include": ["src/**/*"],
5+
6+
"compilerOptions": {
7+
// package-specific options
8+
}
9+
}

packages/astro/tsconfig.test.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
4+
"include": ["test/**/*", "vite.config.ts"],
5+
6+
"compilerOptions": {
7+
// should include all types from `./tsconfig.json` plus types for all test frameworks used
8+
"types": ["node", "vitest/globals"]
9+
}
10+
}

packages/astro/tsconfig.types.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
4+
"compilerOptions": {
5+
"declaration": true,
6+
"declarationMap": true,
7+
"emitDeclarationOnly": true,
8+
"outDir": "build/types"
9+
}
10+
}

packages/astro/vite.config.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { UserConfig } from 'vitest';
2+
3+
import baseConfig from '../../vite/vite.config';
4+
5+
export default {
6+
...baseConfig,
7+
test: {
8+
// test exists, no idea why TS doesn't recognize it
9+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
10+
...(baseConfig as UserConfig & { test: any }).test,
11+
environment: 'jsdom',
12+
},
13+
};

packages/browser/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"node-fetch": "^2.6.0",
5252
"playwright": "^1.31.1",
5353
"sinon": "^7.3.2",
54-
"webpack": "^4.30.0"
54+
"webpack": "^4.47.0"
5555
},
5656
"scripts": {
5757
"build": "run-p build:transpile build:bundle build:types",

packages/e2e-tests/verdaccio-config/config.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ packages:
4444
unpublish: $all
4545
# proxy: npmjs # Don't proxy for E2E tests!
4646

47+
'@sentry/astro':
48+
access: $all
49+
publish: $all
50+
unpublish: $all
51+
# proxy: npmjs # Don't proxy for E2E tests!
52+
4753
'@sentry/browser':
4854
access: $all
4955
publish: $all

scripts/node-unit-tests.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const SKIP_TEST_PACKAGES: Record<NodeVersion, VersionConfig> = {
3535
'@sentry-internal/replay-worker',
3636
'@sentry/node-experimental',
3737
'@sentry/vercel-edge',
38+
'@sentry/astro',
3839
],
3940
legacyDeps: [
4041
@@ -53,22 +54,29 @@ const SKIP_TEST_PACKAGES: Record<NodeVersion, VersionConfig> = {
5354
'@sentry-internal/replay-worker',
5455
'@sentry/node-experimental',
5556
'@sentry/vercel-edge',
57+
'@sentry/astro',
5658
],
5759
5860
shouldES6Utils: true,
5961
},
6062
'12': {
61-
ignoredPackages: ['@sentry/remix', '@sentry/sveltekit', '@sentry/node-experimental', '@sentry/vercel-edge'],
63+
ignoredPackages: [
64+
'@sentry/remix',
65+
'@sentry/sveltekit',
66+
'@sentry/node-experimental',
67+
'@sentry/vercel-edge',
68+
'@sentry/astro',
69+
],
6270
legacyDeps: ['[email protected]'],
6371
shouldES6Utils: true,
6472
},
6573
'14': {
66-
ignoredPackages: ['@sentry/sveltekit', '@sentry/vercel-edge'],
74+
ignoredPackages: ['@sentry/sveltekit', '@sentry/vercel-edge', '@sentry/astro'],
6775
legacyDeps: [],
6876
shouldES6Utils: false,
6977
},
7078
'16': {
71-
ignoredPackages: ['@sentry/vercel-edge'],
79+
ignoredPackages: ['@sentry/vercel-edge', '@sentry/astro'],
7280
legacyDeps: [],
7381
shouldES6Utils: false,
7482
},

0 commit comments

Comments
 (0)