Skip to content

Commit 733f528

Browse files
jondavidjohngitbook-bot
authored andcommitted
GitBook: [master] 17 pages and 8 assets modified
1 parent 7a628c3 commit 733f528

25 files changed

+576
-0
lines changed
18.1 KB
Loading
29.5 KB
Loading

.gitbook/assets/github-check.png

323 KB
Loading

.gitbook/assets/github-checks.png

73.1 KB
Loading

.gitbook/assets/github-status (1).png

33.9 KB
Loading

.gitbook/assets/github-status.png

62.3 KB
Loading
Loading
Loading

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# packtracker.io documentation
2+

SUMMARY.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Table of contents
2+
3+
* [packtracker.io documentation](README.md)
4+
* [Creating your first project](creating-your-first-project.md)
5+
* [Uploading your webpack stats](uploading-your-webpack-stats/README.md)
6+
* [GitHub Action](uploading-your-webpack-stats/github-actions.md)
7+
* [CircleCI Orb](uploading-your-webpack-stats/circleci-orb.md)
8+
* [Webpack Plugin](uploading-your-webpack-stats/webpack-plugin.md)
9+
* [Command Line Interface](uploading-your-webpack-stats/with-our-cli.md)
10+
* [Common App Platforms](uploading-your-webpack-stats/common-app-platforms/README.md)
11+
* [Laravel Mix](uploading-your-webpack-stats/common-app-platforms/laravel-mix.md)
12+
* [Webpacker \(with Rails\)](uploading-your-webpack-stats/common-app-platforms/webpacker-with-rails.md)
13+
* [Create React App](uploading-your-webpack-stats/common-app-platforms/create-react-app.md)
14+
* [GitHub Pull Request Checks](github-pull-request-checks/README.md)
15+
* [Performance Budgets](github-pull-request-checks/performance-budgets.md)
16+
* [Forked Repositories](github-pull-request-checks/forked-repositories.md)
17+
* [Managing your team](managing-your-team.md)
18+
* [FAQ](faq.md)
19+

creating-your-first-project.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Creating your first project
2+
3+
### Create an Organizaiton
4+
5+
In order to get started tracking your webpack build stats, you need to create an organization to house your team and projects. Anyone invited to your organization will be able to see and interact with any projects created by your organization.
6+
7+
### Create your project
8+
9+
Once you have an organization set up, you are ready to create your first project. Projects provide you a space to visualize your webpack asset history allowing you to keep track of the assets you are delivering to your users. Once you have created your project you will have access to the `project_token` on your project settings page. This token is what identifies your project when uploading to packtracker.
10+

faq.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# FAQ
2+
3+
## Do you have access to my source code?
4+
5+
No, [the way we gather your webpack stats is entirely open source and open for inspection](https://github.com/packtracker/webpack-plugin). We filter out your source code specifically.
6+
7+
We also do not request source code access through our GitHub App integration.
8+
9+
## Can I upload my stats from my local development environment?
10+
11+
Yes, **this is possible** though we don't recommend it.
12+
13+
Any run of your webpack build process in which our plugin has `upload` set to `true` will send your stats to our service.
14+
15+
We recommend setting your process up to upload your stats in an automated way when you push your code. Generally this is done either:
16+
17+
* In a CI environment
18+
* In your deployment process
19+
20+
This ensures that your not creating a lot of noise in your asset metrics, and allows everyone on your team to take advantage of the tool without additional training and manual intervention.
21+
22+
## Why can't the plugin determine my branch name?
23+
24+
Our webpack plugin uses the local git checkout to query against to determine the branch name. Commonly in CI environments this query comes back as `HEAD` which doesn't quite give us the information we want.
25+
26+
When this is the case the plugin will thrown an error informing you of this **\(as of version `1.2.0`\)**. In this case you need to provide the branch name as either [a plugin configuration or environment variable](https://github.com/packtracker/webpack-plugin#options). In most CI environments there is an environment variable available to you to pass along to the plugin. For example, in CodeShip this environment variable is called `CI_BRANCH`, and you would pass it along to us like so:
27+
28+
```javascript
29+
const PacktrackerPlugin = require('@packtracker/webpack-plugin')
30+
31+
module.exports = {
32+
plugins: [
33+
new PacktrackerPlugin({
34+
project_token: '<your packtracker project token>',
35+
branch: process.env.CI_BRANCH,
36+
})
37+
]
38+
}
39+
```
40+

github-pull-request-checks/README.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
description: >-
3+
Use our GitHub Checks integration to see the real time effects of your asset
4+
changes on a per pull request basis and establish performance budgets for your
5+
asset profile.
6+
---
7+
8+
# GitHub Pull Request Checks
9+
10+
## A note on using automation
11+
12+
In order for this integration to run smoothly, we assume you are using a CI/CD service to perform your webpack build and [report your build stats](https://docs.packtracker.io/uploading-your-webpack-stats).
13+
14+
If you are not utilizing a CI environment to run your webpack builds and report your stats, we suggest starting there first. Integrating your project with a provider that runs your build every time you push, provides a consistent basis to perform these checks.
15+
16+
Make sure you're uploading your stats for every push, not only pull requests. We need stats for both the last commit of the branch you're merging into, as well as the head of the pull request branch in order to provide you with details of the difference between the two.
17+
18+
## Setting up GitHub Checks
19+
20+
![](../.gitbook/assets/github-status%20%281%29.png)
21+
22+
### Connecting to GitHub
23+
24+
First visit the **"GitHub Checks"** tab from your project overview page.
25+
26+
From there you should see an option to connect your user account with your GitHub user account. Once you complete this process, you will then see the option to select which repository you want us to report Checks to.
27+
28+
Initially you will not see any repositories because you have not installed our GitHub App yet. When you open the repository drop down you should see a link suggesting that you install our GitHub App. While installing our GitHub App, be sure to provide us with access to the repository you ware wanting to attach to your packtracker project.
29+
30+
Once you have installed the app and selected it from the dropdown, save your project settings. This should get webhooks flowing.
31+
32+
### When does it report?
33+
34+
We will report asset changes on all your pull requests, taking a previously calculated base commit and comparing it with the latest commit on your pull request.
35+
36+
Once you open and/or push to a pull request, you should see our in progress checks show up. Once we have calculated your stats for both the base and latest commit on your branch, they will show up as completed.
37+
38+
![](../.gitbook/assets/github-checks.png)
39+
40+
41+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Forked Repositories
2+
3+
### My checks are stuck "in progress"!
4+
5+
Many CI providers \(like TravisCI\) run pull request build jobs on the merged result of the base and head commit. This is **great** because you get to test the _result_ of the pull request, not only it's current state.
6+
7+
The problem this creates for us, is that because we try \(by default\) to glean the head commit SHA by running something like `git rev-parse --short HEAD`, we end up getting the merge commit SHA instead of most recent commit SHA of the pull request.
8+
9+
In order to report your data to the SHA we expect, most CI providers have environment variables that provide the data we need. We can adjust our configuration to look to those variables for the data we want.
10+
11+
For example, TravisCI provides not only `TRAVIS_BRANCH` but also `TRAVIS_PULL_REQUEST_BRANCH`
12+
13+
The difference is subtle, but important \(from the TravisCI documentation\)
14+
15+
> `TRAVIS_BRANCH`:
16+
>
17+
> * for push builds, or **builds not triggered by a pull request**, this is the name of the branch.
18+
> * **for builds triggered by a pull request** this is the name of the branch targeted by the pull request.
19+
20+
> `TRAVIS_PULL_REQUEST_BRANCH`:
21+
>
22+
> * **if the current job is a pull request**, the name of the branch from which the PR originated.
23+
> * if the current job is a push build, this variable is empty \(`""`\).
24+
25+
This distinction also extends to the way Travis exposes their commit SHA, so to correctly report your packtracker information to your forked pull requests, configure your plugin similarly as follows
26+
27+
```javascript
28+
new PacktrackerPlugin({
29+
branch: process.env.TRAVIS_PULL_REQUEST_BRANCH || process.env.TRAVIS_BRANCH,
30+
commit: process.env.TRAVIS_PULL_REQUEST_SHA || process.env.TRAVIS_COMMIT,
31+
}),
32+
33+
```
34+
35+
And in this way, we can apply your build stats against the head commit of your pull request resulting in the correct reporting for forked pull requests.
36+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Performance Budgets
2+
3+
As part of our Github Checks integration, you can set up performance budgets for both your **total asset output size** and on a **per asset basis**.
4+
5+
This means you can have both an upper limit for your total asset footprint, and also make sure your individual assets are beneath the threshold you configure. When either of these limits are exceeded, we will fail the offending pull request with detailed information.
6+
7+
### Setting up your performance budgets
8+
9+
Performance budgets can be configured within the Project settings.
10+
11+
A budget of 0 will disable the budget checks.
12+
13+
![Navigate to your project settings](../.gitbook/assets/2018-11-20-at-5.10-pm.png)
14+
15+
![](../.gitbook/assets/2019-03-04-at-10.27-am.png)
16+

managing-your-team.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
description: Permissions and Roles
3+
---
4+
5+
# Managing your team
6+
7+
Inviting members to your organization
8+
9+
Once you have created your organization, you can access your team management feature through the **People** tab on your organization overview page. On this page you will be able to see existing members, see outstanding invitations, and send out new invitations.
10+
11+
When inviting a team member \(and managing existing members\), we have 3 levels of access for you to choose from.
12+
13+
* Owner
14+
* Admin
15+
* Contributor
16+
17+
| Capability | Owner | Admin | Contributor |
18+
| :--- | :--- | :--- | :--- |
19+
| View Private Projects ||||
20+
| Create Projects ||| 🚫 |
21+
| Modify Project Settings ||| 🚫 |
22+
| Delete Projects ||| 🚫 |
23+
| Invite new members ||| 🚫 |
24+
| Modify Organization Settings || 🚫 | 🚫 |
25+
| Modify Organization Subscription || 🚫 | 🚫 |
26+
| Delete the Organization || 🚫 | 🚫 |
27+
| Modify Member Roles || 🚫 | 🚫 |
28+
| Revoke membership from the Organization || 🚫 | 🚫 |
29+
30+
31+
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Uploading your webpack stats
2+
3+
There are a few requirements that enable you to take advantage of the core packtracker experience:
4+
5+
* Usage of [webpack](https://webpack.js.org/) 2, 3, or 4
6+
* Node 6.14.4+
7+
* Usage of `git` for source control
8+
9+
{% page-ref page="github-actions.md" %}
10+
11+
{% page-ref page="circleci-orb.md" %}
12+
13+
{% page-ref page="webpack-plugin.md" %}
14+
15+
{% page-ref page="with-our-cli.md" %}
16+
17+
{% page-ref page="common-app-platforms/" %}
18+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
---
2+
description: >-
3+
CircleCI Orbs are reusable bits of configuration, we've combined this with a
4+
standard Docker image to provide a turn key solution for CircleCI users. No
5+
need to modify your project at all.
6+
---
7+
8+
# CircleCI Orb
9+
10+
{% hint style="warning" %}
11+
In order to use the CircleCI Orb, you must first opt-in your organization to allow third party orbs within your Organization Security settings.
12+
13+
You can do this by going to **Settings** &gt; **Organization** &gt; **Security**
14+
{% endhint %}
15+
16+
Next, you will add our orb to your configuration by declaring it in your CircleCI configuration.
17+
18+
```yaml
19+
version: 2.1
20+
21+
orbs:
22+
packtracker: packtracker/[email protected]
23+
```
24+
25+
{% hint style="info" %}
26+
If you started using CircleCI prior to 2.1, you must enable pipelines within your project configuration to be able to use the `orbs` configuration.
27+
{% endhint %}
28+
29+
### Authentication
30+
31+
In order for us to know what project you are reporting stats for, you must send along your packtracker project token. To do this with the CircleCI Orb, you must create a new project environment variable in your CircleCI settings called `PT_PROJECT_TOKEN`. You can find your packtracker project token in your project's settings.
32+
33+
### Configuration
34+
35+
{% hint style="info" %}
36+
If you are not yet using [CircleCI Workflows](https://circleci.com/docs/2.0/workflows/), you will need to do so. If this is the case, you likely have a single `build` job in your CircleCI configuration. In order to add the packtracker `job` to your CI run, you will need to set up a [multi-job workflow as seen in this example configuration](https://circleci.com/docs/2.0/workflows/#workflows-configuration-examples).
37+
{% endhint %}
38+
39+
Now that you've declared our orb for use and added your project token, you have access to our `report` **job**. You can put this job anywhere inside your existing CircleCI workflows.
40+
41+
```yaml
42+
workflows:
43+
version: 2
44+
your_existing_workflow:
45+
jobs:
46+
- build
47+
- packtracker/report
48+
```
49+
50+
Or, create a new workflow to run packtracker reporting.
51+
52+
```yaml
53+
workflows:
54+
version: 2
55+
your_existing_workflow:
56+
jobs:
57+
- build
58+
packtracker:
59+
jobs:
60+
- packtracker/report
61+
```
62+
63+
By default, this base configuration should _just work_ most of the time. If you have a non-standard setup, you can tweak the job with the following 2 optional parameters.
64+
65+
| Parameter | Description |
66+
| :--- | :--- |
67+
| `project_root` | The relative path to the directory containing the `package.json` of your project. By default, this is the root of your repository. This can be especially useful for projects that do not live at the root of the repository, like lerna mono-repositories for example. |
68+
| `webpack_config` | The relative path to your webpack configuration. By default, it looks in the root directory for `webpack.config.js`. |
69+
70+
For example, a Ruby on Rails project might look something like this.
71+
72+
```yaml
73+
workflows:
74+
packtracker:
75+
jobs:
76+
- packtracker/report:
77+
webpack_config: "./config/webpack/production.js"
78+
79+
```
80+
81+
82+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
description: >-
3+
We also offer additional instruction for tools that use webpack, but might do
4+
so in their own proprietary way.
5+
---
6+
7+
# Common App Platforms
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
description: >-
3+
Create React App is a powerful, opinionated tool for bootstrapping a modern
4+
React web application.
5+
---
6+
7+
# Create React App
8+
9+
## For CircleCI or GitHub Actions Users
10+
11+
If you're using CircleCI or GitHub Actions, the packaged stat reporter for these integrations automatically handles the process of uploading the build stats of your Create React App application.
12+
13+
{% page-ref page="../circleci-orb.md" %}
14+
15+
{% page-ref page="../github-actions.md" %}
16+
17+
## Not using CircleCI or GitHub Actions?
18+
19+
{% hint style="danger" %}
20+
This documentation works **only for projects using Create React App 2.x**
21+
22+
Unfortunately they have removed the `--stats` flag in 3.x
23+
{% endhint %}
24+
25+
While the [Create React App](https://facebook.github.io/create-react-app/) project maintains great usability by hiding much of the ceremony of webpack behind it's own set of scripts, without ejecting you would otherwise not be able to use our service to track your bundle sizes.
26+
27+
To allow you to maintain your usage of the CRA scripts, we have provided a CLI tool along side our plugin that allows you to upload your stats to us as long as you have a static json stats file available.
28+
29+
You will still need to install our plugin in your project
30+
31+
```text
32+
npm install @packtracker/webpack-plugin
33+
```
34+
35+
The provided command, `packtracker-upload`, will upload your stats to our service from a static json file. Luckily, Create React App exposes this json via the `--stats` flag.
36+
37+
The only caveat to using the command \(instead of the plugin\) is that you **must** use environment variables to configure your stat reporting \(most importantly `PT_PROJECT_TOKEN`\).
38+
39+
{% hint style="info" %}
40+
See [our plugin documentation](https://github.com/packtracker/webpack-plugin#options) for a full list of configuration options available via environment variable.
41+
{% endhint %}
42+
43+
### Get your project token
44+
45+
After [creating your organization and project on packtracker.io](https://docs.packtracker.io/creating-your-first-project), grab your project token and assign it to `PT_PROJECT_TOKEN` as an environment variable.
46+
47+
```text
48+
export PT_PROJECT_TOKEN=your-project-token-here
49+
```
50+
51+
### **Creating the npm script to report your stats**
52+
53+
Now that your environment has your environment variable available. In your `package.json` you can add a npm script like the following
54+
55+
```text
56+
{
57+
"scripts": {
58+
"packtracker": "react-scripts build --stats && packtracker-upload --stats=build/bundle-stats.json"
59+
}
60+
}
61+
```
62+
63+
Then running `npm run packtracker` should upload your stats to our service
64+
65+
Once you've tested that you are all set up, be sure to set this script to run in your CI environment or on deployment of your application so we can track each and every commit.
66+
67+
68+
69+
70+

0 commit comments

Comments
 (0)