@proca/cli 3.3.1 → 3.8.3
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 +1992 -60
- package/package.json +88 -71
- package/proca-cli +8 -0
- package/src/commands/action/add.mjs +192 -0
- package/src/commands/action/confirm.mjs +93 -0
- package/src/commands/action/count.mjs +61 -0
- package/src/commands/action/list.mjs +204 -0
- package/src/commands/action/replay.mjs +56 -0
- package/src/commands/action/requeue.mjs +156 -0
- package/src/commands/campaign/add.mjs +113 -0
- package/src/commands/campaign/copy.mjs +91 -0
- package/src/commands/campaign/delete.mjs +41 -0
- package/src/commands/campaign/get.mjs +132 -0
- package/src/commands/campaign/list.mjs +161 -0
- package/src/commands/campaign/mtt.mjs +131 -0
- package/src/commands/campaign/queries.graphql +19 -0
- package/src/commands/campaign/status.mjs +63 -0
- package/src/commands/campaign/widget/archive.mjs +124 -0
- package/src/commands/campaign/widget/copy.mjs +175 -0
- package/src/commands/campaign/widget/get.mjs +19 -0
- package/src/commands/campaign/widget/index.mjs +17 -0
- package/src/commands/campaign/widget/rebuild.mjs +50 -0
- package/src/commands/config/add.mjs +97 -0
- package/src/commands/config/folder.mjs +42 -0
- package/src/commands/config/server.mjs +33 -0
- package/src/commands/config/set.mjs +103 -0
- package/src/commands/config/user.mjs +79 -0
- package/src/commands/contact/count.mjs +41 -0
- package/src/commands/contact/list.mjs +207 -0
- package/src/commands/org/add.mjs +75 -0
- package/src/commands/org/crm.mjs +88 -0
- package/src/commands/org/delete.mjs +48 -0
- package/src/commands/org/email.mjs +111 -0
- package/src/commands/org/get.mjs +152 -0
- package/src/commands/service/add.mjs +78 -0
- package/src/commands/service/list.mjs +24 -0
- package/src/commands/target/add.mjs +94 -0
- package/src/commands/template/add.mjs +97 -0
- package/src/commands/template/list.mjs +61 -0
- package/src/commands/user/get.mjs +91 -0
- package/src/commands/user/invite.mjs +56 -0
- package/src/commands/user/join.mjs +81 -0
- package/src/commands/user/leave.mjs +57 -0
- package/src/commands/user/list.mjs +80 -0
- package/src/commands/user/reset.mjs +83 -0
- package/src/commands/widget/add.mjs +116 -0
- package/src/commands/widget/delete.mjs +45 -0
- package/src/commands/widget/get.mjs +60 -0
- package/src/commands/widget/list.mjs +135 -0
- package/src/commands/widget/rebuild.mjs +64 -0
- package/src/commands/widget/update.mjs +174 -0
- package/src/config.mjs +49 -0
- package/src/generated/schema.json +10677 -0
- package/src/hooks/help.mjs +14 -0
- package/src/hooks/init.mjs +41 -0
- package/src/index.mjs +1 -0
- package/src/procaCommand.mjs +316 -0
- package/src/queries/campaign.mjs +35 -0
- package/src/queries/widget.mjs +25 -0
- package/src/urql.mjs +60 -0
- package/src/util/twitter.mjs +23 -0
- package/theme.json +29 -0
- package/LICENSE +0 -661
- package/bin/proca-cli +0 -4
- package/dist/a.d.ts +0 -1
- package/dist/a.js +0 -21
- package/dist/a.js.map +0 -1
- package/dist/browser.d.ts +0 -1
- package/dist/browser.js +0 -24
- package/dist/browser.js.map +0 -1
- package/dist/campaign.d.ts +0 -156
- package/dist/campaign.js +0 -188
- package/dist/campaign.js.map +0 -1
- package/dist/cli.d.ts +0 -40
- package/dist/cli.js +0 -411
- package/dist/cli.js.map +0 -1
- package/dist/client.d.ts +0 -2
- package/dist/client.js +0 -18
- package/dist/client.js.map +0 -1
- package/dist/config.d.ts +0 -35
- package/dist/config.js +0 -71
- package/dist/config.js.map +0 -1
- package/dist/crypto.d.ts +0 -40
- package/dist/crypto.js +0 -53
- package/dist/crypto.js.map +0 -1
- package/dist/decrypt.d.ts +0 -7
- package/dist/decrypt.js +0 -29
- package/dist/decrypt.js.map +0 -1
- package/dist/export.d.ts +0 -15
- package/dist/export.js +0 -141
- package/dist/export.js.map +0 -1
- package/dist/format.d.ts +0 -37
- package/dist/format.js +0 -200
- package/dist/format.js.map +0 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -35
- package/dist/index.js.map +0 -1
- package/dist/keys.d.ts +0 -4
- package/dist/keys.js +0 -38
- package/dist/keys.js.map +0 -1
- package/dist/org.d.ts +0 -11
- package/dist/org.js +0 -93
- package/dist/org.js.map +0 -1
- package/dist/proca.d.ts +0 -2066
- package/dist/proca.js +0 -396
- package/dist/proca.js.map +0 -1
- package/dist/queue.d.ts +0 -8
- package/dist/queue.js +0 -126
- package/dist/queue.js.map +0 -1
- package/dist/queueMessage.d.ts +0 -102
- package/dist/queueMessage.js +0 -109
- package/dist/queueMessage.js.map +0 -1
- package/dist/scalarLocations.d.ts +0 -4
- package/dist/scalarLocations.js +0 -236
- package/dist/scalarLocations.js.map +0 -1
- package/dist/service/actionnetwork.d.ts +0 -10
- package/dist/service/actionnetwork.js +0 -302
- package/dist/service/actionnetwork.js.map +0 -1
- package/dist/service/distance.d.ts +0 -3
- package/dist/service/distance.js +0 -92
- package/dist/service/distance.js.map +0 -1
- package/dist/service/echo.d.ts +0 -4
- package/dist/service/echo.js +0 -19
- package/dist/service/echo.js.map +0 -1
- package/dist/service/email.d.ts +0 -14
- package/dist/service/email.js +0 -67
- package/dist/service/email.js.map +0 -1
- package/dist/service/identity.d.ts +0 -58
- package/dist/service/identity.js +0 -190
- package/dist/service/identity.js.map +0 -1
- package/dist/service/index.d.ts +0 -14
- package/dist/service/index.js +0 -61
- package/dist/service/index.js.map +0 -1
- package/dist/setup.d.ts +0 -2
- package/dist/setup.js +0 -287
- package/dist/setup.js.map +0 -1
- package/dist/test.d.ts +0 -1
- package/dist/test.js +0 -33
- package/dist/test.js.map +0 -1
- package/dist/util.d.ts +0 -5
- package/dist/util.js +0 -30
- package/dist/util.js.map +0 -1
- package/dist/watch.d.ts +0 -9
- package/dist/watch.js +0 -76
- package/dist/watch.js.map +0 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Config, Help } from "@oclif/core";
|
|
2
|
+
|
|
3
|
+
export default class CustomHelp extends Help {
|
|
4
|
+
showCommandHelp(command) {
|
|
5
|
+
// console.log("This will be displayed in single-command CLIs");
|
|
6
|
+
super.showCommandHelp(command);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async showHelp(argv) {
|
|
10
|
+
// console.log('This will be displayed in multi-command CLIs')
|
|
11
|
+
// Always include --all flag to show all commands
|
|
12
|
+
await super.showHelp([...argv, "--all"]);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import oclif from "@oclif/core";
|
|
2
|
+
import { config as dotenv } from "dotenv";
|
|
3
|
+
import { getFilename, load } from "#src/config.mjs";
|
|
4
|
+
import CustomHelp from "./help.mjs";
|
|
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
|
+
|
|
27
|
+
const hook = async (opts) => {
|
|
28
|
+
const config = load(opts.config.configDir, getEnv());
|
|
29
|
+
if (config) {
|
|
30
|
+
opts.config.procaConfig = config;
|
|
31
|
+
} else {
|
|
32
|
+
const file = getFilename(opts.config.configDir);
|
|
33
|
+
this.warn("missing config", file);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//console.log(opts);
|
|
37
|
+
//console.log(opts.config.helpClass, CustomHelp);
|
|
38
|
+
// opts.config.helpClass = CustomHelp;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default hook;
|
package/src/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { run, Args, Flags } from "@oclif/core";
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { Args, Command, Flags, ux } from "@oclif/core";
|
|
2
|
+
import debug from "debug";
|
|
3
|
+
import { parse as dxid, id } from "dxid";
|
|
4
|
+
import Table from "easy-table";
|
|
5
|
+
import fastcsv from "fast-csv";
|
|
6
|
+
import initHook from "#src/hooks/init.mjs";
|
|
7
|
+
import { createClient } from "#src/urql.mjs";
|
|
8
|
+
|
|
9
|
+
class ProcaCommand extends Command {
|
|
10
|
+
static enableJsonFlag = true;
|
|
11
|
+
procaConfig = { url: "https://api.proca.app/api" };
|
|
12
|
+
format = "human"; // the default formatting
|
|
13
|
+
flags = {};
|
|
14
|
+
|
|
15
|
+
static baseFlags = {
|
|
16
|
+
env: Flags.string({
|
|
17
|
+
default: "default",
|
|
18
|
+
description: "allow to switch between configurations (server or users)",
|
|
19
|
+
}),
|
|
20
|
+
human: Flags.boolean({
|
|
21
|
+
helpGroup: "OUTPUT", // Optional, groups it under a specific help section if desired
|
|
22
|
+
description: "Format output to be read on screen by a human [default]",
|
|
23
|
+
default: true,
|
|
24
|
+
}),
|
|
25
|
+
json: Flags.boolean({
|
|
26
|
+
helpGroup: "OUTPUT", // Optional, groups it under a specific help section if desired
|
|
27
|
+
description: "Format output as json",
|
|
28
|
+
exclusive: ["human", "csv", "markdown"],
|
|
29
|
+
}),
|
|
30
|
+
csv: Flags.boolean({
|
|
31
|
+
description: "Format output as csv",
|
|
32
|
+
helpGroup: "OUTPUT", // Optional, groups it under a specific help section if desired
|
|
33
|
+
}),
|
|
34
|
+
markdown: Flags.boolean({
|
|
35
|
+
description: "Format output as markdown table",
|
|
36
|
+
helpGroup: "OUTPUT", // Optional, groups it under a specific help section if desired
|
|
37
|
+
}),
|
|
38
|
+
simplify: Flags.boolean({
|
|
39
|
+
helpGroup: "OUTPUT",
|
|
40
|
+
description:
|
|
41
|
+
"flatten and filter to output only the most important attributes, mostly relevant for json",
|
|
42
|
+
allowNo: true,
|
|
43
|
+
}),
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
static multiid() {
|
|
47
|
+
const args = {
|
|
48
|
+
id_name_dxid: Args.string({
|
|
49
|
+
ignoreStdin: true,
|
|
50
|
+
hidden: true,
|
|
51
|
+
description:
|
|
52
|
+
"it's better to use -i <id> or -x <dxid> or -n <name>, but you can for convenience",
|
|
53
|
+
}),
|
|
54
|
+
};
|
|
55
|
+
return args;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static flagify(params = {}) {
|
|
59
|
+
const flags = Object.assign({}, ProcaCommand.baseFlags);
|
|
60
|
+
if (params.name) {
|
|
61
|
+
flags.name = Flags.string({
|
|
62
|
+
char: "n",
|
|
63
|
+
charAliases: ["o"],
|
|
64
|
+
description: "name",
|
|
65
|
+
helpValue: "<the_short_name>",
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
if (params.multiid) {
|
|
69
|
+
flags.id = Flags.string({
|
|
70
|
+
char: "i",
|
|
71
|
+
parse: (input) => Number.parseInt(input, 10),
|
|
72
|
+
exclusive: ["name", "dxid"],
|
|
73
|
+
});
|
|
74
|
+
flags.dxid = Flags.string({
|
|
75
|
+
char: "x",
|
|
76
|
+
description: "dxid",
|
|
77
|
+
});
|
|
78
|
+
flags.name = Flags.string({
|
|
79
|
+
char: "n",
|
|
80
|
+
description: "name",
|
|
81
|
+
helpValue: "<the_short_name>",
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return flags;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async parse() {
|
|
88
|
+
const parsed = await super.parse();
|
|
89
|
+
if (this.ctor.args.id_name_dxid === undefined) {
|
|
90
|
+
return parsed;
|
|
91
|
+
}
|
|
92
|
+
const maybe = parsed.args.id_name_dxid;
|
|
93
|
+
if (maybe) {
|
|
94
|
+
const d = dxid(maybe, false);
|
|
95
|
+
if (d) parsed.flags.id = d;
|
|
96
|
+
else parsed.flags.name = maybe;
|
|
97
|
+
}
|
|
98
|
+
if (parsed.flags.dxid) {
|
|
99
|
+
parsed.flags.id = dxid(parsed.flags.dxid);
|
|
100
|
+
}
|
|
101
|
+
const identified = [
|
|
102
|
+
parsed.flags.name,
|
|
103
|
+
parsed.flags.id,
|
|
104
|
+
parsed.flags.dxid,
|
|
105
|
+
].filter(Boolean).length;
|
|
106
|
+
|
|
107
|
+
if (identified === 0) {
|
|
108
|
+
this.error("One of --name, --id, or --dxid is required");
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
await super.parse(); // check that either the first arg or the name/id/dxid are set
|
|
112
|
+
return parsed;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static hooks = {
|
|
116
|
+
init: async (options) => {
|
|
117
|
+
console.log("init hook called", options);
|
|
118
|
+
process.exit(1);
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
async init() {
|
|
122
|
+
await super.init();
|
|
123
|
+
const { argv, flags } = await this.parse();
|
|
124
|
+
this.flags = flags;
|
|
125
|
+
if (flags.json) this.format = "json";
|
|
126
|
+
if (flags.csv) this.format = "csv";
|
|
127
|
+
if (flags.markdown) this.format = "markdown";
|
|
128
|
+
|
|
129
|
+
this.debug = debug("proca");
|
|
130
|
+
initHook({ config: this.config });
|
|
131
|
+
this.procaConfig = this.config.procaConfig; // set up from the hooks/init
|
|
132
|
+
// await this.config.runHook('init', { config: this.config });
|
|
133
|
+
createClient(this.procaConfig);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async _catch(err) {
|
|
137
|
+
// Check if the error was caused by a missing flag or wrong argument format
|
|
138
|
+
console.log("aaa", err);
|
|
139
|
+
try {
|
|
140
|
+
this.error(err.toString());
|
|
141
|
+
} catch (e) {
|
|
142
|
+
console.log(e);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
flatten = (obj, prefix = "", result = {}) => {
|
|
147
|
+
Object.entries(obj).forEach(([k, v]) => {
|
|
148
|
+
const newKey = Object.hasOwn(result, k) && prefix ? `${prefix}-${k}` : k;
|
|
149
|
+
|
|
150
|
+
if (v?.constructor === Object) {
|
|
151
|
+
this.flatten(v, newKey, result);
|
|
152
|
+
} else {
|
|
153
|
+
result[newKey] = v;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
return result;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
simplify = (d) => {
|
|
160
|
+
const r = {};
|
|
161
|
+
for (const [key, value] of Object.entries(d)) {
|
|
162
|
+
if (key === "__typename") continue;
|
|
163
|
+
if (key === "config" && typeof value === "string") continue; // it's just a giant mess if not processed, let's skipt
|
|
164
|
+
if (value === null) continue;
|
|
165
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
166
|
+
r[key] = value;
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (typeof value === "object") {
|
|
171
|
+
if (value?.name) r[key] = value.name;
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
r[key] = value;
|
|
175
|
+
}
|
|
176
|
+
return r;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
tlog(color, ...msg) {
|
|
180
|
+
const coloredMsg = msg.map((d) => ux.colorize(this.config.theme[color], d));
|
|
181
|
+
this.log(...coloredMsg);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
info(...msg) {
|
|
185
|
+
this.tlog("info", msg);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
prettyJson(obj) {
|
|
189
|
+
if (typeof obj === "string") {
|
|
190
|
+
obj = JSON.parse(obj);
|
|
191
|
+
}
|
|
192
|
+
this.log(ux.colorizeJson(obj, { theme: this.config.theme.json }));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
warn(...msg) {
|
|
196
|
+
this.tlog("warn", ...msg);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
error(msg, options = {}) {
|
|
200
|
+
const colouredMessage = ux.colorize(this.config.theme.error, msg);
|
|
201
|
+
super.error(colouredMessage, options);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
async csv(data) {
|
|
205
|
+
return new Promise((resolve, reject) => {
|
|
206
|
+
let d = null;
|
|
207
|
+
const format = this.flags.simplify
|
|
208
|
+
? this.simplify
|
|
209
|
+
: (d) => this.flatten(d, "");
|
|
210
|
+
if (Array.isArray(data)) {
|
|
211
|
+
d = data.map(format);
|
|
212
|
+
} else {
|
|
213
|
+
d = [format(data)];
|
|
214
|
+
}
|
|
215
|
+
const stream = fastcsv
|
|
216
|
+
.write(d, { headers: true })
|
|
217
|
+
.on("finish", () => {
|
|
218
|
+
console.log();
|
|
219
|
+
resolve();
|
|
220
|
+
})
|
|
221
|
+
.on("error", reject);
|
|
222
|
+
|
|
223
|
+
stream.pipe(process.stdout);
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
markdown(raw) {
|
|
228
|
+
if (!raw || raw.length === 0) return "";
|
|
229
|
+
let data = [];
|
|
230
|
+
const format = this.flags.simplify
|
|
231
|
+
? this.simplify
|
|
232
|
+
: (d) => this.flatten(d, "");
|
|
233
|
+
if (Array.isArray(raw)) {
|
|
234
|
+
data = raw.map(format);
|
|
235
|
+
} else {
|
|
236
|
+
data = [format(raw)];
|
|
237
|
+
}
|
|
238
|
+
// Get all unique keys from all objects
|
|
239
|
+
const keys = [...new Set(data.flatMap((obj) => Object.keys(obj)))];
|
|
240
|
+
// Create header row
|
|
241
|
+
const header = `| ${keys.join(" | ")} |`;
|
|
242
|
+
const separator = `| ${keys.map(() => "---").join(" | ")} |`;
|
|
243
|
+
|
|
244
|
+
// Create data rows
|
|
245
|
+
const rows = data.map((obj) => {
|
|
246
|
+
return `| ${keys
|
|
247
|
+
.map((key) => {
|
|
248
|
+
const value = obj[key];
|
|
249
|
+
// Handle different value types
|
|
250
|
+
if (value === null || value === undefined) return "";
|
|
251
|
+
if (Array.isArray(value)) return `[Array(${value.length})]`;
|
|
252
|
+
if (typeof value === "object") return "[Object]";
|
|
253
|
+
return String(value);
|
|
254
|
+
})
|
|
255
|
+
.join(" | ")} |`;
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
this.log([header, separator, ...rows].join("\n"));
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
table(data, transformRow, print = (table) => table.toString()) {
|
|
262
|
+
if (!transformRow) {
|
|
263
|
+
if (this.flags.simplify !== false) {
|
|
264
|
+
transformRow = (d, cell, idx) => {
|
|
265
|
+
const r = this.simplify(d);
|
|
266
|
+
if (r === null) return null;
|
|
267
|
+
for (const [key, value] of Object.entries(r)) {
|
|
268
|
+
cell(key, value);
|
|
269
|
+
}
|
|
270
|
+
return true;
|
|
271
|
+
};
|
|
272
|
+
} else {
|
|
273
|
+
transformRow = (d, cell, idx) => {
|
|
274
|
+
for (const [key, value] of Object.entries(this.flatten(d))) {
|
|
275
|
+
cell(key, value);
|
|
276
|
+
}
|
|
277
|
+
return true;
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
const theme = this.config.theme;
|
|
282
|
+
Table.prototype.pushDelimeter = function (cols) {
|
|
283
|
+
// hack to change the formatting of the header
|
|
284
|
+
cols = cols || this.columns();
|
|
285
|
+
cols.forEach(function (col) {
|
|
286
|
+
this.cell(
|
|
287
|
+
col,
|
|
288
|
+
undefined,
|
|
289
|
+
Table.leftPadder(ux.colorize(theme.flagSeparator, "-")),
|
|
290
|
+
);
|
|
291
|
+
}, this);
|
|
292
|
+
return this.newRow();
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
this.log(Table.print(data, transformRow, print));
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
async output(data) {
|
|
299
|
+
if (this.format === "json") {
|
|
300
|
+
if (this.flags.simplify)
|
|
301
|
+
return data?.map(this.simplify) || this.simplify(data);
|
|
302
|
+
const isDirectCall = process.argv.join(":").includes(this.id);
|
|
303
|
+
return data;
|
|
304
|
+
}
|
|
305
|
+
if (this.format === "markdown") {
|
|
306
|
+
return this.markdown(data);
|
|
307
|
+
}
|
|
308
|
+
if (this.format === "csv") {
|
|
309
|
+
return this.csv(data);
|
|
310
|
+
}
|
|
311
|
+
return this.table(data);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
export { ProcaCommand as Command, Args, Flags };
|
|
316
|
+
export default ProcaCommand;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { gql } from "#src/urql.mjs";
|
|
2
|
+
|
|
3
|
+
export const FragmentSummary = gql`fragment Summary on Campaign {id name title externalId status}`;
|
|
4
|
+
|
|
5
|
+
export const FragmentMtt = gql`
|
|
6
|
+
fragment Mtt on PrivateCampaign {
|
|
7
|
+
mtt {
|
|
8
|
+
startAt
|
|
9
|
+
endAt
|
|
10
|
+
messageTemplate
|
|
11
|
+
testEmail
|
|
12
|
+
ccContacts
|
|
13
|
+
ccSender
|
|
14
|
+
dripDelivery
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
export const FragmentOrg = gql`
|
|
20
|
+
fragment Org on Campaign {
|
|
21
|
+
org {
|
|
22
|
+
name
|
|
23
|
+
title
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
export const FragmentStats = gql`
|
|
29
|
+
fragment Stats on Campaign {
|
|
30
|
+
stats {
|
|
31
|
+
supporterCount
|
|
32
|
+
actionCount {actionType count}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { gql } from "#src/urql.mjs";
|
|
2
|
+
|
|
3
|
+
export const FragmentSummary = gql`fragment Summary on PrivateActionPage {
|
|
4
|
+
id
|
|
5
|
+
locale
|
|
6
|
+
name
|
|
7
|
+
journey
|
|
8
|
+
extraSupporters
|
|
9
|
+
status
|
|
10
|
+
location
|
|
11
|
+
org {name, ... on PrivateOrg {id} }
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
export const FragmentSummaryOrg = gql`fragment Summary on PrivateActionPage {
|
|
16
|
+
id
|
|
17
|
+
locale
|
|
18
|
+
name
|
|
19
|
+
journey
|
|
20
|
+
extraSupporters
|
|
21
|
+
status
|
|
22
|
+
location
|
|
23
|
+
campaign {name }
|
|
24
|
+
}
|
|
25
|
+
`;
|
package/src/urql.mjs
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { authExchange } from "@urql/exchange-auth";
|
|
2
|
+
import {
|
|
3
|
+
createClient as _createClient,
|
|
4
|
+
cacheExchange,
|
|
5
|
+
fetchExchange,
|
|
6
|
+
gql,
|
|
7
|
+
} from "urql";
|
|
8
|
+
|
|
9
|
+
import { GraphQLError, formatError } from "graphql";
|
|
10
|
+
|
|
11
|
+
export let client = {
|
|
12
|
+
query: () => {
|
|
13
|
+
throw new Error("urql graphql not initialised, call init first");
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// Create a URQL client with your GraphQL API endpoint
|
|
18
|
+
export const createClient = (config) => {
|
|
19
|
+
if (!config) {
|
|
20
|
+
console.error("config missing on createClient");
|
|
21
|
+
}
|
|
22
|
+
client = _createClient({
|
|
23
|
+
url: config?.url || "https://api.proca.app/api",
|
|
24
|
+
exchanges: [
|
|
25
|
+
// cacheExchange, // Handles caching
|
|
26
|
+
authExchange(async (utils) => {
|
|
27
|
+
const token = config.token;
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
addAuthToOperation(operation) {
|
|
31
|
+
if (!token) return operation;
|
|
32
|
+
return utils.appendHeaders(operation, {
|
|
33
|
+
Authorization: `Bearer ${token}`,
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}),
|
|
38
|
+
fetchExchange, // Handles fetching
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const query = async (query, payload) => {
|
|
44
|
+
const result = await client.query(query, payload).toPromise();
|
|
45
|
+
if (result.error) {
|
|
46
|
+
//console.log(result.error);
|
|
47
|
+
throw result.error;
|
|
48
|
+
}
|
|
49
|
+
return result.data;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const mutation = async (mutation, payload) => {
|
|
53
|
+
const result = await client.mutation(mutation, payload).toPromise();
|
|
54
|
+
if (result.error) {
|
|
55
|
+
throw result.error;
|
|
56
|
+
}
|
|
57
|
+
return result.data;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export { gql };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const getTwitter = async (org) => {
|
|
2
|
+
const orgName = org.config.twitter?.screen_name || org.name;
|
|
3
|
+
try {
|
|
4
|
+
const res = await fetch(
|
|
5
|
+
`https://twitter.proca.app/?screen_name=${orgName}`,
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
if (res.status >= 400) {
|
|
9
|
+
throw new Error("Bad response from twitter.proca.app");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const twitter = await res.json();
|
|
13
|
+
twitter.picture = twitter.profile_image_url_https;
|
|
14
|
+
twitter.profile_image_url_https = undefined;
|
|
15
|
+
if (twitter) org.config.twitter = twitter;
|
|
16
|
+
if (!org.config.description) org.config.description = twitter.description;
|
|
17
|
+
if (!org.config.location) org.config.location = twitter.location;
|
|
18
|
+
if (!org.config.url) org.config.url = twitter.url;
|
|
19
|
+
if (!org.title) org.title = twitter.name;
|
|
20
|
+
} catch (err) {
|
|
21
|
+
console.error(err);
|
|
22
|
+
}
|
|
23
|
+
};
|
package/theme.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"info": "cyan",
|
|
3
|
+
"warn": "#FFAB40",
|
|
4
|
+
"error": "red",
|
|
5
|
+
"bin": "block",
|
|
6
|
+
"command": "cyan",
|
|
7
|
+
"commandSummary": "black",
|
|
8
|
+
"dollarSign": "white",
|
|
9
|
+
"flag": "blackBright",
|
|
10
|
+
"flagDefaultValue": "blue",
|
|
11
|
+
"flagOptions": "white",
|
|
12
|
+
"flagRequired": "red",
|
|
13
|
+
"flagSeparator": "white",
|
|
14
|
+
"json": {
|
|
15
|
+
"brace": "magenta",
|
|
16
|
+
"bracket": "magenta",
|
|
17
|
+
"colon": "dim",
|
|
18
|
+
"comma": "dim",
|
|
19
|
+
"key": "yellow",
|
|
20
|
+
"string": "green",
|
|
21
|
+
"number": "green",
|
|
22
|
+
"boolean": "green",
|
|
23
|
+
"null": "red"
|
|
24
|
+
},
|
|
25
|
+
"sectionDescription": "blackBright",
|
|
26
|
+
"sectionHeader": "underline",
|
|
27
|
+
"topic": "cyan",
|
|
28
|
+
"version": "white"
|
|
29
|
+
}
|