Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@focus-me/focus-cli

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@focus-me/focus-cli - npm Package Compare versions

Comparing version 3.0.0 to 3.0.1

6

dist/plugins/application-manager/application-manager.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const exec_script_1 = require("../../util/exec-script");
const debug_1 = require("debug");
const debug = debug_1.default('plugin:application-manager');
const plugin = {

@@ -10,3 +12,3 @@ async start(config) {

catch (e) {
console.error(e);
debug(e);
}

@@ -21,3 +23,3 @@ },

catch (e) {
console.error(e);
debug(e);
}

@@ -24,0 +26,0 @@ },

@@ -5,2 +5,4 @@ "use strict";

const path = require("path");
const debug_1 = require("debug");
const debug = debug_1.default('plugin:rain');
let proc;

@@ -10,4 +12,5 @@ const play = async (config) => {

const p = new Promise((res, rej) => {
proc = child_process_1.exec(`afplay -v ${volume} ${path.join(__dirname, '..', '..', '..', 'assets', 'rain.mp3')}`, () => {
proc = child_process_1.exec(`afplay -v ${volume} ${path.join(__dirname, '..', '..', '..', 'assets', 'rain.mp3')}`, err => {
// swallow errors, we don't really care if this plays and we also kill the process at the end.
debug(err);
res();

@@ -14,0 +17,0 @@ });

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const api_1 = require("./api");
const debug_1 = require("debug");
const debug = debug_1.default('plugin:rescue-time');
const plugin = {
async start(config) {
await api_1.startFocustime(config.apiKey, config.duration);
try {
await api_1.startFocustime(config.apiKey, config.duration);
}
catch (e) {
debug(e);
}
},
async stop(config, completed) {
if (!completed)
await api_1.endFocustime(config.apiKey);
if (!completed) {
try {
await api_1.endFocustime(config.apiKey);
}
catch (e) {
debug(e);
}
}
},

@@ -12,0 +25,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const api_1 = require("./api");
const debug_1 = require("debug");
const debug = debug_1.default('plugin:slack');
const plugin = {
async start(config) {
await Promise.all([
api_1.setDndOn(config.token, config.duration),
api_1.setStatus(config.token, {
// eslint-disable-next-line @typescript-eslint/camelcase
status_text: config.statusText,
// eslint-disable-next-line @typescript-eslint/camelcase
status_emoji: config.statusEmoji,
}),
]);
try {
await Promise.all([
api_1.setDndOn(config.token, config.duration),
api_1.setStatus(config.token, {
// eslint-disable-next-line @typescript-eslint/camelcase
status_text: config.statusText,
// eslint-disable-next-line @typescript-eslint/camelcase
status_emoji: config.statusEmoji,
}),
]);
}
catch (e) {
debug(e);
}
},

@@ -16,0 +23,0 @@ async stop(config, completed) {

@@ -5,8 +5,10 @@ "use strict";

const exec_script_1 = require("../../util/exec-script");
const debug_1 = require("debug");
const debug = debug_1.default('plugin:spotify');
const plugin = {
async start() {
child_process_1.exec(`osascript -l JavaScript ${exec_script_1.script('spotify', 'play-spotify.js')}`, exec_script_1.log);
child_process_1.exec(`osascript -l JavaScript ${exec_script_1.script('spotify', 'play-spotify.js')}`, debug);
},
async stop() {
child_process_1.exec(`osascript -l JavaScript ${exec_script_1.script('spotify', 'pause-spotify.js')}`, exec_script_1.log);
child_process_1.exec(`osascript -l JavaScript ${exec_script_1.script('spotify', 'pause-spotify.js')}`, debug);
},

@@ -13,0 +15,0 @@ };

@@ -6,2 +6,4 @@ "use strict";

const timers_1 = require("timers");
const debug_1 = require("debug");
const debug = debug_1.default('timer');
class Timer extends events_1.EventEmitter {

@@ -22,12 +24,19 @@ constructor(config, plugins) {

async start() {
debug('starting timer');
this.emit('starting', this.until);
const promises = this.plugins.map(({ name, plugin, config }) => plugin.start(config).catch(e => {
console.error(`error starting ${name} plugin: ${e}`);
}));
const promises = this.plugins.map(({ name, plugin, config }) => {
debug(`starting plugin: ${name}`);
return plugin.start(config).catch(e => {
debug(`error starting ${name} plugin: ${e}`);
});
});
try {
await Promise.all(promises);
}
catch (e) { }
catch (e) {
debug('error starting timer', e);
}
this.emit('started', this.until);
this.state = 'STARTED';
debug('started');
this.intervalId = timers_1.setInterval(async () => {

@@ -45,7 +54,12 @@ this.until -= 1;

catch (e) {
console.error('error ticking plugin');
debug('error ticking plugin', e);
}
if (!this.until && this.intervalId) {
timers_1.clearInterval(this.intervalId);
await this.stop(true);
try {
await this.stop(true);
}
catch (e) {
debug('error stopping', e);
}
}

@@ -56,9 +70,15 @@ }, 1000);

this.emit('stopping');
const promises = this.plugins.map(({ name, plugin, config }) => plugin.stop(config, completed).catch(e => {
console.error(`error stopping ${name} plugin: ${e}`);
}));
debug('stopping timer');
const promises = this.plugins.map(({ name, plugin, config }) => {
debug(`stopping plugin: ${name}`);
return plugin.stop(config, completed).catch(() => {
debug(`error stopping ${name} plugin`);
});
});
try {
await Promise.all(promises);
}
catch (e) { }
catch (e) {
debug('error stopping timer', e);
}
if (this.intervalId)

@@ -65,0 +85,0 @@ timers_1.clearInterval(this.intervalId);

@@ -1,4 +0,2 @@

import { ExecException } from 'child_process';
export declare const script: (plugin: string, file: string) => string;
export declare const log: (error: ExecException | null) => void;
export declare const execAppleScript: (plugin: string, file: string, configPath: string) => Promise<{

@@ -5,0 +3,0 @@ stdout: string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.execAppleScript = exports.log = exports.script = void 0;
exports.execAppleScript = exports.script = void 0;
const path_1 = require("path");
const child_process_1 = require("child_process");
exports.script = (plugin, file) => path_1.join(__dirname, '..', 'plugins', plugin, 'applescripts', file);
exports.log = (error) => {
if (error)
console.error(error);
};
exports.execAppleScript = (plugin, file, configPath) => new Promise((res, rej) => {

@@ -12,0 +8,0 @@ child_process_1.exec(`osascript -l JavaScript ${exports.script(plugin, file)}`, { env: { config: configPath } }, (err, stdout, stderr) => {

@@ -11,3 +11,3 @@ "use strict";

from: 'user domain',
})}/FocusMe/timerrc.json`);
})}/FocusMe/preferences.json`);
const contents = app.read(file);

@@ -14,0 +14,0 @@ return JSON.parse(contents);

@@ -9,2 +9,4 @@ "use strict";

const readFile = util_1.promisify(fs.readFile);
const debug_1 = require("debug");
const debug = debug_1.default('load-config');
const defaultConfig = {

@@ -25,3 +27,5 @@ darwin: path.join(os.homedir(), 'Library/Application Support/FocusMe/preferences.json'),

try {
debug(`loading config from: ${configPath}`);
config = JSON.parse(await readFile(configPath, 'utf8'));
debug('config found: %o', config);
}

@@ -28,0 +32,0 @@ catch (e) {

@@ -5,2 +5,4 @@ "use strict";

const path = require("path");
const debug_1 = require("debug");
const debug = debug_1.default('load-plugins');
exports.loadPlugins = (config) => {

@@ -21,3 +23,3 @@ if (!config.plugins)

catch (e) {
console.error(`could not load plugin ${pluginName}`);
debug_1.default(`could not load plugin ${pluginName}`);
throw e;

@@ -24,0 +26,0 @@ }

{
"name": "@focus-me/focus-cli",
"version": "3.0.0",
"version": "3.0.1",
"author": "Ryan Kois <ryan.kois@gmail.com>",

@@ -31,2 +31,3 @@ "repository": {

"@types/yargs": "^13.0.0",
"debug": "^4.3.2",
"find-up": "4.0.0",

@@ -39,2 +40,3 @@ "got": "^11.5.2",

"devDependencies": {
"@types/debug": "^4.1.6",
"@typescript-eslint/eslint-plugin": "^2.9.0",

@@ -41,0 +43,0 @@ "@typescript-eslint/parser": "^2.9.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc