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

[refactor] Re-organise project files. #107

Merged
merged 9 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ module.exports = {
},
},
{
files: ['packages/tests/src/jest/**/*.*'],
files: ['packages/tests/src/_jest/*.*'],
rules: {
'no-restricted-imports': [
'error',
Expand All @@ -390,13 +390,13 @@ module.exports = {
},
},
{
files: ['rollup.config.mjs', 'packages/core/**/*', 'packages/*-plugin/**/*'],
files: ['rollup.config.mjs', 'packages/core/**/*', 'packages/published/**/*'],
rules: {
'import/no-extraneous-dependencies': 'off',
},
},
{
files: ['packages/core/**/*', 'packages/plugins/**/*', 'packages/*-plugin/**/*'],
files: ['packages/core/**/*', 'packages/plugins/**/*', 'packages/published/**/*'],
rules: {
'no-console': ['error', { allow: ['time', 'timeEnd'] }],
},
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

- name: Install Node ${{matrix.node}}.x
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: ${{matrix.node}}.x
- run: yarn install
Expand All @@ -28,9 +28,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '18.19.0'
- run: yarn install
Expand All @@ -42,9 +42,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '18.19.0'
- run: yarn install
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18.x'
- run: yarn config set npmAuthToken $YARN_NPM_AUTH_TOKEN
Expand Down
62 changes: 29 additions & 33 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ We have two types of workspaces:
- `@dd/assets` | `./packages/assets`: Only the static files used as assets.
- `@dd/core` | `./packages/core`: The core package that contains the shared code between the plugins.
- `@dd/factory` | `./packages/factory`: The factory package that contains the logic to aggregate all the plugins together.
- `@dd/*-plugin` | `./packages/plugins/*`: The plugins workspaces that contains the plugins. Each plugin is a workspace.
- `@dd/*-plugin` | `./packages/plugins/*`: The actual features of our bundler plugins.
- `@dd/tests` | `./packages/tests`: The tests package that contains the shared tests between the all the workspaces.
- `@dd/tools` | `./packages/tools`: The tools package that contains the shared tools we use locally for the development.

Expand All @@ -80,43 +80,44 @@ title: Datadog Build Plugins Design
---
stateDiagram-v2
published: Published Packages
plugins: Custom Plugins
customplugin1: @dd/*-plugins
customplugin2: @dd/*-plugins
customplugin3: [...]
customplugin12: @dd/*-plugins
customplugin22: @dd/*-plugins
customplugin32: [...]
productPlugins: Product Plugins
productPlugin: @dd/{product}-plugin
productPlugin2: [...]
esbuildplugin: @datadog/esbuild-plugin
viteplugin: @datadog/vite-plugin
rollupplugin: @datadog/rollup-plugin
webpackplugin: @datadog/webpack-plugin
tests: @dd/tests
tools: @dd/tools
factory: @dd/factory
core: @dd/core
types: Shared Types
sharedHelpers: Shared Helpers
sharedConstants: Shared Constants
helpers: Aggregated Helpers
atypes: Aggregated Types
aplugins: Aggregated List of Plugins
contextCreation: Creation of the Global Context
cli: Internal CLIs
internalPlugins: Internal Plugins
buildReportPlugin: Build Report Plugin
bundlerReportPlugin: Bundler Report Plugin
injectionPlugin: Injection Plugin
gitPlugin: Git Plugin
buildReportPlugin: @dd/internal-build-report-plugin
bundlerReportPlugin: @dd/internal-bundler-report-plugin
contextPlugin: @dd/internal-context-plugin
injectionPlugin: @dd/internal-injection-plugin
gitPlugin: @dd/internal-git-plugin

state internalPlugins {
buildReportPlugin
bundlerReportPlugin
contextPlugin
gitPlugin
injectionPlugin
}

state core {
getLogger()
sharedHelpers
sharedConstants
types
internalPlugins
}

state published {
Expand All @@ -126,13 +127,13 @@ stateDiagram-v2
webpackplugin
}

state plugins {
customplugin1
customplugin2
customplugin3
state productPlugins {
productPlugin
productPlugin2
}

state factory {
contextCreation
helpers
atypes
aplugins
Expand All @@ -142,18 +143,13 @@ stateDiagram-v2
cli
}

state tests {
customplugin12
customplugin22
customplugin32
}

plugins --> factory: CONFIG_KEY<br/>helpers<br/>types<br/>getPlugins()
core --> tools: types
core --> factory: Internal Plugins<br/>types
core --> plugins: getLogger()<br/>types
core --> tests: types
factory --> plugins: Global Context
internalPlugins --> factory
productPlugins --> factory: CONFIG_KEY<br/>helpers<br/>types<br/>getPlugins()
core --> tools
core --> factory
core --> internalPlugins
core --> productPlugins
factory --> productPlugins: Global Context
factory --> published: Unplugin Factory
published --> NPM: types<br/>helpers<br/>datadogBundlerPlugin
```
Expand All @@ -167,11 +163,11 @@ Bootstrapping all the files you'll need to start coding.
yarn cli create-plugin
```

Then learn more about what you can use from [the ecosystem](./packages/core).
Then learn more about what you can use from [the ecosystem](/packages/core).

## Tests

<kbd>[📝 Full testing documentation ➡️](./packages/tests#readme)</kbd>
<kbd>[📝 Full testing documentation ➡️](/packages/tests#readme)</kbd>

> [!IMPORTANT]
> If you're modifying a behavior or adding a new feature, update/add the required tests to your PR.
Expand Down Expand Up @@ -290,7 +286,7 @@ yarn publish:all --tag=alpha

## Misc. Tooling

We have a [CLI to help with some tasks](./packages/tools#readme).
We have a [CLI to help with some tasks](/packages/tools#readme).

---

Expand Down
2 changes: 1 addition & 1 deletion MIGRATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ esbuild
const config = {
plugins: [
- new BuildPlugin({
+ datadogEsbuildPlugin({
+ datadogWebpackPlugin({
// Your configuration here.
}),
]
Expand Down
27 changes: 11 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
# Datadog Build Plugins <!-- #omit in toc -->

A set of plugins to interact with Datadog directly from your builds.

## ✨ Key takeaways ✨ <!-- #omit in toc -->

- This is a bundler plugin for <img src="packages/assets/src/webpack.svg" alt="Webpack" width="17" /> Webpack, <img src="packages/assets/src/vite.svg" alt="Vite" width="17" /> Vite, <img src="packages/assets/src/esbuild.svg" alt="ESBuild" width="17" /> ESBuild and <img src="packages/assets/src/rollup.svg" alt="Rollup" width="17" /> Rollup.
- Very easy to setup and disable on the fly.
A set of bundler plugins for <img src="packages/assets/src/webpack.svg" alt="Webpack" width="17" /> Webpack, <img src="packages/assets/src/vite.svg" alt="Vite" width="17" /> Vite, <img src="packages/assets/src/esbuild.svg" alt="ESBuild" width="17" /> ESBuild and <img src="packages/assets/src/rollup.svg" alt="Rollup" width="17" /> Rollup, to interact with Datadog directly from your builds.

> [!NOTE]
> If you want to upgrade from v1 to v2, please follow our [migration guide](./MIGRATIONS.md#v1-to-v2).
> If you want to upgrade from v1 to v2, please follow our [migration guide](/MIGRATIONS.md#v1-to-v2).

## Table of content <!-- #omit in toc -->

Expand Down Expand Up @@ -69,7 +64,7 @@ require('esbuild').build({
> It is important to have the plugin in the first position in order to report every other plugins.


<kbd>[📝 More details ➡️](./packages/esbuild-plugin#readme)</kbd>
<kbd>[📝 More details ➡️](/packages/published/esbuild-plugin#readme)</kbd>

### <img src="packages/assets/src/rollup.svg" alt="Rollup" width="17" /> Rollup

Expand Down Expand Up @@ -108,7 +103,7 @@ export default {
> It is important to have the plugin in the first position in order to report every other plugins.


<kbd>[📝 More details ➡️](./packages/rollup-plugin#readme)</kbd>
<kbd>[📝 More details ➡️](/packages/published/rollup-plugin#readme)</kbd>

### <img src="packages/assets/src/vite.svg" alt="Vite" width="17" /> Vite

Expand Down Expand Up @@ -148,7 +143,7 @@ export default defineConfig({
> It is important to have the plugin in the first position in order to report every other plugins.


<kbd>[📝 More details ➡️](./packages/vite-plugin#readme)</kbd>
<kbd>[📝 More details ➡️](/packages/published/vite-plugin#readme)</kbd>

### <img src="packages/assets/src/webpack.svg" alt="Webpack" width="17" /> Webpack

Expand Down Expand Up @@ -187,7 +182,7 @@ module.exports = {
> It is important to have the plugin in the first position in order to report every other plugins.


<kbd>[📝 More details ➡️](./packages/webpack-plugin#readme)</kbd>
<kbd>[📝 More details ➡️](/packages/published/webpack-plugin#readme)</kbd>
<!-- #list-of-bundlers -->

## Features
Expand All @@ -214,7 +209,7 @@ datadogWebpackPlugin({
});
```

<kbd>[📝 Full documentation ➡️](./packages/plugins/rum#readme)</kbd>
<kbd>[📝 Full documentation ➡️](/packages/plugins/rum#readme)</kbd>

### Telemetry <img src="packages/assets/src/esbuild.svg" alt="ESBuild" width="17" /> <img src="packages/assets/src/rollup.svg" alt="Rollup" width="17" /> <img src="packages/assets/src/vite.svg" alt="Vite" width="17" /> <img src="packages/assets/src/webpack.svg" alt="Webpack" width="17" />

Expand All @@ -241,7 +236,7 @@ datadogWebpackPlugin({
});
```

<kbd>[📝 Full documentation ➡️](./packages/plugins/telemetry#readme)</kbd>
<kbd>[📝 Full documentation ➡️](/packages/plugins/telemetry#readme)</kbd>
<!-- #list-of-packages -->

## Configuration
Expand Down Expand Up @@ -381,7 +376,7 @@ type GlobalContext = {
git?: {
hash: string;
remote: string;
trackedFilesMatcher: [TrackedFilesMatcher](packages/core/src/plugins/git/trackedFilesMatcher.ts);
trackedFilesMatcher: [TrackedFilesMatcher](/packages/plugins/git/trackedFilesMatcher.ts);
};
inject: (item: { type: 'file' | 'code'; value: string; fallback?: @self }) => void;
start: number;
Expand All @@ -401,10 +396,10 @@ Your function will need to return an array of [Unplugin Plugins definitions](htt

## Contributing

Check out [CONTRIBUTING.md](CONTRIBUTING.md) for more information about how to work with the build-plugins ecosystem.
Check out [CONTRIBUTING.md](/CONTRIBUTING.md) for more information about how to work with the build-plugins ecosystem.

## License

[MIT](LICENSE)
[MIT](/LICENSE)

<kbd>[Back to top :arrow_up:](#top)</kbd>
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"workspaces": [
"packages/*",
"packages/plugins/*",
"packages/tests/src/fixtures/project"
"packages/published/*",
"packages/tests/src/_jest/fixtures/project"
],
"volta": {
"node": "18.19.0",
Expand Down
Loading