devicerent 0.1.0 → 0.2.0

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,85 +1,135 @@
1
- # devicerent
2
-
3
- DeviceRent from your terminal. Rent a **real** Android phone by the minute,
4
- install your APK, run Espresso or a Quick test, get a hosted Appium URL, or hand
5
- the phone to DeviceyAI — everything the website does except show you the live
6
- screen.
7
-
8
- ```bash
9
- npm install -g devicerent # Node 22 or newer
10
- devicerent login # approve in your browser, like `gh auth login`
11
- devicerent devices # what is in the rack right now
12
- devicerent rent "Pixel 7a" # billing starts now
13
- devicerent install app-debug.apk --launch
14
- devicerent test quick com.example.app --report quick-test.md
15
- devicerent stop
16
- ```
17
-
18
- ## Signing in
19
-
20
- `devicerent login` opens `devicerent.net` in your browser and asks you to
21
- approve the sign-in. Nothing is typed into the terminal: the page hands the
22
- terminal a one-time sign-in token, encrypted so that only the waiting
23
- `devicerent` process can open it. If your account has two-factor turned on, the
24
- terminal asks for your authenticator code too.
25
-
26
- Signing in on a machine without a browser (an SSH session, a VM):
27
-
28
- ```bash
29
- devicerent login --no-browser # open the printed link anywhere, paste the code back
30
- ```
31
-
32
- The session is stored in `~/.config/devicerent/` (`%APPDATA%\devicerent` on
33
- Windows), readable only by you, and is only ever sent to the DeviceRent that
34
- issued it. `devicerent logout` signs this terminal out and leaves your browser
35
- sessions alone.
36
-
37
- ## Commands
38
-
39
- | Group | Commands |
40
- | --- | --- |
41
- | Account | `whoami`, `wallet [--history]`, `history`, `credits [buy s\|m\|l]`, `topup <eur>`, `subscribe <plus\|pro\|slot> [--yearly]`, `billing`, `keys list\|create\|revoke` |
42
- | Rentals | `devices [--available]`, `rent <device…>` (up to three), `status`, `stop [rental] \| --all` |
43
- | Phone | `install <apk…> [--launch]`, `apps`, `launch <pkg>`, `uninstall <pkg>`, `shell [cmd]`, `logcat [-f] [--package] [--level]`, `screenshot [file]`, `push`, `pull`, `ui [--xml]` |
44
- | Testing | `test espresso [--runner] [--class] [--junit out.xml]`, `test quick <apk\|pkg> [--report] [--fix-prompt]`, `appium [--check]`, `connect [--port]` |
45
- | DeviceyAI | `ai "<task>" [--allow-actions] [--allow-shell] [--model]`, `ai --models` |
46
-
47
- Every command takes `--json` for machine-readable output, and `-h` for help.
48
- With more than one rental running, pick the phone with `--rental <id or name>`.
49
-
50
- Payments always happen in the browser: `topup`, `subscribe`, `credits buy` and
51
- `billing` print a Stripe link and open it.
52
-
53
- ## How you are billed
54
-
55
- Exactly as on the website. A rental bills per minute from `rent` until `stop`,
56
- at your plan's rate. A rental with no activity for 30 minutes is stopped for
57
- you; installing, testing, shell input and DeviceyAI steps count as activity,
58
- merely holding `logcat -f` or an idle `connect` tunnel open does not.
59
- DeviceyAI spends AI credits, the same as in the panel.
60
-
61
- ## Exit codes
62
-
63
- `0` success · `1` failure (a test failed, the app crashed, a request was
64
- refused) · `2` usage error or not signed in · `3` the test run itself broke.
65
-
66
- `test espresso` writes JUnit XML with `--junit`, so it drops into a CI report.
67
-
68
- ## Pointing at another DeviceRent
69
-
70
- `--api-base <url>` (or `DEVICERENT_API_BASE`) targets another deployment, for
71
- example a local `next start` on `http://localhost:3000`. Each deployment keeps
72
- its own session.
73
-
74
- ## Security
75
-
76
- - The terminal holds an ordinary DeviceRent session for your account — the same
77
- identity and the same row-level security as your browser tab. It can do what
78
- you can do on the site; admin pages stay browser-only.
79
- - Phones are reached over the same serial-pinned, ten-minute bridge tokens the
80
- session page uses. The Pi never sees your session.
81
- - Approve a sign-in only if you just ran `devicerent login` yourself, and never
82
- send the code from `--no-browser` to anyone.
83
-
84
- Source: [`clients/devicerent-cli`](https://github.com/DeviceRent-net/devicerent.net/tree/main/clients/devicerent-cli).
85
- Design notes: `docs/CLI.md` in the same repository.
1
+ # devicerent
2
+
3
+ DeviceRent from your terminal. Rent a **real** Android phone by the minute,
4
+ install your APK, run a Quick test or Espresso, get a hosted Appium URL, or hand
5
+ the phone to DeviceyAI — everything the website does except show you the live
6
+ screen. You don't need to know how to code to use it.
7
+
8
+ ## Start here
9
+
10
+ You need [Node.js](https://nodejs.org) 22 or newer (the LTS download). Then open
11
+ a terminal — on Windows press Start and type **Terminal**, on a Mac press ⌘-Space
12
+ and type **Terminal** — and type:
13
+
14
+ ```bash
15
+ npx devicerent
16
+ ```
17
+
18
+ That opens a guided session:
19
+
20
+ ```
21
+ ╭──────────────────────────────────────────────────╮
22
+ │ ✻ Welcome to DeviceRent │
23
+ │ Real Android phones, rented by the minute. │
24
+ │ you@example.com · Pro · Wallet €12.50 │
25
+ ╰──────────────────────────────────────────────────╯
26
+ ╭──────────────────────────────────────────────────╮
27
+ │ > rent a phone │
28
+ ╰──────────────────────────────────────────────────╯
29
+ / for commands · ? for help no phone rented
30
+ ```
31
+
32
+ Then just say what you want, in plain words:
33
+
34
+ | Type | What happens |
35
+ | --- | --- |
36
+ | `rent` | Pick a phone from a menu; it shows **your** price and asks before billing starts |
37
+ | *drag your `.apk` onto the window* | Installs it on the rented phone, then offers to open it |
38
+ | `test my app` | The Quick test: opens your app, taps around, reports any crash |
39
+ | `take a screenshot` | Saves a picture of the phone's screen to Downloads and opens it |
40
+ | `open Settings and turn on dark mode` | Anything else in plain words goes to DeviceyAI, which does it on the phone (it asks first, and uses AI credits) |
41
+ | `I'm done` | Stops the rental (it asks first; the phone is wiped afterwards) |
42
+ | `balance` · `topup` · `plans` | Your wallet and plan; payment opens Stripe in your browser |
43
+ | `/` | Every command, with a live menu — ↑↓ to choose, Enter to run |
44
+
45
+ Leaving with a phone still rented asks whether to stop it first. Arrow keys,
46
+ Enter and Esc work in every menu; Ctrl-C stops whatever is running.
47
+
48
+ ## One command at a time (scripts and CI)
49
+
50
+ Every command also works on its own, exactly as before, and that is what
51
+ scripts and CI should use:
52
+
53
+ ```bash
54
+ npm install -g devicerent # Node 22 or newer
55
+ devicerent login # approve in your browser, like `gh auth login`
56
+ devicerent devices # what is in the rack right now
57
+ devicerent rent "Pixel 7a" # billing starts now
58
+ devicerent install app-debug.apk --launch
59
+ devicerent test quick com.example.app --report quick-test.md
60
+ devicerent stop
61
+ ```
62
+
63
+ `devicerent` with no command opens the guided session only when a person is at
64
+ a terminal. Piped, with `--json`, under `CI`, or with
65
+ `DEVICERENT_NO_INTERACTIVE=1`, it prints the help text instead, and every
66
+ command's output and exit code are unchanged.
67
+
68
+ ## Signing in
69
+
70
+ `devicerent login` opens `devicerent.net` in your browser and asks you to
71
+ approve the sign-in. Nothing is typed into the terminal: the page hands the
72
+ terminal a one-time sign-in token, encrypted so that only the waiting
73
+ `devicerent` process can open it. If your account has two-factor turned on, the
74
+ terminal asks for your authenticator code too.
75
+
76
+ Signing in on a machine without a browser (an SSH session, a VM):
77
+
78
+ ```bash
79
+ devicerent login --no-browser # open the printed link anywhere, paste the code back
80
+ ```
81
+
82
+ The session is stored in `~/.config/devicerent/` (`%APPDATA%\devicerent` on
83
+ Windows), readable only by you, and is only ever sent to the DeviceRent that
84
+ issued it. `devicerent logout` signs this terminal out and leaves your browser
85
+ sessions alone.
86
+
87
+ ## Commands
88
+
89
+ | Group | Commands |
90
+ | --- | --- |
91
+ | Account | `whoami`, `wallet [--history]`, `history`, `credits [buy s\|m\|l]`, `topup <eur>`, `subscribe <plus\|pro\|slot> [--yearly]`, `billing`, `keys list\|create\|revoke` |
92
+ | Rentals | `devices [--available]`, `rent <device…>` (up to three), `status`, `stop [rental] \| --all` |
93
+ | Phone | `install <apk…> [--launch]`, `apps`, `launch <pkg>`, `uninstall <pkg>`, `shell [cmd]`, `logcat [-f] [--package] [--level]`, `screenshot [file]`, `push`, `pull`, `ui [--xml]` |
94
+ | Testing | `test espresso [--runner] [--class] [--junit out.xml]`, `test quick <apk\|pkg> [--report] [--fix-prompt]`, `appium [--check]`, `connect [--port]` |
95
+ | DeviceyAI | `ai "<task>" [--allow-actions] [--allow-shell] [--model]`, `ai --models` |
96
+
97
+ Every command takes `--json` for machine-readable output, and `-h` for help.
98
+ With more than one rental running, pick the phone with `--rental <id or name>`.
99
+
100
+ Payments always happen in the browser: `topup`, `subscribe`, `credits buy` and
101
+ `billing` print a Stripe link and open it.
102
+
103
+ ## How you are billed
104
+
105
+ Exactly as on the website. A rental bills per minute from `rent` until `stop`,
106
+ at your plan's rate. A rental with no activity for 30 minutes is stopped for
107
+ you; installing, testing, shell input and DeviceyAI steps count as activity,
108
+ merely holding `logcat -f` or an idle `connect` tunnel open does not.
109
+ DeviceyAI spends AI credits, the same as in the panel.
110
+
111
+ ## Exit codes
112
+
113
+ `0` success · `1` failure (a test failed, the app crashed, a request was
114
+ refused) · `2` usage error or not signed in · `3` the test run itself broke.
115
+
116
+ `test espresso` writes JUnit XML with `--junit`, so it drops into a CI report.
117
+
118
+ ## Pointing at another DeviceRent
119
+
120
+ `--api-base <url>` (or `DEVICERENT_API_BASE`) targets another deployment, for
121
+ example a local `next start` on `http://localhost:3000`. Each deployment keeps
122
+ its own session.
123
+
124
+ ## Security
125
+
126
+ - The terminal holds an ordinary DeviceRent session for your account — the same
127
+ identity and the same row-level security as your browser tab. It can do what
128
+ you can do on the site; admin pages stay browser-only.
129
+ - Phones are reached over the same serial-pinned, ten-minute bridge tokens the
130
+ session page uses. The Pi never sees your session.
131
+ - Approve a sign-in only if you just ran `devicerent login` yourself, and never
132
+ send the code from `--no-browser` to anyone.
133
+
134
+ Source: [`clients/devicerent-cli`](https://github.com/DeviceRent-net/devicerent.net/tree/main/clients/devicerent-cli).
135
+ Design notes: `docs/CLI.md` in the same repository.
@@ -2,4 +2,16 @@
2
2
  // The published entry point. Everything lives in the bundle `npm run build`
3
3
  // writes to dist/ — the CLI imports the web app's own device and DeviceyAI
4
4
  // modules from src/lib, so it cannot run from source without the bundler.
5
- import "../dist/devicerent.mjs";
5
+ //
6
+ // The Node version is checked FIRST, and the bundle loaded with a dynamic
7
+ // import (a static one would be hoisted above the check): on an old Node the
8
+ // bundle dies with an error nobody can act on, and the people this tool is
9
+ // for are told what to install instead.
10
+ import { nodeTooOld, tooOldMessage } from "./nodeCheck.mjs";
11
+
12
+ if (nodeTooOld(process.version)) {
13
+ process.stderr.write(tooOldMessage(process.version));
14
+ process.exitCode = 1;
15
+ } else {
16
+ import("../dist/devicerent.mjs");
17
+ }
@@ -0,0 +1,21 @@
1
+ // Kept to syntax every Node from 12 on can parse: this file has to run on the
2
+ // old Node it is warning about.
3
+
4
+ export var MIN_NODE_MAJOR = 22;
5
+
6
+ /** True when `version` ("v20.11.1" or "20.11.1") is older than we support. */
7
+ export function nodeTooOld(version) {
8
+ var major = Number(String(version).replace(/^v/, "").split(".")[0]);
9
+ return !(major >= MIN_NODE_MAJOR);
10
+ }
11
+
12
+ export function tooOldMessage(version) {
13
+ return (
14
+ "DeviceRent needs Node.js " +
15
+ MIN_NODE_MAJOR +
16
+ " or newer, and this computer has " +
17
+ version +
18
+ ".\n" +
19
+ "Install the LTS version from https://nodejs.org, open a new terminal, then run: npx devicerent\n"
20
+ );
21
+ }