proca 0.4.2 → 0.5.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
@@ -18,7 +18,7 @@ $ npm install -g proca
18
18
  $ proca COMMAND
19
19
  running command...
20
20
  $ proca (--version)
21
- proca/0.4.2 linux-x64 node-v20.12.2
21
+ proca/0.5.2 linux-x64 node-v20.12.2
22
22
  $ proca --help [COMMAND]
23
23
  USAGE
24
24
  $ proca COMMAND
@@ -59,7 +59,9 @@ USAGE
59
59
  * [`proca campaign list [TITLE]`](#proca-campaign-list-title)
60
60
  * [`proca config add [ENVIRONMENT]`](#proca-config-add-environment)
61
61
  * [`proca config get`](#proca-config-get)
62
+ * [`proca config set [ENVIRONMENT]`](#proca-config-set-environment)
62
63
  * [`proca config setup [ENVIRONMENT]`](#proca-config-setup-environment)
64
+ * [`proca config token`](#proca-config-token)
63
65
  * [`proca config user`](#proca-config-user)
64
66
  * [`proca help [COMMAND]`](#proca-help-command)
65
67
  * [`proca org add`](#proca-org-add)
@@ -118,18 +120,14 @@ EXAMPLES
118
120
  ```
119
121
  USAGE
120
122
  $ proca action list [TITLE] -o <organisation name> [--simplify [--json | --human |
121
- --csv]] [-i <value> | -n <the_short_name> | -x <value>] [-c <campaign title>] [--limit <value>] [--optin]
122
- [--testing] [--doi] [--utm]
123
+ --csv]] [-c <campaign title>] [--limit <value>] [--optin] [--testing] [--doi] [--utm]
123
124
 
124
125
  ARGUMENTS
125
126
  TITLE name of the campaign, % for wildchar
126
127
 
127
128
  FLAGS
128
129
  -c, --campaign=<campaign title> name of the campaign, % for wildchar
129
- -i, --id=<value>
130
- -n, --name=<the_short_name> name
131
130
  -o, --org=<organisation name> (required) campaigns of the organisation (coordinator or partner)
132
- -x, --dxid=<value> dxid
133
131
  --doi only export the double optin actions
134
132
  --limit=<value> max number of actions
135
133
  --optin only export the optin actions
@@ -150,15 +148,12 @@ EXAMPLES
150
148
 
151
149
  ```
152
150
  USAGE
153
- $ proca action replay -o <organisation name> [--simplify [--json | --human | --csv]] [-i
154
- <value> | -n <the_short_name> | -x <value>] [-c <campaign title>]
151
+ $ proca action replay -o <organisation name> [--simplify [--json | --human | --csv]] [-c
152
+ <campaign title>]
155
153
 
156
154
  FLAGS
157
155
  -c, --campaign=<campaign title> name of the campaign, % for wildchar
158
- -i, --id=<value>
159
- -n, --name=<the_short_name> name
160
156
  -o, --org=<organisation name> (required) campaigns of the organisation (coordinator or partner)
161
- -x, --dxid=<value> dxid
162
157
 
163
158
  OUTPUT FLAGS
164
159
  --csv Format output as csv
@@ -174,17 +169,15 @@ EXAMPLES
174
169
 
175
170
  ```
176
171
  USAGE
177
- $ proca campaign add [TITLE] [--simplify [--json | --human | --csv]] [-i <value> | -n
178
- <campaign name> | -x <value>] [-o <org name>]
172
+ $ proca campaign add [TITLE] [--simplify [--json | --human | --csv]] [-n <campaign
173
+ name>] [-o <org name>]
179
174
 
180
175
  ARGUMENTS
181
176
  TITLE title of the campaign
182
177
 
183
178
  FLAGS
184
- -i, --id=<value>
185
179
  -n, --name=<campaign name> name of the campaign
186
180
  -o, --org=<org name> name of the coordinator
187
- -x, --dxid=<value> dxid
188
181
 
189
182
  OUTPUT FLAGS
190
183
  --csv Format output as csv
@@ -203,12 +196,11 @@ delete a campaign
203
196
  ```
204
197
  USAGE
205
198
  $ proca campaign delete [--simplify [--json | --human | --csv]] [-i <organisation name>]
206
- [-x <value>] [-n <campaign name>]
199
+ [-n <campaign name>]
207
200
 
208
201
  FLAGS
209
202
  -i, --id=<organisation name> id of the campaign
210
203
  -n, --name=<campaign name> name of the campaign
211
- -x, --dxid=<value> dxid
212
204
 
213
205
  OUTPUT FLAGS
214
206
  --csv Format output as csv
@@ -259,18 +251,15 @@ list all the campaigns
259
251
 
260
252
  ```
261
253
  USAGE
262
- $ proca campaign list [TITLE] [--simplify [--json | --human | --csv]] [-i <value> | -n
263
- <the_short_name> | -x <value>] [-o <organisation name>] [-t <campaign title>] [--stats]
254
+ $ proca campaign list [TITLE] [--simplify [--json | --human | --csv]] [-o <organisation
255
+ name>] [-t <campaign title>] [--stats]
264
256
 
265
257
  ARGUMENTS
266
258
  TITLE name of the campaign, % for wildchar
267
259
 
268
260
  FLAGS
269
- -i, --id=<value>
270
- -n, --name=<the_short_name> name
271
261
  -o, --org=<organisation name> campaigns of the organisation (coordinator or partner)
272
262
  -t, --title=<campaign title> name of the campaign, % for wildchar
273
- -x, --dxid=<value> dxid
274
263
  --[no-]stats display the stats
275
264
 
276
265
  OUTPUT FLAGS
@@ -293,23 +282,20 @@ create setting to access the server authentication
293
282
  ```
294
283
  USAGE
295
284
  $ proca config add [ENVIRONMENT] --token <API-token> [--simplify [--json | --human |
296
- --csv]] [-i <value> | -n <the_short_name> | -x <value>] [--force] [--url <url>] [--n8n <n8n api>] [--supabase <url>]
297
- [--supabase-anon-key <value>] [--supabase-secrey-key <value>]
285
+ --csv]] [--force] [--url <url>] [--n8n <n8n api>] [--supabase <url>] [--supabase-anon-key <value>]
286
+ [--supabase-secrey-key <value>]
298
287
 
299
288
  ARGUMENTS
300
289
  ENVIRONMENT [default: default] environment
301
290
 
302
291
  FLAGS
303
- -i, --id=<value>
304
- -n, --name=<the_short_name> name
305
- -x, --dxid=<value> dxid
306
- --force write over an existing configuration
307
- --n8n=<n8n api> api access on the n8n server
308
- --supabase=<url> url of the supabase
309
- --supabase-anon-key=<value> anonymous key
310
- --supabase-secrey-key=<value> secret service key
311
- --token=<API-token> (required) user token on proca server
312
- --url=<url> [default: https://api.proca.app/api] url of the proca server api
292
+ --force write over an existing configuration
293
+ --n8n=<n8n api> api access on the n8n server
294
+ --supabase=<url> url of the supabase
295
+ --supabase-anon-key=<value> anonymous key
296
+ --supabase-secrey-key=<value> secret service key
297
+ --token=<API-token> (required) user token on proca server
298
+ --url=<url> [default: https://api.proca.app/api] url of the proca server api
313
299
 
314
300
  OUTPUT FLAGS
315
301
  --csv Format output as csv
@@ -333,13 +319,39 @@ get the server config
333
319
 
334
320
  ```
335
321
  USAGE
336
- $ proca config get [--simplify [--json | --human | --csv]] [-i <value> | -n
337
- <the_short_name> | -x <value>]
322
+ $ proca config get [--simplify [--json | --human | --csv]]
323
+
324
+ OUTPUT FLAGS
325
+ --csv Format output as csv
326
+ --human Format output to be read on screen by a human [default]
327
+ --json Format output as json
328
+ --simplify flatten and filter to output only the most important attributes, mostly relevant for json
329
+
330
+ DESCRIPTION
331
+ get the server config
332
+ ```
333
+
334
+ ## `proca config set [ENVIRONMENT]`
335
+
336
+ create setting to access the server authentication
337
+
338
+ ```
339
+ USAGE
340
+ $ proca config set [ENVIRONMENT] --token <API-token> [--simplify [--json | --human |
341
+ --csv]] [--force] [--url <url>] [--n8n <n8n api>] [--supabase <url>] [--supabase-anon-key <value>]
342
+ [--supabase-secrey-key <value>]
343
+
344
+ ARGUMENTS
345
+ ENVIRONMENT [default: default] environment
338
346
 
339
347
  FLAGS
340
- -i, --id=<value>
341
- -n, --name=<the_short_name> name
342
- -x, --dxid=<value> dxid
348
+ --force write over an existing configuration
349
+ --n8n=<n8n api> api access on the n8n server
350
+ --supabase=<url> url of the supabase
351
+ --supabase-anon-key=<value> anonymous key
352
+ --supabase-secrey-key=<value> secret service key
353
+ --token=<API-token> (required) user token on proca server
354
+ --url=<url> [default: https://api.proca.app/api] url of the proca server api
343
355
 
344
356
  OUTPUT FLAGS
345
357
  --csv Format output as csv
@@ -348,7 +360,13 @@ OUTPUT FLAGS
348
360
  --simplify flatten and filter to output only the most important attributes, mostly relevant for json
349
361
 
350
362
  DESCRIPTION
351
- get the server config
363
+ create setting to access the server authentication
364
+
365
+ ALIASES
366
+ $ proca config setup
367
+
368
+ EXAMPLES
369
+ $ proca config set --user=xavier@example.org --token=API-12345789
352
370
  ```
353
371
 
354
372
  ## `proca config setup [ENVIRONMENT]`
@@ -358,23 +376,20 @@ create setting to access the server authentication
358
376
  ```
359
377
  USAGE
360
378
  $ proca config setup [ENVIRONMENT] --token <API-token> [--simplify [--json | --human |
361
- --csv]] [-i <value> | -n <the_short_name> | -x <value>] [--force] [--url <url>] [--n8n <n8n api>] [--supabase <url>]
362
- [--supabase-anon-key <value>] [--supabase-secrey-key <value>]
379
+ --csv]] [--force] [--url <url>] [--n8n <n8n api>] [--supabase <url>] [--supabase-anon-key <value>]
380
+ [--supabase-secrey-key <value>]
363
381
 
364
382
  ARGUMENTS
365
383
  ENVIRONMENT [default: default] environment
366
384
 
367
385
  FLAGS
368
- -i, --id=<value>
369
- -n, --name=<the_short_name> name
370
- -x, --dxid=<value> dxid
371
- --force write over an existing configuration
372
- --n8n=<n8n api> api access on the n8n server
373
- --supabase=<url> url of the supabase
374
- --supabase-anon-key=<value> anonymous key
375
- --supabase-secrey-key=<value> secret service key
376
- --token=<API-token> (required) user token on proca server
377
- --url=<url> [default: https://api.proca.app/api] url of the proca server api
386
+ --force write over an existing configuration
387
+ --n8n=<n8n api> api access on the n8n server
388
+ --supabase=<url> url of the supabase
389
+ --supabase-anon-key=<value> anonymous key
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
378
393
 
379
394
  OUTPUT FLAGS
380
395
  --csv Format output as csv
@@ -392,19 +407,34 @@ EXAMPLES
392
407
  $ proca config setup --user=xavier@example.org --token=API-12345789
393
408
  ```
394
409
 
395
- ## `proca config user`
410
+ ## `proca config token`
396
411
 
397
- fetch the information about the current user (based on the token)
412
+ convert between token and sql value
398
413
 
399
414
  ```
400
415
  USAGE
401
- $ proca config user [--simplify [--json | --human | --csv]] [-i <value> | -n
402
- <the_short_name> | -x <value>]
416
+ $ proca config token [--simplify [--json | --human | --csv]] [--token API-xxx]
403
417
 
404
418
  FLAGS
405
- -i, --id=<value>
406
- -n, --name=<the_short_name> name
407
- -x, --dxid=<value> dxid
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
+ --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
+ ## `proca config user`
432
+
433
+ fetch the information about the current user (based on the token)
434
+
435
+ ```
436
+ USAGE
437
+ $ proca config user [--simplify [--json | --human | --csv]]
408
438
 
409
439
  OUTPUT FLAGS
410
440
  --csv Format output as csv
@@ -443,13 +473,11 @@ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.1
443
473
 
444
474
  ```
445
475
  USAGE
446
- $ proca org add [--simplify [--json | --human | --csv]] [-i <value> | -n <org
447
- name> | -x <value>] [--twitter <screen name>]
476
+ $ proca org add [--simplify [--json | --human | --csv]] [--twitter <screen name>]
477
+ [-n <org name>]
448
478
 
449
479
  FLAGS
450
- -i, --id=<value>
451
480
  -n, --name=<org name> name of the org
452
- -x, --dxid=<value> dxid
453
481
  --twitter=<screen name> twitter account
454
482
 
455
483
  OUTPUT FLAGS
@@ -468,13 +496,11 @@ view a org crm synchroniser
468
496
 
469
497
  ```
470
498
  USAGE
471
- $ proca org crm [--simplify [--json | --human | --csv]] (-i <value> | -n <org
472
- name> | -x <value>) [--synchronize]
499
+ $ proca org crm -n <org name> [--simplify [--json | --human | --csv]]
500
+ [--synchronize]
473
501
 
474
502
  FLAGS
475
- -i, --id=<value>
476
503
  -n, --name=<org name> (required) name of the org
477
- -x, --dxid=<value> dxid
478
504
  --[no-]synchronize enable or disable the synchronisation queue
479
505
 
480
506
  OUTPUT FLAGS
@@ -493,13 +519,11 @@ view a org
493
519
 
494
520
  ```
495
521
  USAGE
496
- $ proca org get [--simplify [--json | --human | --csv]] [-i <value> | -n <org
497
- name> | -x <value>] [--config] [--keys] [--campaigns] [--widgets] [--users]
522
+ $ proca org get [--simplify [--json | --human | --csv]] [-n <org name>] [--config]
523
+ [--keys] [--campaigns] [--widgets] [--users]
498
524
 
499
525
  FLAGS
500
- -i, --id=<value>
501
526
  -n, --name=<org name> name of the org
502
- -x, --dxid=<value> dxid
503
527
  --[no-]campaigns
504
528
  --[no-]config display the config
505
529
  --[no-]keys
@@ -525,17 +549,14 @@ let a user join an organisation with a role
525
549
 
526
550
  ```
527
551
  USAGE
528
- $ proca org join -o <org name> [--simplify [--json | --human | --csv]] [-i <value>
529
- | -n <the_short_name> | -x <value>] [--user <value>] [--role owner|campaigner|coordinator|translator]
552
+ $ proca org join -o <org name> [--simplify [--json | --human | --csv]] [--user
553
+ <value>] [--role owner|campaigner|coordinator|translator]
530
554
 
531
555
  FLAGS
532
- -i, --id=<value>
533
- -n, --name=<the_short_name> name
534
- -o, --org=<org name> (required) name of the org
535
- -x, --dxid=<value> dxid
536
- --role=<option> [default: campaigner] permission level in that org
537
- <options: owner|campaigner|coordinator|translator>
538
- --user=<value> user email
556
+ -o, --org=<org name> (required) name of the org
557
+ --role=<option> [default: campaigner] permission level in that org
558
+ <options: owner|campaigner|coordinator|translator>
559
+ --user=<value> user email
539
560
 
540
561
  OUTPUT FLAGS
541
562
  --csv Format output as csv
@@ -879,15 +900,13 @@ fetch the information about a user
879
900
 
880
901
  ```
881
902
  USAGE
882
- $ proca user get [--simplify [--json | --human | --csv]] [-i <value>] [-x <value>]
883
- [-n <the_short_name>] [--email <value>] [-o <org name>]
903
+ $ proca user get [--simplify [--json | --human | --csv]] [--email <value>] [-o <org
904
+ name>] [-i <value>]
884
905
 
885
906
  FLAGS
886
- -i, --id=<value> id of the user
887
- -n, --name=<the_short_name> name
888
- -o, --org=<org name> name of the org
889
- -x, --dxid=<value> dxid
890
- --email=<value> user email
907
+ -i, --id=<value> id of the user
908
+ -o, --org=<org name> name of the org
909
+ --email=<value> user email
891
910
 
892
911
  OUTPUT FLAGS
893
912
  --csv Format output as csv
@@ -909,14 +928,11 @@ leave a org
909
928
  ```
910
929
  USAGE
911
930
  $ proca user leave --email <user email> -o <org name> [--simplify [--json | --human |
912
- --csv]] [-i <value> | -n <the_short_name> | -x <value>]
931
+ --csv]]
913
932
 
914
933
  FLAGS
915
- -i, --id=<value>
916
- -n, --name=<the_short_name> name
917
- -o, --org=<org name> (required) name of the org
918
- -x, --dxid=<value> dxid
919
- --email=<user email> (required) email
934
+ -o, --org=<org name> (required) name of the org
935
+ --email=<user email> (required) email
920
936
 
921
937
  OUTPUT FLAGS
922
938
  --csv Format output as csv
@@ -937,14 +953,10 @@ list all the users
937
953
 
938
954
  ```
939
955
  USAGE
940
- $ proca user list -o <value> [--simplify [--json | --human | --csv]] [-i <value> |
941
- -n <the_short_name> | -x <value>]
956
+ $ proca user list -o <value> [--simplify [--json | --human | --csv]]
942
957
 
943
958
  FLAGS
944
- -i, --id=<value>
945
- -n, --name=<the_short_name> name
946
- -o, --org=<value> (required) organisation
947
- -x, --dxid=<value> dxid
959
+ -o, --org=<value> (required) organisation
948
960
 
949
961
  OUTPUT FLAGS
950
962
  --csv Format output as csv
@@ -963,16 +975,14 @@ EXAMPLES
963
975
 
964
976
  ```
965
977
  USAGE
966
- $ proca widget add -c <campaign name> [--simplify [--json | --human | --csv]] [-i
967
- <value> | -n by default <campaign>/<org>/<lang> | -x <value>] [-o <en>] [-l <en>]
978
+ $ proca widget add -c <campaign name> [--simplify [--json | --human | --csv]] [-o
979
+ <en>] [-l <en>] [-n by default <campaign>/<org>/<lang>]
968
980
 
969
981
  FLAGS
970
982
  -c, --campaign=<campaign name> (required) name of the campaign
971
- -i, --id=<value>
972
983
  -l, --lang=<en> [default: en] language
973
984
  -n, --name=by default <campaign>/<org>/<lang> url slug
974
985
  -o, --org=<en> organisation
975
- -x, --dxid=<value> dxid
976
986
 
977
987
  OUTPUT FLAGS
978
988
  --csv Format output as csv
@@ -1015,15 +1025,12 @@ list all the widgets of an org or campaign
1015
1025
 
1016
1026
  ```
1017
1027
  USAGE
1018
- $ proca widget list [--simplify [--json | --human | --csv]] [-i <value> | -n
1019
- <the_short_name> | -x <value>] [-o <organisation name>] [-c <campaign name>] [--config]
1028
+ $ proca widget list [--simplify [--json | --human | --csv]] [-o <organisation name>]
1029
+ [-c <campaign name>] [--config]
1020
1030
 
1021
1031
  FLAGS
1022
1032
  -c, --campaign=<campaign name> widgets of the campaign (coordinator or partner)
1023
- -i, --id=<value>
1024
- -n, --name=<the_short_name> name
1025
1033
  -o, --org=<organisation name> widgets of the organisation (coordinator or partner)
1026
- -x, --dxid=<value> dxid
1027
1034
  --[no-]config get the config
1028
1035
 
1029
1036
  OUTPUT FLAGS
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "proca",
3
3
  "description": "Access the proca api",
4
- "version": "0.4.2",
4
+ "version": "0.5.2",
5
5
  "author": "Xavier",
6
6
  "bin": {
7
7
  "proca": "./proca-cli"
@@ -0,0 +1,101 @@
1
+ import { Args, Flags } from "@oclif/core";
2
+ import { error, stdout, ux } from "@oclif/core/ux";
3
+ import { get as getConfig, getFilename, write } from "#src/config.mjs";
4
+ import Command from "#src/procaCommand.mjs";
5
+
6
+ export default class CampaignList extends Command {
7
+ static enableJsonFlag = true;
8
+ static aliases = ["config:setup"];
9
+ static deprecateAliases = true;
10
+
11
+ static args = {
12
+ environment: Args.string({
13
+ description: "environment",
14
+ default: "default",
15
+ }),
16
+ };
17
+
18
+ static description = "create setting to access the server authentication";
19
+
20
+ static examples = [
21
+ "<%= config.bin %> <%= command.id %> --user=xavier@example.org --token=API-12345789",
22
+ ];
23
+
24
+ static flags = {
25
+ // flag with no value (-f, --force)
26
+ ...super.globalFlags,
27
+ force: Flags.boolean({
28
+ description: "write over an existing configuration",
29
+ default: false,
30
+ helpValue: "(default false)",
31
+ }),
32
+ url: Flags.string({
33
+ description: "url of the proca server api",
34
+ default: "https://api.proca.app/api",
35
+ helpValue: "<url>",
36
+ }),
37
+ token: Flags.string({
38
+ description: "user token on proca server",
39
+ helpValue: "<API-token>",
40
+ required: true,
41
+ }),
42
+ n8n: Flags.string({
43
+ description: "api access on the n8n server",
44
+ helpValue: "<n8n api>",
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
+ }),
56
+ };
57
+
58
+ format = (obj) => {
59
+ const content = ["# generated by proca-api"];
60
+ for (const [key, value] of Object.entries(obj)) {
61
+ if (value) {
62
+ content.push(`${key}='${value.replace(/'/g, "''")}'`);
63
+ } else {
64
+ content.push(`#${key}= `);
65
+ }
66
+ }
67
+ return content.join("\n");
68
+ };
69
+
70
+ generate = function () {
71
+ const mapping = {
72
+ REACT_APP_NAME: "proca",
73
+ REACT_APP_API_URL: this.flags.url,
74
+ PROCA_TOKEN: this.flags.token,
75
+ N8N_TOKEN: this.flags.n8n,
76
+ REACT_APP_SUPABASE_URL: this.flags.supabase,
77
+ REACT_APP_SUPABASE_ANON_KEY: this.flags.supabase_anon_key,
78
+ SUPABASE_SECRET_KEY: this.flags.supabase_secret_key,
79
+ };
80
+
81
+ return this.format(mapping);
82
+ };
83
+
84
+ async run() {
85
+ const { args, flags } = await this.parse();
86
+ const file = getFilename(this.config.configDir);
87
+
88
+ const userConfig = getConfig(file);
89
+ if (userConfig && !this.flags.force) {
90
+ this.error("config file exists already", {
91
+ code: "CONFIG_ERR",
92
+ _ref: "README.md#",
93
+ suggestions: [
94
+ `edit ${file}`,
95
+ "add --force flag\nWARNING, it will delete the existing file",
96
+ ],
97
+ });
98
+ }
99
+ write(file, this.generate());
100
+ }
101
+ }
@@ -0,0 +1,33 @@
1
+ import crypto from '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 =
8
+ "convert between token and sql value";
9
+
10
+
11
+ static flags = {
12
+ token: Flags.string({
13
+ exactlyOne: ["token"],
14
+ description: "the token in your config",
15
+ helpValue: "API-xxx",
16
+ }),
17
+ };
18
+
19
+ async run() {
20
+ const { args, flags } = await this.parse();
21
+ if (flags.token) {
22
+ const token = flags.token.replace("API-","").replace(/-/g, '+').replace(/_/g, '/');
23
+ const decoded = Buffer.from(token, 'base64').toString('utf-8');
24
+ const hexa = crypto.createHash('sha256').update(decoded).digest('hex')
25
+ console.log(token, decoded, hexa);
26
+
27
+ return this.output({hexa:'\\x'+hexa});
28
+ }
29
+ const data = flags;
30
+
31
+ return this.output(data);
32
+ }
33
+ }
@@ -38,13 +38,12 @@ query {
38
38
  };
39
39
 
40
40
  simplify = (d) => {
41
- console.log(d);
42
41
  const result = {
43
42
  id: d.id,
44
43
  email: d.email,
45
44
  };
46
45
  if (d.apiToken) {
47
- result.tokenExpire = "2024-11-09T11:22:22";
46
+ result.tokenExpire = d.apiToken.expiresAt;
48
47
  }
49
48
  if (d.isAdmin) {
50
49
  result.admin = true;
@@ -41,8 +41,11 @@ mutation ($org: OrgInput!) {
41
41
  const result = await mutation(AddOrgDocument, {
42
42
  org,
43
43
  });
44
- console.log(result);
45
- return result.org;
44
+ if (!result.addOrg) {
45
+ console.log(result);
46
+ return result;
47
+ }
48
+ return result?.addOrg;
46
49
  };
47
50
 
48
51
  async run() {
@@ -5,14 +5,15 @@ import Command from "#src/procaCommand.mjs";
5
5
  import { gql, query } from "#src/urql.mjs";
6
6
 
7
7
  export default class OrgGet extends Command {
8
- static args = {};
9
-
10
8
  static description = "view a org";
11
9
 
12
10
  static examples = ["<%= config.bin %> <%= command.id %> <name of the ngo>"];
13
11
 
12
+ static args = {}; //this.multiid();
13
+
14
14
  static flags = {
15
15
  // flag with no value (-f, --force)
16
+ // ...this.flagify({multiid: false}),
16
17
  ...super.globalFlags,
17
18
  name: Flags.string({
18
19
  char: "n",
package/src/config.mjs CHANGED
@@ -11,6 +11,7 @@ export const load = (folder, env = "default") => {
11
11
  return {
12
12
  token: config.parsed.PROCA_TOKEN,
13
13
  url: config.parsed.REACT_APP_API_URL,
14
+ folder: process.env.PROCA_CONFIG_FOLDER,
14
15
  };
15
16
  };
16
17
 
@@ -1,9 +1,17 @@
1
1
  import oclif from "@oclif/core";
2
+ import { config as dotenv } from "dotenv";
3
+ import { getFilename, load } from "#src/config.mjs";
2
4
  import CustomHelp from "./help.mjs";
3
5
 
4
- //console.log("hook init");
5
-
6
6
  const hook = async (opts) => {
7
+ const config = load(opts.config.configDir);
8
+ if (config) {
9
+ opts.config.procaConfig = config;
10
+ } else {
11
+ const file = getFilename(opts.config.configDir);
12
+ this.warn("missing config", file);
13
+ }
14
+
7
15
  //console.log(opts);
8
16
  //console.log(opts.config.helpClass, CustomHelp);
9
17
  // opts.config.helpClass = CustomHelp;
@@ -4,10 +4,9 @@ import { parse as dxid, id } from "dxid";
4
4
  import Table from "easy-table";
5
5
  import fastcsv from "fast-csv";
6
6
 
7
- import { getFilename as fileConfig, load as loadConfig } from "#src/config.mjs";
8
7
  import { createClient } from "#src/urql.mjs";
9
8
 
10
- export class ProcaCommand extends Command {
9
+ class ProcaCommand extends Command {
11
10
  static enableJsonFlag = true;
12
11
  procaConfig = { url: "https://api.proca.app/api" };
13
12
  format = "human"; // the default formatting
@@ -49,7 +48,7 @@ export class ProcaCommand extends Command {
49
48
  }
50
49
 
51
50
  static flagify(params = {}) {
52
- const flags = ProcaCommand.baseFlags;
51
+ const flags = Object.assign({}, ProcaCommand.baseFlags);
53
52
  if (params.multiid) {
54
53
  flags.id = Flags.string({
55
54
  char: "i",
@@ -91,35 +90,16 @@ export class ProcaCommand extends Command {
91
90
  if (flags.csv) this.format = "csv";
92
91
 
93
92
  this.debug = debug("proca");
94
- const userConfig = loadConfig(this.config.configDir);
95
- if (userConfig) {
96
- this.procaConfig = userConfig;
97
- } else {
98
- const file = fileConfig(this.config.configDir);
99
- this.warn("missing config", file);
100
- }
101
- createClient(userConfig);
93
+ this.procaConfig = this.config.procaConfig; // set up from the hooks/init
94
+ createClient(this.procaConfig);
102
95
  }
103
96
 
104
97
  async catch(err) {
105
98
  // Check if the error was caused by a missing flag or wrong argument format
106
- this.error(err.toString());
107
- if (
108
- err.message.includes("Unexpected argument") ||
109
- err.message.includes("flag")
110
- ) {
111
- // Try to adjust the argument as a flag
112
- const argv = process.argv;
113
- if (argv.includes("param")) {
114
- // Adjusting the argument 'param' to be a flag `-id`
115
- const paramIndex = argv.indexOf("param");
116
- argv.splice(paramIndex, 0, "-id"); // Insert the flag `-id` before 'param'
117
- }
118
-
119
- // Re-run the command with modified arguments
120
- await this.parse();
121
- } else {
122
- throw err;
99
+ try {
100
+ this.error(err.toString());
101
+ } catch (e) {
102
+ console.log(e);
123
103
  }
124
104
  }
125
105
 
package/src/urql.mjs CHANGED
@@ -40,7 +40,7 @@ export const createClient = (config) => {
40
40
  export const query = async (query, payload) => {
41
41
  const result = await client.query(query, payload).toPromise();
42
42
  if (result.error) {
43
- console.log(formatError(result.error));
43
+ //console.log(result.error);
44
44
  throw result.error;
45
45
  }
46
46
  return result.data;