@swirls/cli 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,6 +28,14 @@ Run with `swirls`
28
28
  swirls <command> [options]
29
29
  ```
30
30
 
31
+ ## Installation and how it works
32
+
33
+ The published package is a **launcher**: the `swirls` / `cli` bin points at `launcher/cli.js`, which runs on **every** CLI invocation (not at install time).
34
+
35
+ On install, the package manager installs the launcher plus **one** platform-specific binary. That binary is provided by an optional dependency (`@swirls/cli-darwin-arm64`, etc.). The package manager installs only the optional dependency whose `os` and `cpu` match the host, so you only get the binary for your platform.
36
+
37
+ At run time, the launcher looks up the current platform, resolves that optional dependency's binary, and exec's it with your arguments.
38
+
31
39
  ## Reference
32
40
 
33
41
  Run `--help` for a reference guide; use `-v` or `--version` to print the CLI version.
@@ -0,0 +1,17 @@
1
+ # Launcher
2
+
3
+ The launcher is the Node entry point for `@swirls/cli`. It runs on every `swirls` invocation, resolves the current platform's optional dependency, and exec's that package's `swirls` binary.
4
+
5
+ ## Files
6
+
7
+ - **cli.js** — Entry script. Resolves `platform-arch`, looks up the package in `platforms.js`, and exec's the binary with the user's arguments.
8
+ - **platforms.js** — Generated during build from the repo root `platforms.ts`. Do not edit by hand.
9
+
10
+ ## Adding a platform
11
+
12
+ 1. Add an entry to [platforms.ts](../platforms.ts).
13
+ 2. Run the build (which regenerates `launcher/platforms.js`).
14
+ 3. Add or update the package under `packages/<pkgDir>/` and its `package.json` (with `os` and `cpu`).
15
+ 4. Add the npm package to `optionalDependencies` in [package.json](../package.json).
16
+
17
+ See [AGENTS.md](../AGENTS.md) "Adding a new platform" for detailed build and publish steps.
package/launcher/cli.js CHANGED
@@ -3,7 +3,6 @@
3
3
  import { execFileSync } from 'node:child_process'
4
4
  import { createRequire } from 'node:module'
5
5
  import { dirname, join } from 'node:path'
6
- import { Table } from 'console-table-printer'
7
6
  import { platforms } from './platforms.js'
8
7
 
9
8
  const require = createRequire(import.meta.url)
@@ -13,25 +12,7 @@ const pkg = platforms[key]
13
12
 
14
13
  // handle unsupported platform
15
14
  if (!pkg) {
16
- console.warn(`\n⚠️ Your platform is not currently supported: ${key}\n`)
17
-
18
- // list supported platforms
19
- const table = new Table({
20
- columns: [
21
- { name: 'Platform', alignment: 'left' },
22
- { name: 'Package', alignment: 'left' },
23
- ],
24
- rows: Object.entries(platforms).map(([platform, pkg]) => ({
25
- Platform: platform,
26
- Package: pkg,
27
- })),
28
- })
29
- table.printTable()
30
-
31
- console.info(
32
- '\nTo request support for your platform, send us an email at help@swirls.ai\n',
33
- )
34
-
15
+ printUnsupportedPlatform(key)
35
16
  process.exit(1)
36
17
  }
37
18
 
@@ -39,3 +20,26 @@ const pkgDir = dirname(require.resolve(`${pkg}/package.json`))
39
20
  const binary = join(pkgDir, 'swirls')
40
21
 
41
22
  execFileSync(binary, process.argv.slice(2), { stdio: 'inherit' })
23
+
24
+ function printUnsupportedPlatform(key) {
25
+ const noColor = 'NO_COLOR' in process.env
26
+ const reset = noColor ? '' : '\x1b[0m'
27
+ const yellow = noColor ? '' : '\x1b[33m'
28
+ // const bold = noColor ? '' : '\x1b[1m'
29
+ const cyan = noColor ? '' : '\x1b[36m'
30
+ const blue = noColor ? '' : '\x1b[34m'
31
+ const dim = noColor ? '' : '\x1b[2m'
32
+
33
+ console.warn(
34
+ `\n${yellow}Your platform is not currently supported:${reset} ${key}\n`,
35
+ )
36
+ console.log('Supported platforms:')
37
+ for (const [platform, pkgName] of Object.entries(platforms)) {
38
+ console.log(
39
+ ` ${cyan}${platform.padEnd(16)}${reset}\t${dim}${pkgName}${reset}`,
40
+ )
41
+ }
42
+ console.log(
43
+ `\nTo request support for your platform, send us an email at ${blue}help@swirls.ai${reset}\n`,
44
+ )
45
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swirls/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Swirls command line application",
5
5
  "author": {
6
6
  "name": "Swirls",
@@ -17,8 +17,8 @@
17
17
  "scripts": {
18
18
  "build": "bun run ci/build.ts",
19
19
  "dev": "bun run --watch src/bin/cli.ts",
20
- "pkg:publish": "SWIRLS_ENV=production bun run build && bun run cd/publish.ts",
21
- "pkg:publish:dry": "SWIRLS_ENV=production bun run build && bun run cd/publish.ts --dry-run"
20
+ "publish": "SWIRLS_ENV=production bun run build && bun run cd/publish.ts",
21
+ "publish:dry": "SWIRLS_ENV=production bun run build && bun run cd/publish.ts --dry-run"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@byteslice/result": "0.3.0",
@@ -35,15 +35,14 @@
35
35
  "console-table-printer": "2.15.0",
36
36
  "dotenv": "16.4.7",
37
37
  "open": "10.2.0",
38
- "sucrase": "3.35.1",
39
38
  "typescript": "5.9.3",
40
39
  "zod": "4.3.5"
41
40
  },
42
41
  "optionalDependencies": {
43
- "@swirls/cli-darwin-arm64": "0.1.0",
44
- "@swirls/cli-darwin-x64": "0.1.0",
45
- "@swirls/cli-linux-arm64": "0.1.0",
46
- "@swirls/cli-linux-x64": "0.1.0"
42
+ "@swirls/cli-darwin-arm64": "0.1.1",
43
+ "@swirls/cli-darwin-x64": "0.1.1",
44
+ "@swirls/cli-linux-arm64": "0.1.1",
45
+ "@swirls/cli-linux-x64": "0.1.1"
47
46
  },
48
47
  "engines": {
49
48
  "node": ">=22"