mirror of
https://github.com/zhigang1992/bundlewatch.git
synced 2026-01-12 08:54:09 +08:00
Rebrand
This commit is contained in:
@@ -37,8 +37,8 @@ jobs:
|
||||
when: always
|
||||
|
||||
- run:
|
||||
name: Run bundlesize in our CI for testing
|
||||
command: make bundlesize
|
||||
name: Run bundlewatch in our CI for testing
|
||||
command: make bundlewatch
|
||||
|
||||
- store_artifacts:
|
||||
path: artifacts
|
||||
|
||||
4
.github/ISSUE_TEMPLATE.md
vendored
4
.github/ISSUE_TEMPLATE.md
vendored
@@ -3,7 +3,7 @@
|
||||
|
||||
**Do you want to request a *feature* or report a *bug*?**
|
||||
|
||||
<!-- Please ask questions [on Slack](https://join.slack.com/t/bundlesize-bundlesize/shared_invite/enQtMzUwNjYxNTMwMzcyLWE5NGI4MzZjMjM4MTRlYzllOTMwYzIzZWNjM2MyMjBmMzNjNGM0ZGVhODc2YjFkNzIwMzNkYjk3NzE0MjZkOTc) -->
|
||||
<!-- Please ask questions [on Slack](https://join.slack.com/t/bundlewatch-bundlewatch/shared_invite/enQtMzUwNjYxNTMwMzcyLWE5NGI4MzZjMjM4MTRlYzllOTMwYzIzZWNjM2MyMjBmMzNjNGM0ZGVhODc2YjFkNzIwMzNkYjk3NzE0MjZkOTc) -->
|
||||
|
||||
**What is the current behavior?**
|
||||
|
||||
@@ -16,4 +16,4 @@
|
||||
|
||||
**If this is a feature request, what is motivation or use case for changing the behavior?**
|
||||
|
||||
**Please mention other relevant information such as the browser version, Node.js version, bundlesize version, and Operating System.**
|
||||
**Please mention other relevant information such as the browser version, Node.js version, bundlewatch version, and Operating System.**
|
||||
|
||||
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -10,7 +10,7 @@
|
||||
|
||||
**If relevant, link to documentation update:**
|
||||
|
||||
<!-- Link PR from bundlesize/bundlesize.io here, or N/A -->
|
||||
<!-- Link PR from bundlewatch/bundlewatch.io here, or N/A -->
|
||||
|
||||
**Summary**
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
This is a work in progress, watch this space
|
||||
|
||||
|
||||
When developing, its easier to run the below where flags it the CLI options you want to pass to bundlesize
|
||||
When developing, its easier to run the below where flags it the CLI options you want to pass to bundlewatch
|
||||
```
|
||||
make bundlesize FLAGS="--help"
|
||||
make bundlewatch FLAGS="--help"
|
||||
```
|
||||
|
||||
|
||||
If you need more information
|
||||
[hit us on Slack](https://join.slack.com/t/bundlesize-bundlesize/shared_invite/enQtMzUwNjYxNTMwMzcyLWE5NGI4MzZjMjM4MTRlYzllOTMwYzIzZWNjM2MyMjBmMzNjNGM0ZGVhODc2YjFkNzIwMzNkYjk3NzE0MjZkOTc)
|
||||
If you need more information
|
||||
[hit us on Slack](https://join.slack.com/t/bundlewatch-bundlewatch/shared_invite/enQtMzUwNjYxNTMwMzcyLWE5NGI4MzZjMjM4MTRlYzllOTMwYzIzZWNjM2MyMjBmMzNjNGM0ZGVhODc2YjFkNzIwMzNkYjk3NzE0MjZkOTc)
|
||||
|
||||
8
Makefile
8
Makefile
@@ -19,22 +19,22 @@ help:
|
||||
@echo "--------------------- Useful Commands for Development ----------------------"
|
||||
@echo "make help - show this help message"
|
||||
@echo "make install - install dependencies, blows up node_modules"
|
||||
@echo "make bundlesize - runs the bundlesize command in the project"
|
||||
@echo "make bundlewatch - runs the bundlewatch command in the project"
|
||||
@echo "make test - runs test"
|
||||
@echo "make test-watch - watches test"
|
||||
@echo "make test-snapshots - runs test and overwrites snapshots"
|
||||
@echo "make lint - runs eslint"
|
||||
@echo "make lint-fix - attempts to autofix linting errors"
|
||||
@echo "make watch - babelize locally for development"
|
||||
@echo "make package - package (babelize) bundlesize ready for distribution"
|
||||
@echo "make package - package (babelize) bundlewatch ready for distribution"
|
||||
|
||||
# ---- Installing, Building and Running ----
|
||||
|
||||
.PHONY: install
|
||||
install: check-versions clean node_modules
|
||||
|
||||
.PHONY: bundlesize
|
||||
bundlesize: package check-versions node_modules
|
||||
.PHONY: bundlewatch
|
||||
bundlewatch: package check-versions node_modules
|
||||
./lib/bin/index.js ${FLAGS}
|
||||
|
||||
ifndef CI
|
||||
|
||||
58
README.md
58
README.md
@@ -1,12 +1,12 @@
|
||||
<div align="center">
|
||||
<a href="http://bundlesize.io">
|
||||
<img src="https://cdn.rawgit.com/bundlesize/bundlesize.io/master/docs/_assets/logo-large.svg" height="100px">
|
||||
<a href="http://bundlewatch.io">
|
||||
<img src="https://cdn.rawgit.com/bundlewatch/bundlewatch.io/master/docs/_assets/logo-large.svg" height="100px">
|
||||
</a>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
[![npm][npm]][npm-url]
|
||||
[![bundlesize][bundlesize]][bundlesize-url]
|
||||
[![bundlewatch][bundlewatch]][bundlewatch-url]
|
||||
|
||||
[![node][node]][node-url]
|
||||
[![deps][deps]][deps-url]
|
||||
@@ -15,29 +15,29 @@
|
||||
|
||||
|
||||
<br>
|
||||
<a href="https://npmcharts.com/compare/@bundlesize/bundlesize?minimal=true">
|
||||
<img src="https://img.shields.io/npm/dm/@bundlesize/bundlesize.svg">
|
||||
<a href="https://npmcharts.com/compare/@bundlewatch/bundlewatch?minimal=true">
|
||||
<img src="https://img.shields.io/npm/dm/@bundlewatch/bundlewatch.svg">
|
||||
</a>
|
||||
<a href="https://github.com/bundlesize/bundlesize/graphs/contributors">
|
||||
<img src="https://img.shields.io/github/contributors/bundlesize/bundlesize.svg">
|
||||
<a href="https://github.com/bundlewatch/bundlewatch/graphs/contributors">
|
||||
<img src="https://img.shields.io/github/contributors/bundlewatch/bundlewatch.svg">
|
||||
</a>
|
||||
<h1>bundlesize</h1>
|
||||
<h1>bundlewatch</h1>
|
||||
<p>
|
||||
bundlesize is a file size checker. Its main purpose is to ensure bundled browser assets don't jump in file size. <br />
|
||||
Sharp increases in bundlesize can signal something is wrong: added a package that bloaded the slug, wrong import, forgot to minify.
|
||||
bundlewatch is a file size checker. Its main purpose is to ensure bundled browser assets don't jump in file size. <br />
|
||||
Sharp increases in bundlewatch can signal something is wrong: added a package that bloaded the slug, wrong import, forgot to minify.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
Inspired by [Siddharth Kshetrapal original Bundlesize](https://github.com/siddharthkp/bundlesize)
|
||||
Inspired by [Siddharth Kshetrapal bundlesize](https://github.com/siddharthkp/bundlesize)
|
||||
|
||||
# Getting Started and Configuration
|
||||
To get started with bundlesize, head over to the [documentation on bundlesize.io](http://bundlesize.io/)
|
||||
To get started with bundlewatch, head over to the [documentation on bundlewatch.io](http://bundlewatch.io/)
|
||||
|
||||
|
||||
|
||||
## Why the change in direction from the original?
|
||||
- The original bundlesize has entered maintenance mode, pull requests are left hanging, we wanted to reboost the community and start growing bundlesize out
|
||||
- Split store into seperate app -> bundlesize/service with infrastructure as code
|
||||
## Why the change in direction from bundlesize?
|
||||
- bundlesize has entered maintenance mode, pull requests are left hanging, we wanted to reboost the community and start growing bundlewatch out
|
||||
- Split store into seperate app -> bundlewatch/service with infrastructure as code
|
||||
- Launched documentation website
|
||||
- Enough test coverage to support CD
|
||||
- Node API Support
|
||||
@@ -45,32 +45,32 @@ To get started with bundlesize, head over to the [documentation on bundlesize.io
|
||||
|
||||
|
||||
### Additional features:
|
||||
- [x] Config validation to stop users guessing why bundlesize won't work
|
||||
- [x] Config validation to stop users guessing why bundlewatch won't work
|
||||
- [x] Better details breakdown
|
||||
- [x] Better comparisons between branches, support branches other than master
|
||||
- [x] Support for your own server for storing data
|
||||
- [x] New and improved CI behaviour
|
||||
- [ ] Show history of bundlesizes over time (Coming soon)
|
||||
- [ ] Show history of bundlewatchs over time (Coming soon)
|
||||
|
||||
|
||||
## Want to help?
|
||||
[See the Contributing docs](CONTRIBUTING.md) or [Join us on Slack](https://join.slack.com/t/bundlesize-bundlesize/shared_invite/enQtMzUwNjYxNTMwMzcyLWE5NGI4MzZjMjM4MTRlYzllOTMwYzIzZWNjM2MyMjBmMzNjNGM0ZGVhODc2YjFkNzIwMzNkYjk3NzE0MjZkOTc) and start contributing
|
||||
[See the Contributing docs](CONTRIBUTING.md) or [Join us on Slack](https://join.slack.com/t/bundlewatch-bundlewatch/shared_invite/enQtMzUwNjYxNTMwMzcyLWE5NGI4MzZjMjM4MTRlYzllOTMwYzIzZWNjM2MyMjBmMzNjNGM0ZGVhODc2YjFkNzIwMzNkYjk3NzE0MjZkOTc) and start contributing
|
||||
|
||||
|
||||
[npm]: https://img.shields.io/npm/v/@bundlesize/bundlesize.svg
|
||||
[npm-url]: https://npmjs.com/package/@bundlesize/bundlesize
|
||||
[npm]: https://img.shields.io/npm/v/@bundlewatch/bundlewatch.svg
|
||||
[npm-url]: https://npmjs.com/package/@bundlewatch/bundlewatch
|
||||
|
||||
[node]: https://img.shields.io/node/v/@bundlesize/bundlesize.svg
|
||||
[node]: https://img.shields.io/node/v/@bundlewatch/bundlewatch.svg
|
||||
[node-url]: https://nodejs.org
|
||||
|
||||
[bundlesize]: https://img.shields.io/badge/bundlesize-checked-green.svg
|
||||
[bundlesize-url]: http://bundlesize.io
|
||||
[bundlewatch]: https://img.shields.io/badge/bundlewatch-checked-green.svg
|
||||
[bundlewatch-url]: http://bundlewatch.io
|
||||
|
||||
[deps]: https://img.shields.io/david/bundlesize/bundlesize.svg
|
||||
[deps-url]: https://david-dm.org/bundlesize/bundlesize
|
||||
[deps]: https://img.shields.io/david/bundlewatch/bundlewatch.svg
|
||||
[deps-url]: https://david-dm.org/bundlewatch/bundlewatch
|
||||
|
||||
[builds]: https://img.shields.io/circleci/project/github/bundlesize/bundlesize.svg
|
||||
[builds-url]: https://circleci.com/gh/bundlesize/bundlesize
|
||||
[builds]: https://img.shields.io/circleci/project/github/bundlewatch/bundlewatch.svg
|
||||
[builds-url]: https://circleci.com/gh/bundlewatch/bundlewatch
|
||||
|
||||
[licenses]: https://img.shields.io/npm/l/@bundlesize/bundlesize.svg
|
||||
[licenses-url]: https://github.com/bundlesize/bundlesize/blob/master/LICENSE
|
||||
[licenses]: https://img.shields.io/npm/l/@bundlewatch/bundlewatch.svg
|
||||
[licenses-url]: https://github.com/bundlewatch/bundlewatch/blob/master/LICENSE
|
||||
|
||||
10
package.json
10
package.json
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"name": "bundlewatch",
|
||||
"version": "0.0.0",
|
||||
"description": "Keep your library size in check",
|
||||
"description": "Keep watch of your bundle size",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/bundlesize/bundlesize.git"
|
||||
"url": "git+https://github.com/bundlewatch/bundlewatch.git"
|
||||
},
|
||||
"main": "lib/index.js",
|
||||
"bin": {
|
||||
"bundlesize": "lib/bin/index.js"
|
||||
"bundlewatch": "lib/bin/index.js"
|
||||
},
|
||||
"files": [
|
||||
"lib"
|
||||
@@ -28,7 +28,7 @@
|
||||
"build",
|
||||
"maxSize"
|
||||
],
|
||||
"author": "bundlesize",
|
||||
"author": "bundlewatch",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"axios": "^0.18.0",
|
||||
@@ -66,7 +66,7 @@
|
||||
"engines": {
|
||||
"node": ">=6.11.5"
|
||||
},
|
||||
"bundlesize": {
|
||||
"bundlewatch": {
|
||||
"files": [
|
||||
{
|
||||
"path": "./__testdata__/*.jpg",
|
||||
|
||||
@@ -20,7 +20,7 @@ echo "Deploying...."
|
||||
echo '//registry.npmjs.org/:_authToken=${NPM_PUBLISH_TOKEN}' > .npmrc
|
||||
|
||||
PACKAGE_VERSION_JSON=package.json
|
||||
PACKAGE_VERSION_NPM=@bundlesize/bundlesize
|
||||
PACKAGE_VERSION_NPM=@bundlewatch/bundlewatch
|
||||
|
||||
jq ".version=\"$version\"" $PACKAGE_VERSION_JSON > $PACKAGE_VERSION_JSON.tmp
|
||||
mv $PACKAGE_VERSION_JSON.tmp $PACKAGE_VERSION_JSON
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`bundlesize Node API Works when files dont exist, shows warning 1`] = `
|
||||
exports[`bundlewatch Node API Works when files dont exist, shows warning 1`] = `
|
||||
Object {
|
||||
"fullResults": Array [
|
||||
Object {
|
||||
@@ -14,7 +14,7 @@ Object {
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`bundlesize Node API Works with CI environment 1`] = `
|
||||
exports[`bundlewatch Node API Works with CI environment 1`] = `
|
||||
Object {
|
||||
"fullResults": Array [
|
||||
Object {
|
||||
@@ -47,7 +47,7 @@ Object {
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`bundlesize Node API Works with basic options 1`] = `
|
||||
exports[`bundlewatch Node API Works with basic options 1`] = `
|
||||
Object {
|
||||
"fullResults": Array [
|
||||
Object {
|
||||
|
||||
@@ -49,7 +49,7 @@ const ciEnv = () => {
|
||||
}
|
||||
|
||||
const githubAccessToken =
|
||||
process.env.GITHUB_ACCESS_TOKEN || process.env.BUNDLESIZE_GITHUB_TOKEN
|
||||
process.env.GITHUB_ACCESS_TOKEN || process.env.BUNDLEWATCH_GITHUB_TOKEN
|
||||
|
||||
repoBranchBase = env.CI_BRANCH_BASE
|
||||
|
||||
|
||||
@@ -40,19 +40,19 @@ const ensureValid = config => {
|
||||
)
|
||||
|
||||
if (missingOptions.length === 0) {
|
||||
if (!config.bundlesizeServiceHost) {
|
||||
logger.warn(`bundlesizeServiceHost was not supplied, bundlesize comparisons unavilable:
|
||||
Learn more at: http://bundlesize.io/#/getting-started/the-best-parts
|
||||
if (!config.bundlewatchServiceHost) {
|
||||
logger.warn(`bundlewatchServiceHost was not supplied, bundlewatch comparisons unavilable:
|
||||
Learn more at: http://bundlewatch.io/#/getting-started/the-best-parts
|
||||
`)
|
||||
} else {
|
||||
if (!config.ci.repoBranchBase) {
|
||||
logger.warn(`The ci.repoBranchCase was not supplied, bundlesize comparisons unavailable:
|
||||
Learn more at: http://bundlesize.io/#/getting-started/the-best-parts
|
||||
logger.warn(`The ci.repoBranchCase was not supplied, bundlewatch comparisons unavailable:
|
||||
Learn more at: http://bundlewatch.io/#/getting-started/the-best-parts
|
||||
`)
|
||||
}
|
||||
if (!config.ci.repoCurrentBranch) {
|
||||
logger.warn(`The ci.repoCurrentBranch was not supplied, bundlesize results with not be saved:
|
||||
Learn more at: http://bundlesize.io/#/getting-started/the-best-parts
|
||||
logger.warn(`The ci.repoCurrentBranch was not supplied, bundlewatch results with not be saved:
|
||||
Learn more at: http://bundlewatch.io/#/getting-started/the-best-parts
|
||||
`)
|
||||
}
|
||||
}
|
||||
@@ -60,8 +60,8 @@ const ensureValid = config => {
|
||||
logger.warn(`Some CI configuration options were not found (${missingOptions.join(
|
||||
', ',
|
||||
)}):
|
||||
bundlesize will be unable to report build status, or save comparison data
|
||||
Learn more at: http://bundlesize.io/#/getting-started/the-best-parts
|
||||
bundlewatch will be unable to report build status, or save comparison data
|
||||
Learn more at: http://bundlewatch.io/#/getting-started/the-best-parts
|
||||
`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import ensureValid from './ensureValid'
|
||||
|
||||
const defaultConfig = {
|
||||
files: [],
|
||||
bundlesizeServiceHost: 'https://service.bundlesize.io', // Can be a custom service, or set to NUll
|
||||
bundlewatchServiceHost: 'https://service.bundlewatch.io', // Can be a custom service, or set to NUll
|
||||
ci: {
|
||||
githubAccessToken: ciEnv.githubAccessToken,
|
||||
repoOwner: ciEnv.repoOwner,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import getLocalFileDetails from './getLocalFileDetails'
|
||||
import BundlesizeService from './reporting/BundlesizeService'
|
||||
import BundleWatchService from './reporting/BundleWatchService'
|
||||
import GitHubService from './reporting/GitHubService'
|
||||
import analyze from './analyze'
|
||||
import { STATUSES } from './analyze/analyzeFiles'
|
||||
@@ -8,7 +8,7 @@ import createURLToResultPage from './resultsPage/createURL'
|
||||
|
||||
const main = async ({
|
||||
files,
|
||||
bundlesizeServiceHost,
|
||||
bundlewatchServiceHost,
|
||||
ci,
|
||||
defaultCompression,
|
||||
}) => {
|
||||
@@ -17,18 +17,18 @@ const main = async ({
|
||||
defaultCompression: defaultCompression,
|
||||
})
|
||||
|
||||
const bundlesizeService = new BundlesizeService({
|
||||
const bundlewatchService = new BundleWatchService({
|
||||
repoOwner: ci.repoOwner,
|
||||
repoName: ci.repoName,
|
||||
repoCurrentBranch: ci.repoCurrentBranch,
|
||||
repoBranchBase: ci.repoBranchBase,
|
||||
commitSha: ci.commitSha,
|
||||
bundlesizeServiceHost,
|
||||
bundlewatchServiceHost,
|
||||
githubAccessToken: ci.githubAccessToken,
|
||||
})
|
||||
|
||||
const baseBranchFileDetails = await bundlesizeService.getFileDetailsForBaseBranch()
|
||||
await bundlesizeService.saveFileDetailsForCurrentBranch({
|
||||
const baseBranchFileDetails = await bundlewatchService.getFileDetailsForBaseBranch()
|
||||
await bundlewatchService.saveFileDetailsForCurrentBranch({
|
||||
fileDetailsByPath: currentBranchFileDetails,
|
||||
trackBranches: ci.trackBranches,
|
||||
})
|
||||
@@ -41,7 +41,7 @@ const main = async ({
|
||||
|
||||
const url = await createURLToResultPage({
|
||||
results,
|
||||
bundlesizeServiceHost,
|
||||
bundlewatchServiceHost,
|
||||
repoOwner: ci.repoOwner,
|
||||
repoName: ci.repoName,
|
||||
repoCurrentBranch: ci.repoCurrentBranch,
|
||||
@@ -55,7 +55,7 @@ const main = async ({
|
||||
}
|
||||
}
|
||||
|
||||
const bundleSizeApi = async customConfig => {
|
||||
const bundlewatchApi = async customConfig => {
|
||||
const config = getConfig(customConfig)
|
||||
const githubService = new GitHubService({
|
||||
repoOwner: config.ci.repoOwner,
|
||||
@@ -63,7 +63,7 @@ const bundleSizeApi = async customConfig => {
|
||||
commitSha: config.ci.commitSha,
|
||||
githubAccessToken: config.ci.githubAccessToken,
|
||||
})
|
||||
await githubService.start({ message: 'Checking bundlesize...' })
|
||||
await githubService.start({ message: 'Checking bundlewatch...' })
|
||||
|
||||
try {
|
||||
const results = await main(config)
|
||||
@@ -100,5 +100,5 @@ const bundleSizeApi = async customConfig => {
|
||||
}
|
||||
}
|
||||
|
||||
export default bundleSizeApi
|
||||
export default bundlewatchApi
|
||||
export { STATUSES }
|
||||
|
||||
@@ -3,11 +3,11 @@ import MockAdapter from 'axios-mock-adapter'
|
||||
|
||||
const networkMock = new MockAdapter(axios)
|
||||
|
||||
import bundlesizeApi from '.'
|
||||
import bundlewatchApi from '.'
|
||||
|
||||
describe(`bundlesize Node API`, () => {
|
||||
describe(`bundlewatch Node API`, () => {
|
||||
it('Works with basic options', async () => {
|
||||
const result = await bundlesizeApi({
|
||||
const result = await bundlewatchApi({
|
||||
files: [
|
||||
{
|
||||
path: './__testdata__/*.jpg',
|
||||
@@ -24,7 +24,7 @@ describe(`bundlesize Node API`, () => {
|
||||
})
|
||||
|
||||
it(`Works when files dont exist, shows warning`, async () => {
|
||||
const result = await bundlesizeApi({
|
||||
const result = await bundlewatchApi({
|
||||
files: [
|
||||
{
|
||||
path: './__testdata__/test-file-doesnt-exist.jpg',
|
||||
@@ -48,7 +48,7 @@ describe(`bundlesize Node API`, () => {
|
||||
}
|
||||
|
||||
networkMock
|
||||
.onPost('https://service.bundlesize.io/store/lookup')
|
||||
.onPost('https://service.bundlewatch.io/store/lookup')
|
||||
.reply(200, {
|
||||
fileDetailsByPath: {
|
||||
'./__testdata__/test-file-1.jpg': {
|
||||
@@ -64,7 +64,7 @@ describe(`bundlesize Node API`, () => {
|
||||
|
||||
// TODO: assert save was called
|
||||
|
||||
const result = await bundlesizeApi({
|
||||
const result = await bundlewatchApi({
|
||||
files: [
|
||||
{
|
||||
path: './__testdata__/*.jpg',
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import logger from '../../../logger'
|
||||
import axios from 'axios'
|
||||
|
||||
class BundlesizeService {
|
||||
class bundlewatchService {
|
||||
constructor({
|
||||
repoOwner,
|
||||
repoName,
|
||||
repoBranchBase,
|
||||
repoCurrentBranch,
|
||||
commitSha,
|
||||
bundlesizeServiceHost,
|
||||
bundlewatchServiceHost,
|
||||
githubAccessToken,
|
||||
}) {
|
||||
this.repoOwner = repoOwner
|
||||
@@ -16,12 +16,12 @@ class BundlesizeService {
|
||||
this.repoBranchBase = repoBranchBase
|
||||
this.repoCurrentBranch = repoCurrentBranch
|
||||
this.commitSha = commitSha
|
||||
this.bundlesizeServiceHost = bundlesizeServiceHost
|
||||
this.bundlewatchServiceHost = bundlewatchServiceHost
|
||||
this.githubAccessToken = githubAccessToken
|
||||
}
|
||||
|
||||
get bundlesizeServiceStoreUrl() {
|
||||
return `${this.bundlesizeServiceHost}/store`
|
||||
get bundlewatchServiceStoreUrl() {
|
||||
return `${this.bundlewatchServiceHost}/store`
|
||||
}
|
||||
|
||||
get enabled() {
|
||||
@@ -29,7 +29,7 @@ class BundlesizeService {
|
||||
this.githubAccessToken &&
|
||||
this.repoOwner &&
|
||||
this.repoName &&
|
||||
this.bundlesizeServiceHost
|
||||
this.bundlewatchServiceHost
|
||||
) {
|
||||
return true
|
||||
}
|
||||
@@ -46,7 +46,7 @@ class BundlesizeService {
|
||||
|
||||
return axios
|
||||
.post(
|
||||
`${this.bundlesizeServiceStoreUrl}/lookup`,
|
||||
`${this.bundlewatchServiceStoreUrl}/lookup`,
|
||||
{
|
||||
repoOwner: this.repoOwner,
|
||||
repoName: this.repoName,
|
||||
@@ -67,7 +67,7 @@ class BundlesizeService {
|
||||
`Unable to fetch fileDetails for baseBranch=${
|
||||
this.repoBranchBase
|
||||
} from ${
|
||||
this.bundlesizeServiceStoreUrl
|
||||
this.bundlewatchServiceStoreUrl
|
||||
} code=${error.code || error.message}`,
|
||||
)
|
||||
return {}
|
||||
@@ -103,7 +103,7 @@ class BundlesizeService {
|
||||
|
||||
return axios
|
||||
.post(
|
||||
`${this.bundlesizeServiceStoreUrl}`,
|
||||
`${this.bundlewatchServiceStoreUrl}`,
|
||||
{
|
||||
repoOwner: this.repoOwner,
|
||||
repoName: this.repoName,
|
||||
@@ -127,4 +127,4 @@ class BundlesizeService {
|
||||
}
|
||||
}
|
||||
|
||||
export default BundlesizeService
|
||||
export default bundlewatchService
|
||||
@@ -3,7 +3,7 @@ import axios from 'axios'
|
||||
import logger from '../../../logger'
|
||||
|
||||
const getContextForFilePath = filePath => {
|
||||
let context = 'bundlesize'
|
||||
let context = 'bundlewatch'
|
||||
if (filePath) {
|
||||
const TRUNCATE_TO_LENGTH = 35
|
||||
if (filePath.length > TRUNCATE_TO_LENGTH) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import shortenURL from './shortenURL'
|
||||
|
||||
const createURL = async ({
|
||||
results,
|
||||
bundlesizeServiceHost,
|
||||
bundlewatchServiceHost,
|
||||
repoOwner,
|
||||
repoName,
|
||||
repoCurrentBranch,
|
||||
@@ -29,7 +29,7 @@ const createURL = async ({
|
||||
results: strippedResultsForURL,
|
||||
})
|
||||
const urlResultData = encodeURIComponent(packedJSON)
|
||||
const longURL = `${bundlesizeServiceHost}/results?d=${urlResultData}`
|
||||
const longURL = `${bundlewatchServiceHost}/results?d=${urlResultData}`
|
||||
const shortURL = await shortenURL(longURL)
|
||||
return shortURL
|
||||
}
|
||||
|
||||
@@ -53,10 +53,10 @@ const getConfigFileContents = configFilePath => {
|
||||
|
||||
const determineConfig = cliOptions => {
|
||||
const pkgJson = readPkgUp.sync().pkg
|
||||
let pkgJsonBundlesize = pkgJson.bundlesize
|
||||
let pkgJsonbundlewatch = pkgJson.bundlewatch
|
||||
|
||||
if (cliOptions.args && cliOptions.args.length > 0) {
|
||||
if (pkgJsonBundlesize) {
|
||||
if (pkgJsonbundlewatch) {
|
||||
logger.warn(
|
||||
`CLI files supplied, config in package.json will be ignored`,
|
||||
)
|
||||
@@ -81,7 +81,7 @@ const determineConfig = cliOptions => {
|
||||
}
|
||||
|
||||
if (cliOptions.config) {
|
||||
if (pkgJsonBundlesize) {
|
||||
if (pkgJsonbundlewatch) {
|
||||
logger.warn(
|
||||
`configFilePath supplied, config in package.json will be ignored`,
|
||||
)
|
||||
@@ -89,13 +89,13 @@ const determineConfig = cliOptions => {
|
||||
return getConfigFileContents(cliOptions.config)
|
||||
}
|
||||
|
||||
if (pkgJsonBundlesize) {
|
||||
if (Array.isArray(pkgJsonBundlesize)) {
|
||||
if (pkgJsonbundlewatch) {
|
||||
if (Array.isArray(pkgJsonbundlewatch)) {
|
||||
return {
|
||||
files: pkgJsonBundlesize,
|
||||
files: pkgJsonbundlewatch,
|
||||
}
|
||||
}
|
||||
return pkgJsonBundlesize
|
||||
return pkgJsonbundlewatch
|
||||
}
|
||||
|
||||
return {}
|
||||
|
||||
@@ -5,7 +5,7 @@ import chalk from 'chalk'
|
||||
|
||||
import determineConfig from './determineConfig'
|
||||
import logger from '../logger'
|
||||
import bundlesizeApi, { STATUSES } from '../app'
|
||||
import bundlewatchApi, { STATUSES } from '../app'
|
||||
|
||||
const prettyPrintResults = fullResults => {
|
||||
logger.log('')
|
||||
@@ -40,7 +40,7 @@ const main = async () => {
|
||||
const config = determineConfig(program)
|
||||
|
||||
if (config.files && config.files.length > 0) {
|
||||
const results = await bundlesizeApi(config)
|
||||
const results = await bundlewatchApi(config)
|
||||
|
||||
if (results.url) {
|
||||
logger.log('')
|
||||
@@ -52,20 +52,20 @@ const main = async () => {
|
||||
prettyPrintResults(results.fullResults)
|
||||
|
||||
if (results.status === STATUSES.FAIL) {
|
||||
logger.log(chalk.redBright(`bundlesize FAIL`))
|
||||
logger.log(chalk.redBright(`bundlewatch FAIL`))
|
||||
logger.log(results.summary)
|
||||
logger.log('')
|
||||
return 1
|
||||
}
|
||||
|
||||
if (results.status === STATUSES.WARN) {
|
||||
logger.log(chalk.redBright(`bundlesize WARN`))
|
||||
logger.log(chalk.redBright(`bundlewatch WARN`))
|
||||
logger.log(results.summary)
|
||||
logger.log('')
|
||||
return 0
|
||||
}
|
||||
|
||||
logger.log(chalk.greenBright(`bundlesize PASS`))
|
||||
logger.log(chalk.greenBright(`bundlewatch PASS`))
|
||||
logger.log(results.summary)
|
||||
logger.log('')
|
||||
|
||||
@@ -73,8 +73,8 @@ const main = async () => {
|
||||
}
|
||||
|
||||
logger.error(`Configuration missing:
|
||||
Run ${chalk.italic('bundlesize --help')} for examples and options
|
||||
Documentation available at: http://bundlesize.io/`)
|
||||
Run ${chalk.italic('bundlewatch --help')} for examples and options
|
||||
Documentation available at: http://bundlewatch.io/`)
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -110,13 +110,13 @@ program.on('--help', () => {
|
||||
logger.log(' Examples:')
|
||||
logger.log('')
|
||||
logger.log(' Read configuration from package.json')
|
||||
logger.log(' $ bundlesize ')
|
||||
logger.log(' $ bundlewatch ')
|
||||
logger.log('')
|
||||
logger.log(' Read configuration from file')
|
||||
logger.log(' $ bundlesize --config internals/bundlesize.config.js')
|
||||
logger.log(' $ bundlewatch --config internals/bundlewatch.config.js')
|
||||
logger.log('')
|
||||
logger.log(' Use command line')
|
||||
logger.log(' $ bundlesize --max-size 100KB ./src/*.js /lib/*.js')
|
||||
logger.log(' $ bundlewatch --max-size 100KB ./src/*.js /lib/*.js')
|
||||
logger.log('')
|
||||
logger.log('')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user