@apet97/clockify-cli-115 1.0.0 → 2.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 +7 -6
- package/dist/client.js +11 -2
- package/dist/commands/helpers.js +10 -3
- package/dist/error-codes.js +3 -0
- package/dist/generated/version.js +1 -1
- package/dist/output.js +0 -12
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Command-line interface for [Clockify](https://clockify.me/), built on
|
|
4
4
|
top of `clockify-sdk-ts-115`.
|
|
5
5
|
|
|
6
|
-
Current release: `
|
|
7
|
-
`clockify-sdk-ts-115 ^
|
|
6
|
+
Current release: `2.0.0`. Requires Node.js `>=22.13.0` and
|
|
7
|
+
`clockify-sdk-ts-115 ^2`.
|
|
8
8
|
|
|
9
9
|
Two binaries, identical behavior:
|
|
10
10
|
|
|
@@ -74,12 +74,13 @@ touching production credentials.
|
|
|
74
74
|
`--select 0.name`) before emitting JSON or NDJSON.
|
|
75
75
|
|
|
76
76
|
In `json` and `ndjson` modes, errors go to stderr as `{"ok": false, "error":
|
|
77
|
-
"...", "code": "...", "recovery": "...", "retryable": true|false}
|
|
78
|
-
commands emit `{"ok": true, "message": "..."}`. `--no-color` disables ANSI
|
|
79
|
-
codes, and the CLI also auto-disables color when stdout is not a TTY.
|
|
77
|
+
"...", "code": "...", "recovery": "...", "retryable": true|false}`.
|
|
80
78
|
Successful write commands in JSON and NDJSON include receipt fields:
|
|
81
79
|
`ok`, `action`, `entity`, `ids`, `changed`, `warnings`, and `next`.
|
|
82
80
|
Legacy top-level fields such as `id` remain for simple shell scripts.
|
|
81
|
+
Read-only commands (e.g. `status`, `entries list`) print the requested
|
|
82
|
+
object or array directly, with no `ok` wrapper. `--no-color` disables
|
|
83
|
+
ANSI codes, and the CLI also auto-disables color when stdout is not a TTY.
|
|
83
84
|
|
|
84
85
|
## Commands
|
|
85
86
|
|
|
@@ -239,7 +240,7 @@ node dist/index.js status # smoke test (or invoke installed clk115/clockify11
|
|
|
239
240
|
```
|
|
240
241
|
|
|
241
242
|
`clockify-sdk-ts-115` is workspace-linked for local development and is a
|
|
242
|
-
`^
|
|
243
|
+
`^2` peer dependency for published consumers.
|
|
243
244
|
|
|
244
245
|
## License
|
|
245
246
|
|
package/dist/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { requireApiKey } from "./config.js";
|
|
2
|
-
const REGIONAL_PREFIXES = ["eu", "us", "uk", "au"];
|
|
3
|
-
const KNOWN_REGIONS = ["global", ...REGIONAL_PREFIXES, "developer"];
|
|
2
|
+
export const REGIONAL_PREFIXES = ["eu", "us", "uk", "au"];
|
|
3
|
+
export const KNOWN_REGIONS = ["global", ...REGIONAL_PREFIXES, "developer"];
|
|
4
4
|
export function buildRoutingOptions(region, subdomain) {
|
|
5
5
|
if (region === undefined && subdomain === undefined)
|
|
6
6
|
return undefined;
|
|
@@ -25,12 +25,21 @@ export function buildRoutingOptions(region, subdomain) {
|
|
|
25
25
|
acknowledgeUnconfirmedRegion: true,
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
+
export function unconfirmedRegionNotice(routing) {
|
|
29
|
+
if (routing === undefined || routing.profile === "global")
|
|
30
|
+
return undefined;
|
|
31
|
+
const host = routing.profile === "subdomain" ? `${routing.subdomain} (${routing.region})` : routing.profile;
|
|
32
|
+
return `clk115: using the unconfirmed "${host}" Clockify profile. Only the global profile is live-confirmed; drop --region/--subdomain (and CLOCKIFY_REGION/CLOCKIFY_SUBDOMAIN or the rc-file entry) to route to api.clockify.me.`;
|
|
33
|
+
}
|
|
28
34
|
export async function buildClient(config) {
|
|
29
35
|
const apiKey = requireApiKey(config);
|
|
30
36
|
const routing = buildRoutingOptions(config.region, config.subdomain);
|
|
31
37
|
if (routing !== undefined && config.baseUrl !== undefined) {
|
|
32
38
|
throw new Error("clk115: --region/--subdomain and --base-url configure the same thing two different ways; provide only one of them.");
|
|
33
39
|
}
|
|
40
|
+
const notice = unconfirmedRegionNotice(routing);
|
|
41
|
+
if (notice !== undefined)
|
|
42
|
+
process.stderr.write(`${notice}\n`);
|
|
34
43
|
const { createClockifyClient } = await import("clockify-sdk-ts-115");
|
|
35
44
|
if (routing !== undefined) {
|
|
36
45
|
return createClockifyClient({ apiKey, allowNonClockifyHttpsHost: false, routing });
|
package/dist/commands/helpers.js
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
import { InvalidArgumentError } from "commander";
|
|
2
2
|
import { requireWorkspaceId } from "../config.js";
|
|
3
3
|
import { globalFlags, resolveFlags } from "../index.js";
|
|
4
|
+
function parseStrictNumber(value) {
|
|
5
|
+
const trimmed = value.trim();
|
|
6
|
+
if (trimmed === "" || /^[+-]?0[xXoObB]/.test(trimmed)) {
|
|
7
|
+
return Number.NaN;
|
|
8
|
+
}
|
|
9
|
+
return Number(trimmed);
|
|
10
|
+
}
|
|
4
11
|
export function parseIntArg(value) {
|
|
5
|
-
const parsed =
|
|
12
|
+
const parsed = parseStrictNumber(value);
|
|
6
13
|
if (!Number.isInteger(parsed) || parsed <= 0) {
|
|
7
14
|
throw new InvalidArgumentError("must be a positive integer.");
|
|
8
15
|
}
|
|
9
16
|
return parsed;
|
|
10
17
|
}
|
|
11
18
|
export function parseFloatArg(value) {
|
|
12
|
-
const parsed =
|
|
19
|
+
const parsed = parseStrictNumber(value);
|
|
13
20
|
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
14
21
|
throw new InvalidArgumentError("must be a positive number.");
|
|
15
22
|
}
|
|
16
23
|
return parsed;
|
|
17
24
|
}
|
|
18
25
|
export function parseSignedFloatArg(value) {
|
|
19
|
-
const parsed =
|
|
26
|
+
const parsed = parseStrictNumber(value);
|
|
20
27
|
if (!Number.isFinite(parsed)) {
|
|
21
28
|
throw new InvalidArgumentError("must be a number.");
|
|
22
29
|
}
|
package/dist/error-codes.js
CHANGED
|
@@ -245,6 +245,9 @@ export function errorCodeForMessage(message) {
|
|
|
245
245
|
return "not_found";
|
|
246
246
|
if (/(unauthorized|forbidden|permission|api[\s_-]?key|addon[\s_-]?token|CLOCKIFY_API_KEY|CLOCKIFY_ADDON_TOKEN|workspace id not set)/i.test(message))
|
|
247
247
|
return "auth_or_permission";
|
|
248
|
+
if (/(upstream|gateway|bad gateway|service unavailable|internal server error)/i.test(message)) {
|
|
249
|
+
return "clockify_upstream_error";
|
|
250
|
+
}
|
|
248
251
|
if (/(required|provide|missing|invalid|unknown option|unknown command|could not parse|not valid|must use|must not|confirmation token)/i.test(message)) {
|
|
249
252
|
return "invalid_request";
|
|
250
253
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const PACKAGE_VERSION = "
|
|
1
|
+
export const PACKAGE_VERSION = "2.0.0";
|
package/dist/output.js
CHANGED
|
@@ -42,18 +42,6 @@ export function printObject(obj, opts) {
|
|
|
42
42
|
}
|
|
43
43
|
console.log(table.toString());
|
|
44
44
|
}
|
|
45
|
-
export function printSuccess(message, opts) {
|
|
46
|
-
if (opts.mode === "ndjson") {
|
|
47
|
-
printNdjson({ ok: true, message }, opts);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
if (opts.mode === "json") {
|
|
51
|
-
printJson({ ok: true, message }, opts);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const prefix = opts.color ? pc.green("OK") : "OK";
|
|
55
|
-
console.log(`${prefix} ${message}`);
|
|
56
|
-
}
|
|
57
45
|
export function printError(message, opts, statusCode) {
|
|
58
46
|
const messageCode = errorCodeForMessage(message);
|
|
59
47
|
const code = messageCode === "not_found" && statusCode === 400
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apet97/clockify-cli-115",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Unofficial, community-built — not affiliated with CAKE.com or Clockify. Command-line interface for Clockify, built on clockify-sdk-ts-115.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Aleksandar Petković <petkovic.aleksandar037@gmail.com>",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"zod": "^4.4.3"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"clockify-sdk-ts-115": "^
|
|
57
|
+
"clockify-sdk-ts-115": "^2"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/node": "^22",
|