Skip to content

Commit b981d92

Browse files
committed
Decouple the CLI from the main library
This is causing renderer updates to unnecessarily bump core Codama libraries.
1 parent db4324f commit b981d92

File tree

6 files changed

+33
-11
lines changed

6 files changed

+33
-11
lines changed

.changeset/cruel-candles-doubt.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'codama': minor
3+
'@codama/cli': minor
4+
---
5+
6+
Decouples the `@codama/cli` package to the main `codama` library as this was causing renderer updates to unnecessarily bump core Codama libraries.

packages/cli/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99

1010
This package provides a CLI for the Codama library that can be used to run scripts on Codama IDLs.
1111

12-
Note that, whilst the CLI code is located in the `@codama/cli` package, the CLI binary is directly provided by the main `codama` library.
13-
1412
## Getting started
1513

16-
To get started with Codama, simply install `codama` to your project and run the `init` command like so:
14+
To get started with Codama, simply install `@codama/cli` which provides the `codama` binary. Then, run the `init` command like so:
1715

1816
```sh
19-
pnpm install codama
17+
pnpm install @codama/cli
2018
codama init
2119
```
2220

File renamed without changes.

packages/cli/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@codama/cli",
33
"version": "1.0.12",
4-
"description": "The package that provides a CLI for the Codama standard",
4+
"description": "A CLI for setting up and managing Codama IDLs",
55
"exports": {
66
"types": "./dist/types/index.d.ts",
77
"node": {
@@ -13,8 +13,13 @@
1313
"module": "./dist/index.node.mjs",
1414
"types": "./dist/types/index.d.ts",
1515
"type": "commonjs",
16+
"bin": {
17+
"codama": "./bin/cli.cjs"
18+
},
1619
"files": [
20+
"./bin",
1721
"./dist/types",
22+
"./dist/cli.*",
1823
"./dist/index.*"
1924
],
2025
"sideEffects": false,
@@ -24,8 +29,9 @@
2429
"cli"
2530
],
2631
"scripts": {
27-
"build": "rimraf dist && pnpm build:src && pnpm build:types",
32+
"build": "rimraf dist && pnpm build:src && pnpm build:cli && pnpm build:types",
2833
"build:src": "zx ../../node_modules/@codama/internals/scripts/build-src.mjs node",
34+
"build:cli": "zx ../../node_modules/@codama/internals/scripts/build-src.mjs cli",
2935
"build:types": "zx ../../node_modules/@codama/internals/scripts/build-types.mjs",
3036
"dev": "zx ../../node_modules/@codama/internals/scripts/test-unit.mjs node --watch",
3137
"lint": "zx ../../node_modules/@codama/internals/scripts/lint.mjs",

packages/cli/src/cli/index.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { createProgram } from '../program';
2+
import { logDebug, logError } from '../utils';
3+
4+
const program = createProgram();
5+
6+
export async function run(argv: readonly string[]) {
7+
try {
8+
await program.parseAsync(argv);
9+
} catch (err) {
10+
if (program.opts().debug) {
11+
logDebug(`${(err as { stack: string }).stack}`);
12+
}
13+
logError((err as { message: string }).message);
14+
process.exitCode = 1;
15+
}
16+
}

packages/library/package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,8 @@
2626
"react-native": "./dist/index.react-native.mjs",
2727
"types": "./dist/types/index.d.ts",
2828
"type": "commonjs",
29-
"bin": "./bin/cli.cjs",
3029
"files": [
31-
"./bin",
3230
"./dist/types",
33-
"./dist/cli.*",
3431
"./dist/index.*"
3532
],
3633
"sideEffects": false,
@@ -42,9 +39,8 @@
4239
"code generation"
4340
],
4441
"scripts": {
45-
"build": "rimraf dist && pnpm build:src && pnpm build:cli && pnpm build:types",
42+
"build": "rimraf dist && pnpm build:src && pnpm build:types",
4643
"build:src": "zx ../../node_modules/@codama/internals/scripts/build-src.mjs library",
47-
"build:cli": "zx ../../node_modules/@codama/internals/scripts/build-src.mjs cli",
4844
"build:types": "zx ../../node_modules/@codama/internals/scripts/build-types.mjs",
4945
"dev": "zx ../../node_modules/@codama/internals/scripts/test-unit.mjs node --watch",
5046
"lint": "zx ../../node_modules/@codama/internals/scripts/lint.mjs",

0 commit comments

Comments
 (0)