diff --git a/.gitignore b/.gitignore
index 606779f..ba044e4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -59,4 +59,4 @@ typings/
temp
.DS_Store
package-lock.json
-release
+dist
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cadb2c9..0fc4ebb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+# 0.1.0 (07/04/2017)
+
+- show dropdown menu, instead of electron webview
+- default sync interval is 60 seconds, should use less CPU
+
# 0.0.1 (07/04/2017)
- quick and easy working example
diff --git a/assets/example.png b/assets/example.png
index 6a18c60..6eb66df 100644
Binary files a/assets/example.png and b/assets/example.png differ
diff --git a/index.html b/index.html
deleted file mode 100644
index 9e24257..0000000
--- a/index.html
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
- Sample Menubar App
-
-
-
- local-npm
-
-
diff --git a/index.js b/index.js
index e69de29..33df618 100644
--- a/index.js
+++ b/index.js
@@ -0,0 +1,48 @@
+const { app, BrowserWindow, ipcMain, Tray, Menu, MenuItem, shell } = require('electron');
+
+const path = require('path')
+const local = require('local-npm');
+
+const assetsDir = path.join(__dirname, 'assets');
+const tempDir = path.join(__dirname, 'temp');
+
+const server = local({
+ directory: tempDir,
+ port: 5678,
+ pouchPort: 3040,
+ logLevel: 'error',
+ remote: 'https://registry.npmjs.org',
+ remoteSkim: 'https://replicate.npmjs.com',
+ url: 'http://127.0.0.1:5080',
+ syncInterval: 60000
+}, () => {
+ console.log('listening!');
+});
+
+let tray;
+
+app.on('ready', () => {
+ tray = new Tray(path.resolve(__dirname, './assets/cloudTemplate.png'));
+
+ var requests = 0;
+ var sync = 0;
+ function getMenu() {
+ return Menu.buildFromTemplate([
+ {label: 'http://localhost:5678', click: function() { shell.openExternal('http://localhost:5678/_browse') } },
+ {label: `requests: ${requests}`, type: 'normal'},
+ {label: `sync: ${sync}`, type: 'normal'}
+ ]);
+ }
+
+ process.on('request', (args) => {
+ ++requests;
+ })
+
+ process.on('sync', (args) => {
+ sync = args[1];
+ })
+
+ tray.on('click', function() {
+ tray.popUpContextMenu(getMenu())
+ })
+});
diff --git a/log.js b/log.js
deleted file mode 100644
index ccebf34..0000000
--- a/log.js
+++ /dev/null
@@ -1,72 +0,0 @@
-'use strict'
-
-/**
- * Redirects default log functions
- *
- * On Mac => ~/Library/Logs/[AppName-WithoutSpaces|Electron].log
- * On Win => C:\Users\[UserName]\AppData\Local\[AppName-WithoutSpaces|Electron].log
- * On Linux => ~/.[AppName-WithoutSpaces|Electron].log
- */
-
-const os = require('os')
-const fs = require('fs')
-const path = require('path')
-const isDev = require('electron-is-dev')
-
-// Set default output streams (STDOUT/STDERR) and an empty log file path
-var output = process.stdout
-var errorOutput = process.stderr
-var logFile = null
-
-module.exports = (logFileName) => {
- switch (os.platform()) {
- case 'darwin':
- logFile = path.join(os.homedir(), 'Library/Logs', (logFileName || 'Electron').replace(' ', '') + '.log')
- break
- case 'win32':
- logFile = path.join(os.homedir(), 'AppData', 'Local', (logFileName || 'Electron').replace(' ', '') + '.log')
- break
- case 'linux':
- logFile = path.join(os.homedir(), '.' + (logFileName || 'Electron').replace(' ', '') + '.log')
- break
- default:
- // Others: leave untouched
- }
-
- // If we are in production and a log file is defined we redirect logs to that file
- if (!isDev && logFile) {
- output = fs.createWriteStream(logFile)
- errorOutput = fs.createWriteStream(logFile)
- }
-
- // Create common logger
- const logger = new console.Console(output, errorOutput)
-
- // Override default log utilities
- console.log = function () {
- arguments[0] = new Date().toISOString() + ' - ' + arguments[0]
- logger.log.apply(null, arguments)
- }
-
- console.debug = function () {
- arguments[0] = new Date().toISOString() + ' - ' + arguments[0]
- if (isDev || (global.appSettings && global.appSettings.debug)) {
- logger.log.apply(null, arguments)
- }
- }
-
- console.info = function () {
- arguments[0] = new Date().toISOString() + ' - ' + arguments[0]
- logger.log.apply(null, arguments)
- }
-
- console.warn = function () {
- arguments[0] = new Date().toISOString() + ' - ' + arguments[0]
- logger.log.apply(null, arguments)
- }
-
- console.error = function () {
- arguments[0] = new Date().toISOString() + ' - ' + arguments[0]
- logger.log.apply(null, arguments)
- }
-}
diff --git a/main.js b/main.js
deleted file mode 100644
index 96e8808..0000000
--- a/main.js
+++ /dev/null
@@ -1,101 +0,0 @@
-const { app, BrowserWindow, ipcMain, Tray } = require('electron');
-
-require('electron-debug')({enabled: true, showDevTools: true});
-require('./log')('local-npm-daemon');
-
-const path = require('path')
-const spawn = require('child_process').spawn;
-const npm = require('local-npm');
-
-const assetsDir = path.join(__dirname, 'assets');
-const tempDir = path.join(__dirname, 'temp');
-
-const server = npm({
- directory: tempDir,
- port: 5678,
- pouchPort: 3040,
- logLevel: 'debug',
- remote: 'https://registry.npmjs.org',
- remoteSkim: 'https://replicate.npmjs.com',
- url: 'http://127.0.0.1:5080'
-}, () => {
- console.log('listening!');
-});
-
-let tray = undefined
-let window = undefined
-
-// This method is called once Electron is ready to run our code
-// It is effectively the main method of our Electron app
-app.on('ready', () => {
- // Setup the menubar with an icon
- tray = new Tray(path.resolve(__dirname, './assets/cloudTemplate.png'));
-
- // Add a click handler so that when the user clicks on the menubar icon, it shows
- // our popup window
- tray.on('click', function(event) {
- toggleWindow()
-
- // Show devtools when command clicked
- if (window.isVisible() && process.defaultApp && event.metaKey) {
- window.openDevTools({mode: 'detach'})
- }
- })
-
- // Make the popup window for the menubar
- window = new BrowserWindow({
- width: 500,
- height: 350,
- show: false,
- frame: false,
- resizable: false,
- })
-
- // Only close the window on blur if dev tools isn't opened
- window.on('blur', () => {
- if(!window.webContents.isDevToolsOpened()) {
- window.hide()
- }
- })
-})
-
-const toggleWindow = () => {
- if (window.isVisible()) {
- window.hide()
- } else {
- showWindow()
- }
-}
-
-const showWindow = () => {
- window.loadURL(`http://127.0.0.1:5678/_browse`);
-
- const trayPos = tray.getBounds()
- const windowPos = window.getBounds()
- let x, y = 0
- if (process.platform == 'darwin') {
- x = Math.round(trayPos.x + (trayPos.width / 2) - (windowPos.width / 2))
- y = Math.round(trayPos.y + trayPos.height)
- } else {
- x = Math.round(trayPos.x + (trayPos.width / 2) - (windowPos.width / 2))
- y = Math.round(trayPos.y + trayPos.height * 10)
- }
-
-
- window.setPosition(x, y, false)
- window.show()
- window.focus()
-}
-
-ipcMain.on('show-window', () => {
- showWindow()
-})
-
-app.on('window-all-closed', () => {
- // On macOS it is common for applications and their menu bar
- // to stay active until the user quits explicitly with Cmd + Q
- if (process.platform !== 'darwin') {
- server.close();
- app.quit()
- }
-})
diff --git a/package.json b/package.json
index 2dad2b1..710b8f3 100644
--- a/package.json
+++ b/package.json
@@ -1,31 +1,28 @@
{
- "name": "local-npm-daemon",
- "version": "0.0.1",
- "description": "An electron application to run local-npm",
- "main": "main.js",
- "scripts": {
- "start": "electron .",
- "build": "electron-packager . --overwrite --platform=linux,darwin --arch=x64 --icon=./assets/logo.icns --prune=true --out=release",
- "test": "echo \"Error: no test specified\" && exit 1"
- },
- "repository": {
- "type": "git",
- "url": "git+https://github.com/gabrielcsapo/local-npm-daemon.git"
- },
- "author": "Gabriel J. Csapo ",
- "license": "ISC",
- "bugs": {
- "url": "https://github.com/gabrielcsapo/local-npm-daemon/issues"
- },
- "homepage": "https://github.com/gabrielcsapo/local-npm-daemon#readme",
- "devDependencies": {
- "devtron": "^1.4.0",
- "electron-packager": "^8.7.2",
- "electron-prebuilt": "^1.4.13"
- },
- "dependencies": {
- "electron-debug": "^1.2.0",
- "electron-is-dev": "^0.2.0",
- "local-npm": "^2.1.0"
- }
+ "name": "local-npm-daemon",
+ "version": "0.1.0",
+ "description": "An electron application to run local-npm",
+ "main": "index.js",
+ "scripts": {
+ "start": "electron .",
+ "build": "electron-rebuild && electron-packager . --overwrite --platform=linux,darwin --arch=x64 --icon=./assets/logo.icns --prune=true --out=dist --ignore=temp"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/gabrielcsapo/local-npm-daemon.git"
+ },
+ "author": "Gabriel J. Csapo ",
+ "license": "ISC",
+ "bugs": {
+ "url": "https://github.com/gabrielcsapo/local-npm-daemon/issues"
+ },
+ "homepage": "https://github.com/gabrielcsapo/local-npm-daemon#readme",
+ "devDependencies": {
+ "electron": "^1.6.11",
+ "electron-packager": "^8.7.2",
+ "electron-rebuild": "^1.5.11"
+ },
+ "dependencies": {
+ "local-npm": "^2.2.0"
+ }
}