mirror of
https://github.com/matheus23/elmjs-inspect.git
synced 2024-09-11 11:25:45 +03:00
Merge pull request #2 from miniBill/master
Use commander to build a minimal CLI
This commit is contained in:
commit
afd01fedc0
14
README.md
14
README.md
@ -1,8 +1,14 @@
|
||||
# elmjs-inspect
|
||||
|
||||
## Running it
|
||||
|
||||
```sh
|
||||
npm build
|
||||
node dist/index.js analyse <filename>
|
||||
```
|
||||
|
||||
## TODO
|
||||
|
||||
* Wrap with CLI stuff (commander?)
|
||||
* Allow giving .js file by options or otherwise by file input (inquirer.js?)
|
||||
* Show results by package/module/file level
|
||||
* NPM Publish
|
||||
- Allow giving .js file by options or otherwise by file input (inquirer.js?)
|
||||
- Show results by package/module/file level
|
||||
- NPM Publish
|
||||
|
132
package-lock.json
generated
Normal file
132
package-lock.json
generated
Normal file
@ -0,0 +1,132 @@
|
||||
{
|
||||
"name": "sizes",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "sizes",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"esprima": "^4.0.1",
|
||||
"node-estree": "^3.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/esprima": "^4.0.2",
|
||||
"@types/estree": "^0.0.51",
|
||||
"@types/node": "^13.11.0",
|
||||
"typescript": "^3.8.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@slimio/is": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@slimio/is/-/is-1.5.1.tgz",
|
||||
"integrity": "sha512-xQ0AgodIE8nHYy508AVmpxqnIr/Ytyz5Xm7I6NQU33+RvDzs94T9c0dTnUWuariByLr1geXXe6kMaTM9TcOIEA==",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/esprima": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/esprima/-/esprima-4.0.2.tgz",
|
||||
"integrity": "sha512-DKqdyuy7Go7ir6iKhZ0jUvgt/h9Q5zb9xS+fLeeXD2QSHv8gC6TimgujBBGfw8dHrpx4+u2HlMv7pkYOOfuUqg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/estree": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/estree": {
|
||||
"version": "0.0.51",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.51.tgz",
|
||||
"integrity": "sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "13.11.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-13.11.0.tgz",
|
||||
"integrity": "sha512-uM4mnmsIIPK/yeO+42F2RQhGUIs39K2RFmugcJANppXe6J1nvH87PvzPZYpza7Xhhs8Yn9yIAVdLZ84z61+0xQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/esprima": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
|
||||
"bin": {
|
||||
"esparse": "bin/esparse.js",
|
||||
"esvalidate": "bin/esvalidate.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/node-estree": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/node-estree/-/node-estree-3.1.0.tgz",
|
||||
"integrity": "sha512-Au8RrdfNCbvzT3/POUQjQnArLGpqXpuLrK0fU0acGSynjRA1CFWQ6mExO8HPR7mc9Q4RqemNJg/yTvm3E2nBqw==",
|
||||
"dependencies": {
|
||||
"@slimio/is": "^1.5.1"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "3.8.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz",
|
||||
"integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.2.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@slimio/is": {
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@slimio/is/-/is-1.5.1.tgz",
|
||||
"integrity": "sha512-xQ0AgodIE8nHYy508AVmpxqnIr/Ytyz5Xm7I6NQU33+RvDzs94T9c0dTnUWuariByLr1geXXe6kMaTM9TcOIEA=="
|
||||
},
|
||||
"@types/esprima": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/esprima/-/esprima-4.0.2.tgz",
|
||||
"integrity": "sha512-DKqdyuy7Go7ir6iKhZ0jUvgt/h9Q5zb9xS+fLeeXD2QSHv8gC6TimgujBBGfw8dHrpx4+u2HlMv7pkYOOfuUqg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/estree": "*"
|
||||
}
|
||||
},
|
||||
"@types/estree": {
|
||||
"version": "0.0.51",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.51.tgz",
|
||||
"integrity": "sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "13.11.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-13.11.0.tgz",
|
||||
"integrity": "sha512-uM4mnmsIIPK/yeO+42F2RQhGUIs39K2RFmugcJANppXe6J1nvH87PvzPZYpza7Xhhs8Yn9yIAVdLZ84z61+0xQ==",
|
||||
"dev": true
|
||||
},
|
||||
"esprima": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A=="
|
||||
},
|
||||
"node-estree": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/node-estree/-/node-estree-3.1.0.tgz",
|
||||
"integrity": "sha512-Au8RrdfNCbvzT3/POUQjQnArLGpqXpuLrK0fU0acGSynjRA1CFWQ6mExO8HPR7mc9Q4RqemNJg/yTvm3E2nBqw==",
|
||||
"requires": {
|
||||
"@slimio/is": "^1.5.1"
|
||||
}
|
||||
},
|
||||
"typescript": {
|
||||
"version": "3.8.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz",
|
||||
"integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
@ -2,6 +2,9 @@
|
||||
"name": "sizes",
|
||||
"version": "1.0.0",
|
||||
"main": "src/index.ts",
|
||||
"bin": {
|
||||
"elmjs-inspector": "src/index.ts"
|
||||
},
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"repl": "ts-node --project .",
|
||||
@ -10,10 +13,13 @@
|
||||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@types/esprima": "^4.0.2",
|
||||
"@types/estree": "^0.0.51",
|
||||
"@types/node": "^13.11.0",
|
||||
"typescript": "^3.8.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"esprima": "^4.0.1"
|
||||
"commander": "^9.2.0",
|
||||
"esprima": "^4.0.1",
|
||||
"node-estree": "^3.1.0"
|
||||
}
|
||||
}
|
65
pnpm-lock.yaml
Normal file
65
pnpm-lock.yaml
Normal file
@ -0,0 +1,65 @@
|
||||
lockfileVersion: 5.4
|
||||
|
||||
specifiers:
|
||||
'@types/esprima': ^4.0.2
|
||||
'@types/estree': ^0.0.51
|
||||
'@types/node': ^13.11.0
|
||||
commander: ^9.2.0
|
||||
esprima: ^4.0.1
|
||||
node-estree: ^3.1.0
|
||||
typescript: ^3.8.3
|
||||
|
||||
dependencies:
|
||||
commander: 9.2.0
|
||||
esprima: 4.0.1
|
||||
node-estree: 3.1.0
|
||||
|
||||
devDependencies:
|
||||
'@types/esprima': 4.0.3
|
||||
'@types/estree': 0.0.51
|
||||
'@types/node': 13.13.52
|
||||
typescript: 3.9.10
|
||||
|
||||
packages:
|
||||
|
||||
/@slimio/is/1.5.1:
|
||||
resolution: {integrity: sha512-xQ0AgodIE8nHYy508AVmpxqnIr/Ytyz5Xm7I6NQU33+RvDzs94T9c0dTnUWuariByLr1geXXe6kMaTM9TcOIEA==}
|
||||
engines: {node: '>=10'}
|
||||
dev: false
|
||||
|
||||
/@types/esprima/4.0.3:
|
||||
resolution: {integrity: sha512-jo14dIWVVtF0iMsKkYek6++4cWJjwpvog+rchLulwgFJGTXqIeTdCOvY0B3yMLTaIwMcKCdJ6mQbSR6wYHy98A==}
|
||||
dependencies:
|
||||
'@types/estree': 0.0.51
|
||||
dev: true
|
||||
|
||||
/@types/estree/0.0.51:
|
||||
resolution: {integrity: sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==}
|
||||
dev: true
|
||||
|
||||
/@types/node/13.13.52:
|
||||
resolution: {integrity: sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==}
|
||||
dev: true
|
||||
|
||||
/commander/9.2.0:
|
||||
resolution: {integrity: sha512-e2i4wANQiSXgnrBlIatyHtP1odfUp0BbV5Y5nEGbxtIrStkEOAAzCUirvLBNXHLr7kwLvJl6V+4V3XV9x7Wd9w==}
|
||||
engines: {node: ^12.20.0 || >=14}
|
||||
dev: false
|
||||
|
||||
/esprima/4.0.1:
|
||||
resolution: {integrity: sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==}
|
||||
engines: {node: '>=4'}
|
||||
hasBin: true
|
||||
dev: false
|
||||
|
||||
/node-estree/3.1.0:
|
||||
resolution: {integrity: sha512-Au8RrdfNCbvzT3/POUQjQnArLGpqXpuLrK0fU0acGSynjRA1CFWQ6mExO8HPR7mc9Q4RqemNJg/yTvm3E2nBqw==}
|
||||
dependencies:
|
||||
'@slimio/is': 1.5.1
|
||||
dev: false
|
||||
|
||||
/typescript/3.9.10:
|
||||
resolution: {integrity: sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==}
|
||||
engines: {node: '>=4.2.0'}
|
||||
hasBin: true
|
||||
dev: true
|
18
src/index.ts
Normal file
18
src/index.ts
Normal file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { program } from "commander";
|
||||
import { analyse } from "./analyse.js";
|
||||
|
||||
program
|
||||
.name("elmjs-inspector")
|
||||
.description("Analyse your elm.js file size with this tool.")
|
||||
.version("1.0.0");
|
||||
|
||||
program
|
||||
.command("analyze")
|
||||
.argument("<filename>", "The file to analyze")
|
||||
.action((filename) => {
|
||||
analyse(filename);
|
||||
});
|
||||
|
||||
program.parse();
|
@ -1,10 +1,13 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
// "target": "ES2019",
|
||||
"module": "ES6",
|
||||
"downlevelIteration": true,
|
||||
"moduleResolution": "node",
|
||||
"outDir": "dist"
|
||||
},
|
||||
"files": [
|
||||
"src/analyse.ts"
|
||||
"src/analyse.ts",
|
||||
"src/index.ts"
|
||||
]
|
||||
}
|
||||
|
48
yarn.lock
48
yarn.lock
@ -2,29 +2,41 @@
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@slimio/is@^1.5.1":
|
||||
"integrity" "sha512-xQ0AgodIE8nHYy508AVmpxqnIr/Ytyz5Xm7I6NQU33+RvDzs94T9c0dTnUWuariByLr1geXXe6kMaTM9TcOIEA=="
|
||||
"resolved" "https://registry.npmjs.org/@slimio/is/-/is-1.5.1.tgz"
|
||||
"version" "1.5.1"
|
||||
|
||||
"@types/esprima@^4.0.2":
|
||||
version "4.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/esprima/-/esprima-4.0.2.tgz#0303602d0644086d4802635d7abc9ac0eec57207"
|
||||
integrity sha512-DKqdyuy7Go7ir6iKhZ0jUvgt/h9Q5zb9xS+fLeeXD2QSHv8gC6TimgujBBGfw8dHrpx4+u2HlMv7pkYOOfuUqg==
|
||||
"integrity" "sha512-DKqdyuy7Go7ir6iKhZ0jUvgt/h9Q5zb9xS+fLeeXD2QSHv8gC6TimgujBBGfw8dHrpx4+u2HlMv7pkYOOfuUqg=="
|
||||
"resolved" "https://registry.npmjs.org/@types/esprima/-/esprima-4.0.2.tgz"
|
||||
"version" "4.0.2"
|
||||
dependencies:
|
||||
"@types/estree" "*"
|
||||
|
||||
"@types/estree@*":
|
||||
version "0.0.44"
|
||||
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.44.tgz#980cc5a29a3ef3bea6ff1f7d021047d7ea575e21"
|
||||
integrity sha512-iaIVzr+w2ZJ5HkidlZ3EJM8VTZb2MJLCjw3V+505yVts0gRC4UMvjw0d1HPtGqI/HQC/KdsYtayfzl+AXY2R8g==
|
||||
"@types/estree@*", "@types/estree@^0.0.51":
|
||||
"integrity" "sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ=="
|
||||
"resolved" "https://registry.npmjs.org/@types/estree/-/estree-0.0.51.tgz"
|
||||
"version" "0.0.51"
|
||||
|
||||
"@types/node@^13.11.0":
|
||||
version "13.11.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.11.0.tgz#390ea202539c61c8fa6ba4428b57e05bc36dc47b"
|
||||
integrity sha512-uM4mnmsIIPK/yeO+42F2RQhGUIs39K2RFmugcJANppXe6J1nvH87PvzPZYpza7Xhhs8Yn9yIAVdLZ84z61+0xQ==
|
||||
"integrity" "sha512-uM4mnmsIIPK/yeO+42F2RQhGUIs39K2RFmugcJANppXe6J1nvH87PvzPZYpza7Xhhs8Yn9yIAVdLZ84z61+0xQ=="
|
||||
"resolved" "https://registry.npmjs.org/@types/node/-/node-13.11.0.tgz"
|
||||
"version" "13.11.0"
|
||||
|
||||
esprima@^4.0.1:
|
||||
version "4.0.1"
|
||||
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
|
||||
integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==
|
||||
"esprima@^4.0.1":
|
||||
"integrity" "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A=="
|
||||
"resolved" "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz"
|
||||
"version" "4.0.1"
|
||||
|
||||
typescript@^3.8.3:
|
||||
version "3.8.3"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061"
|
||||
integrity sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==
|
||||
"node-estree@^3.1.0":
|
||||
"integrity" "sha512-Au8RrdfNCbvzT3/POUQjQnArLGpqXpuLrK0fU0acGSynjRA1CFWQ6mExO8HPR7mc9Q4RqemNJg/yTvm3E2nBqw=="
|
||||
"resolved" "https://registry.npmjs.org/node-estree/-/node-estree-3.1.0.tgz"
|
||||
"version" "3.1.0"
|
||||
dependencies:
|
||||
"@slimio/is" "^1.5.1"
|
||||
|
||||
"typescript@^3.8.3":
|
||||
"integrity" "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w=="
|
||||
"resolved" "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz"
|
||||
"version" "3.8.3"
|
||||
|
Loading…
Reference in New Issue
Block a user