Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jun 26, 2016
0 parents commit 3ed52df
Show file tree
Hide file tree
Showing 10 changed files with 236 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{package.json,*.yml}]
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions .gitattributes
@@ -0,0 +1 @@
* text=auto
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
node_modules
Binary file added icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions index.js
@@ -0,0 +1,42 @@
'use strict';
const got = require('got');

got('https://api.npms.io/search', {
json: true,
query: {
term: process.argv[2],
size: 20
}
})
.then(res => {
const items = res.body.results
.filter(x => x.name.length > 1)
.map(x => {
return {
title: x.name,
subtitle: x.description,
arg: x.links.repository || x.links.npm,
mods: {
alt: {
arg: x.links.npm,
subtitle: 'Open the npm page instead of the GitHub repo'
}
},
quicklookurl: x.links.repository && `${x.links.repository}#readme`
};
});

console.log(JSON.stringify({items}));
})
.catch(err => {
console.log(JSON.stringify({
items: [{
title: err.name,
subtitle: err.message,
valid: false,
text: {
copy: err.stack
}
}]
}));
});
123 changes: 123 additions & 0 deletions info.plist
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>bundleid</key>
<string>com.sindresorhus.npms</string>
<key>category</key>
<string>Productivity</string>
<key>connections</key>
<dict>
<key>81E50DB1-23ED-46C6-BB73-4AA70B96FE96</key>
<array>
<dict>
<key>destinationuid</key>
<string>785375A5-6E6C-4EDE-8F20-D5B487D19AD2</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
</dict>
<key>createdby</key>
<string>Sindre Sorhus</string>
<key>description</key>
<string>Search for npm packages with npms.io</string>
<key>disabled</key>
<false/>
<key>name</key>
<string>npms</string>
<key>objects</key>
<array>
<dict>
<key>config</key>
<dict>
<key>browser</key>
<string></string>
<key>spaces</key>
<string></string>
<key>url</key>
<string>{query}</string>
<key>utf8</key>
<true/>
</dict>
<key>type</key>
<string>alfred.workflow.action.openurl</string>
<key>uid</key>
<string>785375A5-6E6C-4EDE-8F20-D5B487D19AD2</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>alfredfiltersresults</key>
<false/>
<key>argumenttype</key>
<integer>0</integer>
<key>escaping</key>
<integer>102</integer>
<key>keyword</key>
<string>npm</string>
<key>queuedelaycustom</key>
<integer>3</integer>
<key>queuedelayimmediatelyinitially</key>
<true/>
<key>queuedelaymode</key>
<integer>0</integer>
<key>queuemode</key>
<integer>2</integer>
<key>runningsubtext</key>
<string>Searching...</string>
<key>script</key>
<string>PATH=$($(echo $SHELL) -ic 'echo $PATH')
node index.js "$1"</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string>index.js</string>
<key>subtext</key>
<string></string>
<key>title</key>
<string>Search for npm packages</string>
<key>type</key>
<integer>0</integer>
<key>withspace</key>
<true/>
</dict>
<key>type</key>
<string>alfred.workflow.input.scriptfilter</string>
<key>uid</key>
<string>81E50DB1-23ED-46C6-BB73-4AA70B96FE96</string>
<key>version</key>
<integer>2</integer>
</dict>
</array>
<key>readme</key>
<string></string>
<key>uidata</key>
<dict>
<key>785375A5-6E6C-4EDE-8F20-D5B487D19AD2</key>
<dict>
<key>xpos</key>
<integer>220</integer>
<key>ypos</key>
<integer>50</integer>
</dict>
<key>81E50DB1-23ED-46C6-BB73-4AA70B96FE96</key>
<dict>
<key>xpos</key>
<integer>70</integer>
<key>ypos</key>
<integer>50</integer>
</dict>
</dict>
<key>version</key>
<string>0.0.0</string>
<key>webaddress</key>
<string>https://github.com/sindresorhus/alfred-npms</string>
</dict>
</plist>
21 changes: 21 additions & 0 deletions license
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
5 changes: 5 additions & 0 deletions package.json
@@ -0,0 +1,5 @@
{
"dependencies": {
"got": "^6.3.0"
}
}
31 changes: 31 additions & 0 deletions readme.md
@@ -0,0 +1,31 @@
# alfred-npms

> [Alfred 3](https://www.alfredapp.com) workflow to search for npm packages with [npms.io](https://npms.io)
<img src="screenshot.png" width="694">


## Install

[Install the workflow.](https://github.com/sindresorhus/alfred-npms/releases/latest)

*Requires [Node.js](https://nodejs.org) 4+ and the Alfred [Powerpack](https://www.alfredapp.com/powerpack/).*


## Usage

In Alfred, type `npm`, <kbd>Enter</kbd>, and your query, to search for packages.

Select a package and press <kbd>Enter</kbd> to go to its GitHub repo.<br>
Hold <kbd>Alt</kbd> when pressing <kbd>Enter</kbd> to go to its npm page.<br>
Press <kbd>Shift</kbd> to view its readme in Quick Look.


## Related

- [alfred-simple](https://github.com/sindresorhus/alfred-simple) - Simple theme


## License

MIT © [Sindre Sorhus](https://sindresorhus.com)
Binary file added screenshot.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3ed52df

Please sign in to comment.