componentjs / component

frontend package manager and build tool for modular web applications
https://github.com/componentjs/guide
MIT License
4.55k stars 306 forks source link

Having locals below the root & fetching private components #553

Closed prewk closed 10 years ago

prewk commented 10 years ago

Hi, I updated from an old version and I get this error message when building:

error : can not require components below the root

It seems to be originating from my set-up:

front-end/
front-end/apps/
front-end/apps/my-private-app-component/
front-end/apps/my-private-app-component/component.json
front-end/components/
front-end/components/my-private-component-1/
front-end/components/my-private-component-2/
front-end/components/my-private-component-3/

With a component.json (front-end/apps/my-private-app-component/component.json) like this:

"paths": ["../../components"],
"local": [
    "my-private-component-1",
    "my-private-component-2",
    "my-private-component-3"
]

I'm using front-end/apps to store different angular apps, that all should be able to pick and choose from our private components in front-end/components.

The apps themselves have regular dependencies (angular, for instance) that get downloaded to their respective components/ directory when building, of course.

Is this set-up not possible anymore? Can't I have my "local" components above (tree sibling, is more correct) the app's component.json file?

If not, can you give me some guidance - Do my "apps" need to share the same directory as the local components?

Thank you for an excellent utility, btw!

jonathanong commented 10 years ago

at this point, those components aren't locals but dependencies. i would just store them each in their own (private) repo and link them in development.

locals are for local components within the same app.

dominicbarnes commented 10 years ago

I don't know if this would work, but if you can't do private repos maybe you could try adding a symlink within each "app" to your shared "components" dir.

prewk commented 10 years ago

@jonathanong Okay thanks, I was hoping I could keep it simpler. Keeping all local components in separate repos instead is a hard idea to sell to my dev team but I understand it's sort of a core concept.

Could you elaborate some on what locals actually are considered to be, and where they may apply? I couldn't find a whole lot in the guides about this.

@dominicbarnes Interesting idea! Adds a bit of complexity to the dev directories I'd rather not have (symlinks in git etc) but it might be doable.

prewk commented 10 years ago

Never mind, I think I found the info I needed. I'll have to consider to host the components in a private repo instead, it seems to be the cleanest solution and it does have a lot of benefits.

jonathanong commented 10 years ago

yeah. now that we have bitbucket support, you can store these in private bitbucket repos for free!

prewk commented 10 years ago

@jonathanong Yeah, but now I can't seem to get the private hosting to work at all!

I have a public repo at lumikenterprises/color-picker (just some test component to get things going). Creating a component.json:

{
    "dependencies": {
        "lumikenterprises/color-picker": "0.0.2"
    }
}

component install installs the component, no problems. I can access https://raw.github.com/lumikenterprises/color-picker/0.0.2/component.json in the browser.

Now, I make the repo private (and wait for a while, GitHub needs a minute or two it seems). I add the remotes to component.json:

{
    "dependencies": {
        "lumikenterprises/color-picker": "0.0.2"
    },
    "remotes": [
        "https://MYUSERNAME:PASSWORD@raw.github.com"
    ]
}

DEBUG=component* component install

component-resolver remote not set - defaulting to remotes's defaults +0ms
component-resolver:locals resolving local at "/Users/oskar/lumikenterprises/app" +0ms
component-resolver resolving "app" +8ms
component-resolver:dependencies resolving dependency lumikenterprises/color-picker@0.0.2 +0ms
component-resolver:dependencies searching ["https://MYREDACTEDUSERNAME:MYREDACTEDPASSWORD@raw.github.com"] for lumikenterprises/color-picker@0.0.2 +0ms
component-resolver remaining dependencies: 1 +4ms
component-resolver remaining semver: 0 +0ms
component-resolver finished resolving locals +0ms
component-consoler Error: no remote found for dependency "lumikenterprises/color-picker@0.0.2". run `component open troubleshooting` for help.
    at Resolver.<anonymous> (/usr/local/lib/node_modules/component/node_modules/component-resolver/build/dependencies.js:504:13)
    at Generator.invoke (/usr/local/lib/node_modules/component/node_modules/component-resolver/build/index.js:141:31)
    at Generator.invoke (/usr/local/lib/node_modules/component/node_modules/component-resolver/build/index.js:79:50)
    at next (/usr/local/lib/node_modules/component/node_modules/co/index.js:77:21)
    at /usr/local/lib/node_modules/component/node_modules/co/index.js:50:5
    at Channel._call (/usr/local/lib/node_modules/component/node_modules/component-resolver/node_modules/chanel/lib/proto.js:114:3)
    at Channel.push (/usr/local/lib/node_modules/component/node_modules/component-resolver/node_modules/chanel/lib/proto.js:100:8)
    at Resolver.<anonymous> (/usr/local/lib/node_modules/component/node_modules/component-resolver/build/dependencies.js:574:8)
    at Array.forEach (native)
    at Resolver.resolveDependencies (/usr/local/lib/node_modules/component/node_modules/component-resolver/build/dependencies.js:573:21) +0ms

       error : no remote found for dependency "lumikenterprises/color-picker@0.0.2". run `component open troubleshooting` for help.

I might be misunderstanding how raw.github.com works but I note that https://MYUSERNAME:MYPASSWORD@raw.github.com/lumikenterprises/color-picker/0.0.2/component.json doesn't work (404).

I've also tried adding credentials to ~/.netrc and the environment variables to cover all bases.

Any ideas on how I should proceed with the troubleshooting?

(I made the repo public again for the sake of debugging)

edit: Same problem with bitbucket for me.

Public works fine, but if I make my repo private and add:

"remotes": [
    "https://prewk:MYPASSWORD@api.bitbucket.org"
]

or

"remotes": [
    "https://prewk:MYPASSWORD@bitbucket.org"
]

The same error occurs.

It should be noted that https://api.bitbucket.org/1.0/repositories/prewk/color-picker/raw/0.0.1/component.json is accessible with normal HTTP authentication in the browser.

I'll reopen this so it won't get buried, hopefully the answer might help someone else.

prewk commented 10 years ago

Continuing my crazy-person monologue:

I finally got Bitbucket private repos to work using the env variables found here and removing .remotes from the JSON completely: https://github.com/component/guide/blob/master/changelogs/1.0.0.md

Thank you and good bye! :)

jonathanong commented 10 years ago

i'll add that .remotes is pretty much broken right now somewhere