activitysmith-cli 1.8.0 → 1.9.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.
Files changed (3) hide show
  1. package/README.md +54 -13
  2. package/package.json +4 -3
  3. package/src/cli.js +54 -1
package/README.md CHANGED
@@ -17,8 +17,9 @@ CLI wrapper for the ActivitySmith API using the official Node SDK.
17
17
  - [Live Activity Action](#live-activity-action)
18
18
  - [Icons and Badges](#icons-and-badges)
19
19
  - [Live Activity Colors](#live-activity-colors)
20
- - [Channels](#channels)
21
20
  - [Widgets](#widgets)
21
+ - [App Icon Badge Count](#app-icon-badge-count)
22
+ - [Channels](#channels)
22
23
  - [Aliases](#aliases)
23
24
  - [Content State Options](#content-state-options)
24
25
  - [Output](#output)
@@ -51,6 +52,7 @@ The skill maps those requests to the CLI:
51
52
  - action buttons for follow-up links or Shortcut buttons
52
53
  - Live Activities for long-running progress
53
54
  - widget metrics for values that should stay visible
55
+ - App Icon Badge Counts for a number that should stay on the app icon
54
56
 
55
57
  Install the public skill from this repo:
56
58
 
@@ -519,17 +521,6 @@ Choose from these colors for the Live Activity accent, including progress bars a
519
521
 
520
522
  `lime`, `green`, `cyan`, `blue`, `purple`, `magenta`, `red`, `orange`, `yellow`, `gray`
521
523
 
522
- ## Channels
523
-
524
- Channels are used to target specific team members or devices. Can be used for both push notifications and live activities.
525
-
526
- ```bash
527
- activitysmith push \
528
- --title "Build Failed 🚨" \
529
- --message "CI pipeline failed on main branch" \
530
- --channels "devs,ops"
531
- ```
532
-
533
524
  ## Widgets
534
525
 
535
526
  <p align="center">
@@ -554,6 +545,56 @@ String metric values work too.
554
545
  activitysmith metrics update prod.status healthy
555
546
  ```
556
547
 
548
+ ## App Icon Badge Count
549
+
550
+ <p align="center">
551
+ <img src="https://cdn.activitysmith.com/features/badge-count.png" alt="ActivitySmith app icon with an App Icon Badge Count" width="680" />
552
+ </p>
553
+
554
+ Show the number you care about on your ActivitySmith app icon. Track MRR, a customer count, a stock price, or any other value you want to keep in view.
555
+
556
+ Set or update the badge value.
557
+
558
+ ```bash
559
+ activitysmith badge 8333
560
+ ```
561
+
562
+ To clear the badge, set its value to 0.
563
+
564
+ ```bash
565
+ activitysmith badge 0
566
+ ```
567
+
568
+ ## Channels
569
+
570
+ Use `--channels` to target specific team members or devices
571
+
572
+ ### Push Notifications
573
+
574
+ ```bash
575
+ activitysmith push \
576
+ --title "New subscription 💸" \
577
+ --message "Customer upgraded to Pro plan" \
578
+ --channels "sales,customer-success"
579
+ ```
580
+
581
+ ### Live Activities
582
+
583
+ ```bash
584
+ activitysmith activity start \
585
+ --title "Nightly Database Backup" \
586
+ --subtitle "verify restore" \
587
+ --type progress \
588
+ --percentage 62 \
589
+ --channels "sales,customer-success"
590
+ ```
591
+
592
+ ### App Icon Badge Count
593
+
594
+ ```bash
595
+ activitysmith badge 3 --channels "sales,customer-success"
596
+ ```
597
+
557
598
  ## Aliases
558
599
 
559
600
  The CLI installs two bin names:
@@ -600,7 +641,7 @@ Live Activity action options:
600
641
 
601
642
  Targeting options:
602
643
 
603
- - `--channels <comma-separated-slugs>` (for `push`, `activity stream`, and `activity start`)
644
+ - `--channels <comma-separated-slugs>` (for `push`, `badge`, `activity stream`, and `activity start`)
604
645
 
605
646
  Widget metric options:
606
647
 
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "activitysmith-cli",
3
- "version": "1.8.0",
4
- "description": "Command-line interface for ActivitySmith. Send push notifications and manage Live Activities from your terminal.",
3
+ "version": "1.9.0",
4
+ "description": "Command-line interface for ActivitySmith. Send push notifications, manage Live Activities, and set App Icon Badge Counts from your terminal.",
5
5
  "keywords": [
6
6
  "activitysmith",
7
7
  "live-activities",
8
8
  "push-notifications",
9
+ "app-icon-badge",
9
10
  "api",
10
11
  "cli",
11
12
  "deployment",
@@ -40,7 +41,7 @@
40
41
  "lint": "node --check src/cli.js"
41
42
  },
42
43
  "dependencies": {
43
- "activitysmith": "^1.8.0",
44
+ "activitysmith": "^1.9.0",
44
45
  "commander": "^12.1.0"
45
46
  }
46
47
  }
package/src/cli.js CHANGED
@@ -29,6 +29,16 @@ const parseIntegerOption = (label) => (value) => {
29
29
  return parsed;
30
30
  };
31
31
 
32
+ const parseBadgeCountArgument = (value) => {
33
+ const badge = parseIntegerOption("badge")(value);
34
+ if (badge < 0 || badge > 2147483647) {
35
+ throw new InvalidArgumentError(
36
+ "badge must be an integer between 0 and 2147483647"
37
+ );
38
+ }
39
+ return badge;
40
+ };
41
+
32
42
  const parseNumberOption = (label) => (value) => {
33
43
  const parsed = Number(value);
34
44
  if (!Number.isFinite(parsed)) {
@@ -223,7 +233,11 @@ const addLiveActivityActionOptions = (command) =>
223
233
  const getApiKey = (options) =>
224
234
  options.apiKey || process.env.ACTIVITYSMITH_API_KEY;
225
235
 
226
- const createClient = (apiKey) => new ActivitySmith({ apiKey });
236
+ const createClient = (apiKey) =>
237
+ new ActivitySmith({
238
+ apiKey,
239
+ sdk: { name: "cli", version },
240
+ });
227
241
 
228
242
  const assertPlainObject = (value, label) => {
229
243
  const isPlainObject =
@@ -1233,6 +1247,45 @@ program
1233
1247
  }
1234
1248
  });
1235
1249
 
1250
+ program
1251
+ .command("badge")
1252
+ .alias("badge-count")
1253
+ .description("Set App Icon Badge Count; pass 0 to clear it")
1254
+ .argument(
1255
+ "<value>",
1256
+ "App Icon Badge Count; pass 0 to clear it",
1257
+ parseBadgeCountArgument
1258
+ )
1259
+ .option(
1260
+ "--channels <channels>",
1261
+ "Comma-separated channel slugs (optional)",
1262
+ parseChannelsOption
1263
+ )
1264
+ .action(async (value, options) => {
1265
+ const globalOptions = program.opts();
1266
+
1267
+ try {
1268
+ const apiKey = requireApiKey(globalOptions);
1269
+ const client = createClient(apiKey);
1270
+ const response = await client.badgeCount(
1271
+ value,
1272
+ options.channels ? { channels: options.channels } : undefined
1273
+ );
1274
+
1275
+ outputResult(response, globalOptions, [
1276
+ value === 0
1277
+ ? "App Icon Badge Count cleared."
1278
+ : "App Icon Badge Count updated.",
1279
+ response?.badge !== undefined ? `Badge: ${response.badge}` : null,
1280
+ response?.devicesNotified !== undefined
1281
+ ? `Devices notified: ${response.devicesNotified}`
1282
+ : null,
1283
+ ]);
1284
+ } catch (error) {
1285
+ await handleError(error, globalOptions);
1286
+ }
1287
+ });
1288
+
1236
1289
  const metricsCommand = program
1237
1290
  .command("metrics")
1238
1291
  .alias("metric")