-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
5,987 additions
and
6,552 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,6 @@ yarn-error.log | |
# Serverless directories | ||
.serverless | ||
cache | ||
tsconfig.tsbuildinfo | ||
logs | ||
version-packs.sh |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
undecided: | ||
- package-build-stats-monorepo | ||
- package-build-stats-cli | ||
- parcel-reporter-package-build-stats | ||
- parcel-resolver-package-build-stats |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env node | ||
|
||
const oclif = require('@oclif/core') | ||
|
||
const path = require('path') | ||
const project = path.join(__dirname, '..', 'tsconfig.json') | ||
|
||
// In dev mode -> use ts-node and dev plugins | ||
process.env.NODE_ENV = 'development' | ||
|
||
require('ts-node').register({project}) | ||
|
||
// In dev mode, always show stack traces | ||
oclif.settings.debug = true; | ||
|
||
// Start the CLI | ||
oclif.run().then(oclif.flush).catch(oclif.Errors.handle) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@echo off | ||
|
||
node "%~dp0\dev" %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env node | ||
|
||
const oclif = require('@oclif/core') | ||
|
||
oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@echo off | ||
|
||
node "%~dp0\run" %* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"name": "package-build-stats-cli", | ||
"version": "0.0.1", | ||
"description": "Calculate the package size of an npm library", | ||
"author": "Shubham Kanodia @pastelsky", | ||
"bin": "./bin/run", | ||
"homepage": "https://github.com/pastelsky/package-build-stats", | ||
"license": "MIT", | ||
"main": "dist/index.js", | ||
"repository": "https://github.com/pastelsky/package-build-stats", | ||
"files": [ | ||
"/bin", | ||
"/dist", | ||
"/npm-shrinkwrap.json", | ||
"/oclif.manifest.json" | ||
], | ||
"dependencies": { | ||
"@oclif/core": "^1", | ||
"@oclif/plugin-help": "^5", | ||
"@oclif/plugin-plugins": "^2.0.1", | ||
"purdy": "^3.5.1" | ||
}, | ||
"devDependencies": { | ||
"@oclif/test": "^2", | ||
"@types/chai": "^4", | ||
"@types/mocha": "^9.0.0", | ||
"@types/node": "^16.9.4", | ||
"@types/purdy": "^3", | ||
"oclif": "^2", | ||
"shx": "^0.3.3", | ||
"ts-node": "^10.2.1", | ||
"tslib": "^2.3.1", | ||
"typescript": "^4.4.3" | ||
}, | ||
"oclif": { | ||
"bin": "npmsize ", | ||
"dirname": "npmsize ", | ||
"commands": "./dist/commands", | ||
"plugins": [ | ||
"@oclif/plugin-help" | ||
], | ||
"topicSeparator": " ", | ||
"topics": { | ||
"hello": { | ||
"description": "Say hello to the world and others" | ||
} | ||
} | ||
}, | ||
"scripts": { | ||
"build": "shx rm -rf dist && tsc -b", | ||
"lint": "eslint . --ext .ts --config .eslintrc", | ||
"postpack": "shx rm -f oclif.manifest.json", | ||
"posttest": "yarn lint", | ||
"prepack": "yarn build && oclif manifest && oclif readme", | ||
"test": "mocha --forbid-only \"test/**/*.test.ts\"", | ||
"version": "oclif readme && git add README.md" | ||
}, | ||
"engines": { | ||
"node": ">=12.0.0" | ||
}, | ||
"bugs": "https://github.com/pastelsky/package-build-stats/issues", | ||
"keywords": [ | ||
"oclif" | ||
], | ||
"types": "dist/index.d.ts" | ||
} |
66 changes: 66 additions & 0 deletions
66
packages/package-build-stats-cli/src/commands/export-sizes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { Command, Flags } from '@oclif/core' | ||
import { getPackageExportSizes } from 'package-build-stats' | ||
import Purdy from 'purdy' | ||
|
||
export default class ExportSizes extends Command { | ||
static description = 'Get export sizes of a package' | ||
|
||
static examples = [`$ npmsize export-sizes package-name`] | ||
|
||
static args = [ | ||
{ | ||
name: 'package', | ||
description: 'Name / Version of the NPM package', | ||
required: true, | ||
}, | ||
] | ||
|
||
static flags = { | ||
client: Flags.string({ | ||
char: 'p', | ||
description: 'Which npm package manager to use', | ||
required: false, | ||
options: ['npm', 'yarn', 'pnpm'], | ||
}), | ||
customImports: Flags.string({ | ||
char: 'i', | ||
description: 'Comma separated custom imports', | ||
required: false, | ||
}), | ||
debug: Flags.boolean({ | ||
char: 'd', | ||
description: 'Debug builds', | ||
required: false, | ||
}), | ||
limitConcurrency: Flags.boolean({ | ||
char: 'c', | ||
description: 'Limit concurrency', | ||
required: false, | ||
}), | ||
networkConcurrency: Flags.integer({ | ||
char: 'n', | ||
description: 'Network concurrency', | ||
required: false, | ||
}), | ||
installTimeout: Flags.integer({ | ||
char: 't', | ||
description: 'Install timeout in ms', | ||
required: false, | ||
}), | ||
} | ||
|
||
async run(): Promise<void> { | ||
const { args, flags } = await this.parse(ExportSizes) | ||
const result = await getPackageExportSizes(args.package, { | ||
// @ts-ignore - convert string to enum | ||
client: flags.client, | ||
limitConcurrency: flags.limitConcurrency, | ||
networkConcurrency: flags.networkConcurrency, | ||
debug: flags.debug, | ||
customImports: flags.customImports?.split(','), | ||
installTimeout: flags.installTimeout, | ||
}) | ||
|
||
Purdy(result, {}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { Command, Flags } from '@oclif/core' | ||
import { getAllPackageExports } from 'package-build-stats' | ||
import Purdy from 'purdy' | ||
|
||
export default class Total extends Command { | ||
static description = 'Total bundled size of an NPM package' | ||
|
||
static examples = [`$ npmsize exports package-name`] | ||
|
||
static args = [ | ||
{ | ||
name: 'package', | ||
description: 'Name / Version of the NPM package', | ||
required: true, | ||
}, | ||
] | ||
|
||
static flags = { | ||
client: Flags.string({ | ||
char: 'p', | ||
description: 'Which npm package manager to use', | ||
required: false, | ||
options: ['npm', 'yarn', 'pnpm'], | ||
}), | ||
limitConcurrency: Flags.boolean({ | ||
char: 'c', | ||
description: 'Limit concurrency', | ||
required: false, | ||
}), | ||
networkConcurrency: Flags.integer({ | ||
char: 'n', | ||
description: 'Network concurrency', | ||
required: false, | ||
}), | ||
local: Flags.boolean({ | ||
char: 'l', | ||
description: 'Get exports of a local package', | ||
required: false, | ||
}), | ||
installTimeout: Flags.integer({ | ||
char: 't', | ||
description: 'Install timeout in ms', | ||
required: false, | ||
}), | ||
} | ||
|
||
async run(): Promise<void> { | ||
const { args, flags } = await this.parse(Total) | ||
const result = await getAllPackageExports(args.package, { | ||
// @ts-ignore - convert string to enum | ||
client: flags.client, | ||
limitConcurrency: flags.limitConcurrency, | ||
networkConcurrency: flags.networkConcurrency, | ||
isLocal: flags.local, | ||
installTimeout: flags.installTimeout, | ||
}) | ||
|
||
Purdy(result, {}) | ||
} | ||
} |
Oops, something went wrong.