@trycourier/cli 1.0.1 → 1.1.0
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 +2 -0
- package/dist/commands/Send.js +1 -3
- package/dist/commands/TranslationUpload.d.ts +5 -0
- package/dist/commands/TranslationUpload.js +28 -0
- package/dist/commands/TranslationsUpload.d.ts +5 -0
- package/dist/commands/TranslationsUpload.js +28 -0
- package/dist/components/Elemental.js +8 -9
- package/dist/components/Request.js +1 -1
- package/dist/mappings.js +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,6 +35,8 @@ You can find your Courier API key in your [Courier Settings](https://app.courier
|
|
|
35
35
|
- `courier whoami` – Display the currently authenticated workspace
|
|
36
36
|
- `courier send` - Send a notification to a user, list, or audience
|
|
37
37
|
- `courier track` - Send an event to test your Courier Automations
|
|
38
|
+
- `courier digests:flush` - Send an event to test your Courier Automations
|
|
39
|
+
- `courier translations:upload` - Upload .PO files to your Courier workspace
|
|
38
40
|
|
|
39
41
|
For more details, run `courier` to see a list of commands and their arguments & options.
|
|
40
42
|
|
package/dist/commands/Send.js
CHANGED
|
@@ -101,9 +101,7 @@ export default ({ params }) => {
|
|
|
101
101
|
return (React.createElement(Box, { flexDirection: "column" },
|
|
102
102
|
params.elemental ? (React.createElement(React.Fragment, null,
|
|
103
103
|
React.createElement(Box, { borderStyle: "bold", borderColor: "white" },
|
|
104
|
-
React.createElement(Text, null,
|
|
105
|
-
' ',
|
|
106
|
-
"Elemental")),
|
|
104
|
+
React.createElement(Text, null, " Elemental")),
|
|
107
105
|
React.createElement(Box, null,
|
|
108
106
|
React.createElement(Elemental, { elemental: payload.message.content })))) : null,
|
|
109
107
|
React.createElement(Request, { request: request, response: resp })));
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import UhOh from '../components/UhOh.js';
|
|
4
|
+
import Request from '../components/Request.js';
|
|
5
|
+
import api from '../lib/api.js';
|
|
6
|
+
export default ({ params }) => {
|
|
7
|
+
const [resp, setResp] = useState();
|
|
8
|
+
const locale = params?._?.[0];
|
|
9
|
+
if (!locale) {
|
|
10
|
+
return React.createElement(UhOh, { text: "You must specify a locale, e.g. en-US." });
|
|
11
|
+
}
|
|
12
|
+
const filepath = params?._?.[1];
|
|
13
|
+
if (!filepath) {
|
|
14
|
+
return React.createElement(UhOh, { text: "You must specify a path to the .PO file." });
|
|
15
|
+
}
|
|
16
|
+
else if (!fs.existsSync(filepath)) {
|
|
17
|
+
return React.createElement(UhOh, { text: "No .PO file found at given path." });
|
|
18
|
+
}
|
|
19
|
+
const request = {
|
|
20
|
+
method: 'PUT',
|
|
21
|
+
url: `/translations/global/${locale}`,
|
|
22
|
+
body: fs.readFileSync(filepath, 'utf8'),
|
|
23
|
+
};
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
api(request).then(res => setResp(res));
|
|
26
|
+
}, []);
|
|
27
|
+
return React.createElement(Request, { request: request, response: resp });
|
|
28
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import UhOh from '../components/UhOh.js';
|
|
4
|
+
import Request from '../components/Request.js';
|
|
5
|
+
import api from '../lib/api.js';
|
|
6
|
+
export default ({ params }) => {
|
|
7
|
+
const [resp, setResp] = useState();
|
|
8
|
+
const locale = params?._?.[0];
|
|
9
|
+
if (!locale) {
|
|
10
|
+
return React.createElement(UhOh, { text: "You must specify a locale, e.g. en-US." });
|
|
11
|
+
}
|
|
12
|
+
const filepath = params?._?.[1];
|
|
13
|
+
if (!filepath) {
|
|
14
|
+
return React.createElement(UhOh, { text: "You must specify a path to the .PO file." });
|
|
15
|
+
}
|
|
16
|
+
else if (!fs.existsSync(filepath)) {
|
|
17
|
+
return React.createElement(UhOh, { text: "No .PO file found at given path." });
|
|
18
|
+
}
|
|
19
|
+
const request = {
|
|
20
|
+
method: 'PUT',
|
|
21
|
+
url: `/translations/global/${locale}`,
|
|
22
|
+
body: fs.readFileSync(filepath, 'utf8'),
|
|
23
|
+
};
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
api(request).then(res => setResp(res));
|
|
26
|
+
}, []);
|
|
27
|
+
return React.createElement(Request, { request: request, response: resp });
|
|
28
|
+
};
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Box, Text
|
|
2
|
+
import { Box, Text } from 'ink';
|
|
3
3
|
export default ({ elemental }) => {
|
|
4
4
|
const buckets = [];
|
|
5
|
-
elemental.elements.map(
|
|
5
|
+
elemental.elements.map(element => {
|
|
6
6
|
const { type, ...rest } = element;
|
|
7
7
|
buckets.push({
|
|
8
8
|
type: element.type,
|
|
9
|
-
properties: Object.keys(rest).map(
|
|
9
|
+
properties: Object.keys(rest).map(key => ({
|
|
10
10
|
name: key,
|
|
11
|
-
value: rest[key]
|
|
12
|
-
}))
|
|
11
|
+
value: rest[key],
|
|
12
|
+
})),
|
|
13
13
|
});
|
|
14
14
|
});
|
|
15
|
-
return React.createElement(Box, { flexDirection:
|
|
15
|
+
return (React.createElement(Box, { flexDirection: "column" }, buckets.map(bucket => bucket.properties.map(property => (React.createElement(Box, null,
|
|
16
16
|
React.createElement(Box, { width: 16, paddingTop: 1 },
|
|
17
17
|
React.createElement(Text, null,
|
|
18
18
|
bucket.type,
|
|
19
19
|
".",
|
|
20
|
-
property.name),
|
|
21
|
-
|
|
22
|
-
React.createElement(Box, { borderStyle: 'round', flexDirection: 'column', paddingX: 1 },
|
|
20
|
+
property.name)),
|
|
21
|
+
React.createElement(Box, { borderStyle: "round", flexDirection: "column", paddingX: 1 },
|
|
23
22
|
React.createElement(Text, null, property.value))))))));
|
|
24
23
|
};
|
|
@@ -11,7 +11,7 @@ export default (props) => {
|
|
|
11
11
|
' ',
|
|
12
12
|
"https://api.courier.com",
|
|
13
13
|
props.request.url)),
|
|
14
|
-
props.request.body
|
|
14
|
+
props.request.body ? (typeof props.request.body === 'string' ? (React.createElement(Text, null, props.request.body)) : (React.createElement(Text, null, JSON.stringify(props.request.body, undefined, ' ')))) : null,
|
|
15
15
|
!props.request.body ? React.createElement(Text, { color: "gray" }, "No request body") : null,
|
|
16
16
|
!props.response ? (React.createElement(Spinner, { text: props.spinnerText || defaultSpinnerText })) : null,
|
|
17
17
|
props.response ? (React.createElement(Box, { borderStyle: "bold", borderColor: props.response?.err ? 'red' : 'green' },
|
package/dist/mappings.js
CHANGED
|
@@ -4,6 +4,7 @@ import WhoAmI from './commands/WhoAmI.js';
|
|
|
4
4
|
import Track from './commands/Track.js';
|
|
5
5
|
import Send from './commands/Send.js';
|
|
6
6
|
import DigestFlush from './commands/DigestFlush.js';
|
|
7
|
+
import TranslationsUpload from './commands/TranslationsUpload.js';
|
|
7
8
|
const mappings = new Map();
|
|
8
9
|
mappings.set('help', {
|
|
9
10
|
component: () => {
|
|
@@ -95,4 +96,11 @@ mappings.set('digest:flush', {
|
|
|
95
96
|
return React.createElement(DigestFlush, { params: params });
|
|
96
97
|
},
|
|
97
98
|
});
|
|
99
|
+
mappings.set('translations:upload', {
|
|
100
|
+
params: '<locale> <filepath>',
|
|
101
|
+
instructions: 'Upload a .PO file to Courier for a given locale',
|
|
102
|
+
component: params => {
|
|
103
|
+
return React.createElement(TranslationsUpload, { params: params });
|
|
104
|
+
},
|
|
105
|
+
});
|
|
98
106
|
export default mappings;
|