Skip to content

Commit 7d17fc9

Browse files
improvement(cli): bundle and publish as @sim/cli
1 parent c4f29c5 commit 7d17fc9

50 files changed

Lines changed: 216 additions & 215 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/publish-sim-cli.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ jobs:
2626
with:
2727
bun-version: 1.3.14
2828

29+
- name: Setup Node
30+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
31+
with:
32+
node-version: '20'
33+
2934
- name: Cache Bun dependencies
3035
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5
3136
with:
@@ -40,8 +45,10 @@ jobs:
4045
- name: Install dependencies
4146
run: bun install --frozen-lockfile --ignore-scripts
4247

43-
- name: Verify initial package exists
44-
run: bun pm view @simai/cli@preview name
48+
- name: Verify npm authentication
49+
env:
50+
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
51+
run: bun pm whoami
4552

4653
- name: Run tests
4754
working-directory: packages/sim-cli
@@ -98,6 +105,16 @@ jobs:
98105
echo "tag=$TAG"
99106
} >> "$GITHUB_OUTPUT"
100107
108+
- name: Smoke-test packed Node bundle
109+
working-directory: packages/sim-cli
110+
run: |
111+
set -euo pipefail
112+
SMOKE_DIR="$(mktemp -d "$RUNNER_TEMP/sim-cli-smoke.XXXXXX")"
113+
PACKAGE_PATH="$SMOKE_DIR/sim-cli.tgz"
114+
bun pm pack --ignore-scripts --filename "$PACKAGE_PATH" --quiet
115+
tar -xzf "$PACKAGE_PATH" -C "$SMOKE_DIR"
116+
"$SMOKE_DIR/package/dist/index.js" --version
117+
101118
- name: Publish to npm
102119
working-directory: packages/sim-cli
103120
env:
@@ -109,4 +126,4 @@ jobs:
109126
env:
110127
VERSION: ${{ steps.release.outputs.version }}
111128
NPM_TAG: ${{ steps.release.outputs.tag }}
112-
run: echo "Published @simai/cli@$VERSION with the '$NPM_TAG' tag."
129+
run: echo "Published @sim/cli@$VERSION with the '$NPM_TAG' tag."

bun.lock

Lines changed: 18 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/sim-cli/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
Talk to the [Sim](https://sim.ai) API from your terminal.
44

55
```bash
6-
npm install --global @simai/cli
6+
npm install --global @sim/cli
77
sim login
88
sim workflows list
99
```
1010

1111
Prerelease channels track the corresponding Sim environments:
1212

1313
```bash
14-
npm install --global @simai/cli@preview # staging
15-
npm install --global @simai/cli@dev # dev
14+
npm install --global @sim/cli@preview # staging
15+
npm install --global @sim/cli@dev # dev
1616
```
1717

1818
## Profiles
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
The Sim CLI bundle includes the following third-party software.
2+
3+
chalk
4+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
5+
6+
commander
7+
Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>
8+
9+
js-yaml
10+
Copyright (C) 2011-2015 by Vitaly Puzrin
11+
12+
Each dependency above is licensed under the MIT License:
13+
14+
Permission is hereby granted, free of charge, to any person obtaining a copy
15+
of this software and associated documentation files (the "Software"), to deal
16+
in the Software without restriction, including without limitation the rights
17+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18+
copies of the Software, and to permit persons to whom the Software is
19+
furnished to do so, subject to the following conditions:
20+
21+
The above copyright notice and this permission notice shall be included in
22+
all copies or substantial portions of the Software.
23+
24+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30+
SOFTWARE.

packages/sim-cli/package.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@simai/cli",
2+
"name": "@sim/cli",
33
"version": "0.1.0",
44
"description": "Sim CLI - talk to the Sim API from your terminal",
55
"type": "module",
@@ -8,7 +8,7 @@
88
},
99
"scripts": {
1010
"prebuild": "bun run clean",
11-
"build": "tsc --project tsconfig.build.json",
11+
"build": "bun build src/index.ts --target=node --format=esm --packages=bundle --reject-unresolved --outfile=dist/index.js",
1212
"clean": "bun -e \"import { rmSync } from 'node:fs'; rmSync('dist', { recursive: true, force: true })\"",
1313
"type-check": "tsc --noEmit",
1414
"lint": "biome check --write --unsafe .",
@@ -19,7 +19,8 @@
1919
"prepublishOnly": "bun run build"
2020
},
2121
"files": [
22-
"dist"
22+
"dist",
23+
"THIRD_PARTY_LICENSES"
2324
],
2425
"keywords": [
2526
"sim",
@@ -45,16 +46,14 @@
4546
"engines": {
4647
"node": ">=20"
4748
},
48-
"dependencies": {
49-
"chalk": "5.6.2",
50-
"commander": "^11.1.0",
51-
"js-yaml": "4.3.0"
52-
},
5349
"devDependencies": {
5450
"@sim/tsconfig": "workspace:*",
5551
"@types/js-yaml": "4.0.9",
5652
"@types/node": "24.2.1",
5753
"@xterm/headless": "6.0.0",
54+
"chalk": "5.6.2",
55+
"commander": "^11.1.0",
56+
"js-yaml": "4.3.0",
5857
"typescript": "^7.0.2",
5958
"vitest": "^3.2.4"
6059
}

packages/sim-cli/src/auth/device-flow.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { afterEach, describe, expect, it, vi } from 'vitest'
2-
import { buildApprovalUrl, createAuthRequest, pollForKey } from './device-flow.js'
2+
import { buildApprovalUrl, createAuthRequest, pollForKey } from './device-flow'
33

44
const ENDPOINT = 'https://sim.test'
55

packages/sim-cli/src/auth/device-flow.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createHash, randomBytes, randomInt } from 'node:crypto'
2-
import { sleep } from '../helpers.js'
3-
import { SimApiError } from '../http/client.js'
2+
import { sleep } from '../helpers'
3+
import { SimApiError } from '../http/client'
44

55
/**
66
* The terminal half of the CLI key handoff.

packages/sim-cli/src/commands/auth.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, it } from 'vitest'
2-
import { profilesCommand } from './auth.js'
2+
import { profilesCommand } from './auth'
33

44
describe('profiles command', () => {
55
it('accepts the singular profile alias', () => {

packages/sim-cli/src/commands/auth.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ import {
66
type CliAuthScope,
77
createAuthRequest,
88
pollForKey,
9-
} from '../auth/device-flow.js'
9+
} from '../auth/device-flow'
1010
import {
1111
credentialsPath,
1212
deleteProfile,
1313
listProfiles,
1414
readCredentialsProfile,
1515
writeConfigProfile,
1616
writeCredentialsProfile,
17-
} from '../config/index.js'
18-
import { profileFrom } from '../context.js'
19-
import { SimApiError } from '../http/client.js'
20-
import { printRecord } from '../output/render.js'
17+
} from '../config/index'
18+
import { profileFrom } from '../context'
19+
import { SimApiError } from '../http/client'
20+
import { printRecord } from '../output/render'
2121

2222
/**
2323
* Best-effort browser launch. Failure is not an error: the URL is always printed

packages/sim-cli/src/commands/configure.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
import chalk from 'chalk'
22
import { Command } from 'commander'
3-
import {
4-
configPath,
5-
OUTPUT_FORMATS,
6-
readConfigProfile,
7-
writeConfigProfile,
8-
} from '../config/index.js'
9-
import { profileFrom } from '../context.js'
10-
import { SimApiError } from '../http/client.js'
3+
import { configPath, OUTPUT_FORMATS, readConfigProfile, writeConfigProfile } from '../config/index'
4+
import { profileFrom } from '../context'
5+
import { SimApiError } from '../http/client'
116

127
/**
138
* Non-secret profile settings. Credentials are deliberately not settable here —

0 commit comments

Comments
 (0)