Skip to content

Commit 2c86d4c

Browse files
author
Alex LaFroscia
committed
Initial Commit
0 parents  commit 2c86d4c

12 files changed

+242
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.DS_Store
2+
npm-debug.log
3+
node_modules

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 0.1.0 - First Release
2+
* Every feature added
3+
* Every bug fixed

LICENSE.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2014 <Your name here>
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Ember CLI Helper
2+
3+
[ember-cli]() integration in Atom.
4+
5+
![ember cli helper]()
6+
7+
The Ember CLI Helper is super easy to use. Just press `clt-alt-o` or search
8+
for `ember cli helper` in the command palette.
9+
10+
## Todo List
11+
12+
- [ ] Open `ember-cli-helper` automatically if the package uses the Ember CLI
13+
- [ ] Differentiate a task's button from the others when it is active
14+
- [ ] Use the editor's theme to get colors for success and error in the command output
15+
16+
17+
***
18+
19+
**Special thanks** to [@nickClaw](https://github.com/nickclaw/) and his
20+
[atom-grunt-runner](https://github.com/nickclaw/atom-grunt-runner)
21+
package, which was my inspiration for building this and a big help in putting it
22+
together.

keymaps/ember-cli-helper.cson

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Keybindings require three things to be fully defined: A selector that is
2+
# matched against the focused element, the keystroke and the command to
3+
# execute.
4+
#
5+
# Below is a basic keybinding which registers on all platforms by applying to
6+
# the root workspace element.
7+
8+
# For more detailed documentation see
9+
# https://atom.io/docs/latest/advanced/keymaps
10+
'.workspace':
11+
'ctrl-alt-o': 'ember-cli-helper:toggle'

lib/ember-cli-helper-view.coffee

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{View, Task, BufferedProcess} = require 'atom'
2+
3+
module.exports =
4+
class EmberCliHelperView extends View
5+
6+
@content: ->
7+
@div class: 'ember-cli-helper tool-panel panel-bottom native-key-bindings', =>
8+
@div class: 'ember-cli-btn-group', =>
9+
@button outlet: 'server', click: 'startServer', class: 'btn', 'Server'
10+
@button outlet: 'test', click: 'startTesting', class: 'btn', 'Test'
11+
@button outlet: 'exit', click: 'stopProcess', class: 'btn', 'Exit'
12+
@button outlet: 'hide', click: 'toggle', class: 'btn btn-right', 'Close'
13+
@button outlet: 'mini', click: 'minimize', class: 'btn btn-right', 'Minimize'
14+
@div outlet: 'panel', class: 'panel-body padded hidden', =>
15+
@ul outlet: 'messages', class: 'list-group'
16+
17+
initialize: ->
18+
# Register Commands
19+
atom.workspaceView.command "ember-cli-helper:toggle", => @toggle()
20+
21+
# Enable or disable the helper
22+
try
23+
ember = require("#{atom.project.getPath()}/package.json").devDependencies["ember-cli"]
24+
catch e
25+
error = e.code
26+
27+
if ember?
28+
# @toggle()
29+
else
30+
@emberProject = false
31+
@addLine "This is not an Ember CLI projet!"
32+
33+
34+
# Returns an object that can be retrieved when package is activated
35+
serialize: ->
36+
37+
38+
# Tear down any state and detach
39+
destroy: ->
40+
@detach()
41+
42+
43+
toggle: ->
44+
if @hasParent()
45+
@detach()
46+
else
47+
atom.workspaceView.prependToBottom this
48+
49+
50+
minimize: ->
51+
@panel.toggleClass 'hidden'
52+
53+
54+
startServer: ->
55+
@runCommand 'Ember CLI Server Started'.fontcolor("green"), 'server'
56+
57+
58+
startTesting: ->
59+
@runCommand 'Ember CLI Testing Started'.fontcolor("green"), 'test'
60+
61+
62+
runCommand: (message, task) ->
63+
@minimize() if @panel.hasClass 'hidden'
64+
@clearPanel()
65+
@addLine message
66+
stdout = (out) ->
67+
@addLine out
68+
exit = (code) ->
69+
atom.beep() unless code == 0
70+
@addLine "Ember CLI exited: code #{code}"
71+
try
72+
@process = new BufferedProcess
73+
command: 'ember'
74+
args: [task]
75+
options: {cwd: atom.project.getPath()}
76+
stdout: stdout.bind @
77+
exit: exit.bind @
78+
catch e
79+
@addLine "There was an error running the script"
80+
81+
82+
stopProcess: ->
83+
if @process?
84+
@process.kill()
85+
@process = null
86+
@addLine "Ember CLI Stopped".fontcolor("red")
87+
88+
89+
# Borrowed from grunt-runner by @nickclaw
90+
# https://github.com/nickclaw/atom-grunt-runner
91+
addLine: (text, type = "plain") ->
92+
[panel, messages] = [@panel, @messages]
93+
text = text.trim().replace /[\r\n]+/g, '<br />'
94+
stuckToBottom = messages.height() - panel.height() - panel.scrollTop() == 0
95+
messages.append "<li class='text-#{type}'>#{text}</li>"
96+
panel.scrollTop messages.height() if stuckToBottom
97+
98+
clearPanel: ->
99+
@messages.empty()

lib/ember-cli-helper.coffee

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
EmberCliHelperView = require './ember-cli-helper-view'
2+
3+
module.exports =
4+
emberCliHelperView: null
5+
6+
activate: (state = {}) ->
7+
@emberCliHelperView = new EmberCliHelperView(state.emberCliHelperViewState)
8+
9+
deactivate: ->
10+
@emberCliHelperView.stopProcess()
11+
@emberCliHelperView.destroy()
12+
13+
serialize: ->
14+
emberCliHelperViewState: @emberCliHelperView.serialize()

menus/ember-cli-helper.cson

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# See https://atom.io/docs/latest/creating-a-package#menus for more details
2+
'context-menu':
3+
'.overlayer':
4+
'Enable ember-cli-helper': 'ember-cli-helper:toggle'
5+
6+
'menu': [
7+
{
8+
'label': 'Packages'
9+
'submenu': [
10+
'label': 'Ember CLI'
11+
'submenu': [
12+
{ 'label': 'Toggle', 'command': 'ember-cli-helper:toggle' }
13+
]
14+
]
15+
}
16+
]

package.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "ember-cli-helper",
3+
"main": "./lib/ember-cli-helper",
4+
"version": "0.0.0",
5+
"description": "A short description of your package",
6+
"activationEvents": ["ember-cli-helper:toggle"],
7+
"repository": "https://github.com/atom/ember-cli-helper",
8+
"license": "MIT",
9+
"engines": {
10+
"atom": ">0.50.0"
11+
},
12+
"dependencies": {
13+
}
14+
}

spec/ember-cli-helper-spec.coffee

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{WorkspaceView} = require 'atom'
2+
EmberCliHelper = require '../lib/ember-cli-helper'
3+
4+
# Use the command `window:run-package-specs` (cmd-alt-ctrl-p) to run specs.
5+
#
6+
# To run a specific `it` or `describe` block add an `f` to the front (e.g. `fit`
7+
# or `fdescribe`). Remove the `f` to unfocus the block.
8+
9+
describe "EmberCliHelper", ->
10+
activationPromise = null
11+
12+
@content: ->
13+
@div class: 'ember-cli-helper tool-panel panel-bottom'
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
EmberCliHelperView = require '../lib/ember-cli-helper-view'
2+
3+
describe "EmberCliHelperView", ->
4+
it "has one valid test", ->
5+
expect("life").toBe "easy"

stylesheets/ember-cli-helper.less

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// The ui-variables file is provided by base themes provided by Atom.
2+
//
3+
// See https://github.com/atom/atom-dark-ui/blob/master/stylesheets/ui-variables.less
4+
// for a full listing of what's available.
5+
@import "ui-variables";
6+
7+
.ember-cli-helper {
8+
.panel-body {
9+
height: 95px;
10+
overflow: scroll;
11+
}
12+
.btn:focus {
13+
outline: 0;
14+
}
15+
.btn-right {
16+
float: right;
17+
}
18+
}
19+
20+
.ember-cli-btn-group:extend(.btn-group) {
21+
width: 100%;
22+
}

0 commit comments

Comments
 (0)