Skip to content

Commit 77dd877

Browse files
committed
Improved CLI performance by using rollup to bundle, tree-shake and minify files
1 parent 660e2c4 commit 77dd877

4 files changed

Lines changed: 65 additions & 19 deletions

File tree

README.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $ npm install -g codify
1818
$ codify COMMAND
1919
running command...
2020
$ codify (--version)
21-
codify/0.0.1 darwin-arm64 node-v20.15.0
21+
codify/0.0.2 darwin-arm64 node-v20.15.0
2222
$ codify --help [COMMAND]
2323
USAGE
2424
$ codify COMMAND
@@ -68,8 +68,6 @@ EXAMPLES
6868
$ codify apply
6969
```
7070

71-
_See code: [src/commands/apply/index.ts](https://github.com/kevinwang5658/codify/blob/v0.0.1/src/commands/apply/index.ts)_
72-
7371
## `codify help [COMMAND]`
7472

7573
Display help for codify.
@@ -88,7 +86,7 @@ DESCRIPTION
8886
Display help for codify.
8987
```
9088

91-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.4/src/commands/help.ts)_
89+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.5/src/commands/help.ts)_
9290

9391
## `codify plan`
9492

@@ -116,8 +114,6 @@ EXAMPLES
116114
$ codify plan
117115
```
118116

119-
_See code: [src/commands/plan/index.ts](https://github.com/kevinwang5658/codify/blob/v0.0.1/src/commands/plan/index.ts)_
120-
121117
## `codify plugins`
122118

123119
List installed plugins.
@@ -139,7 +135,7 @@ EXAMPLES
139135
$ codify plugins
140136
```
141137

142-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/index.ts)_
138+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.4/src/commands/plugins/index.ts)_
143139

144140
## `codify plugins add PLUGIN`
145141

@@ -213,7 +209,7 @@ EXAMPLES
213209
$ codify plugins inspect myplugin
214210
```
215211

216-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/inspect.ts)_
212+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.4/src/commands/plugins/inspect.ts)_
217213

218214
## `codify plugins install PLUGIN`
219215

@@ -262,7 +258,7 @@ EXAMPLES
262258
$ codify plugins install someuser/someplugin
263259
```
264260

265-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/install.ts)_
261+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.4/src/commands/plugins/install.ts)_
266262

267263
## `codify plugins link PATH`
268264

@@ -292,7 +288,7 @@ EXAMPLES
292288
$ codify plugins link myplugin
293289
```
294290

295-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/link.ts)_
291+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.4/src/commands/plugins/link.ts)_
296292

297293
## `codify plugins remove [PLUGIN]`
298294

@@ -333,7 +329,7 @@ FLAGS
333329
--reinstall Reinstall all plugins after uninstalling.
334330
```
335331

336-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/reset.ts)_
332+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.4/src/commands/plugins/reset.ts)_
337333

338334
## `codify plugins uninstall [PLUGIN]`
339335

@@ -361,7 +357,7 @@ EXAMPLES
361357
$ codify plugins uninstall myplugin
362358
```
363359

364-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/uninstall.ts)_
360+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.4/src/commands/plugins/uninstall.ts)_
365361

366362
## `codify plugins unlink [PLUGIN]`
367363

@@ -405,7 +401,7 @@ DESCRIPTION
405401
Update installed plugins.
406402
```
407403

408-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.3/src/commands/plugins/update.ts)_
404+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.4/src/commands/plugins/update.ts)_
409405

410406
## `codify uninstall`
411407

@@ -430,6 +426,4 @@ DESCRIPTION
430426
EXAMPLES
431427
$ codify uninstall
432428
```
433-
434-
_See code: [src/commands/uninstall.ts](https://github.com/kevinwang5658/codify/blob/v0.0.1/src/commands/uninstall.ts)_
435429
<!-- commandsstop -->

package.json

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626
"devDependencies": {
2727
"@oclif/prettier-config": "^0.2.1",
2828
"@oclif/test": "^4.0.4",
29+
"@rollup/plugin-json": "^6.1.0",
30+
"@rollup/plugin-typescript": "^11.1.6",
31+
"@rollup/plugin-commonjs": "^25.0.7",
32+
"@rollup/plugin-node-resolve": "^15.2.3",
33+
"@rollup/plugin-terser": "^0.4.4",
34+
"@rollup/plugin-wasm": "^6.2.2",
2935
"@types/chai": "^4",
3036
"@types/chai-as-promised": "^7.1.7",
3137
"@types/chalk": "^2.2.0",
@@ -46,6 +52,8 @@
4652
"mocha": "^10",
4753
"mock-fs": "^5.2.0",
4854
"oclif": "4.13.12",
55+
"rollup": "^4.12.0",
56+
"rollup-plugin-copy": "^3.5.0",
4957
"shx": "^0.3.3",
5058
"strip-ansi": "^7.1.0",
5159
"tsx": "^4.7.3",
@@ -69,11 +77,15 @@
6977
"oclif": {
7078
"bin": "codify",
7179
"dirname": "codify",
72-
"commands": "./dist/commands",
7380
"plugins": [
7481
"@oclif/plugin-help",
7582
"@oclif/plugin-plugins"
7683
],
84+
"commands": {
85+
"strategy": "explicit",
86+
"target": "./dist/index.js",
87+
"identifier": "COMMANDS"
88+
},
7789
"topicSeparator": " ",
7890
"topics": {
7991
"plan": {
@@ -93,15 +105,15 @@
93105
"build": "shx rm -rf dist && tsc -b",
94106
"lint": "tsc && eslint . --ext .ts",
95107
"postpack": "shx rm -f oclif.manifest.json",
96-
"pkg": "tsc && oclif pack macos -r .",
108+
"pkg": "shx rm -rf dist && rollup -c && oclif pack macos -r .",
97109
"posttest": "npm run lint",
98110
"prepack": "oclif manifest && oclif readme",
99111
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
100112
"version": "oclif readme && git add README.md",
101113
"start:dev": "./bin/dev.js",
102114
"start:vm": "npm run build && npm run pack:macos && npm run start:vm"
103115
},
104-
"version": "0.0.1",
116+
"version": "0.0.2",
105117
"bugs": "https://github.com/kevinwang5658/codify/issues",
106118
"keywords": [
107119
"oclif"

rollup.config.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import commonjs from '@rollup/plugin-commonjs';
2+
import json from '@rollup/plugin-json';
3+
import nodeResolve from '@rollup/plugin-node-resolve';
4+
import terser from '@rollup/plugin-terser';
5+
import typescript from '@rollup/plugin-typescript';
6+
import wasm from '@rollup/plugin-wasm';
7+
import copy from 'rollup-plugin-copy';
8+
9+
export default {
10+
input: 'src/index.ts',
11+
output: {
12+
dir:'dist',
13+
format: 'es'
14+
},
15+
plugins: [
16+
copy({
17+
targets: [{ dest: './dist/', src: './node_modules/yoga-wasm-web/dist/yoga.wasm' }]
18+
}),
19+
json(),
20+
wasm(),
21+
nodeResolve({ exportConditions: ['node'] }),
22+
typescript(),
23+
commonjs(),
24+
terser()
25+
]
26+
}

src/index.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1-
export { run } from '@oclif/core'
1+
import { Command, execute } from '@oclif/core';
2+
3+
import Apply from './commands/apply/index.js'
4+
import Plan from './commands/plan/index.js'
5+
import Uninstall from './commands/uninstall.js'
6+
7+
export const COMMANDS: Record<string, Command.Class> = {
8+
apply: Apply,
9+
plan: Plan,
10+
uninstall: Uninstall,
11+
}
12+
13+
export async function run() {
14+
await execute({ dir: import.meta.url })
15+
}

0 commit comments

Comments
 (0)