@referalli/cli 0.0.0-stage → 0.1.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/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/README.md +75 -2
- package/dist/bin/referalli.d.ts +2 -0
- package/dist/bin/referalli.js +36 -0
- package/dist/src/client.d.ts +18 -0
- package/dist/src/client.js +38 -0
- package/dist/src/commands.d.ts +38 -0
- package/dist/src/commands.js +329 -0
- package/dist/src/config.d.ts +13 -0
- package/dist/src/config.js +32 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.js +118 -0
- package/dist/src/version.d.ts +2 -0
- package/dist/src/version.js +2 -0
- package/package.json +55 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@referalli/cli` are recorded here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and versions follow
|
|
5
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html). Before 1.0, a minor
|
|
6
|
+
bump may include breaking changes; they are called out under **Changed**.
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- First public release: `referalli login`, `whoami`, `keys`, `listen --forward-to`, `trigger`, `events tail`, `logs tail`, `api` and `open`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Referalli
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,76 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @referalli/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Referalli command line. Sign in from the terminal, forward webhooks to your laptop, fire test events, and watch events and API requests live.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install -g @referalli/cli # or: npx @referalli/cli <command>
|
|
7
|
+
referalli login
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Requires Node.js 20 or later.
|
|
11
|
+
|
|
12
|
+
## Sign in
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
referalli login # opens a browser to approve this device (owner or admin)
|
|
16
|
+
referalli login --no-browser # prints the approval link instead
|
|
17
|
+
referalli login --key rk_test_… # paste an API key instead (checked before it is saved)
|
|
18
|
+
referalli whoami
|
|
19
|
+
referalli logout
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The key is saved to `~/.config/referalli/cli.json` with mode 600. In CI, set `REFERALLI_API_KEY` instead and nothing is written to disk.
|
|
23
|
+
|
|
24
|
+
## Forward webhooks to localhost
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
referalli listen --forward-to http://localhost:3000/webhooks
|
|
28
|
+
referalli listen --events referral.created,commission.earned --forward-to http://localhost:3000/webhooks
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`listen` prints a signing secret for the session. Each event is delivered to your URL with Standard Webhooks headers (`webhook-id`, `webhook-timestamp`, `webhook-signature`) signed with that secret, so your verification code runs unchanged. Without `--forward-to`, events are printed.
|
|
32
|
+
|
|
33
|
+
## Fire test events
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
referalli trigger # lists the topics you can trigger
|
|
37
|
+
referalli trigger referral.created
|
|
38
|
+
referalli trigger commission.earned --data '{"amountMinor": 2500}'
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
A triggered event is sent to every running `listen` session and to your webhook endpoints.
|
|
42
|
+
|
|
43
|
+
## Watch what is happening
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
referalli events tail # every event, one line each
|
|
47
|
+
referalli events tail --events payout.sent --json # full event bodies, for piping into jq
|
|
48
|
+
referalli logs tail # your API requests: method, path, status, latency
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Everything else
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
referalli keys create --name "Dana laptop" --owner dana@example.com --mode test
|
|
55
|
+
referalli keys list
|
|
56
|
+
referalli keys revoke key_…
|
|
57
|
+
referalli api GET /v1/partners
|
|
58
|
+
referalli api POST /v1/links --data '{"partnerId":"prt_…","programId":"prg_…"}'
|
|
59
|
+
referalli open docs # also: dashboard, keys, webhooks, spec, status
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Environment
|
|
63
|
+
|
|
64
|
+
| Variable | Meaning |
|
|
65
|
+
| --- | --- |
|
|
66
|
+
| `REFERALLI_API_KEY` | Use this key instead of the saved login |
|
|
67
|
+
| `REFERALLI_API_URL` | API base URL (default `https://referalli.com`; `http://localhost:4000` for a local API) |
|
|
68
|
+
| `REFERALLI_CONFIG_DIR` | Where the login is saved (default `~/.config/referalli`) |
|
|
69
|
+
|
|
70
|
+
## Links
|
|
71
|
+
|
|
72
|
+
- Docs: https://referalli.com/docs
|
|
73
|
+
- Issues: https://github.com/Referalli/referalli-cli/issues
|
|
74
|
+
- Changelog: [CHANGELOG.md](./CHANGELOG.md)
|
|
75
|
+
|
|
76
|
+
MIT licensed.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import { runCli } from '../src/index.js';
|
|
4
|
+
const controller = new AbortController();
|
|
5
|
+
// The first Ctrl-C stops a running command cleanly (listeners are closed); a second one exits at once.
|
|
6
|
+
process.on('SIGINT', () => {
|
|
7
|
+
if (controller.signal.aborted)
|
|
8
|
+
process.exit(130);
|
|
9
|
+
controller.abort();
|
|
10
|
+
});
|
|
11
|
+
const openBrowser = (url) => {
|
|
12
|
+
const cmd = process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd' : 'xdg-open';
|
|
13
|
+
const args = process.platform === 'win32' ? ['/c', 'start', '', url] : [url];
|
|
14
|
+
try {
|
|
15
|
+
spawn(cmd, args, { stdio: 'ignore', detached: true }).on('error', () => { }).unref();
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const code = await runCli(process.argv.slice(2), {
|
|
23
|
+
out: (line) => process.stdout.write(`${line}\n`),
|
|
24
|
+
err: (line) => process.stderr.write(`${line}\n`),
|
|
25
|
+
env: process.env,
|
|
26
|
+
sleep: (ms) => new Promise((resolve) => {
|
|
27
|
+
const t = setTimeout(resolve, ms);
|
|
28
|
+
controller.signal.addEventListener('abort', () => {
|
|
29
|
+
clearTimeout(t);
|
|
30
|
+
resolve();
|
|
31
|
+
});
|
|
32
|
+
}),
|
|
33
|
+
openBrowser,
|
|
34
|
+
signal: controller.signal,
|
|
35
|
+
});
|
|
36
|
+
process.exit(code);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** A thin JSON client for the Referalli API, authenticated with the saved key. */
|
|
2
|
+
export declare class ApiError extends Error {
|
|
3
|
+
readonly status: number;
|
|
4
|
+
readonly code: string | null;
|
|
5
|
+
constructor(status: number, code: string | null, message: string);
|
|
6
|
+
}
|
|
7
|
+
export type FetchFn = typeof fetch;
|
|
8
|
+
export interface Client {
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
request<T = unknown>(method: string, path: string, body?: unknown, opts?: {
|
|
11
|
+
signal?: AbortSignal;
|
|
12
|
+
}): Promise<T>;
|
|
13
|
+
}
|
|
14
|
+
export declare function createClient(opts: {
|
|
15
|
+
baseUrl: string;
|
|
16
|
+
key?: string;
|
|
17
|
+
fetchFn?: FetchFn;
|
|
18
|
+
}): Client;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { VERSION } from './version.js';
|
|
2
|
+
/** A thin JSON client for the Referalli API, authenticated with the saved key. */
|
|
3
|
+
export class ApiError extends Error {
|
|
4
|
+
status;
|
|
5
|
+
code;
|
|
6
|
+
constructor(status, code, message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.code = code;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export function createClient(opts) {
|
|
13
|
+
const fetchFn = opts.fetchFn ?? fetch;
|
|
14
|
+
const baseUrl = opts.baseUrl.replace(/\/$/, '');
|
|
15
|
+
return {
|
|
16
|
+
baseUrl,
|
|
17
|
+
async request(method, path, body, ropts = {}) {
|
|
18
|
+
const headers = { 'user-agent': `referalli-cli/${VERSION}` };
|
|
19
|
+
if (opts.key)
|
|
20
|
+
headers.authorization = `Bearer ${opts.key}`;
|
|
21
|
+
if (body !== undefined)
|
|
22
|
+
headers['content-type'] = 'application/json';
|
|
23
|
+
const res = await fetchFn(`${baseUrl}${path}`, {
|
|
24
|
+
method,
|
|
25
|
+
headers,
|
|
26
|
+
body: body === undefined ? undefined : JSON.stringify(body),
|
|
27
|
+
signal: ropts.signal,
|
|
28
|
+
});
|
|
29
|
+
const text = await res.text();
|
|
30
|
+
const data = text ? JSON.parse(text) : null;
|
|
31
|
+
if (!res.ok) {
|
|
32
|
+
const err = data?.error;
|
|
33
|
+
throw new ApiError(res.status, err?.code ?? null, err?.message ?? `HTTP ${res.status}`);
|
|
34
|
+
}
|
|
35
|
+
return data;
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type FetchFn } from './client.js';
|
|
2
|
+
/** Everything a command touches, injected so commands are testable. */
|
|
3
|
+
export interface Io {
|
|
4
|
+
out(line: string): void;
|
|
5
|
+
err(line: string): void;
|
|
6
|
+
env: NodeJS.ProcessEnv;
|
|
7
|
+
fetchFn?: FetchFn;
|
|
8
|
+
sleep(ms: number): Promise<void>;
|
|
9
|
+
/** Try to open a URL in the browser; false when it couldn't. */
|
|
10
|
+
openBrowser(url: string): boolean;
|
|
11
|
+
/** Aborted on Ctrl-C: long-running commands stop and clean up. */
|
|
12
|
+
signal: AbortSignal;
|
|
13
|
+
}
|
|
14
|
+
export type Flags = Record<string, string | boolean>;
|
|
15
|
+
/** A user-facing failure: printed without a stack trace, exit code 1. */
|
|
16
|
+
export declare class CliError extends Error {
|
|
17
|
+
}
|
|
18
|
+
export declare function login(io: Io, flags: Flags): Promise<number>;
|
|
19
|
+
export declare function logout(io: Io): Promise<number>;
|
|
20
|
+
export declare function whoami(io: Io): Promise<number>;
|
|
21
|
+
export declare function listen(io: Io, flags: Flags): Promise<number>;
|
|
22
|
+
/**
|
|
23
|
+
* `referalli events tail`: print every event your account emits, live, one line each
|
|
24
|
+
* (or the full Standard Webhooks body with --json). It opens a CLI listener like
|
|
25
|
+
* `listen` does, without forwarding, and closes it on exit.
|
|
26
|
+
*/
|
|
27
|
+
export declare function eventsTail(io: Io, flags: Flags): Promise<number>;
|
|
28
|
+
export declare const OPEN_TARGETS: Record<string, string>;
|
|
29
|
+
/** `referalli open [docs|dashboard|keys|webhooks|spec|status]`: open the page, or print it. */
|
|
30
|
+
export declare function open(io: Io, target: string | undefined, flags: Flags): Promise<number>;
|
|
31
|
+
export declare function trigger(io: Io, topic: string | undefined, flags: Flags): Promise<number>;
|
|
32
|
+
export declare function logsTail(io: Io, flags: Flags): Promise<number>;
|
|
33
|
+
/**
|
|
34
|
+
* `referalli keys create|list|revoke`: mint a developer their own live and
|
|
35
|
+
* test keys (needs an admin key), list the team's keys, or revoke one.
|
|
36
|
+
*/
|
|
37
|
+
export declare function keys(io: Io, sub: string | undefined, arg: string | undefined, flags: Flags): Promise<number>;
|
|
38
|
+
export declare function api(io: Io, method: string | undefined, path: string | undefined, flags: Flags): Promise<number>;
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { hostname } from 'node:os';
|
|
2
|
+
import { ApiError, createClient } from './client.js';
|
|
3
|
+
import { DEFAULT_BASE_URL, readConfig, removeConfig, writeConfig } from './config.js';
|
|
4
|
+
/** A user-facing failure: printed without a stack trace, exit code 1. */
|
|
5
|
+
export class CliError extends Error {
|
|
6
|
+
}
|
|
7
|
+
function signedIn(io) {
|
|
8
|
+
const config = readConfig(io.env);
|
|
9
|
+
if (!config)
|
|
10
|
+
throw new CliError('Not signed in. Run `referalli login` first (or set REFERALLI_API_KEY).');
|
|
11
|
+
return { config, client: createClient({ baseUrl: config.baseUrl, key: config.key, fetchFn: io.fetchFn }) };
|
|
12
|
+
}
|
|
13
|
+
const time = (d) => new Date(d).toISOString().slice(11, 19);
|
|
14
|
+
export async function login(io, flags) {
|
|
15
|
+
const baseUrl = String(flags['base-url'] ?? io.env.REFERALLI_API_URL ?? DEFAULT_BASE_URL).replace(/\/$/, '');
|
|
16
|
+
if (typeof flags.key === 'string') {
|
|
17
|
+
// Non-interactive: check the pasted key works before saving it.
|
|
18
|
+
const client = createClient({ baseUrl, key: flags.key, fetchFn: io.fetchFn });
|
|
19
|
+
const org = await client.request('GET', '/v1/org');
|
|
20
|
+
const path = writeConfig({ baseUrl, key: flags.key, orgId: org.id, orgName: org.name }, io.env);
|
|
21
|
+
io.out(`Signed in to ${org.name} (${org.id}). Key saved to ${path}.`);
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
const client = createClient({ baseUrl, fetchFn: io.fetchFn });
|
|
25
|
+
const code = await client.request('POST', '/v1/cli/device-codes', { clientName: hostname().slice(0, 80) });
|
|
26
|
+
io.out(`Your sign-in code is ${code.userCode}.`);
|
|
27
|
+
io.out(`Confirm it at ${code.verificationUriComplete}`);
|
|
28
|
+
if (!flags['no-browser'] && io.openBrowser(code.verificationUriComplete))
|
|
29
|
+
io.out('(opened in your browser)');
|
|
30
|
+
io.out('Waiting for approval…');
|
|
31
|
+
const deadline = Date.now() + code.expiresIn * 1000;
|
|
32
|
+
let interval = code.interval * 1000;
|
|
33
|
+
while (Date.now() < deadline && !io.signal.aborted) {
|
|
34
|
+
await io.sleep(interval);
|
|
35
|
+
let result;
|
|
36
|
+
try {
|
|
37
|
+
result = await client.request('POST', '/v1/cli/device-codes/token', { deviceCode: code.deviceCode });
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
if (err instanceof ApiError && err.status === 429) {
|
|
41
|
+
interval += 1000; // asked to slow down
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
throw err;
|
|
45
|
+
}
|
|
46
|
+
if (result.status === 'approved') {
|
|
47
|
+
const path = writeConfig({ baseUrl, key: result.key, orgId: result.orgId, orgName: result.orgName }, io.env);
|
|
48
|
+
io.out(`Signed in to ${result.orgName} (${result.orgId}) with access: ${result.scopes.join(', ')}.`);
|
|
49
|
+
io.out(`Key saved to ${path}.`);
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
if (result.status === 'denied')
|
|
53
|
+
throw new CliError('The sign-in was denied.');
|
|
54
|
+
if (result.status === 'expired' || result.status === 'consumed')
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
throw new CliError('The sign-in code expired. Run `referalli login` again.');
|
|
58
|
+
}
|
|
59
|
+
export async function logout(io) {
|
|
60
|
+
io.out(removeConfig(io.env) ? 'Signed out; the saved key was removed. Revoke it under Settings → API keys if it may have leaked.' : 'Not signed in.');
|
|
61
|
+
return 0;
|
|
62
|
+
}
|
|
63
|
+
export async function whoami(io) {
|
|
64
|
+
const { config, client } = signedIn(io);
|
|
65
|
+
const org = await client.request('GET', '/v1/org');
|
|
66
|
+
io.out(`${org.name} (${org.id})`);
|
|
67
|
+
io.out(`API: ${config.baseUrl}`);
|
|
68
|
+
io.out(`Key: ${config.key.slice(0, 12)}…`);
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
71
|
+
export async function listen(io, flags) {
|
|
72
|
+
const { client } = signedIn(io);
|
|
73
|
+
const forwardTo = typeof flags['forward-to'] === 'string' ? flags['forward-to'] : null;
|
|
74
|
+
const topics = typeof flags.events === 'string' ? flags.events.split(',').map((s) => s.trim()).filter(Boolean) : undefined;
|
|
75
|
+
const maxEvents = typeof flags['max-events'] === 'string' ? Number(flags['max-events']) : Infinity;
|
|
76
|
+
const wait = typeof flags.wait === 'string' ? Number(flags.wait) : 20;
|
|
77
|
+
const fetchFn = io.fetchFn ?? fetch;
|
|
78
|
+
const listener = await client.request('POST', '/v1/cli/listeners', {
|
|
79
|
+
...(topics ? { topics } : {}),
|
|
80
|
+
...(forwardTo ? { forwardTo } : {}),
|
|
81
|
+
});
|
|
82
|
+
io.out(`Ready! Listening for ${listener.topics.join(', ')}${forwardTo ? ` and forwarding to ${forwardTo}` : ''}.`);
|
|
83
|
+
io.out(`Your webhook signing secret is ${listener.secret} (verify deliveries with it while testing).`);
|
|
84
|
+
let seen = 0;
|
|
85
|
+
try {
|
|
86
|
+
while (!io.signal.aborted && seen < maxEvents) {
|
|
87
|
+
let batch;
|
|
88
|
+
try {
|
|
89
|
+
batch = (await client.request('GET', `/v1/cli/listeners/${listener.id}/events?wait=${wait}`, undefined, { signal: io.signal })).events;
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
if (io.signal.aborted)
|
|
93
|
+
break;
|
|
94
|
+
io.err(`Polling failed (${err.message}); retrying…`);
|
|
95
|
+
await io.sleep(2000);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
for (const e of batch) {
|
|
99
|
+
seen++;
|
|
100
|
+
if (!forwardTo) {
|
|
101
|
+
io.out(`${time(new Date())} ${e.topic} [${e.eventId}]`);
|
|
102
|
+
io.out(e.body);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
const started = Date.now();
|
|
106
|
+
try {
|
|
107
|
+
const res = await fetchFn(forwardTo, { method: 'POST', headers: e.headers, body: e.body });
|
|
108
|
+
io.out(`${time(new Date())} --> ${e.topic} [${e.eventId}] <-- ${res.status} (${Date.now() - started}ms)`);
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
io.err(`${time(new Date())} --> ${e.topic} [${e.eventId}] failed: ${err.message}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (seen >= maxEvents)
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
finally {
|
|
120
|
+
await client.request('DELETE', `/v1/cli/listeners/${listener.id}`).catch(() => { });
|
|
121
|
+
}
|
|
122
|
+
return 0;
|
|
123
|
+
}
|
|
124
|
+
// --- events tail -----------------------------------------------------------------
|
|
125
|
+
/**
|
|
126
|
+
* `referalli events tail`: print every event your account emits, live, one line each
|
|
127
|
+
* (or the full Standard Webhooks body with --json). It opens a CLI listener like
|
|
128
|
+
* `listen` does, without forwarding, and closes it on exit.
|
|
129
|
+
*/
|
|
130
|
+
export async function eventsTail(io, flags) {
|
|
131
|
+
const { client } = signedIn(io);
|
|
132
|
+
const topics = typeof flags.events === 'string' ? flags.events.split(',').map((s) => s.trim()).filter(Boolean) : undefined;
|
|
133
|
+
const max = typeof flags.max === 'string' ? Number(flags.max) : Infinity;
|
|
134
|
+
const wait = typeof flags.wait === 'string' ? Number(flags.wait) : 20;
|
|
135
|
+
const listener = await client.request('POST', '/v1/cli/listeners', topics ? { topics } : {});
|
|
136
|
+
if (!flags.json)
|
|
137
|
+
io.err(`Tailing ${listener.topics.join(', ')} (Ctrl-C to stop)…`);
|
|
138
|
+
let seen = 0;
|
|
139
|
+
try {
|
|
140
|
+
while (!io.signal.aborted && seen < max) {
|
|
141
|
+
let batch;
|
|
142
|
+
try {
|
|
143
|
+
batch = (await client.request('GET', `/v1/cli/listeners/${listener.id}/events?wait=${wait}`, undefined, {
|
|
144
|
+
signal: io.signal,
|
|
145
|
+
})).events;
|
|
146
|
+
}
|
|
147
|
+
catch (err) {
|
|
148
|
+
if (io.signal.aborted)
|
|
149
|
+
break;
|
|
150
|
+
io.err(`Polling failed (${err.message}); retrying…`);
|
|
151
|
+
await io.sleep(2000);
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
for (const e of batch) {
|
|
155
|
+
seen++;
|
|
156
|
+
if (flags.json)
|
|
157
|
+
io.out(e.body);
|
|
158
|
+
else
|
|
159
|
+
io.out(`${time(new Date())} ${e.topic.padEnd(24)} ${e.eventId}${summarize(e.body)}`);
|
|
160
|
+
if (seen >= max)
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
finally {
|
|
166
|
+
await client.request('DELETE', `/v1/cli/listeners/${listener.id}`).catch(() => { });
|
|
167
|
+
}
|
|
168
|
+
return 0;
|
|
169
|
+
}
|
|
170
|
+
/** A short "key=value" tail for an event line: the ids and amounts a developer looks for. */
|
|
171
|
+
function summarize(body) {
|
|
172
|
+
try {
|
|
173
|
+
const data = JSON.parse(body).data ?? {};
|
|
174
|
+
const keys = ['partnerId', 'referralId', 'commissionId', 'payoutId', 'amountMinor', 'currency', 'status'];
|
|
175
|
+
const parts = keys.filter((k) => data[k] !== undefined && data[k] !== null).map((k) => `${k}=${String(data[k])}`);
|
|
176
|
+
return parts.length ? ` ${parts.join(' ')}` : '';
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
return '';
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// --- open --------------------------------------------------------------------------
|
|
183
|
+
export const OPEN_TARGETS = {
|
|
184
|
+
docs: '/docs',
|
|
185
|
+
dashboard: '/dashboard',
|
|
186
|
+
keys: '/settings',
|
|
187
|
+
webhooks: '/webhooks',
|
|
188
|
+
spec: '/v1/openapi.json',
|
|
189
|
+
status: '/status',
|
|
190
|
+
};
|
|
191
|
+
/** `referalli open [docs|dashboard|keys|webhooks|spec|status]`: open the page, or print it. */
|
|
192
|
+
export async function open(io, target, flags) {
|
|
193
|
+
const name = target ?? 'docs';
|
|
194
|
+
const path = OPEN_TARGETS[name];
|
|
195
|
+
if (!path)
|
|
196
|
+
throw new CliError(`Usage: referalli open [${Object.keys(OPEN_TARGETS).join('|')}]`);
|
|
197
|
+
const config = readConfig(io.env);
|
|
198
|
+
const base = String(flags['base-url'] ?? config?.baseUrl ?? io.env.REFERALLI_API_URL ?? DEFAULT_BASE_URL).replace(/\/$/, '');
|
|
199
|
+
const url = `${base}${path}`;
|
|
200
|
+
io.out(io.openBrowser(url) ? `Opened ${url}` : url);
|
|
201
|
+
return 0;
|
|
202
|
+
}
|
|
203
|
+
// --- trigger -----------------------------------------------------------------------
|
|
204
|
+
export async function trigger(io, topic, flags) {
|
|
205
|
+
const { client } = signedIn(io);
|
|
206
|
+
if (!topic) {
|
|
207
|
+
const { topics } = await client.request('GET', '/v1/cli/topics');
|
|
208
|
+
throw new CliError(`Usage: referalli trigger <topic>. Topics: ${topics.join(', ')}`);
|
|
209
|
+
}
|
|
210
|
+
let data;
|
|
211
|
+
if (typeof flags.data === 'string') {
|
|
212
|
+
try {
|
|
213
|
+
data = JSON.parse(flags.data);
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
throw new CliError('--data must be a JSON object, e.g. --data \'{"amountMinor": 2500}\'');
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
const res = await client.request('POST', '/v1/cli/trigger', { topic, ...(data ? { data } : {}) });
|
|
220
|
+
io.out(`Triggered ${topic} [${res.eventId}]: ${res.deliveredTo.listeners} listener(s), ${res.deliveredTo.endpoints} webhook endpoint(s).`);
|
|
221
|
+
return 0;
|
|
222
|
+
}
|
|
223
|
+
const logLine = (e) => `${time(e.ts)} ${e.method.padEnd(6)} ${e.path} ${e.status} ${e.latencyMs}ms ${e.requestId}`;
|
|
224
|
+
export async function logsTail(io, flags) {
|
|
225
|
+
const { client } = signedIn(io);
|
|
226
|
+
const max = typeof flags.max === 'string' ? Number(flags.max) : Infinity;
|
|
227
|
+
const wait = typeof flags.wait === 'string' ? Number(flags.wait) : 20;
|
|
228
|
+
let printed = 0;
|
|
229
|
+
const first = await client.request('GET', '/v1/cli/logs');
|
|
230
|
+
for (const e of first.entries) {
|
|
231
|
+
io.out(logLine(e));
|
|
232
|
+
if (++printed >= max)
|
|
233
|
+
return 0;
|
|
234
|
+
}
|
|
235
|
+
let cursor = first.cursor;
|
|
236
|
+
while (!io.signal.aborted && printed < max) {
|
|
237
|
+
let page;
|
|
238
|
+
try {
|
|
239
|
+
page = await client.request('GET', `/v1/cli/logs?after=${cursor}&wait=${wait}`, undefined, { signal: io.signal });
|
|
240
|
+
}
|
|
241
|
+
catch (err) {
|
|
242
|
+
if (io.signal.aborted)
|
|
243
|
+
break;
|
|
244
|
+
io.err(`Polling failed (${err.message}); retrying…`);
|
|
245
|
+
await io.sleep(2000);
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
for (const e of page.entries) {
|
|
249
|
+
io.out(logLine(e));
|
|
250
|
+
if (++printed >= max)
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
cursor = page.cursor;
|
|
254
|
+
}
|
|
255
|
+
return 0;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* `referalli keys create|list|revoke`: mint a developer their own live and
|
|
259
|
+
* test keys (needs an admin key), list the team's keys, or revoke one.
|
|
260
|
+
*/
|
|
261
|
+
export async function keys(io, sub, arg, flags) {
|
|
262
|
+
const { client } = signedIn(io);
|
|
263
|
+
if (sub === 'create') {
|
|
264
|
+
if (typeof flags.name !== 'string')
|
|
265
|
+
throw new CliError('Usage: referalli keys create --name NAME [--owner WHO] [--mode both|live|test] [--scopes full,…] [--expires-days N]');
|
|
266
|
+
const mode = typeof flags.mode === 'string' ? flags.mode : 'both';
|
|
267
|
+
if (!['both', 'live', 'test'].includes(mode))
|
|
268
|
+
throw new CliError('--mode is both, live or test');
|
|
269
|
+
const body = { name: flags.name, mode };
|
|
270
|
+
if (typeof flags.owner === 'string')
|
|
271
|
+
body.owner = flags.owner;
|
|
272
|
+
if (typeof flags.scopes === 'string')
|
|
273
|
+
body.scopes = flags.scopes.split(',').map((x) => x.trim()).filter(Boolean);
|
|
274
|
+
if (typeof flags['expires-days'] === 'string')
|
|
275
|
+
body.expiresInDays = Number(flags['expires-days']);
|
|
276
|
+
const res = await client.request('POST', '/v1/api-keys', body);
|
|
277
|
+
const issued = 'live' in res ? [res.live, res.test] : [res];
|
|
278
|
+
io.out('Each key is shown once. Store it now (a password manager or your secrets store):');
|
|
279
|
+
for (const k of issued)
|
|
280
|
+
io.out(` ${k.livemode ? 'live' : 'test'} ${k.key} (${k.id})`);
|
|
281
|
+
return 0;
|
|
282
|
+
}
|
|
283
|
+
if (sub === 'list') {
|
|
284
|
+
const q = new URLSearchParams();
|
|
285
|
+
if (typeof flags.owner === 'string')
|
|
286
|
+
q.set('owner', flags.owner);
|
|
287
|
+
if (typeof flags.mode === 'string')
|
|
288
|
+
q.set('mode', flags.mode);
|
|
289
|
+
const res = await client.request('GET', `/v1/api-keys${String(q) ? `?${q}` : ''}`);
|
|
290
|
+
const rows = Array.isArray(res) ? res : res.data;
|
|
291
|
+
for (const k of rows) {
|
|
292
|
+
const state = k.revokedAt ? 'revoked' : k.expired ? 'expired' : 'active';
|
|
293
|
+
io.out([k.id, k.livemode ? 'live' : 'test', state, `${k.prefix}…`, k.name, k.owner ?? '-', k.scopes.join(','), k.lastUsedAt ? `used ${k.lastUsedAt}` : 'never used']
|
|
294
|
+
.join(' '));
|
|
295
|
+
}
|
|
296
|
+
return 0;
|
|
297
|
+
}
|
|
298
|
+
if (sub === 'revoke') {
|
|
299
|
+
if (!arg)
|
|
300
|
+
throw new CliError('Usage: referalli keys revoke <key id> [--pair] [--cascade]');
|
|
301
|
+
const q = new URLSearchParams();
|
|
302
|
+
if (flags.pair)
|
|
303
|
+
q.set('pair', 'true');
|
|
304
|
+
if (flags.cascade)
|
|
305
|
+
q.set('cascade', 'true');
|
|
306
|
+
const res = await client.request('DELETE', `/v1/api-keys/${encodeURIComponent(arg)}${String(q) ? `?${q}` : ''}`);
|
|
307
|
+
io.out(`Revoked: ${res.revoked.join(', ') || 'nothing (already revoked)'}`);
|
|
308
|
+
return 0;
|
|
309
|
+
}
|
|
310
|
+
throw new CliError('Usage: referalli keys create|list|revoke');
|
|
311
|
+
}
|
|
312
|
+
// --- api ---------------------------------------------------------------------------
|
|
313
|
+
export async function api(io, method, path, flags) {
|
|
314
|
+
if (!method || !path)
|
|
315
|
+
throw new CliError('Usage: referalli api <METHOD> <path> [--data JSON]');
|
|
316
|
+
const { client } = signedIn(io);
|
|
317
|
+
let body;
|
|
318
|
+
if (typeof flags.data === 'string') {
|
|
319
|
+
try {
|
|
320
|
+
body = JSON.parse(flags.data);
|
|
321
|
+
}
|
|
322
|
+
catch {
|
|
323
|
+
throw new CliError('--data must be JSON');
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
const res = await client.request(method.toUpperCase(), path.startsWith('/') ? path : `/${path}`, body);
|
|
327
|
+
io.out(JSON.stringify(res, null, 2));
|
|
328
|
+
return 0;
|
|
329
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** What `referalli login` saves. The key is a secret: the file is mode 600. */
|
|
2
|
+
export interface CliConfig {
|
|
3
|
+
baseUrl: string;
|
|
4
|
+
key: string;
|
|
5
|
+
orgId?: string;
|
|
6
|
+
orgName?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const DEFAULT_BASE_URL = "https://referalli.com";
|
|
9
|
+
export declare const configDir: (env?: NodeJS.ProcessEnv) => string;
|
|
10
|
+
export declare const configPath: (env?: NodeJS.ProcessEnv) => string;
|
|
11
|
+
export declare function readConfig(env?: NodeJS.ProcessEnv): CliConfig | null;
|
|
12
|
+
export declare function writeConfig(config: CliConfig, env?: NodeJS.ProcessEnv): string;
|
|
13
|
+
export declare function removeConfig(env?: NodeJS.ProcessEnv): boolean;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
export const DEFAULT_BASE_URL = 'https://referalli.com';
|
|
5
|
+
export const configDir = (env = process.env) => env.REFERALLI_CONFIG_DIR ?? join(env.XDG_CONFIG_HOME ?? join(homedir(), '.config'), 'referalli');
|
|
6
|
+
export const configPath = (env = process.env) => join(configDir(env), 'cli.json');
|
|
7
|
+
export function readConfig(env = process.env) {
|
|
8
|
+
// Env wins, so CI can run the CLI without a saved login.
|
|
9
|
+
if (env.REFERALLI_API_KEY) {
|
|
10
|
+
return { baseUrl: env.REFERALLI_API_URL ?? DEFAULT_BASE_URL, key: env.REFERALLI_API_KEY };
|
|
11
|
+
}
|
|
12
|
+
const path = configPath(env);
|
|
13
|
+
if (!existsSync(path))
|
|
14
|
+
return null;
|
|
15
|
+
const parsed = JSON.parse(readFileSync(path, 'utf8'));
|
|
16
|
+
return { ...parsed, baseUrl: env.REFERALLI_API_URL ?? parsed.baseUrl };
|
|
17
|
+
}
|
|
18
|
+
export function writeConfig(config, env = process.env) {
|
|
19
|
+
const dir = configDir(env);
|
|
20
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
21
|
+
const path = configPath(env);
|
|
22
|
+
writeFileSync(path, `${JSON.stringify(config, null, 2)}\n`, { mode: 0o600 });
|
|
23
|
+
chmodSync(path, 0o600); // an existing file keeps its old mode on write
|
|
24
|
+
return path;
|
|
25
|
+
}
|
|
26
|
+
export function removeConfig(env = process.env) {
|
|
27
|
+
const path = configPath(env);
|
|
28
|
+
if (!existsSync(path))
|
|
29
|
+
return false;
|
|
30
|
+
rmSync(path);
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Io } from './commands.js';
|
|
2
|
+
export { readConfig, writeConfig, configPath, type CliConfig } from './config.js';
|
|
3
|
+
export { createClient, ApiError } from './client.js';
|
|
4
|
+
export type { Io } from './commands.js';
|
|
5
|
+
export { VERSION } from './version.js';
|
|
6
|
+
export declare const HELP = "referalli: the Referalli command line\n\nUsage:\n referalli login [--key rk_\u2026] [--base-url URL] [--no-browser]\n referalli logout\n referalli whoami\n referalli listen [--forward-to URL] [--events topic,topic] [--max-events N]\n referalli trigger <topic> [--data JSON]\n referalli events tail [--events topic,topic] [--json] [--max N]\n referalli logs tail [--max N]\n referalli open [docs|dashboard|keys|webhooks|spec|status]\n referalli api <METHOD> <path> [--data JSON]\n referalli keys create --name NAME [--owner WHO] [--mode both|live|test] [--scopes full,\u2026] [--expires-days N]\n referalli keys list [--owner WHO] [--mode live|test]\n referalli keys revoke <key id> [--pair] [--cascade]\n\nEnvironment:\n REFERALLI_API_KEY use this key instead of the saved login\n REFERALLI_API_URL API base URL (default: the hosted API)\n REFERALLI_CONFIG_DIR where the login is saved (default ~/.config/referalli)";
|
|
7
|
+
/** Run one command; returns the process exit code. */
|
|
8
|
+
export declare function runCli(argv: string[], io: Io): Promise<number>;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { parseArgs } from 'node:util';
|
|
2
|
+
import { ApiError } from './client.js';
|
|
3
|
+
import { api, CliError, eventsTail, keys, login, listen, logout, logsTail, open, trigger, whoami } from './commands.js';
|
|
4
|
+
import { VERSION } from './version.js';
|
|
5
|
+
export { readConfig, writeConfig, configPath } from './config.js';
|
|
6
|
+
export { createClient, ApiError } from './client.js';
|
|
7
|
+
export { VERSION } from './version.js';
|
|
8
|
+
export const HELP = `referalli: the Referalli command line
|
|
9
|
+
|
|
10
|
+
Usage:
|
|
11
|
+
referalli login [--key rk_…] [--base-url URL] [--no-browser]
|
|
12
|
+
referalli logout
|
|
13
|
+
referalli whoami
|
|
14
|
+
referalli listen [--forward-to URL] [--events topic,topic] [--max-events N]
|
|
15
|
+
referalli trigger <topic> [--data JSON]
|
|
16
|
+
referalli events tail [--events topic,topic] [--json] [--max N]
|
|
17
|
+
referalli logs tail [--max N]
|
|
18
|
+
referalli open [docs|dashboard|keys|webhooks|spec|status]
|
|
19
|
+
referalli api <METHOD> <path> [--data JSON]
|
|
20
|
+
referalli keys create --name NAME [--owner WHO] [--mode both|live|test] [--scopes full,…] [--expires-days N]
|
|
21
|
+
referalli keys list [--owner WHO] [--mode live|test]
|
|
22
|
+
referalli keys revoke <key id> [--pair] [--cascade]
|
|
23
|
+
|
|
24
|
+
Environment:
|
|
25
|
+
REFERALLI_API_KEY use this key instead of the saved login
|
|
26
|
+
REFERALLI_API_URL API base URL (default: the hosted API)
|
|
27
|
+
REFERALLI_CONFIG_DIR where the login is saved (default ~/.config/referalli)`;
|
|
28
|
+
/** Run one command; returns the process exit code. */
|
|
29
|
+
export async function runCli(argv, io) {
|
|
30
|
+
let parsed;
|
|
31
|
+
try {
|
|
32
|
+
parsed = parseArgs({
|
|
33
|
+
args: argv,
|
|
34
|
+
allowPositionals: true,
|
|
35
|
+
strict: true,
|
|
36
|
+
options: {
|
|
37
|
+
key: { type: 'string' },
|
|
38
|
+
'base-url': { type: 'string' },
|
|
39
|
+
'no-browser': { type: 'boolean' },
|
|
40
|
+
'forward-to': { type: 'string' },
|
|
41
|
+
events: { type: 'string' },
|
|
42
|
+
'max-events': { type: 'string' },
|
|
43
|
+
max: { type: 'string' },
|
|
44
|
+
wait: { type: 'string' },
|
|
45
|
+
data: { type: 'string' },
|
|
46
|
+
name: { type: 'string' },
|
|
47
|
+
owner: { type: 'string' },
|
|
48
|
+
mode: { type: 'string' },
|
|
49
|
+
scopes: { type: 'string' },
|
|
50
|
+
'expires-days': { type: 'string' },
|
|
51
|
+
pair: { type: 'boolean' },
|
|
52
|
+
cascade: { type: 'boolean' },
|
|
53
|
+
json: { type: 'boolean' },
|
|
54
|
+
help: { type: 'boolean', short: 'h' },
|
|
55
|
+
version: { type: 'boolean', short: 'v' },
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
io.err(err.message);
|
|
61
|
+
io.err(HELP);
|
|
62
|
+
return 2;
|
|
63
|
+
}
|
|
64
|
+
const flags = parsed.values;
|
|
65
|
+
const [command, ...rest] = parsed.positionals;
|
|
66
|
+
if (flags.version) {
|
|
67
|
+
io.out(VERSION);
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
70
|
+
if (!command || flags.help) {
|
|
71
|
+
io.out(HELP);
|
|
72
|
+
return command || flags.help ? 0 : 2;
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
switch (command) {
|
|
76
|
+
case 'login':
|
|
77
|
+
return await login(io, flags);
|
|
78
|
+
case 'logout':
|
|
79
|
+
return await logout(io);
|
|
80
|
+
case 'whoami':
|
|
81
|
+
return await whoami(io);
|
|
82
|
+
case 'listen':
|
|
83
|
+
return await listen(io, flags);
|
|
84
|
+
case 'trigger':
|
|
85
|
+
return await trigger(io, rest[0], flags);
|
|
86
|
+
case 'logs':
|
|
87
|
+
if (rest[0] !== 'tail')
|
|
88
|
+
throw new CliError('Usage: referalli logs tail');
|
|
89
|
+
return await logsTail(io, flags);
|
|
90
|
+
case 'events':
|
|
91
|
+
if (rest[0] !== 'tail')
|
|
92
|
+
throw new CliError('Usage: referalli events tail');
|
|
93
|
+
return await eventsTail(io, flags);
|
|
94
|
+
case 'open':
|
|
95
|
+
return await open(io, rest[0], flags);
|
|
96
|
+
case 'version':
|
|
97
|
+
io.out(VERSION);
|
|
98
|
+
return 0;
|
|
99
|
+
case 'api':
|
|
100
|
+
return await api(io, rest[0], rest[1], flags);
|
|
101
|
+
case 'keys':
|
|
102
|
+
return await keys(io, rest[0], rest[1], flags);
|
|
103
|
+
default:
|
|
104
|
+
io.err(`Unknown command "${command}".`);
|
|
105
|
+
io.err(HELP);
|
|
106
|
+
return 2;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
if (err instanceof CliError)
|
|
111
|
+
io.err(err.message);
|
|
112
|
+
else if (err instanceof ApiError)
|
|
113
|
+
io.err(`API error ${err.status}${err.code ? ` (${err.code})` : ''}: ${err.message}`);
|
|
114
|
+
else
|
|
115
|
+
io.err(`Error: ${err.message}`);
|
|
116
|
+
return 1;
|
|
117
|
+
}
|
|
118
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@referalli/cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "The Referalli command line: sign in, forward webhooks to localhost, trigger test events, tail events and API logs.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=20"
|
|
9
|
+
},
|
|
10
|
+
"bin": {
|
|
11
|
+
"referalli": "./dist/bin/referalli.js"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/src/index.d.ts",
|
|
16
|
+
"default": "./dist/src/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md",
|
|
22
|
+
"LICENSE",
|
|
23
|
+
"CHANGELOG.md"
|
|
24
|
+
],
|
|
25
|
+
"keywords": [
|
|
26
|
+
"referalli",
|
|
27
|
+
"cli",
|
|
28
|
+
"webhooks",
|
|
29
|
+
"referral",
|
|
30
|
+
"affiliate"
|
|
31
|
+
],
|
|
32
|
+
"homepage": "https://referalli.com/docs",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/Referalli/referalli-cli.git"
|
|
36
|
+
},
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/Referalli/referalli-cli/issues"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public",
|
|
42
|
+
"provenance": true
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && chmod +x dist/bin/referalli.js",
|
|
46
|
+
"prepack": "npm run build",
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"typecheck": "tsc --noEmit",
|
|
49
|
+
"start": "tsx bin/referalli.ts"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/node": "^22.9.0",
|
|
53
|
+
"tsx": "^4.19.2",
|
|
54
|
+
"typescript": "^5.6.3",
|
|
55
|
+
"vitest": "^3.0.0"
|
|
56
|
+
}
|
|
57
|
+
}
|