proca 1.7.8 → 1.8.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 CHANGED
@@ -60,6 +60,8 @@ you should also use the local proca-api in your [widget generator](https://githu
60
60
  * [`proca campaign list [TITLE]`](#proca-campaign-list-title)
61
61
  * [`proca campaign mtt`](#proca-campaign-mtt)
62
62
  * [`proca campaign status`](#proca-campaign-status)
63
+ * [`proca campaign widget get`](#proca-campaign-widget-get)
64
+ * [`proca campaign widget rebuild`](#proca-campaign-widget-rebuild)
63
65
  * [`proca config add [ENV] [HUMAN] [JSON] [CSV] [MARKDOWN] [SIMPLIFY]`](#proca-config-add-env-human-json-csv-markdown-simplify)
64
66
  * [`proca config folder`](#proca-config-folder)
65
67
  * [`proca config init [ENV] [HUMAN] [JSON] [CSV] [MARKDOWN] [SIMPLIFY]`](#proca-config-init-env-human-json-csv-markdown-simplify)
@@ -75,14 +77,16 @@ you should also use the local proca-api in your [widget generator](https://githu
75
77
  * [`proca org delete`](#proca-org-delete)
76
78
  * [`proca org email`](#proca-org-email)
77
79
  * [`proca org get`](#proca-org-get)
80
+ * [`proca org user get`](#proca-org-user-get)
78
81
  * [`proca plugins`](#proca-plugins)
79
- * [`proca plugins:install PLUGIN...`](#proca-pluginsinstall-plugin)
82
+ * [`proca plugins add PLUGIN`](#proca-plugins-add-plugin)
80
83
  * [`proca plugins:inspect PLUGIN...`](#proca-pluginsinspect-plugin)
81
- * [`proca plugins:install PLUGIN...`](#proca-pluginsinstall-plugin)
82
- * [`proca plugins:link PLUGIN`](#proca-pluginslink-plugin)
83
- * [`proca plugins:uninstall PLUGIN...`](#proca-pluginsuninstall-plugin)
84
- * [`proca plugins:uninstall PLUGIN...`](#proca-pluginsuninstall-plugin)
85
- * [`proca plugins:uninstall PLUGIN...`](#proca-pluginsuninstall-plugin)
84
+ * [`proca plugins install PLUGIN`](#proca-plugins-install-plugin)
85
+ * [`proca plugins link PATH`](#proca-plugins-link-path)
86
+ * [`proca plugins remove [PLUGIN]`](#proca-plugins-remove-plugin)
87
+ * [`proca plugins reset`](#proca-plugins-reset)
88
+ * [`proca plugins uninstall [PLUGIN]`](#proca-plugins-uninstall-plugin)
89
+ * [`proca plugins unlink [PLUGIN]`](#proca-plugins-unlink-plugin)
86
90
  * [`proca plugins update`](#proca-plugins-update)
87
91
  * [`proca service add`](#proca-service-add)
88
92
  * [`proca service list`](#proca-service-list)
@@ -101,15 +105,16 @@ you should also use the local proca-api in your [widget generator](https://githu
101
105
  * [`proca widget delete`](#proca-widget-delete)
102
106
  * [`proca widget get`](#proca-widget-get)
103
107
  * [`proca widget list`](#proca-widget-list)
108
+ * [`proca widget rebuild`](#proca-widget-rebuild)
104
109
 
105
110
  ## `proca action add`
106
111
 
107
112
  ```
108
113
  USAGE
109
- $ proca action add -i <value> --firstname <value> --email <value> [--json | --human |
110
- --csv | --markdown] [--env <value>] [--simplify] [-x <value>] [-n <the_short_name>] [--testing] [--optin]
111
- [--action_type <value>] [--lastname <value>] [--street <value>] [--locality <value>] [--region <value>] [--country
112
- <value>] [--utm <value>] [--target <value>] [--subject <value>] [--body <value>]
114
+ $ proca action add [ID_NAME_DXID...] -i <value> --firstname <value> --email <value>
115
+ [--json | --human | --csv | --markdown] [--env <value>] [--simplify] [-x <value>] [-n <the_short_name>] [--testing]
116
+ [--optin] [--action_type <value>] [--lastname <value>] [--street <value>] [--locality <value>] [--region <value>]
117
+ [--country <value>] [--utm <value>] [--target <value>] [--subject <value>] [--body <value>]
113
118
 
114
119
  FLAGS
115
120
  -i, --id=<value> (required) widget's id
@@ -181,8 +186,8 @@ counter of actions
181
186
 
182
187
  ```
183
188
  USAGE
184
- $ proca action count [--json | --human | --csv | --markdown] [--env <value>]
185
- [--simplify] [-i <value> | -n <the_short_name> | -x <value>]
189
+ $ proca action count [ID_NAME_DXID] [--json | --human | --csv | --markdown] [--env
190
+ <value>] [--simplify] [-i <value> | -n <the_short_name> | -x <value>]
186
191
 
187
192
  FLAGS
188
193
  -i, --id=<value>
@@ -215,7 +220,7 @@ USAGE
215
220
  [--testing] [--doi] [--utm | --simplify] [--comment | ]
216
221
 
217
222
  ARGUMENTS
218
- [TITLE] name of the campaign, % for wildchar
223
+ TITLE name of the campaign, % for wildchar
219
224
 
220
225
  FLAGS
221
226
  -c, --campaign=<campaign name> name of the campaign, % for wildchar
@@ -311,7 +316,7 @@ USAGE
311
316
  | --markdown] [--env <value>] [--simplify]
312
317
 
313
318
  ARGUMENTS
314
- [TITLE] title of the campaign
319
+ TITLE title of the campaign
315
320
 
316
321
  FLAGS
317
322
  -n, --name=<campaign name> (required) name of the campaign
@@ -333,12 +338,12 @@ EXAMPLES
333
338
 
334
339
  ```
335
340
  USAGE
336
- $ proca campaign close --status draft|live|closed|ignored [--json | --human | --csv |
337
- --markdown] [--env <value>] [--simplify]
341
+ $ proca campaign close [ID_NAME_DXID] --status draft|live|closed|ignored [--json |
342
+ --human | --csv | --markdown] [--env <value>] [--simplify]
338
343
 
339
344
  FLAGS
340
345
  --env=<value> [default: default] allow to switch between configurations (server or users)
341
- --status=<option> (required) [env: [object Object]] Status to set
346
+ --status=<option> (required) Status to set
342
347
  <options: draft|live|closed|ignored>
343
348
 
344
349
  OUTPUT FLAGS
@@ -391,8 +396,8 @@ view a campaign
391
396
 
392
397
  ```
393
398
  USAGE
394
- $ proca campaign get [--json | --human | --csv | --markdown] [--env <value>]
395
- [--simplify] [-i <value> | -n <the_short_name> | -x <value>] [--config] [--stats] [--locale <value>]
399
+ $ proca campaign get [ID_NAME_DXID] [--json | --human | --csv | --markdown] [--env
400
+ <value>] [--simplify] [-i <value> | -n <the_short_name> | -x <value>] [--config] [--stats] [--locale <value>]
396
401
 
397
402
  FLAGS
398
403
  -i, --id=<value>
@@ -427,7 +432,7 @@ USAGE
427
432
  [--simplify] [-o <organisation name>] [-t <campaign title>] [--stats]
428
433
 
429
434
  ARGUMENTS
430
- [TITLE] name of the campaign, % for wildchar
435
+ TITLE name of the campaign, % for wildchar
431
436
 
432
437
  FLAGS
433
438
  -o, --org=<organisation name> campaigns of the organisation (coordinator or partner)
@@ -455,9 +460,9 @@ set the mail to target (mtt) params
455
460
 
456
461
  ```
457
462
  USAGE
458
- $ proca campaign mtt [--json | --human | --csv | --markdown] [--env <value>]
459
- [--simplify] [-i <value> | -n <the_short_name> | -x <value>] [--from <value>] [--to <value>] [--template <value>]
460
- [--period <value>] [--email <value>] [--cc <value>] [--sender] [--drip]
463
+ $ proca campaign mtt [ID_NAME_DXID] [--json | --human | --csv | --markdown] [--env
464
+ <value>] [--simplify] [-i <value> | -n <the_short_name> | -x <value>] [--from <value>] [--to <value>] [--template
465
+ <value>] [--period <value>] [--email <value>] [--cc <value>] [--sender] [--drip]
461
466
 
462
467
  FLAGS
463
468
  -i, --id=<value>
@@ -491,12 +496,12 @@ EXAMPLES
491
496
 
492
497
  ```
493
498
  USAGE
494
- $ proca campaign status --status draft|live|closed|ignored [--json | --human | --csv |
495
- --markdown] [--env <value>] [--simplify]
499
+ $ proca campaign status [ID_NAME_DXID] --status draft|live|closed|ignored [--json |
500
+ --human | --csv | --markdown] [--env <value>] [--simplify]
496
501
 
497
502
  FLAGS
498
503
  --env=<value> [default: default] allow to switch between configurations (server or users)
499
- --status=<option> (required) [env: [object Object]] Status to set
504
+ --status=<option> (required) Status to set
500
505
  <options: draft|live|closed|ignored>
501
506
 
502
507
  OUTPUT FLAGS
@@ -515,6 +520,61 @@ EXAMPLES
515
520
  $ proca campaign status -i <campaign_id>
516
521
  ```
517
522
 
523
+ ## `proca campaign widget get`
524
+
525
+ List widgets in a campaign
526
+
527
+ ```
528
+ USAGE
529
+ $ proca campaign widget get [ID_NAME_DXID] [--json | --human | --csv | --markdown] [--env
530
+ <value>] [--simplify] [-i <value> | -n <the_short_name> | -x <value>]
531
+
532
+ FLAGS
533
+ -i, --id=<value>
534
+ -n, --name=<the_short_name> name
535
+ -x, --dxid=<value> dxid
536
+ --env=<value> [default: default] allow to switch between configurations (server or users)
537
+
538
+ OUTPUT FLAGS
539
+ --csv Format output as csv
540
+ --human Format output to be read on screen by a human [default]
541
+ --json Format output as json
542
+ --markdown Format output as markdown table
543
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
544
+
545
+ DESCRIPTION
546
+ List widgets in a campaign
547
+ ```
548
+
549
+ ## `proca campaign widget rebuild`
550
+
551
+ (re)build all the widgets of a campaign
552
+
553
+ ```
554
+ USAGE
555
+ $ proca campaign widget rebuild [ID_NAME_DXID] [--json | --human | --csv | --markdown] [--env
556
+ <value>] [--simplify] [-i <value> | -n <the_short_name> | -x <value>]
557
+
558
+ FLAGS
559
+ -i, --id=<value>
560
+ -n, --name=<the_short_name> name
561
+ -x, --dxid=<value> dxid
562
+ --env=<value> [default: default] allow to switch between configurations (server or users)
563
+
564
+ OUTPUT FLAGS
565
+ --csv Format output as csv
566
+ --human Format output to be read on screen by a human [default]
567
+ --json Format output as json
568
+ --markdown Format output as markdown table
569
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
570
+
571
+ DESCRIPTION
572
+ (re)build all the widgets of a campaign
573
+
574
+ EXAMPLES
575
+ $ proca-cli campaign widget rebuild climate-action
576
+ ```
577
+
518
578
  ## `proca config add [ENV] [HUMAN] [JSON] [CSV] [MARKDOWN] [SIMPLIFY]`
519
579
 
520
580
  create setting to access to a server
@@ -526,12 +586,12 @@ USAGE
526
586
  you@example.org] [--folder /var/www/proca/config.example]
527
587
 
528
588
  ARGUMENTS
529
- [ENV] [default: default] allow to switch between configurations (server or users)
530
- [HUMAN] [default: true] Format output to be read on screen by a human [default]
531
- [JSON] Format output as json
532
- [CSV] Format output as csv
533
- [MARKDOWN] Format output as markdown table
534
- [SIMPLIFY] flatten and filter to output only the most important attributes, mostly relevant for json
589
+ ENV [default: default] allow to switch between configurations (server or users)
590
+ HUMAN [default: true] Format output to be read on screen by a human [default]
591
+ JSON Format output as json
592
+ CSV Format output as csv
593
+ MARKDOWN Format output as markdown table
594
+ SIMPLIFY flatten and filter to output only the most important attributes, mostly relevant for json
535
595
 
536
596
  FLAGS
537
597
  --email=you@example.org user email on proca server
@@ -594,12 +654,12 @@ USAGE
594
654
  you@example.org] [--folder /var/www/proca/config.example]
595
655
 
596
656
  ARGUMENTS
597
- [ENV] [default: default] allow to switch between configurations (server or users)
598
- [HUMAN] [default: true] Format output to be read on screen by a human [default]
599
- [JSON] Format output as json
600
- [CSV] Format output as csv
601
- [MARKDOWN] Format output as markdown table
602
- [SIMPLIFY] flatten and filter to output only the most important attributes, mostly relevant for json
657
+ ENV [default: default] allow to switch between configurations (server or users)
658
+ HUMAN [default: true] Format output to be read on screen by a human [default]
659
+ JSON Format output as json
660
+ CSV Format output as csv
661
+ MARKDOWN Format output as markdown table
662
+ SIMPLIFY flatten and filter to output only the most important attributes, mostly relevant for json
603
663
 
604
664
  FLAGS
605
665
  --email=you@example.org user email on proca server
@@ -659,8 +719,8 @@ USAGE
659
719
  <value>] [--simplify] [--environment <value>] [--url <url>] [--token <API-token>]
660
720
 
661
721
  ARGUMENTS
662
- [KEY] variable name
663
- [VALUE] value
722
+ KEY variable name
723
+ VALUE value
664
724
 
665
725
  FLAGS
666
726
  --env=<value> [default: default] allow to switch between configurations (server or users)
@@ -698,12 +758,12 @@ USAGE
698
758
  you@example.org] [--folder /var/www/proca/config.example]
699
759
 
700
760
  ARGUMENTS
701
- [ENV] [default: default] allow to switch between configurations (server or users)
702
- [HUMAN] [default: true] Format output to be read on screen by a human [default]
703
- [JSON] Format output as json
704
- [CSV] Format output as csv
705
- [MARKDOWN] Format output as markdown table
706
- [SIMPLIFY] flatten and filter to output only the most important attributes, mostly relevant for json
761
+ ENV [default: default] allow to switch between configurations (server or users)
762
+ HUMAN [default: true] Format output to be read on screen by a human [default]
763
+ JSON Format output as json
764
+ CSV Format output as csv
765
+ MARKDOWN Format output as markdown table
766
+ SIMPLIFY flatten and filter to output only the most important attributes, mostly relevant for json
707
767
 
708
768
  FLAGS
709
769
  --email=you@example.org user email on proca server
@@ -766,8 +826,8 @@ counter of supporters
766
826
 
767
827
  ```
768
828
  USAGE
769
- $ proca contact count [--json | --human | --csv | --markdown] [--env <value>]
770
- [--simplify] [-i <value> | -n <the_short_name> | -x <value>]
829
+ $ proca contact count [ID_NAME_DXID] [--json | --human | --csv | --markdown] [--env
830
+ <value>] [--simplify] [-i <value> | -n <the_short_name> | -x <value>]
771
831
 
772
832
  FLAGS
773
833
  -i, --id=<value>
@@ -800,7 +860,7 @@ USAGE
800
860
  [--doi] [--utm | --simplify] [--comment | ]
801
861
 
802
862
  ARGUMENTS
803
- [TITLE] name of the campaign, % for wildchar
863
+ TITLE name of the campaign, % for wildchar
804
864
 
805
865
  FLAGS
806
866
  -c, --campaign=<campaign title> name of the campaign, % for wildchar
@@ -835,7 +895,7 @@ USAGE
835
895
  $ proca help [COMMAND...] [-n]
836
896
 
837
897
  ARGUMENTS
838
- [COMMAND...] Command to show help for.
898
+ COMMAND... Command to show help for.
839
899
 
840
900
  FLAGS
841
901
  -n, --nested-commands Include all nested commands in the output.
@@ -901,8 +961,8 @@ DESCRIPTION
901
961
 
902
962
  ```
903
963
  USAGE
904
- $ proca org delete [--json | --human | --csv | --markdown] [--env <value>]
905
- [--simplify] [-i <value> | -n <org name> | -x <value>]
964
+ $ proca org delete [ID_NAME_DXID] [--json | --human | --csv | --markdown] [--env
965
+ <value>] [--simplify] [-i <value> | -n <org name> | -x <value>]
906
966
 
907
967
  FLAGS
908
968
  -i, --id=<value>
@@ -927,8 +987,9 @@ Set service, usually email backend for an org
927
987
 
928
988
  ```
929
989
  USAGE
930
- $ proca org email --org <value> --mailer mailjet ses stripe test_stripe system
931
- preview webhook supabase smtp [--json | --human | --csv | --markdown] [--env <value>] [--simplify] [--from <value>]
990
+ $ proca org email [ID_NAME_DXID] --org <value> --mailer mailjet ses stripe
991
+ test_stripe system preview webhook supabase smtp [--json | --human | --csv | --markdown] [--env <value>]
992
+ [--simplify] [--from <value>]
932
993
 
933
994
  FLAGS
934
995
  --env=<value> [default: default] allow to switch
@@ -957,8 +1018,8 @@ view a org
957
1018
 
958
1019
  ```
959
1020
  USAGE
960
- $ proca org get [--json | --human | --csv | --markdown] [--env <value>]
961
- [--simplify] [-n <org name>] [--config] [--personaldata] [--processing] [--keys] [--campaigns] [--users]
1021
+ $ proca org get [ID_NAME_DXID] [--json | --human | --csv | --markdown] [--env
1022
+ <value>] [--simplify] [-n <org name>] [--config] [--personaldata] [--processing] [--keys] [--campaigns] [--users]
962
1023
 
963
1024
  FLAGS
964
1025
  -n, --name=<org name> name of the org
@@ -984,6 +1045,36 @@ EXAMPLES
984
1045
  $ proca org get <name of the ngo>
985
1046
  ```
986
1047
 
1048
+ ## `proca org user get`
1049
+
1050
+ list all the users
1051
+
1052
+ ```
1053
+ USAGE
1054
+ $ proca org user get -o <value> [--json | --human | --csv | --markdown] [--env <value>]
1055
+ [--simplify]
1056
+
1057
+ FLAGS
1058
+ -o, --org=<value> (required) organisation
1059
+ --env=<value> [default: default] allow to switch between configurations (server or users)
1060
+
1061
+ OUTPUT FLAGS
1062
+ --csv Format output as csv
1063
+ --human Format output to be read on screen by a human [default]
1064
+ --json Format output as json
1065
+ --markdown Format output as markdown table
1066
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1067
+
1068
+ DESCRIPTION
1069
+ list all the users
1070
+
1071
+ ALIASES
1072
+ $ proca org user get
1073
+
1074
+ EXAMPLES
1075
+ $ proca org user get %pizza%
1076
+ ```
1077
+
987
1078
  ## `proca plugins`
988
1079
 
989
1080
  List installed plugins.
@@ -1005,44 +1096,53 @@ EXAMPLES
1005
1096
  $ proca plugins
1006
1097
  ```
1007
1098
 
1008
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.1.0/src/commands/plugins/index.ts)_
1099
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/index.ts)_
1009
1100
 
1010
- ## `proca plugins:install PLUGIN...`
1101
+ ## `proca plugins add PLUGIN`
1011
1102
 
1012
- Installs a plugin into the CLI.
1103
+ Installs a plugin into proca.
1013
1104
 
1014
1105
  ```
1015
1106
  USAGE
1016
- $ proca plugins add plugins:install PLUGIN...
1107
+ $ proca plugins add PLUGIN... [--json] [-f] [-h] [-s | -v]
1017
1108
 
1018
1109
  ARGUMENTS
1019
1110
  PLUGIN... Plugin to install.
1020
1111
 
1021
1112
  FLAGS
1022
- -f, --force Run yarn install with force flag.
1113
+ -f, --force Force npm to fetch remote resources even if a local copy exists on disk.
1023
1114
  -h, --help Show CLI help.
1024
- -v, --verbose
1115
+ -s, --silent Silences npm output.
1116
+ -v, --verbose Show verbose npm output.
1117
+
1118
+ GLOBAL FLAGS
1119
+ --json Format output as json.
1025
1120
 
1026
1121
  DESCRIPTION
1027
- Installs a plugin into the CLI.
1028
- Can be installed from npm or a git url.
1122
+ Installs a plugin into proca.
1029
1123
 
1030
- Installation of a user-installed plugin will override a core plugin.
1124
+ Uses npm to install plugins.
1031
1125
 
1032
- e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
1033
- will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
1034
- the CLI without the need to patch and update the whole CLI.
1126
+ Installation of a user-installed plugin will override a core plugin.
1035
1127
 
1128
+ Use the PROCA_NPM_LOG_LEVEL environment variable to set the npm loglevel.
1129
+ Use the PROCA_NPM_REGISTRY environment variable to set the npm registry.
1036
1130
 
1037
1131
  ALIASES
1038
1132
  $ proca plugins add
1039
1133
 
1040
1134
  EXAMPLES
1041
- $ proca plugins:install myplugin
1135
+ Install a plugin from npm registry.
1136
+
1137
+ $ proca plugins add myplugin
1042
1138
 
1043
- $ proca plugins:install https://github.com/someuser/someplugin
1139
+ Install a plugin from a github url.
1044
1140
 
1045
- $ proca plugins:install someuser/someplugin
1141
+ $ proca plugins add https://github.com/someuser/someplugin
1142
+
1143
+ Install a plugin from a github slug.
1144
+
1145
+ $ proca plugins add someuser/someplugin
1046
1146
  ```
1047
1147
 
1048
1148
  ## `proca plugins:inspect PLUGIN...`
@@ -1067,68 +1167,79 @@ DESCRIPTION
1067
1167
  Displays installation properties of a plugin.
1068
1168
 
1069
1169
  EXAMPLES
1070
- $ proca plugins:inspect myplugin
1170
+ $ proca plugins inspect myplugin
1071
1171
  ```
1072
1172
 
1073
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.1.0/src/commands/plugins/inspect.ts)_
1173
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/inspect.ts)_
1074
1174
 
1075
- ## `proca plugins:install PLUGIN...`
1175
+ ## `proca plugins install PLUGIN`
1076
1176
 
1077
- Installs a plugin into the CLI.
1177
+ Installs a plugin into proca.
1078
1178
 
1079
1179
  ```
1080
1180
  USAGE
1081
- $ proca plugins install PLUGIN...
1181
+ $ proca plugins install PLUGIN... [--json] [-f] [-h] [-s | -v]
1082
1182
 
1083
1183
  ARGUMENTS
1084
1184
  PLUGIN... Plugin to install.
1085
1185
 
1086
1186
  FLAGS
1087
- -f, --force Run yarn install with force flag.
1187
+ -f, --force Force npm to fetch remote resources even if a local copy exists on disk.
1088
1188
  -h, --help Show CLI help.
1089
- -v, --verbose
1189
+ -s, --silent Silences npm output.
1190
+ -v, --verbose Show verbose npm output.
1191
+
1192
+ GLOBAL FLAGS
1193
+ --json Format output as json.
1090
1194
 
1091
1195
  DESCRIPTION
1092
- Installs a plugin into the CLI.
1093
- Can be installed from npm or a git url.
1196
+ Installs a plugin into proca.
1094
1197
 
1095
- Installation of a user-installed plugin will override a core plugin.
1198
+ Uses npm to install plugins.
1096
1199
 
1097
- e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
1098
- will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
1099
- the CLI without the need to patch and update the whole CLI.
1200
+ Installation of a user-installed plugin will override a core plugin.
1100
1201
 
1202
+ Use the PROCA_NPM_LOG_LEVEL environment variable to set the npm loglevel.
1203
+ Use the PROCA_NPM_REGISTRY environment variable to set the npm registry.
1101
1204
 
1102
1205
  ALIASES
1103
1206
  $ proca plugins add
1104
1207
 
1105
1208
  EXAMPLES
1106
- $ proca plugins:install myplugin
1209
+ Install a plugin from npm registry.
1107
1210
 
1108
- $ proca plugins:install https://github.com/someuser/someplugin
1211
+ $ proca plugins install myplugin
1109
1212
 
1110
- $ proca plugins:install someuser/someplugin
1213
+ Install a plugin from a github url.
1214
+
1215
+ $ proca plugins install https://github.com/someuser/someplugin
1216
+
1217
+ Install a plugin from a github slug.
1218
+
1219
+ $ proca plugins install someuser/someplugin
1111
1220
  ```
1112
1221
 
1113
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.1.0/src/commands/plugins/install.ts)_
1222
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/install.ts)_
1114
1223
 
1115
- ## `proca plugins:link PLUGIN`
1224
+ ## `proca plugins link PATH`
1116
1225
 
1117
1226
  Links a plugin into the CLI for development.
1118
1227
 
1119
1228
  ```
1120
1229
  USAGE
1121
- $ proca plugins link PLUGIN
1230
+ $ proca plugins link PATH [-h] [--install] [-v]
1122
1231
 
1123
1232
  ARGUMENTS
1124
1233
  PATH [default: .] path to plugin
1125
1234
 
1126
1235
  FLAGS
1127
- -h, --help Show CLI help.
1236
+ -h, --help Show CLI help.
1128
1237
  -v, --verbose
1238
+ --[no-]install Install dependencies after linking the plugin.
1129
1239
 
1130
1240
  DESCRIPTION
1131
1241
  Links a plugin into the CLI for development.
1242
+
1132
1243
  Installation of a linked plugin will override a user-installed or core plugin.
1133
1244
 
1134
1245
  e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
@@ -1136,21 +1247,21 @@ DESCRIPTION
1136
1247
 
1137
1248
 
1138
1249
  EXAMPLES
1139
- $ proca plugins:link myplugin
1250
+ $ proca plugins link myplugin
1140
1251
  ```
1141
1252
 
1142
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.1.0/src/commands/plugins/link.ts)_
1253
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/link.ts)_
1143
1254
 
1144
- ## `proca plugins:uninstall PLUGIN...`
1255
+ ## `proca plugins remove [PLUGIN]`
1145
1256
 
1146
1257
  Removes a plugin from the CLI.
1147
1258
 
1148
1259
  ```
1149
1260
  USAGE
1150
- $ proca plugins remove plugins:uninstall PLUGIN...
1261
+ $ proca plugins remove [PLUGIN...] [-h] [-v]
1151
1262
 
1152
1263
  ARGUMENTS
1153
- [PLUGIN] plugin to uninstall
1264
+ PLUGIN... plugin to uninstall
1154
1265
 
1155
1266
  FLAGS
1156
1267
  -h, --help Show CLI help.
@@ -1162,18 +1273,36 @@ DESCRIPTION
1162
1273
  ALIASES
1163
1274
  $ proca plugins unlink
1164
1275
  $ proca plugins remove
1276
+
1277
+ EXAMPLES
1278
+ $ proca plugins remove myplugin
1165
1279
  ```
1166
1280
 
1167
- ## `proca plugins:uninstall PLUGIN...`
1281
+ ## `proca plugins reset`
1282
+
1283
+ Remove all user-installed and linked plugins.
1284
+
1285
+ ```
1286
+ USAGE
1287
+ $ proca plugins reset [--hard] [--reinstall]
1288
+
1289
+ FLAGS
1290
+ --hard Delete node_modules and package manager related files in addition to uninstalling plugins.
1291
+ --reinstall Reinstall all plugins after uninstalling.
1292
+ ```
1293
+
1294
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/reset.ts)_
1295
+
1296
+ ## `proca plugins uninstall [PLUGIN]`
1168
1297
 
1169
1298
  Removes a plugin from the CLI.
1170
1299
 
1171
1300
  ```
1172
1301
  USAGE
1173
- $ proca plugins uninstall PLUGIN...
1302
+ $ proca plugins uninstall [PLUGIN...] [-h] [-v]
1174
1303
 
1175
1304
  ARGUMENTS
1176
- [PLUGIN] plugin to uninstall
1305
+ PLUGIN... plugin to uninstall
1177
1306
 
1178
1307
  FLAGS
1179
1308
  -h, --help Show CLI help.
@@ -1185,20 +1314,23 @@ DESCRIPTION
1185
1314
  ALIASES
1186
1315
  $ proca plugins unlink
1187
1316
  $ proca plugins remove
1317
+
1318
+ EXAMPLES
1319
+ $ proca plugins uninstall myplugin
1188
1320
  ```
1189
1321
 
1190
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.1.0/src/commands/plugins/uninstall.ts)_
1322
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/uninstall.ts)_
1191
1323
 
1192
- ## `proca plugins:uninstall PLUGIN...`
1324
+ ## `proca plugins unlink [PLUGIN]`
1193
1325
 
1194
1326
  Removes a plugin from the CLI.
1195
1327
 
1196
1328
  ```
1197
1329
  USAGE
1198
- $ proca plugins unlink plugins:uninstall PLUGIN...
1330
+ $ proca plugins unlink [PLUGIN...] [-h] [-v]
1199
1331
 
1200
1332
  ARGUMENTS
1201
- [PLUGIN] plugin to uninstall
1333
+ PLUGIN... plugin to uninstall
1202
1334
 
1203
1335
  FLAGS
1204
1336
  -h, --help Show CLI help.
@@ -1210,6 +1342,9 @@ DESCRIPTION
1210
1342
  ALIASES
1211
1343
  $ proca plugins unlink
1212
1344
  $ proca plugins remove
1345
+
1346
+ EXAMPLES
1347
+ $ proca plugins unlink myplugin
1213
1348
  ```
1214
1349
 
1215
1350
  ## `proca plugins update`
@@ -1228,7 +1363,7 @@ DESCRIPTION
1228
1363
  Update installed plugins.
1229
1364
  ```
1230
1365
 
1231
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v3.1.0/src/commands/plugins/update.ts)_
1366
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.25/src/commands/plugins/update.ts)_
1232
1367
 
1233
1368
  ## `proca service add`
1234
1369
 
@@ -1496,6 +1631,9 @@ OUTPUT FLAGS
1496
1631
  DESCRIPTION
1497
1632
  list all the users
1498
1633
 
1634
+ ALIASES
1635
+ $ proca org user get
1636
+
1499
1637
  EXAMPLES
1500
1638
  $ proca user list %pizza%
1501
1639
  ```
@@ -1540,7 +1678,7 @@ USAGE
1540
1678
  [--simplify] [--password <value>] [--url <value>]
1541
1679
 
1542
1680
  ARGUMENTS
1543
- [USER] Username (email)
1681
+ USER Username (email)
1544
1682
 
1545
1683
  FLAGS
1546
1684
  --env=<value> [default: default] allow to switch between configurations (server or users)
@@ -1617,8 +1755,8 @@ Delete a widget
1617
1755
 
1618
1756
  ```
1619
1757
  USAGE
1620
- $ proca widget delete [--json | --human | --csv | --markdown] [--env <value>]
1621
- [--simplify] [-i <value> | -n <the_short_name> | -x <value>]
1758
+ $ proca widget delete [ID_NAME_DXID] [--json | --human | --csv | --markdown] [--env
1759
+ <value>] [--simplify] [-i <value> | -n <the_short_name> | -x <value>]
1622
1760
 
1623
1761
  FLAGS
1624
1762
  -i, --id=<value>
@@ -1643,8 +1781,8 @@ view a widget
1643
1781
 
1644
1782
  ```
1645
1783
  USAGE
1646
- $ proca widget get [--json | --human | --csv | --markdown] [--env <value>]
1647
- [--simplify] [-i <value> | -n <the_short_name> | -x <value>] [--config]
1784
+ $ proca widget get [ID_NAME_DXID] [--json | --human | --csv | --markdown] [--env
1785
+ <value>] [--simplify] [-i <value> | -n <the_short_name> | -x <value>] [--config]
1648
1786
 
1649
1787
  FLAGS
1650
1788
  -i, --id=<value>
@@ -1662,9 +1800,6 @@ OUTPUT FLAGS
1662
1800
 
1663
1801
  DESCRIPTION
1664
1802
  view a widget
1665
-
1666
- EXAMPLES
1667
- $ proca widget get <path of the widget>
1668
1803
  ```
1669
1804
 
1670
1805
  ## `proca widget list`
@@ -1695,4 +1830,39 @@ DESCRIPTION
1695
1830
  EXAMPLES
1696
1831
  $ proca widget list -o <organisation>
1697
1832
  ```
1833
+
1834
+ ## `proca widget rebuild`
1835
+
1836
+ (re)build a widget
1837
+
1838
+ ```
1839
+ USAGE
1840
+ $ proca widget rebuild [ID_NAME_DXID] [--json | --human | --csv | --markdown] [--env
1841
+ <value>] [--simplify] [-i <value> | -n <the_short_name> | -x <value>]
1842
+
1843
+ FLAGS
1844
+ -i, --id=<value>
1845
+ -n, --name=<the_short_name> name
1846
+ -x, --dxid=<value> dxid
1847
+ --env=<value> [default: default] allow to switch between configurations (server or users)
1848
+
1849
+ OUTPUT FLAGS
1850
+ --csv Format output as csv
1851
+ --human Format output to be read on screen by a human [default]
1852
+ --json Format output as json
1853
+ --markdown Format output as markdown table
1854
+ --[no-]simplify flatten and filter to output only the most important attributes, mostly relevant for json
1855
+
1856
+ DESCRIPTION
1857
+ (re)build a widget
1858
+
1859
+ EXAMPLES
1860
+ $ proca widget rebuild 42
1861
+
1862
+ $ proca widget rebuild climate-action/my-org/en
1863
+
1864
+ SEE ALSO:
1865
+
1866
+ $ proca campaign widget rebuild Rebuild all the widgets of a campaign
1867
+ ```
1698
1868
  <!-- commandsstop -->
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "proca",
3
3
  "description": "Access the proca api",
4
- "version": "1.7.8",
4
+ "version": "1.8.2",
5
5
  "author": "Xavier",
6
6
  "bin": {
7
7
  "proca": "proca-cli"
@@ -18,9 +18,10 @@
18
18
  "easy-table": "^1.2.0",
19
19
  "fast-csv": "^5.0.1",
20
20
  "graphql": "^16.10.0",
21
+ "merge-anything": "^6.0.6",
22
+ "prompts": "^2.4.2",
21
23
  "typescript": "^5.7.3",
22
- "urql": "^4.1.0",
23
- "prompts": "^2.4.2"
24
+ "urql": "^4.1.0"
24
25
  },
25
26
  "devDependencies": {
26
27
  "@biomejs/biome": "^1.9.3",
@@ -0,0 +1,19 @@
1
+ import Command from "#src/procaCommand.mjs";
2
+ import WidgetList from "../../widget/list.mjs";
3
+
4
+ export default class CampaignWidgetList extends Command {
5
+ static description = "List widgets in a campaign";
6
+ static args = this.multiid();
7
+
8
+ static flags = {
9
+ // flag with no value (-f, --force)
10
+ ...this.flagify({ multiid: true }),
11
+ };
12
+
13
+ async run() {
14
+ const { flags } = await this.parse();
15
+
16
+ // Delegate to widget list, but with campaign pre-filled
17
+ await WidgetList.run(["--campaign", flags.name], this.config);
18
+ }
19
+ }
@@ -0,0 +1,17 @@
1
+ import { Command } from "@oclif/core";
2
+
3
+ export default class CampaignWidget extends Command {
4
+ static description = "commands for multiple widgets in a campaign";
5
+ static aliases = ["campaign:widget"];
6
+ static hidden = true; // Hide from command list, only show as topic
7
+
8
+ static id = "campaign:widget";
9
+
10
+ async run() {
11
+ const { Help } = await import("@oclif/core");
12
+ const help = new Help(this.config, { all: true });
13
+ const formatted = help.formatCommand(this);
14
+ this.log(formatted);
15
+ // this.error("Please specify a subcommand, run with --help to list them");
16
+ }
17
+ }
@@ -0,0 +1,50 @@
1
+ import WidgetList from "#src/commands/widget/list.mjs";
2
+ import WidgetRebuild from "#src/commands/widget/rebuild.mjs";
3
+ import Command from "#src/procaCommand.mjs";
4
+
5
+ export default class CampaignWidgetRebuild extends Command {
6
+ static description = "(re)build all the widgets of a campaign";
7
+
8
+ static examples = ["$ proca-cli campaign widget rebuild climate-action"];
9
+
10
+ static args = this.multiid();
11
+
12
+ static flags = {
13
+ // flag with no value (-f, --force)
14
+ ...this.flagify({ multiid: true }),
15
+ // dryRun: Flags.boolean({
16
+ // description: 'Show what would be rebuilt without actually doing it',
17
+ // }),
18
+ };
19
+
20
+ simplify = (d) => {
21
+ d.location = undefined;
22
+ d.config = undefined;
23
+ d.org = d.org.name;
24
+ return d;
25
+ };
26
+
27
+ table = (r) => {
28
+ super.table(r, null, null);
29
+ };
30
+
31
+ rebuild = async (props) => {
32
+ const wapi = new WidgetList();
33
+ const rebuildapi = new WidgetRebuild();
34
+ wapi.flags.config = true; //we need to fetch each widget config
35
+ const widgets = await wapi.fetchCampaign(props.name); //list all widgets
36
+ const result = [];
37
+ for (const widget of widgets) {
38
+ // do not process all widgets in parallel but in sequence
39
+ const r = await rebuildapi.rebuild({ widget });
40
+ result.push(r);
41
+ }
42
+ return result;
43
+ };
44
+
45
+ async run() {
46
+ const { flags } = await this.parse();
47
+ const r = await this.rebuild(flags);
48
+ return this.output(r);
49
+ }
50
+ }
@@ -3,21 +3,21 @@ import Command from "#src/procaCommand.mjs";
3
3
  import { gql, query } from "#src/urql.mjs";
4
4
 
5
5
  export default class CounterGet extends Command {
6
- static description = "counter of supporters";
6
+ static description = "counter of supporters";
7
7
 
8
- static examples = [
9
- "<%= config.bin %> <%= command.id %> --id <id of the campaign>",
10
- "<%= config.bin %> <%= command.id %> --name <name of the campaign>",
11
- ];
8
+ static examples = [
9
+ "<%= config.bin %> <%= command.id %> --id <id of the campaign>",
10
+ "<%= config.bin %> <%= command.id %> --name <name of the campaign>",
11
+ ];
12
12
 
13
- static args = this.multiid();
14
- static flags = {
15
- // flag with no value (-f, --force)
16
- ...this.flagify({ multiid: true }),
17
- };
13
+ static args = this.multiid();
14
+ static flags = {
15
+ // flag with no value (-f, --force)
16
+ ...this.flagify({ multiid: true }),
17
+ };
18
18
 
19
- fetch = async (params) => {
20
- const GetCounterDocument = gql`
19
+ fetch = async (params) => {
20
+ const GetCounterDocument = gql`
21
21
  query GetCounter($name: String, $id: Int) {
22
22
  campaign(name: $name, id: $id) {
23
23
  stats {
@@ -26,17 +26,17 @@ export default class CounterGet extends Command {
26
26
  }
27
27
  }
28
28
  `;
29
- const result = await query(GetCounterDocument, params);
30
- return result.campaign.stats;
31
- };
29
+ const result = await query(GetCounterDocument, params);
30
+ return result.campaign.stats;
31
+ };
32
32
 
33
- table = (r) => {
34
- super.table(r, null, null);
35
- };
33
+ table = (r) => {
34
+ super.table(r, null, null);
35
+ };
36
36
 
37
- async run() {
38
- const { args, flags } = await this.parse();
39
- const data = await this.fetch(flags);
40
- return this.output(data);
41
- }
37
+ async run() {
38
+ const { args, flags } = await this.parse();
39
+ const data = await this.fetch(flags);
40
+ return this.output(data);
41
+ }
42
42
  }
@@ -101,9 +101,7 @@ export default class OrgGet extends Command {
101
101
  withPersonalData: params.personaldata,
102
102
  $withProcessing: params.processing,
103
103
  });
104
- if (result.org.config) {
105
- result.org.config = JSON.parse(result.org.config);
106
- }
104
+ result.org.config = JSON.parse(result.org.config);
107
105
  return result.org;
108
106
  };
109
107
 
@@ -131,7 +129,6 @@ export default class OrgGet extends Command {
131
129
  };
132
130
 
133
131
  table = (r) => {
134
- r.config = JSON.parse(r.config);
135
132
  super.table(r, null, null);
136
133
  if (this.flags.config) {
137
134
  r.config.locales = undefined;
@@ -1,5 +1,4 @@
1
- import { Args, Flags } from "@oclif/core";
2
- import { error, stdout, ux } from "@oclif/core/ux";
1
+ import { Flags } from "@oclif/core";
3
2
  import Command from "#src/procaCommand.mjs";
4
3
  import { gql, query } from "#src/urql.mjs";
5
4
 
@@ -9,6 +8,7 @@ export default class UserList extends Command {
9
8
  static description = "list all the users";
10
9
 
11
10
  static examples = ["<%= config.bin %> <%= command.id %> %pizza%"];
11
+ static aliases = ["org:user:get"];
12
12
 
13
13
  static flags = {
14
14
  // flag with no value (-f, --force)
@@ -1,29 +1,25 @@
1
- import { Args, Flags } from "@oclif/core";
2
- import { error, stdout, ux } from "@oclif/core/ux";
1
+ import { Flags } from "@oclif/core";
3
2
  import Command from "#src/procaCommand.mjs";
4
3
  import { FragmentSummary } from "#src/queries/widget.mjs";
5
4
  import { gql, query } from "#src/urql.mjs";
6
5
 
7
6
  export default class WidgetGet extends Command {
8
- static description = "view a widget";
7
+ static description = "view a widget";
9
8
 
10
- static examples = [
11
- "<%= config.bin %> <%= command.id %> <path of the widget>",
12
- ];
13
- static args = this.multiid();
9
+ static args = this.multiid();
14
10
 
15
- static flags = {
16
- // flag with no value (-f, --force)
17
- ...this.flagify({ multiid: true }),
18
- config: Flags.boolean({
19
- description: "display the config",
20
- default: true,
21
- allowNo: true,
22
- }),
23
- };
11
+ static flags = {
12
+ // flag with no value (-f, --force)
13
+ ...this.flagify({ multiid: true }),
14
+ config: Flags.boolean({
15
+ description: "display the config",
16
+ default: true,
17
+ allowNo: true,
18
+ }),
19
+ };
24
20
 
25
- fetch = async (params) => {
26
- const GetWidgetDocument = gql`
21
+ fetch = async (params) => {
22
+ const GetWidgetDocument = gql`
27
23
  query GetWidget($name: String, $id: Int, $config: Boolean = true) {
28
24
  actionPage(name: $name, id: $id) {
29
25
  ...Summary
@@ -39,21 +35,21 @@ export default class WidgetGet extends Command {
39
35
  }
40
36
  ${FragmentSummary}
41
37
  `;
42
- const result = await query(GetWidgetDocument, params);
43
- return result.actionPage;
44
- };
38
+ const result = await query(GetWidgetDocument, params);
39
+ result.actionPage.config = JSON.parse(result.actionPage.config);
40
+ return result.actionPage;
41
+ };
45
42
 
46
- table = (r) => {
47
- super.table(r, null, null);
48
- if (this.flags.config) {
49
- r.config = JSON.parse(r.config);
50
- this.prettyJson(r.config);
51
- }
52
- };
43
+ table = (r) => {
44
+ super.table(r, null, null);
45
+ if (this.flags.config) {
46
+ this.prettyJson(r.config);
47
+ }
48
+ };
53
49
 
54
- async run() {
55
- const { args, flags } = await this.parse();
56
- const data = await this.fetch(flags);
57
- return this.output(data);
58
- }
50
+ async run() {
51
+ const { args, flags } = await this.parse();
52
+ const data = await this.fetch(flags);
53
+ return this.output(data);
54
+ }
59
55
  }
@@ -1,38 +1,40 @@
1
- import { Args, Flags } from "@oclif/core";
1
+ import { Args, Flags, Help } from "@oclif/core";
2
2
  import { error, stdout, ux } from "@oclif/core/ux";
3
3
  import Command from "#src/procaCommand.mjs";
4
4
  import { FragmentSummary, FragmentSummaryOrg } from "#src/queries/widget.mjs";
5
5
  import { gql, query } from "#src/urql.mjs";
6
6
 
7
7
  export default class WidgetList extends Command {
8
- static description = "list all the widgets of an org or campaign";
8
+ static description = "list all the widgets of an org or campaign";
9
9
 
10
- static examples = ["<%= config.bin %> <%= command.id %> -o <organisation>"];
10
+ static examples = ["<%= config.bin %> <%= command.id %> -o <organisation>"];
11
11
 
12
- static flags = {
13
- // flag with no value (-f, --force)
14
- ...super.globalFlags,
15
- org: Flags.string({
16
- char: "o",
17
- exactlyOne: ["campaign", "org"],
18
- description: "widgets of the organisation (coordinator or partner)",
19
- helpValue: "<organisation name>",
20
- // required: true,
21
- }),
22
- campaign: Flags.string({
23
- char: "c",
24
- description: "widgets of the campaign (coordinator or partner)",
25
- helpValue: "<campaign name>",
26
- // required: true,
27
- }),
28
- config: Flags.boolean({
29
- description: "get the config",
30
- default: false,
31
- allowNo: true,
32
- }),
33
- };
34
- fetchCampaign = async (name) => {
35
- const Document = gql`
12
+ // static aliases = ["campaign:widget:get", "org:widget:get"]; let's rewrite them for better aliasing
13
+
14
+ static flags = {
15
+ // flag with no value (-f, --force)
16
+ ...super.globalFlags,
17
+ org: Flags.string({
18
+ char: "o",
19
+ // exactlyOne: ["campaign", "org"], actually, we can filter on both
20
+ description: "widgets of the organisation (coordinator or partner)",
21
+ helpValue: "<organisation name>",
22
+ // required: true,
23
+ }),
24
+ campaign: Flags.string({
25
+ char: "c",
26
+ description: "widgets of the campaign (coordinator or partner)",
27
+ helpValue: "<campaign name>",
28
+ // required: true,
29
+ }),
30
+ config: Flags.boolean({
31
+ description: "get the config",
32
+ default: false,
33
+ allowNo: true,
34
+ }),
35
+ };
36
+ fetchCampaign = async (name) => {
37
+ const Document = gql`
36
38
  query SearchWidgets($campaign: String!, $withConfig: Boolean!) {
37
39
  campaign (name:$campaign) { ...on PrivateCampaign {
38
40
  actionPages {
@@ -47,15 +49,20 @@ query SearchWidgets($campaign: String!, $withConfig: Boolean!) {
47
49
  }
48
50
  ${FragmentSummary}
49
51
  }`;
50
- const result = await query(Document, {
51
- campaign: name,
52
- withConfig: this.flags.config,
53
- });
54
- return result.campaign.actionPages;
55
- };
52
+ const result = await query(Document, {
53
+ campaign: name,
54
+ withConfig: this.flags.config,
55
+ });
56
+ if (this.flags.org) {
57
+ return result.campaign.actionPages.filter(
58
+ (d) => d.org.name === this.flags.org,
59
+ );
60
+ }
61
+ return result.campaign.actionPages;
62
+ };
56
63
 
57
- fetchOrg = async (name) => {
58
- const Document = gql`
64
+ fetchOrg = async (name) => {
65
+ const Document = gql`
59
66
  query SearchWidgets($org: String!, $withConfig: Boolean!) {
60
67
  org (name:$org) {
61
68
  actionPages {
@@ -70,53 +77,57 @@ query SearchWidgets($org: String!, $withConfig: Boolean!) {
70
77
  }
71
78
  ${FragmentSummaryOrg}
72
79
  }`;
73
- const result = await query(Document, {
74
- org: name,
75
- withConfig: this.flags.config,
76
- });
77
- return result.org.actionPages;
78
- };
80
+ const result = await query(Document, {
81
+ org: name,
82
+ withConfig: this.flags.config,
83
+ });
84
+ return result.org.actionPages;
85
+ };
79
86
 
80
- simplify = (d) => {
81
- const result = {
82
- id: d.id,
83
- name: d.name,
84
- locale: d.locale,
85
- status: d.status.toLowerCase(),
86
- location: d.location?.startsWith("https://widget.proca.app")
87
- ? undefined
88
- : d.location || undefined,
89
- // live: d.live,
87
+ simplify = (d) => {
88
+ const result = {
89
+ id: d.id,
90
+ name: d.name,
91
+ locale: d.locale,
92
+ status: d.status.toLowerCase(),
93
+ location: d.location?.startsWith("https://widget.proca.app")
94
+ ? undefined
95
+ : d.location || undefined,
96
+ // live: d.live,
90
97
 
91
- // thankYouTemplate: d.thankYouTemplate || undefined,
92
- // thankYouTemplateRef: d.thankYouTemplateRef || undefined,
93
- // supporterConfirmTemplate: d.supporterConfirmTemplate || undefined,
94
- };
95
- if (d.extraSupporters > 0) {
96
- result.extra = d.extraSupporters;
97
- }
98
- // if (d.journey) result.journey = d.journey.join(" → ");
99
- if (d.org) {
100
- result.org = d.org.name;
101
- result.org_id = d.org.id;
102
- }
103
- if (d.campaign) {
104
- result.campaign = d.campaign.name;
105
- }
106
- if (this.flags.config) {
107
- }
108
- return result;
109
- };
98
+ // thankYouTemplate: d.thankYouTemplate || undefined,
99
+ // thankYouTemplateRef: d.thankYouTemplateRef || undefined,
100
+ // supporterConfirmTemplate: d.supporterConfirmTemplate || undefined,
101
+ };
102
+ if (d.extraSupporters > 0) {
103
+ result.extra = d.extraSupporters;
104
+ }
105
+ // if (d.journey) result.journey = d.journey.join(" → ");
106
+ if (d.org) {
107
+ result.org = d.org.name;
108
+ result.org_id = d.org.id;
109
+ }
110
+ if (d.campaign) {
111
+ result.campaign = d.campaign.name;
112
+ }
113
+ if (this.flags.config) {
114
+ }
115
+ return result;
116
+ };
110
117
 
111
- table = (r) => {
112
- super.table(r, null, (table) => table.sort(["id|des"]).toString());
113
- };
118
+ table = (r) => {
119
+ super.table(r, null, (table) => table.sort(["id|des"]).toString());
120
+ };
114
121
 
115
- async run() {
116
- const { flags, args } = await this.parse(WidgetList);
117
- let data = [];
118
- if (flags.org) data = await this.fetchOrg(flags.org);
119
- if (flags.campaign) data = await this.fetchCampaign(flags.campaign);
120
- return this.output(data);
121
- }
122
+ async run() {
123
+ const { flags, args } = await this.parse(WidgetList);
124
+ let data = [];
125
+ if (!flags.org && !flags.campaign) {
126
+ const help = new Help(this.config);
127
+ this.error("Must specify --org or --campaign or --help for more");
128
+ }
129
+ if (flags.org) data = await this.fetchOrg(flags.org);
130
+ if (flags.campaign) data = await this.fetchCampaign(flags.campaign);
131
+ return this.output(data);
132
+ }
122
133
  }
@@ -0,0 +1,64 @@
1
+ import { Flags } from "@oclif/core";
2
+ import { mergeAndConcat as merge } from "merge-anything";
3
+ import WidgetGet from "#src/commands/widget/get.mjs";
4
+ import Command from "#src/procaCommand.mjs";
5
+ import { gql, mutation } from "#src/urql.mjs";
6
+
7
+ export default class WidgetRebuild extends Command {
8
+ static description = "(re)build a widget";
9
+
10
+ static examples = [
11
+ "<%= config.bin %> widget rebuild 42",
12
+ "<%= config.bin %> widget rebuild climate-action/my-org/en",
13
+ "SEE ALSO:",
14
+ "<%= config.bin %> campaign widget rebuild Rebuild all the widgets of a campaign",
15
+ ];
16
+
17
+ static args = this.multiid();
18
+
19
+ static flags = {
20
+ // flag with no value (-f, --force)
21
+ ...this.flagify({ multiid: true }),
22
+ };
23
+
24
+ rebuild = async ({ widget, timestamp = new Date().toISOString() }) => {
25
+ //
26
+ const data = merge(widget, { config: { layout: { update: timestamp } } });
27
+
28
+ const PushWidgetDocument = gql`
29
+ mutation updateActionPage($id: Int!, $config: Json!) {
30
+ updateActionPage(id: $id, input: {config:$config}) {
31
+ id, name, locale, config
32
+ ...on PrivateActionPage {
33
+ status
34
+ location
35
+ org {name}
36
+ }
37
+ }
38
+ }
39
+ `;
40
+ const r = await mutation(PushWidgetDocument, {
41
+ id: data.id,
42
+ config: JSON.stringify(data.config),
43
+ });
44
+ if (r.errors) {
45
+ console.log(r);
46
+ console.log("check your config $npx proca config user");
47
+ throw new Error(r.errors[0].message || "can't update on the server");
48
+ }
49
+ r.updateActionPage.update = data.config.layout.update;
50
+ return r.updateActionPage;
51
+ };
52
+
53
+ table = (r) => {
54
+ super.table(r, null, null);
55
+ };
56
+
57
+ async run() {
58
+ const { flags } = await this.parse();
59
+ const wapi = new WidgetGet();
60
+ const widget = await wapi.fetch(flags);
61
+ const r = await this.rebuild({ widget });
62
+ return this.output(r);
63
+ }
64
+ }