Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Create Astro integration #216

Merged
merged 23 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
49dbc0f
export plugin return type from plugin core
nicholas-codecov Nov 26, 2024
1c08113
add in astro integration
nicholas-codecov Nov 27, 2024
acd54a4
add in example astro app
nicholas-codecov Nov 27, 2024
c6b745a
add in astro integration tests
nicholas-codecov Nov 27, 2024
fe1a0ce
update CI to upload astro example app and astro integration stats
nicholas-codecov Nov 27, 2024
531f85b
update lockfile
nicholas-codecov Nov 27, 2024
860780c
be a bit more specific about keywords in the package.json
nicholas-codecov Nov 27, 2024
248ef94
fix test not testing name being passed
nicholas-codecov Nov 27, 2024
603313b
bump versions in astro package json
nicholas-codecov Dec 3, 2024
a7d3138
fix up jsdoc typo
nicholas-codecov Dec 3, 2024
3618d73
remove leftover comment
nicholas-codecov Dec 3, 2024
4832be0
remove a copy pasted comment
nicholas-codecov Dec 3, 2024
a50566c
rename from astro-integration to astro-plugin
nicholas-codecov Dec 3, 2024
08e90e5
add ts expect errors to build config
nicholas-codecov Dec 3, 2024
c5f09b1
cast type to plugin option array to make things happy
nicholas-codecov Dec 4, 2024
d541782
ignore types in vitest
nicholas-codecov Dec 4, 2024
513c244
resolve all of the unit test issues
nicholas-codecov Dec 4, 2024
9131130
bump version number in astro snapshots
nicholas-codecov Dec 4, 2024
6df545b
remove vite-tsconf-path as it's not needed
nicholas-codecov Dec 4, 2024
cca84a2
final few type fixes
nicholas-codecov Dec 4, 2024
f326bfb
bump version numbers
nicholas-codecov Dec 4, 2024
5ca57d5
correct changeset for dynamic imports
nicholas-codecov Dec 4, 2024
1260bda
fix snapshots
nicholas-codecov Dec 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .changeset/nine-boxes-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"@codecov/bundler-plugin-core": minor
"@codecov/astro-plugin": minor
"@codecov/bundle-analyzer": minor
"@codecov/nextjs-webpack-plugin": minor
"@codecov/nuxt-plugin": minor
"@codecov/remix-vite-plugin": minor
"@codecov/rollup-plugin": minor
"@codecov/solidstart-plugin": minor
"@codecov/sveltekit-plugin": minor
"@codecov/vite-plugin": minor
"@codecov/webpack-plugin": minor
---

Export bundle analysis plugin return type from bundler plugin core
suejung-sentry marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 15 additions & 0 deletions .changeset/old-singers-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"@codecov/bundler-plugin-core": minor
"@codecov/astro-plugin": minor
"@codecov/bundle-analyzer": minor
"@codecov/nextjs-webpack-plugin": minor
"@codecov/nuxt-plugin": minor
"@codecov/remix-vite-plugin": minor
"@codecov/rollup-plugin": minor
"@codecov/solidstart-plugin": minor
"@codecov/sveltekit-plugin": minor
"@codecov/vite-plugin": minor
"@codecov/webpack-plugin": minor
---

Add new Astro Plugin to support BA uploads for Astro applications
10 changes: 6 additions & 4 deletions .changeset/tame-glasses-compete.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
---
"@codecov/nextjs-webpack-plugin": minor
"@codecov/bundler-plugin-core": minor
"@codecov/astro-plugin": minor
"@codecov/bundle-analyzer": minor
"@codecov/nextjs-webpack-plugin": minor
"@codecov/nuxt-plugin": minor
"@codecov/remix-vite-plugin": minor
"@codecov/rollup-plugin": minor
"@codecov/solidstart-plugin": minor
"@codecov/sveltekit-plugin": minor
"@codecov/webpack-plugin": minor
"@codecov/rollup-plugin": minor
"@codecov/nuxt-plugin": minor
"@codecov/vite-plugin": minor
"@codecov/webpack-plugin": minor
---

Collect dynamic imports for base bundler plugins, which apply to the extended meta-framework plugins.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const config = {
"./tsconfig.json",
"./integration-tests/tsconfig.json",
"./packages/bundler-plugin-core/tsconfig.json",
"./packages/astro-plugin/tsconfig.json",
"./packages/nextjs-webpack-plugin/tsconfig.json",
"./packages/nuxt-plugin/tsconfig.json",
"./packages/remix-vite-plugin/tsconfig.json",
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ jobs:
matrix:
example:
[
"astro",
"bundle-analyzer-cli",
"bundle-analyzer-lib-cjs",
"bundle-analyzer-lib-esm",
Expand Down Expand Up @@ -346,6 +347,8 @@ jobs:
env:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
ASTRO_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
ASTRO_API_URL: ${{ secrets.CODECOV_API_URL }}
BUNDLE_ANALYZER_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
BUNDLE_ANALYZER_API_URL: ${{ secrets.CODECOV_API_URL }}
NEXT_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
Expand Down Expand Up @@ -378,6 +381,7 @@ jobs:
matrix:
example:
[
"astro",
"bundle-analyzer-cli",
"bundle-analyzer-lib-cjs",
"bundle-analyzer-lib-esm",
Expand Down Expand Up @@ -440,6 +444,8 @@ jobs:
env:
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
ASTRO_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
ASTRO_API_URL: ${{ secrets.CODECOV_API_URL }}
BUNDLE_ANALYZER_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
BUNDLE_ANALYZER_API_URL: ${{ secrets.CODECOV_API_URL }}
NEXT_UPLOAD_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN_STAGING }}
Expand Down Expand Up @@ -472,6 +478,7 @@ jobs:
matrix:
package:
[
"astro-plugin",
"bundle-analyzer",
"bundler-plugin-core",
"nextjs-webpack-plugin",
Expand Down Expand Up @@ -541,6 +548,7 @@ jobs:
matrix:
package:
[
"astro-plugin",
"bundle-analyzer",
"bundler-plugin-core",
"nextjs-webpack-plugin",
Expand Down
24 changes: 24 additions & 0 deletions examples/astro/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# build output
dist/

# generated types
.astro/

# dependencies
node_modules/

# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# environment variables
.env
.env.production

# macOS-specific files
.DS_Store

# jetbrains setting folder
.idea/
4 changes: 4 additions & 0 deletions examples/astro/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}
11 changes: 11 additions & 0 deletions examples/astro/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
}
54 changes: 54 additions & 0 deletions examples/astro/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Astro Starter Kit: Basics

```sh
npm create astro@latest -- --template basics
```

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/basics)
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/basics)
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/basics/devcontainer.json)

> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
![just-the-basics](https://github.com/withastro/astro/assets/2244813/a0a5533c-a856-4198-8470-2d67b1d7c554)

## 🚀 Project Structure

Inside of your Astro project, you'll see the following folders and files:

```text
/
├── public/
│ └── favicon.svg
├── src/
│ ├── components/
│ │ └── Card.astro
│ ├── layouts/
│ │ └── Layout.astro
│ └── pages/
│ └── index.astro
└── package.json
```

Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name.

There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.

Any static assets, like images, can be placed in the `public/` directory.

## 🧞 Commands

All commands are run from the root of the project, from a terminal:

| Command | Action |
| :------------------------ | :----------------------------------------------- |
| `npm install` | Installs dependencies |
| `npm run dev` | Starts local dev server at `localhost:4321` |
| `npm run build` | Build your production site to `./dist/` |
| `npm run preview` | Preview your build locally, before deploying |
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
| `npm run astro -- --help` | Get help using the Astro CLI |

## 👀 Want to learn more?

Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).
27 changes: 27 additions & 0 deletions examples/astro/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// @ts-check
import { defineConfig } from "astro/config";

import codecovAstroPlugin from "@codecov/astro-plugin";

import node from "@astrojs/node";

import react from "@astrojs/react";

// https://astro.build/config
export default defineConfig({
output: "hybrid",
adapter: node({
mode: "standalone",
}),
integrations: [
react(),
codecovAstroPlugin({
enableBundleAnalysis: true,
bundleName: "@codecov/example-astro-app",
uploadToken: process.env.ASTRO_UPLOAD_TOKEN,
apiUrl: process.env.ASTRO_API_URL,
gitService: "github",
debug: true,
}),
],
});
26 changes: 26 additions & 0 deletions examples/astro/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "astro",
"type": "module",
"version": "0.0.1",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro check && astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"@astrojs/check": "^0.9.4",
"@astrojs/node": "^8.3.4",
"@astrojs/react": "^3.6.3",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"astro": "^4.16.13",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"typescript": "^5.7.2"
},
"devDependencies": {
"@codecov/astro-plugin": "workspace:*"
}
}
9 changes: 9 additions & 0 deletions examples/astro/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions examples/astro/src/components/Card.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
interface Props {
title: string;
body: string;
href: string;
}
const { href, title, body } = Astro.props;
---

<li class="link-card">
<a href={href}>
<h2>
{title}
<span>&rarr;</span>
</h2>
<p>
{body}
</p>
</a>
</li>
<style>
.link-card {
list-style: none;
display: flex;
padding: 1px;
background-color: #23262d;
background-image: none;
background-size: 400%;
border-radius: 7px;
background-position: 100%;
transition: background-position 0.6s cubic-bezier(0.22, 1, 0.36, 1);
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}
.link-card > a {
width: 100%;
text-decoration: none;
line-height: 1.4;
padding: calc(1.5rem - 1px);
border-radius: 8px;
color: white;
background-color: #23262d;
opacity: 0.8;
}
h2 {
margin: 0;
font-size: 1.25rem;
transition: color 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
p {
margin-top: 0.5rem;
margin-bottom: 0;
}
.link-card:is(:hover, :focus-within) {
background-position: 0;
background-image: var(--accent-gradient);
}
.link-card:is(:hover, :focus-within) h2 {
color: rgb(var(--accent-light));
}
</style>
29 changes: 29 additions & 0 deletions examples/astro/src/components/Counter.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.linkCard {
list-style: none;
display: flex;
padding: 1px;
background-color: #23262d;
background-image: none;
background-size: 400%;
border-radius: 7px;
background-position: 100%;
transition: background-position 0.6s cubic-bezier(0.22, 1, 0.36, 1);
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}
.linkCard > button {
width: 100%;
text-decoration: none;
line-height: 1.4;
padding: calc(1.5rem - 1px);
border-radius: 8px;
color: white;
background-color: #23262d;
opacity: 0.8;
}
.linkCard:is(:hover, :focus-within) {
background-position: 0;
background-image: var(--accent-gradient);
}
.linkCard:is(:hover, :focus-within) h2 {
color: rgb(var(--accent-light));
}
15 changes: 15 additions & 0 deletions examples/astro/src/components/Counter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react";

import styles from "./Counter.module.css";

export const Counter = () => {
const [count, setCount] = React.useState(0);

return (
<div className={styles.linkCard}>
<button onClick={() => setCount((c) => c + 1)} style={{}}>
Count: {count}
</button>
</div>
);
};
1 change: 1 addition & 0 deletions examples/astro/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference path="../.astro/types.d.ts" />
Loading
Loading