proca 1.7.8 → 1.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 +469 -134
- package/package.json +5 -3
- package/proca-cli +2 -2
- package/src/commands/action/add.mjs +131 -131
- package/src/commands/action/confirm.mjs +44 -44
- package/src/commands/action/count.mjs +41 -41
- package/src/commands/action/list.mjs +130 -130
- package/src/commands/action/replay.mjs +30 -30
- package/src/commands/action/requeue.mjs +110 -110
- package/src/commands/campaign/add.mjs +95 -83
- package/src/commands/campaign/copy.mjs +91 -0
- package/src/commands/campaign/delete.mjs +36 -56
- package/src/commands/campaign/get.mjs +5 -0
- package/src/commands/campaign/list.mjs +128 -123
- package/src/commands/campaign/queries.graphql +14 -14
- package/src/commands/campaign/status.mjs +39 -39
- 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 +78 -78
- package/src/commands/config/folder.mjs +30 -30
- package/src/commands/config/server.mjs +15 -15
- package/src/commands/config/set.mjs +84 -84
- package/src/commands/config/user.mjs +50 -48
- package/src/commands/contact/count.mjs +22 -23
- package/src/commands/contact/list.mjs +131 -131
- package/src/commands/org/add.mjs +51 -51
- package/src/commands/org/crm.mjs +61 -61
- package/src/commands/org/delete.mjs +31 -31
- package/src/commands/org/email.mjs +94 -66
- package/src/commands/org/get.mjs +10 -5
- package/src/commands/service/add.mjs +59 -59
- package/src/commands/service/list.mjs +15 -15
- package/src/commands/target/add.mjs +52 -52
- package/src/commands/template/add.mjs +67 -67
- package/src/commands/template/list.mjs +33 -33
- package/src/commands/user/get.mjs +60 -60
- package/src/commands/user/invite.mjs +37 -37
- package/src/commands/user/join.mjs +51 -51
- package/src/commands/user/leave.mjs +47 -47
- package/src/commands/user/list.mjs +2 -2
- package/src/commands/user/reset.mjs +72 -72
- package/src/commands/widget/add.mjs +61 -70
- package/src/commands/widget/delete.mjs +27 -27
- package/src/commands/widget/get.mjs +34 -33
- package/src/commands/widget/list.mjs +93 -80
- package/src/commands/widget/rebuild.mjs +64 -0
- package/src/commands/widget/update.mjs +174 -0
- package/src/config.mjs +31 -31
- package/src/generated/schema.json +10675 -10675
- package/src/hooks/help.mjs +9 -9
- package/src/hooks/init.mjs +26 -26
- package/src/procaCommand.mjs +22 -1
- package/src/urql.mjs +39 -39
- package/src/util/twitter.mjs +19 -19
- package/theme.json +27 -27
|
@@ -1,38 +1,46 @@
|
|
|
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
|
+
export const getWidgetList = (params) => {
|
|
8
|
+
const d = new WidgetList([]);
|
|
9
|
+
return d.fetch(params);
|
|
10
|
+
};
|
|
11
|
+
|
|
7
12
|
export default class WidgetList extends Command {
|
|
8
|
-
|
|
13
|
+
static description = "list all the widgets of an org or campaign";
|
|
14
|
+
|
|
15
|
+
static examples = ["<%= config.bin %> <%= command.id %> -o <organisation>"];
|
|
9
16
|
|
|
10
|
-
|
|
17
|
+
// static aliases = ["campaign:widget:get", "org:widget:get"]; let's rewrite them for better aliasing
|
|
11
18
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
static flags = {
|
|
20
|
+
// flag with no value (-f, --force)
|
|
21
|
+
...super.globalFlags,
|
|
22
|
+
org: Flags.string({
|
|
23
|
+
char: "o",
|
|
24
|
+
// exactlyOne: ["campaign", "org"], actually, we can filter on both
|
|
25
|
+
description: "widgets of the organisation (coordinator or partner)",
|
|
26
|
+
helpValue: "<organisation name>",
|
|
27
|
+
exactlyOne: ["campaign", "org"],
|
|
28
|
+
// required: true,
|
|
29
|
+
}),
|
|
30
|
+
campaign: Flags.string({
|
|
31
|
+
char: "c",
|
|
32
|
+
description: "widgets of the campaign (coordinator or partner)",
|
|
33
|
+
helpValue: "<campaign name>",
|
|
34
|
+
// required: true,
|
|
35
|
+
}),
|
|
36
|
+
config: Flags.boolean({
|
|
37
|
+
description: "get the config",
|
|
38
|
+
default: false,
|
|
39
|
+
allowNo: true,
|
|
40
|
+
}),
|
|
41
|
+
};
|
|
42
|
+
fetchCampaign = async (name) => {
|
|
43
|
+
const Document = gql`
|
|
36
44
|
query SearchWidgets($campaign: String!, $withConfig: Boolean!) {
|
|
37
45
|
campaign (name:$campaign) { ...on PrivateCampaign {
|
|
38
46
|
actionPages {
|
|
@@ -47,15 +55,20 @@ query SearchWidgets($campaign: String!, $withConfig: Boolean!) {
|
|
|
47
55
|
}
|
|
48
56
|
${FragmentSummary}
|
|
49
57
|
}`;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
const result = await query(Document, {
|
|
59
|
+
campaign: name,
|
|
60
|
+
withConfig: this.flags.config,
|
|
61
|
+
});
|
|
62
|
+
if (this.flags.org) {
|
|
63
|
+
return result.campaign.actionPages.filter(
|
|
64
|
+
(d) => d.org.name === this.flags.org,
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
return result.campaign.actionPages;
|
|
68
|
+
};
|
|
56
69
|
|
|
57
|
-
|
|
58
|
-
|
|
70
|
+
fetchOrg = async (name) => {
|
|
71
|
+
const Document = gql`
|
|
59
72
|
query SearchWidgets($org: String!, $withConfig: Boolean!) {
|
|
60
73
|
org (name:$org) {
|
|
61
74
|
actionPages {
|
|
@@ -70,53 +83,53 @@ query SearchWidgets($org: String!, $withConfig: Boolean!) {
|
|
|
70
83
|
}
|
|
71
84
|
${FragmentSummaryOrg}
|
|
72
85
|
}`;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
86
|
+
const result = await query(Document, {
|
|
87
|
+
org: name,
|
|
88
|
+
withConfig: this.flags.config,
|
|
89
|
+
});
|
|
90
|
+
return result.org.actionPages;
|
|
91
|
+
};
|
|
79
92
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
93
|
+
simplify = (d) => {
|
|
94
|
+
const result = {
|
|
95
|
+
id: d.id,
|
|
96
|
+
name: d.name,
|
|
97
|
+
locale: d.locale,
|
|
98
|
+
status: d.status.toLowerCase(),
|
|
99
|
+
location: d.location?.startsWith("https://widget.proca.app")
|
|
100
|
+
? undefined
|
|
101
|
+
: d.location || undefined,
|
|
102
|
+
// live: d.live,
|
|
90
103
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
104
|
+
// thankYouTemplate: d.thankYouTemplate || undefined,
|
|
105
|
+
// thankYouTemplateRef: d.thankYouTemplateRef || undefined,
|
|
106
|
+
// supporterConfirmTemplate: d.supporterConfirmTemplate || undefined,
|
|
107
|
+
};
|
|
108
|
+
if (d.extraSupporters > 0) {
|
|
109
|
+
result.extra = d.extraSupporters;
|
|
110
|
+
}
|
|
111
|
+
// if (d.journey) result.journey = d.journey.join(" → ");
|
|
112
|
+
if (d.org) {
|
|
113
|
+
result.org = d.org.name;
|
|
114
|
+
result.org_id = d.org.id;
|
|
115
|
+
}
|
|
116
|
+
if (d.campaign) {
|
|
117
|
+
result.campaign = d.campaign.name;
|
|
118
|
+
}
|
|
119
|
+
if (this.flags.config) {
|
|
120
|
+
}
|
|
121
|
+
return result;
|
|
122
|
+
};
|
|
110
123
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
124
|
+
table = (r) => {
|
|
125
|
+
super.table(r, null, (table) => table.sort(["id|des"]).toString());
|
|
126
|
+
};
|
|
114
127
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
128
|
+
async run() {
|
|
129
|
+
const { flags } = await this.parse(WidgetList);
|
|
130
|
+
let data = [];
|
|
131
|
+
if (flags.org) data = await this.fetchOrg(flags.org);
|
|
132
|
+
if (flags.campaign) data = await this.fetchCampaign(flags.campaign);
|
|
133
|
+
return this.output(data);
|
|
134
|
+
}
|
|
122
135
|
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { Args, Flags } from "@oclif/core";
|
|
2
|
+
import { 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 WidgetUpdate extends Command {
|
|
8
|
+
static description = "Update a widget's properties";
|
|
9
|
+
|
|
10
|
+
static examples = [
|
|
11
|
+
"<%= config.bin %> <%= command.id %> 4454 --name new_widget_name",
|
|
12
|
+
"<%= config.bin %> <%= command.id %> 4454 --locale fr",
|
|
13
|
+
"<%= config.bin %> <%= command.id %> 4454 --confirm-optin",
|
|
14
|
+
"<%= config.bin %> <%= command.id %> 4454 --confirm-optin --dry-run",
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
static args = this.multiid();
|
|
18
|
+
|
|
19
|
+
static flags = {
|
|
20
|
+
// flag with no value (-f, --force)
|
|
21
|
+
...this.flagify({ multiid: true }),
|
|
22
|
+
rename: Flags.string({
|
|
23
|
+
char: "n",
|
|
24
|
+
description: "new name for the widget",
|
|
25
|
+
helpValue: "<widget name>",
|
|
26
|
+
}),
|
|
27
|
+
|
|
28
|
+
locale: Flags.string({
|
|
29
|
+
char: "l",
|
|
30
|
+
description: "change the locale",
|
|
31
|
+
helpValue: "<locale>",
|
|
32
|
+
}),
|
|
33
|
+
color: Flags.string({
|
|
34
|
+
description: "update color (not yet implemented)",
|
|
35
|
+
helpValue: "<hex code>",
|
|
36
|
+
}),
|
|
37
|
+
"confirm-optin": Flags.boolean({
|
|
38
|
+
description:
|
|
39
|
+
"add confirmOptIn (check email snack) to consent.email component ",
|
|
40
|
+
|
|
41
|
+
default: false,
|
|
42
|
+
}),
|
|
43
|
+
"confirm-action": Flags.boolean({
|
|
44
|
+
description:
|
|
45
|
+
"add actionConfirm (check email snack) to consent.email component ",
|
|
46
|
+
|
|
47
|
+
default: false,
|
|
48
|
+
}),
|
|
49
|
+
|
|
50
|
+
"dry-run": Flags.boolean({
|
|
51
|
+
description: "Show changes without updating the widget",
|
|
52
|
+
default: false,
|
|
53
|
+
}),
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
fetchWidget = async (params) => {
|
|
57
|
+
const widgetGet = new WidgetGet([], this.config);
|
|
58
|
+
return widgetGet.fetch(params);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
update = async (widgetId, input) => {
|
|
62
|
+
console.log("Updating widget with input:", input);
|
|
63
|
+
const Document = gql`
|
|
64
|
+
mutation UpdateActionPage($id: Int!, $input: ActionPageInput!) {
|
|
65
|
+
updateActionPage(id: $id, input: $input) {
|
|
66
|
+
id
|
|
67
|
+
name
|
|
68
|
+
locale
|
|
69
|
+
config
|
|
70
|
+
thankYouTemplate
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
|
|
75
|
+
const payload = {
|
|
76
|
+
...input,
|
|
77
|
+
...(input.config && typeof input.config !== "string"
|
|
78
|
+
? { config: JSON.stringify(input.config) }
|
|
79
|
+
: {}),
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const r = await mutation(Document, {
|
|
83
|
+
id: widgetId,
|
|
84
|
+
input: payload,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
return r.updateActionPage;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
table = (r) => {
|
|
91
|
+
super.table(r, null, null);
|
|
92
|
+
if (this.flags.config) {
|
|
93
|
+
this.prettyJson(r.config);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
async run() {
|
|
98
|
+
const { flags } = await this.parse();
|
|
99
|
+
const {
|
|
100
|
+
id,
|
|
101
|
+
rename,
|
|
102
|
+
locale,
|
|
103
|
+
color,
|
|
104
|
+
"confirm-optin": confirmOptIn,
|
|
105
|
+
"confirm-action": confirmAction,
|
|
106
|
+
"dry-run": dryRun,
|
|
107
|
+
} = flags;
|
|
108
|
+
|
|
109
|
+
// Fetch current widget
|
|
110
|
+
const widget = await this.fetchWidget({ id });
|
|
111
|
+
|
|
112
|
+
if (!widget) {
|
|
113
|
+
this.error("Widget not found");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Validate name
|
|
117
|
+
if (rename) {
|
|
118
|
+
const nameParts = renname.split("/");
|
|
119
|
+
if (nameParts.length < 2) {
|
|
120
|
+
this.error(
|
|
121
|
+
"Widget name must follow format: campaign_name/org_name or campaign_name/locale or campaign_name/org_name/locale",
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const input = {
|
|
127
|
+
name: rename ?? widget.name,
|
|
128
|
+
locale: locale ?? widget.locale,
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
if (color) {
|
|
132
|
+
this.error(`Color update requested: ${color} (not yet implemented)`);
|
|
133
|
+
}
|
|
134
|
+
if (confirmOptIn || confirmAction) {
|
|
135
|
+
const act = confirmOptIn ? "confirmOptIn" : "confirmAction";
|
|
136
|
+
const currentConfig =
|
|
137
|
+
typeof widget.config === "string"
|
|
138
|
+
? JSON.parse(widget.config)
|
|
139
|
+
: (widget.config ?? {});
|
|
140
|
+
|
|
141
|
+
const nextConfig = merge(currentConfig, {
|
|
142
|
+
component: {
|
|
143
|
+
consent: {
|
|
144
|
+
email: {
|
|
145
|
+
[act]: true,
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
input.config = nextConfig;
|
|
152
|
+
|
|
153
|
+
this.log(`✓ Will set consent.email.${act} = true`);
|
|
154
|
+
|
|
155
|
+
if (dryRun) {
|
|
156
|
+
this.log("\n--- DRY RUN ---\n");
|
|
157
|
+
this.log("FROM:");
|
|
158
|
+
this.log(JSON.stringify(currentConfig, null, 2));
|
|
159
|
+
this.log("\nTO:");
|
|
160
|
+
this.log(JSON.stringify(nextConfig, null, 2));
|
|
161
|
+
this.log("\n(no mutation executed)");
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
try {
|
|
167
|
+
const updated = await this.update(widget.id, input);
|
|
168
|
+
this.log("✓ Widget updated successfully");
|
|
169
|
+
return this.output(updated);
|
|
170
|
+
} catch (err) {
|
|
171
|
+
this.error(`Failed to update widget: ${err.message}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
package/src/config.mjs
CHANGED
|
@@ -3,47 +3,47 @@ import { join } from "node:path";
|
|
|
3
3
|
import { config as dotenv } from "dotenv";
|
|
4
4
|
|
|
5
5
|
export const getFilename = (folder, env = "default") =>
|
|
6
|
-
|
|
6
|
+
join(folder, `${env}.env`);
|
|
7
7
|
|
|
8
8
|
export const load = (folder, env = "default") => {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const file = getFilename(folder, env);
|
|
10
|
+
const config = dotenv({ path: file });
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
return {
|
|
13
|
+
token: config.parsed.PROCA_TOKEN,
|
|
14
|
+
url: config.parsed.REACT_APP_API_URL,
|
|
15
|
+
folder: process.env.PROCA_CONFIG_FOLDER,
|
|
16
|
+
};
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export const get = (file, parsed = false) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
try {
|
|
21
|
+
if (parsed) {
|
|
22
|
+
const config = dotenv({ path: file });
|
|
23
|
+
return config.parsed;
|
|
24
|
+
}
|
|
25
|
+
const userConfig = readFileSync(file, "utf8");
|
|
26
|
+
return userConfig;
|
|
27
|
+
} catch (e) {
|
|
28
|
+
if (e.code === "ENOENT") {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
throw e;
|
|
32
|
+
}
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
export const write = (file, content) => {
|
|
36
|
-
|
|
36
|
+
writeFileSync(file, content);
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
export const format = (obj) => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
const content = ["# generated by proca-cli"];
|
|
41
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
42
|
+
if (value) {
|
|
43
|
+
content.push(`${key}='${value.replace(/'/g, "''")}'`);
|
|
44
|
+
} else {
|
|
45
|
+
content.push(`#${key}= `);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return content.join("\n");
|
|
49
49
|
};
|