@kolatts/pncli 1.26.0 → 3.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.
@@ -0,0 +1,178 @@
1
+ # Split.IO
2
+
3
+ pncli uses the Split Admin API v2 directly; no external CLI is required.
4
+
5
+ ## Configuration
6
+
7
+ | Key | Environment variable | Purpose |
8
+ |---|---|---|
9
+ | `splitio.baseUrl` | `PNCLI_SPLITIO_BASE_URL` | Split Admin API base URL, such as `https://api.split.io` |
10
+ | `splitio.adminApiKey` | `PNCLI_SPLITIO_ADMIN_API_KEY` | Admin API key generated in the Split UI |
11
+
12
+ Generate an Admin API key in the Split UI under **Admin Settings → API Keys → Admin**.
13
+
14
+ ```bash
15
+ pncli config set splitio.baseUrl https://api.split.io
16
+ pncli config set splitio.adminApiKey <your-admin-api-key>
17
+ pncli config test
18
+ ```
19
+
20
+ ## Change Controls
21
+
22
+ Every write command submits a **Change Request** (CR) rather than modifying flag definitions directly. Each CR requires:
23
+
24
+ | Flag | Required | Description |
25
+ |---|---|---|
26
+ | `--mnemonic` | Yes | Short title for the CR (appears in the Split UI) |
27
+ | `--description` | Yes | Longer description of the intent |
28
+ | `--change-number` | Yes | ServiceNow change ticket (e.g. `CHG0001234`) |
29
+ | `--approvers` | Situational | Comma-separated Split user IDs for non-production approvals |
30
+ | `--yes` | Optional | Skip interactive confirmation (for CI/CD pipelines) |
31
+
32
+ All write commands prompt for confirmation unless `--yes` is supplied. The `--dry-run` flag prints the request body without sending it.
33
+
34
+ ## Commands
35
+
36
+ ### Discovery
37
+
38
+ ```bash
39
+ # List all workspaces
40
+ pncli splitio workspaces list
41
+
42
+ # List environments in a workspace
43
+ pncli splitio environments list --workspace <wsId>
44
+
45
+ # List feature flags in a workspace (paginated)
46
+ pncli splitio flags list --workspace <wsId>
47
+ pncli splitio flags list --workspace <wsId> --limit 100 --offset 0
48
+ pncli splitio flags list --workspace <wsId> --flag-set my-flag-set
49
+ ```
50
+
51
+ ### Inspect
52
+
53
+ ```bash
54
+ # Get a flag's global definition (treatments, traffic type, tags)
55
+ pncli splitio flags get --workspace <wsId> --flag my-feature
56
+
57
+ # Get a flag's full definition including targeting rules for one environment
58
+ pncli splitio flags get --workspace <wsId> --flag my-feature --environment <envId>
59
+ ```
60
+
61
+ ### Update (full definition replacement)
62
+
63
+ Provide the complete flag definition as JSON via `--input-file`. Use `pncli splitio flags get --environment` to retrieve the current definition before editing it.
64
+
65
+ ```bash
66
+ pncli splitio flags update \
67
+ --workspace <wsId> --flag my-feature --environment <envId> \
68
+ --mnemonic "SPLIT-001" --description "Enable feature for all users" \
69
+ --change-number CHG0001234 --approvers "user-id-1,user-id-2" \
70
+ --input-file definition.json
71
+ ```
72
+
73
+ The file must contain the full definition object (treatments, rules, defaultRule, etc.).
74
+
75
+ ### Change one rule
76
+
77
+ ```bash
78
+ # Route all traffic in rule 0 to one treatment
79
+ pncli splitio flags set-rule \
80
+ --workspace <wsId> --flag my-feature --environment <envId> \
81
+ --rule-index 0 --treatment on \
82
+ --mnemonic "SPLIT-002" --description "Route beta users to on" \
83
+ --change-number CHG0001234
84
+
85
+ # Weighted distribution for rule 1
86
+ pncli splitio flags set-rule \
87
+ --workspace <wsId> --flag my-feature --environment <envId> \
88
+ --rule-index 1 --weights '[{"treatment":"on","size":80000},{"treatment":"off","size":20000}]' \
89
+ --mnemonic "SPLIT-003" --description "80/20 split for rule 1" \
90
+ --change-number CHG0001234
91
+ ```
92
+
93
+ ### Change default rule
94
+
95
+ ```bash
96
+ pncli splitio flags set-default \
97
+ --workspace <wsId> --flag my-feature --environment <envId> \
98
+ --treatment off \
99
+ --mnemonic "SPLIT-004" --description "Default traffic to off" \
100
+ --change-number CHG0001234
101
+ ```
102
+
103
+ ### Kill and restore
104
+
105
+ ```bash
106
+ # Kill a flag (forces all traffic to the default treatment)
107
+ pncli splitio flags kill \
108
+ --workspace <wsId> --flag my-feature --environment <envId> \
109
+ --mnemonic "SPLIT-005" --description "Emergency kill for incident INC0001234" \
110
+ --change-number CHG0001234 --yes
111
+
112
+ # Restore a killed flag
113
+ pncli splitio flags restore \
114
+ --workspace <wsId> --flag my-feature --environment <envId> \
115
+ --mnemonic "SPLIT-006" --description "Restore after incident resolved" \
116
+ --change-number CHG0001234
117
+ ```
118
+
119
+ ### Archive a flag
120
+
121
+ ```bash
122
+ pncli splitio flags archive \
123
+ --workspace <wsId> --flag my-old-feature \
124
+ --mnemonic "SPLIT-007" --description "Flag is fully rolled out, cleaning up" \
125
+ --change-number CHG0001234
126
+ ```
127
+
128
+ ### Toggle a single flag
129
+
130
+ ```bash
131
+ # Disable
132
+ pncli splitio flags toggle \
133
+ --workspace <wsId> --flag my-feature --environment <envId> \
134
+ --enabled false \
135
+ --mnemonic "SPLIT-008" --description "Disable for maintenance" \
136
+ --change-number CHG0001234
137
+
138
+ # Enable
139
+ pncli splitio flags toggle \
140
+ --workspace <wsId> --flag my-feature --environment <envId> \
141
+ --enabled true \
142
+ --mnemonic "SPLIT-009" --description "Re-enable after maintenance" \
143
+ --change-number CHG0001234
144
+ ```
145
+
146
+ ### Batch-toggle from a file
147
+
148
+ Failures do not stop remaining entries. Each flag creates its own Change Request.
149
+
150
+ ```bash
151
+ # toggles.json:
152
+ # [
153
+ # { "flag": "feature-a", "enabled": false },
154
+ # { "flag": "feature-b", "enabled": true }
155
+ # ]
156
+
157
+ pncli splitio flags batch-toggle \
158
+ --workspace <wsId> --environment <envId> \
159
+ --mnemonic "SPLIT-010" --description "Maintenance window toggles" \
160
+ --change-number CHG0001234 --yes \
161
+ --input-file toggles.json
162
+ ```
163
+
164
+ ### Change Request tracking
165
+
166
+ ```bash
167
+ # List all CRs for a workspace
168
+ pncli splitio change-requests list --workspace <wsId>
169
+
170
+ # Filter by environment and status
171
+ pncli splitio change-requests list --workspace <wsId> \
172
+ --environment <envId> --status REQUESTED
173
+
174
+ # Retrieve a specific CR
175
+ pncli splitio change-requests get --id <crId>
176
+ ```
177
+
178
+ **Valid status values:** `REQUESTED`, `APPROVED`, `REJECTED`, `PUBLISHED`