proca 0.6.3 → 0.6.4
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 +18 -21
- package/package.json +2 -2
- package/src/commands/campaign/add.mjs +57 -20
- package/src/commands/config/set.mjs +34 -40
- package/src/commands/org/get.mjs +3 -3
- package/src/commands/widget/add.mjs +4 -3
- package/src/procaCommand.mjs +1 -1
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.6.
|
|
21
|
+
proca/0.6.4 linux-x64 node-v20.12.2
|
|
22
22
|
$ proca --help [COMMAND]
|
|
23
23
|
USAGE
|
|
24
24
|
$ proca COMMAND
|
|
@@ -59,7 +59,7 @@ 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 [
|
|
62
|
+
* [`proca config set [KEY] [VALUE]`](#proca-config-set-key-value)
|
|
63
63
|
* [`proca config setup [ENVIRONMENT]`](#proca-config-setup-environment)
|
|
64
64
|
* [`proca config token`](#proca-config-token)
|
|
65
65
|
* [`proca config user`](#proca-config-user)
|
|
@@ -171,15 +171,15 @@ EXAMPLES
|
|
|
171
171
|
|
|
172
172
|
```
|
|
173
173
|
USAGE
|
|
174
|
-
$ proca campaign add [TITLE] [--simplify [--json |
|
|
175
|
-
|
|
174
|
+
$ proca campaign add [TITLE] -n <campaign name> -o <org name> [--simplify [--json |
|
|
175
|
+
--human | --csv]]
|
|
176
176
|
|
|
177
177
|
ARGUMENTS
|
|
178
178
|
TITLE title of the campaign
|
|
179
179
|
|
|
180
180
|
FLAGS
|
|
181
|
-
-n, --name=<campaign name> name of the campaign
|
|
182
|
-
-o, --org=<org name> name of the coordinator
|
|
181
|
+
-n, --name=<campaign name> (required) name of the campaign
|
|
182
|
+
-o, --org=<org name> (required) name of the coordinator
|
|
183
183
|
|
|
184
184
|
OUTPUT FLAGS
|
|
185
185
|
--csv Format output as csv
|
|
@@ -333,28 +333,23 @@ DESCRIPTION
|
|
|
333
333
|
get the server config
|
|
334
334
|
```
|
|
335
335
|
|
|
336
|
-
## `proca config set [
|
|
336
|
+
## `proca config set [KEY] [VALUE]`
|
|
337
337
|
|
|
338
338
|
update the setting used to authenticate to the servers and services
|
|
339
339
|
|
|
340
340
|
```
|
|
341
341
|
USAGE
|
|
342
|
-
$ proca config set [
|
|
343
|
-
|
|
344
|
-
<url>] [--supabase-anon-key <value>] [--supabase-secrey-key <value>]
|
|
342
|
+
$ proca config set [KEY] [VALUE] [--simplify [--json | --human | --csv]]
|
|
343
|
+
[--environment <value>] [--url <url>] [--token <API-token>]
|
|
345
344
|
|
|
346
345
|
ARGUMENTS
|
|
347
|
-
|
|
346
|
+
KEY variable name
|
|
347
|
+
VALUE value
|
|
348
348
|
|
|
349
349
|
FLAGS
|
|
350
|
-
--
|
|
351
|
-
--
|
|
352
|
-
--
|
|
353
|
-
--supabase=<url> url of the supabase
|
|
354
|
-
--supabase-anon-key=<value> anonymous key
|
|
355
|
-
--supabase-secrey-key=<value> secret service key
|
|
356
|
-
--token=<API-token> user token on proca server
|
|
357
|
-
--url=<url> [default: https://api.proca.app/api] url of the proca server api
|
|
350
|
+
--environment=<value> [default: default] environment
|
|
351
|
+
--token=<API-token> user token on proca server
|
|
352
|
+
--url=<url> [default: https://api.proca.app/api] url of the proca server api
|
|
358
353
|
|
|
359
354
|
OUTPUT FLAGS
|
|
360
355
|
--csv Format output as csv
|
|
@@ -370,6 +365,8 @@ ALIASES
|
|
|
370
365
|
|
|
371
366
|
EXAMPLES
|
|
372
367
|
$ proca config set --user=xavier@example.org --token=API-12345789
|
|
368
|
+
|
|
369
|
+
$ proca config set VAR1 VALUE
|
|
373
370
|
```
|
|
374
371
|
|
|
375
372
|
## `proca config setup [ENVIRONMENT]`
|
|
@@ -544,8 +541,8 @@ view a org
|
|
|
544
541
|
|
|
545
542
|
```
|
|
546
543
|
USAGE
|
|
547
|
-
$ proca org get [--simplify [--json | --human | --csv]] [-n <org
|
|
548
|
-
[--keys] [--campaigns] [--widgets] [--users]
|
|
544
|
+
$ proca org get [ID_NAME_DXID] [--simplify [--json | --human | --csv]] [-n <org
|
|
545
|
+
name>] [--config] [--keys] [--campaigns] [--widgets] [--users]
|
|
549
546
|
|
|
550
547
|
FLAGS
|
|
551
548
|
-n, --name=<org name> name of the org
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "proca",
|
|
3
3
|
"description": "Access the proca api",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.4",
|
|
5
5
|
"author": "Xavier",
|
|
6
6
|
"bin": {
|
|
7
7
|
"proca": "./proca-cli"
|
|
8
8
|
},
|
|
9
9
|
"bugs": "https://github.com/fixthestatusquo/git@github.com:fixthestatusquo/proca-cli.git/issues",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@oclif/core": "^4",
|
|
11
|
+
"@oclif/core": "^4.2.10",
|
|
12
12
|
"@oclif/plugin-help": "^6",
|
|
13
13
|
"@oclif/plugin-plugins": "^5",
|
|
14
14
|
"@urql/exchange-auth": "^2.2.0",
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { Args, Flags } from "@oclif/core";
|
|
2
2
|
import { error, stdout, ux } from "@oclif/core/ux";
|
|
3
|
+
import OrgGet from "#src/commands/org/get.mjs";
|
|
3
4
|
import Command from "#src/procaCommand.mjs";
|
|
4
5
|
import { gql, mutation } from "#src/urql.mjs";
|
|
5
6
|
import { getTwitter } from "#src/util/twitter.mjs";
|
|
6
7
|
|
|
7
|
-
export default class
|
|
8
|
-
static args = {
|
|
8
|
+
export default class CampaignAdd extends Command {
|
|
9
|
+
static args = {
|
|
10
|
+
title: Args.string({
|
|
11
|
+
description: "title of the campaign",
|
|
12
|
+
multiple: true,
|
|
13
|
+
}),
|
|
14
|
+
};
|
|
15
|
+
// static strict = false;
|
|
9
16
|
|
|
10
17
|
static examples = [
|
|
11
18
|
"<%= config.bin %> <%= command.id %> -n <new_campaign> the full name of the campaign",
|
|
@@ -18,47 +25,77 @@ export default class OrgAdd extends Command {
|
|
|
18
25
|
char: "n",
|
|
19
26
|
description: "name of the campaign",
|
|
20
27
|
helpValue: "<campaign name>",
|
|
28
|
+
required: true,
|
|
21
29
|
}),
|
|
22
30
|
org: Flags.string({
|
|
23
31
|
char: "o",
|
|
24
32
|
description: "name of the coordinator",
|
|
25
33
|
helpValue: "<org name>",
|
|
34
|
+
required: true,
|
|
26
35
|
}),
|
|
27
36
|
};
|
|
28
37
|
|
|
29
|
-
create = async (
|
|
30
|
-
const org =
|
|
31
|
-
console.log(org);
|
|
38
|
+
create = async (campaign) => {
|
|
39
|
+
const org = await this.getOrg(campaign.org);
|
|
32
40
|
|
|
41
|
+
const config = {
|
|
42
|
+
locales: {
|
|
43
|
+
en: {
|
|
44
|
+
"campaign:": {
|
|
45
|
+
description: "",
|
|
46
|
+
},
|
|
47
|
+
"common:": {},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
if (org.config.locale && org.config.locale !== "en") {
|
|
52
|
+
config.locales[org.config.locale] = {};
|
|
53
|
+
}
|
|
54
|
+
if (!config.portal) {
|
|
55
|
+
config.portal = [];
|
|
56
|
+
}
|
|
33
57
|
const AddOrgDocument = gql`
|
|
34
|
-
mutation ($org: String
|
|
35
|
-
|
|
36
|
-
|
|
58
|
+
mutation ($org: String!
|
|
59
|
+
$name: String!
|
|
60
|
+
$title: String!
|
|
61
|
+
$config: Json!
|
|
62
|
+
) {
|
|
63
|
+
addCampaign (input: { name: $name, title: $title, config: $config }, orgName: $org) {
|
|
37
64
|
name
|
|
38
65
|
title
|
|
66
|
+
config
|
|
39
67
|
}
|
|
40
68
|
}
|
|
41
69
|
`;
|
|
42
70
|
const result = await mutation(AddOrgDocument, {
|
|
43
|
-
org,
|
|
71
|
+
org: org.name,
|
|
72
|
+
name: campaign.name,
|
|
73
|
+
title: campaign.title,
|
|
74
|
+
config: JSON.stringify(config),
|
|
44
75
|
});
|
|
45
|
-
|
|
46
|
-
|
|
76
|
+
|
|
77
|
+
console.log("result", result);
|
|
78
|
+
return result;
|
|
47
79
|
};
|
|
48
80
|
|
|
81
|
+
async getOrg(orgName) {
|
|
82
|
+
const { config } = this;
|
|
83
|
+
const orgGet = new OrgGet({}, this.config);
|
|
84
|
+
const org = await orgGet.fetch({ name: orgName });
|
|
85
|
+
return org;
|
|
86
|
+
}
|
|
87
|
+
|
|
49
88
|
async run() {
|
|
89
|
+
//const { args, flags } = await this.parse(CampaignAdd);
|
|
50
90
|
const { args, flags } = await this.parse();
|
|
51
|
-
if (!flags.name && !flags.twitter) {
|
|
52
|
-
this.error("You must provide either --name or --twitter");
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const org = { name: flags.twitter || flags.name, config: {} };
|
|
56
91
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
92
|
+
const campaign = {
|
|
93
|
+
org: flags.org,
|
|
94
|
+
name: flags.name,
|
|
95
|
+
title: args.title || flags.name,
|
|
96
|
+
};
|
|
60
97
|
|
|
61
|
-
const data = await this.create(
|
|
98
|
+
const data = await this.create(campaign);
|
|
62
99
|
return this.output(data);
|
|
63
100
|
}
|
|
64
101
|
}
|
|
@@ -9,9 +9,13 @@ export default class CampaignList extends Command {
|
|
|
9
9
|
static deprecateAliases = true;
|
|
10
10
|
|
|
11
11
|
static args = {
|
|
12
|
-
|
|
13
|
-
description: "
|
|
14
|
-
|
|
12
|
+
key: Args.string({
|
|
13
|
+
description: "variable name",
|
|
14
|
+
multiple: false,
|
|
15
|
+
}),
|
|
16
|
+
value: Args.string({
|
|
17
|
+
description: "value",
|
|
18
|
+
multiple: true,
|
|
15
19
|
}),
|
|
16
20
|
};
|
|
17
21
|
|
|
@@ -20,40 +24,25 @@ export default class CampaignList extends Command {
|
|
|
20
24
|
|
|
21
25
|
static examples = [
|
|
22
26
|
"<%= config.bin %> <%= command.id %> --user=xavier@example.org --token=API-12345789",
|
|
27
|
+
"<%= config.bin %> <%= command.id %> VAR1 VALUE",
|
|
23
28
|
];
|
|
24
29
|
|
|
25
30
|
static flags = {
|
|
26
31
|
// flag with no value (-f, --force)
|
|
27
32
|
...super.globalFlags,
|
|
33
|
+
environment: Flags.string({
|
|
34
|
+
description: "environment",
|
|
35
|
+
default: "default",
|
|
36
|
+
}),
|
|
28
37
|
url: Flags.string({
|
|
29
38
|
description: "url of the proca server api",
|
|
30
39
|
default: "https://api.proca.app/api",
|
|
31
40
|
helpValue: "<url>",
|
|
32
41
|
}),
|
|
33
|
-
"cloudflare-zone": Flags.string({
|
|
34
|
-
description: "zone for your cloudflare cdn",
|
|
35
|
-
}),
|
|
36
|
-
"cloudflare-token": Flags.string({
|
|
37
|
-
description: "token for your cloudflare cdn",
|
|
38
|
-
}),
|
|
39
42
|
token: Flags.string({
|
|
40
43
|
description: "user token on proca server",
|
|
41
44
|
helpValue: "<API-token>",
|
|
42
45
|
}),
|
|
43
|
-
n8n: Flags.string({
|
|
44
|
-
description: "api access on the n8n server",
|
|
45
|
-
helpValue: "<n8n api>",
|
|
46
|
-
}),
|
|
47
|
-
supabase: Flags.string({
|
|
48
|
-
description: "url of the supabase",
|
|
49
|
-
helpValue: "<url>",
|
|
50
|
-
}),
|
|
51
|
-
"supabase-anon-key": Flags.string({
|
|
52
|
-
description: "anonymous key",
|
|
53
|
-
}),
|
|
54
|
-
"supabase-secrey-key": Flags.string({
|
|
55
|
-
description: "secret service key",
|
|
56
|
-
}),
|
|
57
46
|
};
|
|
58
47
|
|
|
59
48
|
format = (obj) => {
|
|
@@ -70,40 +59,45 @@ export default class CampaignList extends Command {
|
|
|
70
59
|
|
|
71
60
|
generate = function () {
|
|
72
61
|
const mapping = {
|
|
62
|
+
...args,
|
|
73
63
|
REACT_APP_NAME: "proca",
|
|
74
64
|
REACT_APP_API_URL: this.flags.url,
|
|
75
65
|
PROCA_TOKEN: this.flags.token,
|
|
76
|
-
N8N_TOKEN: this.flags.n8n,
|
|
77
|
-
REACT_APP_SUPABASE_URL: this.flags.supabase,
|
|
78
|
-
REACT_APP_SUPABASE_ANON_KEY: this.flags.supabase_anon_key,
|
|
79
|
-
SUPABASE_SECRET_KEY: this.flags.supabase_secret_key,
|
|
80
66
|
};
|
|
81
67
|
|
|
82
68
|
return this.format(mapping);
|
|
83
69
|
};
|
|
84
70
|
|
|
71
|
+
regenerate = function (config, args) {
|
|
72
|
+
config[args.key] = args.value;
|
|
73
|
+
console.log(this.format(config));
|
|
74
|
+
process.exit(1);
|
|
75
|
+
return this.format(config);
|
|
76
|
+
};
|
|
85
77
|
async run() {
|
|
86
78
|
const config = this.config;
|
|
87
79
|
const { args, flags, raw } = await this.parse();
|
|
88
80
|
const rawf = raw.filter((d) => d.type === "flag").map((d) => d.flag);
|
|
81
|
+
|
|
89
82
|
const file = getFilename(this.config.configDir);
|
|
90
83
|
|
|
91
84
|
const userConfig = getConfig(file, true);
|
|
92
85
|
|
|
93
|
-
|
|
94
|
-
console.error(file, userConfig, rawf);
|
|
95
|
-
process.exit(1);
|
|
86
|
+
this.info("config file", file);
|
|
96
87
|
|
|
97
|
-
if (userConfig
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
88
|
+
if (userConfig) {
|
|
89
|
+
if (args.key && args.value) {
|
|
90
|
+
write(file, this.regenerate(userConfig, args));
|
|
91
|
+
} else {
|
|
92
|
+
console.log(userConfig);
|
|
93
|
+
this.error("config file exists already", {
|
|
94
|
+
code: "CONFIG_ERR",
|
|
95
|
+
_ref: "README.md#",
|
|
96
|
+
suggestions: ["add KEY VALUE to update or add new variables"],
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
write(file, this.generate());
|
|
106
101
|
}
|
|
107
|
-
write(file, this.generate());
|
|
108
102
|
}
|
|
109
103
|
}
|
package/src/commands/org/get.mjs
CHANGED
|
@@ -9,12 +9,11 @@ export default class OrgGet extends Command {
|
|
|
9
9
|
|
|
10
10
|
static examples = ["<%= config.bin %> <%= command.id %> <name of the ngo>"];
|
|
11
11
|
|
|
12
|
-
static args =
|
|
12
|
+
static args = this.multiid();
|
|
13
13
|
|
|
14
14
|
static flags = {
|
|
15
15
|
// flag with no value (-f, --force)
|
|
16
|
-
|
|
17
|
-
...super.globalFlags,
|
|
16
|
+
...this.flagify({ multiid: false }),
|
|
18
17
|
name: Flags.string({
|
|
19
18
|
char: "n",
|
|
20
19
|
charAliases: ["o"],
|
|
@@ -58,6 +57,7 @@ export default class OrgGet extends Command {
|
|
|
58
57
|
name: params.name,
|
|
59
58
|
withCampaigns: params.campaigns,
|
|
60
59
|
});
|
|
60
|
+
// result.org.config = JSON.parse (result.org.config);
|
|
61
61
|
return result.org;
|
|
62
62
|
};
|
|
63
63
|
|
|
@@ -75,17 +75,18 @@ export default class WidgetAdd extends Command {
|
|
|
75
75
|
return r;
|
|
76
76
|
} catch (e) {
|
|
77
77
|
const errors = e.graphQLErrors;
|
|
78
|
+
console.log(errors, flag, addWidgetDocument);
|
|
78
79
|
if (errors[0].path[1] === "name") {
|
|
79
80
|
this.error(`invalid name (already taken?): ${flag.name}`);
|
|
80
81
|
throw new Error(errors[0].message);
|
|
81
82
|
}
|
|
82
|
-
if (
|
|
83
|
+
if (errors[0].extensions?.code === "permission_denied") {
|
|
83
84
|
console.error("permission denied to create", name, campaign?.org.name);
|
|
84
|
-
throw new Error(
|
|
85
|
+
throw new Error(errors[0].message);
|
|
85
86
|
}
|
|
86
87
|
const page = await fetchByName(name);
|
|
87
88
|
console.warn("duplicate of widget", page.id);
|
|
88
|
-
throw new Error(
|
|
89
|
+
throw new Error(errors[0].message);
|
|
89
90
|
}
|
|
90
91
|
};
|
|
91
92
|
|
package/src/procaCommand.mjs
CHANGED
|
@@ -202,9 +202,9 @@ class ProcaCommand extends Command {
|
|
|
202
202
|
|
|
203
203
|
async output(data) {
|
|
204
204
|
if (this.format === "json") {
|
|
205
|
-
console.log("json", data);
|
|
206
205
|
if (this.flags.simplify)
|
|
207
206
|
return data?.map(this.simplify) || this.simplify(data);
|
|
207
|
+
const isDirectCall = process.argv.join(":").includes(this.id);
|
|
208
208
|
return data;
|
|
209
209
|
}
|
|
210
210
|
if (this.format === "csv") {
|