peakurl 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 +5 -20
- package/bin/peakurl.js +139 -48
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# PeakURL - Command-Line Interface
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
|
|
3
5
|
The official command-line interface for PeakURL.
|
|
4
6
|
|
|
5
7
|
Use `peakurl` to create short links, inspect existing links, and manage your PeakURL account from the terminal.
|
|
@@ -11,7 +13,7 @@ Learn more in the full CLI docs: <https://peakurl.org/docs/cli>
|
|
|
11
13
|
Node.js 20 or later is required.
|
|
12
14
|
|
|
13
15
|
```bash
|
|
14
|
-
npm
|
|
16
|
+
npm i -g peakurl
|
|
15
17
|
```
|
|
16
18
|
|
|
17
19
|
## Quick Start
|
|
@@ -190,7 +192,7 @@ peakurl update
|
|
|
190
192
|
Install the latest version manually:
|
|
191
193
|
|
|
192
194
|
```bash
|
|
193
|
-
npm
|
|
195
|
+
npm i -g peakurl@latest
|
|
194
196
|
```
|
|
195
197
|
|
|
196
198
|
Disable update notices in the current shell:
|
|
@@ -205,27 +207,10 @@ export PEAKURL_DISABLE_UPDATE_CHECK=1
|
|
|
205
207
|
- `--json` prints machine-readable JSON where supported
|
|
206
208
|
- `--quiet` minimizes output for scripts
|
|
207
209
|
|
|
208
|
-
If you run an authenticated command before logging in, the CLI explains what to do next and shows the command to retry:
|
|
209
|
-
|
|
210
|
-
```text
|
|
211
|
-
Authentication required.
|
|
212
|
-
PeakURL could not find credentials for this command.
|
|
213
|
-
Use one of the first two steps below, then run the last command.
|
|
214
|
-
+---------------------------+-----------------------------------------------------+-----------------------------------------+
|
|
215
|
-
| Step | Command | Notes |
|
|
216
|
-
+---------------------------+-----------------------------------------------------+-----------------------------------------+
|
|
217
|
-
| Save credentials | peakurl login --base-url https://example.com/api/v1 | Regular use on this machine |
|
|
218
|
-
| | --api-key YOUR_API_KEY | |
|
|
219
|
-
| Set environment variables | PEAKURL_BASE_URL=https://example.com/api/v1 | CI, scripts, or one-off use |
|
|
220
|
-
| | PEAKURL_API_KEY=YOUR_API_KEY | |
|
|
221
|
-
| Then run | peakurl whoami | After completing one of the steps above |
|
|
222
|
-
+---------------------------+-----------------------------------------------------+-----------------------------------------+
|
|
223
|
-
```
|
|
224
|
-
|
|
225
210
|
## Links
|
|
226
211
|
|
|
227
212
|
- Website: <https://peakurl.org/>
|
|
228
213
|
- CLI docs: <https://peakurl.org/docs/cli>
|
|
229
214
|
- API docs: <https://peakurl.org/docs/api>
|
|
230
215
|
- npm package: <https://www.npmjs.com/package/peakurl>
|
|
231
|
-
- Issues: <https://github.com/PeakURL/
|
|
216
|
+
- Issues: <https://github.com/PeakURL/CLI/issues>
|
package/bin/peakurl.js
CHANGED
|
@@ -1539,7 +1539,7 @@ function compareSemver(left, right) {
|
|
|
1539
1539
|
return comparePrerelease(parsedLeft.prerelease, parsedRight.prerelease);
|
|
1540
1540
|
}
|
|
1541
1541
|
function getUpdateInstallCommand() {
|
|
1542
|
-
return `npm
|
|
1542
|
+
return `npm i -g ${PACKAGE_NAME}@latest`;
|
|
1543
1543
|
}
|
|
1544
1544
|
async function fetchLatestVersion(env) {
|
|
1545
1545
|
const registryUrl = normalizeRegistryUrl(getRegistryBaseUrl(env));
|
|
@@ -2168,6 +2168,17 @@ function parseNumber(label) {
|
|
|
2168
2168
|
return parsed;
|
|
2169
2169
|
};
|
|
2170
2170
|
}
|
|
2171
|
+
function addExamples(command, lines) {
|
|
2172
|
+
return command.addHelpText(
|
|
2173
|
+
"after",
|
|
2174
|
+
`
|
|
2175
|
+
Examples:
|
|
2176
|
+
${lines.map((line) => ` ${line}`).join("\n")}
|
|
2177
|
+
|
|
2178
|
+
Documentation:
|
|
2179
|
+
https://peakurl.org/docs/cli`
|
|
2180
|
+
);
|
|
2181
|
+
}
|
|
2171
2182
|
async function getCliVersion() {
|
|
2172
2183
|
const packageJson = new URL("../package.json", import.meta.url);
|
|
2173
2184
|
const content = await readFile3(packageJson, "utf8");
|
|
@@ -2190,23 +2201,26 @@ function getRetryCommandName(argv) {
|
|
|
2190
2201
|
async function main() {
|
|
2191
2202
|
const program = new Command();
|
|
2192
2203
|
const version = await getCliVersion();
|
|
2193
|
-
program.name("peakurl").description("PeakURL
|
|
2204
|
+
program.name("peakurl").description("Manage your PeakURL site from the terminal.").helpOption("-h, --help", "Show help").helpCommand("help [command]", "Show help for a command").version(version, "-V, --version", "Show CLI version").showHelpAfterError().showSuggestionAfterError().addHelpText(
|
|
2194
2205
|
"after",
|
|
2195
2206
|
`
|
|
2196
|
-
|
|
2197
|
-
peakurl login --base-url https://example.com/api/v1 --api-key
|
|
2198
|
-
peakurl whoami
|
|
2199
|
-
peakurl
|
|
2207
|
+
Get Started:
|
|
2208
|
+
peakurl login --base-url https://example.com/api/v1 --api-key YOUR_API_KEY
|
|
2209
|
+
peakurl whoami
|
|
2210
|
+
peakurl create https://example.com/docs --alias docs
|
|
2211
|
+
|
|
2212
|
+
Common Commands:
|
|
2200
2213
|
peakurl status
|
|
2201
|
-
peakurl
|
|
2214
|
+
peakurl list --limit 10
|
|
2202
2215
|
peakurl import ./links.csv
|
|
2203
2216
|
peakurl export --format csv
|
|
2204
|
-
peakurl list --limit 10
|
|
2205
2217
|
peakurl webhook list
|
|
2206
|
-
peakurl webhook create https://example.com/api/webhooks/peakurl --event link.clicked
|
|
2207
2218
|
peakurl update --check
|
|
2208
|
-
|
|
2209
|
-
|
|
2219
|
+
|
|
2220
|
+
Documentation:
|
|
2221
|
+
https://peakurl.org/docs/cli
|
|
2222
|
+
|
|
2223
|
+
Run 'peakurl <command> --help' for command-specific flags and examples.`
|
|
2210
2224
|
).exitOverride();
|
|
2211
2225
|
program.hook("preAction", async (_command, actionCommand) => {
|
|
2212
2226
|
const options = actionCommand.optsWithGlobals();
|
|
@@ -2217,43 +2231,120 @@ Examples:
|
|
|
2217
2231
|
env: process.env
|
|
2218
2232
|
});
|
|
2219
2233
|
});
|
|
2220
|
-
|
|
2221
|
-
"Save
|
|
2222
|
-
|
|
2223
|
-
"
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
"
|
|
2235
|
-
)
|
|
2236
|
-
|
|
2237
|
-
"
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
"--
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
"--
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2234
|
+
addExamples(
|
|
2235
|
+
program.command("login").summary("Save API credentials").description(
|
|
2236
|
+
"Save PeakURL credentials after verifying them with GET /users/me."
|
|
2237
|
+
).helpOption("-h, --help", "Show help").option(
|
|
2238
|
+
"--base-url <url>",
|
|
2239
|
+
"PeakURL API base URL, for example https://example.com/api/v1"
|
|
2240
|
+
).option("--api-key <token>", "PeakURL API key to store").option("--json", "Print machine-readable output").option("--quiet", "Suppress success output").action(login),
|
|
2241
|
+
[
|
|
2242
|
+
"peakurl login --base-url https://example.com/api/v1 --api-key YOUR_API_KEY",
|
|
2243
|
+
"peakurl login --json"
|
|
2244
|
+
]
|
|
2245
|
+
);
|
|
2246
|
+
addExamples(
|
|
2247
|
+
program.command("whoami").summary("Show the current account").description("Show the current authenticated PeakURL user.").helpOption("-h, --help", "Show help").option("--json", "Print machine-readable output").option("--quiet", "Print a minimal identity value").action(whoami),
|
|
2248
|
+
["peakurl whoami", "peakurl whoami --json"]
|
|
2249
|
+
);
|
|
2250
|
+
addExamples(
|
|
2251
|
+
program.command("logout").summary("Remove saved credentials").description("Remove saved PeakURL credentials from this device.").helpOption("-h, --help", "Show help").option("--json", "Print machine-readable output").option("--quiet", "Suppress success output").action(logout),
|
|
2252
|
+
["peakurl logout", "peakurl logout --json"]
|
|
2253
|
+
);
|
|
2254
|
+
addExamples(
|
|
2255
|
+
program.command("status").summary("Show site system status").description("Show the current PeakURL system status snapshot.").helpOption("-h, --help", "Show help").option("--json", "Print machine-readable output").option("--quiet", "Print only the overall health value").action(status),
|
|
2256
|
+
["peakurl status", "peakurl status --json", "peakurl status --quiet"]
|
|
2257
|
+
);
|
|
2258
|
+
addExamples(
|
|
2259
|
+
program.command("create").summary("Create a short link").description("Create a PeakURL short link.").helpOption("-h, --help", "Show help").argument("<url>", "Destination URL to shorten").option("--alias <alias>", "Custom alias for the short link").option("--title <title>", "Title to store with the short link").option("--password <password>", "Password-protect the short link").option(
|
|
2260
|
+
"--status <status>",
|
|
2261
|
+
"Link status, for example active or paused"
|
|
2262
|
+
).option(
|
|
2263
|
+
"--expires-at <iso>",
|
|
2264
|
+
"Expiration timestamp in ISO-8601 format"
|
|
2265
|
+
).option("--utm-source <value>", "UTM source").option("--utm-medium <value>", "UTM medium").option("--utm-campaign <value>", "UTM campaign").option("--utm-term <value>", "UTM term").option("--utm-content <value>", "UTM content").option("--json", "Print machine-readable output").option("--quiet", "Print only the created short URL").action(createLink),
|
|
2266
|
+
[
|
|
2267
|
+
"peakurl create https://example.com/docs --alias docs",
|
|
2268
|
+
'peakurl create https://example.com/launch --title "Launch Page"',
|
|
2269
|
+
"peakurl create https://example.com --json"
|
|
2270
|
+
]
|
|
2271
|
+
);
|
|
2272
|
+
addExamples(
|
|
2273
|
+
program.command("import").summary("Import links from a file").description(
|
|
2274
|
+
"Import multiple short links from a local CSV, JSON, or XML file."
|
|
2275
|
+
).helpOption("-h, --help", "Show help").argument("<file>", "Path to the import file").option("--format <format>", "File format: csv, json, or xml").option("--json", "Print machine-readable output").option("--quiet", "Print only the created short URLs").action(importLinks),
|
|
2276
|
+
["peakurl import ./links.csv", "peakurl import ./links.xml --json"]
|
|
2277
|
+
);
|
|
2278
|
+
addExamples(
|
|
2279
|
+
program.command("export").summary("Export links to a file").description(
|
|
2280
|
+
"Export accessible links as a local CSV, JSON, or XML file."
|
|
2281
|
+
).helpOption("-h, --help", "Show help").option("--format <format>", "File format: csv, json, or xml").option("--output <path>", "Write the export to a specific file").option("--stdout", "Write the raw export content to stdout").option("--search <query>", "Search term").option("--sort-by <field>", "Sort field").option(
|
|
2282
|
+
"--sort-order <order>",
|
|
2283
|
+
"Sort order, for example asc or desc"
|
|
2284
|
+
).option("--quiet", "Print only the saved export path").action(exportLinks),
|
|
2285
|
+
[
|
|
2286
|
+
"peakurl export --format csv",
|
|
2287
|
+
"peakurl export --format json --stdout",
|
|
2288
|
+
"peakurl export --format xml --output ./backups/links.xml"
|
|
2289
|
+
]
|
|
2290
|
+
);
|
|
2291
|
+
addExamples(
|
|
2292
|
+
program.command("list").summary("List short links").description("List PeakURL short links.").helpOption("-h, --help", "Show help").option("--page <number>", "Page number", parseNumber("page")).option("--limit <number>", "Page size", parseNumber("limit")).option("--search <query>", "Search term").option("--sort-by <field>", "Sort field").option(
|
|
2293
|
+
"--sort-order <order>",
|
|
2294
|
+
"Sort order, for example asc or desc"
|
|
2295
|
+
).option("--json", "Print machine-readable output").option("--quiet", "Print a minimal per-link value").action(listLinks),
|
|
2296
|
+
[
|
|
2297
|
+
"peakurl list",
|
|
2298
|
+
"peakurl list --limit 25 --page 1",
|
|
2299
|
+
"peakurl list --search launch --json"
|
|
2300
|
+
]
|
|
2301
|
+
);
|
|
2302
|
+
addExamples(
|
|
2303
|
+
program.command("get").summary("Show one short link").description("Fetch a single PeakURL short link by id or alias.").helpOption("-h, --help", "Show help").argument("<id-or-alias>", "Link identifier or alias").option("--json", "Print machine-readable output").option("--quiet", "Print only the short URL").action(getLink),
|
|
2304
|
+
["peakurl get docs", "peakurl get url_123 --json"]
|
|
2305
|
+
);
|
|
2306
|
+
addExamples(
|
|
2307
|
+
program.command("delete").summary("Delete one short link").description("Delete a PeakURL short link by id or alias.").helpOption("-h, --help", "Show help").argument("<id-or-alias>", "Link identifier or alias").option("--json", "Print machine-readable output").option("--quiet", "Suppress success output").action(deleteLink),
|
|
2308
|
+
["peakurl delete docs", "peakurl delete url_123 --quiet"]
|
|
2309
|
+
);
|
|
2310
|
+
addExamples(
|
|
2311
|
+
program.command("update").summary("Check for CLI updates").description(
|
|
2312
|
+
"Check for a newer CLI version and print the npm command to install it."
|
|
2313
|
+
).helpOption("-h, --help", "Show help").option(
|
|
2314
|
+
"--check",
|
|
2315
|
+
"Alias for checking update status without changing anything"
|
|
2316
|
+
).option("--json", "Print machine-readable output").option("--quiet", "Print minimal output").action((options) => checkUpdate(options, version)),
|
|
2317
|
+
["peakurl update", "peakurl update --check", "peakurl update --json"]
|
|
2318
|
+
);
|
|
2319
|
+
const webhook = program.command("webhook").alias("webhooks").summary("Manage webhooks").helpOption("-h, --help", "Show help").description("Manage outbound webhook integrations.");
|
|
2320
|
+
addExamples(webhook, [
|
|
2321
|
+
"peakurl webhook list",
|
|
2322
|
+
"peakurl webhook create https://example.com/api/webhooks/peakurl --event link.clicked",
|
|
2323
|
+
"peakurl webhook events"
|
|
2324
|
+
]);
|
|
2325
|
+
addExamples(
|
|
2326
|
+
webhook.command("list").summary("List webhooks").description("List outbound webhooks.").helpOption("-h, --help", "Show help").option("--json", "Print machine-readable output").option("--quiet", "Print minimal webhook identifiers").action(listWebhooks),
|
|
2327
|
+
["peakurl webhook list", "peakurl webhook list --json"]
|
|
2328
|
+
);
|
|
2329
|
+
addExamples(
|
|
2330
|
+
webhook.command("create").summary("Create a webhook").description("Create an outbound webhook.").helpOption("-h, --help", "Show help").argument("<url>", "Webhook endpoint URL").option(
|
|
2331
|
+
"--event <event>",
|
|
2332
|
+
"Webhook event id, for example link.clicked",
|
|
2333
|
+
parseWebhookEvents
|
|
2334
|
+
).option("--json", "Print machine-readable output").option("--quiet", "Print only the created webhook ID").action(createWebhook),
|
|
2335
|
+
[
|
|
2336
|
+
"peakurl webhook create https://example.com/api/webhooks/peakurl --event link.clicked",
|
|
2337
|
+
"peakurl webhook create https://example.com/api/webhooks/peakurl --event link.clicked --event link.created"
|
|
2338
|
+
]
|
|
2339
|
+
);
|
|
2340
|
+
addExamples(
|
|
2341
|
+
webhook.command("delete").summary("Delete a webhook").description("Delete an outbound webhook by id.").helpOption("-h, --help", "Show help").argument("<id>", "Webhook identifier").option("--json", "Print machine-readable output").option("--quiet", "Suppress success output").action(deleteWebhook),
|
|
2342
|
+
["peakurl webhook delete webhook_123"]
|
|
2343
|
+
);
|
|
2344
|
+
addExamples(
|
|
2345
|
+
webhook.command("events").summary("List supported events").description("List the webhook events supported by the CLI.").helpOption("-h, --help", "Show help").option("--json", "Print machine-readable output").option("--quiet", "Print only event ids").action(listWebhookEvents),
|
|
2346
|
+
["peakurl webhook events", "peakurl webhook events --json"]
|
|
2347
|
+
);
|
|
2257
2348
|
try {
|
|
2258
2349
|
await program.parseAsync(process.argv);
|
|
2259
2350
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "peakurl",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Official CLI for creating, listing, and managing PeakURL short links from the terminal",
|
|
5
5
|
"homepage": "https://peakurl.org",
|
|
6
6
|
"bugs": {
|
|
7
|
-
"url": "https://github.com/PeakURL/
|
|
7
|
+
"url": "https://github.com/PeakURL/CLI/issues"
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/PeakURL/
|
|
11
|
+
"url": "git+https://github.com/PeakURL/CLI.git"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
14
14
|
"peakurl",
|