onlineornot 0.0.16 → 1.0.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 +10 -21
- package/onlineornot-dist/cli.js +31 -8
- package/onlineornot-dist/cli.js.map +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,30 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
`onlineornot` is a CLI for monitoring your uptime checks on [OnlineOrNot](https://onlineornot.com/).
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
To login, you'll need create an environment variable named `ONLINEORNOT_API_TOKEN`, and set it to an OnlineOrNot API token, which you can find [here](https://onlineornot.com/app/settings/developers).
|
|
8
|
-
|
|
9
|
-
For example:
|
|
5
|
+
## Quick Start
|
|
10
6
|
|
|
11
|
-
```bash
|
|
12
|
-
export ONLINEORNOT_API_TOKEN=token-goes-here
|
|
13
|
-
npx onlineornot whoami
|
|
14
7
|
```
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
✅ onlineornot 0.0.10
|
|
20
|
-
----------------------
|
|
21
|
-
Getting User settings...
|
|
22
|
-
👋 You are logged in with an API Token.
|
|
8
|
+
npm i -g onlineornot
|
|
9
|
+
onlineornot login
|
|
10
|
+
export ONLINEORNOT_API_TOKEN=api-token-goes-here
|
|
11
|
+
onlineornot checks list
|
|
23
12
|
```
|
|
24
13
|
|
|
25
|
-
##
|
|
14
|
+
## Docs
|
|
26
15
|
|
|
27
|
-
|
|
16
|
+
There are docs for:
|
|
28
17
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
18
|
+
- [Installing and updating `onlineornot`](https://onlineornot.com/docs/cli-installation)
|
|
19
|
+
- [Logging in](https://onlineornot.com/docs/cli-login)
|
|
20
|
+
- [CLI Commands](https://onlineornot.com/docs/cli-commands)
|
package/onlineornot-dist/cli.js
CHANGED
|
@@ -24390,7 +24390,7 @@ var Yargs = YargsFactory(esm_default);
|
|
|
24390
24390
|
var yargs_default = Yargs;
|
|
24391
24391
|
|
|
24392
24392
|
// package.json
|
|
24393
|
-
var version = "0.0
|
|
24393
|
+
var version = "1.0.0";
|
|
24394
24394
|
var package_default = {
|
|
24395
24395
|
name: "onlineornot",
|
|
24396
24396
|
version,
|
|
@@ -25256,8 +25256,8 @@ var getOnlineOrNotAPITokenFromEnv = getEnvironmentVariableFactory({
|
|
|
25256
25256
|
});
|
|
25257
25257
|
|
|
25258
25258
|
// src/user/index.ts
|
|
25259
|
-
var NOT_LOGGED_IN_MSG = "You are not logged in
|
|
25260
|
-
var INVALID_TOKEN_MSG = "Your API token is invalid
|
|
25259
|
+
var NOT_LOGGED_IN_MSG = "You are not logged in.\nRerun this command with ONLINEORNOT_API_TOKEN set as an environment variable.";
|
|
25260
|
+
var INVALID_TOKEN_MSG = "Your API token is invalid.\nRerun this command with a different ONLINEORNOT_API_TOKEN set as an environment variable.";
|
|
25261
25261
|
function getToken() {
|
|
25262
25262
|
const token = getOnlineOrNotAPITokenFromEnv();
|
|
25263
25263
|
if (!token) {
|
|
@@ -25447,11 +25447,27 @@ function options(yargs) {
|
|
|
25447
25447
|
}
|
|
25448
25448
|
async function handler(args) {
|
|
25449
25449
|
await verifyToken();
|
|
25450
|
-
|
|
25451
|
-
|
|
25452
|
-
|
|
25453
|
-
|
|
25454
|
-
|
|
25450
|
+
let result;
|
|
25451
|
+
try {
|
|
25452
|
+
result = await fetchResult(`/checks/`, {
|
|
25453
|
+
method: "POST",
|
|
25454
|
+
headers: { "content-type": "application/json" },
|
|
25455
|
+
body: JSON.stringify({ name: args.name, url: args.url })
|
|
25456
|
+
});
|
|
25457
|
+
} catch (err) {
|
|
25458
|
+
const errorWithCode = err;
|
|
25459
|
+
if (errorWithCode.code === 10004) {
|
|
25460
|
+
return logger.error(
|
|
25461
|
+
"You have reached the maximum number of checks for your account. Please upgrade to a paid plan to add more checks."
|
|
25462
|
+
);
|
|
25463
|
+
} else if (errorWithCode.code === 1e4) {
|
|
25464
|
+
return logger.error(
|
|
25465
|
+
"Validation error: " + errorWithCode?.notes?.[0].text
|
|
25466
|
+
);
|
|
25467
|
+
} else {
|
|
25468
|
+
return logger.error(err);
|
|
25469
|
+
}
|
|
25470
|
+
}
|
|
25455
25471
|
if (args.json) {
|
|
25456
25472
|
logger.log(JSON.stringify(result, null, " "));
|
|
25457
25473
|
} else {
|
|
@@ -25581,7 +25597,14 @@ function loginOptions() {
|
|
|
25581
25597
|
}
|
|
25582
25598
|
async function loginHandler() {
|
|
25583
25599
|
const urlToOpen = "https://onlineornot.com/app/settings/developers";
|
|
25600
|
+
const apiToken = getTokenQuietly();
|
|
25584
25601
|
await printBanner();
|
|
25602
|
+
if (apiToken) {
|
|
25603
|
+
return logger.log(
|
|
25604
|
+
`You are already logged in with an API token.
|
|
25605
|
+
You can generate another token at ${urlToOpen}`
|
|
25606
|
+
);
|
|
25607
|
+
}
|
|
25585
25608
|
logger.log(`Opening a link in your default browser: ${urlToOpen}`);
|
|
25586
25609
|
logger.log(
|
|
25587
25610
|
`-----------------------------------------------------------------------`
|