@swirls/cli 0.0.23 → 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.
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execFileSync } from 'node:child_process'
4
+ import { createRequire } from 'node:module'
5
+ import { dirname, join } from 'node:path'
6
+ import { platforms } from './platforms.js'
7
+
8
+ const require = createRequire(import.meta.url)
9
+
10
+ const key = `${process.platform}-${process.arch}`
11
+ const pkg = platforms[key]
12
+
13
+ // handle unsupported platform
14
+ if (!pkg) {
15
+ printUnsupportedPlatform(key)
16
+ process.exit(1)
17
+ }
18
+
19
+ const pkgDir = dirname(require.resolve(`${pkg}/package.json`))
20
+ const binary = join(pkgDir, 'swirls')
21
+
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
+ }
@@ -0,0 +1,10 @@
1
+ // Generated during build from `platforms.ts`. Do not edit manually.
2
+ //
3
+ // biome-ignore-all format: generated file
4
+
5
+ export const platforms = {
6
+ "darwin-arm64": "@swirls/cli-darwin-arm64",
7
+ "darwin-x64": "@swirls/cli-darwin-x64",
8
+ "linux-arm64": "@swirls/cli-linux-arm64",
9
+ "linux-x64": "@swirls/cli-linux-x64",
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swirls/cli",
3
- "version": "0.0.23",
3
+ "version": "0.1.1",
4
4
  "description": "Swirls command line application",
5
5
  "author": {
6
6
  "name": "Swirls",
@@ -8,20 +8,17 @@
8
8
  },
9
9
  "type": "module",
10
10
  "bin": {
11
- "cli": "./dist/cli-shim.js",
12
- "swirls": "./dist/cli.js"
11
+ "cli": "./launcher/cli.js",
12
+ "swirls": "./launcher/cli.js"
13
13
  },
14
14
  "files": [
15
- "dist"
15
+ "launcher"
16
16
  ],
17
17
  "scripts": {
18
- "prebuild": "tsc -p tsconfig.json",
19
- "build": "if [ \"$SWIRLS_ENV\" = 'production' ]; then tsup; elif command -v op >/dev/null 2>&1; then op run --no-masking --env-file=.env.development -- tsup; else tsup; fi",
20
- "postbuild": "cp scripts/cli-shim.js dist/cli-shim.js && chmod +x ./dist/cli.js ./dist/cli-shim.js",
21
- "dev": "op run --no-masking --env-file=.env.development -- tsup --watch",
22
- "pkg:publish": "bun publish",
23
- "pkg:publish:dry": "bun publish --dry-run",
24
- "prepublishOnly": "SWIRLS_ENV=production bun run build"
18
+ "build": "bun run ci/build.ts",
19
+ "dev": "bun run --watch src/bin/cli.ts",
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"
25
22
  },
26
23
  "devDependencies": {
27
24
  "@byteslice/result": "0.3.0",
@@ -33,15 +30,20 @@
33
30
  "@stricli/core": "1.2.4",
34
31
  "@swirls/core": "0.0.1",
35
32
  "@swirls/sdk": "0.0.13",
33
+ "@types/bun": "1.3.9",
36
34
  "@types/node": "24.10.0",
37
35
  "console-table-printer": "2.15.0",
38
36
  "dotenv": "16.4.7",
39
37
  "open": "10.2.0",
40
- "sucrase": "3.35.1",
41
- "tsup": "8.5.1",
42
38
  "typescript": "5.9.3",
43
39
  "zod": "4.3.5"
44
40
  },
41
+ "optionalDependencies": {
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"
46
+ },
45
47
  "engines": {
46
48
  "node": ">=22"
47
49
  },
package/dist/cli-shim.js DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import './cli.js'