{ "id": "167521", "key": "DAEMON-81", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "12519", "key": "DAEMON", "name": "Appcelerator Daemon" }, "fixVersions": [ { "id": "20774", "description": "", "name": "Appc Daemon 2.3.0", "archived": false, "released": true } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2019-05-24T20:00:11.000+0000", "created": "2017-05-09T15:02:50.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [], "versions": [], "issuelinks": [], "assignee": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "updated": "2019-06-04T16:07:33.000+0000", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "15803", "name": "winreglib" } ], "description": "On Windows, the daemon needs to watch the Windows Registry for Android SDK, JDK, and Visual Studio related keys so that the system info can monitor it.\r\n\r\nIn the daemon prototype, the detect engine would use https://www.npmjs.com/package/winreg (which calls {{reg.exe}}) and polls the Windows Registry every 15 seconds. This is inefficient and slow.\r\n\r\nIt would be better if we had a native C++ addon for Node that we could use.\r\n\r\nIt looks like it would need to call {{RegNotifyChangeKeyValue()}} (https://msdn.microsoft.com/en-us/library/windows/desktop/ms724892(v=vs.85).aspx).\r\n\r\nThe C++ code would expose a simple API where you can start and stop watching a specific key.\r\n\r\nThen we need a high-level {{.js}} API that exports a nicer, efficient ES6 compliant API. I imagine the {{RegistryWatcher}} would extend an {{EventEmitter}}. This file would also make use of https://www.npmjs.com/package/node-pre-gyp-init to try and downloading the pre-built binary.\r\n\r\nh4. API\r\n\r\nThe public API will expose 3 methods: {{get}}, {{list}}, and {{watch}}.\r\n\r\n{{get()}} will retrieve the value for a given key.\r\n\r\n{{list()}} will retrieve all subkeys and values for a given key.\r\n\r\n{{watch()}} will start watching a registry key for changes. It will return a watch handle that emits change events and also contains the {{stop()}} method to unwatch.\r\n\r\n{code}\r\nimport { get, list, watch } from 'winreglib';\r\n\r\nconst value = get('HKCU\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run');\r\nconsole.log(`value = ${value}`);\r\n\r\nconst { resolvedRoot, key, subkeys, values } = list('HKCU\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run');\r\nconsole.log(`resolvedRoot = ${resolvedRoot}`);\r\nconsole.log(`key = ${key}`);\r\nconsole.log('subkeys:', subkeys);\r\nconsole.log('values:', values);\r\n\r\nconst handle = watch('HKCU'\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run');\r\nhandle.on('change', evt => {\r\n console.log('change!', evt);\r\n\r\n handle.stop();\r\n});\r\n{code}", "attachment": [], "flagged": false, "summary": "winreglib: Implement native addon to watch Windows Registry keys", "creator": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "subtasks": [], "reporter": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "environment": null, "closedSprints": [ { "id": 1135, "state": "closed", "name": "2019 Sprint 10", "startDate": "2019-05-06T15:32:03.726Z", "endDate": "2019-05-19T15:32:00.000Z", "completeDate": "2019-05-24T19:50:33.411Z", "originBoardId": 228 } ], "comment": { "comments": [ { "id": "448648", "author": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "body": "Published v1.0.0: https://www.npmjs.com/package/winreglib.\r\n\r\nOpted to use [prebuildify|https://www.npmjs.com/package/prebuildify] and [node-gyp-build|https://www.npmjs.com/package/node-gyp-build] instead of [node-pre-gyp|https://www.npmjs.com/package/node-pre-gyp] and [node-pre-gyp-init|https://www.npmjs.com/package/node-pre-gyp-init]. The builds are pre-compiled before publish and included in the package. There is no need for S3 or Github to store the prebuilt binaries. Because winreglib uses N-API, version 3, there shouldn't be any issues with future Node.js release and thus no need for runtime downloading of the prebuild or compiling the module.\r\n\r\nThe package contains prebuilds for 64-bit and 32-bit.\r\n", "updateAuthor": { "name": "cbarber", "key": "cbarber", "displayName": "Chris Barber", "active": true, "timeZone": "America/Chicago" }, "created": "2019-05-24T20:00:00.000+0000", "updated": "2019-05-24T20:00:00.000+0000" } ], "maxResults": 1, "total": 1, "startAt": 0 } } }