proca 0.8.1 → 1.1.5
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 +1079 -28
- package/package.json +94 -101
- package/proca-cli +8 -0
- package/src/commands/action/count.mjs +61 -0
- package/src/commands/action/list.mjs +204 -0
- package/src/commands/action/replay.mjs +54 -0
- package/src/commands/campaign/add.mjs +101 -0
- package/src/commands/campaign/delete.mjs +61 -0
- package/src/commands/campaign/get.mjs +107 -0
- package/src/commands/campaign/list.mjs +156 -0
- package/src/commands/campaign/queries.graphql +19 -0
- package/src/commands/config/add.mjs +101 -0
- package/src/commands/config/get.mjs +33 -0
- package/src/commands/config/set.mjs +103 -0
- package/src/commands/config/token.mjs +34 -0
- package/src/commands/config/user.mjs +76 -0
- package/src/commands/org/add.mjs +66 -0
- package/src/commands/org/crm.mjs +88 -0
- package/src/commands/org/delete.mjs +48 -0
- package/src/commands/org/get.mjs +97 -0
- package/src/commands/org/join.mjs +77 -0
- package/src/commands/supporter/count.mjs +96 -0
- package/src/commands/user/get.mjs +91 -0
- package/src/commands/user/leave.mjs +52 -0
- package/src/commands/user/list.mjs +71 -0
- package/src/commands/widget/add.mjs +101 -0
- package/src/commands/widget/cache.mjs +29 -0
- package/src/commands/widget/get.mjs +59 -0
- package/src/commands/widget/list.mjs +116 -0
- package/src/config.mjs +36 -0
- package/src/generated/schema.json +10677 -0
- package/src/hooks/help.mjs +14 -0
- package/src/hooks/init.mjs +20 -0
- package/src/index.mjs +1 -0
- package/src/procaCommand.mjs +242 -0
- package/src/queries/campaign.mjs +21 -0
- package/src/queries/widget.mjs +12 -0
- package/src/urql.mjs +60 -0
- package/src/util/twitter.mjs +23 -0
- package/theme.json +29 -0
- package/LICENSE +0 -661
- package/dist/App.css +0 -22
- package/dist/App.js +0 -25
- package/dist/App.test.js +0 -8
- package/dist/Wizard.js +0 -32
- package/dist/components/Alert.js +0 -49
- package/dist/components/Clickify.js +0 -26
- package/dist/components/Consent.js +0 -120
- package/dist/components/Country.js +0 -94
- package/dist/components/Dialog.js +0 -84
- package/dist/components/Disabled.js +0 -3
- package/dist/components/Emoji.js +0 -12
- package/dist/components/FAB.js +0 -70
- package/dist/components/Html.js +0 -56
- package/dist/components/Loader.js +0 -14
- package/dist/components/Openletter.js +0 -443
- package/dist/components/Organisation.js +0 -181
- package/dist/components/Petition.js +0 -16
- package/dist/components/ProcaRoot.js +0 -23
- package/dist/components/ProcaStyle.js +0 -94
- package/dist/components/ProgressCounter.js +0 -64
- package/dist/components/Register.js +0 -345
- package/dist/components/Share.js +0 -177
- package/dist/components/TextField.js +0 -58
- package/dist/components/Twitter.js +0 -127
- package/dist/components/TwitterAction.js +0 -111
- package/dist/components/TwitterList.js +0 -25
- package/dist/components/TwitterText.js +0 -42
- package/dist/components/Widget.js +0 -266
- package/dist/components/bespoke/Download.js +0 -49
- package/dist/components/bespoke/Register-CH.js +0 -505
- package/dist/data/countries.json +0 -114
- package/dist/hooks/useConfig.js +0 -217
- package/dist/hooks/useCount.js +0 -95
- package/dist/hooks/useData.js +0 -59
- package/dist/hooks/useElementWidth.js +0 -46
- package/dist/hooks/useGeoLocation.js +0 -45
- package/dist/hooks/useLayout.js +0 -63
- package/dist/images/Twitter.js +0 -16
- package/dist/images/Twitter.svg +0 -1
- package/dist/index.css +0 -13
- package/dist/index.js +0 -114
- package/dist/lib/domparser.js +0 -12
- package/dist/lib/i18n.js +0 -40
- package/dist/lib/init.js +0 -7
- package/dist/lib/server.js +0 -331
- package/dist/lib/urlparser.js +0 -65
- package/dist/lib/uuid.js +0 -30
- package/dist/locales/README.md +0 -37
- package/dist/locales/common.json +0 -189
- package/dist/locales/de/common.json +0 -46
- package/dist/locales/de/index.js +0 -0
- package/dist/locales/en/common.json +0 -45
- package/dist/locales/fr/common.json +0 -51
- package/dist/locales/index.js +0 -27
- package/dist/locales/it/common.json +0 -46
- package/dist/logo.svg +0 -1
- package/dist/module.js +0 -14
- package/dist/slingshot.xcf +0 -0
- package/dist/tmp.config/0.json +0 -21
- package/dist/tmp.config/2.json +0 -11
- package/dist/tmp.config/20.json +0 -29
- package/dist/tmp.config/28.json +0 -14
- package/dist/tmp.config/32.json +0 -34
- package/dist/tmp.config/35.json +0 -14
- package/dist/tmp.config/null.json +0 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Args, Flags } from "@oclif/core";
|
|
2
|
+
import { error, stdout, ux } from "@oclif/core/ux";
|
|
3
|
+
import CampaignGet from "#src/commands/campaign/get.mjs";
|
|
4
|
+
import Command from "#src/procaCommand.mjs";
|
|
5
|
+
import { gql, mutation } from "#src/urql.mjs";
|
|
6
|
+
|
|
7
|
+
export default class WidgetAdd extends Command {
|
|
8
|
+
//static args = { path: { description: "" } };
|
|
9
|
+
|
|
10
|
+
static flags = {
|
|
11
|
+
// flag with no value (-f, --force)
|
|
12
|
+
...super.globalFlags,
|
|
13
|
+
campaign: Flags.string({
|
|
14
|
+
char: "c",
|
|
15
|
+
required: true,
|
|
16
|
+
description: "name of the campaign",
|
|
17
|
+
helpValue: "<campaign name>",
|
|
18
|
+
}),
|
|
19
|
+
org: Flags.string({
|
|
20
|
+
char: "o",
|
|
21
|
+
description: "organisation",
|
|
22
|
+
helpValue: "<en>",
|
|
23
|
+
}),
|
|
24
|
+
lang: Flags.string({
|
|
25
|
+
char: "l",
|
|
26
|
+
description: "language",
|
|
27
|
+
default: "en",
|
|
28
|
+
helpValue: "<en>",
|
|
29
|
+
}),
|
|
30
|
+
name: Flags.string({
|
|
31
|
+
char: "n",
|
|
32
|
+
description: "url slug",
|
|
33
|
+
helpValue: "by default <campaign>/<org>/<lang>",
|
|
34
|
+
}),
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
create = async (flag) => {
|
|
38
|
+
const orgName = flag.org;
|
|
39
|
+
let campaign = { org: { name: orgName } }; // no need to fetch the campaign if the orgName is specified
|
|
40
|
+
|
|
41
|
+
const addWidgetDocument = gql`
|
|
42
|
+
mutation addPage(
|
|
43
|
+
$campaign: String!
|
|
44
|
+
$org: String!
|
|
45
|
+
$name: String!
|
|
46
|
+
$lang: String!
|
|
47
|
+
) {
|
|
48
|
+
addActionPage(
|
|
49
|
+
campaignName: $campaign
|
|
50
|
+
orgName: $org
|
|
51
|
+
input: { name: $name, locale: $lang }
|
|
52
|
+
) {
|
|
53
|
+
id
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
`;
|
|
57
|
+
|
|
58
|
+
if (!orgName) {
|
|
59
|
+
try {
|
|
60
|
+
const campapi = new CampaignGet();
|
|
61
|
+
campaign = await campapi.fetch({ name: flag.campaign });
|
|
62
|
+
flag.org = campaign.org.name;
|
|
63
|
+
} catch (e) {
|
|
64
|
+
console.log("error", e);
|
|
65
|
+
throw e;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!campaign) {
|
|
70
|
+
throw new Error(`campaign not found: ${flag.campaign}`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
const r = await mutation(addWidgetDocument, flag);
|
|
75
|
+
return r;
|
|
76
|
+
} catch (e) {
|
|
77
|
+
const errors = e.graphQLErrors;
|
|
78
|
+
console.log(errors, flag, addWidgetDocument);
|
|
79
|
+
if (errors[0].path[1] === "name") {
|
|
80
|
+
this.error(`invalid name (already taken?): ${flag.name}`);
|
|
81
|
+
throw new Error(errors[0].message);
|
|
82
|
+
}
|
|
83
|
+
if (errors[0].extensions?.code === "permission_denied") {
|
|
84
|
+
console.error("permission denied to create", name, campaign?.org.name);
|
|
85
|
+
throw new Error(errors[0].message);
|
|
86
|
+
}
|
|
87
|
+
const page = await fetchByName(name);
|
|
88
|
+
console.warn("duplicate of widget", page.id);
|
|
89
|
+
throw new Error(errors[0].message);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
async run() {
|
|
94
|
+
const { args, flags } = await this.parse();
|
|
95
|
+
|
|
96
|
+
// const org = { name: flags.twitter || flags.name, config: {} };
|
|
97
|
+
|
|
98
|
+
const data = await this.create(flags);
|
|
99
|
+
return this.output(data);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Args, Flags } from "@oclif/core";
|
|
2
|
+
import { error, stdout, ux } from "@oclif/core/ux";
|
|
3
|
+
import Command from "#src/procaCommand.mjs";
|
|
4
|
+
import { FragmentSummary } from "#src/queries/widget.mjs";
|
|
5
|
+
import { gql, query } from "#src/urql.mjs";
|
|
6
|
+
|
|
7
|
+
export default class WidgetGet extends Command {
|
|
8
|
+
static description = "clear the cdn cache of a widget";
|
|
9
|
+
|
|
10
|
+
static examples = [
|
|
11
|
+
"<%= config.bin %> <%= command.id %> --url https://cdn.proca.app/d/[campaign]/[org]/[locale]",
|
|
12
|
+
"<%= config.bin %> <%= command.id %> --name [campaign]/[org]/[locale]",
|
|
13
|
+
];
|
|
14
|
+
static args = this.multiid();
|
|
15
|
+
|
|
16
|
+
static flags = {
|
|
17
|
+
// flag with no value (-f, --force)
|
|
18
|
+
...this.flagify({ multiid: true }),
|
|
19
|
+
url: Flags.string ({
|
|
20
|
+
description: "url of the widget on the CDN",
|
|
21
|
+
}),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
async run() {
|
|
25
|
+
const { args, flags } = await this.parse();
|
|
26
|
+
console.log(flags);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Args, Flags } from "@oclif/core";
|
|
2
|
+
import { error, stdout, ux } from "@oclif/core/ux";
|
|
3
|
+
import Command from "#src/procaCommand.mjs";
|
|
4
|
+
import { FragmentSummary } from "#src/queries/widget.mjs";
|
|
5
|
+
import { gql, query } from "#src/urql.mjs";
|
|
6
|
+
|
|
7
|
+
export default class WidgetGet extends Command {
|
|
8
|
+
static description = "view a widget";
|
|
9
|
+
|
|
10
|
+
static examples = [
|
|
11
|
+
"<%= config.bin %> <%= command.id %> <path of the widget>",
|
|
12
|
+
];
|
|
13
|
+
static args = this.multiid();
|
|
14
|
+
|
|
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
|
+
};
|
|
24
|
+
|
|
25
|
+
fetch = async (params) => {
|
|
26
|
+
const GetWidgetDocument = gql`
|
|
27
|
+
query GetWidget($name: String, $id: Int, $config: Boolean = true) {
|
|
28
|
+
actionPage(name: $name, id: $id) {
|
|
29
|
+
...Summary
|
|
30
|
+
org {
|
|
31
|
+
name
|
|
32
|
+
}
|
|
33
|
+
campaign {
|
|
34
|
+
name
|
|
35
|
+
}
|
|
36
|
+
thankYouTemplate
|
|
37
|
+
config @include(if: $config)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
${FragmentSummary}
|
|
41
|
+
`;
|
|
42
|
+
const result = await query(GetWidgetDocument, params);
|
|
43
|
+
return result.actionPage;
|
|
44
|
+
};
|
|
45
|
+
|
|
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
|
+
};
|
|
53
|
+
|
|
54
|
+
async run() {
|
|
55
|
+
const { args, flags } = await this.parse();
|
|
56
|
+
const data = await this.fetch(flags);
|
|
57
|
+
return this.output(data);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Args, Flags } from "@oclif/core";
|
|
2
|
+
import { error, stdout, ux } from "@oclif/core/ux";
|
|
3
|
+
import Command from "#src/procaCommand.mjs";
|
|
4
|
+
import { FragmentSummary } from "#src/queries/widget.mjs";
|
|
5
|
+
import { gql, query } from "#src/urql.mjs";
|
|
6
|
+
|
|
7
|
+
export default class WidgetList extends Command {
|
|
8
|
+
static description = "list all the widgets of an org or campaign";
|
|
9
|
+
|
|
10
|
+
static examples = ["<%= config.bin %> <%= command.id %> -o <organisation>"];
|
|
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`
|
|
36
|
+
query SearchWidgets($campaign: String!, $withConfig: Boolean!) {
|
|
37
|
+
campaign (name:$campaign) { ...on PrivateCampaign {
|
|
38
|
+
actionPages {
|
|
39
|
+
...Summary
|
|
40
|
+
config @include(if: $withConfig)
|
|
41
|
+
thankYouTemplate
|
|
42
|
+
thankYouTemplateRef
|
|
43
|
+
...on PrivateActionPage {
|
|
44
|
+
supporterConfirmTemplate
|
|
45
|
+
}
|
|
46
|
+
}}
|
|
47
|
+
}
|
|
48
|
+
${FragmentSummary}
|
|
49
|
+
}`;
|
|
50
|
+
const result = await query(Document, {
|
|
51
|
+
campaign: name,
|
|
52
|
+
withConfig: this.flags.config,
|
|
53
|
+
});
|
|
54
|
+
return result.campaign.actionPages;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
fetchOrg = async (name) => {
|
|
58
|
+
const Document = gql`
|
|
59
|
+
query SearchWidgets($org: String!, $withConfig: Boolean!) {
|
|
60
|
+
org (name:$org) {
|
|
61
|
+
actionPages {
|
|
62
|
+
...Summary
|
|
63
|
+
config @include(if: $withConfig)
|
|
64
|
+
thankYouTemplate
|
|
65
|
+
thankYouTemplateRef
|
|
66
|
+
...on PrivateActionPage {
|
|
67
|
+
supporterConfirmTemplate
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
${FragmentSummary}
|
|
72
|
+
}`;
|
|
73
|
+
const result = await query(Document, {
|
|
74
|
+
org: name,
|
|
75
|
+
withConfig: this.flags.config,
|
|
76
|
+
});
|
|
77
|
+
return result.org.actionPages;
|
|
78
|
+
};
|
|
79
|
+
|
|
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,
|
|
90
|
+
|
|
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
|
+
|
|
100
|
+
if (this.flags.config) {
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
table = (r) => {
|
|
106
|
+
super.table(r, null, (table) => table.sort(["id|des"]).toString());
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
async run() {
|
|
110
|
+
const { flags, args } = await this.parse(WidgetList);
|
|
111
|
+
let data = [];
|
|
112
|
+
if (flags.org) data = await this.fetchOrg(flags.org);
|
|
113
|
+
if (flags.campaign) data = await this.fetchCampaign(flags.campaign);
|
|
114
|
+
return this.output(data);
|
|
115
|
+
}
|
|
116
|
+
}
|
package/src/config.mjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { config as dotenv } from "dotenv";
|
|
4
|
+
|
|
5
|
+
export const getFilename = (folder, env = "default") =>
|
|
6
|
+
join(folder, `${env}.env`);
|
|
7
|
+
|
|
8
|
+
export const load = (folder, env = "default") => {
|
|
9
|
+
const file = getFilename(folder, env);
|
|
10
|
+
const config = dotenv({ path: file });
|
|
11
|
+
return {
|
|
12
|
+
token: config.parsed.PROCA_TOKEN,
|
|
13
|
+
url: config.parsed.REACT_APP_API_URL,
|
|
14
|
+
folder: process.env.PROCA_CONFIG_FOLDER,
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const get = (file, parsed = false) => {
|
|
19
|
+
try {
|
|
20
|
+
if (parsed) {
|
|
21
|
+
const config = dotenv({ path: file });
|
|
22
|
+
return config.parsed;
|
|
23
|
+
}
|
|
24
|
+
const userConfig = readFileSync(file, "utf8");
|
|
25
|
+
return userConfig;
|
|
26
|
+
} catch (e) {
|
|
27
|
+
if (e.code === "ENOENT") {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
throw e;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const write = (file, content) => {
|
|
35
|
+
writeFileSync(file, content);
|
|
36
|
+
};
|