@userland.fun/cli 0.3.0 → 0.3.2
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 +2 -0
- package/dist/index.js +17 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ npm install -g @userland.fun/cli
|
|
|
17
17
|
Then run:
|
|
18
18
|
|
|
19
19
|
```sh
|
|
20
|
+
userland --version
|
|
20
21
|
userland login
|
|
21
22
|
userland login --no-browser
|
|
22
23
|
userland signup
|
|
@@ -48,6 +49,7 @@ userland apps domains verify <app-id> <hostname>
|
|
|
48
49
|
From this repo, the same commands can be run from source:
|
|
49
50
|
|
|
50
51
|
```sh
|
|
52
|
+
npm run userland -- --version
|
|
51
53
|
npm run userland -- login
|
|
52
54
|
npm run userland -- login --no-browser
|
|
53
55
|
npm run userland -- signup
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { spawn } from "node:child_process";
|
|
3
|
-
import { promises as fs } from "node:fs";
|
|
3
|
+
import { promises as fs, readFileSync } from "node:fs";
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { createInterface } from "node:readline/promises";
|
|
7
7
|
const DEFAULT_API_BASE_URL = "https://api.userland.fun";
|
|
8
8
|
const DEFAULT_CONSOLE_BASE_URL = "https://console.userland.fun";
|
|
9
|
-
const CLI_VERSION =
|
|
9
|
+
const CLI_VERSION = readCliVersion();
|
|
10
|
+
function readCliVersion() {
|
|
11
|
+
const packageJson = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
12
|
+
if (typeof packageJson.version !== "string" || packageJson.version.length === 0) {
|
|
13
|
+
throw new Error("Unable to read CLI package version");
|
|
14
|
+
}
|
|
15
|
+
return packageJson.version;
|
|
16
|
+
}
|
|
10
17
|
async function main() {
|
|
11
18
|
const [command, ...args] = process.argv.slice(2);
|
|
12
19
|
if (isHelpCommand(command)) {
|
|
13
20
|
usage(0);
|
|
14
21
|
}
|
|
22
|
+
if (isVersionCommand(command)) {
|
|
23
|
+
console.log(CLI_VERSION);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
15
26
|
if (command === "apps") {
|
|
16
27
|
await appsCommand(args);
|
|
17
28
|
return;
|
|
@@ -1280,9 +1291,13 @@ function docsUrlForError(message) {
|
|
|
1280
1291
|
function isHelpCommand(command) {
|
|
1281
1292
|
return command === "--help" || command === "-h" || command === "help";
|
|
1282
1293
|
}
|
|
1294
|
+
function isVersionCommand(command) {
|
|
1295
|
+
return command === "--version" || command === "version";
|
|
1296
|
+
}
|
|
1283
1297
|
function usage(exitCode) {
|
|
1284
1298
|
const message = `Usage:
|
|
1285
1299
|
userland [--help]
|
|
1300
|
+
userland --version
|
|
1286
1301
|
userland signup [--no-browser] [--email <email>] [--api-base-url <url>] [--console-url <url>] [--no-save]
|
|
1287
1302
|
userland login [--no-browser] [--email <email>] [--api-base-url <url>] [--console-url <url>] [--no-save]
|
|
1288
1303
|
userland auth status
|