qualialabs / reval

Instant Meteor reloads
MIT License
98 stars 15 forks source link

Pass hostname/port #3

Closed juho closed 7 years ago

juho commented 7 years ago

Would be cool if the hostname/port could be configured per project somehow. We have a few apps that run at the same time on different ports.

veered commented 7 years ago

Yeah we're actually in a similar situation, we run our app on qualia:80. One solution is to create .revalrc that contains host:port info and when a file is modified, the plugin walks up the source tree from the file being reval'ed until it finds a .revalrc and then sends the info there.

And if it doesn't find a .revalrc it could just default to localhost:3000 as usual

jlukic commented 7 years ago

@juho The sublime plugin includes a full set of config params

https://github.com/qualialabs/reval-sublime

veered commented 7 years ago

@jlukic But you still wouldn't be able to work on multiple meteor projects at the same time with editor-wide configs

juho commented 7 years ago

Yeah, a .revalrc seems like a good cross-IDE solution. I was thinking of including it in the project settings for Sublime but that would just work for Sublime then..

veered commented 7 years ago

Haven't updated the repo yet but here's my Spacemacs implementation of using .revalrc:

(defun qlm--base-path (start-path)
  (require 'f)
  (f-traverse-upwards (lambda (path) (f-exists? (f-expand ".meteor" path))) start-path)
)

(defun qlm--base-url (base-path)
  (require 'f)
  (let ((revalrc (f-join base-path ".revalrc")))
    (if (f-exists? revalrc) (f-read-text revalrc) "localhost:3000")
  )
)

(defun qlm--url (path)
  (require 'f)
  (let ((base-path (qlm--base-path path)))
    (if base-path
        (concat "http://" (qlm--base-url base-path) "/reval/reload?filePath=" (f-relative path base-path))
        (concat "http://localhost:3000/reval/reload?filePath=" path)
    )
  )
)

(defun qlm--reload ()
  (require 'request)
  (interactive)
  (request
    (qlm--url (buffer-file-name))
    :type "POST"
    :data (buffer-string)
  )
)
veered commented 7 years ago

I've been using this the .revalrc way, and it's been working very well. Unfortunately, this needs to be implemented on an editor plugin by editor plugin basis.