Skip to content

Commit

Permalink
Workflow in nodejs using alfy. (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
endrjuskr authored Aug 11, 2019
1 parent 19de39d commit ec4ca13
Show file tree
Hide file tree
Showing 25 changed files with 6,948 additions and 6,125 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["env"]
}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ lib
bin
include
.Python
__pycache__
__pycache__
yarn-error.log
node_modules
.cache
dist
27 changes: 0 additions & 27 deletions alfred-workflow.py

This file was deleted.

23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "clockify-alfred",
"version": "1.0.0",
"main": "src/index.js",
"repository": "git@github.com:endrjuskr/alfred-clockify.git",
"author": "endrjuskr",
"license": "MIT",
"scripts": {
"dev": "parcel src/index.js",
"build": "parcel build src/index.js --target node"
},
"dependencies": {
"alfy": "^0.9.0",
"axios": "^0.19.0",
"fs": "^0.0.1-security",
"lodash": "^4.17.15"
},
"devDependencies": {
"@babel/core": "^7.5.5",
"babel-preset-env": "^1.7.0",
"parcel-bundler": "^1.12.3"
}
}
5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 18 additions & 0 deletions src/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import _ from "lodash";
import axios from "axios";

const API_URL = "https://api.clockify.me/api/v1";

export const get_workspaces = async (token) => {
const response = await axios.get(`${API_URL}/workspaces`, {
headers: {
'content-type': 'application/json',
'X-Api-Key': token
}
});

const workspaces = _.map(response.data, d => _.pick(d, ["id", "name"]));

// console.log(workspaces);
return workspaces;
}
6 changes: 6 additions & 0 deletions src/env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as fs from "fs";

export const get_config = () => {
const rawdata = fs.readFileSync('.env');
return JSON.parse(rawdata);
}
25 changes: 25 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { get_workspaces } from './api';
import { get_config } from "./env";
import * as alfy from "alfy";
import _ from "lodash";

const main = async () => {
const token = get_config().token;
const data = await get_workspaces(token);

// console.log(data);

const items = _.map(data, d => {
return {
title: d.name,
subtitle: d.id,
arg: d.id
};
});

// console.log(items);

alfy.output(items);
};

main();
Binary file removed workflow/Notify.tgz
Binary file not shown.
108 changes: 0 additions & 108 deletions workflow/__init__.py

This file was deleted.

Loading

0 comments on commit ec4ca13

Please sign in to comment.