linemanjs / lineman

Lineman helps you build fat-client JavaScript apps. It produces happiness by building assets, mocking servers, running specs on every file change
MIT License
1.18k stars 82 forks source link

Add customUrlPath config param for server task #245

Closed kgodard closed 9 years ago

kgodard commented 10 years ago

RFC - probably don't merge

We would like to be able to emulate our production paths as closely as possible in development. What we want is to mount the app at something like /development/engagement, but still hit the back-end API at /development/api/...

Using the relativeUrlRoot option, I have not been able to figure out a way to do this. It appears that the relativeUrlRoot option is used both by the api proxy and by the express server, and therefore it will only work if we want the same relative path for both servers.

This works, but I am aware that with my complete lack of "node/express"-fu, this is quite possibly the WRONG way to do this, so I'm asking for input. Is this reasonable? Or am I completely missing something obvious in the application config options?

davemo commented 10 years ago

Hey @kgodard, long time no chat :)

What does your config/application.coffee look like in reference to customUrlPath ?

kgodard commented 10 years ago

This is what my config/application.coffee file looks like at the moment, in case this sheds any light on the question:

module.exports = require(process.env['LINEMAN_MAIN']).config.extend("application",

  #Override application configuration here
  homepage:
    template: "app/templates/homepage.hb"
    dev:
      context:
        relativeUrlRoot: "/development"

  pages:
    dev:
      context:
        relativeUrlRoot: "/development"

  concat:
    js:
      separator: ";"

  server:
    base: "generated"
    web:
      port: 8000

    apiProxy:
      enabled: true
      host: "localhost"
      port: 3000

    customUrlPath: "/development/engagement"

  watch:
    less:
      files: ["<%= files.less.vendor %>", "app/css/**/*.less"]
      tasks: ["less", "concat:css"]
)
kgodard commented 10 years ago

hey man!

so funny I was pasting that just as you were asking for it :)

searls commented 10 years ago

Also keep in mind that you guys are the only people I know of that use this feature

On Tue, Apr 8, 2014 at 3:55 PM, Kim Godard notifications@github.com wrote:

This is what my config/application.coffee file looks like at the moment, in case this sheds any light on the question:

module.exports = require(process.env['LINEMAN_MAIN']).config.extend("application",
  #Override application configuration here
  homepage:
    template: "app/templates/homepage.hb"
    dev:
      context:
        relativeUrlRoot: "/development"
  pages:
    dev:
      context:
        relativeUrlRoot: "/development"
  concat:
    js:
      separator: ";"
  server:
    base: "generated"
    web:
      port: 8000
    apiProxy:
      enabled: true
      host: "localhost"
      port: 3000
    customUrlPath: "/development/engagement"
  watch:
    less:
      files: ["<%= files.less.vendor %>", "app/css/**/*.less"]
      tasks: ["less", "concat:css"]
)

Reply to this email directly or view it on GitHub: https://github.com/linemanjs/lineman/pull/245#issuecomment-39894156

kgodard commented 10 years ago

sure, if there's some way to do something like that without touching the lineman base task configs, that would be great...

davemo commented 10 years ago

So basically you just want a way to mount the express static directory so that it recognizes the customUrlPath?

davemo commented 10 years ago

Is this purely a cosmetic desire or are you intending to use this to hardcode url segments against in API calls?

kgodard commented 10 years ago

It's really about matching our weird production paths. We've had issues with image paths and things because production is running on things like /dukehes/engagement, but locally we're running off of just /

davemo commented 10 years ago

Yeah that makes sense, and development should be as close to mirroring production as possible. If it's causing pain when managing image paths in style sheets then that's definitely not ideal. Are you opposed to running against a fork of Lineman for a bit to see if this causes you any problems before we merge it?

kgodard commented 10 years ago

I don't think we'd mind that at all, but let me double-check with @jrush to confirm.

davemo commented 10 years ago

Also, could you update the relevant section in the docs: https://github.com/linemanjs/lineman-docs and submit a PR there so this change is covered? :)

kgodard commented 10 years ago

@davemo our question is, how do we do that? is it simple to run lineman off of a fork? are we talking about symlinking to it from /usr/local/lib/node_modules, or is there some npm way of setting up a fork? We don't know sh-- about node stuff :(

davemo commented 10 years ago

Oh, you can point the reference to lineman in your package.json to a git URI.

"dependencies": {
    "public": "git://github.com/user/repo.git#ref"
  , "private": "git+ssh://git@github.com:user/repo.git#ref"
}

just replace public and/or private with lineman, and the URI's pointing to your fork and ref (branch).

kgodard commented 10 years ago

yes I can certainly add the relevant info to the docs.

kgodard commented 10 years ago

oh, ok. Do I need both the public and private options? Or is that just standard convention

davemo commented 10 years ago

Those were just examples, pick one depending on if the URI you are linking to is a private repo or public.

kgodard commented 10 years ago

ok, got it.

davemo commented 10 years ago

With that in place, npm install will pull lineman from your fork.

kgodard commented 10 years ago

and it will install it locally in our app/node_modules dir, correct?

davemo commented 10 years ago

Yup!

kgodard commented 10 years ago

cool. that seems simple enough

davemo commented 10 years ago

If things work good for you, then we'll get this merged and cut a release so you can switch over to the new version instead of your fork; we've just found that server.coffee is one of the oldest areas of Lineman and it has a number of complex uses so it's been prone to fragility.

@jasonkarns has a branch that refactors it and adds tests but we haven't merged it yet. Once this has had some time in your development environment and doesn't appear to cause any other issues we'll merge it in :)

kgodard commented 10 years ago

ok fair enough, thanks

searls commented 10 years ago

Hey @kgodard should this be closed? Did something else fix your thing by now?

jewelsjacobs commented 10 years ago

I'd really like this too.

Is there any way we can get this in the new version?

My remote environment runs the app on:

http://remotehost.com/subdir/

so i want to run it locally as

http://localhost:8000/subdir/ and I have to reference all of my assets in my index.us like "/subdir/js/app.js"

but the api i want to proxy is remote and does not include /subdir/. Its totally different, ie.

http://someapihost.com:8080/api

So I could really use a way to mount my static website / assets without messing with the apiProxy.

Thanks!

searls commented 10 years ago

That depends whether it actually worked. @kgodard?

On Sat, Jul 19, 2014 at 1:14 AM, Julia Jacobs notifications@github.com wrote:

I'd really like this too. Is there any way we can get this in the new version?

Thanks!

Reply to this email directly or view it on GitHub: https://github.com/linemanjs/lineman/pull/245#issuecomment-49490044

kgodard commented 10 years ago

It ended up not being a significantly better solution than just using the “relativeUrlRoot” param in the application config, which is what we ultimately chose to do. It did seem to work though.

On Jul 19, 2014, at 12:56 AM, Justin Searls notifications@github.com<mailto:notifications@github.com> wrote:

That depends whether it actually worked. @kgodard?

On Sat, Jul 19, 2014 at 1:14 AM, Julia Jacobs notifications@github.com<mailto:notifications@github.com> wrote:

I'd really like this too. Is there any way we can get this in the new version?

Thanks!

Reply to this email directly or view it on GitHub: https://github.com/linemanjs/lineman/pull/245#issuecomment-49490044

— Reply to this email directly or view it on GitHubhttps://github.com/linemanjs/lineman/pull/245#issuecomment-49501711.

jewelsjacobs commented 10 years ago

Thats too bad :(

This is a requirement for us to maintain consistency between our local dev and remote environments.

I'll have to maintain a separate version of lineman for our team with the change which we are using now: https://github.com/rackerlabs/lineman

Which kind of stinks.

Update - oh sorry I didn't realize this change had been rejected. I just wanted to also confirm the change works and we are using this version now.

It's Monday . . . .

searls commented 10 years ago

Hey @jewelsjacobs -- I struggled to understand a little bit from your comment what you need and how lineman should work better for you. We had some additional background knowledge of @kgodard's needs which were very specific and as a result, the fact that you would like the same feature doesn't really explain to us why it's valuable.

Would you mind explaining what you'd like Lineman to do in clear, simple terms? If it's easier to just look at your fork's commits, feel free to refer me to those.