proca 1.2.2 → 1.4.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/README.md +210 -125
- package/package.json +1 -1
- package/src/commands/action/add.mjs +169 -0
- package/src/commands/campaign/close.mjs +81 -0
- package/src/commands/config/add.mjs +9 -23
- package/src/commands/config/{get.mjs → server.mjs} +1 -1
- package/src/hooks/init.mjs +22 -1
- package/src/procaCommand.mjs +7 -1
- package/src/commands/config/token.mjs +0 -34
- package/src/commands/widget/cache.mjs +0 -29
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ $ npm install -g proca
|
|
|
18
18
|
$ proca COMMAND
|
|
19
19
|
running command...
|
|
20
20
|
$ proca (--version)
|
|
21
|
-
proca/1.
|
|
21
|
+
proca/1.4.0 linux-x64 node-v20.12.2
|
|
22
22
|
$ proca --help [COMMAND]
|
|
23
23
|
USAGE
|
|
24
24
|
$ proca COMMAND
|
|
@@ -45,18 +45,20 @@ USAGE
|
|
|
45
45
|
|
|
46
46
|
# Commands
|
|
47
47
|
<!-- commands -->
|
|
48
|
+
* [`proca action add`](#proca-action-add)
|
|
48
49
|
* [`proca action count`](#proca-action-count)
|
|
49
50
|
* [`proca action list [TITLE]`](#proca-action-list-title)
|
|
50
51
|
* [`proca action replay`](#proca-action-replay)
|
|
51
52
|
* [`proca campaign add [TITLE]`](#proca-campaign-add-title)
|
|
53
|
+
* [`proca campaign close [TITLE]`](#proca-campaign-close-title)
|
|
52
54
|
* [`proca campaign delete`](#proca-campaign-delete)
|
|
53
55
|
* [`proca campaign get`](#proca-campaign-get)
|
|
54
56
|
* [`proca campaign list [TITLE]`](#proca-campaign-list-title)
|
|
55
|
-
* [`proca config add [
|
|
56
|
-
* [`proca config
|
|
57
|
+
* [`proca config add [ENV] [HUMAN] [JSON] [CSV] [SIMPLIFY]`](#proca-config-add-env-human-json-csv-simplify)
|
|
58
|
+
* [`proca config init [ENV] [HUMAN] [JSON] [CSV] [SIMPLIFY]`](#proca-config-init-env-human-json-csv-simplify)
|
|
59
|
+
* [`proca config server`](#proca-config-server)
|
|
57
60
|
* [`proca config set [KEY] [VALUE]`](#proca-config-set-key-value)
|
|
58
|
-
* [`proca config setup [
|
|
59
|
-
* [`proca config token`](#proca-config-token)
|
|
61
|
+
* [`proca config setup [ENV] [HUMAN] [JSON] [CSV] [SIMPLIFY]`](#proca-config-setup-env-human-json-csv-simplify)
|
|
60
62
|
* [`proca config user`](#proca-config-user)
|
|
61
63
|
* [`proca contact count`](#proca-contact-count)
|
|
62
64
|
* [`proca contact list [TITLE]`](#proca-contact-list-title)
|
|
@@ -80,23 +82,61 @@ USAGE
|
|
|
80
82
|
* [`proca user leave`](#proca-user-leave)
|
|
81
83
|
* [`proca user list`](#proca-user-list)
|
|
82
84
|
* [`proca widget add`](#proca-widget-add)
|
|
83
|
-
* [`proca widget cache`](#proca-widget-cache)
|
|
84
85
|
* [`proca widget get`](#proca-widget-get)
|
|
85
86
|
* [`proca widget list`](#proca-widget-list)
|
|
86
87
|
|
|
88
|
+
## `proca action add`
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
USAGE
|
|
92
|
+
$ proca action add [ID_NAME_DXID...] -i <value> --firstname <value> --email <value>
|
|
93
|
+
[--json | --human | --csv] [--env <value>] [--simplify] [-x <value>] [-n <the_short_name>] [--testing] [--optin]
|
|
94
|
+
[--action_type <value>] [--lastname <value>] [--street <value>] [--locality <value>] [--region <value>] [--country
|
|
95
|
+
<value>] [--utm <value>]
|
|
96
|
+
|
|
97
|
+
FLAGS
|
|
98
|
+
-i, --id=<value> (required) widget's id
|
|
99
|
+
-n, --name=<the_short_name> name
|
|
100
|
+
-x, --dxid=<value> dxid
|
|
101
|
+
--action_type=<value> [default: register]
|
|
102
|
+
--country=<value> 2-letter country iso code
|
|
103
|
+
--email=<value> (required) email
|
|
104
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
105
|
+
--firstname=<value> (required) supporter's firstname
|
|
106
|
+
--lastname=<value>
|
|
107
|
+
--locality=<value>
|
|
108
|
+
--optin
|
|
109
|
+
--region=<value>
|
|
110
|
+
--street=<value>
|
|
111
|
+
--testing
|
|
112
|
+
--utm=<value> utm=campaign.source.medium
|
|
113
|
+
|
|
114
|
+
OUTPUT FLAGS
|
|
115
|
+
--csv Format output as csv
|
|
116
|
+
--human Format output to be read on screen by a human [default]
|
|
117
|
+
--json Format output as json
|
|
118
|
+
--[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
|
|
119
|
+
|
|
120
|
+
EXAMPLES
|
|
121
|
+
$ proca action add -i <widget_id> --firstname=John --email=john@example.org
|
|
122
|
+
|
|
123
|
+
$ proca action add -i <widget_id> --firstname=John --email=john@example.org --country=FR custom1=A custom2=B
|
|
124
|
+
```
|
|
125
|
+
|
|
87
126
|
## `proca action count`
|
|
88
127
|
|
|
89
128
|
counter of actions
|
|
90
129
|
|
|
91
130
|
```
|
|
92
131
|
USAGE
|
|
93
|
-
$ proca action count [ID_NAME_DXID] [--json | --human | --csv] [--
|
|
94
|
-
| -n <the_short_name> | -x <value>]
|
|
132
|
+
$ proca action count [ID_NAME_DXID] [--json | --human | --csv] [--env <value>]
|
|
133
|
+
[--simplify] [-i <value> | -n <the_short_name> | -x <value>]
|
|
95
134
|
|
|
96
135
|
FLAGS
|
|
97
136
|
-i, --id=<value>
|
|
98
137
|
-n, --name=<the_short_name> name
|
|
99
138
|
-x, --dxid=<value> dxid
|
|
139
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
100
140
|
|
|
101
141
|
OUTPUT FLAGS
|
|
102
142
|
--csv Format output as csv
|
|
@@ -117,9 +157,9 @@ EXAMPLES
|
|
|
117
157
|
|
|
118
158
|
```
|
|
119
159
|
USAGE
|
|
120
|
-
$ proca action list [TITLE] -o <organisation name> [--json | --human | --csv] [
|
|
121
|
-
<campaign title>] [--limit <value>] [--today | --after 2025-04-09] [--optin] [--testing] [--doi] [--utm
|
|
122
|
-
--simplify] [--comment | ]
|
|
160
|
+
$ proca action list [TITLE] -o <organisation name> [--json | --human | --csv] [--env
|
|
161
|
+
<value>] [-c <campaign title>] [--limit <value>] [--today | --after 2025-04-09] [--optin] [--testing] [--doi] [--utm
|
|
162
|
+
| --simplify] [--comment | ]
|
|
123
163
|
|
|
124
164
|
ARGUMENTS
|
|
125
165
|
TITLE name of the campaign, % for wildchar
|
|
@@ -130,6 +170,7 @@ FLAGS
|
|
|
130
170
|
--after=2025-04-09 only actions after a date
|
|
131
171
|
--[no-]comment display the comment
|
|
132
172
|
--doi only export the double optin actions
|
|
173
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
133
174
|
--limit=<value> max number of actions
|
|
134
175
|
--optin only export the optin actions
|
|
135
176
|
--testing also export the test actions
|
|
@@ -150,12 +191,13 @@ EXAMPLES
|
|
|
150
191
|
|
|
151
192
|
```
|
|
152
193
|
USAGE
|
|
153
|
-
$ proca action replay -o <organisation name> [--json | --human | --csv] [--
|
|
154
|
-
<campaign title>]
|
|
194
|
+
$ proca action replay -o <organisation name> [--json | --human | --csv] [--env <value>]
|
|
195
|
+
[--simplify] [-c <campaign title>]
|
|
155
196
|
|
|
156
197
|
FLAGS
|
|
157
198
|
-c, --campaign=<campaign title> name of the campaign, % for wildchar
|
|
158
199
|
-o, --org=<organisation name> (required) campaigns of the organisation (coordinator or partner)
|
|
200
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
159
201
|
|
|
160
202
|
OUTPUT FLAGS
|
|
161
203
|
--csv Format output as csv
|
|
@@ -172,7 +214,7 @@ EXAMPLES
|
|
|
172
214
|
```
|
|
173
215
|
USAGE
|
|
174
216
|
$ proca campaign add [TITLE] -n <campaign name> -o <org name> [--json | --human |
|
|
175
|
-
--csv] [--simplify]
|
|
217
|
+
--csv] [--env <value>] [--simplify]
|
|
176
218
|
|
|
177
219
|
ARGUMENTS
|
|
178
220
|
TITLE title of the campaign
|
|
@@ -180,6 +222,7 @@ ARGUMENTS
|
|
|
180
222
|
FLAGS
|
|
181
223
|
-n, --name=<campaign name> (required) name of the campaign
|
|
182
224
|
-o, --org=<org name> (required) name of the coordinator
|
|
225
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
183
226
|
|
|
184
227
|
OUTPUT FLAGS
|
|
185
228
|
--csv Format output as csv
|
|
@@ -191,18 +234,46 @@ EXAMPLES
|
|
|
191
234
|
$ proca campaign add -n <new_campaign> the full name of the campaign
|
|
192
235
|
```
|
|
193
236
|
|
|
237
|
+
## `proca campaign close [TITLE]`
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
USAGE
|
|
241
|
+
$ proca campaign close [TITLE] -n <campaign name> -o <org name> --status
|
|
242
|
+
closed|ignored|live [--json | --human | --csv] [--env <value>] [--simplify]
|
|
243
|
+
|
|
244
|
+
ARGUMENTS
|
|
245
|
+
TITLE title of the campaign
|
|
246
|
+
|
|
247
|
+
FLAGS
|
|
248
|
+
-n, --name=<campaign name> (required) name of the campaign
|
|
249
|
+
-o, --org=<org name> (required) name of the coordinator
|
|
250
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
251
|
+
--status=<option> (required) [default: closed] status
|
|
252
|
+
<options: closed|ignored|live>
|
|
253
|
+
|
|
254
|
+
OUTPUT FLAGS
|
|
255
|
+
--csv Format output as csv
|
|
256
|
+
--human Format output to be read on screen by a human [default]
|
|
257
|
+
--json Format output as json
|
|
258
|
+
--[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
|
|
259
|
+
|
|
260
|
+
EXAMPLES
|
|
261
|
+
$ proca campaign close -name <campaign>
|
|
262
|
+
```
|
|
263
|
+
|
|
194
264
|
## `proca campaign delete`
|
|
195
265
|
|
|
196
266
|
delete a campaign
|
|
197
267
|
|
|
198
268
|
```
|
|
199
269
|
USAGE
|
|
200
|
-
$ proca campaign delete [--json | --human | --csv] [--simplify] [-i
|
|
201
|
-
[-n <campaign name>]
|
|
270
|
+
$ proca campaign delete [--json | --human | --csv] [--env <value>] [--simplify] [-i
|
|
271
|
+
<organisation name>] [-n <campaign name>]
|
|
202
272
|
|
|
203
273
|
FLAGS
|
|
204
274
|
-i, --id=<organisation name> id of the campaign
|
|
205
275
|
-n, --name=<campaign name> name of the campaign
|
|
276
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
206
277
|
|
|
207
278
|
OUTPUT FLAGS
|
|
208
279
|
--csv Format output as csv
|
|
@@ -223,14 +294,15 @@ view a campaign
|
|
|
223
294
|
|
|
224
295
|
```
|
|
225
296
|
USAGE
|
|
226
|
-
$ proca campaign get [ID_NAME_DXID] [--json | --human | --csv] [--
|
|
227
|
-
| -n <the_short_name> | -x <value>] [--config] [--stats] [--locale <value>]
|
|
297
|
+
$ proca campaign get [ID_NAME_DXID] [--json | --human | --csv] [--env <value>]
|
|
298
|
+
[--simplify] [-i <value> | -n <the_short_name> | -x <value>] [--config] [--stats] [--locale <value>]
|
|
228
299
|
|
|
229
300
|
FLAGS
|
|
230
301
|
-i, --id=<value>
|
|
231
302
|
-n, --name=<the_short_name> name
|
|
232
303
|
-x, --dxid=<value> dxid
|
|
233
304
|
--[no-]config display the config
|
|
305
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
234
306
|
--locale=<value> display a locale
|
|
235
307
|
--[no-]stats display the stats
|
|
236
308
|
|
|
@@ -253,8 +325,8 @@ list all the campaigns
|
|
|
253
325
|
|
|
254
326
|
```
|
|
255
327
|
USAGE
|
|
256
|
-
$ proca campaign list [TITLE] [--json | --human | --csv] [--
|
|
257
|
-
name>] [-t <campaign title>] [--stats]
|
|
328
|
+
$ proca campaign list [TITLE] [--json | --human | --csv] [--env <value>] [--simplify]
|
|
329
|
+
[-o <organisation name>] [-t <campaign title>] [--stats]
|
|
258
330
|
|
|
259
331
|
ARGUMENTS
|
|
260
332
|
TITLE name of the campaign, % for wildchar
|
|
@@ -262,6 +334,7 @@ ARGUMENTS
|
|
|
262
334
|
FLAGS
|
|
263
335
|
-o, --org=<organisation name> campaigns of the organisation (coordinator or partner)
|
|
264
336
|
-t, --title=<campaign title> name of the campaign, % for wildchar
|
|
337
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
265
338
|
--[no-]stats display the stats
|
|
266
339
|
|
|
267
340
|
OUTPUT FLAGS
|
|
@@ -277,27 +350,27 @@ EXAMPLES
|
|
|
277
350
|
$ proca campaign list %pizza%
|
|
278
351
|
```
|
|
279
352
|
|
|
280
|
-
## `proca config add [
|
|
353
|
+
## `proca config add [ENV] [HUMAN] [JSON] [CSV] [SIMPLIFY]`
|
|
281
354
|
|
|
282
355
|
create setting to access the server authentication
|
|
283
356
|
|
|
284
357
|
```
|
|
285
358
|
USAGE
|
|
286
|
-
$ proca config add [
|
|
287
|
-
|
|
288
|
-
[--supabase-secrey-key <value>]
|
|
359
|
+
$ proca config add [ENV] [HUMAN] [JSON] [CSV] [SIMPLIFY] --token <API-token> [--json
|
|
360
|
+
| --human | --csv] [--env <value>] [--simplify] [--force] [--url <url>]
|
|
289
361
|
|
|
290
362
|
ARGUMENTS
|
|
291
|
-
|
|
363
|
+
ENV [default: default] allow to switch between configurations (server or users)
|
|
364
|
+
HUMAN [default: true] Format output to be read on screen by a human [default]
|
|
365
|
+
JSON Format output as json
|
|
366
|
+
CSV Format output as csv
|
|
367
|
+
SIMPLIFY flatten and filter to output only the most important attributes, mostly relevant for json
|
|
292
368
|
|
|
293
369
|
FLAGS
|
|
294
|
-
--
|
|
295
|
-
--
|
|
296
|
-
--
|
|
297
|
-
--
|
|
298
|
-
--supabase-secrey-key=<value> secret service key
|
|
299
|
-
--token=<API-token> (required) user token on proca server
|
|
300
|
-
--url=<url> [default: https://api.proca.app/api] url of the proca server api
|
|
370
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
371
|
+
--force write over an existing configuration
|
|
372
|
+
--token=<API-token> (required) user token on proca server
|
|
373
|
+
--url=<url> [default: https://api.proca.app/api] url of the proca server api
|
|
301
374
|
|
|
302
375
|
OUTPUT FLAGS
|
|
303
376
|
--csv Format output as csv
|
|
@@ -310,18 +383,61 @@ DESCRIPTION
|
|
|
310
383
|
|
|
311
384
|
ALIASES
|
|
312
385
|
$ proca config setup
|
|
386
|
+
$ proca config init
|
|
313
387
|
|
|
314
388
|
EXAMPLES
|
|
315
389
|
$ proca config add --user=xavier@example.org --token=API-12345789
|
|
316
390
|
```
|
|
317
391
|
|
|
318
|
-
## `proca config
|
|
392
|
+
## `proca config init [ENV] [HUMAN] [JSON] [CSV] [SIMPLIFY]`
|
|
393
|
+
|
|
394
|
+
create setting to access the server authentication
|
|
395
|
+
|
|
396
|
+
```
|
|
397
|
+
USAGE
|
|
398
|
+
$ proca config init [ENV] [HUMAN] [JSON] [CSV] [SIMPLIFY] --token <API-token> [--json
|
|
399
|
+
| --human | --csv] [--env <value>] [--simplify] [--force] [--url <url>]
|
|
400
|
+
|
|
401
|
+
ARGUMENTS
|
|
402
|
+
ENV [default: default] allow to switch between configurations (server or users)
|
|
403
|
+
HUMAN [default: true] Format output to be read on screen by a human [default]
|
|
404
|
+
JSON Format output as json
|
|
405
|
+
CSV Format output as csv
|
|
406
|
+
SIMPLIFY flatten and filter to output only the most important attributes, mostly relevant for json
|
|
407
|
+
|
|
408
|
+
FLAGS
|
|
409
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
410
|
+
--force write over an existing configuration
|
|
411
|
+
--token=<API-token> (required) user token on proca server
|
|
412
|
+
--url=<url> [default: https://api.proca.app/api] url of the proca server api
|
|
413
|
+
|
|
414
|
+
OUTPUT FLAGS
|
|
415
|
+
--csv Format output as csv
|
|
416
|
+
--human Format output to be read on screen by a human [default]
|
|
417
|
+
--json Format output as json
|
|
418
|
+
--[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
|
|
419
|
+
|
|
420
|
+
DESCRIPTION
|
|
421
|
+
create setting to access the server authentication
|
|
422
|
+
|
|
423
|
+
ALIASES
|
|
424
|
+
$ proca config setup
|
|
425
|
+
$ proca config init
|
|
426
|
+
|
|
427
|
+
EXAMPLES
|
|
428
|
+
$ proca config init --user=xavier@example.org --token=API-12345789
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
## `proca config server`
|
|
319
432
|
|
|
320
433
|
get the server config
|
|
321
434
|
|
|
322
435
|
```
|
|
323
436
|
USAGE
|
|
324
|
-
$ proca config
|
|
437
|
+
$ proca config server [--json | --human | --csv] [--env <value>] [--simplify]
|
|
438
|
+
|
|
439
|
+
FLAGS
|
|
440
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
325
441
|
|
|
326
442
|
OUTPUT FLAGS
|
|
327
443
|
--csv Format output as csv
|
|
@@ -339,14 +455,15 @@ update the setting used to authenticate to the servers and services
|
|
|
339
455
|
|
|
340
456
|
```
|
|
341
457
|
USAGE
|
|
342
|
-
$ proca config set [KEY] [VALUE] [--json | --human | --csv] [--
|
|
343
|
-
[--environment <value>] [--url <url>] [--token <API-token>]
|
|
458
|
+
$ proca config set [KEY] [VALUE] [--json | --human | --csv] [--env <value>]
|
|
459
|
+
[--simplify] [--environment <value>] [--url <url>] [--token <API-token>]
|
|
344
460
|
|
|
345
461
|
ARGUMENTS
|
|
346
462
|
KEY variable name
|
|
347
463
|
VALUE value
|
|
348
464
|
|
|
349
465
|
FLAGS
|
|
466
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
350
467
|
--environment=<value> [default: default] environment
|
|
351
468
|
--token=<API-token> user token on proca server
|
|
352
469
|
--url=<url> [default: https://api.proca.app/api] url of the proca server api
|
|
@@ -369,27 +486,27 @@ EXAMPLES
|
|
|
369
486
|
$ proca config set VAR1 VALUE
|
|
370
487
|
```
|
|
371
488
|
|
|
372
|
-
## `proca config setup [
|
|
489
|
+
## `proca config setup [ENV] [HUMAN] [JSON] [CSV] [SIMPLIFY]`
|
|
373
490
|
|
|
374
491
|
create setting to access the server authentication
|
|
375
492
|
|
|
376
493
|
```
|
|
377
494
|
USAGE
|
|
378
|
-
$ proca config setup [
|
|
379
|
-
|
|
380
|
-
[--supabase-secrey-key <value>]
|
|
495
|
+
$ proca config setup [ENV] [HUMAN] [JSON] [CSV] [SIMPLIFY] --token <API-token> [--json
|
|
496
|
+
| --human | --csv] [--env <value>] [--simplify] [--force] [--url <url>]
|
|
381
497
|
|
|
382
498
|
ARGUMENTS
|
|
383
|
-
|
|
499
|
+
ENV [default: default] allow to switch between configurations (server or users)
|
|
500
|
+
HUMAN [default: true] Format output to be read on screen by a human [default]
|
|
501
|
+
JSON Format output as json
|
|
502
|
+
CSV Format output as csv
|
|
503
|
+
SIMPLIFY flatten and filter to output only the most important attributes, mostly relevant for json
|
|
384
504
|
|
|
385
505
|
FLAGS
|
|
386
|
-
--
|
|
387
|
-
--
|
|
388
|
-
--
|
|
389
|
-
--
|
|
390
|
-
--supabase-secrey-key=<value> secret service key
|
|
391
|
-
--token=<API-token> (required) user token on proca server
|
|
392
|
-
--url=<url> [default: https://api.proca.app/api] url of the proca server api
|
|
506
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
507
|
+
--force write over an existing configuration
|
|
508
|
+
--token=<API-token> (required) user token on proca server
|
|
509
|
+
--url=<url> [default: https://api.proca.app/api] url of the proca server api
|
|
393
510
|
|
|
394
511
|
OUTPUT FLAGS
|
|
395
512
|
--csv Format output as csv
|
|
@@ -402,39 +519,22 @@ DESCRIPTION
|
|
|
402
519
|
|
|
403
520
|
ALIASES
|
|
404
521
|
$ proca config setup
|
|
522
|
+
$ proca config init
|
|
405
523
|
|
|
406
524
|
EXAMPLES
|
|
407
525
|
$ proca config setup --user=xavier@example.org --token=API-12345789
|
|
408
526
|
```
|
|
409
527
|
|
|
410
|
-
## `proca config token`
|
|
411
|
-
|
|
412
|
-
convert between token and sql value
|
|
413
|
-
|
|
414
|
-
```
|
|
415
|
-
USAGE
|
|
416
|
-
$ proca config token [--json | --human | --csv] [--simplify] [--token API-xxx]
|
|
417
|
-
|
|
418
|
-
FLAGS
|
|
419
|
-
--token=API-xxx the token in your config
|
|
420
|
-
|
|
421
|
-
OUTPUT FLAGS
|
|
422
|
-
--csv Format output as csv
|
|
423
|
-
--human Format output to be read on screen by a human [default]
|
|
424
|
-
--json Format output as json
|
|
425
|
-
--[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
|
|
426
|
-
|
|
427
|
-
DESCRIPTION
|
|
428
|
-
convert between token and sql value
|
|
429
|
-
```
|
|
430
|
-
|
|
431
528
|
## `proca config user`
|
|
432
529
|
|
|
433
530
|
fetch the information about the current user (based on the token)
|
|
434
531
|
|
|
435
532
|
```
|
|
436
533
|
USAGE
|
|
437
|
-
$ proca config user [--json | --human | --csv] [--simplify]
|
|
534
|
+
$ proca config user [--json | --human | --csv] [--env <value>] [--simplify]
|
|
535
|
+
|
|
536
|
+
FLAGS
|
|
537
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
438
538
|
|
|
439
539
|
OUTPUT FLAGS
|
|
440
540
|
--csv Format output as csv
|
|
@@ -455,13 +555,14 @@ counter of supporters
|
|
|
455
555
|
|
|
456
556
|
```
|
|
457
557
|
USAGE
|
|
458
|
-
$ proca contact count [ID_NAME_DXID] [--json | --human | --csv] [--
|
|
459
|
-
| -n <the_short_name> | -x <value>]
|
|
558
|
+
$ proca contact count [ID_NAME_DXID] [--json | --human | --csv] [--env <value>]
|
|
559
|
+
[--simplify] [-i <value> | -n <the_short_name> | -x <value>]
|
|
460
560
|
|
|
461
561
|
FLAGS
|
|
462
562
|
-i, --id=<value>
|
|
463
563
|
-n, --name=<the_short_name> name
|
|
464
564
|
-x, --dxid=<value> dxid
|
|
565
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
465
566
|
|
|
466
567
|
OUTPUT FLAGS
|
|
467
568
|
--csv Format output as csv
|
|
@@ -482,9 +583,9 @@ EXAMPLES
|
|
|
482
583
|
|
|
483
584
|
```
|
|
484
585
|
USAGE
|
|
485
|
-
$ proca contact list [TITLE] -o <organisation name> [--json | --human | --csv] [
|
|
486
|
-
<campaign title>] [-n <value>] [--today | --after 2025-04-09] [--optin] [--testing] [--doi] [--utm |
|
|
487
|
-
[--comment | ]
|
|
586
|
+
$ proca contact list [TITLE] -o <organisation name> [--json | --human | --csv] [--env
|
|
587
|
+
<value>] [-c <campaign title>] [-n <value>] [--today | --after 2025-04-09] [--optin] [--testing] [--doi] [--utm |
|
|
588
|
+
--simplify] [--comment | ]
|
|
488
589
|
|
|
489
590
|
ARGUMENTS
|
|
490
591
|
TITLE name of the campaign, % for wildchar
|
|
@@ -496,6 +597,7 @@ FLAGS
|
|
|
496
597
|
--after=2025-04-09 only actions after a date
|
|
497
598
|
--[no-]comment display the comment
|
|
498
599
|
--doi only export the double optin actions
|
|
600
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
499
601
|
--optin only export the optin actions
|
|
500
602
|
--testing also export the test actions
|
|
501
603
|
--today only actions today
|
|
@@ -535,11 +637,12 @@ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.2
|
|
|
535
637
|
|
|
536
638
|
```
|
|
537
639
|
USAGE
|
|
538
|
-
$ proca org add [--json | --human | --csv] [--simplify] [--twitter
|
|
539
|
-
[-n <org name>]
|
|
640
|
+
$ proca org add [--json | --human | --csv] [--env <value>] [--simplify] [--twitter
|
|
641
|
+
<screen name>] [-n <org name>]
|
|
540
642
|
|
|
541
643
|
FLAGS
|
|
542
644
|
-n, --name=<org name> name of the org
|
|
645
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
543
646
|
--twitter=<screen name> twitter account
|
|
544
647
|
|
|
545
648
|
OUTPUT FLAGS
|
|
@@ -558,11 +661,12 @@ view a org crm synchroniser
|
|
|
558
661
|
|
|
559
662
|
```
|
|
560
663
|
USAGE
|
|
561
|
-
$ proca org crm -n <org name> [--json | --human | --csv] [--
|
|
562
|
-
[--synchronize]
|
|
664
|
+
$ proca org crm -n <org name> [--json | --human | --csv] [--env <value>]
|
|
665
|
+
[--simplify] [--synchronize]
|
|
563
666
|
|
|
564
667
|
FLAGS
|
|
565
668
|
-n, --name=<org name> (required) name of the org
|
|
669
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
566
670
|
--[no-]synchronize enable or disable the synchronisation queue
|
|
567
671
|
|
|
568
672
|
OUTPUT FLAGS
|
|
@@ -579,13 +683,14 @@ DESCRIPTION
|
|
|
579
683
|
|
|
580
684
|
```
|
|
581
685
|
USAGE
|
|
582
|
-
$ proca org delete [ID_NAME_DXID] [--json | --human | --csv] [--
|
|
583
|
-
| -n <org name> | -x <value>]
|
|
686
|
+
$ proca org delete [ID_NAME_DXID] [--json | --human | --csv] [--env <value>]
|
|
687
|
+
[--simplify] [-i <value> | -n <org name> | -x <value>]
|
|
584
688
|
|
|
585
689
|
FLAGS
|
|
586
690
|
-i, --id=<value>
|
|
587
691
|
-n, --name=<org name> name of the org
|
|
588
692
|
-x, --dxid=<value> dxid
|
|
693
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
589
694
|
|
|
590
695
|
OUTPUT FLAGS
|
|
591
696
|
--csv Format output as csv
|
|
@@ -603,13 +708,14 @@ view a org
|
|
|
603
708
|
|
|
604
709
|
```
|
|
605
710
|
USAGE
|
|
606
|
-
$ proca org get [ID_NAME_DXID] [--json | --human | --csv] [--
|
|
607
|
-
name>] [--config] [--keys] [--campaigns] [--widgets] [--users]
|
|
711
|
+
$ proca org get [ID_NAME_DXID] [--json | --human | --csv] [--env <value>]
|
|
712
|
+
[--simplify] [-n <org name>] [--config] [--keys] [--campaigns] [--widgets] [--users]
|
|
608
713
|
|
|
609
714
|
FLAGS
|
|
610
715
|
-n, --name=<org name> name of the org
|
|
611
716
|
--[no-]campaigns
|
|
612
717
|
--[no-]config display the config
|
|
718
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
613
719
|
--[no-]keys
|
|
614
720
|
--[no-]users
|
|
615
721
|
--[no-]widgets
|
|
@@ -633,11 +739,12 @@ let a user join an organisation with a role
|
|
|
633
739
|
|
|
634
740
|
```
|
|
635
741
|
USAGE
|
|
636
|
-
$ proca org join -o <org name> [--json | --human | --csv] [--
|
|
637
|
-
<value>] [--role owner|campaigner|coordinator|translator]
|
|
742
|
+
$ proca org join -o <org name> [--json | --human | --csv] [--env <value>]
|
|
743
|
+
[--simplify] [--user <value>] [--role owner|campaigner|coordinator|translator]
|
|
638
744
|
|
|
639
745
|
FLAGS
|
|
640
746
|
-o, --org=<org name> (required) name of the org
|
|
747
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
641
748
|
--role=<option> [default: campaigner] permission level in that org
|
|
642
749
|
<options: owner|campaigner|coordinator|translator>
|
|
643
750
|
--user=<value> user email
|
|
@@ -951,13 +1058,14 @@ fetch the information about a user
|
|
|
951
1058
|
|
|
952
1059
|
```
|
|
953
1060
|
USAGE
|
|
954
|
-
$ proca user get [--json | --human | --csv] [--
|
|
955
|
-
name>] [-i <value>]
|
|
1061
|
+
$ proca user get [--json | --human | --csv] [--env <value>] [--simplify] [--email
|
|
1062
|
+
<value>] [-o <org name>] [-i <value>]
|
|
956
1063
|
|
|
957
1064
|
FLAGS
|
|
958
1065
|
-i, --id=<value> id of the user
|
|
959
1066
|
-o, --org=<org name> name of the org
|
|
960
1067
|
--email=<value> user email
|
|
1068
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
961
1069
|
|
|
962
1070
|
OUTPUT FLAGS
|
|
963
1071
|
--csv Format output as csv
|
|
@@ -979,11 +1087,12 @@ leave a org
|
|
|
979
1087
|
```
|
|
980
1088
|
USAGE
|
|
981
1089
|
$ proca user leave --email <user email> -o <org name> [--json | --human | --csv]
|
|
982
|
-
[--simplify]
|
|
1090
|
+
[--env <value>] [--simplify]
|
|
983
1091
|
|
|
984
1092
|
FLAGS
|
|
985
1093
|
-o, --org=<org name> (required) name of the org
|
|
986
1094
|
--email=<user email> (required) email
|
|
1095
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
987
1096
|
|
|
988
1097
|
OUTPUT FLAGS
|
|
989
1098
|
--csv Format output as csv
|
|
@@ -1004,10 +1113,12 @@ list all the users
|
|
|
1004
1113
|
|
|
1005
1114
|
```
|
|
1006
1115
|
USAGE
|
|
1007
|
-
$ proca user list -o <value> [--json | --human | --csv] [--
|
|
1116
|
+
$ proca user list -o <value> [--json | --human | --csv] [--env <value>]
|
|
1117
|
+
[--simplify]
|
|
1008
1118
|
|
|
1009
1119
|
FLAGS
|
|
1010
1120
|
-o, --org=<value> (required) organisation
|
|
1121
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
1011
1122
|
|
|
1012
1123
|
OUTPUT FLAGS
|
|
1013
1124
|
--csv Format output as csv
|
|
@@ -1026,14 +1137,16 @@ EXAMPLES
|
|
|
1026
1137
|
|
|
1027
1138
|
```
|
|
1028
1139
|
USAGE
|
|
1029
|
-
$ proca widget add -c <campaign name> [--json | --human | --csv] [--
|
|
1030
|
-
<en>] [-l <en>] [-n by default <campaign>/<org>/<lang>]
|
|
1140
|
+
$ proca widget add -c <campaign name> [--json | --human | --csv] [--env <value>]
|
|
1141
|
+
[--simplify] [-o <en>] [-l <en>] [-n by default <campaign>/<org>/<lang>]
|
|
1031
1142
|
|
|
1032
1143
|
FLAGS
|
|
1033
1144
|
-c, --campaign=<campaign name> (required) name of the campaign
|
|
1034
1145
|
-l, --lang=<en> [default: en] language
|
|
1035
1146
|
-n, --name=by default <campaign>/<org>/<lang> url slug
|
|
1036
1147
|
-o, --org=<en> organisation
|
|
1148
|
+
--env=<value> [default: default] allow to switch between configurations (server or
|
|
1149
|
+
users)
|
|
1037
1150
|
|
|
1038
1151
|
OUTPUT FLAGS
|
|
1039
1152
|
--csv Format output as csv
|
|
@@ -1042,50 +1155,21 @@ OUTPUT FLAGS
|
|
|
1042
1155
|
--[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
|
|
1043
1156
|
```
|
|
1044
1157
|
|
|
1045
|
-
## `proca widget cache`
|
|
1046
|
-
|
|
1047
|
-
clear the cdn cache of a widget
|
|
1048
|
-
|
|
1049
|
-
```
|
|
1050
|
-
USAGE
|
|
1051
|
-
$ proca widget cache [ID_NAME_DXID] [--json | --human | --csv] [--simplify] [-i <value>
|
|
1052
|
-
| -n <the_short_name> | -x <value>] [--url <value>]
|
|
1053
|
-
|
|
1054
|
-
FLAGS
|
|
1055
|
-
-i, --id=<value>
|
|
1056
|
-
-n, --name=<the_short_name> name
|
|
1057
|
-
-x, --dxid=<value> dxid
|
|
1058
|
-
--url=<value> url of the widget on the CDN
|
|
1059
|
-
|
|
1060
|
-
OUTPUT FLAGS
|
|
1061
|
-
--csv Format output as csv
|
|
1062
|
-
--human Format output to be read on screen by a human [default]
|
|
1063
|
-
--json Format output as json
|
|
1064
|
-
--[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
|
|
1065
|
-
|
|
1066
|
-
DESCRIPTION
|
|
1067
|
-
clear the cdn cache of a widget
|
|
1068
|
-
|
|
1069
|
-
EXAMPLES
|
|
1070
|
-
$ proca widget cache --url https://cdn.proca.app/d/[campaign]/[org]/[locale]
|
|
1071
|
-
|
|
1072
|
-
$ proca widget cache --name [campaign]/[org]/[locale]
|
|
1073
|
-
```
|
|
1074
|
-
|
|
1075
1158
|
## `proca widget get`
|
|
1076
1159
|
|
|
1077
1160
|
view a widget
|
|
1078
1161
|
|
|
1079
1162
|
```
|
|
1080
1163
|
USAGE
|
|
1081
|
-
$ proca widget get [ID_NAME_DXID] [--json | --human | --csv] [--
|
|
1082
|
-
| -n <the_short_name> | -x <value>] [--config]
|
|
1164
|
+
$ proca widget get [ID_NAME_DXID] [--json | --human | --csv] [--env <value>]
|
|
1165
|
+
[--simplify] [-i <value> | -n <the_short_name> | -x <value>] [--config]
|
|
1083
1166
|
|
|
1084
1167
|
FLAGS
|
|
1085
1168
|
-i, --id=<value>
|
|
1086
1169
|
-n, --name=<the_short_name> name
|
|
1087
1170
|
-x, --dxid=<value> dxid
|
|
1088
1171
|
--[no-]config display the config
|
|
1172
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
1089
1173
|
|
|
1090
1174
|
OUTPUT FLAGS
|
|
1091
1175
|
--csv Format output as csv
|
|
@@ -1106,13 +1190,14 @@ list all the widgets of an org or campaign
|
|
|
1106
1190
|
|
|
1107
1191
|
```
|
|
1108
1192
|
USAGE
|
|
1109
|
-
$ proca widget list [--json | --human | --csv] [--simplify] [-o
|
|
1110
|
-
[-c <campaign name>] [--config]
|
|
1193
|
+
$ proca widget list [--json | --human | --csv] [--env <value>] [--simplify] [-o
|
|
1194
|
+
<organisation name>] [-c <campaign name>] [--config]
|
|
1111
1195
|
|
|
1112
1196
|
FLAGS
|
|
1113
1197
|
-c, --campaign=<campaign name> widgets of the campaign (coordinator or partner)
|
|
1114
1198
|
-o, --org=<organisation name> widgets of the organisation (coordinator or partner)
|
|
1115
1199
|
--[no-]config get the config
|
|
1200
|
+
--env=<value> [default: default] allow to switch between configurations (server or users)
|
|
1116
1201
|
|
|
1117
1202
|
OUTPUT FLAGS
|
|
1118
1203
|
--csv Format output as csv
|
package/package.json
CHANGED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { Args, Flags } from "@oclif/core";
|
|
2
|
+
import { error, stdout, ux } from "@oclif/core/ux";
|
|
3
|
+
import OrgGet from "#src/commands/org/get.mjs";
|
|
4
|
+
import Command from "#src/procaCommand.mjs";
|
|
5
|
+
import { gql, mutation } from "#src/urql.mjs";
|
|
6
|
+
import { getTwitter } from "#src/util/twitter.mjs";
|
|
7
|
+
|
|
8
|
+
export default class ActionAdd extends Command {
|
|
9
|
+
static examples = [
|
|
10
|
+
"<%= config.bin %> <%= command.id %> -i <widget_id> --firstname=John --email=john@example.org",
|
|
11
|
+
"<%= config.bin %> <%= command.id %> -i <widget_id> --firstname=John --email=john@example.org --country=FR custom1=A custom2=B",
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
static args = this.multiid();
|
|
15
|
+
static strict = false; //THIS DOES NOT WORK
|
|
16
|
+
|
|
17
|
+
static flags = {
|
|
18
|
+
...this.flagify({ multiid: true }),
|
|
19
|
+
id: Flags.integer({
|
|
20
|
+
char: "i",
|
|
21
|
+
description: "widget's id",
|
|
22
|
+
required: true,
|
|
23
|
+
}),
|
|
24
|
+
testing: Flags.boolean({ default: true }),
|
|
25
|
+
optin: Flags.boolean({ default: false }),
|
|
26
|
+
action_type: Flags.string({
|
|
27
|
+
default: "register",
|
|
28
|
+
}),
|
|
29
|
+
firstname: Flags.string({
|
|
30
|
+
description: "supporter's firstname",
|
|
31
|
+
required: true,
|
|
32
|
+
}),
|
|
33
|
+
lastname: Flags.string(),
|
|
34
|
+
street: Flags.string(),
|
|
35
|
+
locality: Flags.string(),
|
|
36
|
+
region: Flags.string(),
|
|
37
|
+
country: Flags.string({
|
|
38
|
+
description: "2-letter country iso code",
|
|
39
|
+
parse: async (input) => {
|
|
40
|
+
if (input && !/^[A-Za-z]{2}$/.test(input)) {
|
|
41
|
+
throw new Error("Country code must be exactly 2 letters");
|
|
42
|
+
}
|
|
43
|
+
return input?.toUpperCase(); // optional: normalize to uppercase
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
utm: Flags.string({
|
|
47
|
+
description: "utm=campaign.source.medium",
|
|
48
|
+
}),
|
|
49
|
+
email: Flags.string({
|
|
50
|
+
description: "email",
|
|
51
|
+
required: true,
|
|
52
|
+
}),
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
create = async (flags) => {
|
|
56
|
+
const values = {
|
|
57
|
+
action: {
|
|
58
|
+
actionType: flags.action_type,
|
|
59
|
+
customFields: flags.customFields,
|
|
60
|
+
/* "mtt": {
|
|
61
|
+
"body": "body",
|
|
62
|
+
"files": [
|
|
63
|
+
"files"
|
|
64
|
+
],
|
|
65
|
+
"subject": "subject",
|
|
66
|
+
"targets": [
|
|
67
|
+
"targets"
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
*/
|
|
71
|
+
testing: flags.testing,
|
|
72
|
+
},
|
|
73
|
+
actionPageId: flags.id,
|
|
74
|
+
contact: {
|
|
75
|
+
address: {
|
|
76
|
+
country: flags.country,
|
|
77
|
+
locality: flags.locality,
|
|
78
|
+
postcode: flags.postcode,
|
|
79
|
+
region: flags.region,
|
|
80
|
+
street: flags.street,
|
|
81
|
+
// "streetNumber": "streetNumber"
|
|
82
|
+
},
|
|
83
|
+
email: flags.email,
|
|
84
|
+
firstName: flags.firstname,
|
|
85
|
+
lastName: flags.lastname,
|
|
86
|
+
phone: flags.phone,
|
|
87
|
+
},
|
|
88
|
+
privacy: {
|
|
89
|
+
// "leadOptIn": true,
|
|
90
|
+
optIn: flags.optin,
|
|
91
|
+
},
|
|
92
|
+
tracking: {
|
|
93
|
+
...flags.tracking,
|
|
94
|
+
location: "proca-cli/action/add",
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const query = gql`
|
|
99
|
+
mutation (
|
|
100
|
+
$action: ActionInput!
|
|
101
|
+
$actionPageId: Int!
|
|
102
|
+
$contact: ContactInput!
|
|
103
|
+
$contactRef: ID
|
|
104
|
+
$privacy: ConsentInput!
|
|
105
|
+
$tracking: TrackingInput
|
|
106
|
+
) {
|
|
107
|
+
addActionContact(
|
|
108
|
+
action: $action
|
|
109
|
+
actionPageId: $actionPageId
|
|
110
|
+
contact: $contact
|
|
111
|
+
contactRef: $contactRef
|
|
112
|
+
privacy: $privacy
|
|
113
|
+
tracking: $tracking
|
|
114
|
+
) {
|
|
115
|
+
contactRef
|
|
116
|
+
firstName
|
|
117
|
+
}
|
|
118
|
+
}`;
|
|
119
|
+
|
|
120
|
+
const result = await mutation(query, values);
|
|
121
|
+
|
|
122
|
+
console.log("result", result);
|
|
123
|
+
return result;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
parseUnknownFlags = (argv) => {
|
|
127
|
+
const knownFlags = Object.entries(ActionAdd.flags).flatMap(([key, def]) => {
|
|
128
|
+
const chars = def.char ? [def.char] : [];
|
|
129
|
+
return [key, ...chars];
|
|
130
|
+
});
|
|
131
|
+
/* doesn't work static=false has no effect const unknownFlags = Object.fromEntries(
|
|
132
|
+
argv
|
|
133
|
+
.filter(arg =>
|
|
134
|
+
(/^--?\w+=/.test(arg)) // --key=val or -x=val
|
|
135
|
+
)
|
|
136
|
+
.map(arg => {
|
|
137
|
+
const keyval = arg.replace(/^-+/, '').split('=')
|
|
138
|
+
return [keyval[0], keyval[1]]
|
|
139
|
+
})
|
|
140
|
+
.filter(([key]) => !knownFlags.includes(key))
|
|
141
|
+
)
|
|
142
|
+
*/
|
|
143
|
+
|
|
144
|
+
// Extract key=val style positional args (e.g. foo=bar)
|
|
145
|
+
const kvArgs = Object.fromEntries(
|
|
146
|
+
argv
|
|
147
|
+
.filter((arg) => !arg.startsWith("-") && arg.includes("="))
|
|
148
|
+
.map((arg) => arg.split("=")),
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
if (!Object.keys(kvArgs).length) return undefined;
|
|
152
|
+
|
|
153
|
+
return kvArgs;
|
|
154
|
+
};
|
|
155
|
+
async run() {
|
|
156
|
+
const { args, flags } = await this.parse(ActionAdd, {
|
|
157
|
+
context: { strict: false /* this does not work*/ },
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const customFields = this.parseUnknownFlags(this.argv);
|
|
161
|
+
if (customFields) flags.customFields = JSON.stringify(customFields);
|
|
162
|
+
if (flags.utm) {
|
|
163
|
+
const [campaign, source, medium] = flags.utm.split(".");
|
|
164
|
+
flags.tracking = { source, medium, campaign };
|
|
165
|
+
} else flags.tracking = {};
|
|
166
|
+
const data = await this.create(flags);
|
|
167
|
+
return this.output(data);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { Args, Flags } from "@oclif/core";
|
|
2
|
+
import { error, stdout, ux } from "@oclif/core/ux";
|
|
3
|
+
import OrgGet from "#src/commands/org/get.mjs";
|
|
4
|
+
import Command from "#src/procaCommand.mjs";
|
|
5
|
+
import { gql, mutation } from "#src/urql.mjs";
|
|
6
|
+
import { getTwitter } from "#src/util/twitter.mjs";
|
|
7
|
+
|
|
8
|
+
export default class CampaignClose extends Command {
|
|
9
|
+
static args = {
|
|
10
|
+
title: Args.string({
|
|
11
|
+
description: "title of the campaign",
|
|
12
|
+
multiple: true,
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
// static strict = false;
|
|
16
|
+
|
|
17
|
+
static examples = ["<%= config.bin %> <%= command.id %> -name <campaign>"];
|
|
18
|
+
|
|
19
|
+
static flags = {
|
|
20
|
+
// flag with no value (-f, --force)
|
|
21
|
+
...super.globalFlags,
|
|
22
|
+
name: Flags.string({
|
|
23
|
+
char: "n",
|
|
24
|
+
description: "name of the campaign",
|
|
25
|
+
helpValue: "<campaign name>",
|
|
26
|
+
required: true,
|
|
27
|
+
}),
|
|
28
|
+
org: Flags.string({
|
|
29
|
+
char: "o",
|
|
30
|
+
description: "name of the coordinator",
|
|
31
|
+
helpValue: "<org name>",
|
|
32
|
+
required: true,
|
|
33
|
+
}),
|
|
34
|
+
status: Flags.string({
|
|
35
|
+
description: "status",
|
|
36
|
+
required: true,
|
|
37
|
+
options: ["closed", "ignored", "live"],
|
|
38
|
+
default: "closed",
|
|
39
|
+
}),
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
updateStatus = async (props) => {
|
|
43
|
+
const org = await this.getOrg(props.org);
|
|
44
|
+
|
|
45
|
+
const Query = gql`
|
|
46
|
+
mutation ($org: String!
|
|
47
|
+
$name: String!
|
|
48
|
+
$status: String!
|
|
49
|
+
) {
|
|
50
|
+
upsertCampaign (input: { name: $name, status: $status }, orgName: $org) {
|
|
51
|
+
name
|
|
52
|
+
title
|
|
53
|
+
status
|
|
54
|
+
config
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
const result = await mutation(Query, {
|
|
59
|
+
org: props.org,
|
|
60
|
+
name: props.name,
|
|
61
|
+
status: props.status.toUpperCase(),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
console.log("result", result);
|
|
65
|
+
return result;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
async getOrg(orgName) {
|
|
69
|
+
const { config } = this;
|
|
70
|
+
const orgGet = new OrgGet({}, this.config);
|
|
71
|
+
const org = await orgGet.fetch({ name: orgName });
|
|
72
|
+
return org;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async run() {
|
|
76
|
+
const { args, flags } = await this.parse();
|
|
77
|
+
|
|
78
|
+
const data = await this.updateStatus(flags);
|
|
79
|
+
return this.output(data);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -5,14 +5,11 @@ import Command from "#src/procaCommand.mjs";
|
|
|
5
5
|
|
|
6
6
|
export default class CampaignList extends Command {
|
|
7
7
|
static enableJsonFlag = true;
|
|
8
|
-
static aliases = ["config:setup"];
|
|
8
|
+
static aliases = ["config:setup", "config:init"];
|
|
9
9
|
static deprecateAliases = true;
|
|
10
10
|
|
|
11
11
|
static args = {
|
|
12
|
-
|
|
13
|
-
description: "environment",
|
|
14
|
-
default: "default",
|
|
15
|
-
}),
|
|
12
|
+
...this.flagify({ multiid: false }),
|
|
16
13
|
};
|
|
17
14
|
|
|
18
15
|
static description = "create setting to access the server authentication";
|
|
@@ -39,24 +36,14 @@ export default class CampaignList extends Command {
|
|
|
39
36
|
helpValue: "<API-token>",
|
|
40
37
|
required: true,
|
|
41
38
|
}),
|
|
42
|
-
n8n: Flags.string({
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}),
|
|
46
|
-
supabase: Flags.string({
|
|
47
|
-
description: "url of the supabase",
|
|
48
|
-
helpValue: "<url>",
|
|
49
|
-
}),
|
|
50
|
-
"supabase-anon-key": Flags.string({
|
|
51
|
-
description: "anonymous key",
|
|
52
|
-
}),
|
|
53
|
-
"supabase-secrey-key": Flags.string({
|
|
54
|
-
description: "secret service key",
|
|
55
|
-
}),
|
|
39
|
+
// n8n: Flags.string({ description: "api access on the n8n server", helpValue: "<n8n api>", }),
|
|
40
|
+
// supabase: Flags.string({description: "url of the supabase",helpValue: "<url>"}),
|
|
41
|
+
// "supabase-anon-key": Flags.string({ description: "anonymous key", }),
|
|
42
|
+
// "supabase-secrey-key": Flags.string({ description: "secret service key", }),
|
|
56
43
|
};
|
|
57
44
|
|
|
58
45
|
format = (obj) => {
|
|
59
|
-
const content = ["# generated by proca-
|
|
46
|
+
const content = ["# generated by proca-cli"];
|
|
60
47
|
for (const [key, value] of Object.entries(obj)) {
|
|
61
48
|
if (value) {
|
|
62
49
|
content.push(`${key}='${value.replace(/'/g, "''")}'`);
|
|
@@ -83,12 +70,11 @@ export default class CampaignList extends Command {
|
|
|
83
70
|
|
|
84
71
|
async run() {
|
|
85
72
|
const { args, flags } = await this.parse();
|
|
86
|
-
const file = getFilename(this.config.configDir);
|
|
87
|
-
|
|
73
|
+
const file = getFilename(this.config.configDir, flags.env);
|
|
88
74
|
const userConfig = getConfig(file);
|
|
89
75
|
if (userConfig && !this.flags.force) {
|
|
90
76
|
this.error("config file exists already", {
|
|
91
|
-
code: "
|
|
77
|
+
code: "CONFIG_EXISTS",
|
|
92
78
|
_ref: "README.md#",
|
|
93
79
|
suggestions: [
|
|
94
80
|
`edit ${file}`,
|
package/src/hooks/init.mjs
CHANGED
|
@@ -3,8 +3,29 @@ import { config as dotenv } from "dotenv";
|
|
|
3
3
|
import { getFilename, load } from "#src/config.mjs";
|
|
4
4
|
import CustomHelp from "./help.mjs";
|
|
5
5
|
|
|
6
|
+
const getEnv = () => {
|
|
7
|
+
const rawArgs = process.argv.slice(2);
|
|
8
|
+
let envValue = undefined;
|
|
9
|
+
// Manually check for --environment or -e
|
|
10
|
+
rawArgs.findIndex((arg, envIndex) => {
|
|
11
|
+
if (arg === "--env") {
|
|
12
|
+
// || arg === '-e') {
|
|
13
|
+
envValue = rawArgs[envIndex + 1]; // Next arg is the value
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
if (arg.startsWith("--env=")) {
|
|
17
|
+
envValue = arg.split("=")[1];
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// console.log(`Environment set to: ${envValue}`);
|
|
23
|
+
|
|
24
|
+
return envValue;
|
|
25
|
+
};
|
|
26
|
+
|
|
6
27
|
const hook = async (opts) => {
|
|
7
|
-
const config = load(opts.config.configDir);
|
|
28
|
+
const config = load(opts.config.configDir, getEnv());
|
|
8
29
|
if (config) {
|
|
9
30
|
opts.config.procaConfig = config;
|
|
10
31
|
} else {
|
package/src/procaCommand.mjs
CHANGED
|
@@ -13,6 +13,10 @@ class ProcaCommand extends Command {
|
|
|
13
13
|
flags = {};
|
|
14
14
|
|
|
15
15
|
static baseFlags = {
|
|
16
|
+
env: Flags.string({
|
|
17
|
+
default: "default",
|
|
18
|
+
description: "allow to switch between configurations (server or users)",
|
|
19
|
+
}),
|
|
16
20
|
human: Flags.boolean({
|
|
17
21
|
helpGroup: "OUTPUT", // Optional, groups it under a specific help section if desired
|
|
18
22
|
description: "Format output to be read on screen by a human [default]",
|
|
@@ -103,8 +107,9 @@ class ProcaCommand extends Command {
|
|
|
103
107
|
createClient(this.procaConfig);
|
|
104
108
|
}
|
|
105
109
|
|
|
106
|
-
async
|
|
110
|
+
async _catch(err) {
|
|
107
111
|
// Check if the error was caused by a missing flag or wrong argument format
|
|
112
|
+
console.log("aaa", err);
|
|
108
113
|
try {
|
|
109
114
|
this.error(err.toString());
|
|
110
115
|
} catch (e) {
|
|
@@ -164,6 +169,7 @@ class ProcaCommand extends Command {
|
|
|
164
169
|
warn(...msg) {
|
|
165
170
|
this.tlog("warn", ...msg);
|
|
166
171
|
}
|
|
172
|
+
|
|
167
173
|
error(msg, options = {}) {
|
|
168
174
|
const colouredMessage = ux.colorize(this.config.theme.error, msg);
|
|
169
175
|
super.error(colouredMessage, options);
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import crypto from "node:crypto";
|
|
2
|
-
import { Args, Flags } from "@oclif/core";
|
|
3
|
-
import { error, stdout, ux } from "@oclif/core/ux";
|
|
4
|
-
import Command from "#src/procaCommand.mjs";
|
|
5
|
-
|
|
6
|
-
export default class UserList extends Command {
|
|
7
|
-
static description = "convert between token and sql value";
|
|
8
|
-
|
|
9
|
-
static flags = {
|
|
10
|
-
token: Flags.string({
|
|
11
|
-
exactlyOne: ["token"],
|
|
12
|
-
description: "the token in your config",
|
|
13
|
-
helpValue: "API-xxx",
|
|
14
|
-
}),
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
async run() {
|
|
18
|
-
const { args, flags } = await this.parse();
|
|
19
|
-
if (flags.token) {
|
|
20
|
-
const token = flags.token
|
|
21
|
-
.replace("API-", "")
|
|
22
|
-
.replace(/-/g, "+")
|
|
23
|
-
.replace(/_/g, "/");
|
|
24
|
-
const decoded = Buffer.from(token, "base64").toString("utf-8");
|
|
25
|
-
const hexa = crypto.createHash("sha256").update(decoded).digest("hex");
|
|
26
|
-
console.log(token, decoded, hexa);
|
|
27
|
-
|
|
28
|
-
return this.output({ hexa: `\\x${hexa}` });
|
|
29
|
-
}
|
|
30
|
-
const data = flags;
|
|
31
|
-
|
|
32
|
-
return this.output(data);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Args, Flags } from "@oclif/core";
|
|
2
|
-
import { error, stdout, ux } from "@oclif/core/ux";
|
|
3
|
-
import Command from "#src/procaCommand.mjs";
|
|
4
|
-
import { FragmentSummary } from "#src/queries/widget.mjs";
|
|
5
|
-
import { gql, query } from "#src/urql.mjs";
|
|
6
|
-
|
|
7
|
-
export default class WidgetGet extends Command {
|
|
8
|
-
static description = "clear the cdn cache of a widget";
|
|
9
|
-
|
|
10
|
-
static examples = [
|
|
11
|
-
"<%= config.bin %> <%= command.id %> --url https://cdn.proca.app/d/[campaign]/[org]/[locale]",
|
|
12
|
-
"<%= config.bin %> <%= command.id %> --name [campaign]/[org]/[locale]",
|
|
13
|
-
];
|
|
14
|
-
static args = this.multiid();
|
|
15
|
-
|
|
16
|
-
static flags = {
|
|
17
|
-
// flag with no value (-f, --force)
|
|
18
|
-
...this.flagify({ multiid: true }),
|
|
19
|
-
url: Flags.string ({
|
|
20
|
-
description: "url of the widget on the CDN",
|
|
21
|
-
}),
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
async run() {
|
|
25
|
-
const { args, flags } = await this.parse();
|
|
26
|
-
console.log(flags);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|