@swirls/cli 0.1.5 → 0.1.9

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
@@ -1,84 +1,14 @@
1
1
  # @swirls/cli
2
2
 
3
- Swirls command line application for authentication, project setup, code generation, and storage.
3
+ Swirls command line application. https://swirls.ai/docs/docs/references/cli
4
4
 
5
- ## Usage
6
-
7
- The Swirls CLI can be executed remotely or installed on your machine. Use `swirls` or `npx @swirls/cli` depending on what you choose.
8
-
9
- ### Remote
10
-
11
- Run with `npx`
12
- ```sh
13
- npx @swirls/cli <command> [options]
14
- ```
15
-
16
- ### Local
17
-
18
- Install globally with npm or Bun.
5
+ ## Install
19
6
 
20
7
  ```sh
21
8
  npm install -g @swirls/cli
22
- # or
23
- bun add -g @swirls/cli
24
- ```
25
-
26
- Run with `swirls`
27
- ```sh
28
- swirls <command> [options]
29
9
  ```
30
10
 
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
-
39
- ## Reference
40
-
41
- Run `--help` for a reference guide; use `-v` or `--version` to print the CLI version.
42
-
43
- ```sh
44
- # local
45
- swirls --help
46
- # remote
47
- npx @swirls/cli --help
48
- ```
49
-
50
- ## Commands
51
-
52
- The Swirls CLI provides the following namespaces. For each, run its `--help` to see commands and options (examples below).
11
+ ### Supported Platforms
53
12
 
54
- ### Auth
55
-
56
- Log in and out of Swirls.
57
-
58
- ```sh
59
- swirls auth --help
60
- ```
61
-
62
- ### Dev
63
-
64
- Configure Swirls and generate code.
65
-
66
- ```sh
67
- swirls dev --help
68
- ```
69
-
70
- ### Project
71
-
72
- Create and manage Swirls projects.
73
-
74
- ```sh
75
- swirls project --help
76
- ```
77
-
78
- ### Storage
79
-
80
- Manage file storage for your Swirls project.
81
-
82
- ```sh
83
- swirls storage --help
84
- ```
13
+ - **macOS** — Apple Silicon (arm64), Intel (x64)
14
+ - **Linux** — x64 (amd64), arm64 (aarch64)
package/bin/README.txt ADDED
@@ -0,0 +1,7 @@
1
+ The 'swirls' file is a placeholder for the platform-specific binary, which is
2
+ replaced by the 'postinstall' script.
3
+
4
+ Do not use '--ignore-scripts' when installing.
5
+
6
+ This approach avoids invoking the Node.js installation wrapper on every
7
+ invocation of the CLI.
package/bin/swirls ADDED
@@ -0,0 +1,12 @@
1
+ #!/bin/sh
2
+
3
+ echo "Error: Swirls CLI 'postinstall' script was not run." >&2
4
+ echo "" >&2
5
+ echo "This occurs when using '--ignore-scripts' during installation, or when using a" >&2
6
+ echo "package manager that does not run 'postinstall' scripts by default." >&2
7
+ echo "" >&2
8
+ echo "To fix this, reinstall without the '--ignore-scripts' flag:" >&2
9
+ echo " npm install -g @swirls/cli" >&2
10
+ echo "" >&2
11
+ echo "Or run the install script directly: curl -fsSL https://swirls.ai/install | bash" >&2
12
+ exit 1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swirls/cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.9",
4
4
  "description": "Swirls command line application",
5
5
  "author": {
6
6
  "name": "Swirls",
@@ -8,16 +8,17 @@
8
8
  },
9
9
  "type": "module",
10
10
  "bin": {
11
- "cli": "./launcher/cli.js",
12
- "swirls": "./launcher/cli.js"
11
+ "swirls": "./bin/swirls"
13
12
  },
14
13
  "files": [
15
- "launcher"
14
+ "bin",
15
+ "scripts/install.js"
16
16
  ],
17
17
  "scripts": {
18
18
  "build": "bun run scripts/build.ts",
19
19
  "db:studio": "drizzle-kit studio",
20
20
  "dev": "bun run --watch src/bin/cli.ts",
21
+ "postinstall": "node scripts/install.js",
21
22
  "publish": "echo 'Publishing is performed by the CI/CD pipeline, not manually.'",
22
23
  "publish:dry": "SWIRLS_ENV=production bun run build && bun publish --ignore-scripts --dry-run",
23
24
  "version": "bun run scripts/version.ts"
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Runs the install script for platform detection and binary
5
+ * download, then copies the binary into bin/ so `swirls` runs the real
6
+ * binary (no Node wrapper).
7
+ *
8
+ * Skips installation in the following cases:
9
+ * - CI environment
10
+ * - Not installed globally
11
+ * - Windows (no curl/bash)
12
+ */
13
+
14
+ import { execSync } from 'node:child_process'
15
+ import { chmodSync, copyFileSync, existsSync } from 'node:fs'
16
+ import { dirname, join } from 'node:path'
17
+ import { fileURLToPath } from 'node:url'
18
+
19
+ const INSTALL_URL = 'https://swirls.ai/install'
20
+
21
+ const SCRIPT_DIR =
22
+ typeof import.meta.dir === 'string'
23
+ ? import.meta.dir
24
+ : dirname(fileURLToPath(import.meta.url))
25
+
26
+ const PACKAGE_ROOT = join(SCRIPT_DIR, '..')
27
+
28
+ const INSTALLED_BINARY = join(
29
+ process.env.HOME || process.env.USERPROFILE || '',
30
+ '.swirls',
31
+ 'bin',
32
+ 'swirls',
33
+ )
34
+
35
+ const BIN_SWIRLS = join(PACKAGE_ROOT, 'bin', 'swirls')
36
+
37
+ if (process.env.CI === 'true' || process.env.CI === '1') {
38
+ process.exit(0)
39
+ }
40
+ if (process.platform === 'win32') {
41
+ process.exit(0)
42
+ }
43
+ if (!process.env.npm_config_global && !process.env.BUN_INSTALL_GLOBAL) {
44
+ process.exit(0)
45
+ }
46
+
47
+ try {
48
+ execSync(`curl -fsSL ${INSTALL_URL} | bash`, {
49
+ stdio: 'inherit',
50
+ shell: true,
51
+ })
52
+ } catch (_err) {
53
+ process.exit(1)
54
+ }
55
+
56
+ if (existsSync(INSTALLED_BINARY)) {
57
+ copyFileSync(INSTALLED_BINARY, BIN_SWIRLS)
58
+ chmodSync(BIN_SWIRLS, 0o755)
59
+ }
@@ -1,17 +0,0 @@
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 DELETED
@@ -1,45 +0,0 @@
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
- }
@@ -1,10 +0,0 @@
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
- }