activitysmith-cli
Advanced tools
+4
-3
| { | ||
| "name": "activitysmith-cli", | ||
| "version": "1.9.0", | ||
| "version": "1.10.0", | ||
| "description": "Command-line interface for ActivitySmith. Send push notifications, manage Live Activities, and set App Icon Badge Counts from your terminal.", | ||
@@ -41,8 +41,9 @@ "keywords": [ | ||
| "scripts": { | ||
| "lint": "node --check src/cli.js" | ||
| "lint": "node --check src/cli.js", | ||
| "test": "node --test" | ||
| }, | ||
| "dependencies": { | ||
| "activitysmith": "^1.9.0", | ||
| "activitysmith": "^1.10.0", | ||
| "commander": "^12.1.0" | ||
| } | ||
| } |
+16
-0
@@ -23,2 +23,3 @@ # ActivitySmith CLI | ||
| - [Channels](#channels) | ||
| - [Tags](#tags) | ||
| - [Aliases](#aliases) | ||
@@ -599,2 +600,13 @@ - [Content State Options](#content-state-options) | ||
| ## Tags | ||
| Use `tags` to organize and filter your Push Notification and Live Activity history. Tags are created automatically when you first use them. | ||
| ```bash | ||
| activitysmith push \ | ||
| --title "New subscription 💸" \ | ||
| --message "Customer upgraded to Pro plan" \ | ||
| --tags "user:382,billing" | ||
| ``` | ||
| ## Aliases | ||
@@ -648,2 +660,6 @@ | ||
| Organization options: | ||
| - `--tags <comma-separated-tags>` (for `push`, `activity stream`, and `activity start`; repeat the option to add more tags) | ||
| Widget metric options: | ||
@@ -650,0 +666,0 @@ |
+62
-12
@@ -83,2 +83,19 @@ #!/usr/bin/env node | ||
| const parseTagsOption = (value, previous = []) => { | ||
| if (typeof value !== "string") { | ||
| throw new InvalidArgumentError("tags must be a comma-separated string"); | ||
| } | ||
| const tags = value | ||
| .split(",") | ||
| .map((tag) => tag.trim()) | ||
| .filter((tag) => tag.length > 0); | ||
| if (tags.length === 0) { | ||
| throw new InvalidArgumentError("tags must contain at least one tag"); | ||
| } | ||
| return [...previous, ...tags]; | ||
| }; | ||
| const parseMetricValueArgument = (value) => { | ||
@@ -913,2 +930,13 @@ if (typeof value !== "string") { | ||
| const withTags = (request, tags) => { | ||
| if (!tags || tags.length === 0) { | ||
| return request; | ||
| } | ||
| return { | ||
| ...request, | ||
| tags, | ||
| }; | ||
| }; | ||
| const toApiLiveActivityUpdateRequest = ( | ||
@@ -1204,2 +1232,7 @@ activityId, | ||
| ) | ||
| .option( | ||
| "--tags <tags>", | ||
| "Comma-separated tags for organizing history (repeatable)", | ||
| parseTagsOption | ||
| ) | ||
| .action(async (options) => { | ||
@@ -1231,2 +1264,3 @@ const globalOptions = program.opts(); | ||
| actions, | ||
| tags: options.tags, | ||
| }, | ||
@@ -1332,2 +1366,7 @@ options.channels | ||
| ) | ||
| .option( | ||
| "--tags <tags>", | ||
| "Comma-separated tags for organizing history (repeatable)", | ||
| parseTagsOption | ||
| ) | ||
| .action(async (streamKey, options) => { | ||
@@ -1345,9 +1384,12 @@ const globalOptions = program.opts(); | ||
| streamKey, | ||
| withTargetChannels( | ||
| toApiLiveActivityStreamRequest( | ||
| contentState, | ||
| action, | ||
| secondaryAction | ||
| withTags( | ||
| withTargetChannels( | ||
| toApiLiveActivityStreamRequest( | ||
| contentState, | ||
| action, | ||
| secondaryAction | ||
| ), | ||
| options.channels | ||
| ), | ||
| options.channels | ||
| options.tags | ||
| ) | ||
@@ -1379,2 +1421,7 @@ ); | ||
| ) | ||
| .option( | ||
| "--tags <tags>", | ||
| "Comma-separated tags for organizing history (repeatable)", | ||
| parseTagsOption | ||
| ) | ||
| .action(async (options) => { | ||
@@ -1391,9 +1438,12 @@ const globalOptions = program.opts(); | ||
| const response = await client.liveActivities.startLiveActivity({ | ||
| liveActivityStartRequest: withTargetChannels( | ||
| toApiLiveActivityStartRequest( | ||
| contentState, | ||
| action, | ||
| secondaryAction | ||
| liveActivityStartRequest: withTags( | ||
| withTargetChannels( | ||
| toApiLiveActivityStartRequest( | ||
| contentState, | ||
| action, | ||
| secondaryAction | ||
| ), | ||
| options.channels | ||
| ), | ||
| options.channels | ||
| options.tags | ||
| ), | ||
@@ -1400,0 +1450,0 @@ }); |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
63874
2.58%1331
3.42%0
-100%682
2.4%Updated