-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathentrypoint.js
64 lines (55 loc) · 1.53 KB
/
entrypoint.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
function run(_) {
const app = Application.currentApplication();
app.includeStandardAdditions = true;
const env = (key) => app.systemAttribute(`${key}`) || '';
const makeActivityItem = (title, subtitle, arg, valid = true) => ({
title,
subtitle,
arg,
valid
});
const items = (items) => JSON.stringify({ items });
const DEFAULT_ITEMS = [
makeActivityItem(
'Start',
'Start a new Clockify time entry.',
'create_time_entry'
),
makeActivityItem(
'Stop',
'End the currently-ongoing clockify time entry.',
'pick_client'
),
makeActivityItem(
'Discard',
'Discard the currently-ongoing clockify time entry.',
'discard_timer'
)
];
const SETUP_API_KEY_ITEMS = [
makeActivityItem(
'Set API Key to Continue',
'Define the Clockify API key environment variable to continue.',
'install_api_key',
false
)
];
const SETUP_USER_ID_ITEMS = [
makeActivityItem(
'Setup User Account',
'Select this option to install your Clockify user id.',
'install_user_id'
)
];
const SETUP_WORKSPACE_ID_ITEMS = [
makeActivityItem(
'Choose Workspace',
'Select this option to define the Clockify workspace ID to use',
'install_workspace_id'
)
];
if (!env('clockify_api_key')) return items(SETUP_API_KEY_ITEMS);
if (!env('clockify_user_id')) return items(SETUP_USER_ID_ITEMS);
if (!env('clockify_workspace_id')) return items(SETUP_WORKSPACE_ID_ITEMS);
return items(DEFAULT_ITEMS);
}