clocktopus 1.1.0 → 1.1.2
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/dist/index.js +9 -1
- package/dist/lib/jira.js +8 -2
- package/package.json +3 -2
- package/scripts/postinstall.cjs +67 -0
package/dist/index.js
CHANGED
|
@@ -186,7 +186,7 @@ program
|
|
|
186
186
|
const eligible = latestSession.isAutoCompleted && completedAt > twoHoursAgo && !!latestSession.projectId;
|
|
187
187
|
if (!eligible)
|
|
188
188
|
return;
|
|
189
|
-
await clockify.startTimer(workspaceId, latestSession.projectId, latestSession.description);
|
|
189
|
+
await clockify.startTimer(workspaceId, latestSession.projectId, latestSession.description, latestSession.jiraTicket ?? undefined);
|
|
190
190
|
console.log(chalk.green('Timer restarted for the last used project.'));
|
|
191
191
|
lastResumeAt = Date.now();
|
|
192
192
|
}
|
|
@@ -201,6 +201,9 @@ program
|
|
|
201
201
|
if (!getSessionState) {
|
|
202
202
|
throw new Error('getSessionState not found in module');
|
|
203
203
|
}
|
|
204
|
+
// Verify the native addon actually works before setting up polling
|
|
205
|
+
const initialState = getSessionState();
|
|
206
|
+
console.log(chalk.gray(`Initial session state: ${initialState}`));
|
|
204
207
|
pollInterval = setInterval(async () => {
|
|
205
208
|
try {
|
|
206
209
|
const state = getSessionState();
|
|
@@ -217,6 +220,11 @@ program
|
|
|
217
220
|
}
|
|
218
221
|
catch (error) {
|
|
219
222
|
console.error('Error polling session state:', error);
|
|
223
|
+
if (pollInterval) {
|
|
224
|
+
clearInterval(pollInterval);
|
|
225
|
+
pollInterval = null;
|
|
226
|
+
console.error(chalk.red('Display monitoring disabled due to repeated errors.'));
|
|
227
|
+
}
|
|
220
228
|
}
|
|
221
229
|
}, 3000);
|
|
222
230
|
}
|
package/dist/lib/jira.js
CHANGED
|
@@ -21,7 +21,10 @@ async function jiraApiRequest(endpoint, method, body) {
|
|
|
21
21
|
return response.data;
|
|
22
22
|
}
|
|
23
23
|
catch (error) {
|
|
24
|
-
if (error
|
|
24
|
+
if (axios.isAxiosError(error)) {
|
|
25
|
+
console.error('Error making Jira API request (OAuth):', error.message, error.response?.data);
|
|
26
|
+
}
|
|
27
|
+
else if (error instanceof Error) {
|
|
25
28
|
console.error('Error making Jira API request (OAuth):', error.message);
|
|
26
29
|
}
|
|
27
30
|
return null;
|
|
@@ -49,7 +52,10 @@ async function jiraApiRequest(endpoint, method, body) {
|
|
|
49
52
|
return response.data;
|
|
50
53
|
}
|
|
51
54
|
catch (error) {
|
|
52
|
-
if (error
|
|
55
|
+
if (axios.isAxiosError(error)) {
|
|
56
|
+
console.error('Error making Jira API request:', error.message, error.response?.data);
|
|
57
|
+
}
|
|
58
|
+
else if (error instanceof Error) {
|
|
53
59
|
console.error('Error making Jira API request:', error.message);
|
|
54
60
|
}
|
|
55
61
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clocktopus",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -10,12 +10,13 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|
|
12
12
|
"data/.gitkeep",
|
|
13
|
+
"scripts/postinstall.cjs",
|
|
13
14
|
"!dist/desktop"
|
|
14
15
|
],
|
|
15
16
|
"scripts": {
|
|
16
17
|
"build": "bunx tsc",
|
|
17
18
|
"prepublishOnly": "bunx tsc",
|
|
18
|
-
"postinstall": "
|
|
19
|
+
"postinstall": "node scripts/postinstall.cjs",
|
|
19
20
|
"lint": "eslint . --ext .ts",
|
|
20
21
|
"clock": "bun dist/index.js",
|
|
21
22
|
"monitor": "bun dist/index.js monitor",
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { execSync } = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
const nativeModules = ['macos-notification-state', 'desktop-idle'];
|
|
7
|
+
|
|
8
|
+
function findNodeGyp() {
|
|
9
|
+
// Try plain node-gyp first (globally installed)
|
|
10
|
+
try {
|
|
11
|
+
execSync('node-gyp --version', { stdio: 'ignore' });
|
|
12
|
+
return 'node-gyp';
|
|
13
|
+
} catch {}
|
|
14
|
+
|
|
15
|
+
// Try npx (comes with Node.js)
|
|
16
|
+
try {
|
|
17
|
+
execSync('npx --version', { stdio: 'ignore' });
|
|
18
|
+
return 'npx node-gyp';
|
|
19
|
+
} catch {}
|
|
20
|
+
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function rebuildModule(moduleName, nodeGypCmd) {
|
|
25
|
+
let modulePath;
|
|
26
|
+
try {
|
|
27
|
+
modulePath = path.dirname(require.resolve(`${moduleName}/package.json`));
|
|
28
|
+
} catch {
|
|
29
|
+
// Module not installed (e.g. optional dependency on wrong platform)
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const bindingGyp = path.join(modulePath, 'binding.gyp');
|
|
34
|
+
try {
|
|
35
|
+
require('fs').accessSync(bindingGyp);
|
|
36
|
+
} catch {
|
|
37
|
+
// No binding.gyp, not a native module
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
console.log(`Building native addon: ${moduleName}...`);
|
|
43
|
+
execSync(`${nodeGypCmd} rebuild`, { cwd: modulePath, stdio: 'inherit' });
|
|
44
|
+
console.log(`Built ${moduleName} successfully.`);
|
|
45
|
+
} catch (err) {
|
|
46
|
+
console.warn(`Warning: Failed to build ${moduleName}. The monitor feature may not work.`);
|
|
47
|
+
console.warn(` You can try manually: cd ${modulePath} && npx node-gyp rebuild`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Only build on macOS — these are macOS-only native addons
|
|
52
|
+
if (process.platform !== 'darwin') {
|
|
53
|
+
console.log('Skipping native addon build (not macOS).');
|
|
54
|
+
process.exit(0);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const nodeGypCmd = findNodeGyp();
|
|
58
|
+
if (!nodeGypCmd) {
|
|
59
|
+
console.warn('Warning: node-gyp not found. Native addons were not built.');
|
|
60
|
+
console.warn(' Install node-gyp: npm install -g node-gyp');
|
|
61
|
+
console.warn(' Then rebuild: cd node_modules/macos-notification-state && node-gyp rebuild');
|
|
62
|
+
process.exit(0);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
for (const mod of nativeModules) {
|
|
66
|
+
rebuildModule(mod, nodeGypCmd);
|
|
67
|
+
}
|